(t *testing.T)
| 645 | } |
| 646 | |
| 647 | func TestGetRules(t *testing.T) { |
| 648 | // ruler ID -> (user ID -> list of groups). |
| 649 | type expectedRulesMap map[string]map[string]rulespb.RuleGroupList |
| 650 | type rulesMap map[string][]*rulespb.RuleDesc |
| 651 | |
| 652 | type testCase struct { |
| 653 | sharding bool |
| 654 | shardingStrategy string |
| 655 | shuffleShardSize float64 |
| 656 | rulesRequest RulesRequest |
| 657 | expectedCount map[string]int |
| 658 | expectedClientCallCount int |
| 659 | rulerStateMap map[string]ring.InstanceState |
| 660 | rulerAZMap map[string]string |
| 661 | expectedError error |
| 662 | replicationFactor int |
| 663 | enableZoneAwareReplication bool |
| 664 | } |
| 665 | |
| 666 | ruleMap := rulesMap{ |
| 667 | "ruler1-user1-rule-group1": []*rulespb.RuleDesc{ |
| 668 | { |
| 669 | Record: "rtest_user1_1", |
| 670 | Expr: "sum(rate(node_cpu_seconds_total[3h:10m]))", |
| 671 | Labels: []cortexpb.LabelAdapter{ |
| 672 | {Name: "rulename", Value: "rtest_user1_group1_rule_1"}, |
| 673 | }, |
| 674 | }, |
| 675 | { |
| 676 | Alert: "atest_user1_1", |
| 677 | Expr: "sum(rate(node_cpu_seconds_total[3h:10m]))", |
| 678 | Labels: []cortexpb.LabelAdapter{ |
| 679 | {Name: "alertname", Value: "atest_user1_group1_rule_1"}, |
| 680 | }, |
| 681 | }, |
| 682 | }, |
| 683 | "ruler1-user1-rule-group2": []*rulespb.RuleDesc{ |
| 684 | { |
| 685 | Record: "rtest_user1_1", |
| 686 | Expr: "sum(rate(node_cpu_seconds_total[3h:10m]))", |
| 687 | Labels: []cortexpb.LabelAdapter{ |
| 688 | {Name: "rulename", Value: "rtest_user1_group2_rule_1"}, |
| 689 | }, |
| 690 | }, |
| 691 | }, |
| 692 | "ruler1-user2-rule-group1": []*rulespb.RuleDesc{ |
| 693 | { |
| 694 | Record: "rtest_user1_1", |
| 695 | Expr: "sum(rate(node_cpu_seconds_total[3h:10m]))", |
| 696 | Labels: []cortexpb.LabelAdapter{ |
| 697 | {Name: "rulename", Value: "rtest_user2_group1_rule_1"}, |
| 698 | }, |
| 699 | }, |
| 700 | }, |
| 701 | "ruler2-user1-rule-group3": []*rulespb.RuleDesc{ |
| 702 | { |
| 703 | Record: "rtest_user1_1", |
| 704 | Expr: "sum(rate(node_cpu_seconds_total[3h:10m]))", |
nothing calls this directly
no test coverage detected