Skip to content

Commit 879f013

Browse files
authored
Merge pull request #734 from rgeraskin/add-ipam-provider-helm-chart-tests
🌱 Add e2e tests for IPAM provider to Cluster API Operator Helm chart
2 parents 1b8ddbd + 2f73b05 commit 879f013

11 files changed

+381
-1
lines changed

hack/charts/cluster-api-operator/templates/core-conditions.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
{{- if or .Values.addon .Values.bootstrap .Values.controlPlane .Values.infrastructure }}
1+
{{- if or .Values.addon .Values.bootstrap .Values.controlPlane .Values.infrastructure .Values.ipam }}
22
# Deploy core components if not specified
33
{{- if not .Values.core }}
44
---

test/e2e/helm_test.go

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,7 @@ var _ = Describe("Create a proper set of manifests when using helm charts", func
154154
"controlPlane": "kubeadm-control-plane-custom-ns:kubeadm:v1.7.7",
155155
"bootstrap": "kubeadm-bootstrap-custom-ns:kubeadm:v1.7.7",
156156
"infrastructure": "capd-custom-ns:docker:v1.7.7",
157+
"ipam": "in-cluster-custom-ns:in-cluster:v1.0.0",
157158
"addon": "helm-custom-ns:helm:v0.2.6",
158159
})
159160
Expect(err).ToNot(HaveOccurred())
@@ -171,6 +172,7 @@ var _ = Describe("Create a proper set of manifests when using helm charts", func
171172
"controlPlane": "kubeadm:v1.7.7",
172173
"bootstrap": "kubeadm:v1.7.7",
173174
"infrastructure": "docker:v1.7.7",
175+
"ipam": "in-cluster:v1.0.0",
174176
"addon": "helm:v0.2.6",
175177
})
176178
Expect(err).ToNot(HaveOccurred())
@@ -188,6 +190,7 @@ var _ = Describe("Create a proper set of manifests when using helm charts", func
188190
"controlPlane": "kubeadm",
189191
"bootstrap": "kubeadm",
190192
"infrastructure": "docker",
193+
"ipam": "in-cluster",
191194
"addon": "helm",
192195
})
193196
Expect(err).ToNot(HaveOccurred())
@@ -236,6 +239,33 @@ var _ = Describe("Create a proper set of manifests when using helm charts", func
236239
Expect(manifests).To(Equal(string(expectedManifests)))
237240
})
238241

242+
It("should deploy core when only ipam is specified", func() {
243+
manifests, err := helmChart.Run(map[string]string{
244+
"configSecret.name": "test-secret-name",
245+
"configSecret.namespace": "test-secret-namespace",
246+
"ipam": "in-cluster",
247+
})
248+
Expect(err).ToNot(HaveOccurred())
249+
Expect(manifests).ToNot(BeEmpty())
250+
expectedManifests, err := os.ReadFile(filepath.Join(customManifestsFolder, "only-ipam.yaml"))
251+
Expect(err).ToNot(HaveOccurred())
252+
Expect(manifests).To(Equal(string(expectedManifests)))
253+
})
254+
255+
It("should deploy core, bootstrap, control plane when only infra and ipam is specified", func() {
256+
manifests, err := helmChart.Run(map[string]string{
257+
"configSecret.name": "test-secret-name",
258+
"configSecret.namespace": "test-secret-namespace",
259+
"infrastructure": "docker",
260+
"ipam": "in-cluster",
261+
})
262+
Expect(err).ToNot(HaveOccurred())
263+
Expect(manifests).ToNot(BeEmpty())
264+
expectedManifests, err := os.ReadFile(filepath.Join(customManifestsFolder, "only-infra-and-ipam.yaml"))
265+
Expect(err).ToNot(HaveOccurred())
266+
Expect(manifests).To(Equal(string(expectedManifests)))
267+
})
268+
239269
It("should deploy multiple infra providers with custom namespace and versions", func() {
240270
manifests, err := helmChart.Run(map[string]string{
241271
"configSecret.name": "test-secret-name",
@@ -306,6 +336,7 @@ var _ = Describe("Create a proper set of manifests when using helm charts", func
306336
"configSecret.name": "aws-variables",
307337
"configSecret.namespace": "default",
308338
"infrastructure": "aws:v2.4.0",
339+
"ipam": "in-cluster:",
309340
"addon": "helm:",
310341
"image.manager.tag": "v0.9.1",
311342
"cert-manager.enabled": "false",
@@ -330,6 +361,7 @@ var _ = Describe("Create a proper set of manifests when using helm charts", func
330361
"configSecret.namespace": "test-secret-namespace",
331362
"core": "cluster-api",
332363
"infrastructure": "azure",
364+
"ipam": "in-cluster",
333365
"addon": "helm",
334366
"manager.cert-manager.enabled": "false",
335367
"manager.cert-manager.installCRDs": "false",
@@ -346,6 +378,7 @@ var _ = Describe("Create a proper set of manifests when using helm charts", func
346378
"controlPlane": "kubeadm",
347379
"bootstrap": "kubeadm",
348380
"infrastructure": "docker",
381+
"ipam": "in-cluster",
349382
"addon": "helm",
350383
"manager.featureGates.core.ClusterTopology": "true",
351384
"manager.featureGates.core.MachinePool": "true",
@@ -362,6 +395,7 @@ var _ = Describe("Create a proper set of manifests when using helm charts", func
362395
"controlPlane": "kubeadm",
363396
"bootstrap": "kubeadm",
364397
"infrastructure": "docker",
398+
"ipam": "in-cluster",
365399
"addon": "helm",
366400
"manager.featureGates.kubeadm.ClusterTopology": "true",
367401
"manager.featureGates.kubeadm.MachinePool": "true",

test/e2e/resources/all-providers-custom-ns-versions.yaml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,16 @@ metadata:
4646
"argocd.argoproj.io/sync-wave": "1"
4747
name: capd-custom-ns
4848
---
49+
# Source: cluster-api-operator/templates/ipam.yaml
50+
apiVersion: v1
51+
kind: Namespace
52+
metadata:
53+
annotations:
54+
"helm.sh/hook": "post-install,post-upgrade"
55+
"helm.sh/hook-weight": "1"
56+
"argocd.argoproj.io/sync-wave": "1"
57+
name: in-cluster-custom-ns
58+
---
4959
# Source: cluster-api-operator/templates/addon.yaml
5060
apiVersion: operator.cluster.x-k8s.io/v1alpha2
5161
kind: AddonProvider
@@ -105,6 +115,22 @@ spec:
105115
name: test-secret-name
106116
namespace: test-secret-namespace
107117
---
118+
# Source: cluster-api-operator/templates/ipam.yaml
119+
apiVersion: operator.cluster.x-k8s.io/v1alpha2
120+
kind: IPAMProvider
121+
metadata:
122+
name: in-cluster
123+
namespace: in-cluster-custom-ns
124+
annotations:
125+
"helm.sh/hook": "post-install,post-upgrade"
126+
"helm.sh/hook-weight": "2"
127+
"argocd.argoproj.io/sync-wave": "2"
128+
spec:
129+
version: v1.0.0
130+
configSecret:
131+
name: test-secret-name
132+
namespace: test-secret-namespace
133+
---
108134
# Source: cluster-api-operator/templates/infra.yaml
109135
apiVersion: operator.cluster.x-k8s.io/v1alpha2
110136
kind: InfrastructureProvider

test/e2e/resources/all-providers-custom-versions.yaml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,16 @@ metadata:
4646
"argocd.argoproj.io/sync-wave": "1"
4747
name: docker-infrastructure-system
4848
---
49+
# Source: cluster-api-operator/templates/ipam.yaml
50+
apiVersion: v1
51+
kind: Namespace
52+
metadata:
53+
annotations:
54+
"helm.sh/hook": "post-install,post-upgrade"
55+
"helm.sh/hook-weight": "1"
56+
"argocd.argoproj.io/sync-wave": "1"
57+
name: in-cluster-ipam-system
58+
---
4959
# Source: cluster-api-operator/templates/addon.yaml
5060
apiVersion: operator.cluster.x-k8s.io/v1alpha2
5161
kind: AddonProvider
@@ -105,6 +115,22 @@ spec:
105115
name: test-secret-name
106116
namespace: test-secret-namespace
107117
---
118+
# Source: cluster-api-operator/templates/ipam.yaml
119+
apiVersion: operator.cluster.x-k8s.io/v1alpha2
120+
kind: IPAMProvider
121+
metadata:
122+
name: in-cluster
123+
namespace: in-cluster-ipam-system
124+
annotations:
125+
"helm.sh/hook": "post-install,post-upgrade"
126+
"helm.sh/hook-weight": "2"
127+
"argocd.argoproj.io/sync-wave": "2"
128+
spec:
129+
version: v1.0.0
130+
configSecret:
131+
name: test-secret-name
132+
namespace: test-secret-namespace
133+
---
108134
# Source: cluster-api-operator/templates/infra.yaml
109135
apiVersion: operator.cluster.x-k8s.io/v1alpha2
110136
kind: InfrastructureProvider

test/e2e/resources/all-providers-latest-versions.yaml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,16 @@ metadata:
4646
"argocd.argoproj.io/sync-wave": "1"
4747
name: docker-infrastructure-system
4848
---
49+
# Source: cluster-api-operator/templates/ipam.yaml
50+
apiVersion: v1
51+
kind: Namespace
52+
metadata:
53+
annotations:
54+
"helm.sh/hook": "post-install,post-upgrade"
55+
"helm.sh/hook-weight": "1"
56+
"argocd.argoproj.io/sync-wave": "1"
57+
name: in-cluster-ipam-system
58+
---
4959
# Source: cluster-api-operator/templates/addon.yaml
5060
apiVersion: operator.cluster.x-k8s.io/v1alpha2
5161
kind: AddonProvider
@@ -100,6 +110,21 @@ spec:
100110
name: test-secret-name
101111
namespace: test-secret-namespace
102112
---
113+
# Source: cluster-api-operator/templates/ipam.yaml
114+
apiVersion: operator.cluster.x-k8s.io/v1alpha2
115+
kind: IPAMProvider
116+
metadata:
117+
name: in-cluster
118+
namespace: in-cluster-ipam-system
119+
annotations:
120+
"helm.sh/hook": "post-install,post-upgrade"
121+
"helm.sh/hook-weight": "2"
122+
"argocd.argoproj.io/sync-wave": "2"
123+
spec:
124+
configSecret:
125+
name: test-secret-name
126+
namespace: test-secret-namespace
127+
---
103128
# Source: cluster-api-operator/templates/infra.yaml
104129
apiVersion: operator.cluster.x-k8s.io/v1alpha2
105130
kind: InfrastructureProvider

test/e2e/resources/all-providers-manager-defined-no-feature-gates.yaml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,16 @@ metadata:
4848
"argocd.argoproj.io/sync-wave": "1"
4949
name: azure-infrastructure-system
5050
---
51+
# Source: cluster-api-operator/templates/ipam.yaml
52+
apiVersion: v1
53+
kind: Namespace
54+
metadata:
55+
annotations:
56+
"helm.sh/hook": "post-install,post-upgrade"
57+
"helm.sh/hook-weight": "1"
58+
"argocd.argoproj.io/sync-wave": "1"
59+
name: in-cluster-ipam-system
60+
---
5161
# Source: cluster-api-operator/templates/addon.yaml
5262
apiVersion: operator.cluster.x-k8s.io/v1alpha2
5363
kind: AddonProvider
@@ -106,6 +116,22 @@ spec:
106116
name: test-secret-name
107117
namespace: test-secret-namespace
108118
---
119+
# Source: cluster-api-operator/templates/ipam.yaml
120+
apiVersion: operator.cluster.x-k8s.io/v1alpha2
121+
kind: IPAMProvider
122+
metadata:
123+
name: in-cluster
124+
namespace: in-cluster-ipam-system
125+
annotations:
126+
"helm.sh/hook": "post-install,post-upgrade"
127+
"helm.sh/hook-weight": "2"
128+
"argocd.argoproj.io/sync-wave": "2"
129+
spec:
130+
manager:
131+
configSecret:
132+
name: test-secret-name
133+
namespace: test-secret-namespace
134+
---
109135
# Source: cluster-api-operator/templates/infra.yaml
110136
apiVersion: operator.cluster.x-k8s.io/v1alpha2
111137
kind: InfrastructureProvider

test/e2e/resources/feature-gates.yaml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,16 @@ metadata:
4848
"argocd.argoproj.io/sync-wave": "1"
4949
name: aws-infrastructure-system
5050
---
51+
# Source: cluster-api-operator/templates/ipam.yaml
52+
apiVersion: v1
53+
kind: Namespace
54+
metadata:
55+
annotations:
56+
"helm.sh/hook": "post-install,post-upgrade"
57+
"helm.sh/hook-weight": "1"
58+
"argocd.argoproj.io/sync-wave": "1"
59+
name: in-cluster-ipam-system
60+
---
5161
# Source: cluster-api-operator/templates/addon.yaml
5262
apiVersion: operator.cluster.x-k8s.io/v1alpha2
5363
kind: AddonProvider
@@ -110,6 +120,22 @@ spec:
110120
name: aws-variables
111121
namespace: default
112122
---
123+
# Source: cluster-api-operator/templates/ipam.yaml
124+
apiVersion: operator.cluster.x-k8s.io/v1alpha2
125+
kind: IPAMProvider
126+
metadata:
127+
name: in-cluster
128+
namespace: in-cluster-ipam-system
129+
annotations:
130+
"helm.sh/hook": "post-install,post-upgrade"
131+
"helm.sh/hook-weight": "2"
132+
"argocd.argoproj.io/sync-wave": "2"
133+
spec:
134+
manager:
135+
configSecret:
136+
name: aws-variables
137+
namespace: default
138+
---
113139
# Source: cluster-api-operator/templates/infra.yaml
114140
apiVersion: operator.cluster.x-k8s.io/v1alpha2
115141
kind: InfrastructureProvider

test/e2e/resources/kubeadm-manager-defined.yaml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,16 @@ metadata:
4646
"argocd.argoproj.io/sync-wave": "1"
4747
name: docker-infrastructure-system
4848
---
49+
# Source: cluster-api-operator/templates/ipam.yaml
50+
apiVersion: v1
51+
kind: Namespace
52+
metadata:
53+
annotations:
54+
"helm.sh/hook": "post-install,post-upgrade"
55+
"helm.sh/hook-weight": "1"
56+
"argocd.argoproj.io/sync-wave": "1"
57+
name: in-cluster-ipam-system
58+
---
4959
# Source: cluster-api-operator/templates/addon.yaml
5060
apiVersion: operator.cluster.x-k8s.io/v1alpha2
5161
kind: AddonProvider
@@ -95,6 +105,19 @@ metadata:
95105
spec:
96106
manager:
97107
---
108+
# Source: cluster-api-operator/templates/ipam.yaml
109+
apiVersion: operator.cluster.x-k8s.io/v1alpha2
110+
kind: IPAMProvider
111+
metadata:
112+
name: in-cluster
113+
namespace: in-cluster-ipam-system
114+
annotations:
115+
"helm.sh/hook": "post-install,post-upgrade"
116+
"helm.sh/hook-weight": "2"
117+
"argocd.argoproj.io/sync-wave": "2"
118+
spec:
119+
manager:
120+
---
98121
# Source: cluster-api-operator/templates/infra.yaml
99122
apiVersion: operator.cluster.x-k8s.io/v1alpha2
100123
kind: InfrastructureProvider

test/e2e/resources/manager-defined-missing-other-infra-spec.yaml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,16 @@ metadata:
4646
"argocd.argoproj.io/sync-wave": "1"
4747
name: docker-infrastructure-system
4848
---
49+
# Source: cluster-api-operator/templates/ipam.yaml
50+
apiVersion: v1
51+
kind: Namespace
52+
metadata:
53+
annotations:
54+
"helm.sh/hook": "post-install,post-upgrade"
55+
"helm.sh/hook-weight": "1"
56+
"argocd.argoproj.io/sync-wave": "1"
57+
name: in-cluster-ipam-system
58+
---
4959
# Source: cluster-api-operator/templates/addon.yaml
5060
apiVersion: operator.cluster.x-k8s.io/v1alpha2
5161
kind: AddonProvider
@@ -94,6 +104,19 @@ spec:
94104
ClusterTopology: true
95105
MachinePool: true
96106
---
107+
# Source: cluster-api-operator/templates/ipam.yaml
108+
apiVersion: operator.cluster.x-k8s.io/v1alpha2
109+
kind: IPAMProvider
110+
metadata:
111+
name: in-cluster
112+
namespace: in-cluster-ipam-system
113+
annotations:
114+
"helm.sh/hook": "post-install,post-upgrade"
115+
"helm.sh/hook-weight": "2"
116+
"argocd.argoproj.io/sync-wave": "2"
117+
spec:
118+
manager:
119+
---
97120
# Source: cluster-api-operator/templates/infra.yaml
98121
apiVersion: operator.cluster.x-k8s.io/v1alpha2
99122
kind: InfrastructureProvider

0 commit comments

Comments
 (0)