From 1aad4004c32b117979532345a49ef83f3f99a872 Mon Sep 17 00:00:00 2001 From: Linas Medziunas Date: Wed, 27 Sep 2023 09:34:43 +0300 Subject: [PATCH] Additional test case for ValidateHistogram Signed-off-by: Linas Medziunas --- tsdb/head_test.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/tsdb/head_test.go b/tsdb/head_test.go index 3d271e93b..a9179af62 100644 --- a/tsdb/head_test.go +++ b/tsdb/head_test.go @@ -4836,6 +4836,16 @@ func TestHistogramValidation(t *testing.T) { "valid histogram": { h: tsdbutil.GenerateTestHistograms(1)[0], }, + "valid histogram that has its Count (4) higher than the actual total of buckets (2 + 1)": { + // This case is possible if NaN values (which do not fall into any bucket) are observed. + h: &histogram.Histogram{ + ZeroCount: 2, + Count: 4, + Sum: math.NaN(), + PositiveSpans: []histogram.Span{{Offset: 0, Length: 1}}, + PositiveBuckets: []int64{1}, + }, + }, "rejects histogram that has too few negative buckets": { h: &histogram.Histogram{ NegativeSpans: []histogram.Span{{Offset: 0, Length: 1}},