Merge branch 'master' of git://git.pcp.io/pcp into qt
[pcp.git] / qa / 374
blobf658e16015edc9f55f2ee15b6a960557ed5e04cd
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
22 _filter()
24 _filter_pmdumplog \
25 | sed \
26 -e '/^pmlogger .* on host .* is logging metrics from host .*/d' \
27 -e '/^PMCD host/d' \
28 -e '/^TIMESTAMP started/d' \
29 | $PCP_AWK_PROG '
30 /datax/ { skip = 3 }
31 skip > 0 { skip--; next }
32 $1 == "log" && $2 == "size" { if ($3 > 100 && $3 <= 200) $3 = "more than 100"
33 else if ($3 > 200 && $3 <= 300) $3 = "more than 200"
35 { print }'
38 _remote_signal()
40 host="$1"
41 pid="$2"
42 base="$3"
44 cat <<end-of-file >$tmp.cmd
45 . \$PCP_DIR/etc/pcp.env
46 \$PCP_BINADM_DIR/pmsignal -s TERM $pid
47 sleep 1
48 \$PCP_BINADM_DIR/pmsignal -s KILL $pid
49 test -k \$PCP_TMP_DIR/pmlogger || /usr/bin/sudo chmod o-w \$PCP_TMP_DIR/pmlogger 2>/dev/null
50 rm -f /tmp/$base.*
51 end-of-file
52 scp -q $tmp.cmd pcpqa@$host:$tmp.cmd
53 ssh -q pcpqa@$host /bin/sh $tmp.cmd >/dev/null 2>&1
54 ssh -q pcpqa@$host "rm -f $tmp.cmd"
57 _speak_to_me()
59 host=$1
60 pid=''
61 base=''
62 cat <<'End-of-File' | ssh -q pcpqa@$host sh >$tmp.tmp 2>&1
63 if [ -r $PCP_DIR/etc/pcp.env ]
64 then
65 . $PCP_DIR/etc/pcp.env
66 else
67 echo "Error: unable to read $PCP_DIR/etc/pcp.env!" >&2
68 exit 1
70 rm -f /tmp/$$.*
71 test -k $PCP_TMP_DIR/pmlogger || /usr/bin/sudo chmod o+w $PCP_TMP_DIR/pmlogger 2>/dev/null
72 ( pmlogger -T5min -L -c /dev/null -l /tmp/$$.log /tmp/$$ </dev/null >/dev/null 2>&1 ) &
73 echo pid=$! base=$$
74 End-of-File
76 echo >>$seq.full
77 echo "From ssh to $host ..." >>$seq.full
78 cat $tmp.tmp >>$seq.full
80 eval `cat $tmp.tmp`
82 if [ -z "$pid" ]
83 then
84 echo "Arrgh ... failed to get remote pmlogger pid for host $host"
85 exit
88 if [ -z "$base" ]
89 then
90 echo "Arrgh ... failed to get remote archive basename for host $host"
91 exit
94 for i in 1 2 3 4 5 6 7 8 9 10
96 if echo quit | pmlc -h $host $pid 2>&1 | grep 'Connected to' >/dev/null
97 then
98 break
99 else
100 if [ $i = 10 ]
101 then
102 echo "Arrgh ... pmlogger (pid=$pid) on host $host failed to start after 20 seconds"
103 ssh -q pcpqa@$host ps -ef | grep pmlogger
104 ssh -q pcpqa@$host ls -l /tmp/$base.*
105 ssh -q pcpqa@$host pmdumplog -a /tmp/$base
106 ssh -q pcpqa@$host cat /tmp/$base.log
107 sleep 60
108 exit 1
111 sleep 2
112 done
114 # the success cases
116 cat <<End-of-File | pmlc 2>&1 | _filter
117 connect $pid@$host
118 status
119 new volume
120 status
121 flush
122 # singular, all instances
123 query { pmcd.simabi pmcd.control.register }
124 # some instances
125 query pmcd.agent.type ["sample" "pmcd" "sampledso"]
126 # non-leaf
127 query pmcd.pdu_in
128 # logging
129 log mandatory on once pmcd.agent.type ["sample" "pmcd"]
130 End-of-File
132 # stopping and starting again should be enough to allow pmlogger
133 # to have logged the metrics from the last request ... except the
134 # pmlc control port socket may not have been ripped down, so
135 # sleep some
137 sleep 2
139 cat <<End-of-File | pmlc 2>&1 | _filter
140 connect $pid@$host
141 log mandatory off pmcd.agent.type ["sampledso"]
142 query pmcd.agent.type ["sample" "pmcd" "sampledso"]
143 End-of-File
145 # the failures
147 # echo "log mandatory on once proc" | pmlc -h $host $pid -D1
148 echo "connect 0@$host" | pmlc 2>&1 | _filter
150 # cleanup
152 if [ ! -z "$host" ]
153 then
154 _remote_signal $host $pid $base
155 pid=''
156 base=''
160 _cleanup()
162 if $need_clean
163 then
164 if [ ! -z "$pid" -a ! -z "$base" -a ! -z "$host" ]
165 then
166 _remote_signal $host $pid $base
167 pid=''
168 base=''
170 need_clean=false
172 rm -f $tmp.*
175 need_clean=true
176 status=1 # failure is the default!
177 trap "_cleanup; exit \$status" 0 1 2 3 15
179 host=''
180 pid=''
181 base=''
183 # the v1 host may be on the other side of the planet
185 PMCD_CONNECT_TIMEOUT=30
186 PMCD_REQUEST_TIMEOUT=30
187 export PMCD_CONNECT_TIMEOUT PMCD_REQUEST_TIMEOUT
189 # real QA test starts here
191 for type in '-b 64 -v pcp\>=2'
193 cmd="./getpmcdhosts -L -n 1 $type 2>/dev/null"
194 host=`eval $cmd`
195 if [ -z "$host" ]
196 then
197 echo "Cannot find a 64-bit host running PCP" >$seq.notrun
198 need_clean=false
199 exit
200 else
201 echo
202 echo "=== pmlogger host type: $type ===" | sed 's/\\>//'
203 echo "$type => $host" >>$seq.full
204 _speak_to_me $host
206 done
208 # success, all done
209 status=0
210 exit