@@ -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,8 @@ 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
51
+ # HELP kube_horizontalpodautoscaler_deletion_timestamp Unix deletion timestamp
49
52
# TYPE kube_horizontalpodautoscaler_info gauge
50
53
# TYPE kube_horizontalpodautoscaler_annotations gauge
51
54
# TYPE kube_horizontalpodautoscaler_labels gauge
@@ -57,15 +60,19 @@ func TestHPAStore(t *testing.T) {
57
60
# TYPE kube_horizontalpodautoscaler_status_condition gauge
58
61
# TYPE kube_horizontalpodautoscaler_status_current_replicas gauge
59
62
# TYPE kube_horizontalpodautoscaler_status_desired_replicas gauge
63
+ # TYPE kube_horizontalpodautoscaler_created gauge
64
+ # TYPE kube_horizontalpodautoscaler_deletion_timestamp gauge
60
65
`
61
66
cases := []generateMetricsTestCase {
62
67
{
63
68
// Verify populating base metric.
64
69
Obj : & autoscaling.HorizontalPodAutoscaler {
65
70
ObjectMeta : metav1.ObjectMeta {
66
- Generation : 2 ,
67
- Name : "hpa1" ,
68
- Namespace : "ns1" ,
71
+ Generation : 2 ,
72
+ Name : "hpa1" ,
73
+ CreationTimestamp : metav1.Time {Time : time .Unix (1500000000 , 0 )},
74
+ DeletionTimestamp : & metav1.Time {Time : time .Unix (1800000000 , 0 )},
75
+ Namespace : "ns1" ,
69
76
Labels : map [string ]string {
70
77
"app" : "foobar" ,
71
78
},
@@ -233,6 +240,8 @@ func TestHPAStore(t *testing.T) {
233
240
kube_horizontalpodautoscaler_status_condition{condition="AbleToScale",horizontalpodautoscaler="hpa1",namespace="ns1",status="unknown"} 0
234
241
kube_horizontalpodautoscaler_status_current_replicas{horizontalpodautoscaler="hpa1",namespace="ns1"} 2
235
242
kube_horizontalpodautoscaler_status_desired_replicas{horizontalpodautoscaler="hpa1",namespace="ns1"} 2
243
+ kube_horizontalpodautoscaler_created{horizontalpodautoscaler="hpa1",namespace="ns1"} 1.5e+09
244
+ kube_horizontalpodautoscaler_deletion_timestamp{horizontalpodautoscaler="hpa1",namespace="ns1"} 1.8e+09
236
245
` ,
237
246
MetricNames : []string {
238
247
"kube_horizontalpodautoscaler_info" ,
@@ -246,6 +255,8 @@ func TestHPAStore(t *testing.T) {
246
255
"kube_horizontalpodautoscaler_status_condition" ,
247
256
"kube_horizontalpodautoscaler_annotations" ,
248
257
"kube_horizontalpodautoscaler_labels" ,
258
+ "kube_horizontalpodautoscaler_created" ,
259
+ "kube_horizontalpodautoscaler_deletion_timestamp" ,
249
260
},
250
261
},
251
262
{
@@ -255,9 +266,11 @@ func TestHPAStore(t *testing.T) {
255
266
},
256
267
Obj : & autoscaling.HorizontalPodAutoscaler {
257
268
ObjectMeta : metav1.ObjectMeta {
258
- Generation : 2 ,
259
- Name : "hpa2" ,
260
- Namespace : "ns1" ,
269
+ Generation : 2 ,
270
+ Name : "hpa2" ,
271
+ CreationTimestamp : metav1.Time {Time : time .Unix (1500000000 , 0 )},
272
+ DeletionTimestamp : & metav1.Time {Time : time .Unix (1800000000 , 0 )},
273
+ Namespace : "ns1" ,
261
274
Labels : map [string ]string {
262
275
"app" : "foobar" ,
263
276
},
@@ -408,6 +421,8 @@ func TestHPAStore(t *testing.T) {
408
421
kube_horizontalpodautoscaler_status_condition{condition="AbleToScale",horizontalpodautoscaler="hpa2",namespace="ns1",status="unknown"} 0
409
422
kube_horizontalpodautoscaler_status_current_replicas{horizontalpodautoscaler="hpa2",namespace="ns1"} 2
410
423
kube_horizontalpodautoscaler_status_desired_replicas{horizontalpodautoscaler="hpa2",namespace="ns1"} 2
424
+ kube_horizontalpodautoscaler_created{horizontalpodautoscaler="hpa2",namespace="ns1"} 1.5e+09
425
+ kube_horizontalpodautoscaler_deletion_timestamp{horizontalpodautoscaler="hpa2",namespace="ns1"} 1.8e+09
411
426
` ,
412
427
MetricNames : []string {
413
428
"kube_horizontalpodautoscaler_info" ,
@@ -421,6 +436,8 @@ func TestHPAStore(t *testing.T) {
421
436
"kube_horizontalpodautoscaler_status_condition" ,
422
437
"kube_horizontalpodautoscaler_annotation" ,
423
438
"kube_horizontalpodautoscaler_labels" ,
439
+ "kube_horizontalpodautoscaler_created" ,
440
+ "kube_horizontalpodautoscaler_deletion_timestamp" ,
424
441
},
425
442
},
426
443
}
0 commit comments