@@ -33,7 +33,7 @@ func TestIOWriterGroupedRulesYAMLRepoStore(t *testing.T) {
33
33
"Having a single SLI recording rule should render correctly." : {
34
34
slos : []prometheus.StorageSLO {
35
35
{
36
- SLO : prometheus.SLO {ID : "test1" },
36
+ SLO : prometheus.SLO {ID : "test1" , RuleGroupInterval : "2m" },
37
37
Rules : prometheus.SLORules {
38
38
SLIErrorRecRules : []rulefmt.Rule {
39
39
{
@@ -52,6 +52,7 @@ func TestIOWriterGroupedRulesYAMLRepoStore(t *testing.T) {
52
52
53
53
groups:
54
54
- name: sloth-slo-sli-recordings-test1
55
+ interval: 2m
55
56
rules:
56
57
- record: test:record
57
58
expr: test-expr
@@ -91,7 +92,7 @@ groups:
91
92
"Having a single SLO alert rule should render correctly." : {
92
93
slos : []prometheus.StorageSLO {
93
94
{
94
- SLO : prometheus.SLO {ID : "test1" },
95
+ SLO : prometheus.SLO {ID : "test1" , RuleGroupInterval : "2m" },
95
96
Rules : prometheus.SLORules {
96
97
AlertRules : []rulefmt.Rule {
97
98
{
@@ -111,6 +112,7 @@ groups:
111
112
112
113
groups:
113
114
- name: sloth-slo-alerts-test1
115
+ interval: 2m
114
116
rules:
115
117
- alert: testAlert
116
118
expr: test-expr
@@ -120,11 +122,40 @@ groups:
120
122
test-annot: one
121
123
` ,
122
124
},
125
+ "Having a single a blank or empty rule_group interval render correctly." : {
126
+ slos : []prometheus.StorageSLO {
127
+ {
128
+ SLO : prometheus.SLO {ID : "test1" , RuleGroupInterval : "" },
129
+ Rules : prometheus.SLORules {
130
+ SLIErrorRecRules : []rulefmt.Rule {
131
+ {
132
+ Record : "test:record" ,
133
+ Expr : "test-expr" ,
134
+ Labels : map [string ]string {"test-label" : "one" },
135
+ },
136
+ },
137
+ },
138
+ },
139
+ },
140
+ expYAML : `
141
+ ---
142
+ # Code generated by Sloth (dev): https://github.com/slok/sloth.
143
+ # DO NOT EDIT.
144
+
145
+ groups:
146
+ - name: sloth-slo-sli-recordings-test1
147
+ rules:
148
+ - record: test:record
149
+ expr: test-expr
150
+ labels:
151
+ test-label: one
152
+ ` ,
153
+ },
123
154
124
155
"Having a multiple SLO alert and recording rules should render correctly." : {
125
156
slos : []prometheus.StorageSLO {
126
157
{
127
- SLO : prometheus.SLO {ID : "testa" },
158
+ SLO : prometheus.SLO {ID : "testa" , RuleGroupInterval : "3m" },
128
159
Rules : prometheus.SLORules {
129
160
SLIErrorRecRules : []rulefmt.Rule {
130
161
{
@@ -167,7 +198,7 @@ groups:
167
198
},
168
199
},
169
200
{
170
- SLO : prometheus.SLO {ID : "testb" },
201
+ SLO : prometheus.SLO {ID : "testb" , RuleGroupInterval : "1h" },
171
202
Rules : prometheus.SLORules {
172
203
SLIErrorRecRules : []rulefmt.Rule {
173
204
{
@@ -201,6 +232,7 @@ groups:
201
232
202
233
groups:
203
234
- name: sloth-slo-sli-recordings-testa
235
+ interval: 3m
204
236
rules:
205
237
- record: test:record-a1
206
238
expr: test-expr-a1
@@ -211,6 +243,7 @@ groups:
211
243
labels:
212
244
test-label: a-2
213
245
- name: sloth-slo-meta-recordings-testa
246
+ interval: 3m
214
247
rules:
215
248
- record: test:record-a3
216
249
expr: test-expr-a3
@@ -221,6 +254,7 @@ groups:
221
254
labels:
222
255
test-label: a-4
223
256
- name: sloth-slo-alerts-testa
257
+ interval: 3m
224
258
rules:
225
259
- alert: testAlertA1
226
260
expr: test-expr-a1
@@ -235,18 +269,21 @@ groups:
235
269
annotations:
236
270
test-annot: a-2
237
271
- name: sloth-slo-sli-recordings-testb
272
+ interval: 1h
238
273
rules:
239
274
- record: test:record-b1
240
275
expr: test-expr-b1
241
276
labels:
242
277
test-label: b-1
243
278
- name: sloth-slo-meta-recordings-testb
279
+ interval: 1h
244
280
rules:
245
281
- record: test:record-b2
246
282
expr: test-expr-b2
247
283
labels:
248
284
test-label: b-2
249
285
- name: sloth-slo-alerts-testb
286
+ interval: 1h
250
287
rules:
251
288
- alert: testAlertB1
252
289
expr: test-expr-b1
0 commit comments