Initial implementation of a start/stop test of PCP services

This commit is contained in:
Jan Kurik 2021-03-31 14:38:16 +02:00
parent 0c5b6ef698
commit 1a7f3a59d6
3 changed files with 155 additions and 0 deletions

View File

@ -0,0 +1,64 @@
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# Makefile of /tools/pcp/Sanity/pcp-services
# Description: Test of pcp services
# Author: Jan Kuřík <jkurik@redhat.com>
#
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# Copyright (c) 2021 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=/tools/pcp/Sanity/pcp-services
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)
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 Kuřík <jkurik@redhat.com>" > $(METADATA)
@echo "Name: $(TEST)" >> $(METADATA)
@echo "TestVersion: $(TESTVERSION)" >> $(METADATA)
@echo "Path: $(TEST_DIR)" >> $(METADATA)
@echo "Description: Test for BZ#1944150 (Job for pmlogger.service failed because the)" >> $(METADATA)
@echo "Type: Regression" >> $(METADATA)
@echo "TestTime: 15m" >> $(METADATA)
@echo "RunFor: pcp" >> $(METADATA)
@echo "Requires: pcp pcp-zeroconf" >> $(METADATA)
@echo "Priority: Normal" >> $(METADATA)
@echo "License: GPLv2+" >> $(METADATA)
@echo "Confidential: no" >> $(METADATA)
@echo "Destructive: no" >> $(METADATA)
@echo "Bug: 1929556 1944150" >> $(METADATA)
@echo "Releases: -RHEL4 -RHEL6 -RHELClient5 -RHELServer5" >> $(METADATA)
rhts-lint $(METADATA)

View File

@ -0,0 +1,5 @@
PURPOSE of /tools/pcp/Sanity/pcp-services
Description: Test of pcp services (start / stop)
Author: Jan Kuřík <jkurik@redhat.com>
Bug summary: Job for pmlogger.service failed because the service did not take the steps required by its unit configuration.
Bugzilla link: https://bugzilla.redhat.com/show_bug.cgi?id=1944150

View File

@ -0,0 +1,86 @@
#!/bin/bash
# vim: dict+=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# runtest.sh of /tools/pcp/Sanity/pcp-services
# Description: Test of pcp services
# Author: Jan Kuřík <jkurik@redhat.com>
#
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# Copyright (c) 2021 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/.
#
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Include Beaker environment
. /usr/bin/rhts-environment.sh || exit 1
. /usr/share/beakerlib/beakerlib.sh || exit 1
PACKAGE="pcp"
PCPSERVICES="pmlogger pmie pmproxy pmcd"
TOUT="90" # Timeout to wait for a service to start / stop
function service_action() {
local service=$1
local status=$2
local ss=
local t=${TOUT}
rlRun -s "systemctl show -p ActiveState --no-pager ${service}" 0 \
"Check if ${service} service is in expected state"
# Wait for the service to get into a proper state
while [[ "${ss}" != "${status}" ]]; do
[[ $(( t-- )) -le 0 ]] && break
sleep 1
ss=$(sed -n 's/^ActiveState=//g p' < ${rlRun_LOG})
done
if [[ "${ss}" != "${status}" ]]; then
rlFail "The ${service} service is in unexpected state '${ss}'"
return 1
else
rlPass "${service} state is OK '${ss}'"
return 0
fi
}
rlJournalStart
rlPhaseStartSetup
rlAssertRpm $PACKAGE
rlRun "systemctl --no-pager stop ${PCPSERVICES}" 0-255
rlPhaseEnd
rlPhaseStartTest
for s in ${PCPSERVICES}; do
# All services should be stopped
service_action ${s} inactive
done
for s in ${PCPSERVICES}; do
# Start a service and check it runs
rlRun "systemctl start --no-pager ${s}"
service_action ${s} active
# Stop a service and check it is stopped
rlRun "systemctl stop --no-pager ${s}"
service_action ${s} inactive
done
rlPhaseEnd
rlPhaseStartCleanup
rlPhaseEnd
rlJournalPrintText
rlJournalEnd