#1 Add CI tests using the standard test interface
Merged 2 years ago by kdudka. Opened 2 years ago by sturivny.
git://fedorapeople.org/~sturivny/findutils new_tests  into  master

Add CI tests using the standard test interface
Serhii Turivny • 2 years ago  
tests/smoke/Makefile
file added
+63

@@ -0,0 +1,63 @@

+ # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

+ #

+ #   Makefile of /CoreOS/findutils/Sanity/smoke

+ #   Description: Smoke test for find and xargs.

+ #   Author: Branislav Nater <bnater@redhat.com>

+ #

+ # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

+ #

+ #   Copyright (c) 2014 Red Hat, Inc. All rights reserved.

+ #

+ #   This copyrighted material is made available to anyone wishing

+ #   to use, modify, copy, or redistribute it subject to the terms

+ #   and conditions of the GNU General Public License version 2.

+ #

+ #   This program is distributed in the hope that it will be

+ #   useful, but WITHOUT ANY WARRANTY; without even the implied

+ #   warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR

+ #   PURPOSE. See the GNU General Public License for more details.

+ #

+ #   You should have received a copy of the GNU General Public

+ #   License along with this program; if not, write to the Free

+ #   Software Foundation, Inc., 51 Franklin Street, Fifth Floor,

+ #   Boston, MA 02110-1301, USA.

+ #

+ # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

+ 

+ export TEST=/CoreOS/findutils/Sanity/smoke

+ export TESTVERSION=1.0

+ 

+ BUILT_FILES=

+ 

+ FILES=$(METADATA) runtest.sh Makefile PURPOSE

+ 

+ .PHONY: all install download clean

+ 

+ run: $(FILES) build

+ 	./runtest.sh

+ 

+ build: $(BUILT_FILES)

+ 	test -x runtest.sh || chmod a+x runtest.sh

+ 

+ clean:

+ 	rm -f *~ $(BUILT_FILES)

+ 

+ 

+ include /usr/share/rhts/lib/rhts-make.include

+ 

+ $(METADATA): Makefile

+ 	@echo "Owner:           Branislav Nater <bnater@redhat.com>" > $(METADATA)

+ 	@echo "Name:            $(TEST)" >> $(METADATA)

+ 	@echo "TestVersion:     $(TESTVERSION)" >> $(METADATA)

+ 	@echo "Path:            $(TEST_DIR)" >> $(METADATA)

+ 	@echo "Description:     Smoke test for find and xargs." >> $(METADATA)

+ 	@echo "Type:            Sanity" >> $(METADATA)

+ 	@echo "TestTime:        5m" >> $(METADATA)

+ 	@echo "RunFor:          findutils" >> $(METADATA)

+ 	@echo "Requires:        findutils" >> $(METADATA)

+ 	@echo "Priority:        Normal" >> $(METADATA)

+ 	@echo "License:         GPLv2" >> $(METADATA)

+ 	@echo "Confidential:    no" >> $(METADATA)

+ 	@echo "Destructive:     no" >> $(METADATA)

+ 

+ 	rhts-lint $(METADATA)

tests/smoke/PURPOSE
file added
+3

@@ -0,0 +1,3 @@

+ PURPOSE of /CoreOS/findutils/Sanity/smoke

+ Description: Smoke test for find and xargs.

+ Author: Branislav Nater <bnater@redhat.com>

tests/smoke/runtest.sh
file added
+64

@@ -0,0 +1,64 @@

+ #!/bin/bash

+ # vim: dict=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k

+ # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

+ #

+ #   runtest.sh of /CoreOS/findutils/Sanity/smoke

+ #   Description: Smoke test for find and xargs.

+ #   Author: Branislav Nater <bnater@redhat.com>

+ #

+ # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

+ #

+ #   Copyright (c) 2014 Red Hat, Inc. All rights reserved.

+ #

+ #   This copyrighted material is made available to anyone wishing

+ #   to use, modify, copy, or redistribute it subject to the terms

+ #   and conditions of the GNU General Public License version 2.

+ #

+ #   This program is distributed in the hope that it will be

+ #   useful, but WITHOUT ANY WARRANTY; without even the implied

+ #   warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR

+ #   PURPOSE. See the GNU General Public License for more details.

+ #

+ #   You should have received a copy of the GNU General Public

+ #   License along with this program; if not, write to the Free

+ #   Software Foundation, Inc., 51 Franklin Street, Fifth Floor,

+ #   Boston, MA 02110-1301, USA.

+ #

+ # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

+ 

+ # Include rhts environment

+ . /usr/bin/rhts-environment.sh || exit 1

+ . /usr/lib/beakerlib/beakerlib.sh || exit 1

+ 

+ PACKAGE="findutils"

+ 

+ rlJournalStart

+   rlPhaseStartSetup

+     rlAssertRpm $PACKAGE

+     rlRun "TmpDir=\$(mktemp -d)" 0 "Creating tmp directory"

+     rlRun "pushd $TmpDir"

+     rlRun "touch \"file with spaces\"" 0

+     rlRun "mkdir dir" 0

+     rlRun "touch dir/file1" 0

+   rlPhaseEnd

+ 

+   rlGetTestState && {

+     rlPhaseStartTest

+       rlRun "find . -name \"file*\" -type f | tee output | wc -l > wcout" 0

+       cat output

+       rlAssertGrep 2 wcout

+       rlRun "find $TmpDir -mindepth 1 -type d | tee output | wc -l > wcout" 0

+       cat output

+       rlAssertGrep 1 wcout

+       rlRun "find $TmpDir -name \"file*\" -print0 | xargs -0 ls -l | tee output | wc -l > wcout" 0

+       cat output

+       rlAssertGrep 2 wcout

+     rlPhaseEnd

+   }

+ 

+   rlPhaseStartCleanup

+     rlRun "popd"

+     rlRun "rm -r $TmpDir" 0 "Removing tmp directory"

+   rlPhaseEnd

+ rlJournalEnd

+ rlJournalPrintText

tests/tests.yml
file added
+14

@@ -0,0 +1,14 @@

+ ---

+ # Tests which will run in all contexts

+ - hosts: localhost

+   roles:

+   - role: standard-test-beakerlib

+     tags:

+     - classic

+     - container

+     - atomic

+     tests:

+     - smoke

+     - xautofs

+     required_packages:

+     - autofs       # autofs required for xautofs test

tests/xautofs/Makefile
file added
+65

@@ -0,0 +1,65 @@

+ # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

+ #

+ #   Makefile of /CoreOS/findutils/Sanity/options/xautofs

+ #   Description: Check xautofs option

+ #   Author: Petr Splichal <psplicha@redhat.com>

+ #

+ # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

+ #

+ #   Copyright (c) 2009 Red Hat, Inc. All rights reserved.

+ #

+ #   This copyrighted material is made available to anyone wishing

+ #   to use, modify, copy, or redistribute it subject to the terms

+ #   and conditions of the GNU General Public License version 2.

+ #

+ #   This program is distributed in the hope that it will be

+ #   useful, but WITHOUT ANY WARRANTY; without even the implied

+ #   warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR

+ #   PURPOSE. See the GNU General Public License for more details.

+ #

+ #   You should have received a copy of the GNU General Public

+ #   License along with this program; if not, write to the Free

+ #   Software Foundation, Inc., 51 Franklin Street, Fifth Floor,

+ #   Boston, MA 02110-1301, USA.

+ #

+ # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

+ 

+ export TEST=/CoreOS/findutils/Sanity/options/xautofs

+ export TESTVERSION=1.0

+ 

+ BUILT_FILES=

+ 

+ FILES=$(METADATA) runtest.sh Makefile PURPOSE

+ 

+ .PHONY: all install download clean

+ 

+ run: $(FILES) build

+ 	./runtest.sh

+ 

+ build: $(BUILT_FILES)

+ 	chmod a+x runtest.sh

+ 

+ clean:

+ 	rm -f *~ $(BUILT_FILES)

+ 

+ 

+ include /usr/share/rhts/lib/rhts-make.include

+ 

+ $(METADATA): Makefile

+ 	@echo "Owner:           Branislav Nater <bnater@redhat.com>" > $(METADATA)

+ 	@echo "Name:            $(TEST)" >> $(METADATA)

+ 	@echo "TestVersion:     $(TESTVERSION)" >> $(METADATA)

+ 	@echo "Path:            $(TEST_DIR)" >> $(METADATA)

+ 	@echo "Description:     Check xautofs option" >> $(METADATA)

+ 	@echo "Type:            Sanity" >> $(METADATA)

+ 	@echo "TestTime:        10m" >> $(METADATA)

+ 	@echo "RunFor:          findutils" >> $(METADATA)

+ 	@echo "Requires:        autofs findutils" >> $(METADATA)

+ 	@echo "Priority:        Normal" >> $(METADATA)

+ 	@echo "License:         GPLv2" >> $(METADATA)

+ 	@echo "Confidential:    no" >> $(METADATA)

+ 	@echo "Destructive:     no" >> $(METADATA)

+ 	@echo "Bug:             485672 529391" >> $(METADATA)

+ 	@echo "Releases:        -RHEL3 -RHEL4" >> $(METADATA)

+ 

+ 	rhts-lint $(METADATA)

tests/xautofs/PURPOSE
file added
+8

@@ -0,0 +1,8 @@

+ PURPOSE of /CoreOS/findutils/Sanity/options/xautofs

+ Description: Check xautofs option

+ Author: Petr Splichal <psplicha@redhat.com>

+ Bug summary: [RFE] Modify find to be able to skip direct mapped autofs mounts

+ Bugzilla link: None

+ 

+ Check that the new -xautofs option works as expected: make sure

+ find does not descend into directories on autofs filesystems.

tests/xautofs/runtest.sh
file added
+90

@@ -0,0 +1,90 @@

+ #!/bin/bash

+ # vim: dict=/usr/share/rhts-library/dictionary.vim cpt=.,w,b,u,t,i,k

+ # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

+ #

+ #   runtest.sh of /CoreOS/findutils/Sanity/options/xautofs

+ #   Description: Check xautofs option

+ #   Author: Petr Splichal <psplicha@redhat.com>

+ #

+ # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

+ #

+ #   Copyright (c) 2009 Red Hat, Inc. All rights reserved.

+ #

+ #   This copyrighted material is made available to anyone wishing

+ #   to use, modify, copy, or redistribute it subject to the terms

+ #   and conditions of the GNU General Public License version 2.

+ #

+ #   This program is distributed in the hope that it will be

+ #   useful, but WITHOUT ANY WARRANTY; without even the implied

+ #   warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR

+ #   PURPOSE. See the GNU General Public License for more details.

+ #

+ #   You should have received a copy of the GNU General Public

+ #   License along with this program; if not, write to the Free

+ #   Software Foundation, Inc., 51 Franklin Street, Fifth Floor,

+ #   Boston, MA 02110-1301, USA.

+ #

+ # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

+ 

+ # Include rhts environment

+ . /usr/bin/rhts-environment.sh

+ . /usr/share/rhts-library/rhtslib.sh

+ 

+ PACKAGE="findutils"

+ 

+ MasterConf="/etc/auto.master"

+ DirectConf="/etc/auto.direct"

+ 

+ MountDir="/mnt/findutils"

+ AutomountDir="$MountDir/etc"

+ RegularDir="$MountDir/regular/directory/master"

+ 

+ rlJournalStart

+     rlPhaseStartSetup

+         rlAssertRpm $PACKAGE

+         rlAssertRpm "autofs"

+         rlRun "set -o pipefail"

+ 

+         # create dirs & back up

+         rlRun "TmpDir=\`mktemp -d\`" 0 "Creating tmp directory"

+         rlRun "mkdir -p $RegularDir" 0 "Creating regular directory"

+         rlRun "rlFileBackup $MasterConf"

+ 

+         # set up autofs

+         rlRun "echo '/- /etc/auto.direct' > $MasterConf" \

+                 0 "Setting up autofs master map"

+         rlRun "echo '$AutomountDir localhost:/etc' > $DirectConf" \

+                 0 "Setting up autofs direct map"

+ 

+         # RHEL-7 is using xfs

+         rlIsRHEL 4 5 6 && fs="ext[34]" || fs="xfs"

+ 

+         rlRun "pushd $TmpDir"

+     rlPhaseEnd

+ 

+     rlPhaseStartTest "Without -xautofs option"

+         rlRun "rlServiceStart autofs" 0 "Starting autofs"

+         rlAssertNotGrep "$AutomountDir.*$fs" "/proc/mounts"

+         rlRun "find $MountDir -noleaf -name '*master*' | tee filelist"

+         rlAssertGrep "$RegularDir" "filelist"

+         rlAssertGrep "$MountDir$MasterConf" "filelist"

+         rlAssertGrep "$AutomountDir.*$fs" "/proc/mounts"

+     rlPhaseEnd

+ 

+     rlPhaseStartTest "With -xautofs option"

+         rlRun "rlServiceStart autofs" 0 "Starting autofs"

+         rlAssertNotGrep "$AutomountDir.*$fs" "/proc/mounts"

+         rlRun "find $MountDir -xautofs -noleaf -name '*master*' | tee filelist"

+         rlAssertGrep "$RegularDir" "filelist"

+         rlAssertNotGrep "$MountDir$MasterConf" "filelist"

+         rlAssertNotGrep "$AutomountDir.*$fs" "/proc/mounts"

+     rlPhaseEnd

+ 

+     rlPhaseStartCleanup

+         rlRun "popd"

+         rlRun "rlFileRestore"

+         rlRun "rlServiceRestore autofs"

+         rlRun "rm -r $TmpDir $DirectConf $MountDir" 0 "Removing tmp files"

+     rlPhaseEnd

+ rlJournalPrintText

+ rlJournalEnd

no initial comment

Justification

Adds tests according to the CI wiki specifically the standard test interface in the spec.

The playbook includes Tier1 level test cases that have been tested in the following contexts and is passing reliably: Classic and Container. Test logs are stored in the artifacts directory.

The following steps are used to execute the tests using the standard test interface:

Test enveronment

Make sure you have installed packages from the spec

# rpm -q ansible python2-dnf libselinux-python standard-test-roles \
ansible-2.3.2.0-1.fc26.noarch \
python2-dnf-2.6.3-11.fc26.noarch \
libselinux-python-2.6-7.fc26.x86_64 \
standard-test-roles-2.4-1.fc26.noarch

Run tests for Classic

# export TEST_SUBJECTS=
# sudo ansible-playbook --tags classic tests.yml

Snip of the example test run for Classic tests:

fatal: [localhost]: FAILED! => {"changed": true, "cmd": "grep \"^FAIL\" /tmp/artifacts/test.log", "delta": "0:00:00.002027", "end": "2017-10-19 07:46:01.862481", "failed": true, "failed_when_result": true, "rc": 0, "start": "2017-10-19 07:46:01.860454", "stderr": "", "stderr_lines": [], "stdout": "FAIL xautofs", "stdout_lines": ["FAIL xautofs"]}
    to retry, use: --limit @/home/fedora/tests/findutils/tests.retry

PLAY RECAP **********************************************************************************************************************************************************************************************************
localhost                  : ok=14   changed=8    unreachable=0    failed=1   

PASS smoke
FAIL xautofs

Run tests for Container

# export TEST_SUBJECTS=docker:docker.io/library/fedora:26
# sudo ansible-playbook --tags=container tests.yml

Snip of the example test run for Container tests:

fatal: [07a62f99eb52e8497802a84b2402cf7f0642f2740141cb127b99ae82de888a56]: FAILED! => {"changed": true, "cmd": "grep \"^FAIL\" /tmp/artifacts/test.log", "delta": "0:00:01.119371", "end": "2017-10-19 07:49:28.758332", "failed": true, "failed_when_result": true, "rc": 0, "start": "2017-10-19 07:49:27.638961", "stderr": "", "stderr_lines": [], "stdout": "FAIL xautofs", "stdout_lines": ["FAIL xautofs"]}
    to retry, use: --limit @/home/fedora/tests/findutils/tests.retry

PLAY RECAP **********************************************************************************************************************************************************************************************************
07a62f99eb52e8497802a84b2402cf7f0642f2740141cb127b99ae82de888a56 : ok=14   changed=10   unreachable=0    failed=1   

PASS smoke
FAIL xautofs

Run tests for Atomic

TASK [standard-test-beakerlib : Check the results] ******************************************************************************************************************************************************************
fatal: [/home/sturi/Programs/Images/atomic.qcow2]: FAILED! => {"changed": true, "cmd": "grep \"^FAIL\" /tmp/artifacts/test.log", "delta": "0:00:00.002148", "end": "2017-10-19 08:18:06.548567", "failed": true, "failed_when_result": true, "rc": 0, "start": "2017-10-19 08:18:06.546419", "stderr": "", "stderr_lines": [], "stdout": "FAIL xautofs", "stdout_lines": ["FAIL xautofs"]}
    to retry, use: --limit @/home/sturi/Programs/rpms/findutils/tests/tests.retry

PLAY RECAP **********************************************************************************************************************************************************************************************************
/home/sturi/Programs/Images/atomic.qcow2 : ok=12   changed=9    unreachable=0    failed=1   

Notes

Tests will be enabled in CI, yet gating is currently disabled, so nothing will change. Tests will run on each dist-git commit, they are not triggered on koji builds and if you are using FMN, it should notify you of failures normally.

The RH QE maintainer contact in case you have questions: sturivny @redhat.com
The idea is that these tests become yours just as you're maintaining the package, there will of course be people around if you have questions or troubles.

Thanks for the contribution!

Pull-Request has been merged by kdudka

2 years ago