From a61965e94433dbcdf6799a6130e557b20268a670 Mon Sep 17 00:00:00 2001 From: Michael Desa Date: Mon, 27 Feb 2017 11:56:24 -0500 Subject: [PATCH] Add derivative cardinality test --- integrations/data/TestStream_Cardinality.srpl | 272 ++++++++++++++++++ integrations/streamer_test.go | 38 +++ 2 files changed, 310 insertions(+) create mode 100644 integrations/data/TestStream_Cardinality.srpl diff --git a/integrations/data/TestStream_Cardinality.srpl b/integrations/data/TestStream_Cardinality.srpl new file mode 100644 index 000000000..72a31ed43 --- /dev/null +++ b/integrations/data/TestStream_Cardinality.srpl @@ -0,0 +1,272 @@ +dbname +rpname +cpu,cpu=cpu0,host=localhost usage_user=20.1 0000000001 +dbname +rpname +cpu,cpu=cpu1,host=localhost usage_user=20.1 0000000001 +dbname +rpname +cpu,cpu=cpu2,host=localhost usage_user=20.1 0000000001 +dbname +rpname +cpu,cpu=cpu3,host=localhost usage_user=20.1 0000000001 +dbname +rpname +cpu,cpu=cpu4,host=localhost usage_user=20.1 0000000001 +dbname +rpname +cpu,cpu=cpu5,host=localhost usage_user=20.1 0000000001 +dbname +rpname +cpu,cpu=cpu6,host=localhost usage_user=20.1 0000000001 +dbname +rpname +cpu,cpu=cpu7,host=localhost usage_user=20.1 0000000001 +dbname +rpname +cpu,cpu=cpu-total,host=localhost usage_user=20.1 0000000001 +dbname +rpname +cpu,cpu=cpu0,host=localhost usage_user=20.1 0000000002 +dbname +rpname +cpu,cpu=cpu1,host=localhost usage_user=20.1 0000000002 +dbname +rpname +cpu,cpu=cpu2,host=localhost usage_user=20.1 0000000002 +dbname +rpname +cpu,cpu=cpu3,host=localhost usage_user=20.1 0000000002 +dbname +rpname +cpu,cpu=cpu4,host=localhost usage_user=20.1 0000000002 +dbname +rpname +cpu,cpu=cpu5,host=localhost usage_user=20.1 0000000002 +dbname +rpname +cpu,cpu=cpu6,host=localhost usage_user=20.1 0000000002 +dbname +rpname +cpu,cpu=cpu7,host=localhost usage_user=20.1 0000000002 +dbname +rpname +cpu,cpu=cpu-total,host=localhost usage_user=20.1 0000000002 +dbname +rpname +cpu,cpu=cpu0,host=localhost usage_user=20.1 0000000003 +dbname +rpname +cpu,cpu=cpu1,host=localhost usage_user=20.1 0000000003 +dbname +rpname +cpu,cpu=cpu2,host=localhost usage_user=20.1 0000000003 +dbname +rpname +cpu,cpu=cpu3,host=localhost usage_user=20.1 0000000003 +dbname +rpname +cpu,cpu=cpu4,host=localhost usage_user=20.1 0000000003 +dbname +rpname +cpu,cpu=cpu5,host=localhost usage_user=20.1 0000000003 +dbname +rpname +cpu,cpu=cpu6,host=localhost usage_user=20.1 0000000003 +dbname +rpname +cpu,cpu=cpu7,host=localhost usage_user=20.1 0000000003 +dbname +rpname +cpu,cpu=cpu-total,host=localhost usage_user=20.1 0000000003 +dbname +rpname +cpu,cpu=cpu0,host=localhost usage_user=20.1 0000000004 +dbname +rpname +cpu,cpu=cpu1,host=localhost usage_user=20.1 0000000004 +dbname +rpname +cpu,cpu=cpu2,host=localhost usage_user=20.1 0000000004 +dbname +rpname +cpu,cpu=cpu3,host=localhost usage_user=20.1 0000000004 +dbname +rpname +cpu,cpu=cpu4,host=localhost usage_user=20.1 0000000004 +dbname +rpname +cpu,cpu=cpu5,host=localhost usage_user=20.1 0000000004 +dbname +rpname +cpu,cpu=cpu6,host=localhost usage_user=20.1 0000000004 +dbname +rpname +cpu,cpu=cpu7,host=localhost usage_user=20.1 0000000004 +dbname +rpname +cpu,cpu=cpu-total,host=localhost usage_user=20.1 0000000004 +dbname +rpname +cpu,cpu=cpu0,host=localhost usage_user=20.1 0000000005 +dbname +rpname +cpu,cpu=cpu1,host=localhost usage_user=20.1 0000000005 +dbname +rpname +cpu,cpu=cpu2,host=localhost usage_user=20.1 0000000005 +dbname +rpname +cpu,cpu=cpu3,host=localhost usage_user=20.1 0000000005 +dbname +rpname +cpu,cpu=cpu4,host=localhost usage_user=20.1 0000000005 +dbname +rpname +cpu,cpu=cpu5,host=localhost usage_user=20.1 0000000005 +dbname +rpname +cpu,cpu=cpu6,host=localhost usage_user=20.1 0000000005 +dbname +rpname +cpu,cpu=cpu7,host=localhost usage_user=20.1 0000000005 +dbname +rpname +cpu,cpu=cpu-total,host=localhost usage_user=20.1 0000000005 +dbname +rpname +cpu,cpu=cpu0,host=localhost usage_user=20.1 0000000006 +dbname +rpname +cpu,cpu=cpu1,host=localhost usage_user=20.1 0000000006 +dbname +rpname +cpu,cpu=cpu2,host=localhost usage_user=20.1 0000000006 +dbname +rpname +cpu,cpu=cpu3,host=localhost usage_user=20.1 0000000006 +dbname +rpname +cpu,cpu=cpu4,host=localhost usage_user=20.1 0000000006 +dbname +rpname +cpu,cpu=cpu5,host=localhost usage_user=20.1 0000000006 +dbname +rpname +cpu,cpu=cpu6,host=localhost usage_user=20.1 0000000006 +dbname +rpname +cpu,cpu=cpu7,host=localhost usage_user=20.1 0000000006 +dbname +rpname +cpu,cpu=cpu-total,host=localhost usage_user=20.1 0000000006 +dbname +rpname +cpu,cpu=cpu0,host=localhost usage_user=20.1 0000000007 +dbname +rpname +cpu,cpu=cpu1,host=localhost usage_user=20.1 0000000007 +dbname +rpname +cpu,cpu=cpu2,host=localhost usage_user=20.1 0000000007 +dbname +rpname +cpu,cpu=cpu3,host=localhost usage_user=20.1 0000000007 +dbname +rpname +cpu,cpu=cpu4,host=localhost usage_user=20.1 0000000007 +dbname +rpname +cpu,cpu=cpu5,host=localhost usage_user=20.1 0000000007 +dbname +rpname +cpu,cpu=cpu6,host=localhost usage_user=20.1 0000000007 +dbname +rpname +cpu,cpu=cpu7,host=localhost usage_user=20.1 0000000007 +dbname +rpname +cpu,cpu=cpu-total,host=localhost usage_user=20.1 0000000007 +dbname +rpname +cpu,cpu=cpu0,host=localhost usage_user=20.1 0000000008 +dbname +rpname +cpu,cpu=cpu1,host=localhost usage_user=20.1 0000000008 +dbname +rpname +cpu,cpu=cpu2,host=localhost usage_user=20.1 0000000008 +dbname +rpname +cpu,cpu=cpu3,host=localhost usage_user=20.1 0000000008 +dbname +rpname +cpu,cpu=cpu4,host=localhost usage_user=20.1 0000000008 +dbname +rpname +cpu,cpu=cpu5,host=localhost usage_user=20.1 0000000008 +dbname +rpname +cpu,cpu=cpu6,host=localhost usage_user=20.1 0000000008 +dbname +rpname +cpu,cpu=cpu7,host=localhost usage_user=20.1 0000000008 +dbname +rpname +cpu,cpu=cpu-total,host=localhost usage_user=20.1 0000000008 +dbname +rpname +cpu,cpu=cpu0,host=localhost usage_user=20.1 0000000009 +dbname +rpname +cpu,cpu=cpu1,host=localhost usage_user=20.1 0000000009 +dbname +rpname +cpu,cpu=cpu2,host=localhost usage_user=20.1 0000000009 +dbname +rpname +cpu,cpu=cpu3,host=localhost usage_user=20.1 0000000009 +dbname +rpname +cpu,cpu=cpu4,host=localhost usage_user=20.1 0000000009 +dbname +rpname +cpu,cpu=cpu5,host=localhost usage_user=20.1 0000000009 +dbname +rpname +cpu,cpu=cpu6,host=localhost usage_user=20.1 0000000009 +dbname +rpname +cpu,cpu=cpu7,host=localhost usage_user=20.1 0000000009 +dbname +rpname +cpu,cpu=cpu-total,host=localhost usage_user=20.1 0000000009 +dbname +rpname +cpu,cpu=cpu0,host=localhost usage_user=20.1 0000000010 +dbname +rpname +cpu,cpu=cpu1,host=localhost usage_user=20.1 0000000010 +dbname +rpname +cpu,cpu=cpu2,host=localhost usage_user=20.1 0000000010 +dbname +rpname +cpu,cpu=cpu3,host=localhost usage_user=20.1 0000000010 +dbname +rpname +cpu,cpu=cpu4,host=localhost usage_user=20.1 0000000010 +dbname +rpname +cpu,cpu=cpu5,host=localhost usage_user=20.1 0000000010 +dbname +rpname +cpu,cpu=cpu6,host=localhost usage_user=20.1 0000000010 +dbname +rpname +cpu,cpu=cpu7,host=localhost usage_user=20.1 0000000010 +dbname +rpname +cpu,cpu=cpu-total,host=localhost usage_user=20.1 0000000010 +dbname +rpname diff --git a/integrations/streamer_test.go b/integrations/streamer_test.go index 8a799453c..774ded3ab 100644 --- a/integrations/streamer_test.go +++ b/integrations/streamer_test.go @@ -222,6 +222,44 @@ stream testStreamerWithOutput(t, "TestStream_DerivativeNN", script, 15*time.Second, er, false, nil) } +func TestStream_DerivativeCardinality(t *testing.T) { + + var script = ` +stream + |from() + .measurement('cpu') + .groupBy('host','cpu') + |derivative('usage_user') +` + + // Expected Stats + es := map[string]map[string]interface{}{ + "stream0": map[string]interface{}{ + "avg_exec_time_ns": int64(0), + "errors": int64(0), + "working_cardinality": int64(0), + "collected": int64(9), + "emitted": int64(9), + }, + "from1": map[string]interface{}{ + "avg_exec_time_ns": int64(0), + "errors": int64(0), + "working_cardinality": int64(0), + "collected": int64(9), + "emitted": int64(9), + }, + "derivative2": map[string]interface{}{ + "emitted": int64(0), + "working_cardinality": int64(9), + "avg_exec_time_ns": int64(0), + "errors": int64(0), + "collected": int64(9), + }, + } + + testStreamerCardinality(t, "TestStream_Cardinality", script, es) +} + func TestStream_HoltWinters(t *testing.T) { var script = ` stream