Skip to content

Commit a78b9d4

Browse files
authored
test: wait for COSI controller to be ready (#1014)
**What problem does this PR solve?**: Missed this in #1008 since I thought that all HCP are already checked. **Which issue(s) this PR fixes**: Fixes # **How Has This Been Tested?**: <!-- Please describe the tests that you ran to verify your changes. Provide output from the tests and any manual steps needed to replicate the tests. --> **Special notes for your reviewer**: <!-- Use this to provide any additional information to the reviewers. This may include: - Best way to review the PR. - Where the author wants the most review attention on. - etc. -->
1 parent 5b2008a commit a78b9d4

File tree

2 files changed

+85
-0
lines changed

2 files changed

+85
-0
lines changed

test/e2e/addon_helpers.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,17 @@ func WaitForAddonsToBeReadyInWorkloadCluster(
9696
},
9797
)
9898

99+
WaitForCOSIControllerToBeReadyInWorkloadCluster(
100+
ctx,
101+
WaitForCOSIControllerToBeReadyInWorkloadClusterInput{
102+
COSI: input.AddonsConfig.COSI,
103+
WorkloadCluster: input.WorkloadCluster,
104+
ClusterProxy: input.ClusterProxy,
105+
DeploymentIntervals: input.DeploymentIntervals,
106+
HelmReleaseIntervals: input.HelmReleaseIntervals,
107+
},
108+
)
109+
99110
WaitForServiceLoadBalancerToBeReadyInWorkloadCluster(
100111
ctx,
101112
WaitForServiceLoadBalancerToBeReadyInWorkloadClusterInput{

test/e2e/cosi_helpers.go

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
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+
"k8s.io/utils/ptr"
16+
clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1"
17+
"sigs.k8s.io/cluster-api/test/framework"
18+
19+
"github.com/nutanix-cloud-native/cluster-api-runtime-extensions-nutanix/api/v1alpha1"
20+
apivariables "github.com/nutanix-cloud-native/cluster-api-runtime-extensions-nutanix/api/variables"
21+
)
22+
23+
type WaitForCOSIControllerToBeReadyInWorkloadClusterInput struct {
24+
COSI *apivariables.COSI
25+
WorkloadCluster *clusterv1.Cluster
26+
ClusterProxy framework.ClusterProxy
27+
DeploymentIntervals []interface{}
28+
HelmReleaseIntervals []interface{}
29+
}
30+
31+
func WaitForCOSIControllerToBeReadyInWorkloadCluster(
32+
ctx context.Context,
33+
input WaitForCOSIControllerToBeReadyInWorkloadClusterInput, //nolint:gocritic // This hugeParam is OK in tests.
34+
) {
35+
if input.COSI == nil {
36+
return
37+
}
38+
39+
switch ptr.Deref(input.COSI.Strategy, "") {
40+
case v1alpha1.AddonStrategyHelmAddon:
41+
WaitForHelmReleaseProxyReadyForCluster(
42+
ctx,
43+
WaitForHelmReleaseProxyReadyForClusterInput{
44+
GetLister: input.ClusterProxy.GetClient(),
45+
Cluster: input.WorkloadCluster,
46+
HelmReleaseName: "cosi-controller",
47+
},
48+
input.HelmReleaseIntervals...,
49+
)
50+
case "":
51+
Fail("COSI strategy is not set")
52+
default:
53+
Fail(
54+
fmt.Sprintf(
55+
"Do not know how to wait for COSI using strategy %s to be ready",
56+
*input.COSI.Strategy,
57+
),
58+
)
59+
}
60+
61+
workloadClusterClient := input.ClusterProxy.GetWorkloadCluster(
62+
ctx, input.WorkloadCluster.Namespace, input.WorkloadCluster.Name,
63+
).GetClient()
64+
65+
WaitForDeploymentsAvailable(ctx, framework.WaitForDeploymentsAvailableInput{
66+
Getter: workloadClusterClient,
67+
Deployment: &appsv1.Deployment{
68+
ObjectMeta: metav1.ObjectMeta{
69+
Name: "container-object-storage-controller",
70+
Namespace: "container-object-storage-system",
71+
},
72+
},
73+
}, input.DeploymentIntervals...)
74+
}

0 commit comments

Comments
 (0)