#!/bin/sh
# PCP QA Test No. 1710
# Exercises pmdastatsd -
# updates of non-config hardcoded metrics:
# - statsd.pmda.received (before: 0, after: 75)
# - statsd.pmda.parsed (before: 0, after: 45)
# - statsd.pmda.aggregated (before: 0, after: 35)
# - statsd.pmda.dropped (before: 0, after: 40)
# - statsd.pmda.time_spent_parsing (before: 0, after: non-zero)
# - statsd.pmda.time_spent_aggregating (before: 0, after: non-zero)
# - statsd.pmda.metrics_tracked, with its counter, gauge, duration and total instances (before: 0, 0, 0, 0; after: 4, 4, 2, 10)
#
# 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"

_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/04.py
cd $here
status=0
exit
