Skip to content

Commit

Permalink
Merge pull request prometheus#8504 from rbauduin/require_alertname
Browse files Browse the repository at this point in the history
promtool: alert_rule_test items require alertname
  • Loading branch information
roidelapluie authored Feb 17, 2021
2 parents 2d172d0 + a7d64ca commit 1fac1c7
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions cmd/promtool/unittest.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 1fac1c7

Please sign in to comment.