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

Function fillCache

pkg/chunk/cache/cache_test.go:18–41  ·  view source on GitHub ↗
(t *testing.T, cache cache.Cache)

Source from the content-addressed store, hash-verified

16)
17
18func fillCache(t *testing.T, cache cache.Cache) ([]string, []chunkenc.Chunk) {
19 const chunkLen = 13 * 3600 // in seconds
20
21 // put a set of chunks, larger than background batch size, with varying timestamps and values
22 keys := []string{}
23 bufs := [][]byte{}
24 chunks := []chunkenc.Chunk{}
25 for i := range 111 {
26 ts := model.TimeFromUnix(int64(i * chunkLen))
27 promChunk := chunkenc.NewXORChunk()
28 appender, err := promChunk.Appender()
29 require.NoError(t, err)
30 appender.Append(int64(ts), float64(i))
31
32 cleanChunk, err := chunkenc.FromData(promChunk.Encoding(), promChunk.Bytes())
33 require.NoError(t, err)
34 keys = append(keys, strconv.Itoa(i))
35 bufs = append(bufs, promChunk.Bytes())
36 chunks = append(chunks, cleanChunk)
37 }
38
39 cache.Store(context.Background(), keys, bufs)
40 return keys, chunks
41}
42
43func testCacheSingle(t *testing.T, cache cache.Cache, keys []string, chunks []chunkenc.Chunk) {
44 for range 100 {

Callers 2

TestBackgroundFunction · 0.85
testCacheFunction · 0.85

Calls 4

AppendMethod · 0.80
BytesMethod · 0.65
StoreMethod · 0.65
AppenderMethod · 0.45

Tested by

no test coverage detected