Skip to content

Commit e862992

Browse files
committed
feat: Added e2e test for capx cluster
We need to set following vars in either env or caren.yaml NUTANIX_ENDPOINT: x.x.x.x NUTANIX_USER: admin NUTANIX_PASSWORD: “” NUTANIX_INSECURE: true NUTANIX_PORT: 9440 CONTROL_PLANE_ENDPOINT_IP: x.x.x.x CONTROL_PLANE_ENDPOINT_PORT: 6443 NUTANIX_PRISM_ELEMENT_CLUSTER_NAME: "" NUTANIX_MACHINE_TEMPLATE_IMAGE_NAME: "" NUTANIX_SUBNET_NAME: "" DOCKER_HUB_USERNAME: “” NUTANIX_PRISM_ELEMENT_ENDPOINT: x.x.x.x NUTANIX_STORAGE_CONTAINER_NAME: “”
1 parent 36a0662 commit e862992

File tree

5 files changed

+130
-3
lines changed

5 files changed

+130
-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: 36 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,19 @@ variables:
161184
AMI_LOOKUP_FORMAT: "konvoy-ami-{{.BaseOS}}-release-?{{.K8sVersion}}-*"
162185
AMI_LOOKUP_BASEOS: "rocky-9.1"
163186
AMI_LOOKUP_ORG: "999867407951"
187+
NUTANIX_ENDPOINT: ""
188+
NUTANIX_USER: ""
189+
NUTANIX_PASSWORD: ""
190+
NUTANIX_INSECURE: false
191+
NUTANIX_PORT: 9440
192+
CONTROL_PLANE_ENDPOINT_IP: ""
193+
CONTROL_PLANE_ENDPOINT_PORT: 6443
194+
NUTANIX_PRISM_ELEMENT_CLUSTER_NAME: ""
195+
NUTANIX_MACHINE_TEMPLATE_IMAGE_NAME: ""
196+
NUTANIX_SUBNET_NAME: ""
197+
DOCKER_HUB_USERNAME: ""
198+
NUTANIX_PRISM_ELEMENT_ENDPOINT: ""
199+
NUTANIX_STORAGE_CONTAINER_NAME: ""
164200

165201
intervals:
166202
default/wait-controllers: ["3m", "10s"]
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
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: 0
14+
minor: 1
15+
contract: v1alpha4
16+
- major: 0
17+
minor: 2
18+
contract: v1beta1
19+
- major: 0
20+
minor: 3
21+
contract: v1beta1
22+
- major: 0
23+
minor: 4
24+
contract: v1beta1
25+
- major: 0
26+
minor: 5
27+
contract: v1beta1
28+
- major: 1
29+
minor: 0
30+
contract: v1beta1
31+
- major: 1
32+
minor: 1
33+
contract: v1beta1
34+
- major: 1
35+
minor: 2
36+
contract: v1beta1
37+
- major: 1
38+
minor: 3
39+
contract: v1beta1
40+
- major: 1
41+
minor: 4
42+
contract: v1beta1
43+
- major: 0
44+
minor: 0
45+
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)