Skip to content

Commit 9dfb20d

Browse files
committed
test: add WaitForIngressToBeReadyInWorkloadCluster
1 parent b19de30 commit 9dfb20d

File tree

2 files changed

+105
-0
lines changed

2 files changed

+105
-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: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
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+
//nolint:gocritic // This hugeParam is OK in tests.
67+
func waitForAWSLoadBalancerControllerToBeReadyInWorkloadCluster(
68+
ctx context.Context,
69+
input waitForAWSLoadBalancerControllerToBeReadyInWorkloadClusterInput,
70+
) {
71+
WaitForHelmReleaseProxyReadyForCluster(
72+
ctx,
73+
WaitForHelmReleaseProxyReadyForClusterInput{
74+
GetLister: input.clusterProxy.GetClient(),
75+
Cluster: input.workloadCluster,
76+
HelmReleaseName: "aws-lb-controller",
77+
},
78+
input.helmReleaseIntervals...,
79+
)
80+
81+
workloadClusterClient := input.clusterProxy.GetWorkloadCluster(
82+
ctx, input.workloadCluster.Namespace, input.workloadCluster.Name,
83+
).GetClient()
84+
85+
WaitForDeploymentsAvailable(ctx, framework.WaitForDeploymentsAvailableInput{
86+
Getter: workloadClusterClient,
87+
Deployment: &appsv1.Deployment{
88+
ObjectMeta: metav1.ObjectMeta{
89+
Name: "aws-load-balancer-controller",
90+
Namespace: "kube-system",
91+
},
92+
},
93+
}, input.deploymentIntervals...)
94+
}

0 commit comments

Comments
 (0)