summaryrefslogtreecommitdiff
path: root/qa/041
diff options
context:
space:
mode:
authorIgor Pashev <pashev.igor@gmail.com>2014-10-26 12:33:50 +0400
committerIgor Pashev <pashev.igor@gmail.com>2014-10-26 12:33:50 +0400
commit47e6e7c84f008a53061e661f31ae96629bc694ef (patch)
tree648a07f3b5b9d67ce19b0fd72e8caa1175c98f1a /qa/041
downloadpcp-47e6e7c84f008a53061e661f31ae96629bc694ef.tar.gz
Debian 3.9.10debian/3.9.10debian
Diffstat (limited to 'qa/041')
-rwxr-xr-xqa/041158
1 files changed, 158 insertions, 0 deletions
diff --git a/qa/041 b/qa/041
new file mode 100755
index 0000000..c0b2fb9
--- /dev/null
+++ b/qa/041
@@ -0,0 +1,158 @@
+#! /bin/sh
+# PCP QA Test No. 041
+# Test $PCP_RC_DIR/pcp start
+#
+# Copyright (c) 1995-2002 Silicon Graphics, Inc. All Rights Reserved.
+#
+
+seq=`basename $0`
+echo "QA output created by $seq"
+
+# get standard filters
+. ./common.product
+. ./common.filter
+. ./common.check
+
+[ $PCP_PLATFORM = mingw ] && _notrun "Process stop signal not available on Win32"
+
+_filter()
+{
+ tee -a $seq.full \
+ | _filter_pmcd_log \
+ | sed \
+ -e '/^ *$/d' \
+ -e 's/ -t [0-9][0-9]* / /' \
+ -e '/UID/d' \
+ -e '/UNAME/d' \
+ -e '/USER/d' \
+ -e '/host/s/host "[^"]*"/host SOMEHOST/' \
+ -e 's/^ *root[^/]*\// USERNAME ... \//' \
+ -e 's/^ *pcp[^/]*\// USERNAME ... \//' \
+ -e 's/pmcd -.*/pmcd/' \
+ -e '/__pmGetPDU:.*illegal PDU len=0/d' \
+ | _filter_pcp_start
+}
+
+_expect()
+{
+ echo "" | tee -a $seq.full
+ echo "### Expect: $* ###" | tee -a $seq.full
+ echo "" | tee -a $seq.full
+}
+
+tmp=/var/tmp/qa041.$$
+_needclean=true
+TAG=000666000magic
+status=1
+[ -z "$PCP_PMLOGGERCONTROL_PATH" ] && \
+ PCP_PMLOGGERCONTROL_PATH="$PCP_SYSCONF_DIR/pmlogger/control"
+
+trap "_cleanup" 0 1 2 3 15
+
+_cleanup()
+{
+ if $_needclean
+ then
+ [ -f $tmp.control ] && \
+ $sudo cp $tmp.control $PCP_PMLOGGERCONTROL_PATH
+ $sudo $PCP_RC_DIR/pcp restart | _filter_pcp_start
+ _wait_for_pmcd
+ _wait_for_pmlogger
+ _needclean=false
+ fi
+ $sudo rm -f $tmp.*
+ exit $status
+}
+
+if [ -d $PCP_LOG_DIR/pmlogger ]
+then
+ LOGGING_DIR=$PCP_LOG_DIR/pmlogger
+else
+ LOGGING_DIR=$PCP_LOG_DIR
+fi
+
+rm -f $seq.full
+
+# real QA test starts here
+
+# disable all pmloggers ...
+$sudo cp $PCP_PMLOGGERCONTROL_PATH $tmp.control
+cat <<End-of-File >$tmp.tmp
+# dummy file created by qa/$seq on `date`
+# the goal here is to have a controlled primary logger that does
+# not make requests to pmcd!
+\$version=1.1
+LOCALHOSTNAME y n $LOGGING_DIR/LOCALHOSTNAME -c /dev/null
+End-of-File
+$sudo cp $tmp.tmp $PCP_PMLOGGERCONTROL_PATH
+
+# I have no idea why this is required, but this test run
+# after 040 sometimes produces garbled messages unless
+# this is done!
+$sudo $PCP_RC_DIR/pcp stop >$tmp.out 2>$tmp.err
+cat $tmp.out >>$seq.full
+_filter_pcp_stop <$tmp.out
+cat $tmp.err
+
+# allow pmcd's socket teardown to complete
+#
+sleep 2
+
+rm -f $tmp.out $tmp.err
+_expect "connection refused"
+pminfo -f sample.long.million 2>&1 | _filter
+
+$sudo $PCP_RC_DIR/pcp start >$tmp.one 2>&1
+
+_wait_for_pmcd
+_expect "one million retrieved OK from sample.long.million"
+pminfo -f sample.long.million
+
+sleep 3 # make sure pmlogger is not clobbered
+
+pid=`_get_pids_by_name pmcd`
+if [ -z "$pid" ]
+then
+ echo "Arrgh ... cannot find PID for pmcd!"
+ ps $PCP_PS_ALL_FLAGS
+ echo "=== pmcd.log ==="
+ cat $PCP_LOG_DIR/pmcd/pmcd.log
+ echo "=== pmcd.log.prev ==="
+ cat $PCP_LOG_DIR/pmcd/pmcd.log.prev
+ exit
+fi
+echo "pmcd pid=$pid" >>$seq.full
+ps $PCP_PS_ALL_FLAGS | egrep "PID|$pid" >>$seq.full
+
+$sudo kill -STOP $pid
+
+sleep 3 # make sure pmcd gets the SIGSTOP
+
+# this will hang, and then see a timeout failure when PMCD is
+# killed off
+$sudo rm -f $tmp.tmp
+PMCD_CONNECT_TIMEOUT=1000
+export PMCD_CONNECT_TIMEOUT
+pminfo -f sample.long.million >$tmp.tmp 2>&1 &
+
+_expect "Starting, Waiting, Forcing termination and Starting again"
+ps $PCP_PS_ALL_FLAGS | egrep "PID|$pid" >>$seq.full
+$sudo $PCP_RC_DIR/pcp start >$tmp.two 2>&1
+
+_wait_for_pmcd
+wait
+
+_filter_pcp_start <$tmp.one | _filter
+_filter <$tmp.two
+rm -f $tmp.out $tmp.err
+
+_expect "Timeout waiting for a response from PMCD"
+_filter <$tmp.tmp
+rm -f $tmp.tmp
+
+_expect "one million again"
+pminfo -f sample.long.million
+
+# all OK
+status=0
+exit