Skip to content

Commit 55fdaf3

Browse files
authored
test(e2e): Use upstream CRS helpers (#680)
These were previously buggy, but I have had some fixes accepted there so we can switch back to upstream utilities for validating CRS state in e2e tests.
1 parent 3ff2e54 commit 55fdaf3

File tree

4 files changed

+72
-161
lines changed

4 files changed

+72
-161
lines changed

test/e2e/clusterautoscaler_helpers.go

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,9 @@ import (
1313
. "github.com/onsi/gomega"
1414
appsv1 "k8s.io/api/apps/v1"
1515
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
16+
"k8s.io/apimachinery/pkg/types"
1617
clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1"
18+
addonsv1 "sigs.k8s.io/cluster-api/exp/addons/api/v1beta1"
1719
"sigs.k8s.io/cluster-api/test/framework"
1820

1921
"github.com/nutanix-cloud-native/cluster-api-runtime-extensions-nutanix/api/v1alpha1"
@@ -53,14 +55,24 @@ func WaitForClusterAutoscalerToBeReadyInWorkloadCluster(
5355

5456
switch input.ClusterAutoscaler.Strategy {
5557
case v1alpha1.AddonStrategyClusterResourceSet:
56-
waitForClusterResourceSetToApplyResourcesInCluster(
58+
crs := &addonsv1.ClusterResourceSet{}
59+
Expect(input.ClusterProxy.GetClient().Get(
5760
ctx,
58-
waitForClusterResourceSetToApplyResourcesInClusterInput{
59-
name: clusterAutoscalerPrefix + input.WorkloadCluster.Name,
60-
clusterProxy: input.ClusterProxy,
61-
cluster: input.WorkloadCluster,
62-
intervals: input.ClusterResourceSetIntervals,
61+
types.NamespacedName{
62+
Name: clusterAutoscalerPrefix + input.WorkloadCluster.Name,
63+
Namespace: input.WorkloadCluster.Namespace,
64+
},
65+
crs,
66+
)).To(Succeed())
67+
68+
framework.WaitForClusterResourceSetToApplyResources(
69+
ctx,
70+
framework.WaitForClusterResourceSetToApplyResourcesInput{
71+
ClusterResourceSet: crs,
72+
ClusterProxy: input.ClusterProxy,
73+
Cluster: input.WorkloadCluster,
6374
},
75+
input.ClusterResourceSetIntervals...,
6476
)
6577
case v1alpha1.AddonStrategyHelmAddon:
6678
WaitForHelmReleaseProxyReadyForCluster(

test/e2e/clusterresourceset_helpers.go

Lines changed: 0 additions & 137 deletions
This file was deleted.

test/e2e/cni_helpers.go

Lines changed: 35 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,12 @@ import (
1010
"fmt"
1111

1212
. "github.com/onsi/ginkgo/v2"
13+
. "github.com/onsi/gomega"
1314
appsv1 "k8s.io/api/apps/v1"
1415
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
16+
"k8s.io/apimachinery/pkg/types"
1517
clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1"
18+
addonsv1 "sigs.k8s.io/cluster-api/exp/addons/api/v1beta1"
1619
"sigs.k8s.io/cluster-api/test/framework"
1720

1821
"github.com/nutanix-cloud-native/cluster-api-runtime-extensions-nutanix/api/v1alpha1"
@@ -89,14 +92,24 @@ func waitForCalicoToBeReadyInWorkloadCluster(
8992
) {
9093
switch input.strategy {
9194
case v1alpha1.AddonStrategyClusterResourceSet:
92-
waitForClusterResourceSetToApplyResourcesInCluster(
95+
crs := &addonsv1.ClusterResourceSet{}
96+
Expect(input.clusterProxy.GetClient().Get(
9397
ctx,
94-
waitForClusterResourceSetToApplyResourcesInClusterInput{
95-
name: "calico-cni-installation-" + input.workloadCluster.Name,
96-
clusterProxy: input.clusterProxy,
97-
cluster: input.workloadCluster,
98-
intervals: input.clusterResourceSetIntervals,
98+
types.NamespacedName{
99+
Name: "calico-cni-installation-" + input.workloadCluster.Name,
100+
Namespace: input.workloadCluster.Namespace,
99101
},
102+
crs,
103+
)).To(Succeed())
104+
105+
framework.WaitForClusterResourceSetToApplyResources(
106+
ctx,
107+
framework.WaitForClusterResourceSetToApplyResourcesInput{
108+
ClusterResourceSet: crs,
109+
ClusterProxy: input.clusterProxy,
110+
Cluster: input.workloadCluster,
111+
},
112+
input.clusterResourceSetIntervals...,
100113
)
101114
case v1alpha1.AddonStrategyHelmAddon:
102115
WaitForHelmReleaseProxyReadyForCluster(
@@ -193,14 +206,24 @@ func waitForCiliumToBeReadyInWorkloadCluster(
193206
) {
194207
switch input.strategy {
195208
case v1alpha1.AddonStrategyClusterResourceSet:
196-
waitForClusterResourceSetToApplyResourcesInCluster(
209+
crs := &addonsv1.ClusterResourceSet{}
210+
Expect(input.clusterProxy.GetClient().Get(
197211
ctx,
198-
waitForClusterResourceSetToApplyResourcesInClusterInput{
199-
name: "cilium-cni-installation-" + input.workloadCluster.Name,
200-
clusterProxy: input.clusterProxy,
201-
cluster: input.workloadCluster,
202-
intervals: input.clusterResourceSetIntervals,
212+
types.NamespacedName{
213+
Name: "cilium-cni-installation-" + input.workloadCluster.Name,
214+
Namespace: input.workloadCluster.Namespace,
215+
},
216+
crs,
217+
)).To(Succeed())
218+
219+
framework.WaitForClusterResourceSetToApplyResources(
220+
ctx,
221+
framework.WaitForClusterResourceSetToApplyResourcesInput{
222+
ClusterResourceSet: crs,
223+
ClusterProxy: input.clusterProxy,
224+
Cluster: input.workloadCluster,
203225
},
226+
input.clusterResourceSetIntervals...,
204227
)
205228
case v1alpha1.AddonStrategyHelmAddon:
206229
WaitForHelmReleaseProxyReadyForCluster(

test/e2e/nfd_helpers.go

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,12 @@ import (
1010
"fmt"
1111

1212
. "github.com/onsi/ginkgo/v2"
13+
. "github.com/onsi/gomega"
1314
appsv1 "k8s.io/api/apps/v1"
1415
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
16+
"k8s.io/apimachinery/pkg/types"
1517
clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1"
18+
addonsv1 "sigs.k8s.io/cluster-api/exp/addons/api/v1beta1"
1619
"sigs.k8s.io/cluster-api/test/framework"
1720

1821
"github.com/nutanix-cloud-native/cluster-api-runtime-extensions-nutanix/api/v1alpha1"
@@ -38,14 +41,24 @@ func WaitForNFDToBeReadyInWorkloadCluster(
3841

3942
switch input.NFD.Strategy {
4043
case v1alpha1.AddonStrategyClusterResourceSet:
41-
waitForClusterResourceSetToApplyResourcesInCluster(
44+
crs := &addonsv1.ClusterResourceSet{}
45+
Expect(input.ClusterProxy.GetClient().Get(
4246
ctx,
43-
waitForClusterResourceSetToApplyResourcesInClusterInput{
44-
name: "node-feature-discovery-" + input.WorkloadCluster.Name,
45-
clusterProxy: input.ClusterProxy,
46-
cluster: input.WorkloadCluster,
47-
intervals: input.ClusterResourceSetIntervals,
47+
types.NamespacedName{
48+
Name: "node-feature-discovery-" + input.WorkloadCluster.Name,
49+
Namespace: input.WorkloadCluster.Namespace,
4850
},
51+
crs,
52+
)).To(Succeed())
53+
54+
framework.WaitForClusterResourceSetToApplyResources(
55+
ctx,
56+
framework.WaitForClusterResourceSetToApplyResourcesInput{
57+
ClusterResourceSet: crs,
58+
ClusterProxy: input.ClusterProxy,
59+
Cluster: input.WorkloadCluster,
60+
},
61+
input.ClusterResourceSetIntervals...,
4962
)
5063
case v1alpha1.AddonStrategyHelmAddon:
5164
WaitForHelmReleaseProxyReadyForCluster(

0 commit comments

Comments
 (0)