Skip to content

Commit a53efca

Browse files
committed
test: prevent using Consistently for rollout checks
1 parent ab7bac8 commit a53efca

File tree

2 files changed

+34
-19
lines changed

2 files changed

+34
-19
lines changed

test/e2e/clusterctl_upgrade.go

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -612,43 +612,42 @@ func ClusterctlUpgradeSpec(ctx context.Context, inputGetter func() ClusterctlUpg
612612
input.PostUpgrade(managementClusterProxy, workloadClusterNamespace, managementClusterName)
613613
}
614614

615-
// After the upgrade check that MachineList is available. This ensures the APIServer is serving without
616-
// error before checking that it `Consistently` returns the MachineList later on.
617-
Byf("[%d] Waiting for MachineList to be available", i)
615+
// After the upgrade: wait for MachineList to be available after the upgrade.
618616
Eventually(func() error {
619617
postUpgradeMachineList := &unstructured.UnstructuredList{}
620618
postUpgradeMachineList.SetGroupVersionKind(schema.GroupVersionKind{
621619
Group: clusterv1.GroupVersion.Group,
622620
Version: coreCAPIStorageVersion,
623621
Kind: "MachineList",
624622
})
625-
err = managementClusterProxy.GetClient().List(
623+
return managementClusterProxy.GetClient().List(
626624
ctx,
627625
postUpgradeMachineList,
628626
client.InNamespace(workloadCluster.GetNamespace()),
629627
client.MatchingLabels{clusterv1.ClusterNameLabel: workloadCluster.GetName()},
630628
)
631-
return err
632629
}, "3m", "30s").ShouldNot(HaveOccurred(), "MachineList should be available after the upgrade")
633630

634-
// After the upgrade check that there were no unexpected rollouts.
635-
Byf("[%d] Verify there are no unexpected rollouts", i)
636-
Consistently(func() bool {
637-
postUpgradeMachineList := &unstructured.UnstructuredList{}
631+
Byf("[%d] Waiting for three minutes before checking if an unexpected rollout happened", i)
632+
time.Sleep(time.Minute * 3)
633+
634+
// After the upgrade: check that there were no unexpected rollouts.
635+
postUpgradeMachineList := &unstructured.UnstructuredList{}
636+
Byf("[%d] Verifing there are no unexpected rollouts", i)
637+
Eventually(func() error {
638638
postUpgradeMachineList.SetGroupVersionKind(schema.GroupVersionKind{
639639
Group: clusterv1.GroupVersion.Group,
640640
Version: coreCAPIStorageVersion,
641641
Kind: "MachineList",
642642
})
643-
err = managementClusterProxy.GetClient().List(
643+
return managementClusterProxy.GetClient().List(
644644
ctx,
645645
postUpgradeMachineList,
646646
client.InNamespace(workloadCluster.GetNamespace()),
647647
client.MatchingLabels{clusterv1.ClusterNameLabel: workloadCluster.GetName()},
648648
)
649-
Expect(err).ToNot(HaveOccurred())
650-
return validateMachineRollout(preUpgradeMachineList, postUpgradeMachineList)
651-
}, "3m", "30s").Should(BeTrue(), "Machines should remain the same after the upgrade")
649+
}, "3m", "30s").ShouldNot(HaveOccurred(), "MachineList should be available after the upgrade")
650+
Expect(validateMachineRollout(preUpgradeMachineList, postUpgradeMachineList)).To(BeTrue(), "Machines should remain the same after the upgrade")
652651

653652
// Scale up to 2 and back down to 1 so we can repeat this multiple times.
654653
Byf("[%d] Scale MachineDeployment to ensure the providers work", i)

test/e2e/self_hosted.go

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import (
2222
"os"
2323
"path/filepath"
2424
"strings"
25+
"time"
2526

2627
. "github.com/onsi/ginkgo/v2"
2728
. "github.com/onsi/gomega"
@@ -296,20 +297,35 @@ func SelfHostedSpec(ctx context.Context, inputGetter func() SelfHostedSpecInput)
296297
})
297298
Expect(controlPlane).ToNot(BeNil())
298299

299-
// After the move check that there were no unexpected rollouts.
300+
// After the move: wait for MachineList to be available after the upgrade.
300301
log.Logf("Verify there are no unexpected rollouts")
301-
Consistently(func() bool {
302+
Eventually(func() error {
302303
postMoveMachineList := &unstructured.UnstructuredList{}
303304
postMoveMachineList.SetGroupVersionKind(clusterv1.GroupVersion.WithKind("MachineList"))
304-
err = selfHostedClusterProxy.GetClient().List(
305+
return selfHostedClusterProxy.GetClient().List(
305306
ctx,
306307
postMoveMachineList,
307308
client.InNamespace(namespace.Name),
308309
client.MatchingLabels{clusterv1.ClusterNameLabel: workloadClusterName},
309310
)
310-
Expect(err).NotTo(HaveOccurred(), "Failed to list machines after move")
311-
return validateMachineRollout(preMoveMachineList, postMoveMachineList)
312-
}, "3m", "30s").Should(BeTrue(), "Machines should not roll out after move to self-hosted cluster")
311+
}, "3m", "30s").ShouldNot(HaveOccurred(), "MachineList should be available after move to self-hosted cluster")
312+
313+
log.Logf("Waiting for three minutes before checking if an unexpected rollout happened")
314+
time.Sleep(time.Minute * 3)
315+
316+
// After the move: check that there were no unexpected rollouts.
317+
postMoveMachineList := &unstructured.UnstructuredList{}
318+
log.Logf("Verify there are no unexpected rollouts")
319+
Eventually(func() error {
320+
postMoveMachineList.SetGroupVersionKind(clusterv1.GroupVersion.WithKind("MachineList"))
321+
return selfHostedClusterProxy.GetClient().List(
322+
ctx,
323+
postMoveMachineList,
324+
client.InNamespace(namespace.Name),
325+
client.MatchingLabels{clusterv1.ClusterNameLabel: workloadClusterName},
326+
)
327+
}, "3m", "30s").ShouldNot(HaveOccurred(), "MachineList should be available after move to self-hosted cluster")
328+
Expect(validateMachineRollout(preMoveMachineList, postMoveMachineList)).To(BeTrue(), "Machines should not roll out after move to self-hosted cluster")
313329

314330
if input.SkipUpgrade {
315331
// Only do upgrade step if defined by test input.

0 commit comments

Comments
 (0)