Skip to content

Commit

Permalink
assert E2E error responses when waiting for MD nodes
Browse files Browse the repository at this point in the history
  • Loading branch information
jackfrancis committed Apr 10, 2023
1 parent 4f60841 commit 779d38f
Showing 1 changed file with 10 additions and 17 deletions.
27 changes: 10 additions & 17 deletions test/framework/machinedeployment_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,35 +104,28 @@ func WaitForMachineDeploymentNodesToExist(ctx context.Context, input WaitForMach
Expect(input.MachineDeployment).ToNot(BeNil(), "Invalid argument. input.MachineDeployment can't be nil when calling WaitForMachineDeploymentNodesToExist")

By("Waiting for the workload nodes to exist")
Eventually(func() (int, error) {
Eventually(func(g Gomega) (int, error) {
selectorMap, err := metav1.LabelSelectorAsMap(&input.MachineDeployment.Spec.Selector)
if err != nil {
return 0, err
}
g.Expect(err).NotTo(HaveOccurred())
ms := &clusterv1.MachineSetList{}
if err := input.Lister.List(ctx, ms, client.InNamespace(input.Cluster.Namespace), client.MatchingLabels(selectorMap)); err != nil {
return 0, err
}
if len(ms.Items) == 0 {
return 0, errors.New("no machinesets were found")
}
err = input.Lister.List(ctx, ms, client.InNamespace(input.Cluster.Namespace), client.MatchingLabels(selectorMap))
g.Expect(err).NotTo(HaveOccurred())
g.Expect(len(ms.Items)).NotTo(Equal(0))

Check failure on line 113 in test/framework/machinedeployment_helpers.go

View workflow job for this annotation

GitHub Actions / lint (test)

ginkgo-linter: wrong length assertion; consider using `g.Expect(ms.Items).NotTo(BeEmpty())` instead (ginkgolinter)
machineSet := ms.Items[0]
selectorMap, err = metav1.LabelSelectorAsMap(&machineSet.Spec.Selector)
if err != nil {
return 0, err
}
g.Expect(err).NotTo(HaveOccurred())
machines := &clusterv1.MachineList{}
if err := input.Lister.List(ctx, machines, client.InNamespace(machineSet.Namespace), client.MatchingLabels(selectorMap)); err != nil {
return 0, err
}
err = input.Lister.List(ctx, machines, client.InNamespace(machineSet.Namespace), client.MatchingLabels(selectorMap))
g.Expect(err).NotTo(HaveOccurred())
count := 0
for _, machine := range machines.Items {
if machine.Status.NodeRef != nil {
count++
}
}
g.Expect(count).To(Equal(int(*input.MachineDeployment.Spec.Replicas)))
return count, nil
}, 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))
}, intervals...).Should(Succeed(), "Timed out waiting for %d nodes to be created for MachineDeployment %s", int(*input.MachineDeployment.Spec.Replicas), klog.KObj(input.MachineDeployment))
}

// AssertMachineDeploymentFailureDomainsInput is the input for AssertMachineDeploymentFailureDomains.
Expand Down

0 comments on commit 779d38f

Please sign in to comment.