@@ -335,7 +335,6 @@ func TestValidateLabelDuplication(t *testing.T) {
335
335
func TestValidateNativeHistogram (t * testing.T ) {
336
336
userID := "fake"
337
337
lbls := cortexpb .FromLabelsToLabelAdapters (labels .FromStrings ("foo" , "bar" ))
338
- maxNativeHistogramsSampleSizeBytesLimit := 100
339
338
340
339
// Test histogram has 4 positive buckets and 4 negative buckets so 8 in total. Schema set to 1.
341
340
h := tsdbutil .GenerateTestHistogram (0 )
@@ -353,13 +352,14 @@ func TestValidateNativeHistogram(t *testing.T) {
353
352
exceedMaxSampleSizeBytesLimitFloatHistogram := tsdbutil .GenerateTestFloatHistogram (100 )
354
353
355
354
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
363
363
}{
364
364
{
365
365
name : "no limit, histogram" ,
@@ -458,18 +458,19 @@ func TestValidateNativeHistogram(t *testing.T) {
458
458
discardedSampleLabelValue : nativeHistogramInvalidSchema ,
459
459
},
460
460
{
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 ,
465
466
},
466
467
} {
467
468
t .Run (tc .name , func (t * testing.T ) {
468
469
reg := prometheus .NewRegistry ()
469
470
validateMetrics := NewValidateMetrics (reg )
470
471
limits := new (Limits )
471
472
limits .MaxNativeHistogramBuckets = tc .bucketLimit
472
- limits .MaxNativeHistogramsSampleSizeBytes = maxNativeHistogramsSampleSizeBytesLimit
473
+ limits .MaxNativeHistogramsSampleSizeBytes = tc . maxNativeHistogramsSampleSizeBytesLimit
473
474
actualHistogram , actualErr := ValidateNativeHistogram (validateMetrics , limits , userID , lbls , tc .histogram )
474
475
if tc .expectedErr != nil {
475
476
require .Equal (t , tc .expectedErr , actualErr )
0 commit comments