@@ -5085,12 +5085,16 @@ func TestExpendedPostingsCacheIsolation(t *testing.T) {
5085
5085
cfg .BlocksStorageConfig .TSDB .BlockRanges = []time.Duration {2 * time .Hour }
5086
5086
cfg .LifecyclerConfig .JoinAfter = 0
5087
5087
cfg .BlocksStorageConfig .TSDB .PostingsCache = cortex_tsdb.TSDBPostingsCacheConfig {
5088
- SeedSize : 1 , // lets make sure all metric names collide
5088
+ SeedSize : 3 , // lets make sure all metric names collide
5089
5089
Head : cortex_tsdb.PostingsCacheConfig {
5090
- Enabled : true ,
5090
+ Enabled : true ,
5091
+ Ttl : time .Hour ,
5092
+ MaxBytes : 1024 * 1024 * 1024 ,
5091
5093
},
5092
5094
Blocks : cortex_tsdb.PostingsCacheConfig {
5093
- Enabled : true ,
5095
+ Enabled : true ,
5096
+ Ttl : time .Hour ,
5097
+ MaxBytes : 1024 * 1024 * 1024 ,
5094
5098
},
5095
5099
}
5096
5100
@@ -5102,21 +5106,22 @@ func TestExpendedPostingsCacheIsolation(t *testing.T) {
5102
5106
5103
5107
numberOfTenants := 100
5104
5108
wg := sync.WaitGroup {}
5105
- wg .Add (numberOfTenants )
5106
5109
5107
- for j := 0 ; j < numberOfTenants ; j ++ {
5108
- go func () {
5109
- defer wg .Done ()
5110
- userId := fmt .Sprintf ("user%v" , j )
5111
- ctx := user .InjectOrgID (context .Background (), userId )
5112
- _ , err = i .Push (ctx , cortexpb .ToWriteRequest (
5113
- []labels.Labels {labels .FromStrings (labels .MetricName , "foo" , "userId" , userId )}, []cortexpb.Sample {{Value : 2 , TimestampMs : 4 * 60 * 60 * 1000 }}, nil , nil , cortexpb .API ))
5114
- require .NoError (t , err )
5115
- }()
5110
+ for k := 0 ; k < 10 ; k ++ {
5111
+ wg .Add (numberOfTenants )
5112
+ for j := 0 ; j < numberOfTenants ; j ++ {
5113
+ go func () {
5114
+ defer wg .Done ()
5115
+ userId := fmt .Sprintf ("user%v" , j )
5116
+ ctx := user .InjectOrgID (context .Background (), userId )
5117
+ _ , err := i .Push (ctx , cortexpb .ToWriteRequest (
5118
+ []labels.Labels {labels .FromStrings (labels .MetricName , "foo" , "userId" , userId , "k" , strconv .Itoa (k ))}, []cortexpb.Sample {{Value : 2 , TimestampMs : 4 * 60 * 60 * 1000 }}, nil , nil , cortexpb .API ))
5119
+ require .NoError (t , err )
5120
+ }()
5121
+ }
5122
+ wg .Wait ()
5116
5123
}
5117
5124
5118
- wg .Wait ()
5119
-
5120
5125
wg .Add (numberOfTenants )
5121
5126
for j := 0 ; j < numberOfTenants ; j ++ {
5122
5127
go func () {
@@ -5131,8 +5136,8 @@ func TestExpendedPostingsCacheIsolation(t *testing.T) {
5131
5136
Matchers : []* client.LabelMatcher {{Type : client .EQUAL , Name : labels .MetricName , Value : "foo" }},
5132
5137
}, s )
5133
5138
require .NoError (t , err )
5134
- require .Len (t , s .series , 1 )
5135
- require .Len (t , s .series [0 ].Labels , 2 )
5139
+ require .Len (t , s .series , 10 )
5140
+ require .Len (t , s .series [0 ].Labels , 3 )
5136
5141
require .Equal (t , userId , cortexpb .FromLabelAdaptersToLabels (s .series [0 ].Labels ).Get ("userId" ))
5137
5142
}()
5138
5143
}
0 commit comments