/Sanity/initscript Return values differs because some systemd things and polkit (not)installed. The main idea of test is, that the return values should not be zero, so 1 or 4 occuring is fine.
120 lines
5 KiB
Bash
Executable file
120 lines
5 KiB
Bash
Executable file
#!/bin/bash
|
|
# vim: dict=/usr/share/rhts-library/dictionary.vim cpt=.,w,b,u,t,i,k
|
|
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
#
|
|
# runtest.sh of /CoreOS/postfix/Sanity/initscript
|
|
# Description: Init script should meet LSB specifications
|
|
# Author: Jan Scotka <jscotka@redhat.com>, Yulia Kopkova <ykopkova@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/share/beakerlib/beakerlib.sh || exit 1
|
|
|
|
PACKAGE="postfix"
|
|
STATUS_LOG="test.log"
|
|
|
|
SERVICE=$PACKAGE
|
|
|
|
rlJournalStart
|
|
|
|
rlPhaseStartSetup
|
|
rlAssertRpm $PACKAGE
|
|
rlRun "useradd testuserqa" 0 "Add test user"
|
|
rlServiceStop sendmail
|
|
rlServiceStop $SERVICE
|
|
rlRun "TmpDir=\`mktemp -d\`"
|
|
rlRun "pushd $TmpDir"
|
|
rlPhaseEnd
|
|
|
|
rlPhaseStartTest
|
|
rlLog ">>>>>>>>> service start"
|
|
rlRun "service $SERVICE start" 0 " Service must start without problem"
|
|
rlRun "service $SERVICE status &>> $STATUS_LOG" 0 " Then Status command "
|
|
rlRun "service $SERVICE start" 0 " Already started service "
|
|
rlRun "service $SERVICE status &>> $STATUS_LOG" 0 " Again status command "
|
|
|
|
rlLog ">>>>>>>>> service restart"
|
|
rlRun "service $SERVICE restart" 0 " Restarting of service"
|
|
rlRun "service $SERVICE status &>> $STATUS_LOG" 0 " Status command "
|
|
|
|
rlLog ">>>>>>>>> service stop"
|
|
rlRun "service $SERVICE stop" 0 " Stopping service "
|
|
rlRun "service $SERVICE status &>> $STATUS_LOG" 3 " Status of stopped service "
|
|
rlRun "service $SERVICE stop" 0 " Stopping service again "
|
|
rlRun "service $SERVICE status &>> $STATUS_LOG" 3 " Status of stopped service "
|
|
|
|
rlServiceStart $SERVICE
|
|
sleep 10
|
|
rlAssertExists "/var/spool/postfix/pid/master.pid" "Pid file /var/spool/postfix/pid/master.pid must exist"
|
|
SERVICE_PID=`cat /var/spool/postfix/pid/master.pid`
|
|
rlRun "kill -11 $SERVICE_PID" 0 "Kill $SERVICE"
|
|
sleep 5
|
|
|
|
if rlIsRHEL '<=6'; then
|
|
EXIT_STATUS=1;
|
|
rlAssertExists "/var/spool/postfix/pid/master.pid" "Pid file /var/spool/postfix/pid/master.pid must exist after kill"
|
|
else
|
|
EXIT_STATUS=3;
|
|
fi
|
|
rlRun "service $SERVICE status &>> $STATUS_LOG" $EXIT_STATUS " Existing pid file, but service not started "
|
|
|
|
rlRun "rm -f /var/spool/postfix/pid/master.pid" 0 "Remove .pid file"
|
|
rlLog ">>>>>>>>> lock file"
|
|
|
|
if rlIsRHEL '<=6'; then
|
|
EXIT_STATUS=2;
|
|
rlAssertExists "/var/lock/subsys/$SERVICE" "Lock file /var/lock/subsys/$SERVICE must exist"
|
|
else
|
|
EXIT_STATUS=3;
|
|
fi
|
|
rlRun "service $SERVICE status &>> $STATUS_LOG" $EXIT_STATUS "Existing lock file, but service not started "
|
|
rlServiceStop $SERVICE
|
|
|
|
rlLog ">>>>>>>>> insufficient rights"
|
|
rlRun "service $SERVICE start " 0 "Starting service for restarting under nonpriv user"
|
|
# Return values differs because some systemd things and polkit (not)installed.
|
|
# The main idea of test is, that the return values should not be zero, so 1 or 4 occuring is fine.
|
|
rlRun "su testuserqa -c 'service $SERVICE restart'" 1,4 "Insufficient rights, restarting service under nonprivileged user must fail"
|
|
|
|
rlLog ">>>>>>>>> operations"
|
|
rlRun "service $SERVICE start" 0 " Service have to implement start function "
|
|
rlRun "service $SERVICE restart" 0 " Service have to implement restart function "
|
|
rlRun "service $SERVICE status &>> $STATUS_LOG" 0 " Service have to implement status function "
|
|
rlRun "service $SERVICE condrestart" 0 " Service have to implement condrestart function "
|
|
rlRun "service $SERVICE reload" 0 " Service have to implement reload function "
|
|
rlRun "service $SERVICE force-reload" 0 " Service have to implement force-reload function "
|
|
|
|
rlLog ">>>>>>>>> nonexist operations"
|
|
rlRun "service $SERVICE noexistop" 2 " Testing proper return code when nonexisting function"
|
|
|
|
rlPhaseEnd
|
|
|
|
rlPhaseStartCleanup
|
|
rlServiceRestore $SERVICE
|
|
rlServiceRestore sendmail
|
|
rlRun "userdel -fr testuserqa" 0 "Remove test user"
|
|
rlRun "popd"
|
|
rlRun "rm -r $TmpDir"
|
|
rlPhaseEnd
|
|
|
|
rlJournalPrintText
|
|
rlJournalEnd
|