@@ -18,6 +18,7 @@ package store
18
18
19
19
import (
20
20
"testing"
21
+ "time"
21
22
22
23
autoscaling "k8s.io/api/autoscaling/v2"
23
24
v1 "k8s.io/api/core/v1"
@@ -46,6 +47,7 @@ func TestHPAStore(t *testing.T) {
46
47
# HELP kube_horizontalpodautoscaler_status_condition [STABLE] The condition of this autoscaler.
47
48
# HELP kube_horizontalpodautoscaler_status_current_replicas [STABLE] Current number of replicas of pods managed by this autoscaler.
48
49
# HELP kube_horizontalpodautoscaler_status_desired_replicas [STABLE] Desired number of replicas of pods managed by this autoscaler.
50
+ # HELP kube_horizontalpodautoscaler_created Unix creation timestamp
49
51
# TYPE kube_horizontalpodautoscaler_info gauge
50
52
# TYPE kube_horizontalpodautoscaler_annotations gauge
51
53
# TYPE kube_horizontalpodautoscaler_labels gauge
@@ -57,15 +59,17 @@ func TestHPAStore(t *testing.T) {
57
59
# TYPE kube_horizontalpodautoscaler_status_condition gauge
58
60
# TYPE kube_horizontalpodautoscaler_status_current_replicas gauge
59
61
# TYPE kube_horizontalpodautoscaler_status_desired_replicas gauge
62
+ # TYPE kube_horizontalpodautoscaler_created gauge
60
63
`
61
64
cases := []generateMetricsTestCase {
62
65
{
63
66
// Verify populating base metric.
64
67
Obj : & autoscaling.HorizontalPodAutoscaler {
65
68
ObjectMeta : metav1.ObjectMeta {
66
- Generation : 2 ,
67
- Name : "hpa1" ,
68
- Namespace : "ns1" ,
69
+ Generation : 2 ,
70
+ Name : "hpa1" ,
71
+ CreationTimestamp : metav1.Time {Time : time .Unix (1500000000 , 0 )},
72
+ Namespace : "ns1" ,
69
73
Labels : map [string ]string {
70
74
"app" : "foobar" ,
71
75
},
@@ -233,6 +237,7 @@ func TestHPAStore(t *testing.T) {
233
237
kube_horizontalpodautoscaler_status_condition{condition="AbleToScale",horizontalpodautoscaler="hpa1",namespace="ns1",status="unknown"} 0
234
238
kube_horizontalpodautoscaler_status_current_replicas{horizontalpodautoscaler="hpa1",namespace="ns1"} 2
235
239
kube_horizontalpodautoscaler_status_desired_replicas{horizontalpodautoscaler="hpa1",namespace="ns1"} 2
240
+ kube_horizontalpodautoscaler_created{horizontalpodautoscaler="hpa1",namespace="ns1"} 1.5e+09
236
241
` ,
237
242
MetricNames : []string {
238
243
"kube_horizontalpodautoscaler_info" ,
@@ -246,6 +251,7 @@ func TestHPAStore(t *testing.T) {
246
251
"kube_horizontalpodautoscaler_status_condition" ,
247
252
"kube_horizontalpodautoscaler_annotations" ,
248
253
"kube_horizontalpodautoscaler_labels" ,
254
+ "kube_horizontalpodautoscaler_created" ,
249
255
},
250
256
},
251
257
{
@@ -255,9 +261,10 @@ func TestHPAStore(t *testing.T) {
255
261
},
256
262
Obj : & autoscaling.HorizontalPodAutoscaler {
257
263
ObjectMeta : metav1.ObjectMeta {
258
- Generation : 2 ,
259
- Name : "hpa2" ,
260
- Namespace : "ns1" ,
264
+ Generation : 2 ,
265
+ Name : "hpa2" ,
266
+ CreationTimestamp : metav1.Time {Time : time .Unix (1500000000 , 0 )},
267
+ Namespace : "ns1" ,
261
268
Labels : map [string ]string {
262
269
"app" : "foobar" ,
263
270
},
@@ -408,6 +415,7 @@ func TestHPAStore(t *testing.T) {
408
415
kube_horizontalpodautoscaler_status_condition{condition="AbleToScale",horizontalpodautoscaler="hpa2",namespace="ns1",status="unknown"} 0
409
416
kube_horizontalpodautoscaler_status_current_replicas{horizontalpodautoscaler="hpa2",namespace="ns1"} 2
410
417
kube_horizontalpodautoscaler_status_desired_replicas{horizontalpodautoscaler="hpa2",namespace="ns1"} 2
418
+ kube_horizontalpodautoscaler_created{horizontalpodautoscaler="hpa2",namespace="ns1"} 1.5e+09
411
419
` ,
412
420
MetricNames : []string {
413
421
"kube_horizontalpodautoscaler_info" ,
@@ -421,6 +429,7 @@ func TestHPAStore(t *testing.T) {
421
429
"kube_horizontalpodautoscaler_status_condition" ,
422
430
"kube_horizontalpodautoscaler_annotation" ,
423
431
"kube_horizontalpodautoscaler_labels" ,
432
+ "kube_horizontalpodautoscaler_created" ,
424
433
},
425
434
},
426
435
}
0 commit comments