From 41ca4b77ae41982a1293b27f44add7abb961b59f Mon Sep 17 00:00:00 2001 From: Andrei Stepanov Date: Oct 02 2017 17:54:34 +0000 Subject: Add CI tests using the standard test interface Adds tests according to the CI wiki [0] specifically the standard test interface in the spec [1]. [0] https://fedoraproject.org/wiki/CI [1] https://fedoraproject.org/wiki/Changes/InvokingTests --- diff --git a/tests/initscript/Makefile b/tests/initscript/Makefile new file mode 100644 index 0000000..106ee79 --- /dev/null +++ b/tests/initscript/Makefile @@ -0,0 +1,64 @@ +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Makefile of /CoreOS/at/Sanity/initscript +# Description: Initscript sanity +# Author: Radek Biba +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# 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 " > $(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) diff --git a/tests/initscript/PURPOSE b/tests/initscript/PURPOSE new file mode 100644 index 0000000..7845ec7 --- /dev/null +++ b/tests/initscript/PURPOSE @@ -0,0 +1,3 @@ +PURPOSE of /CoreOS/at/Sanity/initscript +Description: Initscript sanity +Author: Radek Biba diff --git a/tests/initscript/runtest.sh b/tests/initscript/runtest.sh new file mode 100755 index 0000000..b56556d --- /dev/null +++ b/tests/initscript/runtest.sh @@ -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 +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# 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 diff --git a/tests/tests.yml b/tests/tests.yml new file mode 100644 index 0000000..7c14ca2 --- /dev/null +++ b/tests/tests.yml @@ -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