File: 956

package info (click to toggle)
pcp 7.1.0-1
  • links: PTS
  • area: main
  • in suites: forky, sid
  • size: 252,748 kB
  • sloc: ansic: 1,483,656; sh: 182,366; xml: 160,462; cpp: 83,813; python: 24,980; perl: 18,327; yacc: 6,877; lex: 2,864; makefile: 2,738; awk: 165; fortran: 60; java: 52
file content (182 lines) | stat: -rwxr-xr-x 4,681 bytes parent folder | download
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
#!/bin/sh
# PCP QA Test No. 956
# Exercise pmcd attribute PDU handling after agent failure.
#
# Copyright (c) 2015 Red Hat.
#

seq=`basename $0`
echo "QA output created by $seq"

# get standard environment, filters and checks
. ./common.product
. ./common.filter
. ./common.check

trap "rm -f $tmp.*" 0
_get_libpcp_config
$unix_domain_sockets || _notrun "No unix domain socket support available"

_filter()
{
    sed -e 's/\.\.\.*/\.\.\./g'
}

_cleanup()
{
    _service pmcd stop | _filter_pcp_stop
    unset PMCD_PORT
    unset PMCD_SOCKET
    _restore_config $PCP_PMCDOPTIONS_PATH
    _service pmcd restart 2>&1 | _filter_pcp_restart
    _wait_for_pmcd
    _restore_auto_restart pmcd
    _service pmlogger restart 2>&1 | _filter_pcp_restart
    _wait_for_pmlogger
    _restore_auto_restart pmlogger

    if pmprobe -I pmcd.agent.status | grep '"dynamic"' >/dev/null
    then
	# need to uninstall dynamic PMDA
	#
        cd $here/pmdas/dynamic
        $sudo ./Remove >>$seq_full 2>&1
        cd $here
    fi

    if pminfo | grep '^dynamic' >/dev/null
    then
	# need to cleanup PMNS
	#
        cd $here/pmdas/dynamic
        $sudo ./Remove >>$seq_full 2>&1
        cd $here
    fi

    $sudo rm -f $tmp.*
}

status=1	# failure is the default!
signal=$PCP_BINADM_DIR/pmsignal
trap "_cleanup; exit \$status" 0 1 2 3 15

port=`_get_port tcp 6060 6070`
if [ -z "$port" ]
then
    echo "Arrggh ... no free TCP port in the range 6060 ... 6070"
    $NETSTAT -a
    exit 1
fi
echo "port=$port" >>$seq_full
_save_config $PCP_PMCDOPTIONS_PATH
cat <<End-of-File >$tmp.newoptions
# New pmcd.options file created by PCP QA test $seq
#
-s $tmp.socket
End-of-File

_stop_auto_restart pmcd
_stop_auto_restart pmlogger
if ! _service pmlogger stop 2>&1; then _exit 1; fi \
| _filter_pcp_stop
_wait_pmlogger_end || _exit 1
if ! _service pmcd stop 2>&1; then _exit 1; fi \
| _filter_pcp_stop
_wait_pmcd_end || _exit 1

$sudo cp $tmp.newoptions $PCP_PMCDOPTIONS_PATH

# need to start pmcd indirectly in a shell script because sudo
# may cleanse the environment, which also means we cannot use
# the _service wrapper
#
echo "PMCD_PORT=$port; export PMCD_PORT" >$tmp.start
echo "PMCD_SOCKET=$tmp.socket; export PMCD_SOCKET" >>$tmp.start
echo "$PCP_RC_DIR/pmcd restart" >>$tmp.start
$sudo sh $tmp.start 2>&1 | _filter_pcp_start
PMCD_PORT=$port; export PMCD_PORT
PMCD_SOCKET=$tmp.socket; export PMCD_SOCKET
_wait_for_pmcd || _exit 1

cd $here/pmdas/dynamic
if [ -f GNUmakefile.install ]
then
    $PCP_MAKE_PROG -f GNUmakefile.install clean >>$seq_full 2>&1
    $PCP_MAKE_PROG -f GNUmakefile.install >>$seq_full 2>&1
else
    $PCP_MAKE_PROG clean >>$seq_full 2>&1
    $PCP_MAKE_PROG >>$seq_full 2>&1
fi
$sudo ./Install < /dev/null >$tmp.out 2>&1
cat $tmp.out | tee -a $seq_full | _filter_pmda_install | _filter
cd $here

# real QA test starts here
echo "Initial check of some metric access"
pmprobe -h unix:$tmp.socket -i hinv.ncpu

pmsleep 0.2

echo "Terminate a PMDA needing attributes" | tee -a $seq_full
date >>$seq_full
$PCP_PS_PROG $PCP_PS_ALL_FLAGS | grep -E '[P]PID|/[p]mdadynamic( |$)' >> $seq_full
$signal -s KILL -an pmdadynamic >> $seq_full 2>&1
$sudo $signal -s KILL -a pmdadynamic >> $seq_full 2>&1

# wait up to 2 seconds for dynamic PMDA to die
i=0
while [ $i -lt 10 ]
do
    $PCP_PS_PROG $PCP_PS_ALL_FLAGS >$tmp.tmp
    echo "ps probe #$i" >>$seq_full
    grep -E '[P]PID|/[p]mdadynamic( |$)' $tmp.tmp >>$seq_full
    # looking for a defunct PMDA process
    #
    if grep -E '(pmdadynamic.*defunct)|( Z .*pmdadynamic)|\(pmdadynamic\)' $tmp.tmp >/dev/null
    then
	rm -f $tmp.tmp
	break
    elif grep "pmdadynamic" $tmp.tmp >/dev/null
    then
	# still running, keep trying
	:
    else
	# not running at all
	rm -f $tmp.tmp
	break
    fi
    pmsleep 0.2
    i=`expr $i + 1`
done
if [ -f $tmp.tmp ]
then
    echo "Arrgh ... dynamic PMDA won't die"
    grep -E '[P]PID|[p]mdadynamic' $tmp.tmp
    exit
fi
date >>$seq_full

# and a bit more for pmcd to notice the PMDA has exited
pmsleep 3.75

echo "Tickle access to the failed PMDA, must see 'Try Again'"
pmprobe -h unix:$tmp.socket -i hinv.ncpu | tee $tmp.tmp
nval=`$PCP_AWK_PROG <$tmp.tmp '{print $2}'`
if [ -z "$nval" -o "$nval" -ge 0 ]
then
    # this is not expected
    #
    echo "Error: nval=$nval not as expected ... see $seq.full"
    pmprobe -h unix:$tmp.socket -i hinv.ncpu >>$seq_full
    pminfo -f pmcd.agent.status pmcd.agent.fenced >>$seq_full
    echo "+++ Tickle failed `date` +++" >>$seq_full
    cat $PCP_LOG_DIR/pmcd/pmcd.log >>$seq_full
    cat $PCP_LOG_DIR/pmcd/dynamic.log >>$seq_full
fi

echo "Verify subsequent return to healthy state"
pmprobe -h unix:$tmp.socket -i hinv.ncpu

# success, all done
status=0
exit