Skip to content

Commit 58ff884

Browse files
committed
apply v1beta2 validation to e2e tests
Signed-off-by: sivchari <[email protected]>
1 parent 0e6ef5a commit 58ff884

17 files changed

+108
-51
lines changed

test/e2e/autoscaler.go

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

370+
Byf("Verify v1beta2 Available and Ready conditions (if exist) to be true for Cluster and Machines")
371+
verifyV1Beta2Conditions(ctx, input.BootstrapClusterProxy.GetClient(), clusterResources.Cluster.Name, clusterResources.Cluster.Namespace,
372+
map[string]struct{}{
373+
clusterv1.AvailableCondition: {}, clusterv1.ReadyCondition: {},
374+
})
375+
370376
By("PASSED!")
371377
})
372378

test/e2e/cluster_deletion.go

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

201+
Byf("Verify v1beta2 Available and Ready conditions (if exist) to be true for Cluster and Machines")
202+
verifyV1Beta2Conditions(ctx, input.BootstrapClusterProxy.GetClient(), clusterResources.Cluster.Name, clusterResources.Cluster.Namespace,
203+
map[string]struct{}{
204+
clusterv1.AvailableCondition: {}, clusterv1.ReadyCondition: {},
205+
})
206+
201207
// Get all objects per deletion phase and the list of blocking objects.
202208
var objectsPerPhase [][]client.Object
203209
objectsPerPhase, blockingObjects = getDeletionPhaseObjects(ctx, input.BootstrapClusterProxy, clusterResources.Cluster, input.ClusterDeletionPhases)

test/e2e/cluster_upgrade.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ import (
2727
corev1 "k8s.io/api/core/v1"
2828
"k8s.io/utils/ptr"
2929

30+
clusterv1 "sigs.k8s.io/cluster-api/api/v1beta2"
3031
"sigs.k8s.io/cluster-api/test/framework"
3132
"sigs.k8s.io/cluster-api/test/framework/clusterctl"
3233
"sigs.k8s.io/cluster-api/test/framework/kubetest"
@@ -259,6 +260,12 @@ func ClusterUpgradeConformanceSpec(ctx context.Context, inputGetter func() Clust
259260
WaitForNodesReady: input.E2EConfig.GetIntervals(specName, "wait-nodes-ready"),
260261
})
261262

263+
Byf("Verify v1beta2 Available and Ready conditions (if exist) to be true for Cluster and Machines")
264+
verifyV1Beta2Conditions(ctx, input.BootstrapClusterProxy.GetClient(), clusterResources.Cluster.Name, clusterResources.Cluster.Namespace,
265+
map[string]struct{}{
266+
clusterv1.AvailableCondition: {}, clusterv1.ReadyCondition: {},
267+
})
268+
262269
if !input.SkipConformanceTests {
263270
By("Running conformance tests")
264271
// Start running the conformance test suite.

test/e2e/cluster_upgrade_runtimesdk.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -347,6 +347,12 @@ 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 v1beta2 Available and Ready conditions (if exist) to be true for Cluster and Machines")
351+
verifyV1Beta2Conditions(ctx, input.BootstrapClusterProxy.GetClient(), clusterResources.Cluster.Name, clusterResources.Cluster.Namespace,
352+
map[string]struct{}{
353+
clusterv1.AvailableCondition: {}, clusterv1.ReadyCondition: {},
354+
})
355+
350356
By("PASSED!")
351357
})
352358

test/e2e/clusterclass_changes.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -271,6 +271,12 @@ func ClusterClassChangesSpec(ctx context.Context, inputGetter func() ClusterClas
271271
WaitForMachinePools: input.E2EConfig.GetIntervals(specName, "wait-machine-pool-nodes"),
272272
})
273273

274+
Byf("Verify v1beta2 Available and Ready conditions (if exist) to be true for Cluster and Machines")
275+
verifyV1Beta2Conditions(ctx, input.BootstrapClusterProxy.GetClient(), clusterResources.Cluster.Name, clusterResources.Cluster.Namespace,
276+
map[string]struct{}{
277+
clusterv1.AvailableCondition: {}, clusterv1.ReadyCondition: {},
278+
})
279+
274280
By("Deleting a MachineDeploymentTopology in the Cluster Topology and wait for associated MachineDeployment to be deleted")
275281
deleteMachineDeploymentTopologyAndWait(ctx, deleteMachineDeploymentTopologyAndWaitInput{
276282
ClusterProxy: input.BootstrapClusterProxy,

test/e2e/clusterclass_rollout.go

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

306+
Byf("Verify v1beta2 Available and Ready conditions (if exist) to be true for Cluster and Machines")
307+
verifyV1Beta2Conditions(ctx, input.BootstrapClusterProxy.GetClient(), clusterResources.Cluster.Name, clusterResources.Cluster.Namespace,
308+
map[string]struct{}{
309+
clusterv1.AvailableCondition: {}, clusterv1.ReadyCondition: {},
310+
})
311+
306312
By("PASSED!")
307313
})
308314

test/e2e/clusterctl_upgrade.go

Lines changed: 4 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -723,8 +723,10 @@ func ClusterctlUpgradeSpec(ctx context.Context, inputGetter func() ClusterctlUpg
723723
}
724724

725725
Byf("[%d] Verify v1beta2 Available and Ready conditions (if exist) to be true for Cluster and Machines", i)
726-
verifyV1Beta2ConditionsTrueV1Beta1(ctx, managementClusterProxy.GetClient(), workloadCluster.Name, workloadCluster.Namespace,
727-
[]string{clusterv1.AvailableCondition, clusterv1.ReadyCondition})
726+
verifyV1Beta2Conditions(ctx, managementClusterProxy.GetClient(), workloadCluster.Name, workloadCluster.Namespace,
727+
map[string]struct{}{
728+
clusterv1.AvailableCondition: {}, clusterv1.ReadyCondition: {},
729+
})
728730

729731
// Note: It is a known issue on Kubernetes < v1.29 that SSA sometimes fail:
730732
// https://github.com/kubernetes/kubernetes/issues/117356
@@ -801,55 +803,6 @@ func ClusterctlUpgradeSpec(ctx context.Context, inputGetter func() ClusterctlUpg
801803
})
802804
}
803805

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

test/e2e/k8s_conformance.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ import (
2828
corev1 "k8s.io/api/core/v1"
2929
"k8s.io/utils/ptr"
3030

31+
clusterv1 "sigs.k8s.io/cluster-api/api/v1beta2"
3132
"sigs.k8s.io/cluster-api/test/framework"
3233
"sigs.k8s.io/cluster-api/test/framework/clusterctl"
3334
"sigs.k8s.io/cluster-api/test/framework/kubetest"
@@ -153,6 +154,12 @@ func K8SConformanceSpec(ctx context.Context, inputGetter func() K8SConformanceSp
153154
)
154155
Expect(err).ToNot(HaveOccurred(), "Failed to run Kubernetes conformance")
155156

157+
Byf("Verify v1beta2 Available and Ready conditions (if exist) to be true for Cluster and Machines")
158+
verifyV1Beta2Conditions(ctx, input.BootstrapClusterProxy.GetClient(), clusterResources.Cluster.Name, clusterResources.Cluster.Namespace,
159+
map[string]struct{}{
160+
clusterv1.AvailableCondition: {}, clusterv1.ReadyCondition: {},
161+
})
162+
156163
By("PASSED!")
157164
})
158165

test/e2e/kcp_adoption.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,12 @@ 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 v1beta2 Available and Ready conditions (if exist) to be true for Cluster and Machines")
251+
verifyV1Beta2Conditions(ctx, input.BootstrapClusterProxy.GetClient(), cluster.Name, cluster.Namespace,
252+
map[string]struct{}{
253+
clusterv1.AvailableCondition: {}, clusterv1.ReadyCondition: {},
254+
})
255+
250256
By("PASSED!")
251257
})
252258

test/e2e/kcp_remediations.go

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

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

416+
Byf("Verify v1beta2 Available and Ready conditions (if exist) to be true for Cluster and Machines")
417+
verifyV1Beta2Conditions(ctx, input.BootstrapClusterProxy.GetClient(), clusterResources.Cluster.Name, clusterResources.Cluster.Namespace,
418+
map[string]struct{}{
419+
clusterv1.AvailableCondition: {}, clusterv1.ReadyCondition: {},
420+
})
421+
416422
By("PASSED!")
417423
})
418424

test/e2e/machine_pool.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ import (
3030
corev1 "k8s.io/api/core/v1"
3131
"k8s.io/utils/ptr"
3232

33+
clusterv1 "sigs.k8s.io/cluster-api/api/v1beta2"
3334
"sigs.k8s.io/cluster-api/test/framework"
3435
"sigs.k8s.io/cluster-api/test/framework/clusterctl"
3536
"sigs.k8s.io/cluster-api/util"
@@ -139,6 +140,12 @@ func MachinePoolSpec(ctx context.Context, inputGetter func() MachinePoolInput) {
139140
WaitForMachinePoolToScale: input.E2EConfig.GetIntervals(specName, "wait-machine-pool-nodes"),
140141
})
141142

143+
Byf("Verify v1beta2 Available and Ready conditions (if exist) to be true for Cluster and Machines")
144+
verifyV1Beta2Conditions(ctx, input.BootstrapClusterProxy.GetClient(), clusterResources.Cluster.Name, clusterResources.Cluster.Namespace,
145+
map[string]struct{}{
146+
clusterv1.AvailableCondition: {}, clusterv1.ReadyCondition: {},
147+
})
148+
142149
By("PASSED!")
143150
})
144151

test/e2e/md_remediations.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ import (
2727
corev1 "k8s.io/api/core/v1"
2828
"k8s.io/utils/ptr"
2929

30+
clusterv1 "sigs.k8s.io/cluster-api/api/v1beta2"
3031
"sigs.k8s.io/cluster-api/test/framework"
3132
"sigs.k8s.io/cluster-api/test/framework/clusterctl"
3233
"sigs.k8s.io/cluster-api/util"
@@ -120,6 +121,12 @@ func MachineDeploymentRemediationSpec(ctx context.Context, inputGetter func() Ma
120121
WaitForMachineRemediation: input.E2EConfig.GetIntervals(specName, "wait-machine-remediation"),
121122
})
122123

124+
Byf("Verify v1beta2 Available and Ready conditions (if exist) to be true for Cluster and Machines")
125+
verifyV1Beta2Conditions(ctx, input.BootstrapClusterProxy.GetClient(), clusterResources.Cluster.Name, clusterResources.Cluster.Namespace,
126+
map[string]struct{}{
127+
clusterv1.AvailableCondition: {}, clusterv1.ReadyCondition: {},
128+
})
129+
123130
By("PASSED!")
124131
})
125132

test/e2e/md_rollout.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ import (
2727
corev1 "k8s.io/api/core/v1"
2828
"k8s.io/utils/ptr"
2929

30+
clusterv1 "sigs.k8s.io/cluster-api/api/v1beta2"
3031
"sigs.k8s.io/cluster-api/test/framework"
3132
"sigs.k8s.io/cluster-api/test/framework/clusterctl"
3233
"sigs.k8s.io/cluster-api/util"
@@ -120,6 +121,13 @@ func MachineDeploymentRolloutSpec(ctx context.Context, inputGetter func() Machin
120121
WaitForMachinesToBeUpgraded: input.E2EConfig.GetIntervals(specName, "wait-machine-upgrade"),
121122
MachineDeployments: clusterResources.MachineDeployments,
122123
})
124+
125+
Byf("Verify v1beta2 Available and Ready conditions (if exist) to be true for Cluster and Machines")
126+
verifyV1Beta2Conditions(ctx, input.BootstrapClusterProxy.GetClient(), clusterResources.Cluster.Name, clusterResources.Cluster.Namespace,
127+
map[string]struct{}{
128+
clusterv1.AvailableCondition: {}, clusterv1.ReadyCondition: {},
129+
})
130+
123131
By("PASSED!")
124132
})
125133

test/e2e/md_scale.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ import (
2828
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
2929
"k8s.io/utils/ptr"
3030

31+
clusterv1 "sigs.k8s.io/cluster-api/api/v1beta2"
3132
"sigs.k8s.io/cluster-api/test/framework"
3233
"sigs.k8s.io/cluster-api/test/framework/clusterctl"
3334
"sigs.k8s.io/cluster-api/util"
@@ -125,6 +126,12 @@ func MachineDeploymentScaleSpec(ctx context.Context, inputGetter func() MachineD
125126
WaitForMachineDeployments: input.E2EConfig.GetIntervals(specName, "wait-worker-nodes"),
126127
})
127128

129+
Byf("Verify v1beta2 Available and Ready conditions (if exist) to be true for Cluster and Machines")
130+
verifyV1Beta2Conditions(ctx, input.BootstrapClusterProxy.GetClient(), clusterResources.Cluster.Name, clusterResources.Cluster.Namespace,
131+
map[string]struct{}{
132+
clusterv1.AvailableCondition: {}, clusterv1.ReadyCondition: {},
133+
})
134+
128135
By("Deleting the MachineDeployment with foreground deletion")
129136
foreground := metav1.DeletePropagationForeground
130137
framework.DeleteAndWaitMachineDeployment(ctx, framework.DeleteAndWaitMachineDeploymentInput{

test/e2e/node_drain.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -614,6 +614,12 @@ func NodeDrainTimeoutSpec(ctx context.Context, inputGetter func() NodeDrainTimeo
614614
}
615615
}, nodeDrainTimeoutKCPInterval...).Should(Succeed())
616616

617+
Byf("Verify v1beta2 Available and Ready conditions (if exist) to be true for Cluster and Machines")
618+
verifyV1Beta2Conditions(ctx, input.BootstrapClusterProxy.GetClient(), clusterResources.Cluster.Name, clusterResources.Cluster.Namespace,
619+
map[string]struct{}{
620+
clusterv1.AvailableCondition: {}, clusterv1.ReadyCondition: {},
621+
})
622+
617623
By("PASSED!")
618624
})
619625

test/e2e/quick_start.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ import (
2828
corev1 "k8s.io/api/core/v1"
2929
"k8s.io/utils/ptr"
3030

31+
clusterv1 "sigs.k8s.io/cluster-api/api/v1beta2"
3132
"sigs.k8s.io/cluster-api/test/framework"
3233
"sigs.k8s.io/cluster-api/test/framework/clusterctl"
3334
"sigs.k8s.io/cluster-api/util"
@@ -180,6 +181,12 @@ func QuickStartSpec(ctx context.Context, inputGetter func() QuickStartSpecInput)
180181
},
181182
}, clusterResources)
182183

184+
Byf("Verify v1beta2 Available and Ready conditions (if exist) to be true for Cluster and Machines")
185+
verifyV1Beta2Conditions(ctx, input.BootstrapClusterProxy.GetClient(), clusterResources.Cluster.Name, clusterResources.Cluster.Namespace,
186+
map[string]struct{}{
187+
clusterv1.AvailableCondition: {}, clusterv1.ReadyCondition: {},
188+
})
189+
183190
By("PASSED!")
184191
})
185192

test/e2e/self_hosted.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -421,6 +421,12 @@ func SelfHostedSpec(ctx context.Context, inputGetter func() SelfHostedSpecInput)
421421
WaitForNodesReady: input.E2EConfig.GetIntervals(specName, "wait-nodes-ready"),
422422
})
423423

424+
Byf("Verify v1beta2 Available and Ready conditions (if exist) to be true for Cluster and Machines")
425+
verifyV1Beta2Conditions(ctx, input.BootstrapClusterProxy.GetClient(), clusterResources.Cluster.Name, clusterResources.Cluster.Namespace,
426+
map[string]struct{}{
427+
clusterv1.AvailableCondition: {}, clusterv1.ReadyCondition: {},
428+
})
429+
424430
By("PASSED!")
425431
})
426432

0 commit comments

Comments
 (0)