Skip to content

Commit 79d030a

Browse files
[release-1.11] 🌱 e2e: use wait-machine-upgrade timeout in ClusterClassChanges tests to wait for machines to be ready (#13022)
* e2e: use wait-machine-upgrade timeout in ClusterClassChanges tests to wait for machines to be ready * bump for netlify --------- Co-authored-by: Christian Schlotter <[email protected]>
1 parent 2d264a1 commit 79d030a

File tree

2 files changed

+43
-6
lines changed

2 files changed

+43
-6
lines changed

‎test/e2e/clusterclass_changes.go‎

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -272,16 +272,17 @@ func ClusterClassChangesSpec(ctx context.Context, inputGetter func() ClusterClas
272272
WaitForMachinePools: input.E2EConfig.GetIntervals(specName, "wait-machine-pool-nodes"),
273273
})
274274

275-
Byf("Verify Cluster Available condition is true")
276-
framework.VerifyClusterAvailable(ctx, framework.VerifyClusterAvailableInput{
277-
Getter: input.BootstrapClusterProxy.GetClient(),
275+
Byf("Wait for all Machine Ready conditions are true")
276+
framework.WaitForMachinesReady(ctx, framework.WaitForMachinesReadyInput{
277+
Lister: input.BootstrapClusterProxy.GetClient(),
278278
Name: clusterResources.Cluster.Name,
279279
Namespace: clusterResources.Cluster.Namespace,
280+
Intervals: input.E2EConfig.GetIntervals(specName, "wait-machine-upgrade"),
280281
})
281282

282-
Byf("Verify Machines Ready condition is true")
283-
framework.VerifyMachinesReady(ctx, framework.VerifyMachinesReadyInput{
284-
Lister: input.BootstrapClusterProxy.GetClient(),
283+
Byf("Verify Cluster Available condition is true")
284+
framework.VerifyClusterAvailable(ctx, framework.VerifyClusterAvailableInput{
285+
Getter: input.BootstrapClusterProxy.GetClient(),
285286
Name: clusterResources.Cluster.Name,
286287
Namespace: clusterResources.Cluster.Namespace,
287288
})

‎test/framework/machines.go‎

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import (
2222
. "github.com/onsi/ginkgo/v2"
2323
. "github.com/onsi/gomega"
2424
corev1 "k8s.io/api/core/v1"
25+
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
2526
"k8s.io/klog/v2"
2627
"sigs.k8s.io/controller-runtime/pkg/client"
2728

@@ -93,3 +94,38 @@ func WaitForClusterMachinesReady(ctx context.Context, input WaitForClusterMachin
9394
return
9495
}, intervals...).Should(Equal(len(machines.Items)), "Timed out waiting for %d nodes to be ready", len(machines.Items))
9596
}
97+
98+
type WaitForMachinesReadyInput struct {
99+
Lister Lister
100+
Name string
101+
Namespace string
102+
Intervals []interface{}
103+
}
104+
105+
func WaitForMachinesReady(ctx context.Context, input WaitForMachinesReadyInput, intervals ...interface{}) {
106+
By("Waiting for the machines' Ready condition to be true")
107+
machineList := &clusterv1.MachineList{}
108+
109+
// Wait for all machines to have Ready condition set to true.
110+
Eventually(func(g Gomega) {
111+
g.Expect(input.Lister.List(ctx, machineList, client.InNamespace(input.Namespace),
112+
client.MatchingLabels{
113+
clusterv1.ClusterNameLabel: input.Name,
114+
})).To(Succeed())
115+
116+
g.Expect(machineList.Items).ToNot(BeEmpty(), "No machines found for cluster %s", input.Name)
117+
118+
for _, machine := range machineList.Items {
119+
readyConditionFound := false
120+
for _, condition := range machine.Status.Conditions {
121+
if condition.Type == clusterv1.ReadyCondition {
122+
readyConditionFound = true
123+
g.Expect(condition.Status).To(Equal(metav1.ConditionTrue), "The Ready condition on Machine %q should be set to true; message: %s", machine.Name, condition.Message)
124+
g.Expect(condition.Message).To(BeEmpty(), "The Ready condition on Machine %q should have an empty message", machine.Name)
125+
break
126+
}
127+
}
128+
g.Expect(readyConditionFound).To(BeTrue(), "Machine %q should have a Ready condition", machine.Name)
129+
}
130+
}, intervals...).Should(Succeed(), "Failed to wait for Machines Ready condition for Cluster %s", klog.KRef(input.Namespace, input.Name))
131+
}

0 commit comments

Comments
 (0)