@@ -6,13 +6,11 @@ import (
66	"math" 
77	"testing" 
88
9+ 	"github.com/cortexproject/cortex/pkg/util" 
10+ 	"github.com/cortexproject/cortex/pkg/util/validation" 
911	"github.com/prometheus/prometheus/model/labels" 
1012	"github.com/stretchr/testify/assert" 
1113	"github.com/stretchr/testify/mock" 
12- 	"github.com/stretchr/testify/require" 
13- 
14- 	"github.com/cortexproject/cortex/pkg/util" 
15- 	"github.com/cortexproject/cortex/pkg/util/validation" 
1614)
1715
1816func  TestLimiter_maxSeriesPerMetric (t  * testing.T ) {
@@ -221,8 +219,7 @@ func runLimiterMaxFunctionTest(
221219			limits  :=  validation.Limits {IngestionTenantShardSize : testData .shardSize }
222220			applyLimits (& limits , testData .localLimit , testData .globalLimit )
223221
224- 			overrides , err  :=  validation .NewOverrides (limits , nil )
225- 			require .NoError (t , err )
222+ 			overrides  :=  validation .NewOverrides (limits , nil )
226223
227224			// Assert on default sharding strategy. 
228225			limiter  :=  NewLimiter (overrides , ring , util .ShardingStrategyDefault , testData .shardByAllLabels , testData .ringReplicationFactor , testData .ringZoneAwarenessEnabled , "" )
@@ -286,11 +283,10 @@ func TestLimiter_AssertMaxSeriesPerMetric(t *testing.T) {
286283			ring .On ("ZonesCount" ).Return (1 )
287284
288285			// Mock limits 
289- 			limits ,  err  :=  validation .NewOverrides (validation.Limits {
286+ 			limits  :=  validation .NewOverrides (validation.Limits {
290287				MaxLocalSeriesPerMetric :  testData .maxLocalSeriesPerMetric ,
291288				MaxGlobalSeriesPerMetric : testData .maxGlobalSeriesPerMetric ,
292289			}, nil )
293- 			require .NoError (t , err )
294290
295291			limiter  :=  NewLimiter (limits , ring , util .ShardingStrategyDefault , testData .shardByAllLabels , testData .ringReplicationFactor , false , "" )
296292			actual  :=  limiter .AssertMaxSeriesPerMetric ("test" , testData .series )
@@ -348,11 +344,10 @@ func TestLimiter_AssertMaxMetadataPerMetric(t *testing.T) {
348344			ring .On ("ZonesCount" ).Return (1 )
349345
350346			// Mock limits 
351- 			limits ,  err  :=  validation .NewOverrides (validation.Limits {
347+ 			limits  :=  validation .NewOverrides (validation.Limits {
352348				MaxLocalMetadataPerMetric :  testData .maxLocalMetadataPerMetric ,
353349				MaxGlobalMetadataPerMetric : testData .maxGlobalMetadataPerMetric ,
354350			}, nil )
355- 			require .NoError (t , err )
356351
357352			limiter  :=  NewLimiter (limits , ring , util .ShardingStrategyDefault , testData .shardByAllLabels , testData .ringReplicationFactor , false , "" )
358353			actual  :=  limiter .AssertMaxMetadataPerMetric ("test" , testData .metadata )
@@ -411,11 +406,10 @@ func TestLimiter_AssertMaxSeriesPerUser(t *testing.T) {
411406			ring .On ("ZonesCount" ).Return (1 )
412407
413408			// Mock limits 
414- 			limits ,  err  :=  validation .NewOverrides (validation.Limits {
409+ 			limits  :=  validation .NewOverrides (validation.Limits {
415410				MaxLocalSeriesPerUser :  testData .maxLocalSeriesPerUser ,
416411				MaxGlobalSeriesPerUser : testData .maxGlobalSeriesPerUser ,
417412			}, nil )
418- 			require .NoError (t , err )
419413
420414			limiter  :=  NewLimiter (limits , ring , util .ShardingStrategyDefault , testData .shardByAllLabels , testData .ringReplicationFactor , false , "" )
421415			actual  :=  limiter .AssertMaxSeriesPerUser ("test" , testData .series )
@@ -496,8 +490,7 @@ func TestLimiter_AssertMaxSeriesPerLabelSet(t *testing.T) {
496490			ring .On ("ZonesCount" ).Return (1 )
497491
498492			// Mock limits 
499- 			limits , err  :=  validation .NewOverrides (testData .limits , nil )
500- 			require .NoError (t , err )
493+ 			limits  :=  validation .NewOverrides (testData .limits , nil )
501494
502495			limiter  :=  NewLimiter (limits , ring , util .ShardingStrategyDefault , testData .shardByAllLabels , testData .ringReplicationFactor , false , "" )
503496			actual  :=  limiter .AssertMaxSeriesPerLabelSet ("test" , labels .FromStrings ("foo" , "bar" ), func (limits  []validation.LimitsPerLabelSet , limit  validation.LimitsPerLabelSet ) (int , error ) {
@@ -558,11 +551,10 @@ func TestLimiter_AssertMaxMetricsWithMetadataPerUser(t *testing.T) {
558551			ring .On ("ZonesCount" ).Return (1 )
559552
560553			// Mock limits 
561- 			limits ,  err  :=  validation .NewOverrides (validation.Limits {
554+ 			limits  :=  validation .NewOverrides (validation.Limits {
562555				MaxLocalMetricsWithMetadataPerUser :  testData .maxLocalMetadataPerUser ,
563556				MaxGlobalMetricsWithMetadataPerUser : testData .maxGlobalMetadataPerUser ,
564557			}, nil )
565- 			require .NoError (t , err )
566558
567559			limiter  :=  NewLimiter (limits , ring , util .ShardingStrategyDefault , testData .shardByAllLabels , testData .ringReplicationFactor , false , "" )
568560			actual  :=  limiter .AssertMaxMetricsWithMetadataPerUser ("test" , testData .metadata )
@@ -579,13 +571,12 @@ func TestLimiter_FormatError(t *testing.T) {
579571	ring .On ("ZonesCount" ).Return (1 )
580572
581573	// Mock limits 
582- 	limits ,  err  :=  validation .NewOverrides (validation.Limits {
574+ 	limits  :=  validation .NewOverrides (validation.Limits {
583575		MaxGlobalSeriesPerUser :              100 ,
584576		MaxGlobalSeriesPerMetric :            20 ,
585577		MaxGlobalMetricsWithMetadataPerUser : 10 ,
586578		MaxGlobalMetadataPerMetric :          3 ,
587579	}, nil )
588- 	require .NoError (t , err )
589580
590581	limiter  :=  NewLimiter (limits , ring , util .ShardingStrategyDefault , true , 3 , false , "please contact administrator to raise it" )
591582	lbls  :=  labels .FromStrings (labels .MetricName , "testMetric" )
0 commit comments