Skip to content

Commit a61c0a9

Browse files
🐛 Fix Available/Ready checks on E2E test (#12549)
* Fix runtime-sdk E2E test * More fix * Fix log message
1 parent 5f657cf commit a61c0a9

File tree

4 files changed

+49
-33
lines changed

4 files changed

+49
-33
lines changed

test/e2e/cluster_upgrade_runtimesdk.go

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -331,6 +331,20 @@ func ClusterUpgradeWithRuntimeSDKSpec(ctx context.Context, inputGetter func() Cl
331331
input.PostUpgrade(input.BootstrapClusterProxy, namespace.Name, clusterResources.Cluster.Name)
332332
}
333333

334+
Byf("Verify Cluster Available condition is true")
335+
framework.VerifyClusterAvailable(ctx, framework.VerifyClusterAvailableInput{
336+
Getter: input.BootstrapClusterProxy.GetClient(),
337+
Name: clusterResources.Cluster.Name,
338+
Namespace: clusterResources.Cluster.Namespace,
339+
})
340+
341+
Byf("Verify Machines Ready condition is true")
342+
framework.VerifyMachinesReady(ctx, framework.VerifyMachinesReadyInput{
343+
Lister: input.BootstrapClusterProxy.GetClient(),
344+
Name: clusterResources.Cluster.Name,
345+
Namespace: clusterResources.Cluster.Namespace,
346+
})
347+
334348
By("Dumping resources and deleting the workload cluster; deletion waits for BeforeClusterDeleteHook to gate the operation")
335349
dumpAndDeleteCluster(ctx, input.BootstrapClusterProxy, input.ClusterctlConfigPath, namespace.Name, clusterName, input.ArtifactFolder)
336350

@@ -347,20 +361,6 @@ func ClusterUpgradeWithRuntimeSDKSpec(ctx context.Context, inputGetter func() Cl
347361
"AfterClusterUpgrade": "Success",
348362
})).To(Succeed(), "Lifecycle hook calls were not as expected")
349363

350-
Byf("Verify Cluster Available condition is true")
351-
framework.VerifyClusterAvailable(ctx, framework.VerifyClusterAvailableInput{
352-
Getter: input.BootstrapClusterProxy.GetClient(),
353-
Name: clusterResources.Cluster.Name,
354-
Namespace: clusterResources.Cluster.Namespace,
355-
})
356-
357-
Byf("Verify Machines Ready condition is true")
358-
framework.VerifyMachinesReady(ctx, framework.VerifyMachinesReadyInput{
359-
Lister: input.BootstrapClusterProxy.GetClient(),
360-
Name: clusterResources.Cluster.Name,
361-
Namespace: clusterResources.Cluster.Namespace,
362-
})
363-
364364
By("PASSED!")
365365
})
366366

test/e2e/clusterctl_upgrade.go

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -723,25 +723,27 @@ func ClusterctlUpgradeSpec(ctx context.Context, inputGetter func() ClusterctlUpg
723723
upgrade.PostUpgrade(managementClusterProxy, workloadCluster.Namespace, workloadCluster.Name)
724724
}
725725

726-
Byf("[%d] Verify Cluster Available condition is true", i)
727-
framework.VerifyClusterAvailable(ctx, framework.VerifyClusterAvailableInput{
728-
Getter: managementClusterProxy.GetClient(),
729-
Name: workloadCluster.Name,
730-
Namespace: workloadCluster.Namespace,
731-
})
732-
733-
Byf("[%d] Verify Machines Ready condition is true", i)
734-
framework.VerifyMachinesReady(ctx, framework.VerifyMachinesReadyInput{
735-
Lister: managementClusterProxy.GetClient(),
736-
Name: workloadCluster.Name,
737-
Namespace: workloadCluster.Namespace,
738-
})
739-
740726
// If this is the last step of the upgrade sequence check hat the resourceVersions are stable, i.e. it verifies there are no
741727
// continuous reconciles when everything should be stable.
742728
if i == len(input.Upgrades)-1 {
743-
By("Checking that resourceVersions are stable")
729+
Byf("[%d] Checking that resourceVersions are stable", i)
744730
framework.ValidateResourceVersionStable(ctx, managementClusterProxy, workloadCluster.Namespace, clusterctlcluster.FilterClusterObjectsWithNameFilter(workloadCluster.Name))
731+
732+
// NOTE: Checks on conditions works on v1beta2 only, so running this checks only in the last step which is
733+
// always current version.
734+
Byf("[%d] Verify Cluster Available condition is true", i)
735+
framework.VerifyClusterAvailable(ctx, framework.VerifyClusterAvailableInput{
736+
Getter: managementClusterProxy.GetClient(),
737+
Name: workloadCluster.Name,
738+
Namespace: workloadCluster.Namespace,
739+
})
740+
741+
Byf("[%d] Verify Machines Ready condition is true", i)
742+
framework.VerifyMachinesReady(ctx, framework.VerifyMachinesReadyInput{
743+
Lister: managementClusterProxy.GetClient(),
744+
Name: workloadCluster.Name,
745+
Namespace: workloadCluster.Namespace,
746+
})
745747
}
746748

747749
// Note: It is a known issue on Kubernetes < v1.29 that SSA sometimes fail:

test/e2e/self_hosted.go

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -334,6 +334,20 @@ func SelfHostedSpec(ctx context.Context, inputGetter func() SelfHostedSpecInput)
334334
}, "3m", "30s").ShouldNot(HaveOccurred(), "MachineList should be available after move to self-hosted cluster")
335335
Expect(validateMachineRollout(preMoveMachineList, postMoveMachineList)).To(BeTrue(), "Machines should not roll out after move to self-hosted cluster")
336336

337+
Byf("Verify Cluster Available condition is true")
338+
framework.VerifyClusterAvailable(ctx, framework.VerifyClusterAvailableInput{
339+
Getter: selfHostedClusterProxy.GetClient(),
340+
Name: clusterResources.Cluster.Name,
341+
Namespace: clusterResources.Cluster.Namespace,
342+
})
343+
344+
Byf("Verify Machines Ready condition is true")
345+
framework.VerifyMachinesReady(ctx, framework.VerifyMachinesReadyInput{
346+
Lister: selfHostedClusterProxy.GetClient(),
347+
Name: clusterResources.Cluster.Name,
348+
Namespace: clusterResources.Cluster.Namespace,
349+
})
350+
337351
if input.SkipUpgrade {
338352
// Only do upgrade step if defined by test input.
339353
return
@@ -431,14 +445,14 @@ func SelfHostedSpec(ctx context.Context, inputGetter func() SelfHostedSpecInput)
431445

432446
Byf("Verify Cluster Available condition is true")
433447
framework.VerifyClusterAvailable(ctx, framework.VerifyClusterAvailableInput{
434-
Getter: input.BootstrapClusterProxy.GetClient(),
448+
Getter: selfHostedClusterProxy.GetClient(),
435449
Name: clusterResources.Cluster.Name,
436450
Namespace: clusterResources.Cluster.Namespace,
437451
})
438452

439453
Byf("Verify Machines Ready condition is true")
440454
framework.VerifyMachinesReady(ctx, framework.VerifyMachinesReadyInput{
441-
Lister: input.BootstrapClusterProxy.GetClient(),
455+
Lister: selfHostedClusterProxy.GetClient(),
442456
Name: clusterResources.Cluster.Name,
443457
Namespace: clusterResources.Cluster.Namespace,
444458
})

test/framework/cluster_helpers.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -452,7 +452,7 @@ func VerifyClusterAvailable(ctx context.Context, input VerifyClusterAvailableInp
452452
g.Expect(input.Getter.Get(ctx, key, cluster)).To(Succeed())
453453
for _, condition := range cluster.Status.Conditions {
454454
if condition.Type == clusterv1.AvailableCondition {
455-
g.Expect(condition.Status).To(Equal(metav1.ConditionTrue), "The Available condition on the Cluster should be set to true")
455+
g.Expect(condition.Status).To(Equal(metav1.ConditionTrue), "The Available condition on the Cluster should be set to true; message: %s", condition.Message)
456456
g.Expect(condition.Message).To(BeEmpty(), "The Available condition on the Cluster should have an empty message")
457457
return
458458
}
@@ -484,7 +484,7 @@ func VerifyMachinesReady(ctx context.Context, input VerifyMachinesReadyInput) {
484484
for _, condition := range machine.Status.Conditions {
485485
if condition.Type == clusterv1.ReadyCondition {
486486
readyConditionFound = true
487-
g.Expect(condition.Status).To(Equal(metav1.ConditionTrue), "The Ready condition on Machine %q should be set to true", machine.Name)
487+
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)
488488
g.Expect(condition.Message).To(BeEmpty(), "The Ready condition on Machine %q should have an empty message", machine.Name)
489489
break
490490
}

0 commit comments

Comments
 (0)