storetestutil

package
v0.37.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 11, 2024 License: Apache-2.0 Imports: 29 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// LabelLongSuffix is a label with ~50B in size, to emulate real-world high cardinality.
	LabelLongSuffix = "aaaaaaaaaabbbbbbbbbbccccccccccdddddddddd"
)

Variables

This section is empty.

Functions

func CreateBlockFromHead added in v0.32.0

func CreateBlockFromHead(t testing.TB, dir string, head *tsdb.Head) ulid.ULID

func CreateHeadWithSeries

func CreateHeadWithSeries(t testing.TB, j int, opts HeadGenOptions) (*tsdb.Head, []*storepb.Series)

CreateHeadWithSeries returns head filled with given samples and same series returned in separate list for assertion purposes. Returned series list has "ext1"="1" prepended. Each series looks as follows: {foo=bar,i=000001aaaaaaaaaabbbbbbbbbbccccccccccdddddddddd} <random value> where number indicate sample number from 0. Returned series are framed in the same way as remote read would frame them.

func ReadSeriesFromBlock added in v0.31.0

func ReadSeriesFromBlock(t testing.TB, h tsdb.BlockReader, extLabels labels.Labels, skipChunks bool) []*storepb.Series

func RunSeriesInterestingCases

func RunSeriesInterestingCases(t testutil.TB, maxSamples, maxSeries int, f func(t testutil.TB, samplesPerSeries, series int))

func TestServerSeries

func TestServerSeries(t testutil.TB, store storepb.StoreServer, cases ...*SeriesCase)

TestServerSeries runs tests against given cases.

Types

type HeadGenOptions

type HeadGenOptions struct {
	TSDBDir                  string
	SamplesPerSeries, Series int
	ScrapeInterval           time.Duration

	WithWAL       bool
	PrependLabels labels.Labels
	SkipChunks    bool // Skips chunks in returned slice (not in generated head!).
	SampleType    chunkenc.ValueType

	Random *rand.Rand
}

type SeriesCase

type SeriesCase struct {
	Name string
	Req  *storepb.SeriesRequest

	// Exact expectations are checked only for tests. For benchmarks only length is assured.
	ExpectedSeries   []*storepb.Series
	ExpectedWarnings []string
	ExpectedHints    []hintspb.SeriesResponseHints
	HintsCompareFunc func(t testutil.TB, expected, actual hintspb.SeriesResponseHints)
}

SeriesCase represents single test/benchmark case for testing storepb series.

type SeriesServer

type SeriesServer struct {
	// This field just exist to pseudo-implement the unused methods of the interface.
	storepb.Store_SeriesServer

	SeriesSet []*storepb.Series
	Warnings  []string
	HintsSet  []*types.Any

	Size int64
	// contains filtered or unexported fields
}

SeriesServer is test gRPC storeAPI series server.

func NewSeriesServer

func NewSeriesServer(ctx context.Context) *SeriesServer

func (*SeriesServer) Context

func (s *SeriesServer) Context() context.Context

func (*SeriesServer) Send

type StoreSeriesClient added in v0.32.0

type StoreSeriesClient struct {
	// This field just exist to pseudo-implement the unused methods of the interface.
	storepb.Store_SeriesClient
	Ctx context.Context

	RespSet         []*storepb.SeriesResponse
	RespDur         time.Duration
	SlowSeriesIndex int

	InjectedError      error
	InjectedErrorIndex int
	// contains filtered or unexported fields
}

StoreSeriesClient is test gRPC storeAPI series client.

func (*StoreSeriesClient) CloseSend added in v0.37.0

func (c *StoreSeriesClient) CloseSend() error

func (*StoreSeriesClient) Context added in v0.32.0

func (c *StoreSeriesClient) Context() context.Context

func (*StoreSeriesClient) Recv added in v0.32.0

type TestClient added in v0.31.0

type TestClient struct {
	storepb.StoreClient

	Name string

	ExtLset                     []labels.Labels
	MinTime, MaxTime            int64
	Shardable                   bool
	WithoutReplicaLabelsEnabled bool
	IsLocalStore                bool
	StoreTSDBInfos              []infopb.TSDBInfo
	StoreFilterNotMatches       bool
}

func (TestClient) Addr added in v0.31.0

func (c TestClient) Addr() (string, bool)

func (TestClient) LabelSets added in v0.31.0

func (c TestClient) LabelSets() []labels.Labels

func (TestClient) Matches added in v0.37.0

func (c TestClient) Matches(matches []*labels.Matcher) bool

func (TestClient) String added in v0.31.0

func (c TestClient) String() string

func (TestClient) SupportsSharding added in v0.31.0

func (c TestClient) SupportsSharding() bool

func (TestClient) SupportsWithoutReplicaLabels added in v0.31.0

func (c TestClient) SupportsWithoutReplicaLabels() bool

func (TestClient) TSDBInfos added in v0.32.0

func (c TestClient) TSDBInfos() []infopb.TSDBInfo

func (TestClient) TimeRange added in v0.31.0

func (c TestClient) TimeRange() (mint, maxt int64)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL