@@ -27,30 +27,36 @@ import (
27
27
28
28
func TestAddEvictedPod (t * testing.T ) {
29
29
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
34
36
}{
35
37
{
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" ,
40
44
},
41
45
{
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" ,
46
52
},
47
53
}
48
54
49
55
for _ , tc := range testCases {
50
56
t .Run (tc .desc , func (t * testing.T ) {
51
57
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 ))
54
60
if val != 1 {
55
61
t .Errorf ("Unexpected value for evictedCount metric with labels (%s, %s): got %v, want 1" , tc .log2 , string (tc .mode ), val )
56
62
}
@@ -60,31 +66,37 @@ func TestAddEvictedPod(t *testing.T) {
60
66
61
67
func TestRecordFailedEviction (t * testing.T ) {
62
68
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
68
76
}{
69
77
{
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" ,
74
84
},
75
85
{
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" ,
80
92
},
81
93
}
82
94
83
95
for _ , tc := range testCases {
84
96
t .Run (tc .desc , func (t * testing.T ) {
85
97
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 ))
88
100
if val != 1 {
89
101
t .Errorf ("Unexpected value for FailedEviction metric with labels (%s, %s): got %v, want 1" , tc .log2 , tc .reason , val )
90
102
}
@@ -94,27 +106,33 @@ func TestRecordFailedEviction(t *testing.T) {
94
106
95
107
func TestAddInPlaceUpdatedPod (t * testing.T ) {
96
108
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
100
114
}{
101
115
{
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" ,
105
121
},
106
122
{
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" ,
110
128
},
111
129
}
112
130
113
131
for _ , tc := range testCases {
114
132
t .Run (tc .desc , func (t * testing.T ) {
115
133
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 ))
118
136
if val != 1 {
119
137
t .Errorf ("Unexpected value for InPlaceUpdatedPod metric with labels (%s): got %v, want 1" , tc .log2 , val )
120
138
}
@@ -124,30 +142,36 @@ func TestAddInPlaceUpdatedPod(t *testing.T) {
124
142
125
143
func TestRecordFailedInPlaceUpdate (t * testing.T ) {
126
144
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
131
151
}{
132
152
{
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" ,
137
159
},
138
160
{
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" ,
143
167
},
144
168
}
145
169
146
170
for _ , tc := range testCases {
147
171
t .Run (tc .desc , func (t * testing.T ) {
148
172
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 ))
151
175
if val != 1 {
152
176
t .Errorf ("Unexpected value for FailedInPlaceUpdate metric with labels (%s, %s): got %v, want 1" , tc .log2 , tc .reason , val )
153
177
}
0 commit comments