@@ -270,18 +270,27 @@ func TestQuerierWithBlocksStorageRunningInMicroservicesMode(t *testing.T) {
270
270
require .Equal (t , model .ValVector , result .Type ())
271
271
assert .Equal (t , expectedVector1 , result .(model.Vector ))
272
272
273
+ var l0CacheHits float64
273
274
if numberOfCacheBackends > 1 {
274
275
// 6 requests for Expanded Postings, 5 for Postings and 3 for Series.
275
276
require .NoError (t , storeGateways .WaitSumMetricsWithOptions (e2e .Equals (float64 (6 + 5 + 3 )), []string {"thanos_store_index_cache_requests_total" }, e2e .WithLabelMatchers (
276
277
labels .MustNewMatcher (labels .MatchEqual , "level" , "L0" ),
277
278
)))
278
279
// In case of L0 cache hits, store gateway might send fewer requests. Should be within range 12 ~ 14.
279
- require .NoError (t , storeGateways .WaitSumMetricsWithOptions (e2e .GreaterOrEqual (float64 (12 )), []string {"thanos_store_index_cache_requests_total" }, e2e .WithLabelMatchers (
280
+ require .NoError (t , storeGateways .WaitSumMetricsWithOptions (e2e .EqualsAmong (float64 (12 ), float64 ( 14 )), []string {"thanos_store_index_cache_requests_total" }, e2e .WithLabelMatchers (
280
281
labels .MustNewMatcher (labels .MatchEqual , "level" , "L1" ),
281
282
)))
282
- require . NoError ( t , storeGateways .WaitSumMetricsWithOptions ( e2e . LessOrEqual ( float64 ( 14 )), []string {"thanos_store_index_cache_requests_total" }, e2e .WithLabelMatchers (
283
+ l1IndexCacheRequests , err := storeGateways .SumMetrics ( []string {"thanos_store_index_cache_requests_total" }, e2e .WithLabelMatchers (
283
284
labels .MustNewMatcher (labels .MatchEqual , "level" , "L1" ),
284
- )))
285
+ ))
286
+ require .NoError (t , err )
287
+ l0IndexCacheHits , err := storeGateways .SumMetrics ([]string {"thanos_store_index_cache_hits_total" }, e2e .WithLabelMatchers (
288
+ labels .MustNewMatcher (labels .MatchEqual , "level" , "L0" ),
289
+ ))
290
+ require .NoError (t , err )
291
+ // Make sure l1 cache requests + l0 cache hits is 14.
292
+ require .Equal (t , float64 (14 ), l1IndexCacheRequests [0 ]+ l0IndexCacheHits [0 ])
293
+ l0CacheHits = l0IndexCacheHits [0 ]
285
294
} else {
286
295
// 6 requests for Expanded Postings, 5 for Postings and 3 for Series.
287
296
require .NoError (t , storeGateways .WaitSumMetrics (e2e .Equals (float64 (6 + 5 + 3 )), "thanos_store_index_cache_requests_total" ))
@@ -293,7 +302,7 @@ func TestQuerierWithBlocksStorageRunningInMicroservicesMode(t *testing.T) {
293
302
require .NoError (t , storeGateways .WaitSumMetrics (e2e .Equals (9 ), "thanos_store_index_cache_items_added_total" )) // as before
294
303
}
295
304
if strings .Contains (testCfg .indexCacheBackend , tsdb .IndexCacheBackendMemcached ) {
296
- require .NoError (t , storeGateways .WaitSumMetrics (e2e .Equals (23 ), "thanos_memcached_operations_total" )) // as before + 2 gets
305
+ require .NoError (t , storeGateways .WaitSumMetrics (e2e .Equals (23 - l0CacheHits ), "thanos_memcached_operations_total" )) // as before + 2 gets - cache hits
297
306
}
298
307
299
308
// Query metadata.
0 commit comments