File: 1226

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 (174 lines) | stat: -rwxr-xr-x 5,044 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
#!/bin/sh
# PCP QA Test No. 1226
# pmiectl - basic functionality
#
# see qa/1204 for the pmlogctl variant of this test
#
# Copyright (c) 2020 Ken McDonell.  All Rights Reserved.
#

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

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

if pmiectl -c default status 2>/dev/null | grep ' default ' >/dev/null
then
    _notrun "at least one pmie already defined for \"default\" class"
fi

_cleanup()
{
    echo "_cleanup: ..." >>$seq_full
    cd $here
    $sudo pmiectl -f -c default destroy localhost >>$seq_full 2>&1
    $sudo pmiectl -a -f -c pmfind destroy localhost >>$seq_full 2>&1
    pmiectl status localhost >$tmp.tmp 2>&1
    cat $tmp.tmp >>$seq_full
    if grep 'localhost not defined in any pmie control file' $tmp.tmp >/dev/null
    then
	# all good
	:
    else
	# really make sure any errant pmie we started will be stopped
	#
	PCPQA_KILL_SIGNAL=KILL; export PCPQA_KILL_SIGNAL
	$sudo pmiectl -f -c default destroy localhost >>$seq_full 2>&1
	$sudo pmiectl -a -f -c pmfind destroy localhost >>$seq_full 2>&1
    fi
    $sudo rm -rf $tmp $tmp.*
    $sudo rm -rf $PCP_LOG_DIR/pmie/localhost
    $sudo rm -rf $PCP_LOG_DIR/pmie/pmfind-localhost
    $sudo rm -rf $PCP_LOG_DIR/pmie/$seq-foo
    if [ "$pmie_state" = off ]
    then
	_change_config pmie off
	_service pmie stop >>$seq_full 2>&1
    fi
}

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

_filter()
{
    tee -a $seq_full \
    | sed \
	-e '/^# created by pmiectl/s/ on .*/ on DATE/' \
	-e "s;$tmp\.;TMP.;g" \
	-e "s;$PCP_BINADM_DIR/;PCP_BINADM_DIR/;g" \
	-e "s;$PCP_LOG_DIR/pmie/;PCP_LOG_DIR/pmie/;g" \
	-e "s;$PCP_TMP_DIR/;PCP_TMP_DIR/;g" \
	-e "s;$PCP_TMPFILE_DIR/pmiectl\.[^/]*;PCP_TMPFILE_DIR/pmiectl.XXXXX;g" \
	-e "s;$PCP_ETC_DIR/;PCP_ETC_DIR/;g" \
    # end
}

# Build filter for any existing non-qa and non-primary pmie instances.
# The "pmcd Host" and "Class" fields from the pmiectl status output
# should suffice to uniquely identify each.
#
pmiectl status 2>&1 \
| $PCP_AWK_PROG >$tmp.awk '
NR == 1	{ next }
NF >= 5	{ if ($4 == "primary") next
	  print "$1 == \"" $1 "\" && $4 == \"" $4 "\" { next }"
	}
END	{ print "{ print }" }'

# Note status command output order is non-deterministic, hence the sort
# at the end
#
_filter_status()
{
    tee -a $seq_full \
    | $PCP_AWK_PROG -f $tmp.awk \
    | sed \
	-e "/^`hostname` .* primary /d" \
	-e 's/[ 	][ 	]*/ /g' \
    | $PCP_AWK_PROG '
$2 ~ /^[0-9][0-9]*$/	{ $2 = "<nrule>" }
$3 ~ /^[0-9][0-9]*$/	{ $3 = "<neval>" }
$5 ~ /^[0-9][0-9]*$/	{ $5 = "<pid>" }
			{ print }' >$tmp.tmp
    head -1 $tmp.tmp
    sed -e '1d' $tmp.tmp | LC_COLLATE=POSIX sort
}

# Need primary pmie running so pmiectl status output is deterministic
#
_get_config pmie >$tmp.tmp || _exit 1
pmie_state=`cat $tmp.tmp`
rm -f $tmp.tmp
[ "$pmie_state" = off ] && _change_config pmie on
if ! _service pmie start >>$seq_full 2>&1; then _exit 1; fi

# real QA test starts here

echo "== usage"
pmiectl --help 2>&1 | _filter

echo
echo '== -N -V create' | tee -a $seq_full
pmiectl -N -V create localhost 2>&1 | _filter

echo | tee -a $seq_full
echo '== create' | tee -a $seq_full
$sudo pmiectl create localhost 2>&1 | _filter
echo '== status' | tee -a $seq_full
pmiectl status 2>&1 | _filter_status
echo '== status localhost' | tee -a $seq_full
pmiectl status localhost 2>&1 | _filter_status

echo | tee -a $seq_full
echo '== stop' | tee -a $seq_full
$sudo pmiectl -V -V stop localhost 2>>$seq_full | _filter
pmsleep 1sec
echo '== status' | tee -a $seq_full
pmiectl status 2>&1 | _filter_status
echo '== status localhost' | tee -a $seq_full
pmiectl status localhost 2>&1 | _filter_status

echo | tee -a $seq_full
echo '== start' | tee -a $seq_full
$sudo pmiectl start localhost 2>&1 | _filter
echo '== status' | tee -a $seq_full
pmiectl status 2>&1 | _filter_status
echo '== status localhost' | tee -a $seq_full
pmiectl status localhost 2>&1 | _filter_status

echo | tee -a $seq_full
echo '== restart' | tee -a $seq_full
$sudo pmiectl restart localhost 2>&1 | _filter
echo '== status' | tee -a $seq_full
pmiectl status 2>&1 | _filter_status
echo '== status localhost' | tee -a $seq_full
pmiectl status localhost 2>&1 | _filter_status

echo | tee -a $seq_full
echo '== destroy' | tee -a $seq_full
$sudo pmiectl -V -V destroy localhost 2>>$seq_full | _filter
echo '== status' | tee -a $seq_full
pmiectl status 2>&1 | _filter_status
echo '== status localhost' | tee -a $seq_full
pmiectl status localhost 2>&1 | _filter_status

echo | tee -a $seq_full
echo '== cond-create' | tee -a $seq_full
$sudo pmiectl cond-create localhost 2>&1 | _filter
echo '== status' | tee -a $seq_full
pmiectl status 2>&1 | _filter_status
$sudo pmiectl -c pmfind destroy localhost 2>&1 | _filter

echo | tee -a $seq_full
echo "== cond-create -i $seq-foo" | tee -a $seq_full
$sudo pmiectl -i $seq-foo cond-create localhost 2>&1 | _filter
echo '== status' | tee -a $seq_full
pmiectl -V status 2>&1 | _filter_status

# success, all done
status=0
exit