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

Add CI tests using the standard test interface
Serhii Turivny • a year ago  
tests/null-length-files/Makefile
file added
+61

@@ -0,0 +1,61 @@

+ # 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=ncompress

+ 

+ # The path of the test below the package:

+ # FIXME: you wil need to change this:

+ RELATIVE_PATH=null-length-files

+ 

+ # 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 Sklenar <psklenar@redhat.com>" > $(METADATA)

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

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

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

+ 	@echo "Description:  Tests for working with null length files." >> $(METADATA)

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

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

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

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

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

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

+ 	

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

tests/null-length-files/PURPOSE
file added
+2

@@ -0,0 +1,2 @@

+ Tests to confirm compress works properly with files with size of zero bytes.

+ 

tests/null-length-files/runtest.sh
file added
+36

@@ -0,0 +1,36 @@

+ #!/bin/sh

+ # source the test script helpers

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

+ 

+ PACKAGE="ncompress"

+ 

+ rlJournalStart

+   rlPhaseStartSetup

+       rlAssertRpm $PACKAGE

+   rlPhaseEnd

+ 

+ rlPhaseStartTest

+   rlLog "---test 1--- output after compressing empty file"

+   rlRun "touch foo"

+   RES1=$(compress -v foo 2>&1)

+   rlRun "echo bar > foo"

+   RES2=$(compress -v foo 2>&1)

+   rlLog "Output was [ $RES1 ]"

+   rlLog "Expected   [ $RES2 ]"

+ 

+   if [ "$RES1" = "$RES2" ] 

+     then

+ 	  rlPass

+   else

+ 	  rlFail

+   fi

+   rlLog "   => $RES1"

+   rlRun "rm -f foo"

+ 

+   rlLog "---test 2--- return code after compressing empty file"

+   rlRun "touch foo"

+   rlRun "compress foo" 2 "Return code should be 2"

+ rlPhaseEnd 

+ rlJournalPrintText

+ rlJournalEnd

+ 

tests/tests.yml
file added
+32

@@ -0,0 +1,32 @@

+ - hosts: localhost

+   tags:

+   - classic

+   roles:

+   - role: standard-test-beakerlib

+     tests:

+     - null-length-files

+     - uncompress-fails-to-uncompress-a-file-it-compressed

+     required_packages:

+     - glibc-headers

+     - glibc-static

+     - ncompress

+ - hosts: localhost

+   tags:

+   - container

+   roles:

+   - role: standard-test-beakerlib

+     tests:

+     - null-length-files

+     - uncompress-fails-to-uncompress-a-file-it-compressed

+     required_packages:

+     - glibc-headers

+     - glibc-static

+     - ncompress

+ - hosts: localhost

+   tags:

+   - atomic

+   roles:

+   - role: standard-test-beakerlib

+     tests:

+     - null-length-files

+ 

tests/uncompress-fails-to-uncompress-a-file-it-compressed/Makefile
file added
+63

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

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

+ #

+ #   Makefile of /CoreOS/ncompress/uncompress-fails-to-uncompress-a-file-it-compressed

+ #   Description: Test for uncompress failing to uncompress a file it compressed

+ #   Author: Petr Sklenar <psklenar@redhat.com>

+ #

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

+ #

+ #   Copyright (c) 2012 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/ncompress/uncompress-fails-to-uncompress-a-file-it-compressed

+ export TESTVERSION=1.0

+ 

+ BUILT_FILES=

+ 

+ FILES=$(METADATA) runtest.sh Makefile PURPOSE n0q_0.tif

+ 

+ .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:           Petr Sklenar <psklenar@redhat.com>" > $(METADATA)

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

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

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

+ 	@echo "Description:     uncompress fails to uncompress a file it compressed" >> $(METADATA)

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

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

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

+ 	@echo "Requires:        ncompress glibc-static glibc-headers compat-glibc-headers compat-glibc" >> $(METADATA)

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

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

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

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

+ 

+ 	rhts-lint $(METADATA)

tests/uncompress-fails-to-uncompress-a-file-it-compressed/PURPOSE
file added
+4

@@ -0,0 +1,4 @@

+ PURPOSE of /CoreOS/ncompress/uncompress-fails-to-uncompress-a-file-it-compressed

+ Description: Test for (uncompress fails to uncompress a file it)

+ Author: Petr Sklenar <psklenar@redhat.com>

+ summary: uncompress fails to uncompress a file it compressed

tests/uncompress-fails-to-uncompress-a-file-it-compressed/n0q_0.tif
file added
empty or binary file added
tests/uncompress-fails-to-uncompress-a-file-it-compressed/runtest.sh
file added
+59

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

+ #!/bin/bash

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

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

+ #

+ #   runtest.sh of /CoreOS/ncompress/uncompress-fails-to-uncompress-a-file-it-compressed

+ #   Description: uncompress fails to uncompress a file it compressed

+ #   Author: Petr Sklenar <psklenar@redhat.com>

+ #

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

+ #

+ #   Copyright (c) 2012 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

+ . /usr/lib/beakerlib/beakerlib.sh

+ 

+ PACKAGE="ncompress"

+ 

+ rlJournalStart

+     rlPhaseStartSetup

+         rlAssertRpm $PACKAGE

+ 	rlRun "ls n0q_0.tif"

+     rlPhaseEnd

+ 

+     rlPhaseStartTest "test the bug"

+ 	rlLog "x86_64 was affected by this bug"

+ 	rlRun "/bin/cp -rf n0q_0.tif /tmp/n0q_0.tif"

+ 	sleep 1

+ 	rlRun "compress n0q_0.tif"

+ 	sleep 1

+ 	rm -rf n0q_0.tif

+ 	sleep 1

+ 	rlRun "uncompress n0q_0.tif.Z"

+ 	sleep 1

+ 	rlRun "diff /tmp/n0q_0.tif n0q_0.tif"

+     rlPhaseEnd

+ 

+     rlPhaseStartCleanup

+ 	rlRun "cp -rf /tmp/n0q_0.tif n0q_0.tif"

+         rlRun "rm -r /tmp/n0q_0.tif"

+     rlPhaseEnd

+ rlJournalPrintText

+ rlJournalEnd

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

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=44   changed=25   unreachable=0    failed=0   

PASS null-length-files
PASS uncompress-fails-to-uncompress-a-file-it-compressed
PASS null-length-files
PASS uncompress-fails-to-uncompress-a-file-it-compressed
PASS null-length-files

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 [Gathering Facts] **********************************************************************************************************************************************************************************************
ok: [578f713d45f7d00d0a7e6305e2ed821402efcbd726c19970eea36fd458b8a53b]

PLAY RECAP **********************************************************************************************************************************************************************************************************
578f713d45f7d00d0a7e6305e2ed821402efcbd726c19970eea36fd458b8a53b : ok=17   changed=11   unreachable=0    failed=0   

PASS null-length-files
PASS uncompress-fails-to-uncompress-a-file-it-compressed

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.

Thanks for the work.

I'll let this on @ovasik, but my opinion is in https://src.fedoraproject.org/rpms/gc/pull-request/1 (and cpio pull 1).

If nobody is faster or nobody will offer a help with maintain this as-is, my plan is (once time permits) separate the beakerlib tests somewhere and only reference them in the *.yml file (see ansible-doc git), at least theoretically it could work.

Closing in favor of https://pagure.io/fedora-infrastructure/issue/6695

Feel free to re-submit but to accept this we need to have someone who commits himself to take care of this form of testing.

rebased onto 460b075

a year ago