Skip to content

Commit e9d395f

Browse files
authored
Merge pull request #12111 from sivchari/validate-conditions-v1beta2
🌱 add checker to validate conditions for v1beta2
2 parents d467f95 + 12432c0 commit e9d395f

18 files changed

+301
-50
lines changed

test/e2e/autoscaler.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -367,6 +367,20 @@ func AutoscalerSpec(ctx context.Context, inputGetter func() AutoscalerSpecInput)
367367
})
368368
}
369369

370+
Byf("Verify Cluster Available condition is true")
371+
framework.VerifyClusterAvailable(ctx, framework.VerifyClusterAvailableInput{
372+
Getter: input.BootstrapClusterProxy.GetClient(),
373+
Name: clusterResources.Cluster.Name,
374+
Namespace: clusterResources.Cluster.Namespace,
375+
})
376+
377+
Byf("Verify Machines Ready condition is true")
378+
framework.VerifyMachinesReady(ctx, framework.VerifyMachinesReadyInput{
379+
Lister: input.BootstrapClusterProxy.GetClient(),
380+
Name: clusterResources.Cluster.Name,
381+
Namespace: clusterResources.Cluster.Namespace,
382+
})
383+
370384
By("PASSED!")
371385
})
372386

test/e2e/cluster_deletion.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,20 @@ func ClusterDeletionSpec(ctx context.Context, inputGetter func() ClusterDeletion
198198
},
199199
}, clusterResources)
200200

201+
Byf("Verify Cluster Available condition is true")
202+
framework.VerifyClusterAvailable(ctx, framework.VerifyClusterAvailableInput{
203+
Getter: input.BootstrapClusterProxy.GetClient(),
204+
Name: clusterResources.Cluster.Name,
205+
Namespace: clusterResources.Cluster.Namespace,
206+
})
207+
208+
Byf("Verify Machines Ready condition is true")
209+
framework.VerifyMachinesReady(ctx, framework.VerifyMachinesReadyInput{
210+
Lister: input.BootstrapClusterProxy.GetClient(),
211+
Name: clusterResources.Cluster.Name,
212+
Namespace: clusterResources.Cluster.Namespace,
213+
})
214+
201215
// Get all objects per deletion phase and the list of blocking objects.
202216
var objectsPerPhase [][]client.Object
203217
objectsPerPhase, blockingObjects = getDeletionPhaseObjects(ctx, input.BootstrapClusterProxy, clusterResources.Cluster, input.ClusterDeletionPhases)

test/e2e/cluster_upgrade.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -259,6 +259,20 @@ func ClusterUpgradeConformanceSpec(ctx context.Context, inputGetter func() Clust
259259
WaitForNodesReady: input.E2EConfig.GetIntervals(specName, "wait-nodes-ready"),
260260
})
261261

262+
Byf("Verify Cluster Available condition is true")
263+
framework.VerifyClusterAvailable(ctx, framework.VerifyClusterAvailableInput{
264+
Getter: input.BootstrapClusterProxy.GetClient(),
265+
Name: clusterResources.Cluster.Name,
266+
Namespace: clusterResources.Cluster.Namespace,
267+
})
268+
269+
Byf("Verify Machines Ready condition is true")
270+
framework.VerifyMachinesReady(ctx, framework.VerifyMachinesReadyInput{
271+
Lister: input.BootstrapClusterProxy.GetClient(),
272+
Name: clusterResources.Cluster.Name,
273+
Namespace: clusterResources.Cluster.Namespace,
274+
})
275+
262276
if !input.SkipConformanceTests {
263277
By("Running conformance tests")
264278
// Start running the conformance test suite.

test/e2e/cluster_upgrade_runtimesdk.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -347,6 +347,20 @@ func ClusterUpgradeWithRuntimeSDKSpec(ctx context.Context, inputGetter func() Cl
347347
"AfterClusterUpgrade": "Success",
348348
})).To(Succeed(), "Lifecycle hook calls were not as expected")
349349

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+
350364
By("PASSED!")
351365
})
352366

test/e2e/clusterclass_changes.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -272,6 +272,20 @@ 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(),
278+
Name: clusterResources.Cluster.Name,
279+
Namespace: clusterResources.Cluster.Namespace,
280+
})
281+
282+
Byf("Verify Machines Ready condition is true")
283+
framework.VerifyMachinesReady(ctx, framework.VerifyMachinesReadyInput{
284+
Lister: input.BootstrapClusterProxy.GetClient(),
285+
Name: clusterResources.Cluster.Name,
286+
Namespace: clusterResources.Cluster.Namespace,
287+
})
288+
275289
By("Deleting a MachineDeploymentTopology in the Cluster Topology and wait for associated MachineDeployment to be deleted")
276290
deleteMachineDeploymentTopologyAndWait(ctx, deleteMachineDeploymentTopologyAndWaitInput{
277291
ClusterProxy: input.BootstrapClusterProxy,

test/e2e/clusterclass_rollout.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -302,6 +302,20 @@ func ClusterClassRolloutSpec(ctx context.Context, inputGetter func() ClusterClas
302302
}, input.E2EConfig.GetIntervals(specName, "wait-machine-upgrade")...).Should(Succeed())
303303
assertClusterObjects(ctx, input.BootstrapClusterProxy, clusterResources.Cluster, clusterResources.ClusterClass, input.FilterMetadataBeforeValidation)
304304

305+
Byf("Verify Cluster Available condition is true")
306+
framework.VerifyClusterAvailable(ctx, framework.VerifyClusterAvailableInput{
307+
Getter: input.BootstrapClusterProxy.GetClient(),
308+
Name: clusterResources.Cluster.Name,
309+
Namespace: clusterResources.Cluster.Namespace,
310+
})
311+
312+
Byf("Verify Machines Ready condition is true")
313+
framework.VerifyMachinesReady(ctx, framework.VerifyMachinesReadyInput{
314+
Lister: input.BootstrapClusterProxy.GetClient(),
315+
Name: clusterResources.Cluster.Name,
316+
Namespace: clusterResources.Cluster.Namespace,
317+
})
318+
305319
By("PASSED!")
306320
})
307321

test/e2e/clusterctl_upgrade.go

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

726-
Byf("[%d] Verify v1beta2 Available and Ready conditions (if exist) to be true for Cluster and Machines", i)
727-
verifyV1Beta2ConditionsTrueV1Beta1(ctx, managementClusterProxy.GetClient(), workloadCluster.Name, workloadCluster.Namespace,
728-
[]string{clusterv1.AvailableCondition, clusterv1.ReadyCondition})
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+
})
729739

730740
// If this is the last step of the upgrade sequence check hat the resourceVersions are stable, i.e. it verifies there are no
731741
// continuous reconciles when everything should be stable.
@@ -809,53 +819,6 @@ func ClusterctlUpgradeSpec(ctx context.Context, inputGetter func() ClusterctlUpg
809819
})
810820
}
811821

812-
// verifyV1Beta2ConditionsTrueV1Beta1 checks the Cluster and Machines of a Cluster that
813-
// the given v1beta2 condition types are set to true without a message, if they exist.
814-
func verifyV1Beta2ConditionsTrueV1Beta1(ctx context.Context, c client.Client, clusterName, clusterNamespace string, v1beta2conditionTypes []string) {
815-
cluster := &clusterv1beta1.Cluster{}
816-
key := client.ObjectKey{
817-
Namespace: clusterNamespace,
818-
Name: clusterName,
819-
}
820-
Eventually(func() error {
821-
return c.Get(ctx, key, cluster)
822-
}, 3*time.Minute, 3*time.Second).Should(Succeed(), "Failed to get Cluster object %s", klog.KRef(clusterNamespace, clusterName))
823-
824-
if cluster.Status.V1Beta2 != nil && len(cluster.Status.V1Beta2.Conditions) > 0 {
825-
for _, conditionType := range v1beta2conditionTypes {
826-
for _, condition := range cluster.Status.V1Beta2.Conditions {
827-
if condition.Type != conditionType {
828-
continue
829-
}
830-
Expect(condition.Status).To(Equal(metav1.ConditionTrue), "The v1beta2 condition %q on the Cluster should be set to true", conditionType)
831-
Expect(condition.Message).To(BeEmpty(), "The v1beta2 condition %q on the Cluster should have an empty message", conditionType)
832-
}
833-
}
834-
}
835-
836-
machineList := &clusterv1beta1.MachineList{}
837-
Eventually(func() error {
838-
return c.List(ctx, machineList, client.InNamespace(clusterNamespace),
839-
client.MatchingLabels{
840-
clusterv1.ClusterNameLabel: clusterName,
841-
})
842-
}, 3*time.Minute, 3*time.Second).Should(Succeed(), "Failed to list Machines for Cluster %s", klog.KObj(cluster))
843-
for _, machine := range machineList.Items {
844-
if machine.Status.V1Beta2 == nil || len(machine.Status.V1Beta2.Conditions) == 0 {
845-
continue
846-
}
847-
for _, conditionType := range v1beta2conditionTypes {
848-
for _, condition := range machine.Status.V1Beta2.Conditions {
849-
if condition.Type != conditionType {
850-
continue
851-
}
852-
Expect(condition.Status).To(Equal(metav1.ConditionTrue), "The v1beta2 condition %q on the Machine %q should be set to true", conditionType, machine.Name)
853-
Expect(condition.Message).To(BeEmpty(), "The v1beta2 condition %q on the Machine %q should have an empty message", conditionType, machine.Name)
854-
}
855-
}
856-
}
857-
}
858-
859822
func setupClusterctl(ctx context.Context, clusterctlBinaryURL, clusterctlConfigPath string) (string, string) {
860823
clusterctlBinaryPath := downloadToTmpFile(ctx, clusterctlBinaryURL)
861824

test/e2e/k8s_conformance.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,20 @@ func K8SConformanceSpec(ctx context.Context, inputGetter func() K8SConformanceSp
153153
)
154154
Expect(err).ToNot(HaveOccurred(), "Failed to run Kubernetes conformance")
155155

156+
Byf("Verify Cluster Available condition is true")
157+
framework.VerifyClusterAvailable(ctx, framework.VerifyClusterAvailableInput{
158+
Getter: input.BootstrapClusterProxy.GetClient(),
159+
Name: clusterResources.Cluster.Name,
160+
Namespace: clusterResources.Cluster.Namespace,
161+
})
162+
163+
Byf("Verify Machines Ready condition is true")
164+
framework.VerifyMachinesReady(ctx, framework.VerifyMachinesReadyInput{
165+
Lister: input.BootstrapClusterProxy.GetClient(),
166+
Name: clusterResources.Cluster.Name,
167+
Namespace: clusterResources.Cluster.Namespace,
168+
})
169+
156170
By("PASSED!")
157171
})
158172

test/e2e/kcp_adoption.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,20 @@ func KCPAdoptionSpec(ctx context.Context, inputGetter func() KCPAdoptionSpecInpu
247247
}
248248
Expect(secrets.Items).To(HaveLen(4 /* pki */ + 1 /* kubeconfig */ + int(*replicas)))
249249

250+
Byf("Verify Cluster Available condition is true")
251+
framework.VerifyClusterAvailable(ctx, framework.VerifyClusterAvailableInput{
252+
Getter: input.BootstrapClusterProxy.GetClient(),
253+
Name: cluster.Name,
254+
Namespace: cluster.Namespace,
255+
})
256+
257+
Byf("Verify Machines Ready condition is true")
258+
framework.VerifyMachinesReady(ctx, framework.VerifyMachinesReadyInput{
259+
Lister: input.BootstrapClusterProxy.GetClient(),
260+
Name: cluster.Name,
261+
Namespace: cluster.Namespace,
262+
})
263+
250264
By("PASSED!")
251265
})
252266

test/e2e/kcp_remediations.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -413,6 +413,20 @@ func KCPRemediationSpec(ctx context.Context, inputGetter func() KCPRemediationSp
413413

414414
By("CP BACK TO FULL OPERATIONAL STATE!")
415415

416+
Byf("Verify Cluster Available condition is true")
417+
framework.VerifyClusterAvailable(ctx, framework.VerifyClusterAvailableInput{
418+
Getter: input.BootstrapClusterProxy.GetClient(),
419+
Name: clusterResources.Cluster.Name,
420+
Namespace: clusterResources.Cluster.Namespace,
421+
})
422+
423+
Byf("Verify Machines Ready condition is true")
424+
framework.VerifyMachinesReady(ctx, framework.VerifyMachinesReadyInput{
425+
Lister: input.BootstrapClusterProxy.GetClient(),
426+
Name: clusterResources.Cluster.Name,
427+
Namespace: clusterResources.Cluster.Namespace,
428+
})
429+
416430
By("PASSED!")
417431
})
418432

0 commit comments

Comments
 (0)