Merge branch 'master' of git://git.pcp.io/pcp into qt
[pcp.git] / qa / 295
blob38a642cb4452a2ae60a515105a7814a2ef3f4e58
1 #! /bin/sh
2 # PCP QA Test No. 295
3 # verify pmproxy cleans up correctly when clients are terminated
5 # Copyright (c) 2005 Silicon Graphics, Inc. All Rights Reserved.
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 which pmproxy >/dev/null 2>&1 || _notrun "No pmproxy binary installed"
18 rm -f $seq.full
20 signal=$PCP_BINADM_DIR/pmsignal
21 status=0 # success is the default!
22 username=`id -u -n`
23 $sudo rm -rf $tmp.*
24 trap "_cleanup; rm -f $tmp.*; exit \$status" 0 1 2 3 15
26 _cleanup()
28 $sudo $signal -a pmproxy >/dev/null 2>&1
29 $sudo $PCP_RC_DIR/pmproxy restart >/dev/null 2>&1
32 _filter_pmproxy()
34 sed \
35 -e '/^__pmSetSocketIPC: fd=/d' \
36 -e '/^__pmSetDataIPC:/d' \
37 -e '/^__pmDataIPC: /d' \
38 -e '/^IPC table fd/d' \
42 _check()
44 connects=`grep AcceptNewClient $tmp.log | wc -l | sed -e 's/ *//g'`
45 disconnects=`grep DeleteClient $tmp.log | wc -l | sed -e 's/ *//g'`
46 difference=$(($connects - $disconnects))
47 echo "N connects"
48 echo "N-$difference disconnects"
49 echo "--- $tmp.log ---" >>$here/$seq.full
50 cat $tmp.log >>$here/$seq.full
51 echo "--- end $tmp.log ---" >>$here/$seq.full
54 $sudo $PCP_RC_DIR/pmproxy stop >/dev/null 2>&1
55 $sudo $signal -a pmproxy >/dev/null 2>&1
57 proxyargs="-Dcontext"
58 id pcp >/dev/null 2>&1 && proxyargs="$proxyargs -U $username"
59 $PCP_BINADM_DIR/pmproxy $proxyargs -l $tmp.log 2>&1 | _filter_pmproxy
61 PMPROXY_HOST=localhost
62 export PMPROXY_HOST
64 # real QA test starts here
65 pidlist=`sh -c "pmval -h $PMPROXY_HOST hinv.ncpu >$tmp.1 2>&1 & echo \\\$!"`
66 echo "pmval pid=$pidlist" >>$here/$seq.full
67 pid=`sh -c "pmstat -h $PMPROXY_HOST >$tmp.2 2>&1 & echo \\\$!"`
68 echo "pmstat pid=$pid" >>$here/$seq.full
69 pidlist="$pidlist $pid"
70 echo "kernel.all.load;" >$tmp.in
71 pid=`sh -c "pmie -v -h $PMPROXY_HOST -c $tmp.in >$tmp.3 2>&1 & echo \\\$!"`
72 echo "pmie pid=$pid" >>$here/$seq.full
73 pidlist="$pidlist $pid"
75 sleep 3
77 echo all clients started
78 echo "expect N connects and N-3 disconnect, thanks to pmie"
79 _check
81 for pid in $pidlist
83 echo
84 echo "kill off a client ..."
85 echo "kill off client pid=$pid" >>$here/$seq.full
86 $signal -s KILL $pid
87 sleep 1
88 _check
89 done
91 echo "pmval output ..." >>$here/$seq.full
92 cat $tmp.1 >>$here/$seq.full
93 echo >>$here/$seq.full
94 echo "pmstat output ..." >>$here/$seq.full
95 cat $tmp.2 >>$here/$seq.full
96 echo >>$here/$seq.full
97 echo "pmie output ..." >>$here/$seq.full
98 cat $tmp.3 >>$here/$seq.full
100 # success, all done
101 exit