From 882933e363ff779a7d3684ead57fa0d83715d241 Mon Sep 17 00:00:00 2001 From: muhammad adil ghaffar Date: Mon, 18 Mar 2024 05:44:30 +0200 Subject: [PATCH] Add wait for MachineList to be available Signed-off-by: muhammad adil ghaffar --- test/e2e/clusterctl_upgrade.go | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/test/e2e/clusterctl_upgrade.go b/test/e2e/clusterctl_upgrade.go index af5c4828a44c..ca3dfbdd3943 100644 --- a/test/e2e/clusterctl_upgrade.go +++ b/test/e2e/clusterctl_upgrade.go @@ -548,6 +548,25 @@ func ClusterctlUpgradeSpec(ctx context.Context, inputGetter func() ClusterctlUpg input.PostUpgrade(managementClusterProxy, workloadClusterNamespace, managementClusterName) } + // After the upgrade check that MachineList is available. This ensures the APIServer is serving without + // error before checking that it `Consistently` returns the MachineList later on. + Byf("[%d] Waiting for MachineList to be available", i) + Eventually(func() error { + postUpgradeMachineList := &unstructured.UnstructuredList{} + postUpgradeMachineList.SetGroupVersionKind(schema.GroupVersionKind{ + Group: clusterv1.GroupVersion.Group, + Version: coreCAPIStorageVersion, + Kind: "MachineList", + }) + err = managementClusterProxy.GetClient().List( + ctx, + postUpgradeMachineList, + client.InNamespace(workloadCluster.GetNamespace()), + client.MatchingLabels{clusterv1.ClusterNameLabel: workloadCluster.GetName()}, + ) + return err + }, "3m", "30s").ShouldNot(HaveOccurred(), "MachineList should be available after the upgrade") + // After the upgrade check that there were no unexpected rollouts. Byf("[%d] Verify there are no unexpected rollouts", i) Consistently(func() bool {