Skip to content

Commit cd3b732

Browse files
authored
feat: Added e2e test for capx cluster (#523)
We need to set following vars in either env or caren.yaml # IP/FQDN of Prism Central. NUTANIX_ENDPOINT: "" # Port of Prism Central. Default: 9440 NUTANIX_PORT: 9440 # Disable Prism Central certificate checking. Default: false NUTANIX_INSECURE: false # Prism Central user NUTANIX_USER: "" # Prism Central password NUTANIX_PASSWORD: "" # Host IP to be assigned to the CAPX Kubernetes cluster. CONTROL_PLANE_ENDPOINT_IP: "" # Port of the CAPX Kubernetes cluster. Default: 6443 CONTROL_PLANE_ENDPOINT_PORT: 6443 # Name of the Prism Element cluster. NUTANIX_PRISM_ELEMENT_CLUSTER_NAME: "" # Name of the OS image pre-uploaded in PC. NUTANIX_MACHINE_TEMPLATE_IMAGE_NAME: "" # Name of the subnet to be assigned to the VMs. NUTANIX_SUBNET_NAME: "" # Name of the storage container to CSI driver NUTANIX_STORAGE_CONTAINER_NAME: "" # Username/Password of dockerhub account to avoid download rate limiting DOCKER_HUB_USERNAME: "" DOCKER_HUB_PASSWORD: "" <!-- Copyright 2023 D2iQ, Inc. All rights reserved. SPDX-License-Identifier: Apache-2.0 --> **What problem does this PR solve?**: Adds Nutanix provider to quick start test **Which issue(s) this PR fixes**: Fixes #https://jira.nutanix.com/browse/D2IQ-100400 **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. --> <pre> make e2e-test </pre> **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 808dae7 commit cd3b732

File tree

6 files changed

+116
-3
lines changed

6 files changed

+116
-3
lines changed

.github/workflows/e2e.yml

+3
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,9 @@ jobs:
4040
run: devbox run -- make e2e-test E2E_LABEL='provider:${{ inputs.provider }}'
4141
env:
4242
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
43+
NUTANIX_ENDPOINT: ${{ secrets.NUTANIX_ENDPOINT }}
44+
NUTANIX_PASSWORD: ${{ secrets.NUTANIX_PASSWORD }}
45+
NUTANIX_USER: ${{ secrets.NUTANIX_USER }}
4346

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

pkg/handlers/generic/lifecycle/csi/nutanix-csi/handler.go

+8-1
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,14 @@ func (n *NutanixCSI) handleHelmAddonApply(
215215
},
216216
}
217217

218-
if err = client.ServerSideApply(ctx, n.client, snapshotChart, client.ForceOwnership); err != nil {
218+
if err = controllerutil.SetOwnerReference(&req.Cluster, snapshotChart, n.client.Scheme()); err != nil {
219+
return fmt.Errorf(
220+
"failed to set owner reference on nutanix-csi-snapshot installation HelmChartProxy: %w",
221+
err,
222+
)
223+
}
224+
225+
if err = client.ServerSideApply(ctx, n.client, snapshotChart); err != nil {
219226
return fmt.Errorf(
220227
"failed to apply nutanix-csi-snapshot installation HelmChartProxy: %w",
221228
err,

test/e2e/config/caren.yaml

+49
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,29 @@ providers:
9393
- old: --metrics-addr=127.0.0.1:8080
9494
new: --metrics-addr=:8080
9595

96+
- name: nutanix
97+
type: InfrastructureProvider
98+
versions:
99+
- name: "${CAPX_VERSION}"
100+
value: "https://github.com/nutanix-cloud-native/cluster-api-provider-nutanix/releases/download/${CAPX_VERSION}/infrastructure-components.yaml"
101+
type: "url"
102+
contract: v1beta1
103+
files:
104+
- sourcePath: "../data/shared/v1beta1-capx/metadata.yaml"
105+
- sourcePath: "../../../charts/cluster-api-runtime-extensions-nutanix/defaultclusterclasses/nutanix-cluster-class.yaml"
106+
targetName: clusterclass-nutanix-quick-start.yaml
107+
- sourcePath: "../../../examples/capi-quick-start/nutanix-cluster-cilium-helm-addon.yaml"
108+
targetName: cluster-template-topology-cilium-helm-addon.yaml
109+
- sourcePath: "../../../examples/capi-quick-start/nutanix-cluster-cilium-crs.yaml"
110+
targetName: cluster-template-topology-cilium-crs.yaml
111+
- sourcePath: "../../../examples/capi-quick-start/nutanix-cluster-calico-helm-addon.yaml"
112+
targetName: cluster-template-topology-calico-helm-addon.yaml
113+
- sourcePath: "../../../examples/capi-quick-start/nutanix-cluster-calico-crs.yaml"
114+
targetName: cluster-template-topology-calico-crs.yaml
115+
replacements:
116+
- old: --metrics-addr=127.0.0.1:8080
117+
new: --metrics-addr=:8080
118+
96119
- name: helm
97120
type: AddonProvider
98121
versions:
@@ -161,6 +184,32 @@ variables:
161184
AMI_LOOKUP_FORMAT: "konvoy-ami-{{.BaseOS}}-release-?{{.K8sVersion}}-*"
162185
AMI_LOOKUP_BASEOS: "rocky-9.1"
163186
AMI_LOOKUP_ORG: "999867407951"
187+
# To run Nutanix provider tests, set following variables here or as an env var
188+
# # IP/FQDN of Prism Central.
189+
# NUTANIX_ENDPOINT: ""
190+
# # Port of Prism Central. Default: 9440
191+
# NUTANIX_PORT: 9440
192+
# # Disable Prism Central certificate checking. Default: false
193+
# NUTANIX_INSECURE: false
194+
# # Prism Central user
195+
# NUTANIX_USER: ""
196+
# # Prism Central password
197+
# NUTANIX_PASSWORD: ""
198+
# # Host IP to be assigned to the CAPX Kubernetes cluster.
199+
# CONTROL_PLANE_ENDPOINT_IP: ""
200+
# # Port of the CAPX Kubernetes cluster. Default: 6443
201+
# CONTROL_PLANE_ENDPOINT_PORT: 6443
202+
# # Name of the Prism Element cluster.
203+
# NUTANIX_PRISM_ELEMENT_CLUSTER_NAME: ""
204+
# # Name of the OS image pre-uploaded in PC.
205+
# NUTANIX_MACHINE_TEMPLATE_IMAGE_NAME: ""
206+
# # Name of the subnet to be assigned to the VMs.
207+
# NUTANIX_SUBNET_NAME: ""
208+
# # Name of the storage container to CSI driver
209+
# NUTANIX_STORAGE_CONTAINER_NAME: ""
210+
# # Username/Password of dockerhub account to avoid download rate limiting
211+
# DOCKER_HUB_USERNAME: ""
212+
# DOCKER_HUB_PASSWORD: ""
164213

165214
intervals:
166215
default/wait-controllers: ["3m", "10s"]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# Copyright 2024 D2iQ, Inc. All rights reserved.
2+
# SPDX-License-Identifier: Apache-2.0
3+
4+
# maps release series of major.minor to cluster-api contract version
5+
# the contract version may change between minor or major versions, but *not*
6+
# between patch versions.
7+
#
8+
# TODO(release-blocker): update this file only when a new major or minor version is released
9+
10+
apiVersion: clusterctl.cluster.x-k8s.io/v1alpha3
11+
kind: Metadata
12+
releaseSeries:
13+
- major: 1
14+
minor: 4
15+
contract: v1beta1

test/e2e/ownerreference_helpers.go

+39-1
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,15 @@ const (
3232
awsClusterTemplateKind = "AWSClusterTemplate"
3333
awsClusterControllerIdentityKind = "AWSClusterControllerIdentity"
3434

35+
nutanixMachineKind = "NutanixMachine"
36+
nutanixMachineTemplateKind = "NutanixMachineTemplate"
37+
nutanixClusterKind = "NutanixCluster"
38+
nutanixClusterTemplateKind = "NutanixClusterTemplate"
39+
3540
helmChartProxyKind = "HelmChartProxy"
3641
helmReleaseProxyKind = "HelmReleaseProxy"
42+
43+
secretKind = "Secret"
3744
)
3845

3946
var (
@@ -105,7 +112,7 @@ var (
105112
return framework.HasExactOwners(owners, machineController)
106113
},
107114
awsMachineTemplateKind: func(owners []metav1.OwnerReference) error {
108-
// Base AWSrMachineTemplates referenced in a ClusterClass must be owned by the ClusterClass.
115+
// Base AWSMachineTemplates referenced in a ClusterClass must be owned by the ClusterClass.
109116
// AWSMachineTemplates created for specific Clusters in the Topology controller must be owned by a Cluster.
110117
return framework.HasOneOfExactOwners(
111118
owners,
@@ -126,6 +133,37 @@ var (
126133
return framework.HasExactOwners(owners)
127134
},
128135
}
136+
137+
// NutanixInfraOwnerReferenceAssertions maps Nutanix Infrastructure types to functions which return an error
138+
// if the passed OwnerReferences aren't as expected.
139+
NutanixInfraOwnerReferenceAssertions = map[string]func([]metav1.OwnerReference) error{
140+
nutanixMachineKind: func(owners []metav1.OwnerReference) error {
141+
// The NutanixMachine must be owned and controlled by a Machine.
142+
return framework.HasExactOwners(owners, machineController)
143+
},
144+
nutanixMachineTemplateKind: func(owners []metav1.OwnerReference) error {
145+
// Base NutanixMachineTemplates referenced in a ClusterClass must be owned by the ClusterClass.
146+
// NutanixMachineTemplates created for specific Clusters in the Topology controller must be owned by a Cluster.
147+
return framework.HasOneOfExactOwners(
148+
owners,
149+
[]metav1.OwnerReference{clusterOwner},
150+
[]metav1.OwnerReference{clusterClassOwner},
151+
)
152+
},
153+
nutanixClusterKind: func(owners []metav1.OwnerReference) error {
154+
// NutanixCluster must be owned and controlled by a Cluster.
155+
return framework.HasExactOwners(owners, clusterController)
156+
},
157+
nutanixClusterTemplateKind: func(owners []metav1.OwnerReference) error {
158+
// NutanixClusterTemplate must be owned by a ClusterClass.
159+
return framework.HasExactOwners(owners, clusterClassOwner)
160+
},
161+
secretKind: func(owners []metav1.OwnerReference) error {
162+
// TODO:deepakm-ntnx Currently pc-creds, pc-creds-for-csi, dockerhub-credentials
163+
// and registry-creds have unexpected owners which needs more investigation
164+
return nil
165+
},
166+
}
129167
)
130168

131169
// dedupeOwners returns a a list of owners without duplicate owner types. Only the fields used in the

test/e2e/quick_start_test.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import (
2222
)
2323

2424
var _ = Describe("Quick start", Serial, func() {
25-
for _, provider := range []string{"Docker", "AWS"} {
25+
for _, provider := range []string{"Docker", "AWS", "Nutanix"} {
2626
lowercaseProvider := strings.ToLower(provider)
2727
for _, cniProvider := range []string{"Cilium", "Calico"} {
2828
for _, addonStrategy := range []string{"HelmAddon", "ClusterResourceSet"} {
@@ -94,6 +94,7 @@ var _ = Describe("Quick start", Serial, func() {
9494
framework.KubeadmControlPlaneOwnerReferenceAssertions,
9595
framework.KubernetesReferenceAssertions,
9696
AWSInfraOwnerReferenceAssertions,
97+
NutanixInfraOwnerReferenceAssertions,
9798
AddonReferenceAssertions,
9899
)
99100

0 commit comments

Comments
 (0)