Skip to content

Commit 911b5c5

Browse files
authored
Merge pull request #692 from rgeraskin/fix-helm-chart-e2e-tests
🐛 Fix helm chart e2e tests: MatchYAML to Equal
2 parents bb5efea + 1914631 commit 911b5c5

8 files changed

+151
-38
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ metadata:
3838
"helm.sh/hook": "post-install,post-upgrade"
3939
"helm.sh/hook-weight": "2"
4040
"argocd.argoproj.io/sync-wave": "2"
41-
{{- if or $coreVersion $.Values.configSecret.name }}
41+
{{- if or $coreVersion $.Values.configSecret.name $.Values.manager }}
4242
spec:
4343
{{- end}}
4444
{{- if $coreVersion }}

test/e2e/helm_test.go

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ var _ = Describe("Create a proper set of manifests when using helm charts", func
135135
manifests, err := fullRun.Run(nil)
136136
Expect(err).ToNot(HaveOccurred())
137137
fullChartInstall, err := os.ReadFile(filepath.Join(customManifestsFolder, "full-chart-install.yaml"))
138-
Expect(manifests).To(MatchYAML(string(fullChartInstall)))
138+
Expect(manifests).To(Equal(string(fullChartInstall)))
139139
})
140140

141141
It("should not deploy providers when none specified", func() {
@@ -158,7 +158,7 @@ var _ = Describe("Create a proper set of manifests when using helm charts", func
158158
Expect(manifests).ToNot(BeEmpty())
159159
expectedManifests, err := os.ReadFile(filepath.Join(customManifestsFolder, "all-providers-custom-ns-versions.yaml"))
160160
Expect(err).ToNot(HaveOccurred())
161-
Expect(manifests).To(MatchYAML(string(expectedManifests)))
161+
Expect(manifests).To(Equal(string(expectedManifests)))
162162
})
163163

164164
It("should deploy all providers with custom versions", func() {
@@ -175,7 +175,7 @@ var _ = Describe("Create a proper set of manifests when using helm charts", func
175175
Expect(manifests).ToNot(BeEmpty())
176176
expectedManifests, err := os.ReadFile(filepath.Join(customManifestsFolder, "all-providers-custom-versions.yaml"))
177177
Expect(err).ToNot(HaveOccurred())
178-
Expect(manifests).To(MatchYAML(string(expectedManifests)))
178+
Expect(manifests).To(Equal(string(expectedManifests)))
179179
})
180180

181181
It("should deploy all providers with latest version", func() {
@@ -192,7 +192,7 @@ var _ = Describe("Create a proper set of manifests when using helm charts", func
192192
Expect(manifests).ToNot(BeEmpty())
193193
expectedManifests, err := os.ReadFile(filepath.Join(customManifestsFolder, "all-providers-latest-versions.yaml"))
194194
Expect(err).ToNot(HaveOccurred())
195-
Expect(manifests).To(MatchYAML(string(expectedManifests)))
195+
Expect(manifests).To(Equal(string(expectedManifests)))
196196
})
197197

198198
It("should deploy core, bootstrap, control plane when only infra is specified", func() {
@@ -205,7 +205,7 @@ var _ = Describe("Create a proper set of manifests when using helm charts", func
205205
Expect(manifests).ToNot(BeEmpty())
206206
expectedManifests, err := os.ReadFile(filepath.Join(customManifestsFolder, "only-infra.yaml"))
207207
Expect(err).ToNot(HaveOccurred())
208-
Expect(manifests).To(MatchYAML(string(expectedManifests)))
208+
Expect(manifests).To(Equal(string(expectedManifests)))
209209
})
210210

211211
It("should deploy core when only bootstrap is specified", func() {
@@ -218,7 +218,7 @@ var _ = Describe("Create a proper set of manifests when using helm charts", func
218218
Expect(manifests).ToNot(BeEmpty())
219219
expectedManifests, err := os.ReadFile(filepath.Join(customManifestsFolder, "only-bootstrap.yaml"))
220220
Expect(err).ToNot(HaveOccurred())
221-
Expect(manifests).To(MatchYAML(string(expectedManifests)))
221+
Expect(manifests).To(Equal(string(expectedManifests)))
222222
})
223223

224224
It("should deploy core when only control plane is specified", func() {
@@ -231,7 +231,7 @@ var _ = Describe("Create a proper set of manifests when using helm charts", func
231231
Expect(manifests).ToNot(BeEmpty())
232232
expectedManifests, err := os.ReadFile(filepath.Join(customManifestsFolder, "only-control-plane.yaml"))
233233
Expect(err).ToNot(HaveOccurred())
234-
Expect(manifests).To(MatchYAML(string(expectedManifests)))
234+
Expect(manifests).To(Equal(string(expectedManifests)))
235235
})
236236

237237
It("should deploy multiple infra providers with custom namespace and versions", func() {
@@ -244,7 +244,7 @@ var _ = Describe("Create a proper set of manifests when using helm charts", func
244244
Expect(manifests).ToNot(BeEmpty())
245245
expectedManifests, err := os.ReadFile(filepath.Join(customManifestsFolder, "multiple-infra-custom-ns-versions.yaml"))
246246
Expect(err).ToNot(HaveOccurred())
247-
Expect(manifests).To(MatchYAML(string(expectedManifests)))
247+
Expect(manifests).To(Equal(string(expectedManifests)))
248248
})
249249

250250
It("should deploy multiple control plane providers with custom namespace and versions", func() {
@@ -257,7 +257,7 @@ var _ = Describe("Create a proper set of manifests when using helm charts", func
257257
Expect(manifests).ToNot(BeEmpty())
258258
expectedManifests, err := os.ReadFile(filepath.Join(customManifestsFolder, "multiple-control-plane-custom-ns-versions.yaml"))
259259
Expect(err).ToNot(HaveOccurred())
260-
Expect(manifests).To(MatchYAML(string(expectedManifests)))
260+
Expect(manifests).To(Equal(string(expectedManifests)))
261261
})
262262

263263
It("should deploy multiple bootstrap providers with custom namespace and versions", func() {
@@ -270,7 +270,7 @@ var _ = Describe("Create a proper set of manifests when using helm charts", func
270270
Expect(manifests).ToNot(BeEmpty())
271271
expectedManifests, err := os.ReadFile(filepath.Join(customManifestsFolder, "multiple-bootstrap-custom-ns-versions.yaml"))
272272
Expect(err).ToNot(HaveOccurred())
273-
Expect(manifests).To(MatchYAML(string(expectedManifests)))
273+
Expect(manifests).To(Equal(string(expectedManifests)))
274274
})
275275

276276
It("should deploy core when only addon is specified", func() {
@@ -283,7 +283,7 @@ var _ = Describe("Create a proper set of manifests when using helm charts", func
283283
Expect(manifests).ToNot(BeEmpty())
284284
expectedManifests, err := os.ReadFile(filepath.Join(customManifestsFolder, "only-addon.yaml"))
285285
Expect(err).ToNot(HaveOccurred())
286-
Expect(manifests).To(MatchYAML(string(expectedManifests)))
286+
Expect(manifests).To(Equal(string(expectedManifests)))
287287
})
288288

289289
It("should deploy core, bootstrap, control plane when only infra and addon is specified", func() {
@@ -297,7 +297,7 @@ var _ = Describe("Create a proper set of manifests when using helm charts", func
297297
Expect(manifests).ToNot(BeEmpty())
298298
expectedManifests, err := os.ReadFile(filepath.Join(customManifestsFolder, "only-infra-and-addon.yaml"))
299299
Expect(err).ToNot(HaveOccurred())
300-
Expect(manifests).To(MatchYAML(string(expectedManifests)))
300+
Expect(manifests).To(Equal(string(expectedManifests)))
301301
})
302302
It("should deploy core and infra with feature gates enabled", func() {
303303
manifests, err := helmChart.Run(map[string]string{
@@ -320,23 +320,23 @@ var _ = Describe("Create a proper set of manifests when using helm charts", func
320320
Expect(manifests).ToNot(BeEmpty())
321321
expectedManifests, err := os.ReadFile(filepath.Join(customManifestsFolder, "feature-gates.yaml"))
322322
Expect(err).ToNot(HaveOccurred())
323-
Expect(manifests).To(MatchYAML(string(expectedManifests)))
323+
Expect(manifests).To(Equal(string(expectedManifests)))
324324
})
325325
It("should deploy all providers with manager defined but no feature gates enabled", func() {
326326
manifests, err := helmChart.Run(map[string]string{
327327
"configSecret.name": "test-secret-name",
328328
"configSecret.namespace": "test-secret-namespace",
329+
"core": "cluster-api",
329330
"infrastructure": "azure",
330331
"addon": "helm",
331-
"core": "cluster-api",
332332
"manager.cert-manager.enabled": "false",
333333
"manager.cert-manager.installCRDs": "false",
334334
})
335335
Expect(err).ToNot(HaveOccurred())
336336
Expect(manifests).ToNot(BeEmpty())
337-
expectedManifests, err := os.ReadFile(filepath.Join(customManifestsFolder, "all-providers-latest-versions.yaml"))
337+
expectedManifests, err := os.ReadFile(filepath.Join(customManifestsFolder, "all-providers-manager-defined-no-feature-gates.yaml"))
338338
Expect(err).ToNot(HaveOccurred())
339-
Expect(manifests).To(MatchYAML(string(expectedManifests)))
339+
Expect(manifests).To(Equal(string(expectedManifests)))
340340
})
341341
It("should deploy all providers when manager is defined but another infrastructure spec field is defined", func() {
342342
manifests, err := helmChart.Run(map[string]string{
@@ -352,7 +352,7 @@ var _ = Describe("Create a proper set of manifests when using helm charts", func
352352
Expect(manifests).ToNot(BeEmpty())
353353
expectedManifests, err := os.ReadFile(filepath.Join(customManifestsFolder, "manager-defined-missing-other-infra-spec.yaml"))
354354
Expect(err).ToNot(HaveOccurred())
355-
Expect(manifests).To(MatchYAML(string(expectedManifests)))
355+
Expect(manifests).To(Equal(string(expectedManifests)))
356356
})
357357
It("should deploy kubeadm control plane with manager specified", func() {
358358
manifests, err := helmChart.Run(map[string]string{
@@ -368,6 +368,6 @@ var _ = Describe("Create a proper set of manifests when using helm charts", func
368368
Expect(manifests).ToNot(BeEmpty())
369369
expectedManifests, err := os.ReadFile(filepath.Join(customManifestsFolder, "kubeadm-manager-defined.yaml"))
370370
Expect(err).ToNot(HaveOccurred())
371-
Expect(manifests).To(MatchYAML(string(expectedManifests)))
371+
Expect(manifests).To(Equal(string(expectedManifests)))
372372
})
373373
})

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ metadata:
5757
"helm.sh/hook-weight": "2"
5858
"argocd.argoproj.io/sync-wave": "2"
5959
spec:
60-
version: v0.1.0-alpha.9
60+
version: v0.2.6
6161
---
6262
# Source: cluster-api-operator/templates/bootstrap.yaml
6363
apiVersion: operator.cluster.x-k8s.io/v1alpha2

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ metadata:
5757
"helm.sh/hook-weight": "2"
5858
"argocd.argoproj.io/sync-wave": "2"
5959
spec:
60-
version: v0.1.0-alpha.9
60+
version: v0.2.6
6161
---
6262
# Source: cluster-api-operator/templates/bootstrap.yaml
6363
apiVersion: operator.cluster.x-k8s.io/v1alpha2
Lines changed: 123 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,123 @@
1+
---
2+
# Source: cluster-api-operator/templates/addon.yaml
3+
apiVersion: v1
4+
kind: Namespace
5+
metadata:
6+
annotations:
7+
"helm.sh/hook": "post-install,post-upgrade"
8+
"helm.sh/hook-weight": "1"
9+
"argocd.argoproj.io/sync-wave": "1"
10+
name: helm-addon-system
11+
---
12+
# Source: cluster-api-operator/templates/core.yaml
13+
apiVersion: v1
14+
kind: Namespace
15+
metadata:
16+
annotations:
17+
"helm.sh/hook": "post-install,post-upgrade"
18+
"helm.sh/hook-weight": "1"
19+
name: capi-system
20+
---
21+
# Source: cluster-api-operator/templates/infra-conditions.yaml
22+
apiVersion: v1
23+
kind: Namespace
24+
metadata:
25+
annotations:
26+
"helm.sh/hook": "post-install,post-upgrade"
27+
"helm.sh/hook-weight": "1"
28+
"argocd.argoproj.io/sync-wave": "1"
29+
name: capi-kubeadm-bootstrap-system
30+
---
31+
# Source: cluster-api-operator/templates/infra-conditions.yaml
32+
apiVersion: v1
33+
kind: Namespace
34+
metadata:
35+
annotations:
36+
"helm.sh/hook": "post-install,post-upgrade"
37+
"helm.sh/hook-weight": "1"
38+
"argocd.argoproj.io/sync-wave": "1"
39+
name: capi-kubeadm-control-plane-system
40+
---
41+
# Source: cluster-api-operator/templates/infra.yaml
42+
apiVersion: v1
43+
kind: Namespace
44+
metadata:
45+
annotations:
46+
"helm.sh/hook": "post-install,post-upgrade"
47+
"helm.sh/hook-weight": "1"
48+
"argocd.argoproj.io/sync-wave": "1"
49+
name: azure-infrastructure-system
50+
---
51+
# Source: cluster-api-operator/templates/addon.yaml
52+
apiVersion: operator.cluster.x-k8s.io/v1alpha2
53+
kind: AddonProvider
54+
metadata:
55+
name: helm
56+
namespace: helm-addon-system
57+
annotations:
58+
"helm.sh/hook": "post-install,post-upgrade"
59+
"helm.sh/hook-weight": "2"
60+
"argocd.argoproj.io/sync-wave": "2"
61+
---
62+
# Source: cluster-api-operator/templates/infra-conditions.yaml
63+
apiVersion: operator.cluster.x-k8s.io/v1alpha2
64+
kind: BootstrapProvider
65+
metadata:
66+
name: kubeadm
67+
namespace: capi-kubeadm-bootstrap-system
68+
annotations:
69+
"helm.sh/hook": "post-install,post-upgrade"
70+
"helm.sh/hook-weight": "2"
71+
"argocd.argoproj.io/sync-wave": "2"
72+
spec:
73+
configSecret:
74+
name: test-secret-name
75+
namespace: test-secret-namespace
76+
---
77+
# Source: cluster-api-operator/templates/infra-conditions.yaml
78+
apiVersion: operator.cluster.x-k8s.io/v1alpha2
79+
kind: ControlPlaneProvider
80+
metadata:
81+
name: kubeadm
82+
namespace: capi-kubeadm-control-plane-system
83+
annotations:
84+
"helm.sh/hook": "post-install,post-upgrade"
85+
"helm.sh/hook-weight": "2"
86+
"argocd.argoproj.io/sync-wave": "2"
87+
spec:
88+
manager:
89+
configSecret:
90+
name: test-secret-name
91+
namespace: test-secret-namespace
92+
---
93+
# Source: cluster-api-operator/templates/core.yaml
94+
apiVersion: operator.cluster.x-k8s.io/v1alpha2
95+
kind: CoreProvider
96+
metadata:
97+
name: cluster-api
98+
namespace: capi-system
99+
annotations:
100+
"helm.sh/hook": "post-install,post-upgrade"
101+
"helm.sh/hook-weight": "2"
102+
"argocd.argoproj.io/sync-wave": "2"
103+
spec:
104+
manager:
105+
configSecret:
106+
name: test-secret-name
107+
namespace: test-secret-namespace
108+
---
109+
# Source: cluster-api-operator/templates/infra.yaml
110+
apiVersion: operator.cluster.x-k8s.io/v1alpha2
111+
kind: InfrastructureProvider
112+
metadata:
113+
name: azure
114+
namespace: azure-infrastructure-system
115+
annotations:
116+
"helm.sh/hook": "post-install,post-upgrade"
117+
"helm.sh/hook-weight": "2"
118+
"argocd.argoproj.io/sync-wave": "2"
119+
spec:
120+
manager:
121+
configSecret:
122+
name: test-secret-name
123+
namespace: test-secret-namespace

test/e2e/resources/feature-gates.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ metadata:
8585
"helm.sh/hook-weight": "2"
8686
"argocd.argoproj.io/sync-wave": "2"
8787
spec:
88+
manager:
8889
configSecret:
8990
name: aws-variables
9091
namespace: default

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ metadata:
9292
"helm.sh/hook": "post-install,post-upgrade"
9393
"helm.sh/hook-weight": "2"
9494
"argocd.argoproj.io/sync-wave": "2"
95+
spec:
9596
manager:
9697
---
9798
# Source: cluster-api-operator/templates/infra.yaml

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

Lines changed: 5 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -66,10 +66,6 @@ metadata:
6666
annotations:
6767
"helm.sh/hook": "post-install,post-upgrade"
6868
"helm.sh/hook-weight": "2"
69-
spec:
70-
configSecret:
71-
name: test-secret-name
72-
namespace: test-secret-namespace
7369
---
7470
# Source: cluster-api-operator/templates/control-plane.yaml
7571
apiVersion: operator.cluster.x-k8s.io/v1alpha2
@@ -81,9 +77,6 @@ metadata:
8177
"helm.sh/hook": "post-install,post-upgrade"
8278
"helm.sh/hook-weight": "2"
8379
spec:
84-
configSecret:
85-
name: test-secret-name
86-
namespace: test-secret-namespace
8780
---
8881
# Source: cluster-api-operator/templates/core.yaml
8982
apiVersion: operator.cluster.x-k8s.io/v1alpha2
@@ -96,9 +89,10 @@ metadata:
9689
"helm.sh/hook-weight": "2"
9790
"argocd.argoproj.io/sync-wave": "2"
9891
spec:
99-
configSecret:
100-
name: test-secret-name
101-
namespace: test-secret-namespace
92+
manager:
93+
featureGates:
94+
ClusterTopology: true
95+
MachinePool: true
10296
---
10397
# Source: cluster-api-operator/templates/infra.yaml
10498
apiVersion: operator.cluster.x-k8s.io/v1alpha2
@@ -111,10 +105,4 @@ metadata:
111105
"helm.sh/hook-weight": "2"
112106
"argocd.argoproj.io/sync-wave": "2"
113107
spec:
114-
configSecret:
115-
name: test-secret-name
116-
namespace: test-secret-namespace
117-
manager:
118-
featureGates:
119-
ClusterTopology: true
120-
MachinePool: true
108+
manager:

0 commit comments

Comments
 (0)