@@ -27,30 +27,36 @@ import (
2727
2828func TestAddEvictedPod (t * testing.T ) {
2929 testCases := []struct {
30- desc string
31- vpaSize int
32- mode vpa_types.UpdateMode
33- log2 string
30+ desc string
31+ vpaSize int
32+ mode vpa_types.UpdateMode
33+ log2 string
34+ vpaName string
35+ vpaNamespace string
3436 }{
3537 {
36- desc : "VPA size 5, mode Auto" ,
37- vpaSize : 5 ,
38- mode : vpa_types .UpdateModeAuto ,
39- log2 : "2" ,
38+ desc : "VPA size 5, mode Auto" ,
39+ vpaSize : 5 ,
40+ mode : vpa_types .UpdateModeAuto ,
41+ log2 : "2" ,
42+ vpaName : "vpa-5" ,
43+ vpaNamespace : "vpa-ns-5" ,
4044 },
4145 {
42- desc : "VPA size 10, mode Off" ,
43- vpaSize : 10 ,
44- mode : vpa_types .UpdateModeOff ,
45- log2 : "3" ,
46+ desc : "VPA size 10, mode Off" ,
47+ vpaSize : 10 ,
48+ mode : vpa_types .UpdateModeOff ,
49+ log2 : "3" ,
50+ vpaName : "vpa-10" ,
51+ vpaNamespace : "vpa-ns-10" ,
4652 },
4753 }
4854
4955 for _ , tc := range testCases {
5056 t .Run (tc .desc , func (t * testing.T ) {
5157 t .Cleanup (evictedCount .Reset )
52- AddEvictedPod (tc .vpaSize , tc .mode )
53- val := testutil .ToFloat64 (evictedCount .WithLabelValues (tc .log2 , string (tc .mode )))
58+ AddEvictedPod (tc .vpaSize , tc .vpaName , tc . vpaNamespace , tc . mode )
59+ val := testutil .ToFloat64 (evictedCount .WithLabelValues (tc .log2 , string (tc .mode ), tc . vpaName , tc . vpaNamespace ))
5460 if val != 1 {
5561 t .Errorf ("Unexpected value for evictedCount metric with labels (%s, %s): got %v, want 1" , tc .log2 , string (tc .mode ), val )
5662 }
@@ -60,31 +66,37 @@ func TestAddEvictedPod(t *testing.T) {
6066
6167func TestRecordFailedEviction (t * testing.T ) {
6268 testCases := []struct {
63- desc string
64- vpaSize int
65- mode vpa_types.UpdateMode
66- reason string
67- log2 string
69+ desc string
70+ vpaSize int
71+ mode vpa_types.UpdateMode
72+ reason string
73+ log2 string
74+ vpaName string
75+ vpaNamespace string
6876 }{
6977 {
70- desc : "VPA size 2, some reason" ,
71- vpaSize : 2 ,
72- reason : "some_reason" ,
73- log2 : "1" ,
78+ desc : "VPA size 2, some reason" ,
79+ vpaSize : 2 ,
80+ reason : "some_reason" ,
81+ log2 : "1" ,
82+ vpaName : "vpa-2" ,
83+ vpaNamespace : "vpa-2-ns" ,
7484 },
7585 {
76- desc : "VPA size 20, another reason" ,
77- vpaSize : 20 ,
78- reason : "another_reason" ,
79- log2 : "4" ,
86+ desc : "VPA size 20, another reason" ,
87+ vpaSize : 20 ,
88+ reason : "another_reason" ,
89+ log2 : "4" ,
90+ vpaName : "vpa-20" ,
91+ vpaNamespace : "vpa-20-ns" ,
8092 },
8193 }
8294
8395 for _ , tc := range testCases {
8496 t .Run (tc .desc , func (t * testing.T ) {
8597 t .Cleanup (failedEvictionAttempts .Reset )
86- RecordFailedEviction (tc .vpaSize , tc .mode , tc .reason )
87- val := testutil .ToFloat64 (failedEvictionAttempts .WithLabelValues (tc .log2 , string (tc .mode ), tc .reason ))
98+ RecordFailedEviction (tc .vpaSize , tc .vpaName , tc . vpaNamespace , tc . mode , tc .reason )
99+ val := testutil .ToFloat64 (failedEvictionAttempts .WithLabelValues (tc .log2 , string (tc .mode ), tc .reason , tc . vpaName , tc . vpaNamespace ))
88100 if val != 1 {
89101 t .Errorf ("Unexpected value for FailedEviction metric with labels (%s, %s): got %v, want 1" , tc .log2 , tc .reason , val )
90102 }
@@ -94,27 +106,33 @@ func TestRecordFailedEviction(t *testing.T) {
94106
95107func TestAddInPlaceUpdatedPod (t * testing.T ) {
96108 testCases := []struct {
97- desc string
98- vpaSize int
99- log2 string
109+ desc string
110+ vpaSize int
111+ log2 string
112+ vpaName string
113+ vpaNamespace string
100114 }{
101115 {
102- desc : "VPA size 10" ,
103- vpaSize : 10 ,
104- log2 : "3" ,
116+ desc : "VPA size 10" ,
117+ vpaSize : 10 ,
118+ log2 : "3" ,
119+ vpaName : "vpa-10" ,
120+ vpaNamespace : "vpa-ns-10" ,
105121 },
106122 {
107- desc : "VPA size 1" ,
108- vpaSize : 1 ,
109- log2 : "0" ,
123+ desc : "VPA size 1" ,
124+ vpaSize : 1 ,
125+ log2 : "0" ,
126+ vpaName : "vpa-1" ,
127+ vpaNamespace : "vpa-ns-1" ,
110128 },
111129 }
112130
113131 for _ , tc := range testCases {
114132 t .Run (tc .desc , func (t * testing.T ) {
115133 t .Cleanup (inPlaceUpdatedCount .Reset )
116- AddInPlaceUpdatedPod (tc .vpaSize )
117- val := testutil .ToFloat64 (inPlaceUpdatedCount .WithLabelValues (tc .log2 ))
134+ AddInPlaceUpdatedPod (tc .vpaSize , tc . vpaName , tc . vpaNamespace )
135+ val := testutil .ToFloat64 (inPlaceUpdatedCount .WithLabelValues (tc .log2 , tc . vpaName , tc . vpaNamespace ))
118136 if val != 1 {
119137 t .Errorf ("Unexpected value for InPlaceUpdatedPod metric with labels (%s): got %v, want 1" , tc .log2 , val )
120138 }
@@ -124,30 +142,36 @@ func TestAddInPlaceUpdatedPod(t *testing.T) {
124142
125143func TestRecordFailedInPlaceUpdate (t * testing.T ) {
126144 testCases := []struct {
127- desc string
128- vpaSize int
129- reason string
130- log2 string
145+ desc string
146+ vpaSize int
147+ reason string
148+ log2 string
149+ vpaName string
150+ vpaNamespace string
131151 }{
132152 {
133- desc : "VPA size 2, some reason" ,
134- vpaSize : 2 ,
135- reason : "some_reason" ,
136- log2 : "1" ,
153+ desc : "VPA size 2, some reason" ,
154+ vpaSize : 2 ,
155+ reason : "some_reason" ,
156+ log2 : "1" ,
157+ vpaName : "vpa-2" ,
158+ vpaNamespace : "vpa-2-ns" ,
137159 },
138160 {
139- desc : "VPA size 20, another reason" ,
140- vpaSize : 20 ,
141- reason : "another_reason" ,
142- log2 : "4" ,
161+ desc : "VPA size 20, another reason" ,
162+ vpaSize : 20 ,
163+ reason : "another_reason" ,
164+ log2 : "4" ,
165+ vpaName : "vpa-20" ,
166+ vpaNamespace : "vpa-20-ns" ,
143167 },
144168 }
145169
146170 for _ , tc := range testCases {
147171 t .Run (tc .desc , func (t * testing.T ) {
148172 t .Cleanup (failedInPlaceUpdateAttempts .Reset )
149- RecordFailedInPlaceUpdate (tc .vpaSize , tc .reason )
150- val := testutil .ToFloat64 (failedInPlaceUpdateAttempts .WithLabelValues (tc .log2 , tc .reason ))
173+ RecordFailedInPlaceUpdate (tc .vpaSize , tc .vpaName , tc . vpaNamespace , tc . reason )
174+ val := testutil .ToFloat64 (failedInPlaceUpdateAttempts .WithLabelValues (tc .log2 , tc .reason , tc . vpaName , tc . vpaNamespace ))
151175 if val != 1 {
152176 t .Errorf ("Unexpected value for FailedInPlaceUpdate metric with labels (%s, %s): got %v, want 1" , tc .log2 , tc .reason , val )
153177 }
0 commit comments