4 # Test out pmlogger_check with duplicate directory names
5 # Test out pmlogger_check with directory names where one is a subname
9 # This test assumes 127.0.0.2 is available ... for some platforms
10 # this may not be the case, e.g. Mac OS X, where it is necessary
11 # to arrange for the command below to be run in the reboot
13 # # ifconfig lo0 alias 127.0.0.2
15 # Copyright (c) 1995-2002 Silicon Graphics, Inc. All Rights Reserved.
19 echo "QA output created by $seq"
21 # get standard filters
29 LOCALHOST
=`echo $realhost | sed -e 's/\..*//'`
30 hostsfile
="/etc/hosts"
31 egrep '^[^#].*[ ]'$realhost'([ ]|$)' <$hostsfile >/dev
/null || \
32 _notrun
"No entry for hostname of local host in $hostsfile"
34 signal
="$sudo $PCP_BINADM_DIR/pmsignal"
35 status
=1 # failure is the default!
36 trap "_cleanup; exit \$status" 0 1 2 3 15
41 -e 's/\.\.\.*/[dots]/' \
42 -e "s/$realhost/LOCALHOST/g" \
43 -e "s/$LOCALHOST/LOCALHOST/g" \
44 -e "s/local:/LOCALHOST/g" \
45 -e 's/control:[0-9][0-9]*]/control:LINE]/' \
46 -e 's/control.d\/*:[0-9][0-9]*]/control:LINE]/' \
47 -e 's;/usr/var;/var;g' \
50 -e 's/process [0-9][0-9]*/process PID/' \
51 -e '/[0-9] inode=/d' \
52 -e 's/[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]\.[0-9][0-9]\.[0-9][0-9]/CHECK/' \
53 | _filter_cron_scripts
58 $signal -a -s TERM pmlogger
>/dev
/null
2>&1
66 if [ -f $tmp.etc.hosts.orig
]
68 $sudo cp $tmp.etc.hosts.orig
$hostsfile
73 cd # get out of tmp directory so we can delete it
74 $sudo rm -rf $tmp $tmp.
*
76 $sudo $PCP_BINADM_DIR/pmlogger_check
83 $sudo rm -rf $logdir $logdir2
84 mkdir
$logdir $logdir2
85 chmod ugo
+w
$logdir $logdir2
88 # This relies on 127.0.0.x being an alias for 127.0.0.1
89 # Also, place our real hostname entry first, then the
90 # 127.0.0.x alias so that the reverse hostname lookup in
91 # pmlogger gets the same hostname for the portmap files
92 # as the -h from the command line
99 $sudo cp $hostsfile $tmp.etc.hosts.orig
102 # add an entry for extra_hostname
104 for i
in 2 3 4 5 6 7 8 9
106 if grep "^127.0.0.$i" $hostsfile >/dev
/null
110 echo "# Hacked for QA/$seq" >$tmp.etc.hosts
111 echo "#" >>$tmp.etc.hosts
112 egrep '^[^#].*[ ]'$realhost'([ ]|$)' <$hostsfile >$tmp.tmp
113 if [ `wc -l <$tmp.tmp | sed -e 's/ *//g'` -ne 1 ]
115 echo "Updating $hostsfile failed: no single $realhost entry: (see $seq.full):"
116 echo "=== $hostsfile ===" >>$here/$seq.full
117 cat $hostsfile >>$here/$seq.full
118 echo "grep $realhost ..." >>$here/$seq.full
119 cat $tmp.tmp
>>$here/$seq.full
122 cat $tmp.tmp
>>$tmp.etc.hosts
123 echo "127.0.0.$i $extra_hostname" >>$tmp.etc.hosts
124 echo "" >>$tmp.etc.hosts
125 egrep -v '^[^#].*[ ]'$realhost'([ ]|$)' <$hostsfile >>$tmp.etc.hosts
131 # we expect to make a change!
132 if [ -s $tmp.etc.hosts
]
134 # create new hosts file
135 $sudo cp $tmp.etc.hosts
$hostsfile
137 echo "Updating $hostsfile failed: no 127.0.0.x available: (see $seq.full):"
138 echo "=== $hostsfile ===" >>$here/$seq.full
139 cat $hostsfile >>$here/$seq.full
150 # PCP archive logging configuration/control - for qa/$seq
156 $PCP_AWK_PROG < $tmp.control
-v id
=$id '
157 $1 == "#" && $2 == id"." {
162 mode == 1 && $1 == "#" && $2 ~ /[0-9][0-9]*\./ {
163 # found next item so exit
173 # real QA test starts here
174 rm -f $here/$seq.full
177 host2
=$LOCALHOST"super"
178 echo "host1=$host1" >>$here/$seq.full
179 echo "host2=$host2" >>$here/$seq.full
180 _update_hostsfile
$host2
181 echo "=== $hostsfile ===" >>$here/$seq.full
182 cat $hostsfile >>$here/$seq.full
183 echo "=== check pcp on $host2 ===" >>$here/$seq.full
184 pcp
-h $host2 >>$here/$seq.full
187 logdir2
="$tmp.subname"
191 # This global file should be extended to do more control
193 # Make sure you put the number in the form "# 3. "
195 cat > $tmp.control
<<EOF
197 # 1. Test duplicate directory names; non-primary and then primary
199 LOCALHOSTNAME n n $logdir -c $logdir/config
200 LOCALHOSTNAME y n $logdir -c $logdir/config
202 # 2. Test duplicate directory names ; primary and then non-primary
204 LOCALHOSTNAME y n $logdir -c $logdir/config
205 LOCALHOSTNAME n n $logdir -c $logdir/config
207 # 3. Test directory names which are subnames
209 LOCALHOSTNAME y n $logdir2 -c $logdir/config
210 LOCALHOSTNAME n n $logdir -c $logdir/config
212 # 4. Test when have hosts which are subnames
214 $host1 y n $logdir/$host1 -c $logdir/config
215 $host2 n n $logdir/$host2 -c $logdir/config
217 # 5. Putting all the cases together
219 LOCALHOSTNAME y n $logdir.1 -c $logdir/config
220 LOCALHOSTNAME n n $logdir.2 -c $logdir/config
221 $host1 n n $logdir.3 -c $logdir/config
222 $host1 n n $logdir.4 -c $logdir/config
223 $host2 n n $logdir.5 -c $logdir/config
224 $host2 n n $logdir.6 -c $logdir/config
227 # which tests to try out
232 echo >>$here/$seq.full
233 echo "=== test $i ===" >>$here/$seq.full
236 # create the control file from master
237 _extract_control
$i > $logdir/control
238 echo "--- control ---" >>$here/$seq.full
239 cat $logdir/control
>>$here/$seq.full
241 # let's see what control file we are using
243 _filter
< $logdir/control
246 echo "log mandatory on once pmcd.control.debug" >$logdir/config
247 echo "--- pmlogger_check ---" >> $here/$seq.full
248 $sudo $PCP_BINADM_DIR/pmlogger_check
-V -c $logdir/control
-l $tmp.log
249 $sudo cat $tmp.log |
tee -a $here/$seq.full | _filter
252 echo |
tee -a $here/$seq.full
253 echo "Restart tests while other pmloggers are running ..." |
tee -a $here/$seq.full
255 # now for the 5. case, terminate the pmloggers one at a time and
256 # check the pmlogger_check restarts the right one
258 for log
in $logdir.1 $logdir.2 $logdir.3 $logdir.4 $logdir.5 $logdir.6
260 echo |
tee -a $here/$seq.full
261 echo "Kill off one pmlogger ..." |
tee -a $here/$seq.full
262 pid
=`grep -l $log $PCP_TMP_DIR/pmlogger/[0-9]* | sed -e 's/.*pmlogger.//'`
264 num_pid
=`echo "$pid" | wc -w | sed -e 's/ *//g'`
265 while [ $try -lt 10 -a $num_pid -ne 1 ]
267 echo "try $try num_pid=$num_pid: `echo $pid`" >>$here/$seq.full
269 pid
=`grep -l $log $PCP_TMP_DIR/pmlogger/[0-9]* | sed -e 's/.*pmlogger.//'`
270 num_pid
=`echo "$pid" | wc -w | sed -e 's/ *//g'`
273 if [ $num_pid -ne 1 ]
275 echo "Arrgh ... failed to find just one pmlogger to kill ... see $seq.full"
276 echo "" >>$here/$seq.full
277 echo "Arrgh ... failed to find just one pmlogger to kill ..." >>$here/$seq.full
278 $PCP_PS_PROG $PCP_PS_ALL_FLAGS |
egrep 'PID|[p]mlogger' >>$here/$seq.full
279 echo "$log contents ..." >>$here/$seq.full
280 ls -l $log >>$here/$seq.full
281 for ctl
in $PCP_TMP_DIR/pmlogger
/[0-9]*
283 echo "+++ $ctl +++" >>$here/$seq.full
284 cat $ctl >>$here/$seq.full
286 echo "+ grep -l $log"' $PCP_TMP_DIR/pmlogger/[0-9]*' >>$here/$seq.full
287 grep $log $PCP_TMP_DIR/pmlogger
/[0-9]* >>$here/$seq.full
290 echo "Victim pid=$pid" >>$here/$seq.full
291 $PCP_PS_PROG $PCP_PS_ALL_FLAGS \
292 |
$PCP_AWK_PROG >>$here/$seq.full
'
295 print "PID not in field 2 of ps output!"
300 $2 == '"$pid"' { print; exit(0) }'
301 echo "+++ $PCP_TMP_DIR/pmlogger/$pid +++" >>$here/$seq.full
302 cat $PCP_TMP_DIR/pmlogger
/$pid >>$here/$seq.full
304 echo "Check ..." |
tee -a $here/$seq.full
305 $sudo $PCP_BINADM_DIR/pmlogger_check
-V -V -c $logdir/control
-l $tmp.log
307 |
tee -a $here/$seq.full \
308 |
sed -e '/^... try /d' \