Skip to content

Commit

Permalink
Merge pull request #549 from willie-yao/helm-test
Browse files Browse the repository at this point in the history
馃尡  Add more cases to helm test
  • Loading branch information
k8s-ci-robot committed Jun 7, 2024
2 parents c4ef701 + 58d8e15 commit d2d1dad
Show file tree
Hide file tree
Showing 2 changed files with 165 additions and 13 deletions.
58 changes: 45 additions & 13 deletions test/e2e/helm_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ var _ = Describe("Create a proper set of manifests when using helm charts", func
manifests, err := fullRun.Run(nil)
Expect(err).ToNot(HaveOccurred())
fullChartInstall, err := os.ReadFile(filepath.Join(customManifestsFolder, "full-chart-install.yaml"))
Expect(manifests).To(Equal(string(fullChartInstall)))
Expect(manifests).To(MatchYAML(string(fullChartInstall)))
})

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

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

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

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

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

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

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

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

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

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

It("should deploy core, bootstrap, control plane when only infra and addon is specified", func() {
Expand All @@ -204,7 +204,7 @@ var _ = Describe("Create a proper set of manifests when using helm charts", func
Expect(manifests).ToNot(BeEmpty())
expectedManifests, err := os.ReadFile(filepath.Join(customManifestsFolder, "only-infra-and-addon.yaml"))
Expect(err).ToNot(HaveOccurred())
Expect(manifests).To(Equal(string(expectedManifests)))
Expect(manifests).To(MatchYAML(string(expectedManifests)))
})
It("should deploy core and infra with feature gates enabled", func() {
manifests, err := helmChart.Run(map[string]string{
Expand All @@ -227,6 +227,38 @@ var _ = Describe("Create a proper set of manifests when using helm charts", func
Expect(manifests).ToNot(BeEmpty())
expectedManifests, err := os.ReadFile(filepath.Join(customManifestsFolder, "feature-gates.yaml"))
Expect(err).ToNot(HaveOccurred())
Expect(manifests).To(Equal(string(expectedManifests)))
Expect(manifests).To(MatchYAML(string(expectedManifests)))
})
It("should deploy all providers with manager defined but no feature gates enabled", func() {
manifests, err := helmChart.Run(map[string]string{
"configSecret.name": "test-secret-name",
"configSecret.namespace": "test-secret-namespace",
"infrastructure": "azure",
"addon": "helm",
"core": "cluster-api",
"manager.cert-manager.enabled": "false",
"manager.cert-manager.installCRDs": "false",
})
Expect(err).ToNot(HaveOccurred())
Expect(manifests).ToNot(BeEmpty())
expectedManifests, err := os.ReadFile(filepath.Join(customManifestsFolder, "all-providers-latest-versions.yaml"))
Expect(err).ToNot(HaveOccurred())
Expect(manifests).To(MatchYAML(string(expectedManifests)))
})
It("should deploy all providers when manager is defined but another infrastructure spec field is defined", func() {
manifests, err := helmChart.Run(map[string]string{
"core": "cluster-api",
"controlPlane": "kubeadm",
"bootstrap": "kubeadm",
"infrastructure": "docker",
"addon": "helm",
"manager.featureGates.core.ClusterTopology": "true",
"manager.featureGates.core.MachinePool": "true",
})
Expect(err).ToNot(HaveOccurred())
Expect(manifests).ToNot(BeEmpty())
expectedManifests, err := os.ReadFile(filepath.Join(customManifestsFolder, "manager-defined-missing-other-infra-spec.yaml"))
Expect(err).ToNot(HaveOccurred())
Expect(manifests).To(MatchYAML(string(expectedManifests)))
})
})
120 changes: 120 additions & 0 deletions test/e2e/resources/manager-defined-missing-other-infra-spec.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
---
# Source: cluster-api-operator/templates/addon.yaml
apiVersion: v1
kind: Namespace
metadata:
annotations:
"helm.sh/hook": "post-install"
"helm.sh/hook-weight": "1"
"argocd.argoproj.io/sync-wave": "1"
name: helm-addon-system
---
# Source: cluster-api-operator/templates/bootstrap.yaml
apiVersion: v1
kind: Namespace
metadata:
annotations:
"helm.sh/hook": "post-install"
"helm.sh/hook-weight": "1"
name: kubeadm-bootstrap-system
---
# Source: cluster-api-operator/templates/control-plane.yaml
apiVersion: v1
kind: Namespace
metadata:
annotations:
"helm.sh/hook": "post-install"
"helm.sh/hook-weight": "1"
name: kubeadm-control-plane-system
---
# Source: cluster-api-operator/templates/core.yaml
apiVersion: v1
kind: Namespace
metadata:
annotations:
"helm.sh/hook": "post-install"
"helm.sh/hook-weight": "1"
name: capi-system
---
# Source: cluster-api-operator/templates/infra.yaml
apiVersion: v1
kind: Namespace
metadata:
annotations:
"helm.sh/hook": "post-install"
"helm.sh/hook-weight": "1"
"argocd.argoproj.io/sync-wave": "1"
name: docker-infrastructure-system
---
# Source: cluster-api-operator/templates/addon.yaml
apiVersion: operator.cluster.x-k8s.io/v1alpha2
kind: AddonProvider
metadata:
name: helm
namespace: helm-addon-system
annotations:
"helm.sh/hook": "post-install"
"helm.sh/hook-weight": "2"
"argocd.argoproj.io/sync-wave": "2"
---
# Source: cluster-api-operator/templates/bootstrap.yaml
apiVersion: operator.cluster.x-k8s.io/v1alpha2
kind: BootstrapProvider
metadata:
name: kubeadm
namespace: kubeadm-bootstrap-system
annotations:
"helm.sh/hook": "post-install"
"helm.sh/hook-weight": "2"
spec:
configSecret:
name: test-secret-name
namespace: test-secret-namespace
---
# Source: cluster-api-operator/templates/control-plane.yaml
apiVersion: operator.cluster.x-k8s.io/v1alpha2
kind: ControlPlaneProvider
metadata:
name: kubeadm
namespace: kubeadm-control-plane-system
annotations:
"helm.sh/hook": "post-install"
"helm.sh/hook-weight": "2"
spec:
configSecret:
name: test-secret-name
namespace: test-secret-namespace
---
# Source: cluster-api-operator/templates/core.yaml
apiVersion: operator.cluster.x-k8s.io/v1alpha2
kind: CoreProvider
metadata:
name: cluster-api
namespace: capi-system
annotations:
"helm.sh/hook": "post-install"
"helm.sh/hook-weight": "2"
"argocd.argoproj.io/sync-wave": "2"
spec:
configSecret:
name: test-secret-name
namespace: test-secret-namespace
---
# Source: cluster-api-operator/templates/infra.yaml
apiVersion: operator.cluster.x-k8s.io/v1alpha2
kind: InfrastructureProvider
metadata:
name: docker
namespace: docker-infrastructure-system
annotations:
"helm.sh/hook": "post-install"
"helm.sh/hook-weight": "2"
"argocd.argoproj.io/sync-wave": "2"
spec:
configSecret:
name: test-secret-name
namespace: test-secret-namespace
manager:
featureGates:
ClusterTopology: true
MachinePool: true

0 comments on commit d2d1dad

Please sign in to comment.