Drop unused condition check
[pcp.git] / qa / 878
blob5ba4ce32e37ab633bbc1ed31b8ffad804a7933da
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 [ -d $PIPE_CONF_DIR.$seq ] && _restore_config $PIPE_CONF_DIR
31 [ -f $PIPE_CONF_FILE.$seq ] && _restore_config $PIPE_CONF_FILE
32 [ -f $PIPE_INDOM_CACHE.$seq ] && _restore_config $PIPE_INDOM_CACHE
33 _cleanup_pmda pipe
36 _prepare_pmda pipe
37 trap "_cleanup; exit \$status" 0 1 2 3 15
39 # move aside pipe configuration state to be restored later.
40 [ -d $PIPE_CONF_DIR ] && _save_config $PIPE_CONF_DIR
41 [ -f $PIPE_CONF_FILE ] && _save_config $PIPE_CONF_FILE
42 [ -f $PIPE_INDOM_CACHE ] && _save_config $PIPE_INDOM_CACHE
44 cat <<EOF > $tmp.config
45 # instance user command
46 empty-line $username echo
47 echo-all $username echo \$0
48 echo-two $username echo \$1 \$2
49 ls-pipe root ls $PCP_PMDAS_DIR/pipe | LC_COLLATE=POSIX sort
50 EOF
52 cat << EOF1 > $tmp.confdir
53 noop nobody exit
54 [access]
55 disallow user $username : noop
56 EOF1
58 _filter_pmval()
60 sed \
61 -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"\
62 -e "s/$hostname/HOST/g" \
63 #end
66 # pmdapipe is installed with custom configuration, check it
68 _exercise_pipe()
70 echo "== basic empty line (ok) =="
71 pmval -x '' -i empty-line -t 0.25 -s 8 pipe.firehose | _filter_pmval
73 echo "== basic echo mirror (ok) =="
74 pmval -x 'hello' -i echo-all -t 0.25 -s 8 pipe.firehose | _filter_pmval
76 echo "== extra parameters (ok) =="
77 pmval -x '1 two 3' -i echo-two -t 0.25 -s 8 pipe.firehose | _filter_pmval
79 echo "== bad parameters (expect failure) =="
80 pmval -x '1;2' -i echo-all -t 0.25 -s 3 pipe.firehose | _filter_pmval
82 echo "== insufficient parameters (expect failure) =="
83 pmval -x 'one' -i echo-two -t 0.25 -s 3 pipe.firehose | _filter_pmval
85 echo "== disallowed access (expect failure) =="
86 pmval -x '' -i noop -s 3 pipe.firehose | _filter_pmval
89 pmdapipe_remove()
91 echo
92 echo "=== remove pipe agent ==="
93 $sudo ./Remove >$tmp.out 2>&1
94 _filter_pmda_remove <$tmp.out
97 # install new (deterministic) configuration for pmcd/pmdapipe
99 pmdapipe_install()
101 # start from known starting points
102 cd $PCP_PMDAS_DIR/pipe
103 $sudo ./Remove >/dev/null 2>&1
104 $sudo $PCP_RC_DIR/pmcd stop 2>&1 | _filter_pcp_stop
106 $sudo rm -rf "$PIPE_CONF_DIR" "$PIPE_CONF_FILE" "$PIPE_INDOM_CACHE"
107 $sudo mkdir -m 755 "$PIPE_CONF_DIR"
109 $sudo mv $tmp.confdir $PIPE_CONF_DIR/config-$seq
110 $sudo mv $tmp.config $PIPE_CONF_FILE
112 echo
113 echo "=== pipe agent installation ==="
114 $sudo ./Install </dev/null >$tmp.out 2>&1
115 cat $tmp.out >>$here/$seq.full
116 # Check pipe metrics have appeared ... X metrics and Y values
117 _filter_pmda_install <$tmp.out \
118 | sed \
119 -e '/^Waiting for pmcd/s/\.\.\.[. ]*$/DOTS/' \
120 -e 's/[0-9][0-9]* warnings, //' \
121 | $PCP_AWK_PROG '
122 /Check pipe metrics have appeared/ { if ($7 >= 5 && $7 <= 25) $7 = "X"
123 if ($10 >= 3 && $10 <= 25) $10 = "Y"
125 { print }'
128 _filter_pipe()
130 # cull message resulting from non-event check access (pminfo/pmprobe)
131 grep -v 'No value(s) available'
134 # real QA test starts here
135 pmdapipe_install
137 # pmcd should have been started by the Install process - check
138 # a sub-tree that is known-good for all pipe versions
139 # and setup states.
140 if pminfo -v pipe > $tmp.info 2> $tmp.err
141 then
142 cat $tmp.info $tmp.err | _filter_pipe
143 _exercise_pipe
144 else
145 echo "... failed! ... here is the Install log ..."
146 cat $tmp.out
147 echo "... pminfo -v pipe ..."
148 cat $tmp.info $tmp.err
151 pmdapipe_remove
152 status=0
153 exit