Skip to content

Commit 2585034

Browse files
committed
Updating testing
Signed-off-by: Paurush Garg <[email protected]>
1 parent dafddb3 commit 2585034

File tree

1 file changed

+14
-13
lines changed

1 file changed

+14
-13
lines changed

pkg/util/validation/validate_test.go

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -335,7 +335,6 @@ func TestValidateLabelDuplication(t *testing.T) {
335335
func TestValidateNativeHistogram(t *testing.T) {
336336
userID := "fake"
337337
lbls := cortexpb.FromLabelsToLabelAdapters(labels.FromStrings("foo", "bar"))
338-
maxNativeHistogramsSampleSizeBytesLimit := 100
339338

340339
// Test histogram has 4 positive buckets and 4 negative buckets so 8 in total. Schema set to 1.
341340
h := tsdbutil.GenerateTestHistogram(0)
@@ -353,13 +352,14 @@ func TestValidateNativeHistogram(t *testing.T) {
353352
exceedMaxSampleSizeBytesLimitFloatHistogram := tsdbutil.GenerateTestFloatHistogram(100)
354353

355354
for _, tc := range []struct {
356-
name string
357-
bucketLimit int
358-
resolutionReduced bool
359-
histogram cortexpb.Histogram
360-
expectedHistogram cortexpb.Histogram
361-
expectedErr error
362-
discardedSampleLabelValue string
355+
name string
356+
bucketLimit int
357+
resolutionReduced bool
358+
histogram cortexpb.Histogram
359+
expectedHistogram cortexpb.Histogram
360+
expectedErr error
361+
discardedSampleLabelValue string
362+
maxNativeHistogramsSampleSizeBytesLimit int
363363
}{
364364
{
365365
name: "no limit, histogram",
@@ -458,18 +458,19 @@ func TestValidateNativeHistogram(t *testing.T) {
458458
discardedSampleLabelValue: nativeHistogramInvalidSchema,
459459
},
460460
{
461-
name: "exceed max sample size bytes limit",
462-
histogram: cortexpb.FloatHistogramToHistogramProto(0, exceedMaxSampleSizeBytesLimitFloatHistogram.Copy()),
463-
expectedErr: newNativeHistogramSampleSizeBytesExceededError(lbls, 126, maxNativeHistogramsSampleSizeBytesLimit),
464-
discardedSampleLabelValue: nativeHistogramSampleSizeBytesExceeded,
461+
name: "exceed max sample size bytes limit",
462+
histogram: cortexpb.FloatHistogramToHistogramProto(0, exceedMaxSampleSizeBytesLimitFloatHistogram.Copy()),
463+
expectedErr: newNativeHistogramSampleSizeBytesExceededError(lbls, 126, 100),
464+
discardedSampleLabelValue: nativeHistogramSampleSizeBytesExceeded,
465+
maxNativeHistogramsSampleSizeBytesLimit: 100,
465466
},
466467
} {
467468
t.Run(tc.name, func(t *testing.T) {
468469
reg := prometheus.NewRegistry()
469470
validateMetrics := NewValidateMetrics(reg)
470471
limits := new(Limits)
471472
limits.MaxNativeHistogramBuckets = tc.bucketLimit
472-
limits.MaxNativeHistogramsSampleSizeBytes = maxNativeHistogramsSampleSizeBytesLimit
473+
limits.MaxNativeHistogramsSampleSizeBytes = tc.maxNativeHistogramsSampleSizeBytesLimit
473474
actualHistogram, actualErr := ValidateNativeHistogram(validateMetrics, limits, userID, lbls, tc.histogram)
474475
if tc.expectedErr != nil {
475476
require.Equal(t, tc.expectedErr, actualErr)

0 commit comments

Comments
 (0)