From: Peter A. Bigot Date: Fri, 16 May 2014 11:57:34 +0000 (-0500) Subject: tests: add test for new rrdcreate feature X-Git-Tag: v1.5.0-rc1~97^2~2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8d758daa0c50697e7627c64d7b0b9412ba903f8d;p=thirdparty%2Frrdtool-1.x.git tests: add test for new rrdcreate feature --- diff --git a/tests/alltests b/tests/alltests index 18638e2c..7822a3f4 100755 --- a/tests/alltests +++ b/tests/alltests @@ -17,3 +17,4 @@ cd $BASEDIR ./modify3 ./modify4 ./modify5 +./rrdcreate diff --git a/tests/rrdcreate b/tests/rrdcreate new file mode 100755 index 00000000..bd4c48ce --- /dev/null +++ b/tests/rrdcreate @@ -0,0 +1,160 @@ +#!/bin/bash + +. $(dirname $0)/functions + +runfailtest () { + desc="${1}" + shift + eval "${@}" > /tmp/test.out 2>/tmp/test.err + if [ 0 = $? ] ; then + echo -n "FAIL: ${desc} : " + cat /tmp/test.err + else + echo -n "OK: ${desc} : " + cat /tmp/test.err | sed -e 's@ERROR@OK@' + fi +} + +runfailtest "diagnose zero step" \ + $RRDTOOL create foo.rrd \ + --start now \ + --step 0 \ + DS:v:GAUGE:5:U:U \ + RRA:AVERAGE:0.5:1:100 + +runfailtest "diagnose negative step" \ + $RRDTOOL create foo.rrd \ + --start now \ + --step -1 \ + DS:v:GAUGE:5:U:U \ + RRA:AVERAGE:0.5:1:100 + +runfailtest "diagnose non-text step" \ + $RRDTOOL create foo.rrd \ + --start now \ + --step one \ + DS:v:GAUGE:5:U:U \ + RRA:AVERAGE:0.5:1:100 + +runfailtest "diagnose misaligned RRA step" \ + $RRDTOOL create foo.rrd \ + --start now \ + --step 10s \ + DS:v:GAUGE:5:U:U \ + RRA:AVERAGE:0.5:15s:1h + +runfailtest "diagnose misaligned RRA rows" \ + $RRDTOOL create foo.rrd \ + --start now \ + --step 10s \ + DS:v:GAUGE:5:U:U \ + RRA:AVERAGE:0.5:10s:75s + +runfailtest "diagnose zero RRA rows" \ + $RRDTOOL create foo.rrd \ + --start now \ + --step 5s \ + DS:v:GAUGE:5:U:U \ + RRA:AVERAGE:0.5:15s:10s + +runfailtest "diagnose missing heartbeat separator" \ + $RRDTOOL create foo.rrd \ + --start now \ + --step 5s \ + DS:v:GAUGE:5 \ + RRA:AVERAGE:0.5:15s:10s + +runfailtest "diagnose missing heartbeat" \ + $RRDTOOL create foo.rrd \ + --start now \ + --step 5s \ + DS:v:GAUGE:xx:U:U \ + RRA:AVERAGE:0.5:15s:1m + +runfailtest "diagnose max/min error" \ + $RRDTOOL create foo.rrd \ + --start now \ + --step 5s \ + DS:v:GAUGE:30s:5:3 \ + RRA:AVERAGE:0.5:15s:1m + +runfailtest "diagnose missing max" \ + $RRDTOOL create foo.rrd \ + --start now \ + --step 5s \ + DS:v:GAUGE:30s:53 \ + RRA:AVERAGE:0.5:15s:1m + +getinfo () { + $RRDTOOL create junk.rrd "${@}" + rrdinfo junk.rrd | sed -e '/^rra\[.*\]\.cur_row =/d' +} + +checkequiv () { + desc="${1}" ; shift + f1="${1}" ; shift + f2="${1}" ; shift + if diff -q ${f1} ${f2} ; then + echo "OK: ${desc}" + else + echo "FAIL ${desc}:" + diff -u ${f1} ${f2} + fi +} + +# Basic step-by-one test +getinfo \ + --start 0 --step 1 \ + DS:watts:GAUGE:300:0:24000 \ + RRA:AVERAGE:0.5:1:864000 \ + RRA:AVERAGE:0.5:60:129600 \ + RRA:AVERAGE:0.5:3600:13392 \ + RRA:AVERAGE:0.5:86400:3660 \ +> ct.out +getinfo \ + --start 0 --step 1s \ + DS:watts:GAUGE:5m:0:24000 \ + RRA:AVERAGE:0.5:1s:10d \ + RRA:AVERAGE:0.5:1m:90d \ + RRA:AVERAGE:0.5:1h:18M \ + RRA:AVERAGE:0.5:1d:10y \ +> dur.out +checkequiv "1-sec PDP equivalents" ct.out dur.out + +# Step-by-5 test +getinfo \ + --start 0 --step 5 \ + DS:watts:GAUGE:300:0:24000 \ + RRA:AVERAGE:0.5:1:172800 \ + RRA:AVERAGE:0.5:12:129600 \ + RRA:AVERAGE:0.5:720:13392 \ + RRA:AVERAGE:0.5:17280:3660 \ +> ct.out +getinfo \ + --start 0 --step 5s \ + DS:watts:GAUGE:5m:0:24000 \ + RRA:AVERAGE:0.5:5s:10d \ + RRA:AVERAGE:0.5:1m:90d \ + RRA:AVERAGE:0.5:1h:18M \ + RRA:AVERAGE:0.5:1d:10y \ +> dur.out +checkequiv "5-sec PDP equivalents" ct.out dur.out + +# HWPREDICT test +getinfo \ + --start 0 --step 300 \ + DS:ifOutOctets:COUNTER:1800:0:4294967295 \ + RRA:AVERAGE:0.5:1:2016 \ + RRA:HWPREDICT:1440:0.1:0.0035:288 \ +> ct.out +getinfo \ + --start 0 --step 5m \ + DS:ifOutOctets:COUNTER:30m:0:4294967295 \ + RRA:AVERAGE:0.5:1:2016 \ + RRA:HWPREDICT:5d:0.1:0.0035:1d:3 \ + RRA:SEASONAL:1d:0.1:2 \ + RRA:DEVSEASONAL:1d:0.1:2 \ + RRA:DEVPREDICT:5d:5 \ + RRA:FAILURES:1d:7:9:5 \ +> dur.out +checkequiv "HWPREDICT equivalents" ct.out dur.out