qa: update 660 to generate index.html, fixing pcp-testsuite runs
[pcp.git] / qa / 374
blobca51cd5e7af2f64774bda809243651c4a27e6a8a
1 #! /bin/sh
2 # PCP QA Test No. 374
3 # pmlogger (assorted) and pmlc (PCP 2.0) version compatibility
5 # 64-bit host version ... see 322 for 32-bit host version ... this
6 # one is optionally not run if you can't find a 64-bit host running
7 # pcp
9 # Copyright (c) 1995-2002 Silicon Graphics, Inc. All Rights Reserved.
12 seq=`basename $0`
13 echo "QA output created by $seq"
15 # get standard filters
16 . ./common.product
17 . ./common.filter
18 . ./common.check
20 rm -f $seq.full
21 rm -f $seq.out
22 if [ $PCP_VER -lt 30800 ]
23 then
24 ln $seq.out.1 $seq.out || exit 1
25 else
26 ln $seq.out.2 $seq.out || exit 1
29 _filter()
31 _filter_pmdumplog \
32 | sed \
33 -e '/^pmlogger .* on host .* is logging metrics from host .*/d' \
34 -e '/^PMCD host/d' \
35 -e '/^TIMESTAMP started/d' \
36 | $PCP_AWK_PROG '
37 /datax/ { skip = 3 }
38 skip > 0 { skip--; next }
39 $1 == "log" && $2 == "size" { if ($3 > 100 && $3 <= 200) $3 = "more than 100"
40 else if ($3 > 200 && $3 <= 300) $3 = "more than 200"
42 { print }'
45 _remote_signal()
47 host="$1"
48 pid="$2"
49 base="$3"
51 cat <<end-of-file >$tmp.cmd
52 . \$PCP_DIR/etc/pcp.env
53 \$PCP_BINADM_DIR/pmsignal -s TERM $pid
54 sleep 1
55 \$PCP_BINADM_DIR/pmsignal -s KILL $pid
56 test -k \$PCP_TMP_DIR/pmlogger || /usr/bin/sudo chmod o-w \$PCP_TMP_DIR/pmlogger 2>/dev/null
57 rm -f /tmp/$base.*
58 end-of-file
59 scp -q $tmp.cmd pcpqa@$host:$tmp.cmd
60 ssh -q pcpqa@$host /bin/sh $tmp.cmd >/dev/null 2>&1
61 ssh -q pcpqa@$host "rm -f $tmp.cmd"
64 _speak_to_me()
66 host=$1
67 pid=''
68 base=''
69 cat <<'End-of-File' | ssh -q pcpqa@$host sh >$tmp.tmp 2>&1
70 if [ -r $PCP_DIR/etc/pcp.env ]
71 then
72 . $PCP_DIR/etc/pcp.env
73 else
74 echo "Error: unable to read $PCP_DIR/etc/pcp.env!" >&2
75 exit 1
77 rm -f /tmp/$$.*
78 test -k $PCP_TMP_DIR/pmlogger || /usr/bin/sudo chmod o+w $PCP_TMP_DIR/pmlogger 2>/dev/null
79 ( pmlogger -T5min -L -c /dev/null -l /tmp/$$.log /tmp/$$ </dev/null >/dev/null 2>&1 ) &
80 echo pid=$! base=$$
81 End-of-File
83 echo >>$seq.full
84 echo "From ssh to $host ..." >>$seq.full
85 cat $tmp.tmp >>$seq.full
87 eval `cat $tmp.tmp`
89 if [ -z "$pid" ]
90 then
91 echo "Arrgh ... failed to get remote pmlogger pid for host $host"
92 exit
95 if [ -z "$base" ]
96 then
97 echo "Arrgh ... failed to get remote archive basename for host $host"
98 exit
101 for i in 1 2 3 4 5 6 7 8 9 10
103 if echo quit | pmlc -h $host $pid 2>&1 | grep 'Connected to' >/dev/null
104 then
105 break
106 else
107 if [ $i = 10 ]
108 then
109 echo "Arrgh ... pmlogger (pid=$pid) on host $host failed to start after 20 seconds"
110 ssh -q pcpqa@$host ps -ef | grep pmlogger
111 ssh -q pcpqa@$host ls -l /tmp/$base.*
112 ssh -q pcpqa@$host pmdumplog -a /tmp/$base
113 ssh -q pcpqa@$host cat /tmp/$base.log
114 sleep 60
115 exit 1
118 sleep 2
119 done
121 # the success cases
123 cat <<End-of-File | pmlc 2>&1 | _filter
124 connect $pid@$host
125 status
126 new volume
127 status
128 flush
129 # singular, all instances
130 query { pmcd.simabi pmcd.control.register }
131 # some instances
132 query pmcd.agent.type ["sample" "pmcd" "sampledso"]
133 # non-leaf
134 query pmcd.pdu_in
135 # logging
136 log mandatory on once pmcd.agent.type ["sample" "pmcd"]
137 End-of-File
139 # stopping and starting again should be enough to allow pmlogger
140 # to have logged the metrics from the last request ... except the
141 # pmlc control port socket may not have been ripped down, so
142 # sleep some
144 sleep 2
146 cat <<End-of-File | pmlc 2>&1 | _filter
147 connect $pid@$host
148 log mandatory off pmcd.agent.type ["sampledso"]
149 query pmcd.agent.type ["sample" "pmcd" "sampledso"]
150 End-of-File
152 # the failures
154 # echo "log mandatory on once proc" | pmlc -h $host $pid -D1
155 echo "connect 0@$host" | pmlc 2>&1 | _filter
157 # cleanup
159 if [ ! -z "$host" ]
160 then
161 _remote_signal $host $pid $base
162 pid=''
163 base=''
167 _cleanup()
169 if $need_clean
170 then
171 if [ ! -z "$pid" -a ! -z "$base" -a ! -z "$host" ]
172 then
173 _remote_signal $host $pid $base
174 pid=''
175 base=''
177 need_clean=false
179 rm -f $tmp.*
182 need_clean=true
183 status=1 # failure is the default!
184 trap "_cleanup; exit \$status" 0 1 2 3 15
186 host=''
187 pid=''
188 base=''
190 # the v1 host may be on the other side of the planet
192 PMCD_CONNECT_TIMEOUT=30
193 PMCD_REQUEST_TIMEOUT=30
194 export PMCD_CONNECT_TIMEOUT PMCD_REQUEST_TIMEOUT
196 # real QA test starts here
198 for type in '-b 64 -v pcp\>=2'
200 cmd="./getpmcdhosts -L -n 1 $type 2>/dev/null"
201 host=`eval $cmd`
202 if [ -z "$host" ]
203 then
204 echo "Cannot find a 64-bit host running PCP" >$seq.notrun
205 need_clean=false
206 exit
207 else
208 echo
209 echo "=== pmlogger host type: $type ===" | sed 's/\\>//'
210 echo "$type => $host" >>$seq.full
211 _speak_to_me $host
213 done
215 # success, all done
216 status=0
217 exit