forked from kubernetes/autoscaler
-
Notifications
You must be signed in to change notification settings - Fork 0
/
aws_nodegroups_test.go
183 lines (174 loc) · 5.28 KB
/
aws_nodegroups_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
/*
Copyright 2024 The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package aws
import (
"testing"
"k8s.io/autoscaler/cluster-autoscaler/config"
"k8s.io/autoscaler/cluster-autoscaler/context"
"k8s.io/autoscaler/cluster-autoscaler/processors/nodegroupset"
. "k8s.io/autoscaler/cluster-autoscaler/utils/test"
)
func TestIsAwsNodeInfoSimilar(t *testing.T) {
comparator := CreateNodeInfoComparator([]string{}, config.NodeGroupDifferenceRatios{})
node1 := BuildTestNode("node1", 1000, 2000)
node2 := BuildTestNode("node2", 1000, 2000)
for _, tc := range []struct {
description string
label string
value1 string
value2 string
removeOneLabel bool
}{
{
description: "alpha.eksctl.io/instance-id empty value",
label: "alpha.eksctl.io/instance-id",
value1: "",
value2: "",
removeOneLabel: false,
},
{
description: "alpha.eksctl.io/instance-id different values",
label: "alpha.eksctl.io/instance-id",
value1: "foo",
value2: "bar",
removeOneLabel: false,
},
{
description: "alpha.eksctl.io/instance-id one node labeled",
label: "alpha.eksctl.io/instance-id",
value1: "foo",
value2: "bar",
removeOneLabel: true,
},
{
description: "alpha.eksctl.io/nodegroup-name empty value",
label: "alpha.eksctl.io/nodegroup-name",
value1: "",
value2: "",
removeOneLabel: false,
},
{
description: "alpha.eksctl.io/nodegroup-name different values",
label: "alpha.eksctl.io/nodegroup-name",
value1: "foo",
value2: "bar",
removeOneLabel: false,
},
{
description: "alpha.eksctl.io/nodegroup-name one node labeled",
label: "alpha.eksctl.io/nodegroup-name",
value1: "foo",
value2: "bar",
removeOneLabel: true,
},
{
description: "eks.amazonaws.com/nodegroup empty value",
label: "eks.amazonaws.com/nodegroup",
value1: "",
value2: "",
removeOneLabel: false,
},
{
description: "eks.amazonaws.com/nodegroup different values",
label: "eks.amazonaws.com/nodegroup",
value1: "foo",
value2: "bar",
removeOneLabel: false,
},
{
description: "eks.amazonaws.com/nodegroup one node labeled",
label: "eks.amazonaws.com/nodegroup",
value1: "foo",
value2: "bar",
removeOneLabel: true,
},
{
description: "k8s.amazonaws.com/eniConfig empty value",
label: "k8s.amazonaws.com/eniConfig",
value1: "",
value2: "",
removeOneLabel: false,
},
{
description: "k8s.amazonaws.com/eniConfig different values",
label: "k8s.amazonaws.com/eniConfig",
value1: "foo",
value2: "bar",
removeOneLabel: false,
},
{
description: "k8s.amazonaws.com/eniConfig one node labeled",
label: "k8s.amazonaws.com/eniConfig",
value1: "foo",
value2: "bar",
removeOneLabel: true,
},
{
description: "lifecycle empty value",
label: "lifecycle",
value1: "",
value2: "",
removeOneLabel: false,
},
{
description: "lifecycle different values",
label: "lifecycle",
value1: "foo",
value2: "bar",
removeOneLabel: false,
},
{
description: "lifecycle one node labeled",
label: "lifecycle",
value1: "foo",
value2: "bar",
removeOneLabel: true,
},
{
description: "topology.ebs.csi.aws.com/zone empty value",
label: "topology.ebs.csi.aws.com/zone",
value1: "",
value2: "",
removeOneLabel: false,
},
{
description: "topology.ebs.csi.aws.com/zone different values",
label: "topology.ebs.csi.aws.com/zone",
value1: "foo",
value2: "bar",
removeOneLabel: false,
},
{
description: "topology.ebs.csi.aws.com/zone one node labeled",
label: "topology.ebs.csi.aws.com/zone",
value1: "foo",
value2: "bar",
removeOneLabel: true,
},
} {
t.Run(tc.description, func(t *testing.T) {
node1.ObjectMeta.Labels[tc.label] = tc.value1
node2.ObjectMeta.Labels[tc.label] = tc.value2
if tc.removeOneLabel {
delete(node2.ObjectMeta.Labels, tc.label)
}
nodegroupset.CheckNodesSimilar(t, node1, node2, comparator, true)
})
}
}
func TestFindSimilarNodeGroupsAwsBasic(t *testing.T) {
context := &context.AutoscalingContext{}
ni1, ni2, ni3 := nodegroupset.BuildBasicNodeGroups(context)
processor := &nodegroupset.BalancingNodeGroupSetProcessor{Comparator: CreateNodeInfoComparator([]string{}, config.NodeGroupDifferenceRatios{})}
nodegroupset.BasicSimilarNodeGroupsTest(t, context, processor, ni1, ni2, ni3)
}