@@ -31,27 +31,32 @@ func TestQuerierWithBlocksStorageRunningInMicroservicesMode(t *testing.T) {
31
31
tenantShardSize int
32
32
ingesterStreamingEnabled bool
33
33
indexCacheBackend string
34
+ chunkCacheBackend string
34
35
bucketIndexEnabled bool
35
36
}{
36
37
"blocks sharding disabled, ingester gRPC streaming disabled, memcached index cache" : {
37
38
blocksShardingStrategy : "" ,
38
39
ingesterStreamingEnabled : false ,
39
40
indexCacheBackend : tsdb .IndexCacheBackendMemcached ,
41
+ chunkCacheBackend : tsdb .CacheBackendMemcached ,
40
42
},
41
43
"blocks sharding disabled, ingester gRPC streaming disabled, multilevel index cache (inmemory, memcached)" : {
42
44
blocksShardingStrategy : "" ,
43
45
ingesterStreamingEnabled : false ,
44
46
indexCacheBackend : fmt .Sprintf ("%v,%v" , tsdb .IndexCacheBackendInMemory , tsdb .IndexCacheBackendMemcached ),
47
+ chunkCacheBackend : tsdb .CacheBackendMemcached ,
45
48
},
46
49
"blocks sharding disabled, ingester gRPC streaming disabled, redis index cache" : {
47
50
blocksShardingStrategy : "" ,
48
51
ingesterStreamingEnabled : false ,
49
52
indexCacheBackend : tsdb .IndexCacheBackendRedis ,
53
+ chunkCacheBackend : tsdb .CacheBackendRedis ,
50
54
},
51
55
"blocks sharding disabled, ingester gRPC streaming disabled, multilevel index cache (inmemory, redis)" : {
52
56
blocksShardingStrategy : "" ,
53
57
ingesterStreamingEnabled : false ,
54
58
indexCacheBackend : fmt .Sprintf ("%v,%v" , tsdb .IndexCacheBackendInMemory , tsdb .IndexCacheBackendRedis ),
59
+ chunkCacheBackend : tsdb .CacheBackendRedis ,
55
60
},
56
61
"blocks default sharding, ingester gRPC streaming disabled, inmemory index cache" : {
57
62
blocksShardingStrategy : "default" ,
@@ -67,12 +72,14 @@ func TestQuerierWithBlocksStorageRunningInMicroservicesMode(t *testing.T) {
67
72
blocksShardingStrategy : "default" ,
68
73
ingesterStreamingEnabled : true ,
69
74
indexCacheBackend : tsdb .IndexCacheBackendMemcached ,
75
+ chunkCacheBackend : tsdb .CacheBackendMemcached ,
70
76
},
71
77
"blocks shuffle sharding, ingester gRPC streaming enabled, memcached index cache" : {
72
78
blocksShardingStrategy : "shuffle-sharding" ,
73
79
tenantShardSize : 1 ,
74
80
ingesterStreamingEnabled : true ,
75
81
indexCacheBackend : tsdb .IndexCacheBackendMemcached ,
82
+ chunkCacheBackend : tsdb .CacheBackendMemcached ,
76
83
},
77
84
"blocks default sharding, ingester gRPC streaming enabled, inmemory index cache, bucket index enabled" : {
78
85
blocksShardingStrategy : "default" ,
@@ -91,13 +98,15 @@ func TestQuerierWithBlocksStorageRunningInMicroservicesMode(t *testing.T) {
91
98
blocksShardingStrategy : "default" ,
92
99
ingesterStreamingEnabled : true ,
93
100
indexCacheBackend : tsdb .IndexCacheBackendRedis ,
101
+ chunkCacheBackend : tsdb .CacheBackendRedis ,
94
102
bucketIndexEnabled : true ,
95
103
},
96
104
"blocks shuffle sharding, ingester gRPC streaming enabled, redis index cache, bucket index enabled" : {
97
105
blocksShardingStrategy : "shuffle-sharding" ,
98
106
tenantShardSize : 1 ,
99
107
ingesterStreamingEnabled : true ,
100
108
indexCacheBackend : tsdb .IndexCacheBackendRedis ,
109
+ chunkCacheBackend : tsdb .CacheBackendRedis ,
101
110
bucketIndexEnabled : true ,
102
111
},
103
112
}
@@ -121,6 +130,7 @@ func TestQuerierWithBlocksStorageRunningInMicroservicesMode(t *testing.T) {
121
130
"-blocks-storage.bucket-store.sync-interval" : "1s" ,
122
131
"-blocks-storage.tsdb.retention-period" : ((blockRangePeriod * 2 ) - 1 ).String (),
123
132
"-blocks-storage.bucket-store.index-cache.backend" : testCfg .indexCacheBackend ,
133
+ "-blocks-storage.bucket-store.chunks-cache.backend" : testCfg .chunkCacheBackend ,
124
134
"-store-gateway.sharding-enabled" : strconv .FormatBool (testCfg .blocksShardingStrategy != "" ),
125
135
"-store-gateway.sharding-strategy" : testCfg .blocksShardingStrategy ,
126
136
"-store-gateway.tenant-shard-size" : fmt .Sprintf ("%d" , testCfg .tenantShardSize ),
@@ -144,6 +154,11 @@ func TestQuerierWithBlocksStorageRunningInMicroservicesMode(t *testing.T) {
144
154
if strings .Contains (testCfg .indexCacheBackend , tsdb .IndexCacheBackendRedis ) {
145
155
flags ["-blocks-storage.bucket-store.index-cache.redis.addresses" ] = redis .NetworkEndpoint (e2ecache .RedisPort )
146
156
}
157
+ if testCfg .chunkCacheBackend == tsdb .CacheBackendMemcached {
158
+ flags ["-blocks-storage.bucket-store.chunks-cache.memcached.addresses" ] = "dns+" + memcached .NetworkEndpoint (e2ecache .MemcachedPort )
159
+ } else if testCfg .chunkCacheBackend == tsdb .CacheBackendRedis {
160
+ flags ["-blocks-storage.bucket-store.chunks-cache.redis.addresses" ] = redis .NetworkEndpoint (e2ecache .RedisPort )
161
+ }
147
162
148
163
// Start Cortex components.
149
164
distributor := e2ecortex .NewDistributor ("distributor" , e2ecortex .RingStoreConsul , consul .NetworkHTTPEndpoint (), flags , "" )
@@ -257,17 +272,12 @@ func TestQuerierWithBlocksStorageRunningInMicroservicesMode(t *testing.T) {
257
272
require .NoError (t , storeGateways .WaitSumMetrics (e2e .Equals (float64 ((5 + 5 + 2 )* numberOfCacheBackends )), "thanos_store_index_cache_requests_total" ))
258
273
require .NoError (t , storeGateways .WaitSumMetrics (e2e .Equals (0 ), "thanos_store_index_cache_hits_total" )) // no cache hit cause the cache was empty
259
274
260
- if testCfg .indexCacheBackend == tsdb .IndexCacheBackendMemcached {
261
- require .NoError (t , storeGateways .WaitSumMetrics (e2e .Equals (21 ), "thanos_memcached_operations_total" )) // 14 gets + 7 sets
262
- }
263
-
264
275
// Query back again the 1st series from storage. This time it should use the index cache.
265
276
result , err = c .Query ("series_1" , series1Timestamp )
266
277
require .NoError (t , err )
267
278
require .Equal (t , model .ValVector , result .Type ())
268
279
assert .Equal (t , expectedVector1 , result .(model.Vector ))
269
280
270
- var l0CacheHits float64
271
281
if numberOfCacheBackends > 1 {
272
282
// 6 requests for Expanded Postings, 5 for Postings and 3 for Series.
273
283
require .NoError (t , storeGateways .WaitSumMetricsWithOptions (e2e .Equals (float64 (6 + 5 + 3 )), []string {"thanos_store_index_cache_requests_total" }, e2e .WithLabelMatchers (
@@ -287,17 +297,12 @@ func TestQuerierWithBlocksStorageRunningInMicroservicesMode(t *testing.T) {
287
297
require .NoError (t , err )
288
298
// Make sure l1 cache requests + l0 cache hits is 14.
289
299
require .Equal (t , float64 (14 ), l1IndexCacheRequests [0 ]+ l0IndexCacheHits [0 ])
290
- l0CacheHits = l0IndexCacheHits [0 ]
291
300
} else {
292
301
// 6 requests for Expanded Postings, 5 for Postings and 3 for Series.
293
302
require .NoError (t , storeGateways .WaitSumMetrics (e2e .Equals (float64 (6 + 5 + 3 )), "thanos_store_index_cache_requests_total" ))
294
303
}
295
304
require .NoError (t , storeGateways .WaitSumMetrics (e2e .Equals (2 ), "thanos_store_index_cache_hits_total" )) // this time has used the index cache
296
305
297
- if testCfg .indexCacheBackend == tsdb .IndexCacheBackendMemcached {
298
- require .NoError (t , storeGateways .WaitSumMetrics (e2e .Equals (23 - l0CacheHits ), "thanos_memcached_operations_total" )) // as before + 2 gets - cache hits
299
- }
300
-
301
306
// Query metadata.
302
307
testMetadataQueriesWithBlocksStorage (t , c , series1 [0 ], series2 [0 ], series3 [0 ], blockRangePeriod )
303
308
0 commit comments