#2 Add CI tests using the standard test interface
Opened 2 years ago by sturivny. Modified 2 years ago
git://fedorapeople.org/~sturivny/unzip add_tests  into  master

Add tests for Localhost Container and Atomic
Serhii Turivny • 2 years ago  
tests/long-filename/Makefile
file added
+59

@@ -0,0 +1,59 @@

+ # Example Makefile for RHTS

+ # This example is geared towards a test for a specific package

+ # It does most of the work for you, but may require further coding

+ 

+ # The toplevel namespace within which the test lives.

+ # FIXME: You will need to change this:

+ TOPLEVEL_NAMESPACE=/CoreOS

+ 

+ # The name of the package under test:

+ # FIXME: you wil need to change this:

+ PACKAGE_NAME=unzip

+ 

+ # The path of the test below the package:

+ # FIXME: you wil need to change this:

+ RELATIVE_PATH=long-filenames

+ 

+ # Version of the Test. Used with make tag.

+ export TESTVERSION=1.0

+ 

+ # The compiled namespace of the test.

+ export TEST=$(TOPLEVEL_NAMESPACE)/$(PACKAGE_NAME)/$(RELATIVE_PATH)

+ 

+ .PHONY: all install download clean

+ 

+ BUILT_FILES= # executables to be built should be added here, they will be generated on the system under test.

+ FILES=$(METADATA) \

+ 	runtest.sh \

+ 	Makefile

+ 

+ run: $(FILES) #build

+ 	./runtest.sh

+ 

+ build: $(BUILT_FILES)

+ 	chmod a+x ./runtest.sh

+ 

+ clean:

+ 	rm -f *~ $(BUILT_FILES)

+ 

+ # You may need to add other taregts e.g. to build executables from source code

+ # Add them here:

+ 

+ 

+ # Include Common Makefile

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

+ 

+ # Generate the testinfo.desc here:

+ $(METADATA): Makefile

+ 	@touch $(METADATA)

+ 	@echo "Owner:        Petr Muller <pmuller@redhat.com>" > $(METADATA)

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

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

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

+ 	@echo "Description:  unzip do not crash with filename too long." >> $(METADATA)

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

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

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

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

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

+ # You may need other fields here; see the documentation

tests/long-filename/runtest.sh
file added
+28

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

+ #!/bin/sh

+ # source the test script helpers

+ . /usr/bin/rhts_environment.sh

+ 

+ 

+ # -----------------------

+ RESULT=FAIL

+ 

+ exec 6>&1

+ exec &>$OUTPUTFILE

+ 

+ unzip `perl -e 'print "A" x 50000'` && rc=$? || rc=$?

+ if [ "$rc" -eq 10 ]

+ then

+ 	RESULT=PASS

+ 	echo "\

+ 	"

+ 	echo "RHTS> filename processed ok, no segmentation problems => PASS"

+ else

+ 	echo "\

+ 	"

+ 	echo "RHTS> some segmentation problems occured => FAIL"

+ fi

+ 

+ exec 1>&6

+ 

+ # Then file the results in the database

+ report_result "${TEST}" "${RESULT}"

tests/roles/preconditions/tasks/main.yml
file added
+11

@@ -0,0 +1,11 @@

+ ---

+ 

+ - name: install perl

+   shell: rpm-ostree install perl && rpm-ostree ex livefs

+   register: command_result

+   ignore_errors: yes

+ 

+ - name: install unzip

+   shell: rpm-ostree install unzip && rpm-ostree ex livefs

+   register: command_result

+   ignore_errors: yes

tests/tests.yml
file added
+22

@@ -0,0 +1,22 @@

+ ---

+ # Tests that run in classic context

+ - hosts: localhost

+   tags:

+   - classic

+   - container

+   roles:

+   - role: standard-test-beakerlib

+     tests:

+     - long-filename

+     required_packages:

+     - findutils         # beakerlib needs find command

+     - perl              # long-filename needs perl

+     - unzip

+ - hosts: localhost

+   tags:

+   - atomic

+   roles:

+   - role: preconditions 

+   - role: standard-test-beakerlib

+     tests:

+     - long-filename

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/unzip
$ cd unzip/



Run tests for Classic

All test should be run under the root

$ sudo ansible-playbook --tags classic tests.yml

Snip of the example test run:

TASK [standard-test-beakerlib : Execute beakerlib tests] ************************************************************************************************************************************************************
changed: [localhost] => (item=long-filename)

TASK [standard-test-beakerlib : Make the master test summary log artifact] ******************************************************************************************************************************************
changed: [localhost] => (item=long-filename)

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

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

PLAY RECAP **********************************************************************************************************************************************************************************************************
localhost                  : ok=31   changed=20   unreachable=0    failed=0   



Run tests for Container

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

Snip of the example test run:

ok: [localhost] => (item=/etc/ansible/roles/standard-test-beakerlib/files/rpm.py)

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=long-filename)

TASK [standard-test-beakerlib : Make the master test summary log artifact] ******************************************************************************************************************************************
changed: [localhost] => (item=long-filename)

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

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

PLAY RECAP **********************************************************************************************************************************************************************************************************
localhost                  : ok=31   changed=20   unreachable=0    failed=0 



Run tests for Atomic Host

$ sudo -s
# export ANSIBLE_INVENTORY=$(test -e inventory && echo inventory || echo /usr/share/ansible/inventory)
# curl -Lo atomic.qcow2 https://ftp-stud.hs-esslingen.de/pub/Mirrors/alt.fedoraproject.org/atomic/stable/Fedora-Atomic-26-20170707.1/CloudImages/x86_64/images/Fedora-Atomic-26-20170707.1.x86_64.qcow2
# sudo ansible-playbook --tags=atomic tests.yml

Snip of the example test run:

TASK [standard-test-beakerlib : Copy tests to target] ***************************************************************************************************************************************************************
changed: [/home/sturi/Programs/Images/Fedora-Atomic-26-20171030.0.x86_64.qcow2]

TASK [standard-test-beakerlib : Fix up beakerlib] *******************************************************************************************************************************************************************
changed: [/home/sturi/Programs/Images/Fedora-Atomic-26-20171030.0.x86_64.qcow2]

TASK [standard-test-beakerlib : Make artifacts directory] ***********************************************************************************************************************************************************
changed: [/home/sturi/Programs/Images/Fedora-Atomic-26-20171030.0.x86_64.qcow2]

TASK [standard-test-beakerlib : Execute beakerlib tests] ************************************************************************************************************************************************************
changed: [/home/sturi/Programs/Images/Fedora-Atomic-26-20171030.0.x86_64.qcow2] => (item=long-filename)

TASK [standard-test-beakerlib : Make the master test summary log artifact] ******************************************************************************************************************************************
changed: [/home/sturi/Programs/Images/Fedora-Atomic-26-20171030.0.x86_64.qcow2] => (item=long-filename)

TASK [standard-test-beakerlib : Pull out the logs] ******************************************************************************************************************************************************************
changed: [/home/sturi/Programs/Images/Fedora-Atomic-26-20171030.0.x86_64.qcow2]

TASK [standard-test-beakerlib : Check the results] ******************************************************************************************************************************************************************
changed: [/home/sturi/Programs/Images/Fedora-Atomic-26-20171030.0.x86_64.qcow2]

PLAY RECAP **********************************************************************************************************************************************************************************************************
/home/sturi/Programs/Images/Fedora-Atomic-26-20171030.0.x86_64.qcow2 : ok=16   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: 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.

Tests are failing in case of testing under docker container and even using atomic image (I havn't tried local run). In both cases there is problem with installation the restraint-rhts rpm because of broken dependency between rhts-* rpms and restraint-rhts rpm.

In case of new installed clean F26 system, the beakerlib tests are executed correctly in case of docker image but doesn't work correctly for atomic image where it fails on missing rpm-ostree command. So in my opinion tests are written wrong as well as the ansible playbook, because set of required packages is obviously incomplete and tests don't take care about that. Maybe I missed something, but I don't get different resolution of tests using atomic image when I run that on different virtual environments. This is really weird from my point of view as I thought that atomic image contains clean minimalistic system that does not depend on host system. So it smells like some tests run locally and some tests run inside atomic image - otherwise I don't understand this different behaviour on two different F26 systems.

Tests are failing in case of testing under docker container and even using atomic image (I havn't tried local run). In both cases there is problem with installation the restraint-rhts rpm because of broken dependency between rhts-* rpms and restraint-rhts rpm.
In case of new installed clean F26 system, the beakerlib tests are executed correctly in case of docker image but doesn't work correctly for atomic image where it fails on missing rpm-ostree command. So in my opinion tests are written wrong as well as the ansible playbook, because set of required packages is obviously incomplete and tests don't take care about that. Maybe I missed something, but I don't get different resolution of tests using atomic image when I run that on different virtual environments. This is really weird from my point of view as I thought that atomic image contains clean minimalistic system that does not depend on host system. So it smells like some tests run locally and some tests run inside atomic image - otherwise I don't understand this different behaviour on two different F26 systems.

Probably you use the old version of the __standard-test-roles___.
Try to:

# dnf update  standard-test-roles

Hi, I am having similar problems as @pstodulk:
-conflicts between rhts-* rpms and restraint-rhts rpm
-errors because of missing rpm-ostree.

#rpm -q standard-test-roles
standard-test-roles-2.6-2.fc26.noarch
# dnf update standard-test-roles
Last metadata expiration check: 0:39:54 ago on St 21. únor 2018, 07:54:51 EST.
Dependencies resolved.
Nothing to do.
Complete!