pmrep: update TODO, man page
[pcp.git] / qa / 255
blob833b1440103a5bdbe1e88959c4dd41884c576123
1 #! /bin/sh
2 # PCP QA Test No. 255
3 # exercise pmcd <-> pmda version exchange
4 # Bug #508731
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 rm -f $seq.out
18 _get_libpcp_config
19 if $ipv6 ; then
20 ln $seq.out.ipv6 $seq.out || exit 1
21 else
22 ln $seq.out.nonipv6 $seq.out || exit 1
25 signal=$PCP_BINADM_DIR/pmsignal
26 status=1 # failure is the default!
27 errlist=''
28 trap "_cleanup; exit \$status" 0 1 2 3 15
30 $sudo rm -f $seq.full $tmp.*
31 echo "=== I am PID $$" >>$seq.full
32 echo "=== /tmp files" >>$seq.full
33 $sudo ls -l /tmp/[0-9][0-9]*.* >>$seq.full 2>&1
34 echo "=== config files" >>$seq.full
35 ls -l $PCP_PMCDCONF_PATH $PCP_PMCDOPTIONS_PATH >>$seq.full
37 unset ROOT MAKEFLAGS
39 simple_domain=253
40 broken_domain=249
41 num_warn=0
43 # pmcd may be quite some distance away
45 PMCD_CONNECT_TIMEOUT=30
46 PMCD_REQUEST_TIMEOUT=30
47 export PMCD_CONNECT_TIMEOUT PMCD_REQUEST_TIMEOUT
49 _filter_ins()
51 sed \
52 -e '/^Installing .mchart view*/d' \
53 -e 's/.* \(hash table entries\)/ NNN \1/' \
54 -e 's/.* \(non-leaf nodes\)/ NNN \1/' \
55 -e 's/.* \(leaf nodes\)/ NNN \1/' \
56 -e 's/.* \(bytes of symbol table\)/ NNN \1/'
59 _filter_pmcd()
61 _filter_pmcd_log \
62 | sed \
63 -e "/^simple.*bin/s/$simple_domain[ ]*[0-9]*[ ]*[0-9]*[ ]*[0-9]*/SIMPLE PID FD FD/" \
64 -e "/^simple.*dso/s/$simple_domain/SIMPLE/" \
65 -e "/^broken.*bin/s/$broken_domain[ ]*[0-9]*[ ]*[0-9]*[ ]*[0-9]*/BROKEN PID FD FD/" \
66 -e "s/[1-2][ ]dso.*irix_init/LIBIRIXPMDA DSO/" \
67 -e "s/[1-2][ ]dso.*linux_init/LINUX DSO/" \
68 -e "s;$PCP_PMDAS_DIR;PCP_PMDAS_DIR;g" \
69 -e "s/ISA\.//g" \
70 -e "s/ \[(nil)]//g" \
71 -e "s/cmd=.*pmdas\/broken./cmd=/" \
72 -e "s/ fd=[0-9]*/ fd=FD/" \
73 -e "s/\.$DSO_SUFFIX/.\$DSO_SUFFIX/g" \
74 -e '/UNIX_DOMAIN_SOCKET/d' \
75 | $PCP_AWK_PROG '
76 BEGIN { skip = 0 }
77 /client connection from/ { print; print "..."; skip=1; next }
78 skip == 1 && NF == 0 { skip = 0 }
79 skip == 1 { next }
80 { print }'
83 _filter_init()
85 sed \
86 -e "s/$$/PID/g" \
87 | _filter_pcp_start
90 # Remove the PMDA and restore pmcd.conf
92 _cleanup()
94 echo ""
95 echo "=== Removing broken_pmda namespace ==="
96 cd $here/pmdas/broken
97 $sudo ./broken_Remove -N
98 cd $here
99 sleep 4
100 _wait_for_pmcd
102 if [ -f $tmp.conf ]
103 then
104 echo "=== Resetting pmcd.conf back to original state ==="
105 $sudo cp $tmp.conf $PCP_PMCDCONF_PATH
107 if [ -f $tmp.options ]
108 then
109 echo "=== Resetting pmcd.options back to original state ==="
110 echo '=== $PCP_PMCDOPTIONS_PATH before cp' >>$seq.full
111 cat $PCP_PMCDOPTIONS_PATH >>$seq.full
112 echo '=== $tmp.options before cp' >>$seq.full
113 cat $tmp.options >>$seq.full
114 $sudo cp $tmp.options $PCP_PMCDOPTIONS_PATH
116 if [ -f $tmp.conf -o -f $tmp.options ]
117 then
118 echo "=== Restart PMCD ==="
119 echo '=== $PCP_PMCDCONF_PATH before init.d/pcp/start' >>$seq.full
120 cat $PCP_PMCDCONF_PATH >>$seq.full
121 echo '=== $PCP_PMCDOPTIONS_PATH before init.d/pcp/start' >>$seq.full
122 cat $PCP_PMCDOPTIONS_PATH >>$seq.full
123 $sudo $PCP_RC_DIR/pcp restart | _filter_pcp_start
124 _wait_for_pmcd
126 if [ -f $tmp.log ]
127 then
128 echo "=== Filter pmcd.log ==="
129 cat $tmp.log | _filter_pmcd
130 echo '=== pmcd log' >>$seq.full
131 cat $tmp.log >>$seq.full
133 if [ -f $tmp.cron ]
134 then
135 echo "=== Restoring crontab ==="
136 _restore_cron $tmp.cron $sudo
138 [ -f $PCP_PMDAS_DIR/simple/simple.conf.$seq ] && $sudo mv $PCP_PMDAS_DIR/simple/simple.conf.$seq $PCP_PMDAS_DIR/simple/simple.conf
140 echo "=== /tmp files" >>$seq.full
141 $sudo ls -l /tmp/[0-9][0-9]*.* >>$seq.full 2>&1
142 echo "=== config files" >>$seq.full
143 ls -l $PCP_PMCDCONF_PATH $PCP_PMCDOPTIONS_PATH >>$seq.full
145 $sudo rm -rf $tmp.*
146 _wait_for_pmlogger
149 # Removing cron entries that may collide
151 echo "=== Removing potential cron conflicts ==="
152 _remove_cron $tmp.cron $sudo
154 # Install broken pmda namespace
156 echo "=== Install broken namespace ==="
157 cd $here/pmdas/broken
158 $sudo ./broken_Install -N < /dev/null | _filter_ins 2>&1
159 # ensure help text built (-N above skips this)
160 $sudo make broken_v2.dir > /dev/null 2>&1
161 cd $here
162 echo "=== Broken PMNS ==="
163 if pminfo broken
164 then
166 else
167 echo "Unable to install broken namespace, exiting"
168 exit
171 # Build simple agent
173 echo "=== Building simple agent ==="
174 cd $PCP_PMDAS_DIR/simple
176 # get rid of warnings from simple if no config exists
178 [ -f simple.conf ] && $sudo mv simple.conf simple.conf.$seq
179 echo "sec,min,hour" >$tmp.simple.conf
180 $sudo cp $tmp.simple.conf simple.conf
182 # Install the simple namespace, I don't bother to remove it again
184 $sudo ./Install -N < /dev/null | _filter_ins 2>&1
185 echo "Namespace installed"
187 # if $sudo smake -f Makefile > $tmp.make 2>&1
188 if $sudo make > $tmp.make 2>&1
189 then
190 echo "PMDA built"
191 else
192 echo "Unable to build the simple PMDA:"
193 cat $tmp.make
194 exit
196 sed -e "/^@ SIMPLE/s/SIMPLE/$simple_domain/" < help \
197 | $sudo $PCP_BINADM_DIR/newhelp -v 2 -o help
198 echo "Help generated"
199 cd $here
201 # Replace pmcd.options
203 echo "=== Replacing pmcd.options ==="
204 $sudo cp $PCP_PMCDOPTIONS_PATH $tmp.options
205 cat << end-of-file > $tmp.newoptions
206 # New pmcd.options file created by QA 255
208 -t 10
209 -l $tmp.log
210 -T 0
211 end-of-file
213 $sudo cp $tmp.newoptions $PCP_PMCDOPTIONS_PATH
214 # Do not restart pmcd here, do it after changing pmcd.conf later
216 _renew_pmcd()
218 echo "=== Restarting PMCD with minimal PMDAs ==="
219 if [ -f $tmp.newconf ]
220 then
221 $sudo cp $tmp.newconf $PCP_PMCDCONF_PATH
222 $sudo $signal -a -s HUP pmcd >/dev/null 2>&1
223 sleep 4
224 _wait_for_pmcd
225 else
226 echo caller - $1 - has not created $tmp.newconf !!!
230 # Install a standard pmda, but do not mess with the namespace
232 _agent_install()
234 agent=$1
235 domain=$2
236 daemon=$3
237 path=$PCP_PMDAS_DIR/$agent
239 echo "=== Installing $agent ==="
240 cp $tmp.newconf $tmp.latest
241 if $daemon
242 then
243 cat << end-of-file >> $tmp.latest
244 $agent $domain pipe binary $path/pmda$agent -d $domain
245 end-of-file
246 else
247 prefix=
248 [ $PCP_PLATFORM = irix ] && prefix=`pmobjstyle`.
249 cat << end-of-file >> $tmp.latest
250 $agent $domain dso ${agent}_init $path/${prefix}pmda_$agent.$DSO_SUFFIX
251 end-of-file
254 $sudo cp $tmp.latest $PCP_PMCDCONF_PATH
255 # after non-root pmcd changes, the log files may be owned by
256 # root.root or pcp.pcp depending on the pattern of installs and
257 # pmcd restarts ... to be sure we can write the log files, remove
258 # any old ones before signalling pmcd
260 $sudo rm -f $PCP_LOG_DIR/pmcd/simple.log* $PCP_LOG_DIR/pmcd/broken.log*
261 $sudo $signal -a -s HUP pmcd >/dev/null 2>&1
262 sleep 4
263 _wait_for_pmcd
265 if _check_agent $agent
266 then
267 echo "$agent is alive and well"
268 else
269 echo "Failed to install $agent"
270 exit
274 # Remove a pmda
276 _agent_remove()
278 agent=$1
280 echo "=== Removing $agent ==="
281 _renew_pmcd _agent_remove
283 if _check_agent $agent
284 then
285 echo "Failed to remove $agent"
286 exit
287 else
288 echo "$agent was removed"
292 # Install broken pmda
294 _broken_install()
296 agent=$1
297 ver=$2
299 echo "=== Installing $agent ==="
300 cp $tmp.newconf $tmp.latest
301 cat << end-of-file >> $tmp.latest
302 broken $broken_domain pipe binary $here/pmdas/broken/$agent -d $broken_domain
303 end-of-file
305 $sudo cp $tmp.latest $PCP_PMCDCONF_PATH
306 $sudo $signal -a -s HUP pmcd >/dev/null 2>&1
307 sleep 4
308 _wait_for_pmcd
310 if _check_agent broken
311 then
312 echo "$agent is alive and well...hang on there should be some warnings"
313 pminfo -f broken
314 exit
315 elif [ "$num_warn" -ne 5 ]
316 then
317 echo "Failed to properly install $agent, expected 4 warnings"
318 exit
319 else
320 echo "$agent is alive and as well as can be expected"
324 # Copy and replace pmcd.conf
326 cp $PCP_PMCDCONF_PATH $tmp.conf
327 cat << end-of-file > $tmp.newconf
328 # pmcd.conf generated by QA 255
330 end-of-file
332 if [ $PCP_PLATFORM = irix ]
333 then
334 cat >>$tmp.newconf <<End-of-File
335 # from qa/$seq
336 irix 1 dso irix_init libirixpmda.so
337 pmcd 2 dso pmcd_init pmda_pmcd.so
338 End-of-File
339 elif [ $PCP_PLATFORM = linux ]
340 then
341 cat >>$tmp.newconf <<End-of-File
342 # from qa/$seq
343 linux 60 dso linux_init $PCP_PMDAS_DIR/linux/pmda_linux.so
344 pmcd 2 dso pmcd_init $PCP_PMDAS_DIR/pmcd/pmda_pmcd.so
345 End-of-File
346 elif [ $PCP_PLATFORM = darwin ]
347 then
348 cat >>$tmp.newconf <<End-of-File
349 # from qa/$seq
350 darwin 78 dso darwin_init $PCP_PMDAS_DIR/darwin/pmda_darwin.dylib
351 pmcd 2 dso pmcd_init $PCP_PMDAS_DIR/pmcd/pmda_pmcd.dylib
352 End-of-File
353 elif [ $PCP_PLATFORM = solaris ]
354 then
355 cat >>$tmp.newconf <<End-of-File
356 solaris 75 dso solaris_init $PCP_PMDAS_DIR/solaris/pmda_solaris.so
357 pmcd 2 dso pmcd_init $PCP_PMDAS_DIR/pmcd/pmda_pmcd.so
358 End-of-File
359 else
360 echo "Arrgh ... need pmcd.conf for $PCP_PLATFORM"
361 exit 1
364 _renew_pmcd main
366 # Start with a fresh pmcd log
368 $sudo $signal -a pmgadgets pmchart pmview >/dev/null 2>&1
369 $sudo $PCP_RC_DIR/pcp restart | _filter_init 2>&1
370 _wait_for_pmcd
372 # Test 2.0 PMDA first
374 _agent_install simple $simple_domain true
375 _agent_remove simple
376 _agent_install simple $simple_domain false
377 _agent_remove simple
379 # Test 2.0 broken PMDA
381 _broken_install broken_pmda_2_0 2
382 _agent_remove broken
384 status=0
385 exit