MCPcopy Create free account
hub / github.com/cortexproject/cortex / TestMergeGroupStateDesc

Function TestMergeGroupStateDesc

pkg/ruler/merger_test.go:15–212  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

13)
14
15func TestMergeGroupStateDesc(t *testing.T) {
16 curTime := time.Now()
17 r := rulespb.RuleDesc{
18 Expr: "1 > 1",
19 }
20 g1 := rulespb.RuleGroupDesc{
21 Name: "g1",
22 Namespace: "ns1",
23 }
24 g2 := rulespb.RuleGroupDesc{
25 Name: "g2",
26 Namespace: "ns1",
27 }
28 rs1 := RuleStateDesc{
29 Rule: &r,
30 EvaluationTimestamp: curTime,
31 }
32 rs1NotRun := RuleStateDesc{
33 Rule: &r,
34 }
35 rs2 := RuleStateDesc{
36 Rule: &r,
37 EvaluationTimestamp: curTime,
38 }
39 rs2NotRun := RuleStateDesc{
40 Rule: &r,
41 }
42 rs3 := RuleStateDesc{
43 Rule: &r,
44 EvaluationTimestamp: curTime.Add(10 * time.Second),
45 }
46
47 gs1 := GroupStateDesc{
48 Group: &g1,
49 ActiveRules: []*RuleStateDesc{&rs1, &rs2},
50 EvaluationTimestamp: curTime,
51 }
52 gs1NotRun := GroupStateDesc{
53 Group: &g1,
54 ActiveRules: []*RuleStateDesc{&rs1NotRun, &rs2NotRun},
55 }
56 gs2 := GroupStateDesc{
57 Group: &g2,
58 ActiveRules: []*RuleStateDesc{&rs1, &rs2},
59 EvaluationTimestamp: curTime,
60 }
61 gs2NotRun := GroupStateDesc{
62 Group: &g2,
63 ActiveRules: []*RuleStateDesc{&rs1NotRun, &rs2NotRun},
64 }
65 gs3 := GroupStateDesc{
66 Group: &g2,
67 ActiveRules: []*RuleStateDesc{&rs1, &rs3},
68 EvaluationTimestamp: curTime,
69 }
70
71 type testCase struct {
72 input []*RulesResponse

Callers

nothing calls this directly

Calls 7

GetRuleGroupNextTokenFunction · 0.85
mergeGroupStateDescFunction · 0.85
RunMethod · 0.65
CompareMethod · 0.65
EqualMethod · 0.65
AddMethod · 0.45
LogMethod · 0.45

Tested by

no test coverage detected