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

Add CI tests using the standard interface
Serhii Turivny • 2 years ago  
tests/sanity-test-create-extract/Makefile
file added
+64

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

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

+ #

+ #   Makefile of /CoreOS/cpio/Sanity/sanity-test-create-extract

+ #   Description: it creates archive in file and extract files then

+ #   Author: Jan Scotka <jscotka@redhat.com>

+ #

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

+ #

+ #   Copyright (c) 2016 Red Hat, Inc.

+ #

+ #   This program is free software: you can redistribute it and/or

+ #   modify it under the terms of the GNU General Public License as

+ #   published by the Free Software Foundation, either version 2 of

+ #   the License, or (at your option) any later version.

+ #

+ #   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, see http://www.gnu.org/licenses/.

+ #

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

+ 

+ export TEST=/CoreOS/cpio/Sanity/sanity-test-create-extract

+ export TESTVERSION=1.1

+ 

+ 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:           Jan Scotka <jscotka@redhat.com>" > $(METADATA)

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

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

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

+ 	@echo "Description:     it creates archive in file and extract files then" >> $(METADATA)

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

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

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

+ 	@echo "Requires:        cpio tar gcc" >> $(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/sanity-test-create-extract/PURPOSE
file added
+3

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

+ PURPOSE of /CoreOS/cpio/Sanity/sanity-test-create-extract

+ Description: it creates archive in file and extract files then

+ Author: Jan Scotka <jscotka@redhat.com>

tests/sanity-test-create-extract/runtest.sh
file added
+72

@@ -0,0 +1,72 @@

+ #!/bin/bash

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

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

+ #

+ #   runtest.sh of /CoreOS/cpio/Sanity/sanity-test-create-extract

+ #   Description: it creates archive in file and extract files then

+ #   Author: Jan Scotka <jscotka@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

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

+ 

+ PACKAGE="cpio"

+ 

+ rlJournalStart

+     rlPhaseStartSetup

+         rlAssertRpm $PACKAGE

+         tmp=`mktemp -d`

+         cd $tmp

+         mkdir arch

+ # creating thousand of files 

+         rlRun 'for foo in `seq 1000`;do touch x.$foo;done'

+ # creating bigger files

+         rlRun 'for foo in `seq 10`;do dd if=/dev/zero of=y.$foo bs=1k seek=$foo count=1;ls -sh y.$foo;done'

+     rlPhaseEnd

+ 

+     rlPhaseStartTest

+         rlRun 'ls x.* | cpio -ov > arch/x.cpio'

+         rlRun 'ls y.* | cpio -ov > arch/y.cpio'

+         rlRun 'find . -type f -maxdepth 1 | cpio -ov > arch/z.cpio'

+ 

+         cd arch

+         

+         

+         rlRun 'cpio -i < x.cpio'

+         rlRun 'cpio -i < y.cpio'

+         rlLog "thereis `ls y.* |wc -w` words in y.*"

+         rlLog "thereis `ls x.* |wc -w` words in x.*"  

+         rlRun 'ls y.* |wc -w |grep 11'

+         rlRun 'ls x.* |wc -w |grep 1001'

+ 

+         rm x.* y.*

+         rlRun 'cpio -i < z.cpio'

+         rlRun 'ls * |wc -w |grep 1011'

+         cd /

+     rlPhaseEnd

+ 

+     rlPhaseStartCleanup

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

+     rlPhaseEnd

+ rlJournalPrintText

+ rlJournalEnd

tests/tests.yml
file added
+13

@@ -0,0 +1,13 @@

+ ---

+ # This first play always runs on the local staging system

+ - hosts: localhost

+   roles:

+   - role: standard-test-beakerlib

+     tags:

+     - classic

+     - container

+     tests:

+     - sanity-test-create-extract

+     required_packages:

+     - findutils         # sanity-test-create-extract needs find command

+     - cpio              # sanity-test-create-extract needs cpio command

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:

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

PASS basic-sanity
PASS selftest
PASS pam_unix
PASS Test-coverage-for-TTY-auditing
PASS ausearch-smoke
PASS sanity-test-create-extract
PASS initscript
PASS key-management
PASS pam_unix
PASS Test-coverage-for-TTY-auditing
PASS sanity-test-create-extract

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:

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

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

PASS sanity-test-create-extract

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: psklenar @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.

TBH, I'm not fan of this CI method: https://src.fedoraproject.org/rpms/gc/pull-request/1
(the same applies here, including the fact that I'm +1 if you volunteer to maintain to maintain the test-case across branches)

Let me propose a solution: Please separate this into different (dist-)git repository, so we can easily maintain the integration testing on one place, and add only necessary (few lines) of code (a) downloading the testsuite and (b) running it.

My 5 cents are: if packager is not willing to maintain tests -- there is absolutely no point in getting them in dist-git. This is not how it works.

Don't take me wrong, I'm all for having a way -- we just need sustainable solution.

From my point of view better to keep tests with the package.
So everybody can run tests.
There is the way to keep tests and package updated)

If you have such tests (which are tightly coupled with cpio, and sensitive to cpio versioning), could you propose this upstream?

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.

Pull-Request has been closed by praiskup

a year ago