Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion pkg/querier/tripperware/queryrange/results_cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,7 @@ type resultsCache struct {
cache cache.Cache
limits tripperware.Limits
splitter CacheSplitter
now func() time.Time

extractor Extractor
minCacheExtent int64 // discard any cache extent smaller than this
Expand Down Expand Up @@ -215,6 +216,7 @@ func NewResultsCacheMiddleware(
extractor: extractor,
minCacheExtent: (5 * time.Minute).Milliseconds(),
splitter: splitter,
now: time.Now,
shouldCache: shouldCache,
cacheQueryableSamplesStats: cfg.CacheQueryableSamplesStats,
}
Expand Down Expand Up @@ -790,7 +792,7 @@ func (s resultsCache) extentsOverlapOutOfOrderWindow(extents []tripperware.Exten
return false
}

nowMs := time.Now().UnixMilli()
nowMs := s.now().UnixMilli()
outOfOrderCutoffMs := nowMs - int64(outOfOrderWindow/time.Millisecond)

for _, extent := range extents {
Expand Down
2 changes: 2 additions & 0 deletions pkg/querier/tripperware/queryrange/results_cache_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1855,6 +1855,7 @@ func TestExtentsOverlapOutOfOrderWindow(t *testing.T) {
)
require.NoError(t, err)
rc := rm.Wrap(nil).(*resultsCache)
rc.now = func() time.Time { return now }

overlap := rc.extentsOverlapOutOfOrderWindow(tc.extents, []string{"tenant-a"})
assert.Equal(t, tc.expectedOverlap, overlap)
Expand Down Expand Up @@ -1943,6 +1944,7 @@ func TestResultsCachePutTTLSelection(t *testing.T) {
)
require.NoError(t, err)
rc := rm.Wrap(nil).(*resultsCache)
rc.now = func() time.Time { return now }

ctx := user.InjectOrgID(context.Background(), "tenant-a")
tenantIDs, _ := users.TenantIDs(ctx)
Expand Down
Loading