#!/bin/sh
# PCP QA Test No. 1715
# Exercises pmdastatsd
# - hdr histogram aggregation on duration metrics
# Since agent works with UDP datagrams, we have to take into account the fact that not all payloads will get processed and will get lost.
# Following test assumes that at least 10% of datagrams gets processed and measued values are within 35% +/- of expected values
#
# Copyright (c) 2020 Red Hat.
#

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

# get standard environment, filters and checks
. ./common.python

test -e $PCP_PMDAS_DIR/statsd/pmdastatsd || _notrun "statsd PMDA not installed"

_check_valgrind

_cleanup()
{
    cd $here
    $sudo rm -rf $tmp $tmp.*
}

status=1	# failure is the default!
$sudo rm -rf $tmp $tmp.* $seq.full
trap "_cleanup; exit \$status" 0 1 2 3 15

_prepare_pmda statsd
# note: _restore_auto_restart pmcd done in _cleanup_pmda()
trap "_cleanup_pmda statsd; exit \$status" 0 1 2 3 15
_stop_auto_restart pmcd

cd $here/statsd/src
$sudo $python cases/09.py 2>>$here/$seq.full
cd $here
status=0
exit
