MCPcopy Create free account
hub / github.com/cortexproject/cortex / TestExpendedPostingsCache

Function TestExpendedPostingsCache

pkg/ingester/ingester_test.go:6520–6819  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

6518}
6519
6520func TestExpendedPostingsCache(t *testing.T) {
6521 cfg := defaultIngesterTestConfig(t)
6522 cfg.BlocksStorageConfig.TSDB.ExpandedCachingExpireInterval = time.Second
6523 cfg.BlocksStorageConfig.TSDB.BlockRanges = []time.Duration{2 * time.Hour}
6524
6525 runQuery := func(t *testing.T, ctx context.Context, i *Ingester, matchers []*client.LabelMatcher) []client.TimeSeriesChunk {
6526 s := &mockQueryStreamServer{ctx: ctx}
6527
6528 err := i.QueryStream(&client.QueryRequest{
6529 StartTimestampMs: 0,
6530 EndTimestampMs: math.MaxInt64,
6531 Matchers: matchers,
6532 }, s)
6533 require.NoError(t, err)
6534 return s.series
6535 }
6536
6537 tc := map[string]struct {
6538 cacheConfig cortex_tsdb.TSDBPostingsCacheConfig
6539 expectedBlockPostingCall int
6540 expectedHeadPostingCall int
6541 shouldExpireDueInactivity bool
6542 }{
6543 "cacheDisabled": {
6544 expectedBlockPostingCall: 0,
6545 expectedHeadPostingCall: 0,
6546 cacheConfig: cortex_tsdb.TSDBPostingsCacheConfig{
6547 Head: cortex_tsdb.PostingsCacheConfig{
6548 Enabled: false,
6549 },
6550 Blocks: cortex_tsdb.PostingsCacheConfig{
6551 Enabled: false,
6552 },
6553 },
6554 },
6555 "enabled cache on compacted blocks": {
6556 expectedBlockPostingCall: 1,
6557 expectedHeadPostingCall: 0,
6558 cacheConfig: cortex_tsdb.TSDBPostingsCacheConfig{
6559 Blocks: cortex_tsdb.PostingsCacheConfig{
6560 Ttl: time.Hour,
6561 MaxBytes: 1024 * 1024 * 1024,
6562 Enabled: true,
6563 },
6564 },
6565 },
6566 "enabled cache on head": {
6567 expectedBlockPostingCall: 0,
6568 expectedHeadPostingCall: 1,
6569 cacheConfig: cortex_tsdb.TSDBPostingsCacheConfig{
6570 Head: cortex_tsdb.PostingsCacheConfig{
6571 Ttl: time.Hour,
6572 MaxBytes: 1024 * 1024 * 1024,
6573 Enabled: true,
6574 },
6575 },
6576 },
6577 "enabled cache on compacted blocks and head": {

Callers

nothing calls this directly

Calls 15

StartAndAwaitRunningFunction · 0.92
StopAndAwaitTerminatedFunction · 0.92
PollFunction · 0.92
ToWriteRequestFunction · 0.92
compactBlocksMethod · 0.80
LoadMethod · 0.80
getTSDBUsersMethod · 0.80
getTSDBMethod · 0.80
QueryStreamMethod · 0.65
RunMethod · 0.65

Tested by

no test coverage detected