Skip to content

Commit

Permalink
fixup! add test for sharded rule filtering
Browse files Browse the repository at this point in the history
  • Loading branch information
ashwanthgoli committed Jan 30, 2024
1 parent e7f1c51 commit 8add210
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions pkg/ruler/base/ruler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -401,7 +401,7 @@ func TestGetRules(t *testing.T) {
shuffleShardSize int
}

expectedRules := expectedRulesMap{
allRules := expectedRulesMap{
"ruler1": map[string]rulespb.RuleGroupList{
"user1": {
&rulespb.RuleGroupDesc{User: "user1", Namespace: "namespace", Name: "first", Rules: []*rulespb.RuleDesc{createRecordingRule("COUNT_RULE", `count_over_time({foo="bar"}[5m])`)}, Interval: 10 * time.Second, Limit: 10},
Expand Down Expand Up @@ -495,7 +495,7 @@ func TestGetRules(t *testing.T) {

for name, tc := range testCases {
for _, ruleType := range []RulesRequest_RuleType{AnyRule, AlertingRule, RecordingRule} {
t.Run(name+ruleType.String(), func(t *testing.T) {
t.Run(name+" "+ruleType.String(), func(t *testing.T) {
kvStore, cleanUp := consul.NewInMemoryClient(ring.GetCodec(), log.NewNopLogger(), nil)
t.Cleanup(func() { assert.NoError(t, cleanUp.Close()) })
allRulesByUser := map[string]rulespb.RuleGroupList{}
Expand Down Expand Up @@ -530,7 +530,7 @@ func TestGetRules(t *testing.T) {
return r
}

for rID, r := range expectedRules {
for rID, r := range allRules {
createRuler(rID)
for user, rules := range r {
allRulesByUser[user] = append(allRulesByUser[user], rules...)
Expand All @@ -546,7 +546,7 @@ func TestGetRules(t *testing.T) {
case RecordingRule:
filteredRules = expectedRecordingRules
default:
filteredRules = expectedRules
filteredRules = allRules
}

for _, r := range filteredRules {
Expand Down

0 comments on commit 8add210

Please sign in to comment.