3 # Exercise pmdapipe output capture.
5 # Copyright (c) 2015-2016 Red Hat.
9 echo "QA output created by $seq"
11 # get standard environment, filters and checks
16 [ -f $PCP_PMDAS_DIR/pipe
/pmdapipe
] || _notrun
"pipe PMDA not installed"
17 id
-u nobody
>/dev
/null
2>&1 || _notrun
"User nobody unavailable"
19 PIPE_CONF_FILE
=$PCP_PMDAS_DIR/pipe
/pipe.conf
20 PIPE_CONF_DIR
=$PCP_SYSCONF_DIR/pipe.conf.d
21 PIPE_INDOM_CACHE
=$PCP_VAR_DIR/config
/pmda
/128.0
23 status
=1 # failure is the default!
26 $sudo rm -rf $tmp $tmp.
* $seq.full
30 $sudo rm -fr $PIPE_CONF_DIR/config-
$seq
31 [ -d $PIPE_CONF_DIR.
$seq ] && _restore_config
$PIPE_CONF_DIR
32 [ -f $PIPE_CONF_FILE.
$seq ] && _restore_config
$PIPE_CONF_FILE
33 [ -f $PIPE_INDOM_CACHE.
$seq ] && _restore_config
$PIPE_INDOM_CACHE
38 trap "_cleanup; exit \$status" 0 1 2 3 15
40 # move aside pipe configuration state to be restored later.
41 [ -d $PIPE_CONF_DIR ] && _save_config
$PIPE_CONF_DIR
42 [ -f $PIPE_CONF_FILE ] && _save_config
$PIPE_CONF_FILE
43 [ -f $PIPE_INDOM_CACHE ] && _save_config
$PIPE_INDOM_CACHE
45 cat <<EOF > $tmp.config
46 # instance user command
47 empty-line $username echo
48 echo-all $username echo \$0
49 echo-two $username echo \$1 \$2
50 ls-pipe root ls $PCP_PMDAS_DIR/pipe | LC_COLLATE=POSIX sort
53 cat << EOF1 > $tmp.confdir
56 disallow user $username : noop
62 -e "s/[0-9][0-9]:[0-9][0-9]:[0-9][0-9].[0-9][0-9][0-9]/HH:MM:SS.MSEC/g"\
63 -e "s/$hostname/HOST/g" \
67 # pmdapipe is installed with custom configuration, check it
71 echo "== basic empty line (ok) =="
72 pmval
-x '' -i empty-line
-t 0.25 -s 8 pipe.firehose | _filter_pmval
74 echo "== basic echo mirror (ok) =="
75 pmval
-x 'hello' -i echo-all
-t 0.25 -s 8 pipe.firehose | _filter_pmval
77 echo "== extra parameters (ok) =="
78 pmval
-x '1 two 3' -i echo-two
-t 0.25 -s 8 pipe.firehose | _filter_pmval
80 echo "== bad parameters (expect failure) =="
81 pmval
-x '1;2' -i echo-all
-t 0.25 -s 3 pipe.firehose | _filter_pmval
83 echo "== insufficient parameters (expect failure) =="
84 pmval
-x 'one' -i echo-two
-t 0.25 -s 3 pipe.firehose | _filter_pmval
86 echo "== disallowed access (expect failure) =="
87 pmval
-x '' -i noop
-s 3 pipe.firehose | _filter_pmval
93 echo "=== remove pipe agent ==="
94 $sudo .
/Remove
>$tmp.out
2>&1
95 _filter_pmda_remove
<$tmp.out
98 # install new (deterministic) configuration for pmcd/pmdapipe
102 # start from known starting points
103 cd $PCP_PMDAS_DIR/pipe
104 $sudo .
/Remove
>/dev
/null
2>&1
105 $sudo $PCP_RC_DIR/pmcd stop
2>&1 | _filter_pcp_stop
107 $sudo rm -rf "$PIPE_CONF_DIR" "$PIPE_CONF_FILE" "$PIPE_INDOM_CACHE"
108 $sudo mkdir
-m 755 "$PIPE_CONF_DIR"
110 $sudo mv $tmp.confdir
$PIPE_CONF_DIR/config-
$seq
111 $sudo mv $tmp.config
$PIPE_CONF_FILE
114 echo "=== pipe agent installation ==="
115 $sudo .
/Install
</dev
/null
>$tmp.out
2>&1
116 cat $tmp.out
>>$here/$seq.full
117 # Check pipe metrics have appeared ... X metrics and Y values
118 _filter_pmda_install
<$tmp.out \
120 -e '/^Waiting for pmcd/s/\.\.\.[. ]*$/DOTS/' \
121 -e 's/[0-9][0-9]* warnings, //' \
123 /Check pipe metrics have appeared/ { if ($7 >= 5 && $7 <= 25) $7 = "X"
124 if ($10 >= 3 && $10 <= 25) $10 = "Y"
131 # cull message resulting from non-event check access (pminfo/pmprobe)
132 grep -v 'No value(s) available'
135 # real QA test starts here
138 # pmcd should have been started by the Install process - check
139 # a sub-tree that is known-good for all pipe versions
141 if pminfo
-v pipe
> $tmp.info
2> $tmp.err
143 cat $tmp.info
$tmp.err | _filter_pipe
146 echo "... failed! ... here is the Install log ..."
148 echo "... pminfo -v pipe ..."
149 cat $tmp.info
$tmp.err