@@ -43,7 +43,6 @@ func TestPusherAppendable(t *testing.T) {
43
43
44
44
lbls1 := cortexpb .FromLabelsToLabelAdapters (labels .FromMap (map [string ]string {labels .MetricName : "foo_bar" }))
45
45
lbls2 := cortexpb .FromLabelsToLabelAdapters (labels .FromMap (map [string ]string {labels .MetricName : "ALERTS" , labels .AlertName : "boop" }))
46
- lbls3 := cortexpb .FromLabelsToLabelAdapters (labels .FromMap (map [string ]string {labels .MetricName : "ALERTS_FOR_STATE" , labels .AlertName : "boop" }))
47
46
48
47
testHistogram := tsdbutil .GenerateTestHistogram (1 )
49
48
testFloatHistogram := tsdbutil .GenerateTestFloatHistogram (2 )
@@ -55,14 +54,13 @@ func TestPusherAppendable(t *testing.T) {
55
54
for _ , tc := range []struct {
56
55
name string
57
56
series string
58
- evalDelay time.Duration
59
57
value float64
60
58
histogram * histogram.Histogram
61
59
floatHistogram * histogram.FloatHistogram
62
60
expectedReq * cortexpb.WriteRequest
63
61
}{
64
62
{
65
- name : "tenant without delay , normal value" ,
63
+ name : "tenant, normal value" ,
66
64
series : "foo_bar" ,
67
65
value : 1.234 ,
68
66
expectedReq : & cortexpb.WriteRequest {
@@ -80,7 +78,7 @@ func TestPusherAppendable(t *testing.T) {
80
78
},
81
79
},
82
80
{
83
- name : "tenant without delay , stale nan value" ,
81
+ name : "tenant, stale nan value" ,
84
82
series : "foo_bar" ,
85
83
value : math .Float64frombits (value .StaleNaN ),
86
84
expectedReq : & cortexpb.WriteRequest {
@@ -98,45 +96,7 @@ func TestPusherAppendable(t *testing.T) {
98
96
},
99
97
},
100
98
{
101
- name : "tenant with delay, normal value" ,
102
- series : "foo_bar" ,
103
- value : 1.234 ,
104
- evalDelay : time .Minute ,
105
- expectedReq : & cortexpb.WriteRequest {
106
- Timeseries : []cortexpb.PreallocTimeseries {
107
- {
108
- TimeSeries : & cortexpb.TimeSeries {
109
- Labels : lbls1 ,
110
- Samples : []cortexpb.Sample {
111
- {Value : 1.234 , TimestampMs : 120_000 },
112
- },
113
- },
114
- },
115
- },
116
- Source : cortexpb .RULE ,
117
- },
118
- },
119
- {
120
- name : "tenant with delay, stale nan value" ,
121
- series : "foo_bar" ,
122
- value : math .Float64frombits (value .StaleNaN ),
123
- evalDelay : time .Minute ,
124
- expectedReq : & cortexpb.WriteRequest {
125
- Timeseries : []cortexpb.PreallocTimeseries {
126
- {
127
- TimeSeries : & cortexpb.TimeSeries {
128
- Labels : lbls1 ,
129
- Samples : []cortexpb.Sample {
130
- {Value : math .Float64frombits (value .StaleNaN ), TimestampMs : 60_000 },
131
- },
132
- },
133
- },
134
- },
135
- Source : cortexpb .RULE ,
136
- },
137
- },
138
- {
139
- name : "ALERTS without delay, normal value" ,
99
+ name : "ALERTS, normal value" ,
140
100
series : `ALERTS{alertname="boop"}` ,
141
101
value : 1.234 ,
142
102
expectedReq : & cortexpb.WriteRequest {
@@ -154,7 +114,7 @@ func TestPusherAppendable(t *testing.T) {
154
114
},
155
115
},
156
116
{
157
- name : "ALERTS without delay , stale nan value" ,
117
+ name : "ALERTS, stale nan value" ,
158
118
series : `ALERTS{alertname="boop"}` ,
159
119
value : math .Float64frombits (value .StaleNaN ),
160
120
expectedReq : & cortexpb.WriteRequest {
@@ -172,45 +132,7 @@ func TestPusherAppendable(t *testing.T) {
172
132
},
173
133
},
174
134
{
175
- name : "ALERTS with delay, normal value" ,
176
- series : `ALERTS{alertname="boop"}` ,
177
- value : 1.234 ,
178
- evalDelay : time .Minute ,
179
- expectedReq : & cortexpb.WriteRequest {
180
- Timeseries : []cortexpb.PreallocTimeseries {
181
- {
182
- TimeSeries : & cortexpb.TimeSeries {
183
- Labels : lbls2 ,
184
- Samples : []cortexpb.Sample {
185
- {Value : 1.234 , TimestampMs : 60_000 },
186
- },
187
- },
188
- },
189
- },
190
- Source : cortexpb .RULE ,
191
- },
192
- },
193
- {
194
- name : "ALERTS with delay, stale nan value" ,
195
- series : `ALERTS_FOR_STATE{alertname="boop"}` ,
196
- value : math .Float64frombits (value .StaleNaN ),
197
- evalDelay : time .Minute ,
198
- expectedReq : & cortexpb.WriteRequest {
199
- Timeseries : []cortexpb.PreallocTimeseries {
200
- {
201
- TimeSeries : & cortexpb.TimeSeries {
202
- Labels : lbls3 ,
203
- Samples : []cortexpb.Sample {
204
- {Value : math .Float64frombits (value .StaleNaN ), TimestampMs : 60_000 },
205
- },
206
- },
207
- },
208
- },
209
- Source : cortexpb .RULE ,
210
- },
211
- },
212
- {
213
- name : "tenant without delay, normal histogram" ,
135
+ name : "tenant, normal histogram" ,
214
136
series : "foo_bar" ,
215
137
histogram : testHistogram ,
216
138
expectedReq : & cortexpb.WriteRequest {
@@ -228,7 +150,7 @@ func TestPusherAppendable(t *testing.T) {
228
150
},
229
151
},
230
152
{
231
- name : "tenant without delay , float histogram" ,
153
+ name : "tenant, float histogram" ,
232
154
series : "foo_bar" ,
233
155
floatHistogram : testFloatHistogram ,
234
156
expectedReq : & cortexpb.WriteRequest {
@@ -246,7 +168,7 @@ func TestPusherAppendable(t *testing.T) {
246
168
},
247
169
},
248
170
{
249
- name : "tenant without delay , both sample and histogram" ,
171
+ name : "tenant, both sample and histogram" ,
250
172
series : "foo_bar" ,
251
173
value : 1.234 ,
252
174
histogram : testHistogram ,
@@ -273,7 +195,7 @@ func TestPusherAppendable(t *testing.T) {
273
195
},
274
196
},
275
197
{
276
- name : "tenant without delay , both sample and float histogram" ,
198
+ name : "tenant, both sample and float histogram" ,
277
199
series : "foo_bar" ,
278
200
value : 1.234 ,
279
201
floatHistogram : testFloatHistogram ,
@@ -299,106 +221,9 @@ func TestPusherAppendable(t *testing.T) {
299
221
Source : cortexpb .RULE ,
300
222
},
301
223
},
302
- {
303
- name : "tenant with delay and NaN sample, normal histogram" ,
304
- series : "foo_bar" ,
305
- value : math .Float64frombits (value .StaleNaN ),
306
- evalDelay : time .Minute ,
307
- histogram : testHistogram ,
308
- expectedReq : & cortexpb.WriteRequest {
309
- Timeseries : []cortexpb.PreallocTimeseries {
310
- {
311
- TimeSeries : & cortexpb.TimeSeries {
312
- Labels : lbls1 ,
313
- Samples : []cortexpb.Sample {
314
- {Value : math .Float64frombits (value .StaleNaN ), TimestampMs : 60_000 },
315
- },
316
- },
317
- },
318
- {
319
- TimeSeries : & cortexpb.TimeSeries {
320
- Labels : lbls1 ,
321
- Histograms : []cortexpb.Histogram {
322
- cortexpb .HistogramToHistogramProto (120_000 , testHistogram ),
323
- },
324
- },
325
- },
326
- },
327
- Source : cortexpb .RULE ,
328
- },
329
- },
330
- {
331
- name : "tenant with delay and NaN sample, float histogram" ,
332
- series : "foo_bar" ,
333
- value : math .Float64frombits (value .StaleNaN ),
334
- evalDelay : time .Minute ,
335
- floatHistogram : testFloatHistogram ,
336
- expectedReq : & cortexpb.WriteRequest {
337
- Timeseries : []cortexpb.PreallocTimeseries {
338
- {
339
- TimeSeries : & cortexpb.TimeSeries {
340
- Labels : lbls1 ,
341
- Samples : []cortexpb.Sample {
342
- {Value : math .Float64frombits (value .StaleNaN ), TimestampMs : 60_000 },
343
- },
344
- },
345
- },
346
- {
347
- TimeSeries : & cortexpb.TimeSeries {
348
- Labels : lbls1 ,
349
- Histograms : []cortexpb.Histogram {
350
- cortexpb .FloatHistogramToHistogramProto (120_000 , testFloatHistogram ),
351
- },
352
- },
353
- },
354
- },
355
- Source : cortexpb .RULE ,
356
- },
357
- },
358
- {
359
- name : "tenant with delay, NaN histogram" ,
360
- series : "foo_bar" ,
361
- histogram : testHistogramWithNaN ,
362
- evalDelay : time .Minute ,
363
- expectedReq : & cortexpb.WriteRequest {
364
- Timeseries : []cortexpb.PreallocTimeseries {
365
- {
366
- TimeSeries : & cortexpb.TimeSeries {
367
- Labels : lbls1 ,
368
- Histograms : []cortexpb.Histogram {
369
- cortexpb .HistogramToHistogramProto (60_000 , testHistogramWithNaN ),
370
- },
371
- },
372
- },
373
- },
374
- Source : cortexpb .RULE ,
375
- },
376
- },
377
- {
378
- name : "tenant with delay, NaN float histogram" ,
379
- series : "foo_bar" ,
380
- floatHistogram : testFloatHistogramWithNaN ,
381
- evalDelay : time .Minute ,
382
- expectedReq : & cortexpb.WriteRequest {
383
- Timeseries : []cortexpb.PreallocTimeseries {
384
- {
385
- TimeSeries : & cortexpb.TimeSeries {
386
- Labels : lbls1 ,
387
- Histograms : []cortexpb.Histogram {
388
- cortexpb .FloatHistogramToHistogramProto (60_000 , testFloatHistogramWithNaN ),
389
- },
390
- },
391
- },
392
- },
393
- Source : cortexpb .RULE ,
394
- },
395
- },
396
224
} {
397
225
t .Run (tc .name , func (t * testing.T ) {
398
226
ctx := context .Background ()
399
- pa .rulesLimits = & ruleLimits {
400
- evalDelay : tc .evalDelay ,
401
- }
402
227
403
228
lbls , err := parser .ParseMetric (tc .series )
404
229
require .NoError (t , err )
@@ -461,7 +286,7 @@ func TestPusherErrors(t *testing.T) {
461
286
writes := prometheus .NewCounter (prometheus.CounterOpts {})
462
287
failures := prometheus .NewCounter (prometheus.CounterOpts {})
463
288
464
- pa := NewPusherAppendable (pusher , "user-1" , ruleLimits {evalDelay : 10 * time . Second }, writes , failures )
289
+ pa := NewPusherAppendable (pusher , "user-1" , ruleLimits {}, writes , failures )
465
290
466
291
lbls , err := parser .ParseMetric ("foo_bar" )
467
292
require .NoError (t , err )
0 commit comments