pmrep: fix archive end time reporting
[pcp.git] / qa / 1055
blobe65796fea5b7b4e98b489406e022fee6d3a45aad
1 #! /bin/sh
2 # PCP QA Test No. 1055
3 # Check PMCD state change notification, aka PMCD_ADD_AGENT
5 # Copyright (c) 2016 Red Hat, Inc.
8 seq=`basename $0`
9 echo "QA output created by $seq"
11 # get standard filters
12 . ./common.product
13 . ./common.filter
14 . ./common.check
16 signal=$PCP_BINADM_DIR/pmsignal
17 status=1
18 done_clean=false
19 LOCALHOST=`hostname`
21 _cleanup()
23 if $done_clean
24 then
26 else
27 echo "Restore pmcd.conf and restart PMCD ..."
28 if [ -f $tmp.pmcd.conf ]
29 then
30 $sudo cp $tmp.pmcd.conf $PCP_PMCDCONF_PATH
31 rm -f $tmp.pmcd.conf
33 _restore_primary_logger
34 $sudo $PCP_RC_DIR/pcp restart | _filter_pcp_start
35 rm -f $tmp.*
36 _wait_for_pmcd
37 _wait_for_pmlogger
38 done_clean=true
40 exit $status
43 $sudo rm -rf $tmp.* $seq.full
44 trap "_cleanup" 0 1 2 3 15
46 # real QA test starts here
47 PMDA_PMCD_PATH=$PCP_PMDAS_DIR/pmcd/pmda_pmcd.$DSO_SUFFIX
49 # copy the pmcd config file to restore state later.
50 cp $PCP_PMCDCONF_PATH $tmp.pmcd.conf
52 # start from a known starting point
53 $sudo $PCP_RC_DIR/pcp stop >/dev/null 2>&1
55 cat <<End-of-File >$tmp.tmp
56 # temporary for qa/$seq
57 pmcd 2 dso pmcd_init $PMDA_PMCD_PATH
58 sample 29 pipe binary $PCP_PMDAS_DIR/sample/pmdasample -d 29
59 simple 253 pipe binary /var/lib/pcp/pmdas/simple/pmdasimple -d 253
60 End-of-File
61 $sudo cp $tmp.tmp $PCP_PMCDCONF_PATH
63 _writable_primary_logger
64 $sudo $PCP_RC_DIR/pcp restart | _filter_pcp_start
65 _wait_for_pmcd
66 if [ -d $PCP_LOG_DIR/pmlogger ]
67 then
68 LOGGING_DIR=$PCP_LOG_DIR/pmlogger
69 else
70 LOGGING_DIR=$PCP_LOG_DIR
72 _wait_for_pmlogger -P $LOGGING_DIR/$LOCALHOST/pmlogger.log
74 # Reset pmlogger
75 echo "log sample.dynamic.meta.metric"
76 # Log the sample pmda's sample.dynamic.meta.metric
77 echo 'connect primary
78 log mandatory on 500 msec { sample.dynamic.meta.metric }' \
79 | pmlc
81 # log a few samples
82 sleep 2
84 echo "archive contents before pmda simple restart..."
85 echo "expect no <mark> record"
86 echo "---------------------------------------------------------------"
87 pmafm $LOGGING_DIR/$LOCALHOST/Latest pmdumplog >$tmp.out 2>&1
88 egrep '(<mark>)|(sample.dynamic.meta.metric)' $tmp.out \
89 | _filter_pmdumplog \
90 | uniq
91 echo "---------------------------------------------------------------"
93 # Get the type of sample.dynamic.meta.metric by fetching
94 # sample.dynamic.meta.pmdesc.type using pminfo.
95 echo "pminfo -f sample.dynamic.meta.pmdesc.type" | tee -a $seq.full
96 type=`pminfo -f sample.dynamic.meta.pmdesc.type | tee -a $seq.full \
97 | awk '/value/ { print $2 }'`
99 # Change the type of sample.dynamic.meta.metric by using pmstore to store into
100 # sample.dynamic.meta.pmdesc.type
101 echo "changing type from $type to $((type + 1))"
102 pmstore sample.dynamic.meta.pmdesc.type $((type + 1))
104 # Restart the simple pmda by killing it and the getting pmcd to restart it (HUP).
105 # pmlogger should receive PMCD_ADD_AGENT, which should cause it to re-check
106 # all of it's configured metrics. It should then flag the change to
107 # sample.dynamic.meta.pmdesc.type and exit.
108 echo "restart the simple pmda"
109 $sudo $signal -a -s TERM pmdasimple
110 sleep 1 # let the signal arrive and let pmdasimple exit
111 $sudo $signal -a -s HUP pmcd # ensure pmcd restarts the PMDA
112 sleep 1 # let the signal arrive and pmcd think about it
114 echo "archive contents after pmda simple restart..."
115 echo "expect no <mark> record"
116 echo "---------------------------------------------------------------"
117 pmafm $LOGGING_DIR/$LOCALHOST/Latest pmdumplog >$tmp.out 2>&1
118 egrep '(<mark>)|(sample.dynamic.meta.metric)' $tmp.out \
119 | _filter_pmdumplog \
120 | uniq
121 echo "---------------------------------------------------------------"
123 # pmlogger should have stopped. Check for the messages indicating that
124 # the re-check of the configured metrics failed and that it stopped.
125 echo >>$seq.full
126 echo "pmlogger log ..." >>$seq.full
127 cat $LOGGING_DIR/$LOCALHOST/pmlogger.log | tee -a $seq.full | \
128 grep \
129 -e 'Type of metric "sample.dynamic.meta.metric" has changed from 32 to U32' \
130 -e 'One or more configured metrics have changed after pmcd state change. Exiting'
132 status=0
133 exit