Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions test/e2e/clusterclass_changes.go
Original file line number Diff line number Diff line change
Expand Up @@ -272,16 +272,17 @@ func ClusterClassChangesSpec(ctx context.Context, inputGetter func() ClusterClas
WaitForMachinePools: input.E2EConfig.GetIntervals(specName, "wait-machine-pool-nodes"),
})

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

Byf("Verify Machines Ready condition is true")
framework.VerifyMachinesReady(ctx, framework.VerifyMachinesReadyInput{
Lister: input.BootstrapClusterProxy.GetClient(),
Byf("Verify Cluster Available condition is true")
framework.VerifyClusterAvailable(ctx, framework.VerifyClusterAvailableInput{
Getter: input.BootstrapClusterProxy.GetClient(),
Name: clusterResources.Cluster.Name,
Namespace: clusterResources.Cluster.Namespace,
})
Expand Down
36 changes: 36 additions & 0 deletions test/framework/machines.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import (
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/klog/v2"
"sigs.k8s.io/controller-runtime/pkg/client"

Expand Down Expand Up @@ -93,3 +94,38 @@ func WaitForClusterMachinesReady(ctx context.Context, input WaitForClusterMachin
return
}, intervals...).Should(Equal(len(machines.Items)), "Timed out waiting for %d nodes to be ready", len(machines.Items))
}

type WaitForMachinesReadyInput struct {
Lister Lister
Name string
Namespace string
Intervals []interface{}
}

func WaitForMachinesReady(ctx context.Context, input WaitForMachinesReadyInput, intervals ...interface{}) {
By("Waiting for the machines' Ready condition to be true")
machineList := &clusterv1.MachineList{}

// Wait for all machines to have Ready condition set to true.
Eventually(func(g Gomega) {
g.Expect(input.Lister.List(ctx, machineList, client.InNamespace(input.Namespace),
client.MatchingLabels{
clusterv1.ClusterNameLabel: input.Name,
})).To(Succeed())

g.Expect(machineList.Items).ToNot(BeEmpty(), "No machines found for cluster %s", input.Name)

for _, machine := range machineList.Items {
readyConditionFound := false
for _, condition := range machine.Status.Conditions {
if condition.Type == clusterv1.ReadyCondition {
readyConditionFound = true
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)
g.Expect(condition.Message).To(BeEmpty(), "The Ready condition on Machine %q should have an empty message", machine.Name)
break
}
}
g.Expect(readyConditionFound).To(BeTrue(), "Machine %q should have a Ready condition", machine.Name)
}
}, intervals...).Should(Succeed(), "Failed to wait for Machines Ready condition for Cluster %s", klog.KRef(input.Namespace, input.Name))
}