#1 Add CI tests using the standard test interface
Opened 10 months ago by sturivny. Modified 10 months ago
git://fedorapeople.org/~sturivny/libarchive master  into  master

Add CI tests using the standard test interface
Serhii Turivnyi • 10 months ago  
tests/Basic-sanity-test-for-libarchive/Makefile
file added
+63

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

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

+ #

+ #   Makefile of Basic-sanity-test-for-libarchive

+ #   Description: Encapsulates existing sanity tests built into the libarchive source package.

+ #   Author: Martin Cermak <mcermak@redhat.com>

+ #

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

+ #

+ #   Copyright (c) 2010 Red Hat.

+ #

+ #   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=Basic-sanity-test-for-libarchive

+ 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:           Martin Cermak <mcermak@redhat.com>" > $(METADATA)

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

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

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

+ 	@echo "Description:     Encapsulates existing sanity tests built into the libarchive source package." >> $(METADATA)

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

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

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

+ 	@echo "Requires:        libarchive nfs-utils rpm-build gcc make sharutils bzip2-devel xz-devel e2fsprogs-devel libacl-devel libattr-devel lzo-devel openssl-devel libxml2-devel" >> $(METADATA)

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

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

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

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

+ 

+ 	rhts-lint $(METADATA)

tests/Basic-sanity-test-for-libarchive/PURPOSE
file added
+3

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

+ PURPOSE of Basic-sanity-test-for-libarchive

+ Description: Encapsulates existing sanity tests built into the libarchive source package.

+ Author: Martin Cermak <mcermak@redhat.com>

tests/Basic-sanity-test-for-libarchive/runtest.sh
file added
+76

@@ -0,0 +1,76 @@

+ #!/bin/bash

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

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

+ #

+ #   runtest.sh of Basic-sanity-test-for-libarchive

+ #   Description: Encapsulates existing sanity tests built into the libarchive source package.

+ #   Author: Martin Cermak <mcermak@redhat.com>

+ #

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

+ #

+ #   Copyright (c) 2010 Red Hat.

+ #

+ #   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/lib/beakerlib/beakerlib.sh

+ 

+ PACKAGE="libarchive"

+ 

+ [ -z $HOME ] && HOME="/root"

+ 

+ rlJournalStart

+     rlPhaseStartSetup

+         rlAssertRpm $PACKAGE

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

+         rm -rf ~/rpmbuild

+         rlRun "pushd $TmpDir"

+     rlPhaseEnd

+ 

+     rlPhaseStartTest

+         rlFetchSrcForInstalled "libarchive" 0 "Download libarchive src rpm"

+ 

+         rlRun "rpm -Uvh libarchive*.rpm" 0 "Install libarchuve src rpm"

+ 

+         rlRun "pushd ~/rpmbuild/SPECS" 0 "Go to the SPEC directory"

+         rlRun "rpmbuild -bp libarchive.spec"

+         rlRun "rpmbuild -bc libarchive.spec"

+         rlRun "popd"

+ 

+ 

+         rlRun "pushd ~/rpmbuild/BUILD/libarchive-*"

+         rlRun "make &> $TmpDir/make.log" 0-255 "Make."

+         rlRun "make check &> $TmpDir/make_check.log" 0 "Make check"

+         if [[ $? -ne 0 ]]; then

+             rlRun "cat $TmpDir/make_check.log" 0 "Dump make check log"

+         fi

+         rlRun "popd"

+ 

+         rlRun "grep \"[0-9]:\ test_.*FAIL\" $TmpDir/make_check.log" 1 "Verify there was no error."

+         rlRun "grep \"Segmentation fault\" $TmpDir/make_check.log" 1 "Verify there was no segfault."

+ 

+     rlPhaseEnd

+ 

+     rlPhaseStartCleanup

+         rlBundleLogs testlogs "$TmpDir/configure.log" "$TmpDir/make.log" "$TmpDir/make_check.log"

+         rlRun "popd"

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

+         rm -rf ~/rpmbuild

+     rlPhaseEnd

+ rlJournalPrintText

+ rlJournalEnd

tests/tests.yml
file added
+28

@@ -0,0 +1,28 @@

+ ---

+ # Tests that run in classic and container contexts

+ - hosts: localhost

+   roles:

+   - role: standard-test-beakerlib

+     tags:

+     - classic

+     tests:

+     - Basic-sanity-test-for-libarchive

+     required_packages:

+     - automake          # Basic-sanity-test-for-libarchive needs this package

+     - bzip2-devel       # Basic-sanity-test-for-libarchive needs this package

+     - bison             # Basic-sanity-test-for-libarchive needs this package

+     - e2fsprogs-devel   # Basic-sanity-test-for-libarchive needs this package

+     - gcc               # Basic-sanity-test-for-libarchive needs this package

+     - lz4-devel         # Basic-sanity-test-for-libarchive needs this package

+     - libacl-devel      # Basic-sanity-test-for-libarchive needs this package

+     - libattr-devel     # Basic-sanity-test-for-libarchive needs this package

+     - libxml2-devel     # Basic-sanity-test-for-libarchive needs this package

+     - lzo-devel         # Basic-sanity-test-for-libarchive needs this package

+     - make              # Basic-sanity-test-for-libarchive needs this package

+     - nfs-utils         # Basic-sanity-test-for-libarchive needs this package

+     - openssl-devel     # Basic-sanity-test-for-libarchive needs this package

+     - rpm-build         # Basic-sanity-test-for-libarchive needs this package

+     - sharutils         # Basic-sanity-test-for-libarchive needs this package

+     - wget              # rlFetchSrcForInstalled needs this package

+     - xz-devel          # Basic-sanity-test-for-libarchive needs this package

+     - zlib-devel        # Basic-sanity-test-for-libarchive needs this package

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 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



Clone tests to your PC

$ git clone git://fedorapeople.org/~sturivny/libarchive
$ cd libarchive/



Run tests for Classic

All test should be run under the root

# tests/
# sudo ansible-playbook --tags=classic tests.yml

Snip of the example test run:

TASK [standard-test-beakerlib : Run beakerlib tests] ******************************************************************************************************************************************
changed: [localhost] => (item=Basic-sanity-test-for-libarchive)

TASK [standard-test-beakerlib : Make the master tests summary log artifact] *******************************************************************************************************************
changed: [localhost] => (item=Basic-sanity-test-for-libarchive)

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

TASK [standard-test-beakerlib : Set role result] **********************************************************************************************************************************************
ok: [localhost]

TASK [standard-test-beakerlib : include_role] *************************************************************************************************************************************************

TASK [str-common-final : Pull out the logs from test environment to test runner] **************************************************************************************************************
changed: [localhost]

TASK [str-common-final : Report role result] **************************************************************************************************************************************************
ok: [localhost] => {
    "failed_when_result": false, 
    "msg": [
        "Tests failed: False", 
        "Tests msg: ", 
        ""
    ]
}

PLAY RECAP ************************************************************************************************************************************************************************************
localhost                  : ok=33   changed=10   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 by 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: Martin Cermak mcermak@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.