pmrep: update TODO, man page
[pcp.git] / qa / 462
blobffa6af924ec4188f41facf3d731ce5cdc93add97
1 #! /bin/sh
2 # PCP QA Test No. 462
3 # For pv #581025, pv #589006
5 # Test out pmcd_wait
7 # Test:
8 # * Success:
9 #1 - try on already running pmcd
10 # * Failure:
11 #2 - pmcd not running at all
12 #3 - pmcd running but taking too long to get around to
13 # accepting connections
14 # * Wait delta:
15 #4 - delta = X, have pmcd dead for X-1 seconds
16 #5 - delta = X, have pmcd dead for X+1 seconds
18 # Copyright (c) 1995-2002 Silicon Graphics, Inc. All Rights Reserved.
21 seq=`basename $0`
22 echo "QA output created by $seq"
24 # get standard filters
25 . ./common.product
26 . ./common.filter
27 . ./common.check
29 status=1 # failure is the default!
30 trap "_cleanup; exit \$status" 0 1 2 3 15
31 host=`hostname`
33 _cleanup()
35 # _change_config pmlogger on
36 _start >/dev/null 2>&1
37 _wait_for_pmcd
38 _wait_for_pmlogger
39 rm -f $tmp.*
42 _filter()
44 _filter_pcp_start \
45 | _filter_pcp_stop \
46 | sed -e '/^$PCP_RC_DIR\/pmlogger: pmlogger not running/d'
49 _wait_filter()
51 sed -e "s/$host/LOCALHOST/g" -e "s/local:/LOCALHOST/g"
54 _start()
56 echo "restart @ `date` ..." >>$seq.full
57 $sudo $PCP_RC_DIR/pcp restart >$tmp.start.out
58 echo "restart log @ `date` ..." >>$seq.full
59 cat $tmp.start.out >>$seq.full
62 _stop()
64 echo "stop @ `date`..." >>$seq.full
65 $sudo $PCP_RC_DIR/pcp stop >$tmp.stop.out
66 echo "stop log @ `date` ..." >>$seq.full
67 cat $tmp.stop.out >>$seq.full
70 # real QA test starts here
72 # _change_config pmlogger off
74 delta=10
75 pre_delta=5
76 post_delta=15
78 rm -f $seq.full
80 echo "*** test 1 ***" | tee -a $seq.full
81 _start
82 sleep 2
83 if pmcd_wait -v 2>$tmp.err
84 then
85 echo ""
86 echo "pmcd_wait succeeded as expected for running pmcd"
87 echo ""
88 else
89 _wait_filter < $tmp.err
91 _filter <$tmp.start.out
93 echo "*** test 2 ***" | tee -a $seq.full
94 _stop
95 sleep 2
96 if pmcd_wait -v -t $delta 2>$tmp.err
97 then
98 echo ""
99 echo "ERROR: pmcd_wait should not have succeeded !" | tee -a $seq.full
100 echo ""
101 else
102 _wait_filter < $tmp.err
103 echo ""
104 echo "pmcd_wait failed as expected for dead pmcd"
105 echo ""
107 _filter <$tmp.stop.out
109 echo "*** test 4 ***" | tee -a $seq.full
110 _stop
111 sleep 2
112 rm -f $tmp.done
113 ( sleep $pre_delta; _start; touch $tmp.done ) &
114 if pmcd_wait -v -t $delta 2>$tmp.err
115 then
116 echo ""
117 echo "pmcd_wait succeeded as expected for sleeping pmcd - under timeout"
118 echo ""
119 else
120 echo ""
121 echo "ERROR: pmcd_wait should have succeeded !" | tee -a $seq.full
122 echo ""
123 _wait_filter < $tmp.err
126 # Need to wait until _start is _really_ done and pmcd.log has been
127 # reported
128 for i in 1 2 3 4 5
130 [ -f $tmp.done ] && break
131 sleep 1
132 done
133 if [ ! -f $tmp.done ]
134 then
135 echo "Arrgh @ `date` ... _start is really dragging the chain ... check $seq.full" | tee -a $seq.full
136 status=1
137 exit
140 _filter <$tmp.stop.out \
141 | sed -e '/pmlogger not running/d'
142 _filter <$tmp.start.out
144 echo "*** test 5 ***" | tee -a $seq.full
145 _stop
146 sleep 2
147 (sleep $post_delta; _start ) &
148 pid=$!
149 if pmcd_wait -v -t $delta 2>$tmp.err
150 then
151 echo ""
152 echo "ERROR: pmcd_wait should not have succeeded !" | tee -a $seq.full
153 echo ""
154 else
155 _wait_filter < $tmp.err
156 echo ""
157 echo "pmcd_wait failed as expected for sleeping pmcd - over timeout"
158 echo ""
160 _filter <$tmp.stop.out \
161 | sed -e '/pmlogger not running/d'
162 _filter <$tmp.start.out
164 wait $pid # for background processs, "pcp start" to finish
167 # success, all done
168 status=0
169 exit