Skip to content

Commit 584b663

Browse files
committed
feat: Added e2e test for capx cluster
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: ""
1 parent 36a0662 commit 584b663

File tree

5 files changed

+113
-3
lines changed

5 files changed

+113
-3
lines changed

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

Lines changed: 8 additions & 1 deletion
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

Lines changed: 48 additions & 0 deletions
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,31 @@ variables:
161184
AMI_LOOKUP_FORMAT: "konvoy-ami-{{.BaseOS}}-release-?{{.K8sVersion}}-*"
162185
AMI_LOOKUP_BASEOS: "rocky-9.1"
163186
AMI_LOOKUP_ORG: "999867407951"
187+
# IP/FQDN of Prism Central.
188+
NUTANIX_ENDPOINT: ""
189+
# Port of Prism Central. Default: 9440
190+
NUTANIX_PORT: 9440
191+
# Disable Prism Central certificate checking. Default: false
192+
NUTANIX_INSECURE: false
193+
# Prism Central user
194+
NUTANIX_USER: ""
195+
# Prism Central password
196+
NUTANIX_PASSWORD: ""
197+
# Host IP to be assigned to the CAPX Kubernetes cluster.
198+
CONTROL_PLANE_ENDPOINT_IP: ""
199+
# Port of the CAPX Kubernetes cluster. Default: 6443
200+
CONTROL_PLANE_ENDPOINT_PORT: 6443
201+
# Name of the Prism Element cluster.
202+
NUTANIX_PRISM_ELEMENT_CLUSTER_NAME: ""
203+
# Name of the OS image pre-uploaded in PC.
204+
NUTANIX_MACHINE_TEMPLATE_IMAGE_NAME: ""
205+
# Name of the subnet to be assigned to the VMs.
206+
NUTANIX_SUBNET_NAME: ""
207+
# Name of the storage container to CSI driver
208+
NUTANIX_STORAGE_CONTAINER_NAME: ""
209+
# Username/Password of dockerhub account to avoid download rate limiting
210+
DOCKER_HUB_USERNAME: ""
211+
DOCKER_HUB_PASSWORD: ""
164212

165213
intervals:
166214
default/wait-controllers: ["3m", "10s"]
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
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+
contract: v1beta1
14+
- major: 1
15+
minor: 4
16+
contract: v1beta1

test/e2e/ownerreference_helpers.go

Lines changed: 39 additions & 1 deletion
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

Lines changed: 2 additions & 1 deletion
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)