Skip to content

Commit

Permalink
Rules: add e2e test
Browse files Browse the repository at this point in the history
Signed-off-by: Jimmie Han <hanjinming@outlook.com>
  • Loading branch information
hanjm committed Nov 17, 2021
1 parent a42d4c4 commit bf86d8a
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 1 deletion.
15 changes: 15 additions & 0 deletions test/e2e/rule_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,21 @@ groups:
annotations:
summary: "I always complain and I have been loaded via sighup signal."
`
testAlertRuleWithLimit = `
groups:
- name: example_with_limit
interval: 1s
limit: 1
partial_response_strategy: "WARN"
rules:
- alert: TestAlert_WithLimit
expr: some_metric
labels:
severity: page
annotations:
summary: "with limit"
`

testRuleRecordAbsentMetric = `
groups:
- name: example_record_rules
Expand Down
18 changes: 17 additions & 1 deletion test/e2e/rules_api_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@ func TestRulesAPI_Fanout(t *testing.T) {
thanosRulesSubDir := filepath.Join("thanos-rules")
testutil.Ok(t, os.MkdirAll(filepath.Join(e.SharedDir(), thanosRulesSubDir), os.ModePerm))
createRuleFiles(t, filepath.Join(e.SharedDir(), thanosRulesSubDir))

// We create a rule group with limit.
createRuleFile(t, filepath.Join(e.SharedDir(), thanosRulesSubDir, "rules-with-limit.yaml"), testAlertRuleWithLimit)
// 2x Prometheus.
prom1, sidecar1, err := e2ethanos.NewPrometheusWithSidecar(
e,
Expand Down Expand Up @@ -135,6 +136,21 @@ func TestRulesAPI_Fanout(t *testing.T) {
}),
},
},
{
Name: "example_with_limit",
File: "/shared/thanos-rules/rules-with-limit.yaml",
Limit: 1,
Rules: []*rulespb.Rule{
rulespb.NewAlertingRule(&rulespb.Alert{
Name: "TestAlert_WithLimit",
State: rulespb.AlertState_INACTIVE,
Query: "some_metric",
Labels: labelpb.ZLabelSet{Labels: []labelpb.ZLabel{
{Name: "severity", Value: "page"},
}},
}),
},
},
})
}

Expand Down

0 comments on commit bf86d8a

Please sign in to comment.