From 5eb07da5ac07549f5db39455678496caca558be2 Mon Sep 17 00:00:00 2001 From: DistroBaker Date: Tue, 23 Mar 2021 12:30:30 +0000 Subject: [PATCH] Merged update from upstream sources This is an automated DistroBaker update from upstream sources. If you do not know what this is about or would like to opt out, contact the OSCI team. Source: https://src.fedoraproject.org/rpms/pcp.git#235fe8890c0e5bf4b9198c7d6e003146e719d144 --- .fmf/version | 1 + gating.yaml | 19 + pcp.spec | 9 +- plans/ci.fmf | 6 + redhat-bugzilla-1926756.patch | 205 ---------- tests/Library/pcpcommon/Makefile | 65 ++++ tests/Library/pcpcommon/lib.sh | 390 +++++++++++++++++++ tests/Library/pcpcommon/main.fmf | 13 + tests/Library/pcpcommon/runtest.sh | 55 +++ tests/README | 2 + tests/Sanity/pcp-testsuite-sanity/Makefile | 72 ++++ tests/Sanity/pcp-testsuite-sanity/PURPOSE | 3 + tests/Sanity/pcp-testsuite-sanity/bl/s390x | 2 + tests/Sanity/pcp-testsuite-sanity/main.fmf | 31 ++ tests/Sanity/pcp-testsuite-sanity/runtest.sh | 115 ++++++ 15 files changed, 775 insertions(+), 213 deletions(-) create mode 100644 .fmf/version create mode 100644 gating.yaml create mode 100644 plans/ci.fmf delete mode 100644 redhat-bugzilla-1926756.patch create mode 100644 tests/Library/pcpcommon/Makefile create mode 100755 tests/Library/pcpcommon/lib.sh create mode 100644 tests/Library/pcpcommon/main.fmf create mode 100755 tests/Library/pcpcommon/runtest.sh create mode 100644 tests/README create mode 100644 tests/Sanity/pcp-testsuite-sanity/Makefile create mode 100644 tests/Sanity/pcp-testsuite-sanity/PURPOSE create mode 100644 tests/Sanity/pcp-testsuite-sanity/bl/s390x create mode 100644 tests/Sanity/pcp-testsuite-sanity/main.fmf create mode 100755 tests/Sanity/pcp-testsuite-sanity/runtest.sh diff --git a/.fmf/version b/.fmf/version new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/.fmf/version @@ -0,0 +1 @@ +1 diff --git a/gating.yaml b/gating.yaml new file mode 100644 index 0000000..ce3cdc1 --- /dev/null +++ b/gating.yaml @@ -0,0 +1,19 @@ +--- !Policy +product_versions: + - fedora-* +decision_context: bodhi_update_push_stable +subject_type: koji_build +rules: + - !PassingTestCaseRule {test_case_name: fedora-ci.koji-build.tier0.functional} +--- !Policy +product_versions: + - rhel-8 +decision_context: osci_compose_gate +rules: + - !PassingTestCaseRule {test_case_name: baseos-ci.brew-build.tier1.functional} +--- !Policy +product_versions: + - rhel-9 +decision_context: osci_compose_gate +rules: + - !PassingTestCaseRule {test_case_name: baseos-ci.brew-build.tier1.functional} diff --git a/pcp.spec b/pcp.spec index 189b174..f46b8c6 100644 --- a/pcp.spec +++ b/pcp.spec @@ -1,6 +1,6 @@ Name: pcp Version: 5.2.5 -Release: 3%{?dist} +Release: 2%{?dist} Summary: System-level performance monitoring and performance management License: GPLv2+ and LGPLv2+ and CC-BY URL: https://pcp.io @@ -8,8 +8,6 @@ URL: https://pcp.io %global bintray https://bintray.com/artifact/download Source0: %{bintray}/pcp/source/pcp-%{version}.src.tar.gz -Patch000: redhat-bugzilla-1926756.patch - %if 0%{?fedora} >= 26 || 0%{?rhel} > 7 %global __python2 python2 %else @@ -2248,7 +2246,6 @@ updated policy package. %prep %setup -q -%patch000 -p1 %build # fix up build version @@ -3310,10 +3307,6 @@ chown -R pcp:pcp %{_logsdir}/pmproxy 2>/dev/null %files zeroconf -f pcp-zeroconf-files.rpm %changelog -* Fri Feb 12 2021 Mark Goodwin - 5.2.5-3 -- specify pmns_name in sockets PMDA Install and Remove scripts -- add selinux rules for pmcd to use netlink tcpdiag sockets (BZ 1926756) - * Wed Feb 10 2021 Nathan Scott - 5.2.5-2 - Update to latest PCP sources. - Fix pcp-dstat(1) sample count being off-by-one (BZ 1922768) diff --git a/plans/ci.fmf b/plans/ci.fmf new file mode 100644 index 0000000..1ad2c12 --- /dev/null +++ b/plans/ci.fmf @@ -0,0 +1,6 @@ +summary: CI Gating Plan +discover: + how: fmf + directory: tests +execute: + how: beakerlib diff --git a/redhat-bugzilla-1926756.patch b/redhat-bugzilla-1926756.patch deleted file mode 100644 index 779923d..0000000 --- a/redhat-bugzilla-1926756.patch +++ /dev/null @@ -1,205 +0,0 @@ -commit d7679bd7cbb94692250a450bccf9f01cb982467f -Author: Mark Goodwin -Date: Fri Feb 12 10:12:59 2021 +1100 - - selinux, qa: allow pmcd to use netlink_tcpdiag_socket for sockets PMDA - - Add SELinux rules allowing pmcd to create, setopt, bind, getattr and - nlmsg_read to netlink tcpdiag sockets. Needed by pmdasockets. - - Update qa/1622 and 917. - - Resolves: RHBZ#1926756 - -diff --git a/qa/1622 b/qa/1622 -index 83f260d6d..f62b5f89a 100755 ---- a/qa/1622 -+++ b/qa/1622 -@@ -216,6 +216,11 @@ type=AVC msg=audit(XXX.62): avc: denied { getattr open read } for pid=YYYY co - type=AVC msg=audit(XXX.63): avc: denied { connectto } for pid=YYYY comm="pmdaX" name="/" dev="tracefs" ino=1 scontext=system_u:system_r:pcp_pmlogger_t:s0 tcontext=system_u:object_r:saslauthd_t:s0 tclass=unix_stream_socket permissive=0 - type=AVC msg=audit(XXX.66): avc: denied { sys_rawio } for pid=YYYY comm="pmdaX" name="/" dev="tracefs" ino=1 scontext=system_u:system_r:pcp_pmcd_t:s0 tcontext=system_u:object_r:pcp_pmcd_t:s0 tclass=capability permissive=0 - type=AVC msg=audit(XXX.67): avc: denied { module_request } for pid=YYYY comm="pmdalinux" kmod="netdev-tun0" scontext=system_u:system_r:pcp_pmcd_t:s0 tcontext=system_u:system_r:kernel_t:s0 tclass=system permissive=0 -+type=AVC msg=audit(XXX.85): avc: denied { create } for pid=YYYY comm="ss" scontext=system_u:system_r:pcp_pmcd_t:s0 tcontext=system_u:system_r:pcp_pmcd_t:s0 tclass=netlink_tcpdiag_socket permissive=1 -+type=AVC msg=audit(XXX.86): avc: denied { setopt } for pid=YYYY comm="ss" scontext=system_u:system_r:pcp_pmcd_t:s0 tcontext=system_u:system_r:pcp_pmcd_t:s0 tclass=netlink_tcpdiag_socket permissive=1 -+type=AVC msg=audit(XXX.87): avc: denied { bind } for pid=YYYY comm="ss" scontext=system_u:system_r:pcp_pmcd_t:s0 tcontext=system_u:system_r:pcp_pmcd_t:s0 tclass=netlink_tcpdiag_socket permissive=1 -+type=AVC msg=audit(XXX.88): avc: denied { getattr } for pid=YYYY comm="ss" scontext=system_u:system_r:pcp_pmcd_t:s0 tcontext=system_u:system_r:pcp_pmcd_t:s0 tclass=netlink_tcpdiag_socket permissive=1 -+type=AVC msg=audit(XXX.89): avc: denied { nlmsg_read } for pid=YYYY comm="ss" scontext=system_u:system_r:pcp_pmcd_t:s0 tcontext=system_u:system_r:pcp_pmcd_t:s0 tclass=netlink_tcpdiag_socket permissive=1 - EOF - - echo "Silence is golden ... all AVC's are allowed by active policy" -diff --git a/qa/917.out.in b/qa/917.out.in -index 69c3b2d12..ddec57f9c 100644 ---- a/qa/917.out.in -+++ b/qa/917.out.in -@@ -125,6 +125,7 @@ Checking policies. - allow [pcp_pmcd_t] [drbd_exec_t] : [file] { execute execute_no_trans }; - allow [pcp_pmcd_t] self : [netlink_generic_socket] { bind create getattr setopt write read }; - allow [pcp_pmcd_t] [sbd_exec_t] : [file] { execute execute_no_trans }; -+ allow [pcp_pmcd_t] self : [netlink_tcpdiag_socket] { bind create getattr nlmsg_read setopt }; - allow [pcp_pmcd_t] [etc_t] : [dir] { open read search getattr lock ioctl }; - allow [pcp_pmcd_t] [shadow_t] : [file] { getattr ioctl lock open read }; - allow [pcp_pmie_t] [etc_t] : [dir] { open read search getattr lock ioctl }; -diff --git a/src/selinux/GNUlocaldefs b/src/selinux/GNUlocaldefs -index 30b67d907..cbfa34c14 100644 ---- a/src/selinux/GNUlocaldefs -+++ b/src/selinux/GNUlocaldefs -@@ -118,5 +118,7 @@ endif - - ifeq "$(PCP_SELINUX_NETLINK_GENERIC_SOCKET_CLASS)" "true" - PCP_NETLINK_GENERIC_SOCKET_CLASS="class netlink_generic_socket { bind create getattr setopt write read };" -+PCP_NETLINK_TCPDIAG_SOCKET_CLASS="class netlink_tcpdiag_socket { bind create getattr nlmsg_read setopt };" - PCP_NETLINK_GENERIC_SOCKET_RULE="allow pcp_pmcd_t self:netlink_generic_socket { bind create getattr setopt write read };" -+PCP_NETLINK_TCPDIAG_SOCKET_RULE="allow pcp_pmcd_t self:netlink_tcpdiag_socket { bind create getattr nlmsg_read setopt };" - endif -diff --git a/src/selinux/GNUmakefile b/src/selinux/GNUmakefile -index e16859d7e..d04644fcb 100644 ---- a/src/selinux/GNUmakefile -+++ b/src/selinux/GNUmakefile -@@ -80,6 +80,8 @@ $(IAM).te: $(IAM).te.in - -e 's+@PCP_ICMP_SOCKET_RULE@+'$(PCP_ICMP_SOCKET_RULE)'+' \ - -e 's+@PCP_NETLINK_GENERIC_SOCKET_CLASS@+'$(PCP_NETLINK_GENERIC_SOCKET_CLASS)'+' \ - -e 's+@PCP_NETLINK_GENERIC_SOCKET_RULE@+'$(PCP_NETLINK_GENERIC_SOCKET_RULE)'+' \ -+ -e 's+@PCP_NETLINK_TCPDIAG_SOCKET_CLASS@+'$(PCP_NETLINK_TCPDIAG_SOCKET_CLASS)'+' \ -+ -e 's+@PCP_NETLINK_TCPDIAG_SOCKET_RULE@+'$(PCP_NETLINK_TCPDIAG_SOCKET_RULE)'+' \ - -e 's+@PCP_SELINUX_MACRO_RULE@+'$(PCP_SELINUX_MACRO_RULE)'+' \ - -e 's+@PACKAGE_VERSION@+'$(PACKAGE_VERSION)'+' \ - -diff --git a/src/selinux/pcpupstream.te.in b/src/selinux/pcpupstream.te.in -index 36a043be1..d935aee36 100644 ---- a/src/selinux/pcpupstream.te.in -+++ b/src/selinux/pcpupstream.te.in -@@ -90,6 +90,7 @@ require { - @PCP_BPF_CLASS@ - class system { module_request }; - @PCP_NETLINK_GENERIC_SOCKET_CLASS@ -+ @PCP_NETLINK_TCPDIAG_SOCKET_CLASS@ - } - - #============= init_t ============== -@@ -423,3 +424,11 @@ allow pcp_pmcd_t drbd_exec_t:file { execute execute_no_trans }; - # pmda-hacluster requirements for checking sbd - # type=AVC msg=audit(XXX.81): avc: denied { execute_no_trans } for pid=421434 comm="sh" path="/usr/sbin/sbd" dev="vda1" ino=1050019 scontext=system_u:system_r:pcp_pmcd_t:s0 tcontext=system_u:object_r:sbd_exec_t:s0 tclass=file permissive=1 - @PCP_SBD_EXEC_RULE@ -+ -+#=========== pmda-sockets ============ -+# type=AVC msg=audit(XXX.85): avc: denied { create } for pid=YYYY comm="ss" scontext=system_u:system_r:pcp_pmcd_t:s0 tcontext=system_u:system_r:pcp_pmcd_t:s0 tclass=netlink_tcpdiag_socket permissive=1 -+# type=AVC msg=audit(XXX.86): avc: denied { setopt } for pid=YYYY comm="ss" scontext=system_u:system_r:pcp_pmcd_t:s0 tcontext=system_u:system_r:pcp_pmcd_t:s0 tclass=netlink_tcpdiag_socket permissive=1 -+# type=AVC msg=audit(XXX.87): avc: denied { bind } for pid=YYYY comm="ss" scontext=system_u:system_r:pcp_pmcd_t:s0 tcontext=system_u:system_r:pcp_pmcd_t:s0 tclass=netlink_tcpdiag_socket permissive=1 -+# type=AVC msg=audit(XXX.88): avc: denied { getattr } for pid=YYYY comm="ss" scontext=system_u:system_r:pcp_pmcd_t:s0 tcontext=system_u:system_r:pcp_pmcd_t:s0 tclass=netlink_tcpdiag_socket permissive=1 -+# type=AVC msg=audit(XXX.89): avc: denied { nlmsg_read } for pid=YYYY comm="ss" scontext=system_u:system_r:pcp_pmcd_t:s0 tcontext=system_u:system_r:pcp_pmcd_t:s0 tclass=netlink_tcpdiag_socket permissive=1 -+@PCP_NETLINK_TCPDIAG_SOCKET_RULE@ - -commit a49772607d80b25b2ae4b8764be709bb27d7e16f -Author: Mark Goodwin -Date: Fri Feb 12 10:09:23 2021 +1100 - - pmdasockets: minor changes to Install and Remove, add -U username - - Specify pmns_name in Install and Remove scripts since the pmda name - differs to the namespace. Add -U username for optional use when run - as a daemon. - -diff --git a/src/pmdas/linux_sockets/GNUmakefile b/src/pmdas/linux_sockets/GNUmakefile -index 34897f2e9..a32987ef7 100644 ---- a/src/pmdas/linux_sockets/GNUmakefile -+++ b/src/pmdas/linux_sockets/GNUmakefile -@@ -31,7 +31,7 @@ HFILES = indom.h cluster.h ss_stats.h - LLDLIBS = $(PCP_PMDALIB) - LCFLAGS = $(INVISIBILITY) - --SCRIPTS = Install Remove -+SCRIPTS = Install Remove Upgrade - VERSION_SCRIPT = exports - LDIRT = domain.h $(VERSION_SCRIPT) $(IAM).log - -diff --git a/src/pmdas/linux_sockets/Install b/src/pmdas/linux_sockets/Install -index 4bc934c96..28d7c7f9e 100755 ---- a/src/pmdas/linux_sockets/Install -+++ b/src/pmdas/linux_sockets/Install -@@ -1,4 +1,4 @@ --#! /bin/sh -+#!/usr/bin/sh - # - # Copyright (c) 2021 Red Hat. - # -@@ -25,6 +25,8 @@ dso_opt=true - pipe_opt=false - daemon_opt=false - -+pmns_name=network.persocket # differs to PMDA name -+ - which ss >/dev/null 2>&1 - if [ $? -ne 0 ] - then -diff --git a/src/pmdas/linux_sockets/Remove b/src/pmdas/linux_sockets/Remove -index 26edc85aa..3fee6a0e6 100755 ---- a/src/pmdas/linux_sockets/Remove -+++ b/src/pmdas/linux_sockets/Remove -@@ -1,4 +1,4 @@ --#! /bin/sh -+#!/usr/bin/sh - # - # Copyright (c) 2021 Red Hat. - # -@@ -19,6 +19,7 @@ - . $PCP_SHARE_DIR/lib/pmdaproc.sh - - iam=sockets -+pmns_name=network.persocket # differs to PMDA name - - pmdaSetup - pmdaRemove -diff --git a/src/pmdas/linux_sockets/pmda.c b/src/pmdas/linux_sockets/pmda.c -index 9bca5d9d0..fab4be290 100644 ---- a/src/pmdas/linux_sockets/pmda.c -+++ b/src/pmdas/linux_sockets/pmda.c -@@ -23,6 +23,7 @@ - #include "ss_stats.h" - - static int _isDSO = 1; /* for local contexts */ -+static char *username; - - /* metrics supported in this PMDA - see metrictab.c */ - extern pmdaMetric metrictable[]; -@@ -200,6 +201,8 @@ sockets_init(pmdaInterface *dp) - pmGetConfig("PCP_PMDAS_DIR"), sep, sep); - pmdaDSO(dp, PMDA_INTERFACE_7, "SOCKETS DSO", helppath); - } -+ else -+ pmSetProcessIdentity(username); - - if (dp->status != 0) - return; -@@ -227,12 +230,13 @@ static pmLongOptions longopts[] = { - PMOPT_DEBUG, - PMDAOPT_DOMAIN, - PMDAOPT_LOGFILE, -+ PMDAOPT_USERNAME, - PMOPT_HELP, - PMDA_OPTIONS_END - }; - - static pmdaOptions opts = { -- .short_options = "D:d:l:?", -+ .short_options = "D:d:l:U:?", - .long_options = longopts, - }; - -@@ -248,6 +252,7 @@ main(int argc, char **argv) - - _isDSO = 0; - pmSetProgname(argv[0]); -+ pmGetUsername(&username); - pmsprintf(helppath, sizeof(helppath), "%s%c" "sockets" "%c" "help", - pmGetConfig("PCP_PMDAS_DIR"), sep, sep); - pmdaDaemon(&dispatch, PMDA_INTERFACE_7, pmGetProgname(), SOCKETS, "sockets.log", helppath); -@@ -257,6 +262,8 @@ main(int argc, char **argv) - pmdaUsageMessage(&opts); - exit(1); - } -+ if (opts.username) -+ username = opts.username; - - pmdaOpenLog(&dispatch); - sockets_init(&dispatch); - diff --git a/tests/Library/pcpcommon/Makefile b/tests/Library/pcpcommon/Makefile new file mode 100644 index 0000000..cb2c8a2 --- /dev/null +++ b/tests/Library/pcpcommon/Makefile @@ -0,0 +1,65 @@ +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Makefile of /CoreOS/pcp/Library/pcpcommon +# Description: Common functions for PCP tests +# Author: Milos Prchlik +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Copyright (c) 2013 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/pcp/Library/pcpcommon +export TESTVERSION=1.0 + +BUILT_FILES= + +FILES=$(METADATA) lib.sh Makefile runtest.sh + +.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 " > $(METADATA) + @echo "Name: $(TEST)" >> $(METADATA) + @echo "TestVersion: $(TESTVERSION)" >> $(METADATA) + @echo "Path: $(TEST_DIR)" >> $(METADATA) + @echo "Description: Common functions for PCP tests" >> $(METADATA) + @echo "Provides: library(pcp/pcpcommon)" >> $(METADATA) + @echo "Type: Library" >> $(METADATA) + @echo "TestTime: 15m" >> $(METADATA) + @echo "RunFor: pcp" >> $(METADATA) + @echo "Requires: pcp pcp-testsuite" >> $(METADATA) + @echo "Releases: -RedHatEnterpriseLinux3 -RedHatEnterpriseLinux4 -RedHatEnterpriseLinuxClient5 -RedHatEnterpriseLinuxServer5" >> $(METADATA) + @echo "Priority: Normal" >> $(METADATA) + @echo "License: GPLv2" >> $(METADATA) + @echo "Confidential: no" >> $(METADATA) + @echo "Destructive: no" >> $(METADATA) + + rhts-lint $(METADATA) diff --git a/tests/Library/pcpcommon/lib.sh b/tests/Library/pcpcommon/lib.sh new file mode 100755 index 0000000..14ce5cc --- /dev/null +++ b/tests/Library/pcpcommon/lib.sh @@ -0,0 +1,390 @@ +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# lib.sh of /CoreOS/pcp/Library/pcpcommon +# Description: Common functions for PCP tests +# Author: Milos Prchlik +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Copyright (c) 2013 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. +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# library-prefix = pcpcommon +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +. /usr/share/beakerlib/beakerlib.sh + +PACKAGES="pcp" + +pcpcommon_TESTDIR="$(pwd)" + +# Set all the usefull PCP variables +pcpcommon_PCP_ENV="${pcpcommon_PCP_ENV:-/etc/pcp.env}" +for i in $(. ${pcpcommon_PCP_ENV}; set | grep '^PCP_' | grep -v '\s'); do + eval pcpcommon_$i +done + +pcpcommon_PCP_VAR_DIR=${pcpcommon_PCP_VAR_DIR:-/var/lib/pcp} +pcpcommon_PCP_PMDAS_DIR=${pcpcommon_PCP_PMDAS_DIR:-${pcpcommon_PCP_VAR_DIR}/pmdas} +pcpcommon_PCP_PMCDCONF_PATH=${pcpcommon_PCP_PMCDCONF_PATH:-/etc/pcp/pmcd/pmcd.conf} +pcpcommon_PCP_LOG_DIR=${pcpcommon_PCP_LOG_DIR:-/var/log/pcp} +pcpcommon_TESTSUITE_DIR=${pcpcommon_TESTSUITE_DIR:-${pcpcommon_PCP_VAR_DIR}/testsuite} +pcpcommon_TESTSUITE_USER="${pcpcommon_TESTSUITE_USER:-pcpqa}" +pcpcommon_TESTSUITE_USER_HOME=$(getent passwd ${pcpcommon_TESTSUITE_USER} \ + | awk -F : '{print $6}') +pcpcommon_TESTSUITE_USER_HOME="${pcpcommon_TESTSUITE_USER_HOME:-/home/${pcpcommon_TESTSUITE_USER}}" +pcpcommon_REAL_TESTSUITE_USER="${pcpcommon_TESTSUITE_USER}" + +function map_metric() { + case "$1" in + dm) + echo dmcache + ;; + *) + echo $1 + ;; + esac + + return 0 +} + +function _pcpcommon_pmda_bpftrace_setup() { + rlFileBackup --namespace pcpcommon_pcpqa "${pcpcommon_PCP_PMDAS_DIR}/bpftrace" + if rlIsRHEL '>8.2'; then + rlRun "sed -i \ + -e 's/^enabled =.*\$/enabled = true/g' \ + -e 's/^auth_enabled =.*\$/auth_enabled = false/g' \ + ${pcpcommon_PCP_PMDAS_DIR}/bpftrace/bpftrace.conf" + else + rlRun "sed -i \ + -e 's/^enabled =.*\$/enabled = false/g' \ + ${pcpcommon_PCP_PMDAS_DIR}/bpftrace/bpftrace.conf" + fi +} + +pcpcommon_PCPQA_CREATED= +pcpcommon_PCPQA_SETUP= +function pcpcommon_testsuite_user() { + # Check if we have already setup the testsuite user or not + [[ -n "${pcpcommon_PCPQA_SETUP}" ]] && return 0 + pcpcommon_PCPQA_SETUP="done" + + rlFileBackup --clean --namespace pcpcommon_pcpqa --missing-ok \ + "${pcpcommon_TESTSUITE_USER_HOME}" + if ! rlRun "id ${pcpcommon_TESTSUITE_USER}" 0,1; then + rlRun "useradd -d ${pcpcommon_TESTSUITE_USER_HOME} -m \ + -s /bin/bash -U ${pcpcommon_TESTSUITE_USER}" + rlRun "chown -R ${pcpcommon_TESTSUITE_USER}:${pcpcommon_TESTSUITE_USER} \ + ${pcpcommon_TESTSUITE_DIR}" + rlFail "User ${pcpcommon_TESTSUITE_USER} was not created by pcp packages" \ + "- see BZ#1025688" + pcpcommon_PCPQA_CREATED="yes" + fi + + # Fallback + if [[ ! -d ${pcpcommon_TESTSUITE_USER_HOME} ]]; then + rlRun "mkdir -p ${pcpcommon_TESTSUITE_USER_HOME}" + fi + + # Make sure all the testsuite files are owned by pcpqa + rlRun "chown -R ${pcpcommon_TESTSUITE_USER}:${pcpcommon_TESTSUITE_USER} \ + ${pcpcommon_TESTSUITE_DIR} ${pcpcommon_TESTSUITE_USER_HOME}" + + # Configure sudo + if [[ -d "/etc/sudoers.d/" ]]; then + if [[ ! -f "/etc/sudoers.d/99_${pcpcommon_TESTSUITE_USER}" ]]; then + rlRun "rlFileBackup --clean --namespace pcpcommon_pcpqa --missing-ok \ + /etc/sudoers.d/99_${pcpcommon_TESTSUITE_USER}" + rlRun "echo 'Defaults:${pcpcommon_TESTSUITE_USER} !requiretty' \ + > /etc/sudoers.d/99_${pcpcommon_TESTSUITE_USER}" + rlRun "echo '${pcpcommon_TESTSUITE_USER} ALL=(ALL) NOPASSWD: ALL' \ + >> /etc/sudoers.d/99_${pcpcommon_TESTSUITE_USER}" + rlRun "chmod 0440 /etc/sudoers.d/99_${pcpcommon_TESTSUITE_USER}" + fi + else + if ! grep -q "${pcpcommon_TESTSUITE_USER} ALL=(ALL) NOPASSWD: ALL" \ + /etc/sudoers ; then + rlRun "rlFileBackup --namespace pcpcommon_pcpqa /etc/sudoers" + rlRun "echo 'Defaults:${pcpcommon_TESTSUITE_USER} !requiretty' \ + >> /etc/sudoers" + rlRun "echo '${pcpcommon_TESTSUITE_USER} ALL=(ALL) NOPASSWD: ALL' \ + >> /etc/sudoers" + fi + fi + + # Setup ssh + rlRun "rlFileBackup --clean --namespace pcpcommon_pcpqa --missing-ok \ + ${pcpcommon_TESTSUITE_USER_HOME}/.ssh" + if [[ ! -f "${pcpcommon_TESTSUITE_USER_HOME}/.ssh/id_rsa" ]]; then + rlRun "su - -c 'mkdir ${pcpcommon_TESTSUITE_USER_HOME}/.ssh' \ + ${pcpcommon_TESTSUITE_USER}" + rlRun "su - -c 'ssh-keygen -t rsa -N \"\" \ + -f ${pcpcommon_TESTSUITE_USER_HOME}/.ssh/id_rsa' ${pcpcommon_TESTSUITE_USER}" + fi + rlRun "su - -c 'cat ${pcpcommon_TESTSUITE_USER_HOME}/.ssh/id_rsa.pub \ + >> ${pcpcommon_TESTSUITE_USER_HOME}/.ssh/authorized_keys' \ + ${pcpcommon_TESTSUITE_USER}" + rlRun "echo 'Host *' >> ${pcpcommon_TESTSUITE_USER_HOME}/.ssh/config" + rlRun "echo 'StrictHostKeyChecking no' \ + >> ${pcpcommon_TESTSUITE_USER_HOME}/.ssh/config" + rlRun "echo 'UserKnownHostsFile=/dev/null' \ + >> ${pcpcommon_TESTSUITE_USER_HOME}/.ssh/config" + rlRun "chmod 600 ${pcpcommon_TESTSUITE_USER_HOME}/.ssh/config" + rlRun "chmod 0700 ${pcpcommon_TESTSUITE_USER_HOME}/.ssh" + rlRun "chmod 0640 ${pcpcommon_TESTSUITE_USER_HOME}/.ssh/authorized_keys" + + # Setup default PATHs etc. + rlFileBackup --clean --namespace pcpcommon_pcpqa --missing-ok \ + "${pcpcommon_TESTSUITE_USER_HOME}/.bashrc" + rlRun "su -s /bin/sh -c 'touch ${pcpcommon_TESTSUITE_USER_HOME}/.bashrc' \ + ${pcpcommon_TESTSUITE_USER}" + rlRun "echo 'PATH=\${PATH}:\${PCP_BIN_DIR}:\${PCP_BINADM_DIR}:\${PCP_PLATFORM_PATHS}'\ + >> ${pcpcommon_TESTSUITE_USER_HOME}/.bashrc" + + return 0 +} + +function pcpcommon_testsuite_user_cleanup() { + # Check if we have anything to clenup + [[ -z "${pcpcommon_PCPQA_SETUP}" ]] && return 0 + pcpcommon_PCPQA_SETUP= + + # Kill everything related to pcpqa + rlRun "pkill --signal SIGTERM -u ${pcpcommon_TESTSUITE_USER}" 0-255 + rlRun "pkill --signal SIGTERM -g ${pcpcommon_TESTSUITE_USER}" 0-255 + rlRun "sleep 5" 0 "Wait a bit, so proceses can terminate gracefully" + rlRun "pkill --signal SIGKILL -u ${pcpcommon_TESTSUITE_USER}" 0-255 + rlRun "pkill --signal SIGKILL -g ${pcpcommon_TESTSUITE_USER}" 0-255 + + if [[ -n "${pcpcommon_PCPQA_CREATED}" ]]; then + rlRun "userdel -f -r -Z ${pcpcommon_TESTSUITE_USER}" 0-255 + fi + rlFileRestore --namespace pcpcommon_pcpqa + + return 0 +} + +function pcpcommon_log_system_info() { + local pcpcommon_TMP=$(mktemp -d) + local pcpcommon_TAR=$(mktemp /tmp/XXXXXXXX.tar.gz) + + rlShowRunningKernel + [[ -d /etc/os-release ]] && \ + cp /etc/os-release ${pcpcommon_TMP}/os-release + env &> ${pcpcommon_TMP}/env + sestatus &> ${pcpcommon_TMP}/sestatus + [[ -d /var/run/pcp ]] && \ + ls -alZ /var/run/pcp &> ${pcpcommon_TMP}/ls-alZ_var.run.pcp + pstree -u &> ${pcpcommon_TMP}/pstree + ps xau &> ${pcpcommon_TMP}/ps.aux + netstat -lpn &> ${pcpcommon_TMP}/netstat + ip addr &> ${pcpcommon_TMP}/ip.addr + hostname &> ${pcpcommon_TMP}/hostname + cp /etc/hosts ${pcpcommon_TMP}/etc.hosts + which iptables &> /dev/null && \ + iptables -S &> ${pcpcommon_TMP}/iptables + which nft &> /dev/null && \ + nft list ruleset &> ${pcpcommon_TMP}/nftables + + # Upload everything + tar czf ${pcpcommon_TAR} -C ${pcpcommon_TMP} $(cd ${pcpcommon_TMP} && ls -1) + rlFileSubmit "${pcpcommon_TAR}" "system.info.tar.gz" + + # Cleanup + rm -rf ${pcpcommon_TMP} ${pcpcommon_TAR} + + return 0 +} + +function pcpcommon_test () { + local ret=0 + local params="$@" + + pcpcommon_testsuite_user + + if rlRun "pushd ${pcpcommon_TESTSUITE_DIR}"; then + rlRun -s "su -l -s /bin/bash -c 'cd ${pcpcommon_TESTSUITE_DIR} && \ + ./check ${params}' ${pcpcommon_REAL_TESTSUITE_USER}" + rlFileSubmit "${rlRun_LOG}" "check.log" + local _test_results="${rlRun_LOG}" + + if ! rlRun "egrep 'Passed all [[:digit:]]+ tests' ${_test_results}" 0 \ + "Assert all testcases passed"; then + local _tmp_dir=$(mktemp -d) + local _tmp_tar=$(mktemp /tmp/XXXXXXXX.tar.gz) + local failid + local failids="$(egrep 'Failures: ' ${_test_results} | cut -d' ' -f2-)" + + if [[ -n "${failids}" ]]; then + for failid in ${failids}; do + rlFail "TC $failid failed" + rlRun "cp ${failid}.out ${_tmp_dir}/" + rlRun "cp ${failid}.out.bad ${_tmp_dir}/" + done + tar czf ${_tmp_tar} -C ${_tmp_dir} $(cd ${_tmp_dir} && ls -1) + rlFileSubmit "${_tmp_tar}" "failed.tests.tar.gz" + fi + rm -rf ${_tmp_tar} ${_tmp_dir} + ret=1 + fi + + if rlRun -s "egrep 'Not run: [[:digit:]]+' ${_test_results}" 0,1; then + rlLogWarning "$(cat ${rlRun_LOG})" + fi + + rlRun "popd" + fi + + return ${ret} +} + +function pcpcommon_cleanup () { + # Cleanup everything related to pcpqa + pcpcommon_testsuite_user_cleanup + rlFileRestore --namespace pcpcommon_init + + return $? +} + +function pcpcommon_pmda_install () { + local ret=1 + local pmda="$1" + local retries=${2:-10} + local metrics + + # Make sure the PMDA's RPM is installed + if ! rpm -q pcp-pmda-${pmda} &> /dev/null; then + rlRun "yum install -y pcp-pmda-${pmda}" || return 1 + fi + + # Check if the PMDA is already installed in PCP + rlRun -s "sed -e 's/^#.*\$//' -e '/^\\s*\$/d' -e '/^\\s*\\[.*\$/,\$ d' \ + ${pcpcommon_PCP_PMCDCONF_PATH} | cut -f 1" 0 "Get the list of installed PMDAs" + if grep -w ${pmda} "${rlRun_LOG}"; then + rlLogInfo "${pmda} is already installed" + ret=0 + else + if rlRun "pushd ${pcpcommon_PCP_PMDAS_DIR}/${pmda}"; then + [[ "${pmda}" == "bpftrace" ]] && _pcpcommon_pmda_bpftrace_setup + if rlRun "./Install < /dev/null"; then + ret=0 + + # Log all values the pmda is providing + rlRun -s "pminfo -f $(map_metric ${pmda})" + metrics="${rlRun_LOG}" + while [[ ${retries} -gt 0 ]]; do + if grep -q 'Try again. Information not currently available' \ + "${metrics}"; then + rlRun "sleep 10" 0 "Waiting for metrics to be available" + rlRun -s "pminfo -f $(map_metric ${pmda})" + metrics="${rlRun_LOG}" + rlLog "Number of retries left: $(( --retries ))" + else + retries=0 + fi + done + rlAssertNotGrep "Error: Resource temporarily unavailable" \ + "${metrics}" || ret=1 + rlAssertNotGrep "Try again. Information not currently available" \ + "${metrics}" || ret=1 + rlFileSubmit "${metrics}" "pmda.${pmda}.metrics.log" + fi + rlRun "popd" + else + rlFail "Unable to find PMDA's basedir ${pcpcommon_PCP_PMDAS_DIR}/${pmda}" + fi + fi + + return ${ret} +} + +function pcpcommon_pmda_remove () { + local ret=1 + local pmda="$1" + + if rlRun "pushd ${pcpcommon_PCP_PMDAS_DIR}/${pmda}" 0-255; then + rlRun "./Remove" 0-255 && ret=0 + rlRun "popd" + else + rlLogInfo "Unable to find PMDA's basedir ${pcpcommon_PCP_PMDAS_DIR}/${pmda}" + fi + + return ${ret} +} + +function pcpcommon_pmda_check_log () { + local pmda="$1" + local errstr="fail|warn|error|crit|denied" + local logf="${pcpcommon_PCP_LOG_DIR}/pmcd/${pmda}.log" + local result=0 + + # Skip the log check if requested + case "${PCPCOMMON_PMDA_CHECK_LOG}" in + 0|[Ff][Aa][Ll][Ss][Ee]|[Nn][Oo]) + rlLogInfo "Skipping check of the ${pmda} log file" + return 0 + ;; + esac + + if [[ "${pmda}" == "nfsclient" ]]; then + rlRun -s "grep -v 'ignored, already in cache' ${logf}" + logf="${rlRun_LOG}" + fi + + rlAssertNotGrep "${errstr}" ${logf} -Ei || result=1 + rlFileSubmit "${logf}" + + return ${result} +} + +function pcpcommon_pmda_tests () { + local pmda="$1" + local addparam="$2" + local testgroup="pmda.${pmda}" + + if rlRun "grep -q ${testgroup} ${pcpcommon_PCP_VAR_DIR}/testsuite/group" 0,1; then + pcpcommon_test "000 -g ${testgroup} ${addparam}" + pcpcommon_pmda_check_log ${pmda} + else + rlLogInfo "No upstream tests for ${pmda}" + fi +} + +function pcpcommonLibraryLoaded () { + if ! rpm -q pcp-testsuite &>/dev/null; then + rlFail "pcp-testsuite RPM is not installed" + return 1 + fi + + rlFileBackup --namespace pcpcommon_init ${pcpcommon_PCP_ENV} + + # RHEL-6 workaround + if ! ping -c 1 $(hostname) &> /dev/null; then + rlFileBackup --namespace pcpcommon_init /etc/hosts + echo 127.0.0.2 $(hostname) >> /etc/hosts + fi + + # For PCP versions < '5.1.0' run the testuite as root + local _pcpver=$(rpm -q --qf '%{version}' pcp) + local _pcpcmp=$(rlCmpVersion "${_pcpver}" "5.2.0") + if [[ "${_pcpcmp}" == "<" ]];then + rlLogInfo "According to the PCP version, the testsuite will run as user: ${pcpcommon_REAL_TESTSUITE_USER}" + pcpcommon_REAL_TESTSUITE_USER="root" + fi + + return 0 +} diff --git a/tests/Library/pcpcommon/main.fmf b/tests/Library/pcpcommon/main.fmf new file mode 100644 index 0000000..be7d82b --- /dev/null +++ b/tests/Library/pcpcommon/main.fmf @@ -0,0 +1,13 @@ +summary: Common functions for PCP tests +contact: +- Jan Kuřík +component: +- pcp +test: ./runtest.sh +framework: beakerlib +recommend: +- pcp +- pcp-testsuite +duration: 15m +extra-summary: /CoreOS/pcp/Library/pcpcommon +extra-task: /CoreOS/pcp/Library/pcpcommon diff --git a/tests/Library/pcpcommon/runtest.sh b/tests/Library/pcpcommon/runtest.sh new file mode 100755 index 0000000..8dd1d40 --- /dev/null +++ b/tests/Library/pcpcommon/runtest.sh @@ -0,0 +1,55 @@ +#!/bin/bash +# vim: dict+=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# runtest.sh of /CoreOS/pcp/Library/pcpcommon +# Description: Common functions for PCP tests +# Author: Jan Kuřík +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Copyright (c) 2020 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/share/beakerlib/beakerlib.sh || exit 1 +. ../../Library/pcpcommon/lib.sh || exit 1 + +PACKAGE="pcp" + +rlJournalStart + rlPhaseStartTest + rlRun "pcpcommonLibraryLoaded" + + rlServiceStart pmcd + rlServiceStart pmlogger + rlServiceStart pmproxy + rlServiceStart pmie + + err=0 + pmda=bash + rlRun "pcpcommon_test -g sanity" || err=1 + rlRun "pcpcommon_pmda_install ${pmda}" || err=1 + rlRun "pcpcommon_pmda_tests ${pmda}" || err=1 + rlRun "pcpcommon_pmda_remove ${pmda}" || err=1 + rlRun "pcpcommon_cleanup" + + [[ ${err} -ne 0 ]] && \ + rlRun "pcpcommon_log_system_info" + rlPhaseEnd +rlJournalPrintText +rlJournalEnd diff --git a/tests/README b/tests/README new file mode 100644 index 0000000..9ad59d4 --- /dev/null +++ b/tests/README @@ -0,0 +1,2 @@ +The test's Makefiles are not used in Fedora CI infrastructure. But are kept here +for backward compatibility with traditional beakerlib test harness in RHEL. diff --git a/tests/Sanity/pcp-testsuite-sanity/Makefile b/tests/Sanity/pcp-testsuite-sanity/Makefile new file mode 100644 index 0000000..d1a9f85 --- /dev/null +++ b/tests/Sanity/pcp-testsuite-sanity/Makefile @@ -0,0 +1,72 @@ +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Makefile of /tools/pcp/Sanity/pcp-testsuite-sanity +# Description: pcp testing by upstream testsuite +# Author: Jan Kuřík +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Copyright (c) 2018 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-testsuite-sanity +export TESTVERSION=1.0 + +BUILT_FILES= + +FILES=$(METADATA) runtest.sh Makefile PURPOSE bl + +.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 " > $(METADATA) + @echo "Name: $(TEST)" >> $(METADATA) + @echo "TestVersion: $(TESTVERSION)" >> $(METADATA) + @echo "Path: $(TEST_DIR)" >> $(METADATA) + @echo "Description: pcp testing by upstream testsuite" >> $(METADATA) + @echo "Type: Sanity" >> $(METADATA) + @echo "TestTime: 4h" >> $(METADATA) + @echo "RunFor: pcp" >> $(METADATA) + @echo "Requires: pcp time" >> $(METADATA) + @echo "Requires: sudo procps-ng avahi bzip2 pcp-pmda-cisco" >> $(METADATA) + @echo "Requires: coreutils pcp-pmda-news perl-PCP-LogImport" >> $(METADATA) + @echo "Requires: perl-PCP-LogSummary python-pcp gcc" >> $(METADATA) + @echo "Requires: redhat-rpm-config perl-PCP-LogSummary" >> $(METADATA) + @echo "Requires: libuv libuv-devel" >> $(METADATA) + @echo "Requires: /usr/bin/netstat pcp-testsuite" >> $(METADATA) + #@echo "Requires: library(pcp/pcpcommon)" >> $(METADATA) + @echo "Priority: Normal" >> $(METADATA) + @echo "License: GPLv2+" >> $(METADATA) + @echo "Confidential: no" >> $(METADATA) + @echo "Destructive: no" >> $(METADATA) + @echo "Releases: -RHEL4 -RHELClient5 -RHELServer5" >> $(METADATA) + @echo "Bug: 1760750" >> $(METADATA) + #@echo "RhtsRequires: library(pcp/pcpcommon)" >> $(METADATA) + + rhts-lint $(METADATA) diff --git a/tests/Sanity/pcp-testsuite-sanity/PURPOSE b/tests/Sanity/pcp-testsuite-sanity/PURPOSE new file mode 100644 index 0000000..29ee86a --- /dev/null +++ b/tests/Sanity/pcp-testsuite-sanity/PURPOSE @@ -0,0 +1,3 @@ +PURPOSE of /tools/pcp/Sanity/pcp-testsuite-sanity +Description: pcp testing by upstream testsuite +Author: Jan Kuřík diff --git a/tests/Sanity/pcp-testsuite-sanity/bl/s390x b/tests/Sanity/pcp-testsuite-sanity/bl/s390x new file mode 100644 index 0000000..290db00 --- /dev/null +++ b/tests/Sanity/pcp-testsuite-sanity/bl/s390x @@ -0,0 +1,2 @@ +034 +178 diff --git a/tests/Sanity/pcp-testsuite-sanity/main.fmf b/tests/Sanity/pcp-testsuite-sanity/main.fmf new file mode 100644 index 0000000..6adf5ed --- /dev/null +++ b/tests/Sanity/pcp-testsuite-sanity/main.fmf @@ -0,0 +1,31 @@ +summary: pcp testing by upstream testsuite +description: '' +contact: +- Jan Kuřík +component: +- pcp +test: ./runtest.sh +framework: beakerlib +recommend: +- pcp +- time +- sudo +- procps-ng +- avahi +- bzip2 +- pcp-pmda-cisco +- coreutils +- pcp-pmda-news +- perl-PCP-LogImport +- perl-PCP-LogSummary +- python-pcp +- gcc +- redhat-rpm-config +- perl-PCP-LogSummary +- libuv +- libuv-devel +- /usr/bin/netstat +- pcp-testsuite +duration: 4h +extra-summary: /tools/pcp/Sanity/pcp-testsuite-sanity +extra-task: /tools/pcp/Sanity/pcp-testsuite-sanity diff --git a/tests/Sanity/pcp-testsuite-sanity/runtest.sh b/tests/Sanity/pcp-testsuite-sanity/runtest.sh new file mode 100755 index 0000000..0a07f08 --- /dev/null +++ b/tests/Sanity/pcp-testsuite-sanity/runtest.sh @@ -0,0 +1,115 @@ +#!/bin/bash +# vim: dict+=/usr/share/beakerlib/dictionary.vim cpt=.,w,b,u,t,i,k +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# runtest.sh of /tools/pcp/Sanity/pcp-testsuite-sanity +# Description: pcp testing by upstream testsuite +# Author: Jan Kuřík +# +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# +# Copyright (c) 2018 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/share/beakerlib/beakerlib.sh || exit 1 +. ../../Library/pcpcommon/lib.sh || exit 1 + +PACKAGE="pcp" +TSUSER="pcpqa" +TCWD="$(pwd)" + +export SYSTEMD_PAGER='' + +function apply_bl() { + local bl="${1}" + local tc + + if [[ ! -r "${bl}" ]] ; then + rlLogDebug "No BL $(basename ${bl}) found" + return + fi + rlLog "Applying BL $(basename ${bl})" + while read tc; do + rlRun "sed -i '/^${tc} /d' /var/lib/pcp/testsuite/group" + done < "${bl}" + + return +} + +rlJournalStart + rlPhaseStartSetup + rlShowRunningKernel + rlAssertRpm "${PACKAGE}" + rlFileBackup --clean --missing-ok /etc/pcp /etc/pcp.conf /etc/pcp.env \ + /etc/sysconfig/pmcd /etc/sysconfig/pmie_timers /etc/sysconfig/pmlogger \ + /etc/sysconfig/pmlogger_timers /etc/sysconfig/pmproxy /var/lib/pcp/config + rlRun "TmpDir=\$(mktemp -d)" + rlRun "pcpcommonLibraryLoaded" + rlPhaseEnd + + rlPhaseStartSetup "PCP restart" + rlRun "rlServiceStart pmcd pmlogger" 0-255 + rlRun "rlServiceEnable pmcd pmlogger" 0-255 + rlRun "sleep 30" 0 "Give services some time to fully start" + rlPhaseEnd + + rlPhaseStartSetup "BL listing" + # Get all the variables we need + read ID VERSION_ID < <( + . /etc/os-release && \ + echo ${ID} ${VERSION_ID} || \ + echo rhel 6.10 + ) + IFS='.,-_ ' read MAJOR MINOR MICRO <<< "${VERSION_ID}" + ARCH=$(arch) + + _BLSEQ="${ID} ${ID}-${MAJOR}" + [[ -n "${MINOR}" ]] && _BLSEQ="${BLSEQ} ${ID}-${MAJOR}.${MINOR}" + [[ -n "${MICRO}" ]] && _BLSEQ="${BLSEQ} ${ID}-${MAJOR}.${MINOR}.${MICRO}" + + IFS='.,-_ ' read MAJOR MINOR MICRO < <(rpm -q --qf '%{version}' ${PACKAGE}) + _BLSEQ="${BLSEQ} ${PACKAGE}" + [[ -n "${MAJOR}" ]] && _BLSEQ="${BLSEQ} ${PACKAGE}-${MAJOR}" + [[ -n "${MINOR}" ]] && _BLSEQ="${BLSEQ} ${PACKAGE}-${MAJOR}.${MINOR}" + [[ -n "${MICRO}" ]] && _BLSEQ="${BLSEQ} ${PACKAGE}-${MAJOR}.${MINOR}.${MICRO}" + + BLSEQ= + for bl in ${_BLSEQ}; do + BLSEQ="${BLSEQ} ${bl} ${bl}.${ARCH}" + done + + for bl in ${BLSEQ}; do + rlLog "Looking for BL list ${bl}" + if [[ -r "${TCWD}/bl/${bl}" ]]; then + apply_bl "${TCWD}/bl/${bl}" + fi + done + rlPhaseEnd + + rlPhaseStartTest "run testsuite" + rlRun "pcpcommon_test -g sanity" || rlRun "pcpcommon_log_system_info" + rlPhaseEnd + + rlPhaseStartCleanup + rlRun "pcpcommon_cleanup" + rlRun "rlServiceRestore" 0-255 + rlRun "rm -r $TmpDir" + rlFileRestore + rlPhaseEnd +rlJournalPrintText +rlJournalEnd