Skip to content

Commit

Permalink
Merge pull request #8516 from k8s-infra-cherrypick-robot/cherry-pick-…
Browse files Browse the repository at this point in the history
…8501-to-release-1.4

[release-1.4] 🌱 assert E2E error responses when waiting for MD nodes
  • Loading branch information
k8s-ci-robot committed Apr 12, 2023
2 parents 40ea2d9 + 6a6d8b0 commit b2963d8
Showing 1 changed file with 10 additions and 18 deletions.
28 changes: 10 additions & 18 deletions test/framework/machinedeployment_helpers.go
Expand Up @@ -104,35 +104,27 @@ 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) {
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(ms.Items).NotTo(BeEmpty())
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++
}
}
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))
g.Expect(count).To(Equal(int(*input.MachineDeployment.Spec.Replicas)))
}, 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 b2963d8

Please sign in to comment.