#1 Add CI tests using the standard test interface
Merged a year ago by nmav. Opened a year ago by sturivny.
git://fedorapeople.org/~sturivny/libtasn1 add-tests  into  master

Add CI tests using the standard test interface
Sergey Turivniy • a year ago  
tests/libtasn1-doesn-t-handle-OIDs-which-have-elements/Makefile
file added
+64

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

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

+ #

+ #   Makefile of /CoreOS/libtasn1/Regression/libtasn1-doesn-t-handle-OIDs-which-have-elements

+ #   Description: Test for libtasn1 doesn't handle OIDs which have elements

+ #   Author: Hubert Kario <hkario@redhat.com>

+ #

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

+ #

+ #   Copyright (c) 2016 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/libtasn1/Regression/libtasn1-doesn-t-handle-OIDs-which-have-elements

+ 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:           Hubert Kario <hkario@redhat.com>" > $(METADATA)

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

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

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

+ 	@echo "Description:     Test for libtasn1 doesn't handle OIDs which have elements" >> $(METADATA)

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

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

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

+ 	@echo "Requires:        libtasn1 libtasn1-tools openssl" >> $(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/libtasn1-doesn-t-handle-OIDs-which-have-elements/PURPOSE
file added
+6

@@ -0,0 +1,6 @@

+ PURPOSE of /CoreOS/libtasn1/Regression/libtasn1-doesn-t-handle-OIDs-which-have-elements

+ Description: Test for libtasn1 doesn't handle OIDs which have elements

+ Author: Hubert Kario <hkario@redhat.com>

+ Bug summary: libtasn1 doesn't handle OIDs which have elements of size which exceed 32-bits

+ 

+ Test that libtasn1 does handle OIDs which have elements of size which exceed 32-bits

tests/libtasn1-doesn-t-handle-OIDs-which-have-elements/runtest.sh
file added
+71

@@ -0,0 +1,71 @@

+ #!/bin/bash

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

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

+ #

+ #   runtest.sh of /CoreOS/libtasn1/Regression/libtasn1-doesn-t-handle-OIDs-which-have-elements

+ #   Description: Test for libtasn1 doesn't handle OIDs which have elements

+ #   Author: Hubert Kario <hkario@redhat.com>

+ #

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

+ #

+ #   Copyright (c) 2016 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/bin/rhts-environment.sh || exit 1

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

+ 

+ PACKAGE="libtasn1"

+ 

+ TOP_DIR="$(rpm --eval=%{_topdir})"

+ 

+ rlJournalStart

+     rlPhaseStartSetup

+         rlAssertRpm $PACKAGE

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

+         rlRun "pushd $TmpDir"

+         rlRun "echo 'PKIX1 { }

+ 

+ DEFINITIONS IMPLICIT TAGS ::=

+ 

+ BEGIN

+ 

+ Dss-Sig-Value ::= SEQUENCE {

+     r       OBJECT IDENTIFIER,

+     s       INTEGER

+ }

+ END' > pkix.asn"

+         rlRun "echo 'dp PKIX1.Dss-Sig-Value

+ r 1.3.6.1.4.1.2312.9.2.1461701120873.1.6

+ s 255' > assign.asn1"

+     rlPhaseEnd

+ 

+     rlPhaseStartTest

+         rlRun -s "asn1Coding pkix.asn assign.asn1"

+         rlAssertGrep "1.3.6.1.4.1.2312.9.2.1461701120873.1.6" $rlRun_LOG

+         rlRun "rm $rlRun_LOG"

+         rlRun -s "openssl asn1parse -in assign.out -inform DER"

+         rlAssertGrep "1.3.6.1.4.1.2312.9.2.1461701120873.1.6" $rlRun_LOG

+     rlPhaseEnd

+ 

+     rlPhaseStartCleanup

+         rlRun "popd"

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

+     rlPhaseEnd

+ rlJournalPrintText

+ rlJournalEnd

tests/smoke-test/Makefile
file added
+68

@@ -0,0 +1,68 @@

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

+ #

+ #   Makefile of /CoreOS/libtasn1/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/libtasn1/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:        10m" >> $(METADATA)

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

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

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

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

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

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

+ 	@echo "Releases:        -RHEL3 -RHEL4 -RHELServer5 -RHELClient5" >> $(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/libtasn1/Sanity/smoke-test

+ Description: Test calls upstream test suite.

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

tests/smoke-test/make_check.out
file added
empty or binary file added
tests/smoke-test/runtest.sh
file added
+74

@@ -0,0 +1,74 @@

+ #!/bin/bash

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

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

+ #

+ #   runtest.sh of /CoreOS/libtasn1/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 || exit 1

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

+ 

+ PACKAGE="libtasn1"

+ 

+ PACKAGES=( "libtasn1" "valgrind" )

+ 

+ TOPDIR=`rpm --eval %_topdir`

+ 

+ rlJournalStart

+ 

+     rlPhaseStartSetup     

+         for P in "${PACKAGES[@]}"; do rlAssertRpm $P || rlDie; done

+ 	rlFetchSrcForInstalled $PACKAGE

+         rlRun "dnf builddep -y libtasn1*.rpm"

+  	rlRun "rpm -ihv `ls libtasn1*.rpm`" 0

+ 	rlRun "rpmbuild -vv -bc $TOPDIR/SPECS/libtasn1.spec" 0

+     rlPhaseEnd

+ 

+     rlPhaseStartTest

+ 

+ 	rlRun "make -C $TOPDIR/BUILD/libtasn1-* check > make_check.out" 0

+ 	cat make_check.out	

+ 

+ 	if grep "All [0-9]\+ tests passed" make_check.out; then

+             rlPass "All tests passed -- have seen the old format of test summary in the output"

+         elif grep "Testsuite summary" make_check.out; then

+             TOTAL=`sed -rn 's/^# TOTAL: *([0-9]*).*/\1/p' make_check.out`

+             PASS=`sed -rn 's/^# PASS: *([0-9]*).*/\1/p' make_check.out`

+             rlAssertEquals "The number of tests that ran and passed should be equal" "$TOTAL" "$PASS"

+         else

+             rlFail "Tests reported summary in an unknown way"

+             rlBundleLogs make_check.out

+         fi

+ 

+     rlPhaseEnd

+ 

+     rlPhaseStartCleanup

+ 	rlRun "rm libtasn1*.rpm -rf" 0

+ 	rlRun "rm $TOPDIR/BUILD/libtasn1-* -rf" 0

+     rlPhaseEnd

+ 

+ rlJournalPrintText

+ 

+ rlJournalEnd

tests/tests.yml
file added
+17

@@ -0,0 +1,17 @@

+ ---

+ - hosts: localhost

+   roles:

+   - role: standard-test-beakerlib

+     tags:

+     - classic

+     - container

+     tests:

+     - libtasn1-doesn-t-handle-OIDs-which-have-elements

+     required_packages:

+     - libtasn1

+     - libtasn1-devel

+     - libtasn1-tools

+     - openssl

+     - valgrind

+     - nfs-utils

+     - rpm-build

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



Clone tests to you PC

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



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 : Copy tests to target] ***************************************************************************************************************************************************************
changed: [localhost]

TASK [standard-test-beakerlib : Fix up beakerlib] *******************************************************************************************************************************************************************
changed: [localhost]

TASK [standard-test-beakerlib : Make artifacts directory] ***********************************************************************************************************************************************************
changed: [localhost]

TASK [standard-test-beakerlib : Execute beakerlib tests] ************************************************************************************************************************************************************
changed: [localhost] => (item=libtasn1-doesn-t-handle-OIDs-which-have-elements)

TASK [standard-test-beakerlib : Make the master test summary log artifact] ******************************************************************************************************************************************
changed: [localhost] => (item=libtasn1-doesn-t-handle-OIDs-which-have-elements)

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

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

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



Run tests for Container

All test should be run under the root

# export ANSIBLE_INVENTORY=$(test -e inventory && echo inventory || echo /usr/share/ansible/inventory)
# export TEST_SUBJECTS=docker:docker.io/library/fedora:27
# ansible-playbook --tags=container tests.yml

Snip of the example test run:

TASK [standard-test-beakerlib : Copy tests to target] ***************************************************************************************************************************************************************
changed: [53620e3616aa540cad01fe0d1b379f1c21dee3884c914c017833b1849a514834]

TASK [standard-test-beakerlib : Fix up beakerlib] *******************************************************************************************************************************************************************
changed: [53620e3616aa540cad01fe0d1b379f1c21dee3884c914c017833b1849a514834]

TASK [standard-test-beakerlib : Make artifacts directory] ***********************************************************************************************************************************************************
changed: [53620e3616aa540cad01fe0d1b379f1c21dee3884c914c017833b1849a514834]

TASK [standard-test-beakerlib : Execute beakerlib tests] ************************************************************************************************************************************************************
changed: [53620e3616aa540cad01fe0d1b379f1c21dee3884c914c017833b1849a514834] => (item=libtasn1-doesn-t-handle-OIDs-which-have-elements)

TASK [standard-test-beakerlib : Make the master test summary log artifact] ******************************************************************************************************************************************
changed: [53620e3616aa540cad01fe0d1b379f1c21dee3884c914c017833b1849a514834] => (item=libtasn1-doesn-t-handle-OIDs-which-have-elements)

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

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

PLAY RECAP **********************************************************************************************************************************************************************************************************
53620e3616aa540cad01fe0d1b379f1c21dee3884c914c017833b1849a514834 : ok=15   changed=11   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: Hubert Kario hkario@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.

Pull-Request has been merged by nmav

a year ago