Merge pull request #8036 from dgl/promtool-alert-err
promtool: Don't end alert tests early, in some failure situations
This commit is contained in:
commit
8c8de46003
|
@ -228,6 +228,7 @@ func (tg *testGroup) test(evalInterval time.Duration, groupOrderMap map[string]i
|
||||||
var errs []error
|
var errs []error
|
||||||
for ts := mint; ts.Before(maxt) || ts.Equal(maxt); ts = ts.Add(evalInterval) {
|
for ts := mint; ts.Before(maxt) || ts.Equal(maxt); ts = ts.Add(evalInterval) {
|
||||||
// Collects the alerts asked for unit testing.
|
// Collects the alerts asked for unit testing.
|
||||||
|
var evalErrs []error
|
||||||
suite.WithSamplesTill(ts, func(err error) {
|
suite.WithSamplesTill(ts, func(err error) {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
errs = append(errs, err)
|
errs = append(errs, err)
|
||||||
|
@ -237,13 +238,16 @@ func (tg *testGroup) test(evalInterval time.Duration, groupOrderMap map[string]i
|
||||||
g.Eval(suite.Context(), ts)
|
g.Eval(suite.Context(), ts)
|
||||||
for _, r := range g.Rules() {
|
for _, r := range g.Rules() {
|
||||||
if r.LastError() != nil {
|
if r.LastError() != nil {
|
||||||
errs = append(errs, errors.Errorf(" rule: %s, time: %s, err: %v",
|
evalErrs = append(evalErrs, errors.Errorf(" rule: %s, time: %s, err: %v",
|
||||||
r.Name(), ts.Sub(time.Unix(0, 0).UTC()), r.LastError()))
|
r.Name(), ts.Sub(time.Unix(0, 0).UTC()), r.LastError()))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
if len(errs) > 0 {
|
errs = append(errs, evalErrs...)
|
||||||
|
// Only end testing at this point if errors occurred evaluating above,
|
||||||
|
// rather than any test failures already collected in errs.
|
||||||
|
if len(evalErrs) > 0 {
|
||||||
return errs
|
return errs
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue