Skip to content

Commit

Permalink
test: wait for COSI controller to be ready
Browse files Browse the repository at this point in the history
  • Loading branch information
dkoshkin committed Jan 16, 2025
1 parent 4a2a4f5 commit 32809e4
Show file tree
Hide file tree
Showing 2 changed files with 85 additions and 0 deletions.
11 changes: 11 additions & 0 deletions test/e2e/addon_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,17 @@ func WaitForAddonsToBeReadyInWorkloadCluster(
},
)

WaitForCOSIControllerToBeReadyInWorkloadCluster(
ctx,
WaitForCOSIControllerToBeReadyInWorkloadClusterInput{
COSI: input.AddonsConfig.COSI,
WorkloadCluster: input.WorkloadCluster,
ClusterProxy: input.ClusterProxy,
DeploymentIntervals: input.DeploymentIntervals,
HelmReleaseIntervals: input.HelmReleaseIntervals,
},
)

WaitForServiceLoadBalancerToBeReadyInWorkloadCluster(
ctx,
WaitForServiceLoadBalancerToBeReadyInWorkloadClusterInput{
Expand Down
74 changes: 74 additions & 0 deletions test/e2e/cosi_helpers.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
//go:build e2e

// Copyright 2024 Nutanix. All rights reserved.
// SPDX-License-Identifier: Apache-2.0

package e2e

import (
"context"
"fmt"

. "github.com/onsi/ginkgo/v2"
appsv1 "k8s.io/api/apps/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/utils/ptr"
clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1"
"sigs.k8s.io/cluster-api/test/framework"

"github.com/nutanix-cloud-native/cluster-api-runtime-extensions-nutanix/api/v1alpha1"
apivariables "github.com/nutanix-cloud-native/cluster-api-runtime-extensions-nutanix/api/variables"
)

type WaitForCOSIControllerToBeReadyInWorkloadClusterInput struct {
COSI *apivariables.COSI
WorkloadCluster *clusterv1.Cluster
ClusterProxy framework.ClusterProxy
DeploymentIntervals []interface{}
HelmReleaseIntervals []interface{}
}

func WaitForCOSIControllerToBeReadyInWorkloadCluster(
ctx context.Context,
input WaitForCOSIControllerToBeReadyInWorkloadClusterInput, //nolint:gocritic // This hugeParam is OK in tests.
) {
if input.COSI == nil {
return
}

switch ptr.Deref(input.COSI.Strategy, "") {
case v1alpha1.AddonStrategyHelmAddon:
WaitForHelmReleaseProxyReadyForCluster(
ctx,
WaitForHelmReleaseProxyReadyForClusterInput{
GetLister: input.ClusterProxy.GetClient(),
Cluster: input.WorkloadCluster,
HelmReleaseName: "cosi-controller",
},
input.HelmReleaseIntervals...,
)
case "":
Fail("COSI strategy is not set")
default:
Fail(
fmt.Sprintf(
"Do not know how to wait for COSI using strategy %s to be ready",
*input.COSI.Strategy,
),
)
}

workloadClusterClient := input.ClusterProxy.GetWorkloadCluster(
ctx, input.WorkloadCluster.Namespace, input.WorkloadCluster.Name,
).GetClient()

WaitForDeploymentsAvailable(ctx, framework.WaitForDeploymentsAvailableInput{
Getter: workloadClusterClient,
Deployment: &appsv1.Deployment{
ObjectMeta: metav1.ObjectMeta{
Name: "container-object-storage-controller",
Namespace: "container-object-storage-system",
},
},
}, input.DeploymentIntervals...)
}

0 comments on commit 32809e4

Please sign in to comment.