@@ -17,10 +17,11 @@ limitations under the License.
17
17
package utils
18
18
19
19
import (
20
+ "testing"
21
+
20
22
"github.com/stretchr/testify/assert"
21
23
apiv1 "k8s.io/api/core/v1"
22
24
"k8s.io/autoscaler/cluster-autoscaler/utils/test"
23
- "testing"
24
25
)
25
26
26
27
func TestPodSpecSemanticallyEqual (t * testing.T ) {
@@ -46,6 +47,26 @@ func TestPodSpecSemanticallyEqual(t *testing.T) {
46
47
},
47
48
result : true ,
48
49
},
50
+ {
51
+ name : "two pods with different ENV" ,
52
+ p1Spec : apiv1.PodSpec {
53
+ Containers : []apiv1.Container {
54
+ {Env : []apiv1.EnvVar {{Name : "foo" , Value : "bar" }}},
55
+ },
56
+ InitContainers : []apiv1.Container {
57
+ {Env : []apiv1.EnvVar {{Name : "foo" , Value : "bar" }}},
58
+ },
59
+ },
60
+ p2Spec : apiv1.PodSpec {
61
+ Containers : []apiv1.Container {
62
+ {Env : []apiv1.EnvVar {{Name : "baz" , Value : "foo" }}},
63
+ },
64
+ InitContainers : []apiv1.Container {
65
+ {Env : []apiv1.EnvVar {{Name : "baz" , Value : "bar" }}},
66
+ },
67
+ },
68
+ result : true ,
69
+ },
49
70
{
50
71
name : "two pods with different volumes" ,
51
72
p1Spec : apiv1.PodSpec {
@@ -72,6 +93,7 @@ func TestPodSpecSemanticallyEqual(t *testing.T) {
72
93
{Image : "foo/baz" , Name : "foobaz" },
73
94
},
74
95
},
96
+ result : false ,
75
97
},
76
98
{
77
99
name : "two pods with different hostnames" ,
@@ -180,6 +202,27 @@ func TestSanitizePodSpec(t *testing.T) {
180
202
},
181
203
},
182
204
},
205
+ {
206
+ name : "pod spec with env" ,
207
+ inputPodSpec : apiv1.PodSpec {
208
+ NodeSelector : map [string ]string {"foo" : "bar" },
209
+ Containers : []apiv1.Container {
210
+ {Image : "foo/bar" , Name : "foobar" , Env : []apiv1.EnvVar {{Name : "foo" , Value : "bar" }}},
211
+ },
212
+ InitContainers : []apiv1.Container {
213
+ {Image : "foo/baz" , Name : "foobaz" , Env : []apiv1.EnvVar {{Name : "foo2" , Value : "bar2" }}},
214
+ },
215
+ },
216
+ outputPodSpec : apiv1.PodSpec {
217
+ NodeSelector : map [string ]string {"foo" : "bar" },
218
+ Containers : []apiv1.Container {
219
+ {Image : "foo/bar" , Name : "foobar" },
220
+ },
221
+ InitContainers : []apiv1.Container {
222
+ {Image : "foo/baz" , Name : "foobaz" },
223
+ },
224
+ },
225
+ },
183
226
}
184
227
185
228
for _ , tt := range tests {
0 commit comments