Skip to content

Commit 9ad6d51

Browse files
authored
Merge pull request #8501 from jackfrancis/e2e-machinedeployment-wait-nodes-err
🌱 assert E2E error responses when waiting for MD nodes
2 parents c2979d0 + 2d5222d commit 9ad6d51

File tree

1 file changed

+10
-18
lines changed

1 file changed

+10
-18
lines changed

test/framework/machinedeployment_helpers.go

Lines changed: 10 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -104,35 +104,27 @@ func WaitForMachineDeploymentNodesToExist(ctx context.Context, input WaitForMach
104104
Expect(input.MachineDeployment).ToNot(BeNil(), "Invalid argument. input.MachineDeployment can't be nil when calling WaitForMachineDeploymentNodesToExist")
105105

106106
By("Waiting for the workload nodes to exist")
107-
Eventually(func() (int, error) {
107+
Eventually(func(g Gomega) {
108108
selectorMap, err := metav1.LabelSelectorAsMap(&input.MachineDeployment.Spec.Selector)
109-
if err != nil {
110-
return 0, err
111-
}
109+
g.Expect(err).NotTo(HaveOccurred())
112110
ms := &clusterv1.MachineSetList{}
113-
if err := input.Lister.List(ctx, ms, client.InNamespace(input.Cluster.Namespace), client.MatchingLabels(selectorMap)); err != nil {
114-
return 0, err
115-
}
116-
if len(ms.Items) == 0 {
117-
return 0, errors.New("no machinesets were found")
118-
}
111+
err = input.Lister.List(ctx, ms, client.InNamespace(input.Cluster.Namespace), client.MatchingLabels(selectorMap))
112+
g.Expect(err).NotTo(HaveOccurred())
113+
g.Expect(ms.Items).NotTo(BeEmpty())
119114
machineSet := ms.Items[0]
120115
selectorMap, err = metav1.LabelSelectorAsMap(&machineSet.Spec.Selector)
121-
if err != nil {
122-
return 0, err
123-
}
116+
g.Expect(err).NotTo(HaveOccurred())
124117
machines := &clusterv1.MachineList{}
125-
if err := input.Lister.List(ctx, machines, client.InNamespace(machineSet.Namespace), client.MatchingLabels(selectorMap)); err != nil {
126-
return 0, err
127-
}
118+
err = input.Lister.List(ctx, machines, client.InNamespace(machineSet.Namespace), client.MatchingLabels(selectorMap))
119+
g.Expect(err).NotTo(HaveOccurred())
128120
count := 0
129121
for _, machine := range machines.Items {
130122
if machine.Status.NodeRef != nil {
131123
count++
132124
}
133125
}
134-
return count, nil
135-
}, intervals...).Should(Equal(int(*input.MachineDeployment.Spec.Replicas)), "Timed out waiting for %d nodes to be created for MachineDeployment %s", int(*input.MachineDeployment.Spec.Replicas), klog.KObj(input.MachineDeployment))
126+
g.Expect(count).To(Equal(int(*input.MachineDeployment.Spec.Replicas)))
127+
}, intervals...).Should(Succeed(), "Timed out waiting for %d nodes to be created for MachineDeployment %s", int(*input.MachineDeployment.Spec.Replicas), klog.KObj(input.MachineDeployment))
136128
}
137129

138130
// AssertMachineDeploymentFailureDomainsInput is the input for AssertMachineDeploymentFailureDomains.

0 commit comments

Comments
 (0)