Skip to content

Commit d2d1dad

Browse files
authored
Merge pull request kubernetes-sigs#549 from willie-yao/helm-test
🌱 Add more cases to helm test
2 parents c4ef701 + 58d8e15 commit d2d1dad

File tree

2 files changed

+165
-13
lines changed

2 files changed

+165
-13
lines changed

test/e2e/helm_test.go

Lines changed: 45 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ var _ = Describe("Create a proper set of manifests when using helm charts", func
4242
manifests, err := fullRun.Run(nil)
4343
Expect(err).ToNot(HaveOccurred())
4444
fullChartInstall, err := os.ReadFile(filepath.Join(customManifestsFolder, "full-chart-install.yaml"))
45-
Expect(manifests).To(Equal(string(fullChartInstall)))
45+
Expect(manifests).To(MatchYAML(string(fullChartInstall)))
4646
})
4747

4848
It("should not deploy providers when none specified", func() {
@@ -65,7 +65,7 @@ var _ = Describe("Create a proper set of manifests when using helm charts", func
6565
Expect(manifests).ToNot(BeEmpty())
6666
expectedManifests, err := os.ReadFile(filepath.Join(customManifestsFolder, "all-providers-custom-ns-versions.yaml"))
6767
Expect(err).ToNot(HaveOccurred())
68-
Expect(manifests).To(Equal(string(expectedManifests)))
68+
Expect(manifests).To(MatchYAML(string(expectedManifests)))
6969
})
7070

7171
It("should deploy all providers with custom versions", func() {
@@ -82,7 +82,7 @@ var _ = Describe("Create a proper set of manifests when using helm charts", func
8282
Expect(manifests).ToNot(BeEmpty())
8383
expectedManifests, err := os.ReadFile(filepath.Join(customManifestsFolder, "all-providers-custom-versions.yaml"))
8484
Expect(err).ToNot(HaveOccurred())
85-
Expect(manifests).To(Equal(string(expectedManifests)))
85+
Expect(manifests).To(MatchYAML(string(expectedManifests)))
8686
})
8787

8888
It("should deploy all providers with latest version", func() {
@@ -99,7 +99,7 @@ var _ = Describe("Create a proper set of manifests when using helm charts", func
9999
Expect(manifests).ToNot(BeEmpty())
100100
expectedManifests, err := os.ReadFile(filepath.Join(customManifestsFolder, "all-providers-latest-versions.yaml"))
101101
Expect(err).ToNot(HaveOccurred())
102-
Expect(manifests).To(Equal(string(expectedManifests)))
102+
Expect(manifests).To(MatchYAML(string(expectedManifests)))
103103
})
104104

105105
It("should deploy core, bootstrap, control plane when only infra is specified", func() {
@@ -112,7 +112,7 @@ var _ = Describe("Create a proper set of manifests when using helm charts", func
112112
Expect(manifests).ToNot(BeEmpty())
113113
expectedManifests, err := os.ReadFile(filepath.Join(customManifestsFolder, "only-infra.yaml"))
114114
Expect(err).ToNot(HaveOccurred())
115-
Expect(manifests).To(Equal(string(expectedManifests)))
115+
Expect(manifests).To(MatchYAML(string(expectedManifests)))
116116
})
117117

118118
It("should deploy core when only bootstrap is specified", func() {
@@ -125,7 +125,7 @@ var _ = Describe("Create a proper set of manifests when using helm charts", func
125125
Expect(manifests).ToNot(BeEmpty())
126126
expectedManifests, err := os.ReadFile(filepath.Join(customManifestsFolder, "only-bootstrap.yaml"))
127127
Expect(err).ToNot(HaveOccurred())
128-
Expect(manifests).To(Equal(string(expectedManifests)))
128+
Expect(manifests).To(MatchYAML(string(expectedManifests)))
129129
})
130130

131131
It("should deploy core when only control plane is specified", func() {
@@ -138,7 +138,7 @@ var _ = Describe("Create a proper set of manifests when using helm charts", func
138138
Expect(manifests).ToNot(BeEmpty())
139139
expectedManifests, err := os.ReadFile(filepath.Join(customManifestsFolder, "only-control-plane.yaml"))
140140
Expect(err).ToNot(HaveOccurred())
141-
Expect(manifests).To(Equal(string(expectedManifests)))
141+
Expect(manifests).To(MatchYAML(string(expectedManifests)))
142142
})
143143

144144
It("should deploy multiple infra providers with custom namespace and versions", func() {
@@ -151,7 +151,7 @@ var _ = Describe("Create a proper set of manifests when using helm charts", func
151151
Expect(manifests).ToNot(BeEmpty())
152152
expectedManifests, err := os.ReadFile(filepath.Join(customManifestsFolder, "multiple-infra-custom-ns-versions.yaml"))
153153
Expect(err).ToNot(HaveOccurred())
154-
Expect(manifests).To(Equal(string(expectedManifests)))
154+
Expect(manifests).To(MatchYAML(string(expectedManifests)))
155155
})
156156

157157
It("should deploy multiple control plane providers with custom namespace and versions", func() {
@@ -164,7 +164,7 @@ var _ = Describe("Create a proper set of manifests when using helm charts", func
164164
Expect(manifests).ToNot(BeEmpty())
165165
expectedManifests, err := os.ReadFile(filepath.Join(customManifestsFolder, "multiple-control-plane-custom-ns-versions.yaml"))
166166
Expect(err).ToNot(HaveOccurred())
167-
Expect(manifests).To(Equal(string(expectedManifests)))
167+
Expect(manifests).To(MatchYAML(string(expectedManifests)))
168168
})
169169

170170
It("should deploy multiple bootstrap providers with custom namespace and versions", func() {
@@ -177,7 +177,7 @@ var _ = Describe("Create a proper set of manifests when using helm charts", func
177177
Expect(manifests).ToNot(BeEmpty())
178178
expectedManifests, err := os.ReadFile(filepath.Join(customManifestsFolder, "multiple-bootstrap-custom-ns-versions.yaml"))
179179
Expect(err).ToNot(HaveOccurred())
180-
Expect(manifests).To(Equal(string(expectedManifests)))
180+
Expect(manifests).To(MatchYAML(string(expectedManifests)))
181181
})
182182

183183
It("should deploy core when only addon is specified", func() {
@@ -190,7 +190,7 @@ var _ = Describe("Create a proper set of manifests when using helm charts", func
190190
Expect(manifests).ToNot(BeEmpty())
191191
expectedManifests, err := os.ReadFile(filepath.Join(customManifestsFolder, "only-addon.yaml"))
192192
Expect(err).ToNot(HaveOccurred())
193-
Expect(manifests).To(Equal(string(expectedManifests)))
193+
Expect(manifests).To(MatchYAML(string(expectedManifests)))
194194
})
195195

196196
It("should deploy core, bootstrap, control plane when only infra and addon is specified", func() {
@@ -204,7 +204,7 @@ var _ = Describe("Create a proper set of manifests when using helm charts", func
204204
Expect(manifests).ToNot(BeEmpty())
205205
expectedManifests, err := os.ReadFile(filepath.Join(customManifestsFolder, "only-infra-and-addon.yaml"))
206206
Expect(err).ToNot(HaveOccurred())
207-
Expect(manifests).To(Equal(string(expectedManifests)))
207+
Expect(manifests).To(MatchYAML(string(expectedManifests)))
208208
})
209209
It("should deploy core and infra with feature gates enabled", func() {
210210
manifests, err := helmChart.Run(map[string]string{
@@ -227,6 +227,38 @@ var _ = Describe("Create a proper set of manifests when using helm charts", func
227227
Expect(manifests).ToNot(BeEmpty())
228228
expectedManifests, err := os.ReadFile(filepath.Join(customManifestsFolder, "feature-gates.yaml"))
229229
Expect(err).ToNot(HaveOccurred())
230-
Expect(manifests).To(Equal(string(expectedManifests)))
230+
Expect(manifests).To(MatchYAML(string(expectedManifests)))
231+
})
232+
It("should deploy all providers with manager defined but no feature gates enabled", func() {
233+
manifests, err := helmChart.Run(map[string]string{
234+
"configSecret.name": "test-secret-name",
235+
"configSecret.namespace": "test-secret-namespace",
236+
"infrastructure": "azure",
237+
"addon": "helm",
238+
"core": "cluster-api",
239+
"manager.cert-manager.enabled": "false",
240+
"manager.cert-manager.installCRDs": "false",
241+
})
242+
Expect(err).ToNot(HaveOccurred())
243+
Expect(manifests).ToNot(BeEmpty())
244+
expectedManifests, err := os.ReadFile(filepath.Join(customManifestsFolder, "all-providers-latest-versions.yaml"))
245+
Expect(err).ToNot(HaveOccurred())
246+
Expect(manifests).To(MatchYAML(string(expectedManifests)))
247+
})
248+
It("should deploy all providers when manager is defined but another infrastructure spec field is defined", func() {
249+
manifests, err := helmChart.Run(map[string]string{
250+
"core": "cluster-api",
251+
"controlPlane": "kubeadm",
252+
"bootstrap": "kubeadm",
253+
"infrastructure": "docker",
254+
"addon": "helm",
255+
"manager.featureGates.core.ClusterTopology": "true",
256+
"manager.featureGates.core.MachinePool": "true",
257+
})
258+
Expect(err).ToNot(HaveOccurred())
259+
Expect(manifests).ToNot(BeEmpty())
260+
expectedManifests, err := os.ReadFile(filepath.Join(customManifestsFolder, "manager-defined-missing-other-infra-spec.yaml"))
261+
Expect(err).ToNot(HaveOccurred())
262+
Expect(manifests).To(MatchYAML(string(expectedManifests)))
231263
})
232264
})
Lines changed: 120 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
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"
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/bootstrap.yaml
13+
apiVersion: v1
14+
kind: Namespace
15+
metadata:
16+
annotations:
17+
"helm.sh/hook": "post-install"
18+
"helm.sh/hook-weight": "1"
19+
name: kubeadm-bootstrap-system
20+
---
21+
# Source: cluster-api-operator/templates/control-plane.yaml
22+
apiVersion: v1
23+
kind: Namespace
24+
metadata:
25+
annotations:
26+
"helm.sh/hook": "post-install"
27+
"helm.sh/hook-weight": "1"
28+
name: kubeadm-control-plane-system
29+
---
30+
# Source: cluster-api-operator/templates/core.yaml
31+
apiVersion: v1
32+
kind: Namespace
33+
metadata:
34+
annotations:
35+
"helm.sh/hook": "post-install"
36+
"helm.sh/hook-weight": "1"
37+
name: capi-system
38+
---
39+
# Source: cluster-api-operator/templates/infra.yaml
40+
apiVersion: v1
41+
kind: Namespace
42+
metadata:
43+
annotations:
44+
"helm.sh/hook": "post-install"
45+
"helm.sh/hook-weight": "1"
46+
"argocd.argoproj.io/sync-wave": "1"
47+
name: docker-infrastructure-system
48+
---
49+
# Source: cluster-api-operator/templates/addon.yaml
50+
apiVersion: operator.cluster.x-k8s.io/v1alpha2
51+
kind: AddonProvider
52+
metadata:
53+
name: helm
54+
namespace: helm-addon-system
55+
annotations:
56+
"helm.sh/hook": "post-install"
57+
"helm.sh/hook-weight": "2"
58+
"argocd.argoproj.io/sync-wave": "2"
59+
---
60+
# Source: cluster-api-operator/templates/bootstrap.yaml
61+
apiVersion: operator.cluster.x-k8s.io/v1alpha2
62+
kind: BootstrapProvider
63+
metadata:
64+
name: kubeadm
65+
namespace: kubeadm-bootstrap-system
66+
annotations:
67+
"helm.sh/hook": "post-install"
68+
"helm.sh/hook-weight": "2"
69+
spec:
70+
configSecret:
71+
name: test-secret-name
72+
namespace: test-secret-namespace
73+
---
74+
# Source: cluster-api-operator/templates/control-plane.yaml
75+
apiVersion: operator.cluster.x-k8s.io/v1alpha2
76+
kind: ControlPlaneProvider
77+
metadata:
78+
name: kubeadm
79+
namespace: kubeadm-control-plane-system
80+
annotations:
81+
"helm.sh/hook": "post-install"
82+
"helm.sh/hook-weight": "2"
83+
spec:
84+
configSecret:
85+
name: test-secret-name
86+
namespace: test-secret-namespace
87+
---
88+
# Source: cluster-api-operator/templates/core.yaml
89+
apiVersion: operator.cluster.x-k8s.io/v1alpha2
90+
kind: CoreProvider
91+
metadata:
92+
name: cluster-api
93+
namespace: capi-system
94+
annotations:
95+
"helm.sh/hook": "post-install"
96+
"helm.sh/hook-weight": "2"
97+
"argocd.argoproj.io/sync-wave": "2"
98+
spec:
99+
configSecret:
100+
name: test-secret-name
101+
namespace: test-secret-namespace
102+
---
103+
# Source: cluster-api-operator/templates/infra.yaml
104+
apiVersion: operator.cluster.x-k8s.io/v1alpha2
105+
kind: InfrastructureProvider
106+
metadata:
107+
name: docker
108+
namespace: docker-infrastructure-system
109+
annotations:
110+
"helm.sh/hook": "post-install"
111+
"helm.sh/hook-weight": "2"
112+
"argocd.argoproj.io/sync-wave": "2"
113+
spec:
114+
configSecret:
115+
name: test-secret-name
116+
namespace: test-secret-namespace
117+
manager:
118+
featureGates:
119+
ClusterTopology: true
120+
MachinePool: true

0 commit comments

Comments
 (0)