Documentation ¶
Index ¶
- Constants
- func HistogramTestExpression(h *histogram.FloatHistogram) string
- func LoadedStorage(t testutil.T, input string) *teststorage.TestStorage
- func NewTestEngine(enablePerStepStats bool, lookbackDelta time.Duration, maxSamples int) *promql.Engine
- func RunBuiltinTests(t *testing.T, engine promql.QueryEngine)
- func RunTest(t testutil.T, input string, engine promql.QueryEngine)
- type LazyLoader
- func (ll *LazyLoader) Close() error
- func (ll *LazyLoader) Context() context.Context
- func (ll *LazyLoader) QueryEngine() *promql.Engine
- func (ll *LazyLoader) Queryable() storage.Queryable
- func (ll *LazyLoader) Storage() storage.Storage
- func (ll *LazyLoader) WithSamplesTill(ts time.Time, fn func(error))
- type LazyLoaderOpts
Constants ¶
const (
DefaultMaxSamplesPerQuery = 10000
)
Variables ¶
This section is empty.
Functions ¶
func HistogramTestExpression ¶
func HistogramTestExpression(h *histogram.FloatHistogram) string
HistogramTestExpression returns TestExpression() for the given histogram or "" if the histogram is nil.
func LoadedStorage ¶
func LoadedStorage(t testutil.T, input string) *teststorage.TestStorage
LoadedStorage returns storage with generated data using the provided load statements. Non-load statements will cause test errors.
func NewTestEngine ¶
func RunBuiltinTests ¶
func RunBuiltinTests(t *testing.T, engine promql.QueryEngine)
RunBuiltinTests runs an acceptance test suite against the provided engine.
Types ¶
type LazyLoader ¶
LazyLoader lazily loads samples into storage. This is specifically implemented for unit testing of rules.
func NewLazyLoader ¶
func NewLazyLoader(input string, opts LazyLoaderOpts) (*LazyLoader, error)
NewLazyLoader returns an initialized empty LazyLoader.
func (*LazyLoader) Close ¶
func (ll *LazyLoader) Close() error
Close closes resources associated with the LazyLoader.
func (*LazyLoader) Context ¶
func (ll *LazyLoader) Context() context.Context
Context returns the LazyLoader's context.
func (*LazyLoader) QueryEngine ¶
func (ll *LazyLoader) QueryEngine() *promql.Engine
QueryEngine returns the LazyLoader's query engine.
func (*LazyLoader) Queryable ¶
func (ll *LazyLoader) Queryable() storage.Queryable
Queryable allows querying the LazyLoader's data. Note: only the samples till the max timestamp used in `WithSamplesTill` can be queried.
func (*LazyLoader) Storage ¶
func (ll *LazyLoader) Storage() storage.Storage
Storage returns the LazyLoader's storage.
func (*LazyLoader) WithSamplesTill ¶
func (ll *LazyLoader) WithSamplesTill(ts time.Time, fn func(error))
WithSamplesTill loads the samples till given timestamp and executes the given function.
type LazyLoaderOpts ¶
type LazyLoaderOpts struct {
// Both of these must be set to true for regular PromQL (as of
// Prometheus v2.33). They can still be disabled here for legacy and
// other uses.
EnableAtModifier, EnableNegativeOffset bool
}
LazyLoaderOpts are options for the lazy loader.