Set test group interval default to evaluation interval (#13011)
Signed-off-by: Rens Groothuijsen <l.groothuijsen@alumni.maastrichtuniversity.nl>
This commit is contained in:
parent
6d083312e7
commit
122f9506e9
|
@ -0,0 +1,15 @@
|
|||
tests:
|
||||
- input_series:
|
||||
- series: test
|
||||
values: 0 1
|
||||
promql_expr_test:
|
||||
- expr: test
|
||||
eval_time: 59s
|
||||
exp_samples:
|
||||
- value: 0
|
||||
labels: test
|
||||
- expr: test
|
||||
eval_time: 1m
|
||||
exp_samples:
|
||||
- value: 1
|
||||
labels: test
|
|
@ -96,6 +96,9 @@ func ruleUnitTest(filename string, queryOpts promql.LazyLoaderOpts) []error {
|
|||
// Testing.
|
||||
var errs []error
|
||||
for _, t := range unitTestInp.Tests {
|
||||
if t.Interval == 0 {
|
||||
t.Interval = unitTestInp.EvaluationInterval
|
||||
}
|
||||
ers := t.test(evalInterval, groupOrderMap, queryOpts, unitTestInp.RuleFiles...)
|
||||
if ers != nil {
|
||||
errs = append(errs, ers...)
|
||||
|
|
|
@ -112,6 +112,16 @@ func TestRulesUnitTest(t *testing.T) {
|
|||
},
|
||||
want: 0,
|
||||
},
|
||||
{
|
||||
name: "No test group interval",
|
||||
args: args{
|
||||
files: []string{"./testdata/no-test-group-interval.yml"},
|
||||
},
|
||||
queryOpts: promql.LazyLoaderOpts{
|
||||
EnableNegativeOffset: true,
|
||||
},
|
||||
want: 0,
|
||||
},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
|
|
|
@ -39,7 +39,7 @@ tests:
|
|||
|
||||
``` yaml
|
||||
# Series data
|
||||
interval: <duration>
|
||||
[ interval: <duration> | default = evaluation_interval ]
|
||||
input_series:
|
||||
[ - <series> ]
|
||||
|
||||
|
|
Loading…
Reference in New Issue