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
|
#!/bin/sh
# PCP QA Test No. 1977
# Exercise pcp2opentelemetry HTTP POST functionality.
#
# Copyright (c) 2025 Red Hat. All Rights Reserved.
#
seq=`basename $0`
echo "QA output created by $seq"
. ./common.python
which pcp2opentelemetry >/dev/null 2>&1 || _notrun "pcp2opentelemetry not installed"
_cleanup()
{
cd $here
_restore_config $PCP_SYSCONF_DIR/labels
$sudo rm -rf $tmp $tmp.*
}
status=0 # success is the default!
$sudo rm -rf $tmp $tmp.* $seq.full
trap "_cleanup; exit \$status" 0 1 2 3 15
_filter_pcp2opentelemetry_http()
{
tee -a $here/$seq.full \
| col -b \
| sed \
-e '/\"asInt\":/ s/[0-9][0-9]*/INTEGER/' \
-e '/\"asDouble\":/ s/[0-9][0-9]*/DOUBLE/' \
-e 's/\"version\": .*/\"version\": VERSION/' \
-e 's/\"stringValue\": \".*\"/\"stringValue\": \"STRING\"/' \
-e 's/\"timeUnixNano\": [0-9][0-9]*\.[0-9][0-9]*.*/\"timeUnixNano\": TIME/' \
-e '/HTTP/d'
} >> $tmp.python2.out
# real QA test starts here
_save_config $PCP_SYSCONF_DIR/labels
$sudo rm -rf $PCP_SYSCONF_DIR/labels/*
port=`_find_free_port`
$PCP_PYTHON_PROG $here/src/pythonserver.py $port >$tmp.python.out 2>&1 &
pid=$!
sleep 2 # let server start up
echo "pcp2opentelemetry invocation" | tee -a $here/$seq.full
pcp2opentelemetry -s1 -u http://localhost:$port/receive hinv.ncpu >$tmp.json.out 2>$tmp.openjson.err
echo "pcp2opentelemetry HTTP POST (sorted):"
_filter_pcp2opentelemetry_http <$tmp.python.out
_check_http_filter <$tmp.python2.out
# terminate pythonserver.py now
pmsignal $pid >/dev/null 2>&1
# success, all done
exit
|