Drop unused condition check
[pcp.git] / qa / 326
blobaf3fdcc7e68026cd26e5eae7714fa6b7d4889602
1 #! /bin/sh
2 # PCP QA Test No. 326
3 # Check PMCD state change notification, aka PMCD reset
5 # Copyright (c) 1995-2002 Silicon Graphics, Inc. All Rights Reserved.
6 # Copyright (c) 2016 Red Hat, Inc.
9 seq=`basename $0`
10 echo "QA output created by $seq"
12 # get standard filters
13 . ./common.product
14 . ./common.filter
15 . ./common.check
17 signal=$PCP_BINADM_DIR/pmsignal
18 status=1
19 done_clean=false
20 LOCALHOST=`hostname`
22 _cleanup()
24 if $done_clean
25 then
27 else
28 echo
29 echo "Restore pmcd.conf and restart PMCD ..."
30 if [ -f $tmp.pmcd.conf ]
31 then
32 $sudo cp $tmp.pmcd.conf $PCP_PMCDCONF_PATH
33 rm -f $tmp.pmcd.conf
35 _restore_primary_logger
36 $sudo $PCP_RC_DIR/pcp restart | _filter_pcp_start
37 rm -f $tmp.*
38 _wait_for_pmcd
39 _wait_for_pmlogger
40 done_clean=true
42 exit $status
45 $sudo rm -rf $tmp.* $seq.full
46 trap "_cleanup" 0 1 2 3 15
47 timezone=`pmprobe -v pmcd.timezone | $PCP_AWK_PROG '{print $3}'`
49 _filter_host()
51 # filter this, as we now fetch pmcd.hostname, sneakily
52 sed \
53 -e "/ value \"$REALHOST\"/d" \
54 -e "/ value \"$LOCALHOST\"/d"
57 _filter_pmval()
59 sed \
60 -e '1,/^interval:/d' \
61 -e 's/[0-9][0-9]:[0-9][0-9]:[0-9][0-9]\.[0-9][0-9][0-9]/TIMESTAMP/g' \
62 | $PCP_AWK_PROG '
63 /No values available/ { print; next }
64 0 <= $2 && $2 < 1.1 { $2 = "non-negative number, less than 1.1" }
65 { print }' \
66 | uniq
69 trap "_cleanup" 0 1 2 3 15
71 rm -f $seq.full
73 # real QA test starts here
74 PMDA_PMCD_PATH=$PCP_PMDAS_DIR/pmcd/pmda_pmcd.$DSO_SUFFIX
76 # copy the pmcd config file to restore state later.
77 cp $PCP_PMCDCONF_PATH $tmp.pmcd.conf
79 # start from a known starting point
80 $sudo $PCP_RC_DIR/pcp stop >/dev/null 2>&1
82 cat <<End-of-File >$tmp.tmp
83 # temporary for qa/$seq
84 pmcd 2 dso pmcd_init $PMDA_PMCD_PATH
85 sample 29 pipe binary $PCP_PMDAS_DIR/sample/pmdasample -d 29
86 End-of-File
87 $sudo cp $tmp.tmp $PCP_PMCDCONF_PATH
89 _writable_primary_logger
90 $sudo $PCP_RC_DIR/pcp restart | _filter_pcp_start
91 _wait_for_pmcd
92 if [ -d $PCP_LOG_DIR/pmlogger ]
93 then
94 LOGGING_DIR=$PCP_LOG_DIR/pmlogger
95 else
96 LOGGING_DIR=$PCP_LOG_DIR
98 _wait_for_pmlogger -P $LOGGING_DIR/$LOCALHOST/pmlogger.log
100 echo 'connect primary
101 log mandatory on 500 msec { pmcd.numagents sample.milliseconds }' \
102 | pmlc
104 # run for 20 seconds
105 pmval -s 40 -t 0.5 -Z "$timezone" -D fetch pmcd.numagents >$tmp.pmval 2>&1 &
107 sleep 3
109 echo "=== kill sample PMDA process ==="
110 $sudo $signal -a -s TERM pmdasample
111 sleep 2 # enough time for pmcd to restart it - once only
112 $sudo $signal -a -s TERM pmdasample
113 pminfo -v sample >/dev/null 2>&1
114 sleep 3
116 echo "=== SIGHUP PMCD ==="
117 $sudo $signal -a -s HUP pmcd
118 sleep 3
120 echo "=== drop sample PMDA, like Remove ==="
121 cat <<End-of-File >$tmp.tmp
122 # temporary for qa/$seq
123 pmcd 2 dso pmcd_init $PMDA_PMCD_PATH
124 End-of-File
125 $sudo cp $tmp.tmp $PCP_PMCDCONF_PATH
126 $sudo $signal -a -s HUP pmcd
127 sleep 3
129 echo "=== add sample PMDA, like Install ==="
130 cat <<End-of-File >$tmp.tmp
131 # temporary for qa/$seq
132 pmcd 2 dso pmcd_init $PMDA_PMCD_PATH
133 sample 29 pipe binary $PCP_PMDAS_DIR/sample/pmdasample -d 29
134 End-of-File
135 $sudo cp $tmp.tmp $PCP_PMCDCONF_PATH
136 $sudo $signal -a -s HUP pmcd
137 sleep 3
139 wait
141 echo >>$seq.full
142 echo "pmcd log ..." >>$seq.full
143 cat $PCP_PMCDLOG_PATH >>$seq.full
145 echo
146 echo "Trace of observed state changes and PMDA count ..."
147 egrep '(state changes)|( value )' $tmp.pmval \
148 | _filter_host \
149 | uniq
151 echo
152 echo "primary logger ..."
153 echo 'connect primary
154 log mandatory off { pmcd.numagents sample.milliseconds }
155 flush' \
156 | pmlc
157 sleep 2
159 echo >>$seq.full
160 echo "pmlogger log ..." >>$seq.full
161 cat $LOGGING_DIR/$LOCALHOST/pmlogger.log >>$seq.full
163 echo "archive contents ..."
164 pmafm $LOGGING_DIR/$LOCALHOST/Latest pmdumplog >$tmp.out 2>&1
165 egrep '(<mark>)|(pmcd.numagents)' $tmp.out \
166 | _filter_pmdumplog \
167 | uniq
169 # note clip after 4 filtered lines to avoid extra values that sometimes
170 # appear due to non-determinism in pmlogger fetch samples
172 echo
173 echo "sanity check with pmval | filter ..."
174 pmafm $LOGGING_DIR/$LOCALHOST/Latest pmval -t 1 sample.milliseconds 2>&1 \
175 | _filter_pmval \
176 | sed -e 4q
178 echo >>$seq.full
179 echo "unfiltered pmval live output" >>$seq.full
180 cat $tmp.pmval >>$seq.full
182 echo >>$seq.full
183 echo "unfiltered pmval archive output" >>$seq.full
184 pmafm $LOGGING_DIR/$LOCALHOST/Latest pmval -t 1 sample.milliseconds >>$seq.full 2>&1
186 status=0
187 exit