Merge branch 'master' of https://github.com/kmcdonell/pcp into kenj-merge
[pcp.git] / qa / 101
blob289eb39287bc05270dfd1f9641c5fc129331a580
1 #! /bin/sh
2 # PCP QA Test No. 101
3 # exercise the logging state compatibility matrix for pmlc ...
4 # initial: some instances for a metric
5 # request: different instances for the same metric
7 # Copyright (c) 2014 Red Hat.
8 # Copyright (c) 1995-2002 Silicon Graphics, Inc. All Rights Reserved.
11 seq=`basename $0`
12 echo "QA output created by $seq"
14 # get standard filters
15 . ./common.product
16 . ./common.filter
17 . ./common.check
19 trap "$sudo rm -f $tmp $tmp.*; exit" 0 1 2 3 15
21 _filter_pmlc()
23 sed \
24 -e '/connect /{
25 s/connect [0-9][0-9]*/connect PID/
26 s/@.*/@HOSTNAME/
27 }' \
28 -e '/Connected /{
29 s/ on port [0-9][0-9]*//
30 s/ pid [0-9][0-9]*//
31 s/ at .*/ at HOSTNAME/
32 }' \
33 -e 's/ nl / /' \
34 -e "/timed out/d" \
35 -e 's/Version [0-9].*/Version VERSION/' \
36 | $PCP_AWK_PROG '
37 /pmlc commands/ { skip = 1; print "[command summary deleted ...]" }
38 /metric-name/ { skip = 0; next }
39 skip == 1 { next }
40 { print }'
43 _filter_logger()
45 _filter_pmlogger_log \
46 | sed \
47 -e '/AF event queue/d'
50 _filter_dump()
52 _filter_pmdumplog \
53 | sed \
54 -e '/^$/d' \
55 -e '/pmResult/s/ .* numpmid/ ... numpmid/' \
56 -e '/inst /{
57 s/inst \[[0-9][0-9]* or "dks..."]/inst [DISK]/
58 s;inst \[[0-9][0-9]* or "/dev/[^"]*"];inst [DISK];
59 s;inst \[[0-9][0-9]* or ".*/dbs/.*\.dbf"];inst [FILE];
60 }' \
61 -e '/value /{
62 s/value [0-9][0-9]*\.[0-9][0-9]*e.[0-9][0-9]*/value NUMBER/
63 s/value [0-9][0-9]*\.[0-9][0-9]*/value NUMBER/
64 s/value [0-9][0-9]*e.[0-9][0-9]*/value NUMBER/
65 s/value [0-9][0-9]*/value NUMBER/
66 s/value \[.*]/value AGGREGATE/
67 s/value ".*"/value STRING/
68 }' \
69 -e "/pmcd\.pmlogger\./s/$logger_pid/LOGGER_PID/g" \
70 -e '/pmcd\.pmlogger\.port/s/value .*/value PORT/' \
71 -e '/pmcd\.pmlogger\.host/s/value ".*/value "HOST"/' \
72 -e '/pmcd\.pmlogger\.archive/s/value ".*/value "PATH"/' \
73 # end
76 _do_cmds()
78 for ctl in mandatory advisory
80 for state in "on once" maybe off
82 [ "$ctl $state" = "advisory maybe" ] && continue
83 for req_ctl in mandatory advisory
85 for req_state in "on once" maybe off
87 [ "$req_ctl $req_state" = "advisory maybe" ] && continue
88 ( echo "# setup"; \
89 echo "log mandatory maybe sample.bin "'[ "bin-100", "bin-200", "bin-300", "bin-400", "bin-500" ]'
90 echo "# $ctl $state -> $req_ctl $req_state"; \
91 echo "log $ctl $state sample.bin "'[ "bin-100", "bin-200", "bin-300"]'
92 ) | pmlc -ie $1
93 sleep 2
94 ( echo "log $req_ctl $req_state sample.bin "'[ "bin-400", "bin-500" ]'; \
95 echo "query sample.bin"; \
96 ) | pmlc -ie $1
97 sleep 2
98 # need sleeps to allow pmlogger to get a look in and
99 # to allow the pmlogger socket to be closed so the
100 # next pmlc invocation can get connected
101 done
102 done
103 done
104 done
109 # real QA test starts here
110 $sudo rm -f $tmp.0 $tmp.meta $tmp.index
112 # start pmlogger with the expected number of samples plus a few more
113 # to detect extra log output
115 _start_up_pmlogger -t 0.5sec -L -s 30 -c /dev/null -l $tmp.log $tmp >$tmp.err 2>&1
116 logger_pid=$pid
118 sleep 2
119 _do_cmds $logger_pid >$tmp.out 2>&1
121 # this chews up any remaining samples quickly so pmlogger terminates
123 echo "log mandatory on 25 msec sample.long.one" \
124 | pmlc -ie $logger_pid >>$tmp.out 2>&1
126 _filter_pmlc <$tmp.out
128 # wait for pmlogger to terminate
130 _wait_pmlogger_end $logger_pid
131 cat $tmp.err $tmp.log | _filter_logger
133 echo
134 if [ -s $tmp.0 ]
135 then
136 echo "Uniq filtered entries from pmdumplog ..."
137 pmdumplog $tmp \
138 | _filter_dump \
139 | sed -e 's/TIMESTAMP//' -e 's/^ *//' \
140 | LC_COLLATE=POSIX sort -u
141 pmdumplog $tmp >$seq.full 2>&1
142 else
143 echo "Archive log is empty"
146 exit