From c835a6351edcc1dcb681e70c31ac347a5d37f5e3 Mon Sep 17 00:00:00 2001 From: hagen1778 Date: Fri, 12 Jul 2024 11:06:45 +0200 Subject: [PATCH] lib/streamaggr: add missing test cases Signed-off-by: hagen1778 (cherry picked from commit 2f659562593ad129b5d4ec6a0a4fd9c4a5cf1afb) --- lib/streamaggr/streamaggr_test.go | 47 +++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) diff --git a/lib/streamaggr/streamaggr_test.go b/lib/streamaggr/streamaggr_test.go index 9bd7b4e3ff..28170cb961 100644 --- a/lib/streamaggr/streamaggr_test.go +++ b/lib/streamaggr/streamaggr_test.go @@ -48,6 +48,12 @@ func TestAggregatorsFailure(t *testing.T) { - interval: 1m `) + // Bad interval + f(` +- interval: 1foo + outputs: [total] +`) + // Invalid output f(` - interval: 1m @@ -65,6 +71,13 @@ func TestAggregatorsFailure(t *testing.T) { interval: 10ms `) + // bad dedup_interval + f(` +- interval: 1m + dedup_interval: 1foo + outputs: ["quantiles"] +`) + // interval isn't multiple of dedup_interval f(` - interval: 1m @@ -79,6 +92,27 @@ func TestAggregatorsFailure(t *testing.T) { outputs: ["quantiles"] `) + // bad staleness_interval + f(` +- interval: 1m + staleness_interval: 1foo + outputs: ["quantiles"] +`) + + // staleness_interval should be > interval + f(` +- interval: 1m + staleness_interval: 30s + outputs: ["quantiles"] +`) + + // staleness_interval should be multiple of interval + f(` +- interval: 1m + staleness_interval: 100s + outputs: ["quantiles"] +`) + // keep_metric_names is set for multiple inputs f(` - interval: 1m @@ -873,6 +907,19 @@ foo{abc="123", cde="1"} 4 10 foo:1m_by_cde_rate_sum{cde="1"} 0 `, "11") + // unique_samples output + f(` +- interval: 1m + outputs: [unique_samples] +`, ` +foo 1 10 +foo 2 20 +foo 1 10 +foo 2 20 +foo 3 20 +`, `foo:1m_unique_samples 3 +`, "11111") + // keep_metric_names f(` - interval: 1m