File: 878

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 (177 lines) | stat: -rwxr-xr-x 4,735 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
175
176
177
#!/bin/sh
# PCP QA Test No. 878
# Exercise pmdapipe output capture.
#
# Copyright (c) 2015-2016 Red Hat.
#

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

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

[ -f $PCP_PMDAS_DIR/pipe/pmdapipe ] || _notrun "pipe PMDA not installed"
id -u nobody >/dev/null 2>&1 || _notrun "User nobody unavailable"

hostname=`hostname`
PIPE_CONF_FILE=$PCP_PMDAS_DIR/pipe/pipe.conf
PIPE_CONF_DIR=$PCP_SYSCONF_DIR/pipe.conf.d
PIPE_INDOM_CACHE=$PCP_VAR_DIR/config/pmda/128.0

status=1	# failure is the default!
username=`id -u -n`

_cleanup()
{
    $sudo rm -fr $PIPE_CONF_DIR/config-$seq
    [ -d $PIPE_CONF_DIR.$seq ] && _restore_config $PIPE_CONF_DIR
    if [ -f $PIPE_CONF_FILE.$seq ]
    then
	_restore_config $PIPE_CONF_FILE
    else
	$sudo rm -f $PIPE_CONF_FILE
    fi
    if [ -f $PIPE_INDOM_CACHE.$seq ]
    then
	_restore_config $PIPE_INDOM_CACHE
    else
	$sudo rm -f $PIPE_INDOM_CACHE
    fi
    # note: _restore_auto_restart pmcd done in _cleanup_pmda()
    _cleanup_pmda pipe
}

_prepare_pmda pipe
trap "_cleanup; exit \$status" 0 1 2 3 15

# don't need to regenerate config.default with pmlogconf
#
PMLOGGER_CHECK_SKIP_LOGCONF=yes; export PMLOGGER_CHECK_SKIP_LOGCONF

_stop_auto_restart pmcd

# move aside pipe configuration state to be restored later.
[ -d $PIPE_CONF_DIR ] && _save_config $PIPE_CONF_DIR
[ -f $PIPE_CONF_FILE ] && _save_config $PIPE_CONF_FILE
[ -f $PIPE_INDOM_CACHE ] && _save_config $PIPE_INDOM_CACHE

cat <<EOF > $tmp.config
# Installed by PCP QA test $seq on `date`
# instance   user        command
empty-line   $username   echo
echo-all     $username   echo \$0
echo-two     $username   echo \$1 \$2
ls-pipe      root        ls $PCP_PMDAS_DIR/pipe | LC_COLLATE=POSIX sort
EOF

cat << EOF1 > $tmp.confdir
noop         nobody      exit
[access]
disallow user $username : noop
EOF1

_filter_pmval()
{
    sed \
	-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"\
	-e "s/$hostname/HOST/g" \
    #end
}

# pmdapipe is installed with custom configuration, check it
#
_exercise_pipe()
{
    echo "== basic empty line (ok) =="
    pmval -x '' -i empty-line -t 0.25 -s 8 pipe.firehose | _filter_pmval

    echo "== basic echo mirror (ok) =="
    pmval -x 'hello' -i echo-all -t 0.25 -s 8 pipe.firehose | _filter_pmval

    echo "== extra parameters (ok) =="
    pmval -x '1 two 3' -i echo-two -t 0.25 -s 8 pipe.firehose | _filter_pmval

    echo "== bad parameters (expect failure) =="
    pmval -x '1;2' -i echo-all -t 0.25 -s 3 pipe.firehose | _filter_pmval

    echo "== insufficient parameters (expect failure) =="
    pmval -x 'one' -i echo-two -t 0.25 -s 3 pipe.firehose | _filter_pmval

    echo "== disallowed access (expect failure) =="
    pmval -x '' -i noop -s 3 pipe.firehose | _filter_pmval
}

pmdapipe_remove()
{
    echo
    echo "=== remove pipe agent ==="
    $sudo ./Remove >$tmp.out 2>&1
    _filter_pmda_remove <$tmp.out
}

# install new (deterministic) configuration for pmcd/pmdapipe
#
pmdapipe_install()
{
    # start from known starting points
    cd $PCP_PMDAS_DIR/pipe
    $sudo ./Remove >/dev/null 2>&1

    $sudo rm -rf "$PIPE_CONF_DIR" "$PIPE_CONF_FILE" "$PIPE_INDOM_CACHE"
    $sudo mkdir -m 755 "$PIPE_CONF_DIR"

    $sudo mv $tmp.confdir $PIPE_CONF_DIR/config-$seq
    $sudo mv $tmp.config $PIPE_CONF_FILE

    echo
    echo "=== pipe agent installation ==="
    $sudo ./Install </dev/null >$tmp.out 2>&1
    cat $tmp.out >>$seq_full
    # Check pipe metrics have appeared ... X metrics and Y values
    _filter_pmda_install <$tmp.out \
    | sed \
        -e 's/[0-9][0-9]* warnings, //' \
    | $PCP_AWK_PROG '
/Check pipe metrics have appeared/ { if ($7 >= 5 && $7 <= 25) $7 = "X"
                                     if ($10 >= 3 && $10 <= 25) $10 = "Y"
                                   }
                                   { print }'
}

_filter_pipe()
{
    # cull message resulting from non-event check access (pminfo/pmprobe)
    grep -v 'No value(s) available'
}

# real QA test starts here
pmdapipe_install

# avoid race and try to make sure data is ready before the pminfo below
#
sleep 2

# pmcd should have been started by the Install process - check
# a sub-tree that is known-good for all pipe versions
# and setup states.
if pminfo -v pipe > $tmp.info 2> $tmp.err
then
    echo "--- pminfo stdout ---" >>$seq_full
    cat $tmp.info >>$seq_full
    echo "--- pminfo stderr ---" >>$seq_full
    cat $tmp.err >>$seq_full
    cat $tmp.info $tmp.err | _filter_pipe
    _exercise_pipe
else
    echo "... failed! ... here is the Install log ..."
    cat $tmp.out
    echo "... pminfo -v pipe ..."
    cat $tmp.info $tmp.err
fi

pmdapipe_remove
status=0
exit