#1 Add CI tests using the standard test interface
Closed a year ago by sturivny. Opened 2 years ago by sturivny.
git://fedorapeople.org/~sturivny/unzip new_tests  into  master

Add CI tests using the standard test interface
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/tests.yml
file added
+14

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

+ ---

+ # Tests that run in classic context

+ - hosts: localhost

+   roles:

+   - role: standard-test-beakerlib

+     tags:

+     - classic

+     - container

+     tests:

+     - long-filename

+     required_packages:

+     - findutils         # beakerlib needs find command

+     - perl              # long-filename needs perl

+     - unzip

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:

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

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

PASS long-filename

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:

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

PLAY RECAP **********************************************************************************************************************************************************************************************************
6848c423080888193c7cf314fc7e417407adbb7323273a64a0f334393a5cff79 : ok=15   changed=11   unreachable=0    failed=0   

PASS long-filename

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.

Pull-Request has been closed by sturivny

a year ago