-
Notifications
You must be signed in to change notification settings - Fork 784
/
caching_fixtures.go
45 lines (37 loc) · 1.35 KB
/
caching_fixtures.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
package storage
import (
"time"
"github.com/cortexproject/cortex/pkg/util/flagext"
"github.com/cortexproject/cortex/pkg/util/validation"
"github.com/cortexproject/cortex/pkg/chunk/cache"
"github.com/cortexproject/cortex/pkg/chunk/gcp"
"github.com/cortexproject/cortex/pkg/chunk"
"github.com/cortexproject/cortex/pkg/chunk/testutils"
)
type fixture struct {
fixture testutils.Fixture
}
func (f fixture) Name() string { return "caching-store" }
func (f fixture) Clients() (chunk.IndexClient, chunk.Client, chunk.TableClient, chunk.SchemaConfig, error) {
limits, err := defaultLimits()
if err != nil {
return nil, nil, nil, chunk.SchemaConfig{}, err
}
indexClient, chunkClient, tableClient, schemaConfig, err := f.fixture.Clients()
indexClient = newCachingIndexClient(indexClient, cache.NewFifoCache("index-fifo", cache.FifoCacheConfig{
MaxSizeItems: 500,
Validity: 5 * time.Minute,
}), 5*time.Minute, limits)
return indexClient, chunkClient, tableClient, schemaConfig, err
}
func (f fixture) Teardown() error { return f.fixture.Teardown() }
// Fixtures for unit testing the caching storage.
var Fixtures = []testutils.Fixture{
fixture{gcp.Fixtures[0]},
}
func defaultLimits() (*validation.Overrides, error) {
var defaults validation.Limits
flagext.DefaultValues(&defaults)
defaults.CardinalityLimit = 5
return validation.NewOverrides(defaults, nil)
}