pmrep: fix archive end time reporting
[pcp.git] / qa / 956
blob4a60168fed8b319522696b2ba8487fe617669e50
1 #!/bin/sh
2 # PCP QA Test No. 956
3 # Exercise pmcd attribute PDU handling after agent failure.
5 # Copyright (c) 2015 Red Hat.
8 seq=`basename $0`
9 echo "QA output created by $seq"
11 # get standard environment, filters and checks
12 . ./common.product
13 . ./common.filter
14 . ./common.check
16 _get_libpcp_config
17 $unix_domain_sockets || _notrun "No unix domain socket support available"
19 _filter()
21 sed -e 's/\.\.\.*/\.\.\./g'
24 _cleanup()
26 $sudo $PCP_RC_DIR/pcp stop | _filter_pcp_stop
27 unset PMCD_PORT
28 _restore_config $PCP_PMCDOPTIONS_PATH
29 $sudo $PCP_RC_DIR/pcp start | _filter_pcp_start
30 _wait_for_pmcd
31 _wait_for_pmlogger
33 if pmprobe -I pmcd.agent.status | grep '"dynamic"' >/dev/null
34 then
35 cd $here/pmdas/dynamic
36 $sudo ./Remove >>$here/$seq.full 2>&1
37 cd $here
39 $sudo rm -f $tmp.*
42 status=1 # failure is the default!
43 $sudo rm -rf $tmp.* $seq.full
44 signal=$PCP_BINADM_DIR/pmsignal
45 trap "_cleanup; exit \$status" 0 1 2 3 15
47 port=`_get_port tcp 6060 6070`
48 if [ -z "$port" ]
49 then
50 echo "Arrggh ... no free TCP port in the range 6060 ... 6070"
51 $NETSTAT -a
52 exit 1
54 echo "port=$port" >>$seq.full
55 _save_config $PCP_PMCDOPTIONS_PATH
56 cat <<End-of-File >$tmp.newoptions
57 # New pmcd.options file created by QA $seq
59 -s $tmp.socket
60 End-of-File
61 $sudo cp $tmp.newoptions $PCP_PMCDOPTIONS_PATH
63 $sudo $PCP_RC_DIR/pcp stop | _filter_pcp_stop
64 export PMCD_PORT=$port
65 $sudo $PCP_RC_DIR/pcp start | _filter_pcp_start
66 _wait_for_pmcd
67 _wait_for_pmlogger
69 cd $here/pmdas/dynamic
70 if [ -f GNUmakefile.install ]
71 then
72 $PCP_MAKE_PROG -f GNUmakefile.install clean >>$here/$seq.full 2>&1
73 $PCP_MAKE_PROG -f GNUmakefile.install >>$here/$seq.full 2>&1
74 else
75 $PCP_MAKE_PROG clean >>$here/$seq.full 2>&1
76 $PCP_MAKE_PROG >>$here/$seq.full 2>&1
78 $sudo ./Install < /dev/null >$tmp.out 2>&1
79 cat $tmp.out | tee -a $here/$seq.full | _filter_pmda_install | _filter
80 cd $here
82 # real QA test starts here
83 echo "Initial check of some metric access"
84 pmprobe -h unix:$tmp.socket -i hinv.ncpu
86 pmsleep 0.2
88 echo "Terminate a PMDA needing attributes" | tee -a $here/$seq.full
89 date >>$here/$seq.full
90 $sudo $signal -a pmdadynamic >> $here/$seq.full 2>&1
92 # wait up to 2 seconds for dynamic PMDA to die
93 i=0
94 while [ $i -lt 10 ]
96 $PCP_PS_PROG $PCP_PS_ALL_FLAGS >$tmp.tmp
97 echo "ps probe #$i" >>$here/$seq.full
98 egrep '[P]ID|[p]mdadynamic' $tmp.tmp >>$here/$seq.full
99 if egrep '(pmdadynamic.*defunct)|( Z .*pmdadynamic)' $tmp.tmp >/dev/null
100 then
101 rm -f $tmp.tmp
102 break
103 elif grep "pmdadynamic" $tmp.tmp >/dev/null
104 then
106 else
107 rm -f $tmp.tmp
108 break
110 pmsleep 0.2
111 i=`expr $i + 1`
112 done
113 if [ -f $tmp.tmp ]
114 then
115 echo "Arrgh ... dynamic PMDA won't die"
116 egrep '[P]ID|[p]mdadynamic' $tmp.tmp
117 exit
119 date >>$here/$seq.full
121 # and a bit more for pmcd to notice the PMDA has exited
122 pmsleep 3.75
124 echo "Tickle access to the failed PMDA, must see 'Try Again'"
125 pmprobe -h unix:$tmp.socket -i hinv.ncpu | tee $tmp.tmp
126 nval=`$PCP_AWK_PROG <$tmp.tmp '{print $2}'`
127 if [ "$nval" -ge 0 ]
128 then
129 # this is not expected
131 echo "Error: nval=$nval not as expected ... see $seq.full"
132 echo "+++ Tickle failed `date` +++" >>$here/$seq.full
133 cat $PCP_LOG_DIR/pmcd/pmcd.log >>$here/$seq.full
134 cat $PCP_LOG_DIR/pmcd/dynamic.log >>$here/$seq.full
137 echo "Verify subsequent return to healthy state"
138 pmprobe -h unix:$tmp.socket -i hinv.ncpu
140 # success, all done
141 status=0
142 exit