build: Makepkgs support for vector deb building
[pcp.git] / qa / 067
blobf1a28d0ba7112e74f88ca12174627f7da84f4f0f
1 #! /bin/sh
2 # PCP QA Test No. 067
3 # Test PMCD's ability to detect and cleanup agents it didn't create when they
4 # terminate
6 # Copyright (c) 1995-2002 Silicon Graphics, Inc. All Rights Reserved.
9 seq=`basename $0`
10 echo "QA output created by $seq"
12 # get standard filters
13 . ./common.product
14 . ./common.filter
15 . ./common.check
17 which netstat >/dev/null 2>&1 || _notrun "netstat not installed"
19 rm -f $seq.out
20 _get_libpcp_config
21 if $ipv6 ; then
22 ln $seq.out.ipv6 $seq.out || exit 1
23 else
24 ln $seq.out.nonipv6 $seq.out || exit 1
27 trap "rm -f $tmp.*; exit" 0 1 2 3 15
29 # real QA test starts here
31 signal=$PCP_BINADM_DIR/pmsignal
32 log=$PCP_PMCDLOG_PATH
33 LOCALHOST=`hostname`
35 _filter_log()
37 sleep 1
38 _filter_pmcd_log <$log \
39 | sed \
40 -e '/^$/d' \
41 -e 's/ *$//' \
42 -e 's/^$//' \
43 -e '/^->/d' \
44 -e '/^00[08]:/d' \
45 -e '/^sample/s/.*/sample agent.../' \
46 -e 's/fd=[0-9][0-9]*/fd=<n>/g' \
47 -e 's/^ ok [0-9]*/ ok <n>/g' \
48 -e '/^test/s/ *[0-9][0-9]* *[0-9][0-9]* ... bin/ <n> <n> <n> bin/' \
49 -e '/Resource busy/d' \
50 -e 's/0x[^ ]*\([^ ][^ ][^ ]\)/ADDR...\1/' \
51 -e '/client connection from/,/^$/d' \
52 -e '/Cleanup/d' \
53 -e '/Info: spindle_stats_init/d' \
54 -e '/UNIX_DOMAIN_SOCKET/d'
57 _filter_pmda_log()
59 sed \
60 -e 's/^\(Log for pmda[^ ]* on\) .*/\1 HOST .../' \
61 -e 's/^\(Log finished\) .*/\1 .../'
64 interrupt()
66 echo "Interrupted"
67 exit
70 if [ -d $PCP_LOG_DIR/pmlogger ]
71 then
72 LOGGING_DIR=$PCP_LOG_DIR/pmlogger
73 else
74 LOGGING_DIR=$PCP_LOG_DIR
77 cleanup()
79 _restore_config $PCP_PMCDCONF_PATH
80 pmafm $LOGGING_DIR/$LOCALHOST/Latest remove >$tmp.cmd 2>&1 \
81 && $sudo sh $tmp.cmd
82 echo "Restarting pmcd"
83 $sudo $PCP_RC_DIR/pcp restart | _filter_pcp_start
84 _wait_for_pmcd
85 _wait_for_pmlogger
86 rm -f $tmp.*
89 trap interrupt 1 2 3 15
90 trap cleanup 0
92 domain=246
93 if [ $PCP_PLATFORM = linux ]
94 then
95 cat >$tmp.config <<End-of-file
96 linux 60 dso linux_init $PCP_PMDAS_DIR/linux/pmda_linux.so
97 pmcd 2 dso pmcd_init $PCP_PMDAS_DIR/pmcd/pmda_pmcd.so
98 test $domain socket inet 2222
99 End-of-file
100 elif [ $PCP_PLATFORM = darwin ]
101 then
102 cat >$tmp.config <<End-of-file
103 darwin 78 dso darwin_init $PCP_PMDAS_DIR/darwin/pmda_darwin.dylib
104 pmcd 2 dso pmcd_init $PCP_PMDAS_DIR/pmcd/pmda_pmcd.dylib
105 test $domain socket inet 2222
106 End-of-file
107 elif [ $PCP_PLATFORM = solaris ]
108 then
109 cat >>$tmp.config <<End-of-File
110 solaris 75 dso solaris_init $PCP_PMDAS_DIR/solaris/pmda_solaris.so
111 pmcd 2 dso pmcd_init $PCP_PMDAS_DIR/pmcd/pmda_pmcd.so
112 test $domain socket inet 2222
113 End-of-File
114 else
115 echo "Error - need pmcd.conf setup for $PCP_PLATFORM"
116 exit 1
119 # netstat -an formats
121 # Redhat 7.3 and 9
122 # tcp 0 0 0.0.0.0:2222 0.0.0.0:* LISTEN
124 # Mac OS X 10.6
125 # tcp4 0 0 *.2222 *.* LISTEN
127 # openindiana
128 # *.2222 *.* 0 0 128000 0 LISTEN
131 $sudo $signal -a pmgadgets pmchart pmview pmie >/dev/null 2>&1
132 src/pmdashutdown -i 2222 -d $domain -l $tmp.pmdalog &
133 pid=$!
134 echo "pmdashutdown pid: $pid" >$seq.full
135 sleep 1
136 echo
137 echo "port 2222 should be listening"
138 netstat -an \
139 | tee -a $seq.full \
140 | grep '[.:]2222 ' \
141 | sed \
142 -e 's/127\.0\.0\.1/*/g' \
143 -e 's/0\.0\.0\.0/*/g' \
144 -e 's/:/./g' \
145 -e 's/.*\(\*.2222\).*\(LISTEN\).*/... \1 ... \2/'
146 echo
148 _save_config $PCP_PMCDCONF_PATH
149 $sudo cp $tmp.config $PCP_PMCDCONF_PATH
150 pmafm $LOGGING_DIR/$LOCALHOST/Latest remove >$tmp.cmd 2>&1 \
151 && $sudo sh $tmp.cmd
152 $sudo $PCP_RC_DIR/pcp restart | _filter_pcp_start
153 _wait_for_pmcd
154 # echo "config:"
155 # cat $config | sed -e "s;$PCP_PMDAS_DIR;\$PCP_PMDAS_DIR;"
156 echo
158 # wait for pmdashutdown to finish
160 for t in 1 2 3 4 5 6
162 echo >>$seq.full
163 echo "wait for pmdashutdown to finish ... cycle $t" >>$seq.full
164 if ps $PCP_PS_ALL_FLAGS | tee -a $seq.full | cut -f1 | grep $pid >/dev/null 2>&1
165 then
166 sleep 2
167 else
168 break
170 done
172 echo >>$seq.full
173 cat $tmp.pmdalog >>$seq.full
174 echo
175 echo "pmda log (should have terminated):"
176 _filter_pmda_log <$tmp.pmdalog
177 echo
179 $sudo $signal -a -s HUP pmcd
181 # wait for PMCD to finish writing log (or 5 seconds)
182 for t in 1 2 3 4 5
184 if egrep '^Cleanup "test" agent' $log >/dev/null 2>&1
185 then
186 break
188 sleep 1
189 done
191 _filter_log