@@ -269,22 +269,24 @@ func Test_operatorMetrics_Collect(t *testing.T) {
269
269
},
270
270
Status : configv1.ClusterVersionStatus {
271
271
Conditions : []configv1.ClusterOperatorStatusCondition {
272
- {Type : configv1 .RetrievedUpdates , Status : configv1 .ConditionTrue },
272
+ {Type : configv1 .RetrievedUpdates , Status : configv1 .ConditionTrue , Reason : "Because stuff" },
273
273
},
274
274
},
275
275
},
276
276
},
277
277
},
278
278
},
279
279
wants : func (t * testing.T , metrics []prometheus.Metric ) {
280
- if len (metrics ) != 5 {
280
+ if len (metrics ) != 6 {
281
281
t .Fatalf ("Unexpected metrics %s" , spew .Sdump (metrics ))
282
282
}
283
283
expectMetric (t , metrics [0 ], 2 , map [string ]string {"type" : "initial" , "version" : "" , "image" : "" , "from_version" : "" })
284
284
expectMetric (t , metrics [1 ], 2 , map [string ]string {"type" : "cluster" , "version" : "" , "image" : "" , "from_version" : "" })
285
+
285
286
expectMetric (t , metrics [2 ], 0 , map [string ]string {"upstream" : "<default>" , "channel" : "" })
286
- expectMetric (t , metrics [3 ], 0 , map [string ]string {"type" : "current" , "version" : "" , "image" : "" , "from_version" : "" })
287
- expectMetric (t , metrics [4 ], 1 , map [string ]string {"type" : "" })
287
+ expectMetric (t , metrics [3 ], 1 , map [string ]string {"name" : "version" , "condition" : "RetrievedUpdates" , "reason" : "Because stuff" })
288
+ expectMetric (t , metrics [4 ], 0 , map [string ]string {"type" : "current" , "version" : "" , "image" : "" , "from_version" : "" })
289
+ expectMetric (t , metrics [5 ], 1 , map [string ]string {"type" : "" })
288
290
},
289
291
},
290
292
{
@@ -305,22 +307,23 @@ func Test_operatorMetrics_Collect(t *testing.T) {
305
307
},
306
308
Status : configv1.ClusterVersionStatus {
307
309
Conditions : []configv1.ClusterOperatorStatusCondition {
308
- {Type : configv1 .OperatorAvailable , Status : configv1 .ConditionTrue , LastTransitionTime : metav1.Time {Time : time .Unix (5 , 0 )}},
310
+ {Type : configv1 .OperatorAvailable , Status : configv1 .ConditionTrue , LastTransitionTime : metav1.Time {Time : time .Unix (5 , 0 )}, Reason : "Because stuff" },
309
311
},
310
312
},
311
313
},
312
314
},
313
315
},
314
316
},
315
317
wants : func (t * testing.T , metrics []prometheus.Metric ) {
316
- if len (metrics ) != 5 {
318
+ if len (metrics ) != 6 {
317
319
t .Fatalf ("Unexpected metrics %s" , spew .Sdump (metrics ))
318
320
}
319
321
expectMetric (t , metrics [0 ], 2 , map [string ]string {"type" : "initial" , "version" : "" , "image" : "" , "from_version" : "" })
320
322
expectMetric (t , metrics [1 ], 2 , map [string ]string {"type" : "cluster" , "version" : "0.0.2" , "image" : "test/image:1" , "from_version" : "" })
321
323
expectMetric (t , metrics [2 ], 5 , map [string ]string {"type" : "desired" , "version" : "1.0.0" , "image" : "test/image:2" , "from_version" : "" })
322
- expectMetric (t , metrics [3 ], 0 , map [string ]string {"type" : "current" , "version" : "0.0.2" , "image" : "test/image:1" , "from_version" : "" })
323
- expectMetric (t , metrics [4 ], 1 , map [string ]string {"type" : "" })
324
+ expectMetric (t , metrics [3 ], 1 , map [string ]string {"name" : "version" , "condition" : "Available" , "reason" : "Because stuff" })
325
+ expectMetric (t , metrics [4 ], 0 , map [string ]string {"type" : "current" , "version" : "0.0.2" , "image" : "test/image:1" , "from_version" : "" })
326
+ expectMetric (t , metrics [5 ], 1 , map [string ]string {"type" : "" })
324
327
},
325
328
},
326
329
{
@@ -342,24 +345,25 @@ func Test_operatorMetrics_Collect(t *testing.T) {
342
345
},
343
346
Status : configv1.ClusterVersionStatus {
344
347
Conditions : []configv1.ClusterOperatorStatusCondition {
345
- {Type : ClusterStatusFailing , Status : configv1 .ConditionTrue , LastTransitionTime : metav1.Time {Time : time .Unix (4 , 0 )}},
348
+ {Type : ClusterStatusFailing , Status : configv1 .ConditionTrue , LastTransitionTime : metav1.Time {Time : time .Unix (4 , 0 )}, Reason : "Because stuff" },
346
349
},
347
350
},
348
351
},
349
352
},
350
353
},
351
354
},
352
355
wants : func (t * testing.T , metrics []prometheus.Metric ) {
353
- if len (metrics ) != 7 {
356
+ if len (metrics ) != 8 {
354
357
t .Fatalf ("Unexpected metrics %s" , spew .Sdump (metrics ))
355
358
}
356
359
expectMetric (t , metrics [0 ], 5 , map [string ]string {"type" : "initial" , "version" : "" , "image" : "" , "from_version" : "" })
357
360
expectMetric (t , metrics [1 ], 5 , map [string ]string {"type" : "cluster" , "version" : "0.0.2" , "image" : "test/image:1" , "from_version" : "" })
358
361
expectMetric (t , metrics [2 ], 5 , map [string ]string {"type" : "desired" , "version" : "1.0.0" , "image" : "test/image:2" , "from_version" : "" })
359
362
expectMetric (t , metrics [3 ], 4 , map [string ]string {"type" : "failure" , "version" : "1.0.0" , "image" : "test/image:2" , "from_version" : "" })
360
363
expectMetric (t , metrics [4 ], 4 , map [string ]string {"type" : "failure" , "version" : "0.0.2" , "image" : "test/image:1" , "from_version" : "" })
361
- expectMetric (t , metrics [5 ], 6 , map [string ]string {"type" : "current" , "version" : "0.0.2" , "image" : "test/image:1" , "from_version" : "" })
362
- expectMetric (t , metrics [6 ], 1 , map [string ]string {"type" : "" })
364
+ expectMetric (t , metrics [5 ], 1 , map [string ]string {"name" : "version" , "condition" : "Failing" , "reason" : "Because stuff" })
365
+ expectMetric (t , metrics [6 ], 6 , map [string ]string {"type" : "current" , "version" : "0.0.2" , "image" : "test/image:1" , "from_version" : "" })
366
+ expectMetric (t , metrics [7 ], 1 , map [string ]string {"type" : "" })
363
367
},
364
368
},
365
369
{
@@ -377,22 +381,23 @@ func Test_operatorMetrics_Collect(t *testing.T) {
377
381
},
378
382
Status : configv1.ClusterVersionStatus {
379
383
Conditions : []configv1.ClusterOperatorStatusCondition {
380
- {Type : ClusterStatusFailing , Status : configv1 .ConditionTrue },
384
+ {Type : ClusterStatusFailing , Status : configv1 .ConditionTrue , Reason : "Because stuff" },
381
385
},
382
386
},
383
387
},
384
388
},
385
389
},
386
390
},
387
391
wants : func (t * testing.T , metrics []prometheus.Metric ) {
388
- if len (metrics ) != 5 {
392
+ if len (metrics ) != 6 {
389
393
t .Fatalf ("Unexpected metrics %s" , spew .Sdump (metrics ))
390
394
}
391
395
expectMetric (t , metrics [0 ], 2 , map [string ]string {"type" : "initial" , "version" : "" , "image" : "" , "from_version" : "" })
392
396
expectMetric (t , metrics [1 ], 2 , map [string ]string {"type" : "cluster" , "version" : "0.0.2" , "image" : "test/image:1" , "from_version" : "" })
393
397
expectMetric (t , metrics [2 ], 0 , map [string ]string {"type" : "failure" , "version" : "0.0.2" , "image" : "test/image:1" , "from_version" : "" })
394
- expectMetric (t , metrics [3 ], 0 , map [string ]string {"type" : "current" , "version" : "0.0.2" , "image" : "test/image:1" , "from_version" : "" })
395
- expectMetric (t , metrics [4 ], 1 , map [string ]string {"type" : "" })
398
+ expectMetric (t , metrics [3 ], 1 , map [string ]string {"name" : "version" , "condition" : "Failing" , "reason" : "Because stuff" })
399
+ expectMetric (t , metrics [4 ], 0 , map [string ]string {"type" : "current" , "version" : "0.0.2" , "image" : "test/image:1" , "from_version" : "" })
400
+ expectMetric (t , metrics [5 ], 1 , map [string ]string {"type" : "" })
396
401
},
397
402
},
398
403
{
0 commit comments