]> git.ipfire.org Git - thirdparty/rrdtool-1.x.git/commitdiff
Added PDP calculation tests
authorJens Kammler <jens.kammler@bertelsmann.de>
Tue, 5 Mar 2019 17:04:43 +0000 (18:04 +0100)
committerTobias Oetiker <tobi@oetiker.ch>
Wed, 6 Mar 2019 07:17:57 +0000 (08:17 +0100)
tests/Makefile.am
tests/Makefile.in
tests/pdp-calc1 [new file with mode: 0755]
tests/pdp-calc1-1-avg-300.output [new file with mode: 0644]
tests/pdp-calc1-1-avg-60.output [new file with mode: 0644]
tests/pdp-calc1-1-max-300.output [new file with mode: 0644]

index 79254dea0ee29da0cd07d5e5616f954f77af81da..f4416063b543a2e8568fd06ce8bfaf6f525202eb 100644 (file)
@@ -4,7 +4,8 @@ TESTS = modify1 modify2 modify3 modify4 modify5 \
        dump-restore \
        create-with-source-1 create-with-source-2 create-with-source-3 \
        create-with-source-4 create-with-source-and-mapping-1 \
-       create-from-template-1 dcounter1 vformatter1 xport1 list1
+       create-from-template-1 dcounter1 vformatter1 xport1 list1 \
+    pdp-calc1
 
 EXTRA_DIST = Makefile.am \
        functions $(TESTS) \
@@ -17,7 +18,8 @@ EXTRA_DIST = Makefile.am \
        tune1-testa-mod1.dump tune1-testa-mod2.dump tune1-testorg.dump \
        tune2-testa-mod1.dump tune2-testorg.dump \
        valgrind-supressions dcounter1 dcounter1.output graph1.output vformatter1 rpn1.output rpn2.output \
-       xport1.json.output xport1.xml.output
+       xport1.json.output xport1.xml.output \
+    pdp-calc1 pdp-calc1-1-avg-60.output pdp-calc1-1-avg-300.output pdp-calc1-1-max-300.output
        
 # NB: AM_TESTS_ENVIRONMENT not available until automake 1.12
 AM_TESTS_ENVIRONMENT = \
index 42160cd1c0163b4e5815f2dccedadb61b0e1a150..40d4befd82e24d96ca175ff059d56b42ea5de0b2 100644 (file)
@@ -542,7 +542,8 @@ TESTS = modify1 modify2 modify3 modify4 modify5 \
        dump-restore \
        create-with-source-1 create-with-source-2 create-with-source-3 \
        create-with-source-4 create-with-source-and-mapping-1 \
-       create-from-template-1 dcounter1 vformatter1 xport1 list1
+       create-from-template-1 dcounter1 vformatter1 xport1 list1 \
+    pdp-calc1
 
 EXTRA_DIST = Makefile.am \
        functions $(TESTS) \
@@ -555,7 +556,8 @@ EXTRA_DIST = Makefile.am \
        tune1-testa-mod1.dump tune1-testa-mod2.dump tune1-testorg.dump \
        tune2-testa-mod1.dump tune2-testorg.dump \
        valgrind-supressions dcounter1 dcounter1.output graph1.output vformatter1 rpn1.output rpn2.output \
-       xport1.json.output xport1.xml.output
+       xport1.json.output xport1.xml.output \
+    pdp-calc1 pdp-calc1-1-avg-60.output pdp-calc1-1-avg-300.output pdp-calc1-1-max-300.output
 
 
 # NB: AM_TESTS_ENVIRONMENT not available until automake 1.12
@@ -889,6 +891,13 @@ dcounter1.log: dcounter1
        --log-file $$b.log --trs-file $$b.trs \
        $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \
        "$$tst" $(AM_TESTS_FD_REDIRECT)
+pdp-calc1.log: pdp-calc1
+       @p='pdp-calc1'; \
+       b='pdp-calc1'; \
+       $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \
+       --log-file $$b.log --trs-file $$b.trs \
+       $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \
+       "$$tst" $(AM_TESTS_FD_REDIRECT)
 vformatter1.log: vformatter1
        @p='vformatter1'; \
        b='vformatter1'; \
diff --git a/tests/pdp-calc1 b/tests/pdp-calc1
new file mode 100755 (executable)
index 0000000..e02c7e9
--- /dev/null
@@ -0,0 +1,69 @@
+#!/bin/bash
+. $(dirname $0)/functions
+
+BASE=$BASEDIR/pdp_calc1
+BUILD=$BUILDDIR/pdp_calc1
+
+function do_update {
+  UPDATE_LIST=$1     ## List of update value items
+  MAX_ITEMS=${2:-1}  ## Max items per update call
+
+  UPDATE_STRING=""
+  TOTAL_COUNT=0
+  ITEM_COUNT=0
+
+  for ITEM in ${UPDATE_LIST[@]}; do
+    if [ $ITEM_COUNT -lt $MAX_ITEMS ]; then
+      UPDATE_STRING="$UPDATE_STRING $ITEM";
+      ((ITEM_COUNT++))
+    else
+      ((TOTAL_COUNT+=$ITEM_COUNT))
+      $RRDTOOL update ${BUILD}.rrd $UPDATE_STRING || return 1
+      ok "update $TOTAL_COUNT"
+      ITEM_COUNT=1
+      UPDATE_STRING="$ITEM"
+    fi
+  done
+
+ ## Last update with remaining items:
+  if [ ! -z "$UPDATE_STRING" ]; then
+      ((TOTAL_COUNT+=$ITEM_COUNT))
+      $RRDTOOL update ${BUILD}.rrd $UPDATE_STRING || return 1
+      ok "update $TOTAL_COUNT"
+  fi
+
+  return 0
+}
+
+$RRDTOOL create ${BUILD}.rrd --start 1548500640 --step 60 \
+         DS:Gauge:GAUGE:3600:0:10 DS:Counter:COUNTER:3600:0:U DS:Absolute:ABSOLUTE:3600:0:U \
+         RRA:AVERAGE:0.5:1:30 RRA:AVERAGE:0.5:5:6 RRA:MAX:0.5:5:6
+
+report "create" 
+
+declare -a UPDATE_LIST=("1548500700:0:0:0"       # Initalize PDP with 0
+                        "1548500760:1:60:60"     # 1.0 steps value 1
+                        "1548500790:0:60:0"      # 0.5 steps value 0
+                        "1548501000:1:270:210"   # 3.5 steps value 1
+                        "1548501070:2:390:120"   # 70 sec value 2
+                        "1548501101:U:U:U"       # 31 sec undefined (xff > 0.5)
+                        "1548501300:1:1000:199"  # 199 sec value 1 but counter will be re-initialized with 1000
+                        "1548501800:1:1500:500"  # 500 sec value 1
+                        "1548501839:10:1890:390" # 39 sec value 10
+                        "1548502200:0:1890:0"    # Fill up with 0
+                        "1548502210:2:1910:20"   # 10 sec value 2
+                        "1548502410:4:2710:800"  # 200 sec value 4
+                        "1548502510:5:3210:500"  # 100 sec value 5
+                       )
+
+do_update "$UPDATE_LIST" 3
+report "update all"
+
+is_cached && exit 0
+
+$RRDTOOL fetch ${BUILD}.rrd AVERAGE -r 60 -s 1548500640 -e 1548502500 | $DIFF --ignore-space-change - $BASEDIR/pdp-calc1-1-avg-60.output
+report "fetch avg 60"
+$RRDTOOL fetch ${BUILD}.rrd AVERAGE -r 300 -s 1548500640 -e 1548502500 | $DIFF --ignore-space-change - $BASEDIR/pdp-calc1-1-avg-300.output
+report "fetch avg 300"
+$RRDTOOL fetch ${BUILD}.rrd MAX -r 300 -s 1548500640 -e 1548502500 | $DIFF --ignore-space-change - $BASEDIR/pdp-calc1-1-max-300.output
+report "fetch max 300"
diff --git a/tests/pdp-calc1-1-avg-300.output b/tests/pdp-calc1-1-avg-300.output
new file mode 100644 (file)
index 0000000..0e8ff2b
--- /dev/null
@@ -0,0 +1,10 @@
+            Gauge             Counter            Absolute
+
+1548500700: -nan             -nan             -nan
+1548501000: 9.0000000000e-01 9.0000000000e-01 9.0000000000e-01
+1548501300: 1.2500000000e+00 -nan             1.1785714286e+00
+1548501600: 1.0000000000e+00 1.0000000000e+00 1.0000000000e+00
+1548501900: 1.9666666667e+00 1.9666666667e+00 1.9666666667e+00
+1548502200: 0.0000000000e+00 0.0000000000e+00 0.0000000000e+00
+1548502500: 4.2333333333e+00 4.2333333333e+00 4.2333333333e+00
+1548502800: -nan             -nan             -nan
diff --git a/tests/pdp-calc1-1-avg-60.output b/tests/pdp-calc1-1-avg-60.output
new file mode 100644 (file)
index 0000000..f231eb3
--- /dev/null
@@ -0,0 +1,34 @@
+            Gauge             Counter         Absolute
+
+1548500700: -nan             -nan             -nan
+1548500760: 1.0000000000e+00 1.0000000000e+00 1.0000000000e+00
+1548500820: 5.0000000000e-01 5.0000000000e-01 5.0000000000e-01
+1548500880: 1.0000000000e+00 1.0000000000e+00 1.0000000000e+00
+1548500940: 1.0000000000e+00 1.0000000000e+00 1.0000000000e+00
+1548501000: 1.0000000000e+00 1.0000000000e+00 1.0000000000e+00
+1548501060: 2.0000000000e+00 1.7142857143e+00 1.7142857143e+00
+1548501120: -nan             -nan             -nan
+1548501180: 1.0000000000e+00 -nan             1.0000000000e+00
+1548501240: 1.0000000000e+00 -nan             1.0000000000e+00
+1548501300: 1.0000000000e+00 -nan             1.0000000000e+00
+1548501360: 1.0000000000e+00 1.0000000000e+00 1.0000000000e+00
+1548501420: 1.0000000000e+00 1.0000000000e+00 1.0000000000e+00
+1548501480: 1.0000000000e+00 1.0000000000e+00 1.0000000000e+00
+1548501540: 1.0000000000e+00 1.0000000000e+00 1.0000000000e+00
+1548501600: 1.0000000000e+00 1.0000000000e+00 1.0000000000e+00
+1548501660: 1.0000000000e+00 1.0000000000e+00 1.0000000000e+00
+1548501720: 1.0000000000e+00 1.0000000000e+00 1.0000000000e+00
+1548501780: 1.0000000000e+00 1.0000000000e+00 1.0000000000e+00
+1548501840: 6.8333333333e+00 6.8333333333e+00 6.8333333333e+00
+1548501900: 0.0000000000e+00 0.0000000000e+00 0.0000000000e+00
+1548501960: 0.0000000000e+00 0.0000000000e+00 0.0000000000e+00
+1548502020: 0.0000000000e+00 0.0000000000e+00 0.0000000000e+00
+1548502080: 0.0000000000e+00 0.0000000000e+00 0.0000000000e+00
+1548502140: 0.0000000000e+00 0.0000000000e+00 0.0000000000e+00
+1548502200: 0.0000000000e+00 0.0000000000e+00 0.0000000000e+00
+1548502260: 3.6666666667e+00 3.6666666667e+00 3.6666666667e+00
+1548502320: 4.0000000000e+00 4.0000000000e+00 4.0000000000e+00
+1548502380: 4.0000000000e+00 4.0000000000e+00 4.0000000000e+00
+1548502440: 4.5000000000e+00 4.5000000000e+00 4.5000000000e+00
+1548502500: 5.0000000000e+00 5.0000000000e+00 5.0000000000e+00
+1548502560: -nan             -nan             -nan
diff --git a/tests/pdp-calc1-1-max-300.output b/tests/pdp-calc1-1-max-300.output
new file mode 100644 (file)
index 0000000..523d089
--- /dev/null
@@ -0,0 +1,10 @@
+            Gauge            Counter          Absolute
+
+1548500700: -nan             -nan             -nan
+1548501000: 1.0000000000e+00 1.0000000000e+00 1.0000000000e+00
+1548501300: 2.0000000000e+00 -nan             1.7142857143e+00
+1548501600: 1.0000000000e+00 1.0000000000e+00 1.0000000000e+00
+1548501900: 6.8333333333e+00 6.8333333333e+00 6.8333333333e+00
+1548502200: 0.0000000000e+00 0.0000000000e+00 0.0000000000e+00
+1548502500: 5.0000000000e+00 5.0000000000e+00 5.0000000000e+00
+1548502800: -nan             -nan             -nan