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

Initial commit, adding tests for ksh
root • a year ago  
tests/func/.runtest.sh.swp
file added
empty or binary file added
tests/func/Makefile
file added
+60

@@ -0,0 +1,60 @@

+ # Makefile 

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

+ # Location: 

+ 

+ # Copyright (c) 2008 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 v.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.

+  

+ 

+ 

+ TOPLEVEL_NAMESPACE=/CoreOS

+ PACKAGE_NAME=ksh

+ RELATIVE_PATH=sanity/func

+ 

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

+ 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

+ 	@touch $(METADATA)

+ 	@echo "Owner:        Jan Scotka <jscotka@redhat.com>" > $(METADATA)

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

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

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

+ 	@echo "Description:  Try shell basic functionality" >> $(METADATA)

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

+ 	@echo "TestTime:     2h" >> $(METADATA)

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

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

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

+ #	@echo "Releases:     RHEL4 RHELServer5 RHELClient5 F8" >> $(METADATA)

+ 

+ 	rhts-lint $(METADATA)

tests/func/PURPOSE
file added
+1

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

+ Basic test of functions in Korn shell, testing purpose for Test Container Project 

\ No newline at end of file

tests/func/runtest.sh
file added
+47

@@ -0,0 +1,47 @@

+ #!/bin/bash

+ # Include rhts and rhtslib environment

+ [ -e /usr/bin/rhts-environment.sh ] && . /usr/bin/rhts-environment.sh

+ . /usr/share/beakerlib/beakerlib.sh

+ 

+ PACKAGES=${PACKAGES:-ksh}

+ SH_BIN=${SH_BIN:-ksh}

+ 

+ rlJournalStart

+ 

+     rlPhaseStartSetup "Init phase"

+         rlAssertRpm --all

+         if [ $SH_BIN == "zsh" ]; then

+                 ZSH_OPT="-i"

+         else

+                 ZSH_OPT=""

+         fi

+     rlPhaseEnd

+ 

+ 

+     rlPhaseStartTest "Test of functions"

+         rlRun "${SH_BIN} -c pwd" 0 "Checking if ${SH_BIN} do pwd command"

+         rlRun "${SH_BIN} -c unexistcommand3241" 127 "Checking if ${SH_BIN} return 127 if command doesnt exist"

+         rm /tmp/unexistfile &>/dev/null

+         rlRun "${SH_BIN} -c 'ls /tmp/unexistfile'" 2 "Checking if ${SH_BIN} return 2 if none file"

+         rlRun "${SH_BIN} -c 'echo aba| sed s/a/b/g |grep -q bbb'" 0 "Checking pipes"

+         TT=`mktemp`

+         TEXT=sometihngverylong

+         rlRun "${SH_BIN} -c 'echo $TEXT > $TT; cat $TT |grep -q $TEXT'" 0 "Checking redirecting to file"

+         rlRun " ${SH_BIN} -c 'let a=1+1;echo \$a|grep -q 2'" 0 "Checking 'let' arithmetic operation 1+1"

+ #        rlRun "${SH_BIN} -c 'sleep 100&; WC=\`jobs|wc -l\`; [[ \$WC -ge 1 ]]'" 0 "Checking process at background is running" 

+         rlRun "${SH_BIN} $ZSH_OPT -c 'sleep 100& WC=\$(jobs|wc -l) ; [[ \$WC -ge 1 ]]'" 0 "Checking process at background is running" 

+ 

+         USER=${SH_BIN}user

+         rlRun "adduser -s /bin/${SH_BIN} $USER" 0,9 "Created user with ${SH_BIN} as default shell"

+         rlRun "su -l $USER -c 'echo \$PATH'" 0 "Logged as previous created user and run echo PATH"

+     rlPhaseEnd

+ 

+     # cleanup

+     rlPhaseStartCleanup "Cleaning up"

+         rlRun "true" 0 "True action"

+         rlRun "rm $TT" 0 "Checking delete of $TT"

+         sleep 10

+         rlRun "userdel $USER" 0 "Deleted user with ${SH_BIN} as default shell"

+     rlPhaseEnd

+ rlJournalPrintText

+ rlJournalEnd

tests/tests.yml
file added
+15

@@ -0,0 +1,15 @@

+ ---

+ # Tests that run in all contexts

+ - hosts: localhost

+   roles:

+   - role: standard-test-beakerlib

+     tags:

+     - classic

+     - container

+     tests:

+     - func

+     required_packages:

+     - ksh

+     - findutils         # beakerlib needs find command

+     - which             # smoke requires which 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 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 ANSIBLE_INVENTORY=$(test -e inventory && echo inventory || echo /usr/share/ansible/inventory)
    # curl -o ksh.rpm https://kojipkgs.fedoraproject.org/packages/ksh/20120801/35.fc26/x86_64/ksh-20120801-35.fc26.x86_64.rpm
    # export TEST_SUBJECTS=$PWD/ksh.rpm
    # ansible-playbook --tags=classic tests.yml -v

Snip of the example test run for Classic tests:

TASK [standard-test-beakerlib : Check the results] ****************************************************************************************************************************************************************
changed: [rpms] => {"changed": true, "cmd": "grep \"^FAIL\" /tmp/artifacts/test.log", "delta": "0:00:00.002768", "end": "2017-11-01 12:08:56.475609", "failed": false, "failed_when_result": false, "msg": "non-zero return code", "rc": 1, "start": "2017-11-01 12:08:56.472841", "stderr": "", "stderr_lines": [], "stdout": "", "stdout_lines": []}

PLAY RECAP ********************************************************************************************************************************************************************************************************
rpms                       : ok=15   changed=9    unreachable=0    failed=0   


PASS func

::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:: [   LOG    ] :: func
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

:: [   LOG    ] :: Phases: 3 good, 0 bad
:: [   PASS   ] :: RESULT: func

Run tests for Container

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

Snip of the example test run for Classic tests:

TASK [standard-test-beakerlib : Check the results] ****************************************************************************************************************************************************************
changed: [a48199b5a6c87032cd2acd57bf8607086c337e910052ba5a70052fa763641e78] => {"changed": true, "cmd": "grep \"^FAIL\" /tmp/artifacts/test.log", "delta": "0:00:00.121856", "end": "2017-11-01 12:13:07.193028", "failed": false, "failed_when_result": false, "msg": "non-zero return code", "rc": 1, "start": "2017-11-01 12:13:07.071172", "stderr": "", "stderr_lines": [], "stdout": "", "stdout_lines": []}

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


PASS func

::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:: [   LOG    ] :: func
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

:: [   LOG    ] :: Phases: 3 good, 0 bad
:: [   PASS   ] :: RESULT: func

We would like to use a shared approach for testing POSIX shells.
See the Share Test Code proposal for more details.
I believe we can cancel this pull request.

Pull-Request has been closed by esakaiev

a year ago