Merge branch 'master' of git://git.pcp.io/pcp into qt
[pcp.git] / qa / 878
blob1b782a3d577d674738b2b08990b8318e3d18655e
1 #!/bin/sh
2 # PCP QA Test No. 878
3 # Exercise pmdapipe output capture.
5 # Copyright (c) 2015-2016 Red Hat.
8 seq=`basename $0`
9 echo "QA output created by $seq"
11 # get standard environment, filters and checks
12 . ./common.product
13 . ./common.filter
14 . ./common.check
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!
24 username=`id -u -n`
25 hostname=`hostname`
26 $sudo rm -rf $tmp $tmp.* $seq.full
28 _cleanup()
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
34 _cleanup_pmda pipe
37 _prepare_pmda pipe
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
51 EOF
53 cat << EOF1 > $tmp.confdir
54 noop nobody exit
55 [access]
56 disallow user $username : noop
57 EOF1
59 _filter_pmval()
61 sed \
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" \
64 #end
67 # pmdapipe is installed with custom configuration, check it
69 _exercise_pipe()
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
90 pmdapipe_remove()
92 echo
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
100 pmdapipe_install()
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
113 echo
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 \
119 | sed \
120 -e '/^Waiting for pmcd/s/\.\.\.[. ]*$/DOTS/' \
121 -e 's/[0-9][0-9]* warnings, //' \
122 | $PCP_AWK_PROG '
123 /Check pipe metrics have appeared/ { if ($7 >= 5 && $7 <= 25) $7 = "X"
124 if ($10 >= 3 && $10 <= 25) $10 = "Y"
126 { print }'
129 _filter_pipe()
131 # cull message resulting from non-event check access (pminfo/pmprobe)
132 grep -v 'No value(s) available'
135 # real QA test starts here
136 pmdapipe_install
138 # pmcd should have been started by the Install process - check
139 # a sub-tree that is known-good for all pipe versions
140 # and setup states.
141 if pminfo -v pipe > $tmp.info 2> $tmp.err
142 then
143 cat $tmp.info $tmp.err | _filter_pipe
144 _exercise_pipe
145 else
146 echo "... failed! ... here is the Install log ..."
147 cat $tmp.out
148 echo "... pminfo -v pipe ..."
149 cat $tmp.info $tmp.err
152 pmdapipe_remove
153 status=0
154 exit