Skip to content

Commit e9f9612

Browse files
committed
test: add WaitForIngressToBeReadyInWorkloadCluster
1 parent b19de30 commit e9f9612

File tree

2 files changed

+104
-0
lines changed

2 files changed

+104
-0
lines changed

test/e2e/addon_helpers.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,4 +130,15 @@ func WaitForAddonsToBeReadyInWorkloadCluster(
130130
StatefulSetIntervals: input.StatefulSetIntervals,
131131
},
132132
)
133+
134+
WaitForIngressToBeReadyInWorkloadCluster(
135+
ctx,
136+
WaitForIngressToBeReadyInWorkloadClusterInput{
137+
Ingress: input.AddonsConfig.Ingress,
138+
WorkloadCluster: input.WorkloadCluster,
139+
ClusterProxy: input.ClusterProxy,
140+
DeploymentIntervals: input.DeploymentIntervals,
141+
HelmReleaseIntervals: input.HelmReleaseIntervals,
142+
},
143+
)
133144
}

test/e2e/ingress_helpers.go

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
//go:build e2e
2+
3+
// Copyright 2025 Nutanix. All rights reserved.
4+
// SPDX-License-Identifier: Apache-2.0
5+
6+
package e2e
7+
8+
import (
9+
"context"
10+
"fmt"
11+
12+
. "github.com/onsi/ginkgo/v2"
13+
appsv1 "k8s.io/api/apps/v1"
14+
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
15+
clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1"
16+
"sigs.k8s.io/cluster-api/test/framework"
17+
18+
"github.com/nutanix-cloud-native/cluster-api-runtime-extensions-nutanix/api/v1alpha1"
19+
apivariables "github.com/nutanix-cloud-native/cluster-api-runtime-extensions-nutanix/api/variables"
20+
)
21+
22+
type WaitForIngressToBeReadyInWorkloadClusterInput struct {
23+
Ingress *apivariables.Ingress
24+
WorkloadCluster *clusterv1.Cluster
25+
ClusterProxy framework.ClusterProxy
26+
DeploymentIntervals []interface{}
27+
HelmReleaseIntervals []interface{}
28+
}
29+
30+
func WaitForIngressToBeReadyInWorkloadCluster(
31+
ctx context.Context,
32+
input WaitForIngressToBeReadyInWorkloadClusterInput, //nolint:gocritic // This hugeParam is OK in tests.
33+
) {
34+
if input.Ingress == nil {
35+
return
36+
}
37+
38+
switch input.Ingress.Provider {
39+
case v1alpha1.IngressProviderAWSLoadBalancerController:
40+
waitForAWSLoadBalancerControllerToBeReadyInWorkloadCluster(
41+
ctx,
42+
waitForAWSLoadBalancerControllerToBeReadyInWorkloadClusterInput{
43+
workloadCluster: input.WorkloadCluster,
44+
clusterProxy: input.ClusterProxy,
45+
deploymentIntervals: input.DeploymentIntervals,
46+
helmReleaseIntervals: input.HelmReleaseIntervals,
47+
},
48+
)
49+
default:
50+
Fail(
51+
fmt.Sprintf(
52+
"Do not know how to wait for Ingress provider %s to be ready",
53+
input.Ingress.Provider,
54+
),
55+
)
56+
}
57+
}
58+
59+
type waitForAWSLoadBalancerControllerToBeReadyInWorkloadClusterInput struct {
60+
workloadCluster *clusterv1.Cluster
61+
clusterProxy framework.ClusterProxy
62+
deploymentIntervals []interface{}
63+
helmReleaseIntervals []interface{}
64+
}
65+
66+
func waitForAWSLoadBalancerControllerToBeReadyInWorkloadCluster(
67+
ctx context.Context,
68+
input waitForAWSLoadBalancerControllerToBeReadyInWorkloadClusterInput, //nolint:gocritic // This hugeParam is OK in tests.
69+
) {
70+
WaitForHelmReleaseProxyReadyForCluster(
71+
ctx,
72+
WaitForHelmReleaseProxyReadyForClusterInput{
73+
GetLister: input.clusterProxy.GetClient(),
74+
Cluster: input.workloadCluster,
75+
HelmReleaseName: "aws-lb-controller",
76+
},
77+
input.helmReleaseIntervals...,
78+
)
79+
80+
workloadClusterClient := input.clusterProxy.GetWorkloadCluster(
81+
ctx, input.workloadCluster.Namespace, input.workloadCluster.Name,
82+
).GetClient()
83+
84+
WaitForDeploymentsAvailable(ctx, framework.WaitForDeploymentsAvailableInput{
85+
Getter: workloadClusterClient,
86+
Deployment: &appsv1.Deployment{
87+
ObjectMeta: metav1.ObjectMeta{
88+
Name: "aws-load-balancer-controller",
89+
Namespace: "kube-system",
90+
},
91+
},
92+
}, input.deploymentIntervals...)
93+
}

0 commit comments

Comments
 (0)