Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

promtool: alert_rule_test items require alertname #8504

Merged
merged 1 commit into from
Feb 17, 2021
Merged

promtool: alert_rule_test items require alertname #8504

merged 1 commit into from
Feb 17, 2021

Conversation

rbauduin
Copy link

Accepting alert_rule_test without alertname is confusing as it will
always pass with empty exp_alerts, and never with non-empty exp_alerts.

@dgl
Copy link
Member

dgl commented Feb 17, 2021

LGTM -- this addresses the confusion seen in #8462 (that PR can be closed now).

@@ -188,6 +188,9 @@ 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 == "" {
return []error{errors.Errorf("An item under alert_rule_test misses required attribute alertname at eval_time %v", alert.EvalTime)}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we log the test group name, if it is set?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, formatting nit: error messages should not be capitalized, i.e. please start with a lower case letter.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@beorn7 I think that nit is applying the go rule a bit too broadly; given we know where the error is used here it's ok to use capitalisation, as the main reason for the rule is an error might be wrapped, but here we're inside a main package and know it will be printed out, so it looks ugly to not capitalise the error message.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not so much following the Go convention here but what is done elsewhere in this file.

I'm open to capitalize the messages, but then you have to rework the other error messages, too.
(Generally, I'd suggest to do that in a separate PR.)

Accepting alert_rule_test without alertname is confusing as it will
always pass with empty exp_alerts, and never with non-empty exp_alerts.

Signed-off-by: Raphael Bauduin <raphael.bauduin@tessares.net>
@roidelapluie roidelapluie merged commit 1fac1c7 into prometheus:master Feb 17, 2021
@roidelapluie
Copy link
Member

thanks!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants