Merge branch 'master' of git://git.pcp.io/pcp into qt
[pcp.git] / qa / 200
blob3e0bf0fd53a4868c5ca6b7f49268555a81c5c108
1 #! /bin/sh
2 # PCP QA Test No. 200
3 # $PMCD_RECONNECT_TIMEOUT validation
5 # Copyright (c) 1995-2002 Silicon Graphics, Inc. All Rights Reserved.
8 seq=`basename $0`
9 echo "QA output created by $seq"
11 # get standard filters
12 . ./common.product
13 . ./common.filter
14 . ./common.check
16 status=1
17 rm -f $seq.full
19 trap _cleanup 0 1 2 3 15
21 _cleanup()
23 [ -f $tmp.pmcd.conf ] && $sudo cp $tmp.pmcd.conf $PCP_PMCDCONF_PATH
24 [ "$PCP_PLATFORM" != "linux" ] && _change_config pmlogger on
25 $sudo $PCP_RC_DIR/pcp restart >/dev/null
26 _wait_for_pmcd
27 _wait_for_pmlogger
28 $sudo rm -f $tmp.pmcd.conf
29 rm -f $tmp.*
30 exit $status
33 _filter()
35 $PCP_AWK_PROG '
36 BEGIN { last = "" }
37 $0 != last { print; last = $0 }' \
38 | sed \
39 -e 's/failed: Connection reset by peer/failed: IPC protocol failure/' \
40 -e 's/[A-Z][a-z][a-z] [A-Z][a-z][a-z] *[0-9][0-9]* [0-9][0-9]:[0-9][0-9]:[0-9][0-9]/DATE/' \
41 -e '/recon([0-9][0-9]*)/s//recon(PID)/' \
42 -e '/^Context\[/d' \
43 -e '/^pmReconnectContext(/d' \
44 -e '/^Dump Contexts:/d' \
45 -e '/^Dump Instance Profile /d' \
46 -e '/^IPC table fd/d' \
47 -e '/^__pmConnectPMCD(/d' \
48 -e '/^__pmDecodeXtendError:/d' \
49 -e '/^pmNewContext(/d' \
50 -e '/^__pmSendCreds:/d' \
51 -e '/^__pmSetSocketIPC:/d' \
52 -e '/^__pmSetVersionIPC:/d' \
53 -e '/^__pmDataIPC: /d' \
54 -e '/^__pmSetDataIPC:/d' \
55 -e '/^pmWhichContext(/d' \
56 -e '/__pmConnect(fd=.*) ->/d' \
57 -e '/__pmCloseChannelbyContext/d' \
58 | $PCP_AWK_PROG '
59 /delay: 2 / { print "delay: 2-4 secs"; next }
60 /delay: 3 / { print "delay: 2-4 secs"; next }
61 /delay: 4 / { print "delay: 2-4 secs"; next }
62 /delay: 5 / { print "delay: 5-7 secs"; next }
63 /delay: 6 / { print "delay: 5-7 secs"; next }
64 /delay: 7 / { print "delay: 5-7 secs"; next }
65 { print }'
66 # note: now that pmcd starts and stops very quickly, we use a
67 # strategy in testing valid reconnect strings with less-than-
68 # five-seconds (alot less) and any errors fall back to using
69 # the defaults, which are 5,10,etc.
72 cat >$tmp.new <<End-of-File
73 # From QA 200
75 # Name Id IPC IPC Params File/Cmd
76 pmcd 2 dso pmcd_init $PCP_PMDAS_DIR/pmcd/pmda_pmcd.$DSO_SUFFIX
77 sample 29 pipe binary $PCP_PMDAS_DIR/sample/pmdasample -d 29
78 End-of-File
80 # copy the pmcd config file to restore state later.
81 $sudo cp $PCP_PMCDCONF_PATH $tmp.pmcd.conf
82 $sudo cp $tmp.new $PCP_PMCDCONF_PATH
84 # ensure we have pmcd ready for the first iteration.
85 # just doing a start may race and find the pmcd socket busy,
86 # so stop, wait a little, and start
87 $sudo $PCP_RC_DIR/pcp stop >/dev/null 2>&1
88 sleep 2
89 $sudo $PCP_RC_DIR/pmcd start >/dev/null 2>&1
90 _wait_for_pmcd
92 # real QA test starts here
93 for xxx in "" "1,1,2,2" "2" "1-2" "1,2,foo"
95 if [ "X$xxx" = X ]
96 then
97 unset PMCD_RECONNECT_TIMEOUT
98 else
99 PMCD_RECONNECT_TIMEOUT="$xxx"
100 export PMCD_RECONNECT_TIMEOUT
103 echo
104 echo "PMCD_RECONNECT_TIMEOUT=\"$PMCD_RECONNECT_TIMEOUT\""
105 echo "start PMCD_RECONNECT_TIMEOUT=$PMCD_RECONNECT_TIMEOUT" >>$seq.full
106 echo "start `date`" >>$seq.full
108 DEBUG=
109 DEBUG=-D16
110 src/recon $DEBUG >$tmp.out 2>&1 &
112 pmsleep 1.1
113 echo "begin stop pmcd `date`" >>$seq.full
114 $sudo $PCP_RC_DIR/pmcd stop | _filter_pcp_stop
115 echo "end stop pmcd `date`" >>$seq.full
116 pmsleep 1.1
117 echo "begin start pmcd `date`" >>$seq.full
118 $sudo $PCP_RC_DIR/pmcd start \
119 | _filter_pcp_start
120 echo "end start pmcd `date`" >>$seq.full
122 wait
123 _filter <$tmp.out
124 cat $tmp.out >>$seq.full
125 done
127 status=0
128 exit