MCPcopy Create free account
hub / github.com/cortexproject/cortex / TestValidateNativeHistogram

Function TestValidateNativeHistogram

pkg/util/validation/validate_test.go:404–721  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

402}
403
404func TestValidateNativeHistogram(t *testing.T) {
405 userID := "fake"
406 lbls := cortexpb.FromLabelsToLabelAdapters(labels.FromStrings("foo", "bar"))
407
408 // Test histogram has 4 positive buckets and 4 negative buckets so 8 in total. Schema set to 1.
409 h := tsdbutil.GenerateTestHistogram(0)
410 fh := tsdbutil.GenerateTestFloatHistogram(0)
411
412 histogramWithSchemaMin := tsdbutil.GenerateTestHistogram(0)
413 histogramWithSchemaMin.Schema = histogram.ExponentialSchemaMin
414 floatHistogramWithSchemaMin := tsdbutil.GenerateTestFloatHistogram(0)
415 floatHistogramWithSchemaMin.Schema = histogram.ExponentialSchemaMin
416
417 belowMinRangeSchemaHistogram := tsdbutil.GenerateTestFloatHistogram(0)
418 belowMinRangeSchemaHistogram.Schema = -5
419 exceedMaxRangeSchemaFloatHistogram := tsdbutil.GenerateTestFloatHistogram(0)
420 exceedMaxRangeSchemaFloatHistogram.Schema = 20
421 exceedMaxSampleSizeBytesLimitFloatHistogram := tsdbutil.GenerateTestFloatHistogram(100)
422
423 bucketNumMisMatchInPSpanFH := tsdbutil.GenerateTestFloatHistogram(0)
424 bucketNumMisMatchInPSpanFH.PositiveSpans[0].Length = 3
425
426 negativeSpanOffsetInPSpansFH := tsdbutil.GenerateTestFloatHistogram(0)
427 negativeSpanOffsetInPSpansFH.PositiveSpans[1].Offset = -1
428
429 bucketNumMisMatchInNSpanFH := tsdbutil.GenerateTestFloatHistogram(0)
430 bucketNumMisMatchInNSpanFH.NegativeSpans[0].Length = 3
431
432 negativeSpanOffsetInNSpansFH := tsdbutil.GenerateTestFloatHistogram(0)
433 negativeSpanOffsetInNSpansFH.NegativeSpans[1].Offset = -1
434
435 negativeBucketCountInNBucketsFH := tsdbutil.GenerateTestFloatHistogram(0)
436 negativeBucketCountInNBucketsFH.NegativeBuckets = []float64{-1.1, -1.2, -1.3, -1.4}
437
438 negativeBucketCountInPBucketsFH := tsdbutil.GenerateTestFloatHistogram(0)
439 negativeBucketCountInPBucketsFH.PositiveBuckets = []float64{-1.1, -1.2, -1.3, -1.4}
440
441 negativeCountFloatHistogram := tsdbutil.GenerateTestFloatHistogram(0)
442 negativeCountFloatHistogram.Count = -1.2345
443
444 negativeZeroCountFloatHistogram := tsdbutil.GenerateTestFloatHistogram(0)
445 negativeZeroCountFloatHistogram.ZeroCount = -1.2345
446
447 bucketNumMisMatchInPSpanH := tsdbutil.GenerateTestHistogram(0)
448 bucketNumMisMatchInPSpanH.PositiveSpans[0].Length = 3
449
450 negativeSpanOffsetInPSpansH := tsdbutil.GenerateTestHistogram(0)
451 negativeSpanOffsetInPSpansH.PositiveSpans[1].Offset = -1
452
453 bucketNumMisMatchInNSpanH := tsdbutil.GenerateTestHistogram(0)
454 bucketNumMisMatchInNSpanH.NegativeSpans[0].Length = 3
455
456 negativeSpanOffsetInNSpansH := tsdbutil.GenerateTestHistogram(0)
457 negativeSpanOffsetInNSpansH.NegativeSpans[1].Offset = -1
458
459 negativeBucketCountInNBucketsH := tsdbutil.GenerateTestHistogram(0)
460 negativeBucketCountInNBucketsH.NegativeBuckets = []int64{-1, -2, -3, -4}
461

Callers

nothing calls this directly

Calls 13

NewValidateMetricsFunction · 0.85
ValidateNativeHistogramFunction · 0.85
RunMethod · 0.65
EqualMethod · 0.65
CopyMethod · 0.45

Tested by

no test coverage detected