Fix subqueries with default resolution in promql unit tests

Signed-off-by: Julien Pivotto <roidelapluie@inuits.eu>
pull/8569/head
Julien Pivotto 5 years ago
parent 77e648534e
commit 5742a18590
  1. 4
      cmd/promtool/testdata/rules.yml
  2. 1
      cmd/promtool/unittest.go
  3. 3
      docs/configuration/unit_testing_rules.md
  4. 14
      promql/test.go

@ -22,3 +22,7 @@ groups:
# A recording rule that doesn't depend on input series.
- record: fixed_data
expr: 1
# Subquery with default resolution test.
- record: suquery_interval_test
expr: count_over_time(up[5m:])

@ -157,6 +157,7 @@ func (tg *testGroup) test(evalInterval time.Duration, groupOrderMap map[string]i
return []error{err}
}
defer suite.Close()
suite.SubqueryInterval = evalInterval
// Load the rule files.
opts := &rules.ManagerOptions{

@ -22,8 +22,7 @@ You can use `promtool` to test your rules.
rule_files:
[ - <file_name> ]
# optional, default = 1m
evaluation_interval: <duration>
[ evaluation_interval: <duration> | default = 1m ]
# The order in which group names are listed below will be the order of evaluation of
# rule groups (at a given evaluation time). The order is guaranteed only for the groups mentioned below.

@ -657,7 +657,8 @@ type LazyLoader struct {
loadCmd *loadCmd
storage storage.Storage
storage storage.Storage
SubqueryInterval time.Duration
queryEngine *Engine
context context.Context
@ -710,11 +711,12 @@ func (ll *LazyLoader) clear() {
ll.storage = teststorage.New(ll)
opts := EngineOpts{
Logger: nil,
Reg: nil,
MaxSamples: 10000,
Timeout: 100 * time.Second,
EnableAtModifier: true,
Logger: nil,
Reg: nil,
MaxSamples: 10000,
Timeout: 100 * time.Second,
NoStepSubqueryIntervalFn: func(int64) int64 { return durationMilliseconds(ll.SubqueryInterval) },
EnableAtModifier: true,
}
ll.queryEngine = NewEngine(opts)

Loading…
Cancel
Save