Skip to content

Commit 671164e

Browse files
committed
replace Verify functions
Signed-off-by: sivchari <[email protected]>
1 parent 4baa868 commit 671164e

18 files changed

+220
-141
lines changed

test/e2e/autoscaler.go

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -367,11 +367,19 @@ 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-
})
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+
})
375383

376384
By("PASSED!")
377385
})

test/e2e/cluster_deletion.go

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -198,11 +198,19 @@ 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-
})
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+
})
206214

207215
// Get all objects per deletion phase and the list of blocking objects.
208216
var objectsPerPhase [][]client.Object

test/e2e/cluster_upgrade.go

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

30-
clusterv1 "sigs.k8s.io/cluster-api/api/v1beta2"
3130
"sigs.k8s.io/cluster-api/test/framework"
3231
"sigs.k8s.io/cluster-api/test/framework/clusterctl"
3332
"sigs.k8s.io/cluster-api/test/framework/kubetest"
@@ -260,11 +259,19 @@ func ClusterUpgradeConformanceSpec(ctx context.Context, inputGetter func() Clust
260259
WaitForNodesReady: input.E2EConfig.GetIntervals(specName, "wait-nodes-ready"),
261260
})
262261

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-
})
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+
})
268275

269276
if !input.SkipConformanceTests {
270277
By("Running conformance tests")

test/e2e/cluster_upgrade_runtimesdk.go

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -347,11 +347,19 @@ 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-
})
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+
})
355363

356364
By("PASSED!")
357365
})

test/e2e/clusterclass_changes.go

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -272,11 +272,19 @@ func ClusterClassChangesSpec(ctx context.Context, inputGetter func() ClusterClas
272272
WaitForMachinePools: input.E2EConfig.GetIntervals(specName, "wait-machine-pool-nodes"),
273273
})
274274

275-
Byf("Verify v1beta2 Available and Ready conditions (if exist) to be true for Cluster and Machines")
276-
verifyV1Beta2Conditions(ctx, input.BootstrapClusterProxy.GetClient(), clusterResources.Cluster.Name, clusterResources.Cluster.Namespace,
277-
map[string]struct{}{
278-
clusterv1.AvailableCondition: {}, clusterv1.ReadyCondition: {},
279-
})
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+
})
280288

281289
By("Deleting a MachineDeploymentTopology in the Cluster Topology and wait for associated MachineDeployment to be deleted")
282290
deleteMachineDeploymentTopologyAndWait(ctx, deleteMachineDeploymentTopologyAndWaitInput{

test/e2e/clusterclass_rollout.go

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -302,11 +302,19 @@ 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 v1beta2 Available and Ready conditions (if exist) to be true for Cluster and Machines")
306-
verifyV1Beta2Conditions(ctx, input.BootstrapClusterProxy.GetClient(), clusterResources.Cluster.Name, clusterResources.Cluster.Namespace,
307-
map[string]struct{}{
308-
clusterv1.AvailableCondition: {}, clusterv1.ReadyCondition: {},
309-
})
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+
})
310318

311319
By("PASSED!")
312320
})

test/e2e/clusterctl_upgrade.go

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

725-
Byf("[%d] Verify v1beta2 Available and Ready conditions (if exist) to be true for Cluster and Machines", i)
726-
verifyV1Beta2Conditions(ctx, managementClusterProxy.GetClient(), workloadCluster.Name, workloadCluster.Namespace,
727-
map[string]struct{}{
728-
clusterv1.AvailableCondition: {}, clusterv1.ReadyCondition: {},
729-
})
725+
Byf("[%d] Verify Cluster Available condition is true", i)
726+
framework.VerifyClusterAvailable(ctx, framework.VerifyClusterAvailableInput{
727+
Getter: managementClusterProxy.GetClient(),
728+
Name: workloadCluster.Name,
729+
Namespace: workloadCluster.Namespace,
730+
})
731+
732+
Byf("[%d] Verify Machines Ready condition is true", i)
733+
framework.VerifyMachinesReady(ctx, framework.VerifyMachinesReadyInput{
734+
Lister: managementClusterProxy.GetClient(),
735+
Name: workloadCluster.Name,
736+
Namespace: workloadCluster.Namespace,
737+
})
730738

731739
// Note: It is a known issue on Kubernetes < v1.29 that SSA sometimes fail:
732740
// https://github.com/kubernetes/kubernetes/issues/117356

test/e2e/common.go

Lines changed: 0 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -19,17 +19,11 @@ package e2e
1919
import (
2020
"context"
2121
"fmt"
22-
"time"
2322

2423
"github.com/blang/semver/v4"
2524
. "github.com/onsi/ginkgo/v2"
26-
. "github.com/onsi/gomega"
2725
"github.com/onsi/gomega/types"
28-
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
29-
"k8s.io/klog/v2"
30-
"sigs.k8s.io/controller-runtime/pkg/client"
3126

32-
clusterv1 "sigs.k8s.io/cluster-api/api/v1beta2"
3327
"sigs.k8s.io/cluster-api/test/framework/clusterctl"
3428
)
3529

@@ -89,47 +83,3 @@ func GetLatestReleaseOfMinor(ctx context.Context, minorRelease string) (string,
8983
return clusterctl.ResolveRelease(ctx, releaseMarker)
9084
}
9185

92-
// verifyV1Beta2Conditions checks the Cluster and Machines of a Cluster that
93-
// the given v1beta2 condition types are set to true without a message, if they exist.
94-
func verifyV1Beta2Conditions(ctx context.Context, c client.Client, clusterName, clusterNamespace string, v1beta2conditionTypes map[string]struct{}) {
95-
cluster := &clusterv1.Cluster{}
96-
key := client.ObjectKey{
97-
Namespace: clusterNamespace,
98-
Name: clusterName,
99-
}
100-
Eventually(func() error {
101-
return c.Get(ctx, key, cluster)
102-
}, 3*time.Minute, 10*time.Second).Should(Succeed(), "Failed to get Cluster object %s", klog.KRef(clusterNamespace, clusterName))
103-
104-
if len(cluster.Status.Conditions) > 0 {
105-
for _, condition := range cluster.Status.Conditions {
106-
if _, ok := v1beta2conditionTypes[condition.Type]; !ok {
107-
continue
108-
}
109-
Expect(condition.Status).To(Equal(metav1.ConditionTrue), "The v1beta2 condition %q on the Cluster should be set to true", condition.Type)
110-
Expect(condition.Message).To(BeEmpty(), "The v1beta2 condition %q on the Cluster should have an empty message", condition.Type)
111-
}
112-
}
113-
114-
machineList := &clusterv1.MachineList{}
115-
Eventually(func() error {
116-
return c.List(ctx, machineList, client.InNamespace(clusterNamespace),
117-
client.MatchingLabels{
118-
clusterv1.ClusterNameLabel: clusterName,
119-
})
120-
}, 3*time.Minute, 10*time.Second).Should(Succeed(), "Failed to list Machines for Cluster %s", klog.KObj(cluster))
121-
if len(cluster.Status.Conditions) > 0 {
122-
for _, machine := range machineList.Items {
123-
if len(machine.Status.Conditions) == 0 {
124-
continue
125-
}
126-
for _, condition := range machine.Status.Conditions {
127-
if _, ok := v1beta2conditionTypes[condition.Type]; !ok {
128-
continue
129-
}
130-
Expect(condition.Status).To(Equal(metav1.ConditionTrue), "The v1beta2 condition %q on the Machine %q should be set to true", condition.Type, machine.Name)
131-
Expect(condition.Message).To(BeEmpty(), "The v1beta2 condition %q on the Machine %q should have an empty message", condition.Type, machine.Name)
132-
}
133-
}
134-
}
135-
}

test/e2e/k8s_conformance.go

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

31-
clusterv1 "sigs.k8s.io/cluster-api/api/v1beta2"
3231
"sigs.k8s.io/cluster-api/test/framework"
3332
"sigs.k8s.io/cluster-api/test/framework/clusterctl"
3433
"sigs.k8s.io/cluster-api/test/framework/kubetest"
@@ -154,11 +153,19 @@ func K8SConformanceSpec(ctx context.Context, inputGetter func() K8SConformanceSp
154153
)
155154
Expect(err).ToNot(HaveOccurred(), "Failed to run Kubernetes conformance")
156155

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-
})
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+
})
162169

163170
By("PASSED!")
164171
})

test/e2e/kcp_adoption.go

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -247,11 +247,19 @@ 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-
})
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+
})
255263

256264
By("PASSED!")
257265
})

0 commit comments

Comments
 (0)