7
7
"fmt"
8
8
"io"
9
9
"math"
10
+ "math/rand"
10
11
"net"
11
12
"net/http"
12
13
"net/http/httptest"
@@ -182,9 +183,9 @@ func TestIngesterDeletionRace(t *testing.T) {
182
183
limits := defaultLimitsTestConfig ()
183
184
tenantLimits := newMockTenantLimits (map [string ]* validation.Limits {userID : & limits })
184
185
cfg := defaultIngesterTestConfig (t )
185
- cfg .BlocksStorageConfig .TSDB .CloseIdleTSDBInterval = 1 * time .Millisecond
186
+ cfg .BlocksStorageConfig .TSDB .CloseIdleTSDBInterval = 5 * time .Millisecond
186
187
cfg .BlocksStorageConfig .TSDB .CloseIdleTSDBTimeout = 10 * time .Second
187
- cfg .BlocksStorageConfig .TSDB .ExpandedCachingExpireInterval = 1 * time .Millisecond
188
+ cfg .BlocksStorageConfig .TSDB .ExpandedCachingExpireInterval = 5 * time .Millisecond
188
189
cfg .BlocksStorageConfig .TSDB .PostingsCache = cortex_tsdb.TSDBPostingsCacheConfig {
189
190
SeedSize : 3 , // lets make sure all metric names collide
190
191
Head : cortex_tsdb.PostingsCacheConfig {
@@ -205,15 +206,16 @@ func TestIngesterDeletionRace(t *testing.T) {
205
206
require .NoError (t , os .Mkdir (chunksDir , os .ModePerm ))
206
207
require .NoError (t , os .Mkdir (blocksDir , os .ModePerm ))
207
208
208
- ing , err := prepareIngesterWithBlocksStorageAndLimits (t , cfg , limits , tenantLimits , blocksDir , registry , true )
209
+ ing , err := prepareIngesterWithBlocksStorageAndLimits (t , cfg , limits , tenantLimits , blocksDir , registry , false )
209
210
require .NoError (t , err )
210
211
require .NoError (t , services .StartAndAwaitRunning (context .Background (), ing ))
212
+ defer services .StopAndAwaitTerminated (context .Background (), ing ) //nolint:errcheck
211
213
// Wait until it's ACTIVE
212
214
test .Poll (t , time .Second , ring .ACTIVE , func () interface {} {
213
215
return ing .lifecycler .GetState ()
214
216
})
215
217
216
- numberOfTenants := 500
218
+ numberOfTenants := 150
217
219
wg := sync.WaitGroup {}
218
220
wg .Add (numberOfTenants )
219
221
@@ -232,6 +234,7 @@ func TestIngesterDeletionRace(t *testing.T) {
232
234
Matchers : []* client.LabelMatcher {{Type : client .REGEX_MATCH , Name : labels .MetricName , Value : ".*" }},
233
235
}, s )
234
236
require .NoError (t , err )
237
+ time .Sleep (time .Duration (rand .Int63n (5 )) * time .Millisecond )
235
238
ing .getTSDB (u ).deletionMarkFound .Store (true ) // lets force close the tenant
236
239
}()
237
240
}
0 commit comments