Skip to content

Commit f01a20e

Browse files
committed
test: set control plane ip for nutanix e2e tests
1 parent a400260 commit f01a20e

File tree

2 files changed

+28
-1
lines changed

2 files changed

+28
-1
lines changed

.github/workflows/e2e.yml

+2-1
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ jobs:
6464
${{ runner.os }}-go-
6565
6666
- name: Login to Internal Container Registry
67+
if: inputs.focus == 'Self-hosted'
6768
uses: docker/login-action@v3
6869
with:
6970
registry: ${{ secrets.LOCAL_IMAGE_REGISTRY }}
@@ -101,7 +102,7 @@ jobs:
101102
NUTANIX_MACHINE_TEMPLATE_IMAGE_NAME: ${{ inputs.os-image }}
102103
KINDEST_IMAGE_TAG: ${{ inputs.kubernetes-version }}
103104
E2E_KUBERNETES_VERSION: ${{ inputs.kubernetes-version }}
104-
LOCAL_IMAGE_REGISTRY: ${{ secrets.LOCAL_IMAGE_REGISTRY }}
105+
LOCAL_IMAGE_REGISTRY: ${{ inputs.focus == 'Self-hosted' && secrets.LOCAL_IMAGE_REGISTRY || 'ko.local' }}
105106

106107
- if: success() || failure() # always run even if the previous step fails
107108
name: Publish e2e test report

test/e2e/framework/self_hosted.go

+26
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ import (
2828
"sigs.k8s.io/cluster-api/test/framework/clusterctl"
2929
"sigs.k8s.io/cluster-api/util"
3030
"sigs.k8s.io/controller-runtime/pkg/client"
31+
32+
"github.com/nutanix-cloud-native/cluster-api-runtime-extensions-nutanix/test/e2e/framework/nutanix"
3133
)
3234

3335
// SelfHostedSpecInput is the input for SelfHostedSpec.
@@ -180,6 +182,30 @@ func SelfHostedSpec(ctx context.Context, inputGetter func() SelfHostedSpecInput)
180182
if input.InfrastructureProvider != nil {
181183
infrastructureProvider = *input.InfrastructureProvider
182184
}
185+
186+
// For Nutanix provider, reserve an IP address for the workload cluster control plane endpoint -
187+
// remember to unreserve it!
188+
if infrastructureProvider == "nutanix" {
189+
By(
190+
"Reserving an IP address for the workload cluster control plane endpoint",
191+
)
192+
nutanixClient, err := nutanix.NewV4Client(
193+
nutanix.CredentialsFromCAPIE2EConfig(input.E2EConfig),
194+
)
195+
Expect(err).ToNot(HaveOccurred())
196+
//nolint:contextcheck // ReserverIP function does not accept context. Its okay to ignore the context check in tests.
197+
controlPlaneEndpointIP, unreserveControlPlaneEndpointIP, err := nutanix.ReserveIP(
198+
input.E2EConfig.GetVariable("NUTANIX_SUBNET_NAME"),
199+
input.E2EConfig.GetVariable(
200+
"NUTANIX_PRISM_ELEMENT_CLUSTER_NAME",
201+
),
202+
nutanixClient,
203+
)
204+
Expect(err).ToNot(HaveOccurred())
205+
DeferCleanup(unreserveControlPlaneEndpointIP)
206+
clusterctlVariables["CONTROL_PLANE_ENDPOINT_IP"] = controlPlaneEndpointIP
207+
}
208+
183209
clusterctl.ApplyClusterTemplateAndWait(ctx, clusterctl.ApplyClusterTemplateAndWaitInput{
184210
ClusterProxy: input.BootstrapClusterProxy,
185211
ConfigCluster: clusterctl.ConfigClusterInput{

0 commit comments

Comments
 (0)