blob: c736d9bc6c5492da66f59f4abbd5559b44dc2314 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
|
#! /bin/sh
# PCP QA Test No. 282
# Error handling in $PCP_RC_DIR/pcp
#
# Copyright (c) 2014 Red Hat.
# Copyright (c) 1995-2002 Silicon Graphics, Inc. All Rights Reserved.
#
seq=`basename $0`
echo "QA output created by $seq"
# get standard environment, filters and checks
. ./common.product
. ./common.filter
. ./common.check
. ./localconfig
[ $PCP_PLATFORM = linux -o $PCP_PLATFORM = darwin -o $PCP_PLATFORM = solaris ] \
|| _notrun "$PCP_PLATFORM is not yet supported in test $seq"
status=1 # failure is the default!
_needclean=true
sleepy=false
LOCALHOST=`hostname`
LOGGING_DIR=$PCP_LOG_DIR/pmlogger
CHECK=`which pmlogger_check`
[ -z "$CHECK" -o ! -x "$CHECK" ] && \
_notrun "Cannot find an executable pmlogger_check: \"$CHECK\""
_poke_pmcd()
{
$sudo $PCP_RC_DIR/pcp restart 2>&1 \
| tee -a $seq.full \
| sed \
-e '/ root .* .usr.etc.pmcd /s/.*/-- ps output line --/' \
-e '/UID .* PID /d' \
-e '/USER .* PID /d' \
-e "s/$LOCALHOST/HOST/g" \
-e 's|local:/*|HOST|g' \
| _filter_pcp_start \
| _filter_pmcd_log \
| _filter_cron_scripts \
| sed \
-e 's/\(install the pcp.sw.base\) .*/\1 ... PCP 2.0 or later .../' \
-e 's/.*\(consult PMLOGGER.CHECK(1), else\)/ ... \1/' \
-e '/root.*.PCP_BINADM_DIR.pmcd/s/.*/-- ps output line --/' \
-e '/pcp.*.PCP_BINADM_DIR.pmcd/s/.*/-- ps output line --/' \
-e '/^failed (status=1)/d' \
-e '/^Waiting for pmcd/s/\.\.\.[. ]*$/DOTS/' \
-e '/^$/d'
can_wait=5
i=0
while [ $i -lt $can_wait ]
do
clients=`pmprobe pmcd.numclients 2>/dev/null | sed -e 's/.* //'`
if [ $i -eq 0 ]
then
echo >>$seq.full
echo "+ pmprobe pmcd.numclients" >>$seq.full
pmprobe pmcd.numclients >>$seq.full 2>&1
echo "clients=\"$clients\"" >>$seq.full
fi
[ ! -z "$clients" ] && [ "$clients" -gt 0 ] && break
sleep 1
i=`expr $i + 1`
done
$PCP_ECHO_PROG $PCP_ECHO_N "=== probe pmcd: ""$PCP_ECHO_C"
x=`pmprobe pmcd.control.debug 2>&1 | sed -e "s/$LOCALHOST/HOST/g" -e 's|local:/*|HOST|g'`
if [ "$x" = "pmcd.control.debug 1" ]
then
$PCP_ECHO_PROG OK
else
$PCP_ECHO_PROG "$x"
fi
}
_poke_pmcd_n_logger()
{
pmafm $LOGGING_DIR/$LOCALHOST/Latest remove >$tmp.cmd 2>&1 \
&& $sudo sh $tmp.cmd
_poke_pmcd
can_wait=5
i=0
while [ $i -lt $can_wait ]
do
if pmlc -P </dev/null 2>&1 | grep "Connected to.* pmlogger" >/dev/null
then
sleep 2
break
fi
sleep 2
i=`expr $i + 1`
done
$PCP_ECHO_PROG $PCP_ECHO_N "=== probe pmlogger: ""$PCP_ECHO_C"
x=`echo connect primary | pmlc 2>&1 | sed -e "s/$LOCALHOST/HOST/g" -e 's|local:/*|HOST|g'`
sleep 2
if [ -z "$x" ]
then
$PCP_ECHO_PROG OK
else
$PCP_ECHO_PROG "$x"
if $sleepy
then
echo go check the logs while I wait a couple of minutes
sleep 240
fi
fi
}
_interrupt()
{
status=1
}
_save_setup()
{
for file in $PCP_PMCDCONF_PATH $SYSPMDA \
$CHECK $PCP_PMLOGGERCONTROL_PATH \
$PCP_PMLOGGEROPTIONS_PATH
do
[ -f $file.$seq ] && $sudo rm -f $file.$seq
[ -f $file ] && $sudo cp -p $file $file.$seq
done
}
_cleanup()
{
trap "" 0 1 2 3 15
if $_needclean
then
echo
echo "Restore the state of the universe ..."
for file in $PCP_PMCDCONF_PATH $SYSPMDA \
$CHECK $PCP_PMLOGGERCONTROL_PATH \
$PCP_PMLOGGEROPTIONS_PATH
do
if [ -f $file.$seq ]
then
$sudo rm -f $file
$sudo cp -p $file.$seq $file
$sudo rm -f $file.$seq
fi
done
[ -f $PCP_PMCD_PROG.$seq ] && \
$sudo mv -f $PCP_PMCD_PROG.$seq $PCP_PMCD_PROG
pmafm $LOGGING_DIR/$LOCALHOST/Latest remove >$tmp.cmd 2>&1 \
&& $sudo sh $tmp.cmd
$sudo $PCP_RC_DIR/pcp restart | _filter_pcp_start
_wait_for_pmcd
_needclean=false
fi
$sudo rm -f $tmp.*
exit $status
}
trap "_cleanup" 0
trap "_interrupt; _cleanup" 1 2 3 15
rm -f $seq.full
touch $seq.full
_exercise_rc_scripts()
{
echo
echo '=== expect error: no $PCP_PMCDCONF_PATH ==='
$sudo rm -f $PCP_PMCDCONF_PATH
_poke_pmcd
if [ $PCP_PLATFORM = linux ]
then
cat <<End-of-File >$tmp.out
# from qa/$seq
linux 60 dso linux_init $PCP_PMDAS_DIR/linux/pmda_linux.so
pmcd 2 dso pmcd_init $PCP_PMDAS_DIR/pmcd/pmda_pmcd.so
End-of-File
elif [ $PCP_PLATFORM = darwin ]
then
cat <<End-of-File >$tmp.out
# from qa/$seq
darwin 78 dso darwin_init $PCP_PMDAS_DIR/darwin/pmda_darwin.dylib
pmcd 2 dso pmcd_init $PCP_PMDAS_DIR/pmcd/pmda_pmcd.dylib
End-of-File
elif [ $PCP_PLATFORM = solaris ]
then
cat <<End-of-File >$tmp.out
# from qa/$seq
solaris 75 dso solaris_init $PCP_PMDAS_DIR/solaris/pmda_solaris.so
pmcd 2 dso pmcd_init $PCP_PMDAS_DIR/pmcd/pmda_pmcd.so
End-of-File
else
echo "Arrgh ... need pmcd.conf for $PCP_PLATFORM"
exit 1
fi
$sudo cp $tmp.out $PCP_PMCDCONF_PATH
echo
echo "=== simple case, no frills, no errors ==="
_poke_pmcd_n_logger
echo
echo "=== expected failure: a mere mortal ==="
osudo="$sudo"
sudo=''
_poke_pmcd
sudo="$osudo"
echo "=== start again ==="
_poke_pmcd_n_logger
echo
echo "=== expect 2 x connect failure: pmcd is true(1), so hard for pmlogger ==="
$sudo mv -f $PCP_PMCD_PROG $PCP_PMCD_PROG.$seq
$sudo cp `which true` $PCP_PMCD_PROG
_poke_pmcd_n_logger
$sudo mv -f $PCP_PMCD_PROG.$seq $PCP_PMCD_PROG
echo "=== start again ==="
_poke_pmcd_n_logger
echo "=== expect difficulty terminating pmcd ... it has been sent a SIGSTOP ==="
pid=`_get_pids_by_name pmcd`
if [ -z "$pid" ]
then
echo "Arrgh ... cannot find PID for pmcd!"
ps $PCP_PS_ALL_FLAGS
exit
fi
#DEBUG# ps $PCP_PS_ALL_FLAGS
$sudo kill -STOP $pid
_poke_pmcd
echo
echo "=== expect warning: PMLOGGER.CHECK moved, so no pmlogger ==="
$sudo rm $CHECK
_poke_pmcd_n_logger
$sudo cp -p $CHECK.$seq $CHECK
_disable_loggers
echo
echo "=== expect error: pmlogger/control moved, so no pmlogger ==="
$sudo rm -f $PCP_PMLOGGERCONTROL_PATH
_poke_pmcd_n_logger
}
# real QA test starts here
_save_setup
_disable_loggers
_exercise_rc_scripts
# success, all done
status=0
exit
|