Browse Source

Merge pull request #8504 from rbauduin/require_alertname

promtool: alert_rule_test items require alertname
pull/8512/head
Julien Pivotto 4 years ago committed by GitHub
parent
commit
1fac1c783b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 7
      cmd/promtool/unittest.go

7
cmd/promtool/unittest.go

@ -188,6 +188,13 @@ func (tg *testGroup) test(evalInterval time.Duration, groupOrderMap map[string]i
// Map of all the unit tests for given eval_time.
alertTests := make(map[model.Duration][]alertTestCase)
for _, alert := range tg.AlertRuleTests {
if alert.Alertname == "" {
var testGroupLog string
if tg.TestGroupName != "" {
testGroupLog = fmt.Sprintf(" (in TestGroup %s)", tg.TestGroupName)
}
return []error{errors.Errorf("an item under alert_rule_test misses required attribute alertname at eval_time %v%s", alert.EvalTime, testGroupLog)}
}
alertEvalTimesMap[alert.EvalTime] = struct{}{}
if _, ok := alertsInTest[alert.EvalTime]; !ok {

Loading…
Cancel
Save