File: 1111

package info (click to toggle)
pcp 7.0.5-1
  • links: PTS
  • area: main
  • in suites: forky, sid
  • size: 252,916 kB
  • sloc: ansic: 1,478,844; sh: 177,285; xml: 160,462; cpp: 83,809; python: 24,349; perl: 18,303; yacc: 6,877; lex: 2,864; makefile: 2,694; awk: 165; fortran: 60; java: 52
file content (112 lines) | stat: -rwxr-xr-x 3,815 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
#! /bin/sh
# PCP QA Test No. 1111
# checks basic pcp2influxdb functionality
#
# Copyright (c) 2015-2018 Red Hat.
#
seq=`basename $0`
echo "QA output created by $seq"

. ./common.python

$python -c "from pcp import pmapi" >/dev/null 2>&1
[ $? -eq 0 ] || _notrun "python pcp pmapi module not installed"
which socat >/dev/null 2>&1 || _notrun "socat binary not installed"
which pcp2influxdb >$seq_full 2>&1 || _notrun "pcp2influxdb not installed"

$python -c "import requests" >/dev/null 2>&1
[ $? -eq 0 ] || _notrun "python requests module not installed"
major=`$python -c 'import requests; print(requests.__version__.split(".")[0])'`
[ $major -ge 1 ] || _notrun "python requests module too old (v$major)"

port=8086
$PCP_BINADM_DIR/telnet-probe -c localhost $port \
	&& _notrun "Someone already listening on typical InfluxDB $port"

signal=$PCP_BINADM_DIR/pmsignal
status=1	# failure is the default!

trap "rm -f $tmp.*; exit \$status" 0 1 2 3 15

_full_stash()
{
    echo "--- pcp2influxdb stdout --" >>$seq_full
    cat $tmp.p2i.out >>$seq_full
    echo "--- pcp2influxdb stderr --" >>$seq_full
    cat $tmp.p2i.err >>$seq_full
    echo "--- socket cat stdout --" >>$seq_full
    cat $tmp.socat.out >>$seq_full
    echo "--- socket cat stderr --" >>$seq_full
    cat $tmp.socat.err >>$seq_full
}

pcp2influxdb="$python `which pcp2influxdb`"

echo | tee -a $seq_full
echo "=== 1. pcp2influxdb one-shot noauth ===" | tee -a $seq_full
socat tcp-listen:$port,reuseaddr - >$tmp.socat.out 2>$tmp.socat.err &
pid=$!
sleep 2
$pcp2influxdb -x roar -t 1 hinv.ncpu sample.control >$tmp.p2i.out 2>$tmp.p2i.err &
p2ipid=$!
sleep 3
$signal $pid $p2ipid >>$seq_full 2>&1
wait
grep -E -q "^POST /write\?db=roar" $tmp.socat.out
[ $? -eq 0 ] && echo "Found POST URL in noauth output"
grep -E -q "hinv_ncpu value=[0-9]+(\.[0-9]+)? [0-9]+$" $tmp.socat.out
[ $? -eq 0 ] && echo "Found proper metric body in noauth output"
grep -E -q "sample_control value= [0-9]+$" $tmp.socat.out
[ $? -eq 0 ] && echo "Found correct null value in noauth output"
_full_stash

echo "=== 2. pcp2influxdb noauth with tags ===" | tee -a $seq_full
socat tcp-listen:$port,reuseaddr - >$tmp.socat.out 2>$tmp.socat.err &
pid=$!
sleep 2
$pcp2influxdb -x roar -X host=me.example.com -t 1 hinv.ncpu \
        >$tmp.p2i.out 2>$tmp.p2i.err &
p2ipid=$!
sleep 3
$signal $pid $p2ipid >>$seq_full 2>&1
wait
grep -E -q "^POST /write\?db=roar" $tmp.socat.out
[ $? -eq 0 ] && echo "Found POST URL in noauth output"
grep -E -q "hinv_ncpu,host=me\.example\.com value=[0-9]+(\.[0-9]+)? [0-9]+$" $tmp.socat.out
[ $? -eq 0 ] && echo "Found proper metric body in noauth output"
_full_stash

echo "=== 3. pcp2influxdb auth with tags ===" | tee -a $seq_full
socat tcp-listen:$port,reuseaddr - >$tmp.socat.out 2>$tmp.socat.err &
pid=$!
sleep 2
$pcp2influxdb -x roar --db-user pcp --db-pass hey \
        --db-tags host=me.example.com -t 1 hinv.ncpu \
        >$tmp.p2i.out 2>$tmp.p2i.err &
p2ipid=$!
sleep 3
$signal $pid $p2ipid >>$seq_full 2>&1
wait
grep -E -q "^POST /write\?db=roar" $tmp.socat.out
[ $? -eq 0 ] && echo "Found POST URL in output"
grep -E -q "Authorization: Basic cGNwOmhleQ==" $tmp.socat.out
[ $? -eq 0 ] && echo "Found auth data in HTTP request"
grep -E -q "hinv_ncpu,host=me\.example\.com value=[0-9]+(\.[0-9]+)? [0-9]+$" $tmp.socat.out
[ $? -eq 0 ] && echo "Found proper metric body in output"
_full_stash

echo "=== 4. pcp2influxdb bad-instance tolerance ===" | tee -a $seq_full
rm -f $tmp.socat.out $tmp.socat.err
socat tcp-listen:$port,reuseaddr - >>$tmp.socat.out 2>>$tmp.socat.err &
pid=$!
sleep 2
$pcp2influxdb -t 2 -I sample.aggregate.null sample.string.hullo sample.bad >$tmp.p2i.out 2>$tmp.p2i.err &
p2ipid=$!
sleep 8 # enough for at least 2 messages
$signal $pid $p2ipid >>$seq_full 2>&1
wait
grep 'Excluding' $tmp.p2i.err
_full_stash

status=0
exit