Test values overrides
Adds a test that loads the helmChart from the updated resource and verifies that `testOverride` (the value overrode in the test fixtures) changes from `false` to `true`. Signed-off-by: Dylan Arbour <arbourd@users.noreply.github.com>
This commit is contained in:
parent
6f0825c002
commit
c0bd4ab7d0
|
@ -133,6 +133,10 @@ var _ = Describe("HelmChartReconciler", func() {
|
|||
_ = k8sClient.Get(context.Background(), key, got)
|
||||
return got.Status.Artifact != nil && storage.ArtifactExist(*got.Status.Artifact)
|
||||
}, timeout, interval).Should(BeTrue())
|
||||
helmChart, err := loader.Load(storage.LocalPath(*got.Status.Artifact))
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
Expect(helmChart.Values["testDefault"]).To(BeTrue())
|
||||
Expect(helmChart.Values["testOverride"]).To(BeFalse())
|
||||
|
||||
By("Packaging a new chart version and regenerating the index")
|
||||
Expect(helmServer.PackageChartWithVersion(path.Join("testdata/charts/helmchart"), "0.2.0")).Should(Succeed())
|
||||
|
@ -585,13 +589,55 @@ var _ = Describe("HelmChartReconciler", func() {
|
|||
Expect(err).NotTo(HaveOccurred())
|
||||
|
||||
By("Expecting new artifact revision and GC")
|
||||
now := &sourcev1.HelmChart{}
|
||||
Eventually(func() bool {
|
||||
now := &sourcev1.HelmChart{}
|
||||
_ = k8sClient.Get(context.Background(), key, now)
|
||||
// Test revision change and garbage collection
|
||||
return now.Status.Artifact.Revision != got.Status.Artifact.Revision &&
|
||||
!storage.ArtifactExist(*got.Status.Artifact)
|
||||
}, timeout, interval).Should(BeTrue())
|
||||
helmChart, err := loader.Load(storage.LocalPath(*now.Status.Artifact))
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
Expect(helmChart.Values["testDefault"]).To(BeTrue())
|
||||
Expect(helmChart.Values["testOverride"]).To(BeFalse())
|
||||
|
||||
When("Setting valid valuesFile attribute", func() {
|
||||
updated := &sourcev1.HelmChart{}
|
||||
Expect(k8sClient.Get(context.Background(), key, updated)).To(Succeed())
|
||||
updated.Spec.ValuesFile = "./testdata/charts/helmchart/override.yaml"
|
||||
Expect(k8sClient.Update(context.Background(), updated)).To(Succeed())
|
||||
got := &sourcev1.HelmChart{}
|
||||
Eventually(func() bool {
|
||||
_ = k8sClient.Get(context.Background(), key, got)
|
||||
return got.Status.Artifact.Checksum != updated.Status.Artifact.Checksum &&
|
||||
storage.ArtifactExist(*got.Status.Artifact)
|
||||
}, timeout, interval).Should(BeTrue())
|
||||
f, err := os.Stat(storage.LocalPath(*got.Status.Artifact))
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
Expect(f.Size()).To(BeNumerically(">", 0))
|
||||
helmChart, err := loader.Load(storage.LocalPath(*got.Status.Artifact))
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
Expect(helmChart.Values["testOverride"]).To(BeTrue())
|
||||
})
|
||||
|
||||
When("Setting invalid valuesFile attribute", func() {
|
||||
updated := &sourcev1.HelmChart{}
|
||||
Expect(k8sClient.Get(context.Background(), key, updated)).To(Succeed())
|
||||
updated.Spec.ValuesFile = "./testdata/charts/helmchart/invalid.yaml"
|
||||
Expect(k8sClient.Update(context.Background(), updated)).To(Succeed())
|
||||
got := &sourcev1.HelmChart{}
|
||||
Eventually(func() bool {
|
||||
_ = k8sClient.Get(context.Background(), key, got)
|
||||
return got.Status.ObservedGeneration > updated.Status.ObservedGeneration &&
|
||||
storage.ArtifactExist(*got.Status.Artifact)
|
||||
}, timeout, interval).Should(BeTrue())
|
||||
f, err := os.Stat(storage.LocalPath(*got.Status.Artifact))
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
Expect(f.Size()).To(BeNumerically(">", 0))
|
||||
helmChart, err := loader.Load(storage.LocalPath(*got.Status.Artifact))
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
Expect(helmChart.Values["testOverride"]).To(BeTrue())
|
||||
})
|
||||
})
|
||||
|
||||
It("Creates artifacts with .tgz file", func() {
|
||||
|
@ -693,31 +739,6 @@ var _ = Describe("HelmChartReconciler", func() {
|
|||
return got.Status.Artifact != nil &&
|
||||
storage.ArtifactExist(*got.Status.Artifact)
|
||||
}, timeout, interval).Should(BeTrue())
|
||||
|
||||
When("Setting valid valuesFile attribute", func() {
|
||||
updated := &sourcev1.HelmChart{}
|
||||
Expect(k8sClient.Get(context.Background(), key, updated)).To(Succeed())
|
||||
chart.Spec.ValuesFile = "./charts/helmchart/override.yaml"
|
||||
Expect(k8sClient.Update(context.Background(), updated)).To(Succeed())
|
||||
got := &sourcev1.HelmChart{}
|
||||
Eventually(func() bool {
|
||||
_ = k8sClient.Get(context.Background(), key, got)
|
||||
return got.Status.Artifact != nil &&
|
||||
storage.ArtifactExist(*got.Status.Artifact)
|
||||
}, timeout, interval).Should(BeTrue())
|
||||
})
|
||||
|
||||
When("Setting invalid valuesFile attribute", func() {
|
||||
updated := &sourcev1.HelmChart{}
|
||||
Expect(k8sClient.Get(context.Background(), key, updated)).To(Succeed())
|
||||
chart.Spec.ValuesFile = "invalid.yaml"
|
||||
Expect(k8sClient.Update(context.Background(), updated)).To(Succeed())
|
||||
got := &sourcev1.HelmChart{}
|
||||
Eventually(func() bool {
|
||||
_ = k8sClient.Get(context.Background(), key, got)
|
||||
return got.Status.Artifact != nil && got.Status.Artifact.Revision == updated.Status.Artifact.Revision
|
||||
}, timeout, interval).Should(BeTrue())
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
|
@ -961,30 +982,47 @@ var _ = Describe("HelmChartReconciler", func() {
|
|||
return got.Status.Artifact != nil &&
|
||||
storage.ArtifactExist(*got.Status.Artifact)
|
||||
}, timeout, interval).Should(BeTrue())
|
||||
helmChart, err := loader.Load(storage.LocalPath(*got.Status.Artifact))
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
Expect(helmChart.Values["testDefault"]).To(BeTrue())
|
||||
Expect(helmChart.Values["testOverride"]).To(BeFalse())
|
||||
|
||||
When("Setting valid valuesFile attribute", func() {
|
||||
updated := &sourcev1.HelmChart{}
|
||||
Expect(k8sClient.Get(context.Background(), key, updated)).To(Succeed())
|
||||
chart.Spec.ValuesFile = "override.yaml"
|
||||
updated.Spec.ValuesFile = "./testdata/charts/helmchartwithdeps/override.yaml"
|
||||
Expect(k8sClient.Update(context.Background(), updated)).To(Succeed())
|
||||
got := &sourcev1.HelmChart{}
|
||||
Eventually(func() bool {
|
||||
_ = k8sClient.Get(context.Background(), key, got)
|
||||
return got.Status.Artifact != nil &&
|
||||
return got.Status.Artifact.Checksum != updated.Status.Artifact.Checksum &&
|
||||
storage.ArtifactExist(*got.Status.Artifact)
|
||||
}, timeout, interval).Should(BeTrue())
|
||||
f, err := os.Stat(storage.LocalPath(*got.Status.Artifact))
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
Expect(f.Size()).To(BeNumerically(">", 0))
|
||||
helmChart, err := loader.Load(storage.LocalPath(*got.Status.Artifact))
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
Expect(helmChart.Values["testOverride"]).To(BeTrue())
|
||||
})
|
||||
|
||||
When("Setting invalid valuesFile attribute", func() {
|
||||
updated := &sourcev1.HelmChart{}
|
||||
Expect(k8sClient.Get(context.Background(), key, updated)).To(Succeed())
|
||||
chart.Spec.ValuesFile = "./charts/helmchart/override.yaml"
|
||||
updated.Spec.ValuesFile = "./testdata/charts/helmchartwithdeps/invalid.yaml"
|
||||
Expect(k8sClient.Update(context.Background(), updated)).To(Succeed())
|
||||
got := &sourcev1.HelmChart{}
|
||||
Eventually(func() bool {
|
||||
_ = k8sClient.Get(context.Background(), key, got)
|
||||
return got.Status.Artifact != nil && got.Status.Artifact.Revision == updated.Status.Artifact.Revision
|
||||
return got.Status.ObservedGeneration > updated.Status.ObservedGeneration &&
|
||||
storage.ArtifactExist(*got.Status.Artifact)
|
||||
}, timeout, interval).Should(BeTrue())
|
||||
f, err := os.Stat(storage.LocalPath(*got.Status.Artifact))
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
Expect(f.Size()).To(BeNumerically(">", 0))
|
||||
helmChart, err := loader.Load(storage.LocalPath(*got.Status.Artifact))
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
Expect(helmChart.Values["testOverride"]).To(BeTrue())
|
||||
})
|
||||
})
|
||||
})
|
||||
|
|
|
@ -64,3 +64,7 @@ nodeSelector: {}
|
|||
tolerations: []
|
||||
|
||||
affinity: {}
|
||||
|
||||
# Values for tests
|
||||
# testDefault: true
|
||||
testOverride: true
|
||||
|
|
|
@ -64,3 +64,7 @@ nodeSelector: {}
|
|||
tolerations: []
|
||||
|
||||
affinity: {}
|
||||
|
||||
# Values for tests
|
||||
testDefault: true
|
||||
testOverride: false
|
||||
|
|
|
@ -0,0 +1,70 @@
|
|||
# Override values for helmchart.
|
||||
# This is a YAML-formatted file.
|
||||
# Declare variables to be passed into your templates.
|
||||
|
||||
replicaCount: 3
|
||||
|
||||
image:
|
||||
repository: nginx
|
||||
pullPolicy: IfNotPresent
|
||||
|
||||
imagePullSecrets: []
|
||||
nameOverride: ""
|
||||
fullnameOverride: ""
|
||||
|
||||
serviceAccount:
|
||||
# Specifies whether a service account should be created
|
||||
create: true
|
||||
# The name of the service account to use.
|
||||
# If not set and create is true, a name is generated using the fullname template
|
||||
name:
|
||||
|
||||
podSecurityContext: {}
|
||||
# fsGroup: 2000
|
||||
|
||||
securityContext: {}
|
||||
# capabilities:
|
||||
# drop:
|
||||
# - ALL
|
||||
# readOnlyRootFilesystem: true
|
||||
# runAsNonRoot: true
|
||||
# runAsUser: 1000
|
||||
|
||||
service:
|
||||
type: ClusterIP
|
||||
port: 80
|
||||
|
||||
ingress:
|
||||
enabled: false
|
||||
annotations: {}
|
||||
# kubernetes.io/ingress.class: nginx
|
||||
# kubernetes.io/tls-acme: "true"
|
||||
hosts:
|
||||
- host: chart-example.local
|
||||
paths: []
|
||||
tls: []
|
||||
# - secretName: chart-example-tls
|
||||
# hosts:
|
||||
# - chart-example.local
|
||||
|
||||
resources: {}
|
||||
# We usually recommend not to specify default resources and to leave this as a conscious
|
||||
# choice for the user. This also increases chances charts run on environments with little
|
||||
# resources, such as Minikube. If you do want to specify resources, uncomment the following
|
||||
# lines, adjust them as necessary, and remove the curly braces after 'resources:'.
|
||||
# limits:
|
||||
# cpu: 100m
|
||||
# memory: 128Mi
|
||||
# requests:
|
||||
# cpu: 100m
|
||||
# memory: 128Mi
|
||||
|
||||
nodeSelector: {}
|
||||
|
||||
tolerations: []
|
||||
|
||||
affinity: {}
|
||||
|
||||
# Values for tests
|
||||
# testDefault: true
|
||||
testOverride: true
|
|
@ -64,3 +64,7 @@ nodeSelector: {}
|
|||
tolerations: []
|
||||
|
||||
affinity: {}
|
||||
|
||||
# Values for tests
|
||||
testDefault: true
|
||||
testOverride: false
|
||||
|
|
Loading…
Reference in New Issue