Skip to content

Commit

Permalink
test(e2e): Use upstream CRS helpers (#680)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
jimmidyson committed May 21, 2024
1 parent 3ff2e54 commit 55fdaf3
Show file tree
Hide file tree
Showing 4 changed files with 72 additions and 161 deletions.
24 changes: 18 additions & 6 deletions test/e2e/clusterautoscaler_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@ import (
. "github.com/onsi/gomega"
appsv1 "k8s.io/api/apps/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/types"
clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1"
addonsv1 "sigs.k8s.io/cluster-api/exp/addons/api/v1beta1"
"sigs.k8s.io/cluster-api/test/framework"

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

switch input.ClusterAutoscaler.Strategy {
case v1alpha1.AddonStrategyClusterResourceSet:
waitForClusterResourceSetToApplyResourcesInCluster(
crs := &addonsv1.ClusterResourceSet{}
Expect(input.ClusterProxy.GetClient().Get(
ctx,
waitForClusterResourceSetToApplyResourcesInClusterInput{
name: clusterAutoscalerPrefix + input.WorkloadCluster.Name,
clusterProxy: input.ClusterProxy,
cluster: input.WorkloadCluster,
intervals: input.ClusterResourceSetIntervals,
types.NamespacedName{
Name: clusterAutoscalerPrefix + input.WorkloadCluster.Name,
Namespace: input.WorkloadCluster.Namespace,
},
crs,
)).To(Succeed())

framework.WaitForClusterResourceSetToApplyResources(
ctx,
framework.WaitForClusterResourceSetToApplyResourcesInput{
ClusterResourceSet: crs,
ClusterProxy: input.ClusterProxy,
Cluster: input.WorkloadCluster,
},
input.ClusterResourceSetIntervals...,
)
case v1alpha1.AddonStrategyHelmAddon:
WaitForHelmReleaseProxyReadyForCluster(
Expand Down
137 changes: 0 additions & 137 deletions test/e2e/clusterresourceset_helpers.go

This file was deleted.

47 changes: 35 additions & 12 deletions test/e2e/cni_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,12 @@ import (
"fmt"

. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
appsv1 "k8s.io/api/apps/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/types"
clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1"
addonsv1 "sigs.k8s.io/cluster-api/exp/addons/api/v1beta1"
"sigs.k8s.io/cluster-api/test/framework"

"github.com/nutanix-cloud-native/cluster-api-runtime-extensions-nutanix/api/v1alpha1"
Expand Down Expand Up @@ -89,14 +92,24 @@ func waitForCalicoToBeReadyInWorkloadCluster(
) {
switch input.strategy {
case v1alpha1.AddonStrategyClusterResourceSet:
waitForClusterResourceSetToApplyResourcesInCluster(
crs := &addonsv1.ClusterResourceSet{}
Expect(input.clusterProxy.GetClient().Get(
ctx,
waitForClusterResourceSetToApplyResourcesInClusterInput{
name: "calico-cni-installation-" + input.workloadCluster.Name,
clusterProxy: input.clusterProxy,
cluster: input.workloadCluster,
intervals: input.clusterResourceSetIntervals,
types.NamespacedName{
Name: "calico-cni-installation-" + input.workloadCluster.Name,
Namespace: input.workloadCluster.Namespace,
},
crs,
)).To(Succeed())

framework.WaitForClusterResourceSetToApplyResources(
ctx,
framework.WaitForClusterResourceSetToApplyResourcesInput{
ClusterResourceSet: crs,
ClusterProxy: input.clusterProxy,
Cluster: input.workloadCluster,
},
input.clusterResourceSetIntervals...,
)
case v1alpha1.AddonStrategyHelmAddon:
WaitForHelmReleaseProxyReadyForCluster(
Expand Down Expand Up @@ -193,14 +206,24 @@ func waitForCiliumToBeReadyInWorkloadCluster(
) {
switch input.strategy {
case v1alpha1.AddonStrategyClusterResourceSet:
waitForClusterResourceSetToApplyResourcesInCluster(
crs := &addonsv1.ClusterResourceSet{}
Expect(input.clusterProxy.GetClient().Get(
ctx,
waitForClusterResourceSetToApplyResourcesInClusterInput{
name: "cilium-cni-installation-" + input.workloadCluster.Name,
clusterProxy: input.clusterProxy,
cluster: input.workloadCluster,
intervals: input.clusterResourceSetIntervals,
types.NamespacedName{
Name: "cilium-cni-installation-" + input.workloadCluster.Name,
Namespace: input.workloadCluster.Namespace,
},
crs,
)).To(Succeed())

framework.WaitForClusterResourceSetToApplyResources(
ctx,
framework.WaitForClusterResourceSetToApplyResourcesInput{
ClusterResourceSet: crs,
ClusterProxy: input.clusterProxy,
Cluster: input.workloadCluster,
},
input.clusterResourceSetIntervals...,
)
case v1alpha1.AddonStrategyHelmAddon:
WaitForHelmReleaseProxyReadyForCluster(
Expand Down
25 changes: 19 additions & 6 deletions test/e2e/nfd_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,12 @@ import (
"fmt"

. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
appsv1 "k8s.io/api/apps/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/types"
clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1"
addonsv1 "sigs.k8s.io/cluster-api/exp/addons/api/v1beta1"
"sigs.k8s.io/cluster-api/test/framework"

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

switch input.NFD.Strategy {
case v1alpha1.AddonStrategyClusterResourceSet:
waitForClusterResourceSetToApplyResourcesInCluster(
crs := &addonsv1.ClusterResourceSet{}
Expect(input.ClusterProxy.GetClient().Get(
ctx,
waitForClusterResourceSetToApplyResourcesInClusterInput{
name: "node-feature-discovery-" + input.WorkloadCluster.Name,
clusterProxy: input.ClusterProxy,
cluster: input.WorkloadCluster,
intervals: input.ClusterResourceSetIntervals,
types.NamespacedName{
Name: "node-feature-discovery-" + input.WorkloadCluster.Name,
Namespace: input.WorkloadCluster.Namespace,
},
crs,
)).To(Succeed())

framework.WaitForClusterResourceSetToApplyResources(
ctx,
framework.WaitForClusterResourceSetToApplyResourcesInput{
ClusterResourceSet: crs,
ClusterProxy: input.ClusterProxy,
Cluster: input.WorkloadCluster,
},
input.ClusterResourceSetIntervals...,
)
case v1alpha1.AddonStrategyHelmAddon:
WaitForHelmReleaseProxyReadyForCluster(
Expand Down

0 comments on commit 55fdaf3

Please sign in to comment.