#1 Add CI tests using the standard test interface
Opened 2 years ago by astepano. Modified 2 years ago
git://fedorapeople.org/~astepano/libcap-ng master  into  master

Add CI tests using the standard test interface
Andrei Stepanov • 2 years ago  
tests/README.rst
file added
empty or binary file added
tests/compare-capabilities-from-captest-and-capsh/Makefile
file added
+64

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

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

+ #

+ #   Makefile of /CoreOS/libcap-ng/compare-capabilities-from-captest-and-capsh

+ #   Description: Test for captest list sys_psacct instead of sys_pacct

+ #   Author: Karel Srot <ksrot@redhat.com>

+ #

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

+ #

+ #   Copyright (c) 2015 Red Hat, Inc.

+ #

+ #   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/libcap-ng/compare-capabilities-from-captest-and-capsh

+ 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:           Karel Srot <ksrot@redhat.com>" > $(METADATA)

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

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

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

+ 	@echo "Description:     Test for captest list sys_psacct instead of sys_pacct" >> $(METADATA)

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

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

+ 	@echo "RunFor:          libcap-ng" >> $(METADATA)

+ 	@echo "Requires:        libcap-ng libcap-ng-utils" >> $(METADATA)

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

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

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

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

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

+ 

+ 	rhts-lint $(METADATA)

tests/compare-capabilities-from-captest-and-capsh/PURPOSE
file added
+9

@@ -0,0 +1,9 @@

+ PURPOSE of /CoreOS/libcap-ng/Regression/compare-capabilities-from-captest-and-capsh

+ Description: Test for captest list sys_psacct instead of sys_pacct

+ Author: Karel Srot <ksrot@redhat.com>

+ Bug summary: captest list sys_psacct instead of sys_pacct

+ 

+ The test compare textual form of capabilities listed by

+  captest --text

+ and respective capabilities converted by

+  capsh

tests/compare-capabilities-from-captest-and-capsh/runtest.sh
file added
+60

@@ -0,0 +1,60 @@

+ #!/bin/bash

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

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

+ #

+ #   runtest.sh of /CoreOS/libcap-ng/Regression/compare-capabilities-from-captest-and-capsh

+ #   Description: Test for captest list sys_psacct instead of sys_pacct

+ #   Author: Karel Srot <ksrot@redhat.com>

+ #

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

+ #

+ #   Copyright (c) 2015 Red Hat, Inc.

+ #

+ #   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 Beaker environment

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

+ 

+ PACKAGE="libcap-ng"

+ 

+ rlJournalStart

+     rlPhaseStartSetup

+         rlAssertRpm $PACKAGE

+ 	rlRun "uname -a"

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

+         rlRun "pushd $TmpDir"

+ 	rlRun "captest --text &> captest.out"

+ 	rlRun "captest &> hexadec.out"

+ 	HEXA=`awk '/^Effective:/ { print $2,$3; exit }' hexadec.out | sed 's/, //'`

+ 	rlLogInfo "hexadecimal representation of Effective capabilities: $HEXA"

+ 	rlRun "capsh --decode=$HEXA &> capsh.out"

+ 	# now convert output to a better form

+ 	rlRun "cut -d '=' -f 2 capsh.out | sed -e 's/cap_//g' -e 's/,/\\n/g' | sort > capsh_sorted.out"

+ 	rlRun "sed -e 's/35/wake_alarm/' -e 's/36/block_suspend/' -e 's/37/audit_read/' capsh_sorted.out | sort > capsh_sorted2.out" 0 "substituting unknown/numeric capabilities in the output"

+ 	rlRun "grep '^Effective' captest.out | sed -e 's/Effective: //' -e 's/, /\\n/g' | sort > captest_sorted.out"

+     rlPhaseEnd

+ 

+     rlPhaseStartTest

+ 	rlRun "diff capsh_sorted2.out captest_sorted.out" 0 "'Effective permissions listed by captest --text' and 'capsh --decode=$HEXA' should match"

+     rlPhaseEnd

+ 

+     rlPhaseStartCleanup

+         rlRun "popd"

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

+     rlPhaseEnd

+ rlJournalPrintText

+ rlJournalEnd

tests/smoke-test/Makefile
file added
+72

@@ -0,0 +1,72 @@

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

+ #

+ #   Makefile of /CoreOS/libcap-ng/Sanity/smoke-test

+ #   Description: Test calls upstream test suite.

+ #   Author: Ondrej Moris <omoris@redhat.com>

+ #

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

+ #

+ #   Copyright (c) 2010 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/libcap-ng/Sanity/smoke-test

+ 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:           Ondrej Moris <omoris@redhat.com>" > $(METADATA)

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

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

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

+ 	@echo "Description:     Test calls upstream test suite." >> $(METADATA)

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

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

+ 	@echo "RunFor:          libcap-ng" >> $(METADATA)

+ 	@echo "Requires:        libcap-ng" >> $(METADATA)

+ 	@echo "Requires:        libcap-ng-devel" >> $(METADATA)

+ 	@echo "Requires:        libattr-devel" >> $(METADATA)

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

+ 	@echo "Requires:        python-devel" >> $(METADATA)

+ 	@echo "Requires:        kernel-headers" >> $(METADATA)

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

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

+ 	@echo "Requires:        python3-devel wget rpm-build" >> $(METADATA)

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

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

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

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

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

+ 

+ 	rhts-lint $(METADATA)

tests/smoke-test/PURPOSE
file added
+3

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

+ PURPOSE of /CoreOS/libcap-ng/Sanity/smoke-test

+ Description: Test calls upstream test suite.

+ Author: Ondrej Moris <omoris@redhat.com>

tests/smoke-test/runtest.sh
file added
+93

@@ -0,0 +1,93 @@

+ #!/bin/bash

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

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

+ #

+ #   runtest.sh of /CoreOS/libcap-ng/Sanity/smoke-test

+ #   Description: Test calls upstream test suite.

+ #   Author: Ondrej Moris <omoris@redhat.com>

+ #

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

+ #

+ #   Copyright (c) 2010 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/beakerlib/beakerlib.sh

+ 

+ PACKAGE="libcap-ng"

+ 

+ TESTUSER="libcapngtestuser"

+ 

+ rlJournalStart

+ 

+     rlPhaseStartSetup

+     

+         rlAssertRpm $PACKAGE	

+ 	rlRun "useradd $TESTUSER" 0-255

+ 	rlFetchSrcForInstalled $PACKAGE

+ 

+     rlPhaseEnd

+ 

+     rlPhaseStartTest

+     

+          rlRun "cp *.rpm /tmp/libcap.src.rpm" 0

+ 

+ 	 rlRun "/sbin/runuser -s /bin/sh -c \

+                 'rpm -ihv /tmp/libcap.src.rpm' -- $TESTUSER" 0 \

+ 	     "Installing libcap-ng source RPM"

+ 	 

+          rlRun "/sbin/runuser -s /bin/sh -c \

+                 'rpmbuild -vv -bc ~/rpmbuild/SPECS/libcap-ng.spec' \

+                 -- $TESTUSER" 0 \

+ 	     "Building libcap-ng source RPM"

+ 

+          rlRun "/sbin/runuser -s /bin/sh -c \

+                 \"make -C ~/rpmbuild/BUILD/libcap-ng* check\" \

+                 >/tmp/make.check.out -- $TESTUSER" 0 \

+ 	     "Running libcap-ng self-test (as non-root user)"

+ 

+ 	 

+ 	 cat /tmp/make.check.out

+ 

+ 	if rlIsRHEL 6; then

+             rlAssertNotGrep "failed"  /tmp/make.check.out

+             rlAssertNotGrep "skipped" /tmp/make.check.out

+             rlRun "[ `grep passed /tmp/make.check.out | wc -l` -eq 2 ]" 0 "All tests should pass."

+ 	else

+ 	    rlAssertEquals "1st set of tests should pass" \

+                        `grep '# PASS:' /tmp/make.check.out | awk 'NR==1 {print $3}'` \

+                        `grep '# TOTAL:' /tmp/make.check.out | awk 'NR==1 {print $3}'`

+ 	    rlAssertEquals "2nd set of tests should pass" \

+                        `grep '# PASS:' /tmp/make.check.out | awk 'NR==2 {print $3}'` \

+                        `grep '# TOTAL:' /tmp/make.check.out | awk 'NR==2 {print $3}'`

+ 	fi

+ 	 rm -f /tmp/make.check.out

+ 	 

+     rlPhaseEnd

+ 

+     rlPhaseStartCleanup

+ 

+ 	rlRun "userdel $TESTUSER" 0

+ 	rlRun "rm -rf /home/$TESTUSER" 0

+ 

+     rlPhaseEnd

+ 

+ rlJournalPrintText

+ 

+ rlJournalEnd

tests/tests.yml
file added
+44

@@ -0,0 +1,44 @@

+ - hosts: localhost

+   tags:

+   - classic

+   roles:

+   - role: standard-test-beakerlib

+     tests:

+     - compare-capabilities-from-captest-and-capsh

+     - smoke-test

+     required_packages:

+     - gcc

+     - kernel-headers

+     - libattr-devel

+     - libcap-ng

+     - libcap-ng-devel

+     - libcap-ng-utils

+     - pkgconfig

+     - python-devel

+     - python3-devel

+     - rpm-build

+     - swig

+     - wget

+     - make

+ - hosts: localhost

+   tags:

+   - container

+   roles:

+   - role: standard-test-beakerlib

+     tests:

+     - compare-capabilities-from-captest-and-capsh

+     - smoke-test

+     required_packages:

+     - gcc

+     - kernel-headers

+     - libattr-devel

+     - libcap-ng

+     - libcap-ng-devel

+     - libcap-ng-utils

+     - pkgconfig

+     - python-devel

+     - python3-devel

+     - rpm-build

+     - swig

+     - wget

+     - make

no initial comment

Justification

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

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,
Container. Test logs are stored in the artifacts directory.

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

$ ansible-playbook --list-tags tests.yml
playbook: tests.yml

  play #1 (localhost): localhost        TAGS: [classic]
      TASK TAGS: [classic]

  play #2 (localhost): localhost        TAGS: [container]
      TASK TAGS: [container]

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

Test environment

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

    $ sudo TEST_SUBJECTS='' ansible-playbook --inventory=/usr/share/ansible/inventory --tags=classic tests.yml
    
  • For container

    $ sudo TEST_SUBJECTS=docker:docker.io/library/fedora:26 ansible-playbook --inventory=/usr/share/ansible/inventory --tags=container tests.yml
    

Snippet of test run

TASK [standard-test-beakerlib : Make the master test summary log artifact] **********************************************
changed: [localhost] => (item=compare-capabilities-from-captest-and-capsh)
changed: [localhost] => (item=smoke-test)

TASK [standard-test-beakerlib : Pull out the logs] **********************************************************************
changed: [localhost]

TASK [standard-test-beakerlib : Check the results] **********************************************************************
changed: [localhost]

PLAY [localhost] ********************************************************************************************************

TASK [Gathering Facts] **************************************************************************************************
ok: [localhost]

PLAY RECAP **************************************************************************************************************
localhost                  : ok=16   changed=9    unreachable=0    failed=0

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: ksrot @redhat.com The
idea is that these tests become yours just as you are maintaining the package,
there will of course be people around if you have questions or troubles.