From a79983d5bae1adba4dabad4ebb8de5f298846afc Mon Sep 17 00:00:00 2001 From: Jimmie Han Date: Tue, 16 Nov 2021 21:06:35 +0800 Subject: [PATCH] Rules: add e2e test Signed-off-by: Jimmie Han --- test/e2e/rule_test.go | 15 +++++++++++++++ test/e2e/rules_api_test.go | 18 +++++++++++++++++- 2 files changed, 32 insertions(+), 1 deletion(-) diff --git a/test/e2e/rule_test.go b/test/e2e/rule_test.go index dd2d6a927b..d8d4826bac 100644 --- a/test/e2e/rule_test.go +++ b/test/e2e/rule_test.go @@ -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: up + labels: + severity: page + annotations: + summary: "with limit" +` + testRuleRecordAbsentMetric = ` groups: - name: example_record_rules diff --git a/test/e2e/rules_api_test.go b/test/e2e/rules_api_test.go index 75a088e08b..7187bf48f7 100644 --- a/test/e2e/rules_api_test.go +++ b/test/e2e/rules_api_test.go @@ -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, @@ -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_FIRING, + Query: "up", + Labels: labelpb.ZLabelSet{Labels: []labelpb.ZLabel{ + {Name: "severity", Value: "page"}, + }}, + }), + }, + }, }) }