#1 Add CI tests using the standard test interface
Merged 6 years ago by tmraz. Opened 6 years ago by astepano.
git://fedorapeople.org/~astepano/at master  into  master

Add CI tests using the standard test interface
Andrei Stepanov • 6 years ago  
tests/initscript/Makefile
file added
+64
@@ -0,0 +1,64 @@

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

+ #

+ #   Makefile of /CoreOS/at/Sanity/initscript

+ #   Description: Initscript sanity

+ #   Author: Radek Biba <rbiba@redhat.com>

+ #

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

+ #

+ #   Copyright (c) 2009 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/at/Sanity/initscript

+ 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:           Radek Biba <rbiba@redhat.com>" > $(METADATA)

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

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

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

+ 	@echo "Description:     Initscript sanity" >> $(METADATA)

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

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

+ 	@echo "Releases:	-RHEL3 -RHEL4 -RHELServer5 -RHELClient5 -RedHatEnterpriseLinux3 -RedHatEnterpriseLinux4 -RedHatEnterpriseLinuxClient5 -RedHatEnterpriseLinuxServer5" >> $(METADATA)

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

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

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

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

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

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

+ 

+ 	rhts-lint $(METADATA)

tests/initscript/PURPOSE
file added
+3
@@ -0,0 +1,3 @@

+ PURPOSE of /CoreOS/at/Sanity/initscript

+ Description: Initscript sanity

+ Author: Radek Biba <rbiba@redhat.com>

tests/initscript/runtest.sh
file added
+88
@@ -0,0 +1,88 @@

+ #!/bin/bash

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

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

+ #

+ #   runtest.sh of /CoreOS/at/Sanity/initscript

+ #   Description: Initscript sanity

+ #   Author: Radek Biba <rbiba@redhat.com>

+ #

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

+ #

+ #   Copyright (c) 2009 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/share/rhts-library/rhtslib.sh

+ 

+ PACKAGE="at"

+ SERVICE="atd"

+ 

+ rlJournalStart

+     rlPhaseStartSetup "Prepare"

+         rlServiceStop $SERVICE

+     rlPhaseEnd

+     if rlIsRHEL "<7"; then

+         rlPhaseStartTest "Mandatory actions"

+             for ACTION in "start" "stop" "restart" "force-reload" "status" ; do

+                 rlRun "grep -i \"usage.*$ACTION\" /etc/init.d/$SERVICE"

+             done

+         rlPhaseEnd

+     fi

+     rlPhaseStartTest "Start"

+         rlRun "service $SERVICE start" 0

+         rlRun "service $SERVICE status" 0

+         rlRun "service $SERVICE start" 0

+         rlRun "service $SERVICE status" 0

+         rlRun "service $SERVICE restart" 0

+         rlRun "service $SERVICE status" 0

+         rlRun "service $SERVICE force-reload" 0

+         rlRun "service $SERVICE status" 0

+         rlRun "service $SERVICE try-restart" 0

+         rlRun "service $SERVICE status" 0

+     rlPhaseEnd

+     rlPhaseStartTest "Stop"

+         rlRun "service $SERVICE stop" 0

+         rlRun "service $SERVICE status" 3

+         rlRun "service $SERVICE stop" 0

+         rlRun "service $SERVICE status" 3

+         rlRun "service $SERVICE try-restart" 0

+         rlRun "service $SERVICE status" 3

+     rlPhaseEnd

+     rlPhaseStartTest "Dead service"

+         rlRun "touch /var/lock/subsys/$SERVICE"

+         rlRun "service $SERVICE status" $(

+                     if rlIsRHEL "<7"; then

+                         echo 2;

+                     else

+                         echo 3;

+                     fi

+                 )

+         rlRun "service $SERVICE start" 0

+         rlRun "service $SERVICE status" 0

+     rlPhaseEnd

+     rlPhaseStartTest "Invalid arguments"

+         rlRun "service $SERVICE" 2

+         rlRun "service $SERVICE fubar" 2

+     rlPhaseEnd

+ 

+     rlPhaseStartCleanup "Restore"

+         rlServiceRestore $SERVICE

+     rlPhaseEnd

+ rlJournalPrintText

+ rlJournalEnd

tests/tests.yml
file added
+11
@@ -0,0 +1,11 @@

+ ---

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

+ - hosts: localhost

+   roles:

+   - role: standard-test-beakerlib

+     tags:

+     - classic

+     tests:

+     - initscript

+     required_packages:

+     - at       # Required to run initscript

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

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] ***************************************************************
ok: [localhost]

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

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

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=8    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 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: rskvaril @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 tmraz

6 years ago