Skip to content

Commit 55e9be6

Browse files
validate ready and available node counts
1 parent 089e073 commit 55e9be6

File tree

1 file changed

+65
-0
lines changed

1 file changed

+65
-0
lines changed

exp/internal/controllers/machinepool_controller_noderef_test.go

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,14 @@ func TestMachinePoolGetNodeReference(t *testing.T) {
4545
Spec: corev1.NodeSpec{
4646
ProviderID: "aws://us-east-1/id-node-1",
4747
},
48+
Status: corev1.NodeStatus{
49+
Conditions: []corev1.NodeCondition{
50+
{
51+
Type: corev1.NodeReady,
52+
Status: corev1.ConditionTrue,
53+
},
54+
},
55+
},
4856
},
4957
&corev1.Node{
5058
ObjectMeta: metav1.ObjectMeta{
@@ -53,6 +61,14 @@ func TestMachinePoolGetNodeReference(t *testing.T) {
5361
Spec: corev1.NodeSpec{
5462
ProviderID: "aws://us-west-2/id-node-2",
5563
},
64+
Status: corev1.NodeStatus{
65+
Conditions: []corev1.NodeCondition{
66+
{
67+
Type: corev1.NodeReady,
68+
Status: corev1.ConditionTrue,
69+
},
70+
},
71+
},
5672
},
5773
&corev1.Node{
5874
ObjectMeta: metav1.ObjectMeta{
@@ -61,6 +77,14 @@ func TestMachinePoolGetNodeReference(t *testing.T) {
6177
Spec: corev1.NodeSpec{
6278
ProviderID: "gce://us-central1/gce-id-node-2",
6379
},
80+
Status: corev1.NodeStatus{
81+
Conditions: []corev1.NodeCondition{
82+
{
83+
Type: corev1.NodeReady,
84+
Status: corev1.ConditionTrue,
85+
},
86+
},
87+
},
6488
},
6589
&corev1.Node{
6690
ObjectMeta: metav1.ObjectMeta{
@@ -69,6 +93,14 @@ func TestMachinePoolGetNodeReference(t *testing.T) {
6993
Spec: corev1.NodeSpec{
7094
ProviderID: "azure://westus2/id-node-4",
7195
},
96+
Status: corev1.NodeStatus{
97+
Conditions: []corev1.NodeCondition{
98+
{
99+
Type: corev1.NodeReady,
100+
Status: corev1.ConditionTrue,
101+
},
102+
},
103+
},
72104
},
73105
&corev1.Node{
74106
ObjectMeta: metav1.ObjectMeta{
@@ -77,6 +109,14 @@ func TestMachinePoolGetNodeReference(t *testing.T) {
77109
Spec: corev1.NodeSpec{
78110
ProviderID: "azure://westus2/id-nodepool1/0",
79111
},
112+
Status: corev1.NodeStatus{
113+
Conditions: []corev1.NodeCondition{
114+
{
115+
Type: corev1.NodeReady,
116+
Status: corev1.ConditionTrue,
117+
},
118+
},
119+
},
80120
},
81121
&corev1.Node{
82122
ObjectMeta: metav1.ObjectMeta{
@@ -85,6 +125,14 @@ func TestMachinePoolGetNodeReference(t *testing.T) {
85125
Spec: corev1.NodeSpec{
86126
ProviderID: "azure://westus2/id-nodepool2/0",
87127
},
128+
Status: corev1.NodeStatus{
129+
Conditions: []corev1.NodeCondition{
130+
{
131+
Type: corev1.NodeReady,
132+
Status: corev1.ConditionTrue,
133+
},
134+
},
135+
},
88136
},
89137
}
90138

@@ -104,6 +152,8 @@ func TestMachinePoolGetNodeReference(t *testing.T) {
104152
references: []corev1.ObjectReference{
105153
{Name: "node-1"},
106154
},
155+
available: 1,
156+
ready: 1,
107157
},
108158
},
109159
{
@@ -113,6 +163,8 @@ func TestMachinePoolGetNodeReference(t *testing.T) {
113163
references: []corev1.ObjectReference{
114164
{Name: "node-2"},
115165
},
166+
available: 1,
167+
ready: 1,
116168
},
117169
},
118170
{
@@ -122,6 +174,8 @@ func TestMachinePoolGetNodeReference(t *testing.T) {
122174
references: []corev1.ObjectReference{
123175
{Name: "gce-node-2"},
124176
},
177+
available: 1,
178+
ready: 1,
125179
},
126180
},
127181
{
@@ -131,6 +185,8 @@ func TestMachinePoolGetNodeReference(t *testing.T) {
131185
references: []corev1.ObjectReference{
132186
{Name: "azure-node-4"},
133187
},
188+
available: 1,
189+
ready: 1,
134190
},
135191
},
136192
{
@@ -141,6 +197,8 @@ func TestMachinePoolGetNodeReference(t *testing.T) {
141197
{Name: "node-1"},
142198
{Name: "azure-node-4"},
143199
},
200+
available: 2,
201+
ready: 2,
144202
},
145203
},
146204
{
@@ -165,6 +223,8 @@ func TestMachinePoolGetNodeReference(t *testing.T) {
165223
references: []corev1.ObjectReference{
166224
{Name: "azure-nodepool1-0"},
167225
},
226+
available: 1,
227+
ready: 1,
168228
},
169229
},
170230
{
@@ -175,6 +235,8 @@ func TestMachinePoolGetNodeReference(t *testing.T) {
175235
{Name: "azure-nodepool1-0"},
176236
{Name: "azure-nodepool2-0"},
177237
},
238+
available: 2,
239+
ready: 2,
178240
},
179241
},
180242
{
@@ -217,6 +279,9 @@ func TestMachinePoolGetNodeReference(t *testing.T) {
217279

218280
g.Expect(result.references).To(HaveLen(len(test.expected.references)), "Expected NodeRef count to be %v, got %v", len(result.references), len(test.expected.references))
219281

282+
g.Expect(result.available).To(Equal(test.expected.ready), "Expected available node count to be %v, got %v", test.expected.available, result.available)
283+
g.Expect(result.ready).To(Equal(test.expected.ready), "Expected ready node count to be %v, got %v", test.expected.ready, result.ready)
284+
220285
for n := range test.expected.references {
221286
g.Expect(result.references[n].Name).To(Equal(test.expected.references[n].Name), "Expected NodeRef's name to be %v, got %v", result.references[n].Name, test.expected.references[n].Name)
222287
g.Expect(result.references[n].Namespace).To(Equal(test.expected.references[n].Namespace), "Expected NodeRef's namespace to be %v, got %v", result.references[n].Namespace, test.expected.references[n].Namespace)

0 commit comments

Comments
 (0)