Skip to content

Commit

Permalink
fix: failing unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
apetrovYa committed Jan 25, 2024
1 parent 61b06c5 commit aa25b68
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 39 deletions.
3 changes: 0 additions & 3 deletions templates/statefulset/manifest.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,6 @@ spec:
{{- include "lib.annotations" . | nindent 8 }}
{{- include "app.podAnnotations" . | nindent 8 }}
{{- include "app.additionalPodAnnotations" . | nindent 8 }}
{{- include "app.configChecksum" . | nindent 8 }}
spec:
{{- if .Values.nodeName }}
{{/* NOTE: nodeName takes precedence over the nodeSelector.
Expand Down Expand Up @@ -296,11 +295,9 @@ spec:
- nfs: an NFS mount on the host that shares a pod's lifetime;
*/}}
volumes:
{{- if and .Values.defaultConfig.mountPath .Values.defaultConfig.name }}
- name: conf
configMap:
name: {{ include "lib.appName" . }}-conf
{{- end }}
{{- $volumes := concat .Values.volumes .Values.additionalVolumes }}
{{- if $volumes }}
{{- range $volume := $volumes }}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
suite: app deployment
suite: app statefulset
release:
name: unittest
namespace: kube-app
templates:
- deployment/manifest.yaml
- statefulset/manifest.yaml
- configuration/manifest.yaml
- configuration/secret.envs.yaml
tests:
Expand All @@ -12,12 +12,41 @@ tests:
- hasDocuments:
count: 1
- isKind:
of: Deployment
of: StatefulSet
- isSubset:
path: spec.strategy
path: spec.updateStrategy
content:
type: RollingUpdate
template: deployment/manifest.yaml
rollingUpdate:
maxUnavailable: 1
partition: 0
- isSubset:
path: spec.selector
content:
matchLabels:
app.kubernetes.io/component: app
app.kubernetes.io/instance: unittest
app.kubernetes.io/managed-by: Helm
app.kubernetes.io/name: kubernetes-stateful-chart
helm.sh/chart: kubernetes-stateful-chart-1.0.0
- equal:
path: spec.replicas
value: 1
- equal:
path: spec.minReadySeconds
value: 0
- equal:
path: spec.revisionHistoryLimit
value: 10
- equal:
path: spec.serviceName
value: unittest-kubernetes-stateful-chart-app
- equal:
path: spec.volumeClaimTemplates
value: []
- equal:
path: spec.podManagementPolicy
value: OrderedReady
template: statefulset/manifest.yaml
- it: should be created with the full configuration
set:
namespaceOverride: kube-app
Expand Down Expand Up @@ -143,10 +172,7 @@ tests:
value: 2
- isNotNull:
path: spec.template.spec.containers
- equal:
path: spec.strategy["type"]
value: Recreate
template: deployment/manifest.yaml
template: statefulset/manifest.yaml
- it: should accept init containers expressed with golang templates
set:
initContainers:
Expand Down Expand Up @@ -179,7 +205,7 @@ tests:
asserts:
- isNotNull:
path: spec.template.spec.initContainers
template: deployment/manifest.yaml
template: statefulset/manifest.yaml
- it: should accept init containers expressed with golang templates as default and additional group
set:
initContainers:
Expand Down Expand Up @@ -232,7 +258,7 @@ tests:
asserts:
- isNotNull:
path: spec.template.spec.initContainers
template: deployment/manifest.yaml
template: statefulset/manifest.yaml
- it: should construct final initContainers list correctly
set:
initContainers:
Expand Down Expand Up @@ -278,7 +304,7 @@ tests:
name: check-postgresql
count: 1
any: true
template: deployment/manifest.yaml
template: statefulset/manifest.yaml
- it: should use internalEnvSecret instead of the environment variables
set:
include: true
Expand All @@ -289,7 +315,7 @@ tests:
- equal:
path: spec.template.spec.containers[0].envFrom[0].secretRef.name
value: 'packages-internal-secret'
template: deployment/manifest.yaml
template: statefulset/manifest.yaml
- it: should correctly render args
set:
args: [ "--arg1", "--arg2" ]
Expand All @@ -299,7 +325,7 @@ tests:
- equal:
path: spec.template.spec.containers[0].args
value: [ "--arg1", "--arg2" ]
template: deployment/manifest.yaml
template: statefulset/manifest.yaml
- it: should correctly render entrypoint
set:
entrypoint: [ "command1", "--arg1" ]
Expand All @@ -309,7 +335,7 @@ tests:
- equal:
path: spec.template.spec.containers[0].command
value: [ "command1", "--arg1" ]
template: deployment/manifest.yaml
template: statefulset/manifest.yaml
- it: should overwrite args with values from customArgs
set:
args: [ "--arg1", "--arg2" ]
Expand All @@ -320,7 +346,7 @@ tests:
- equal:
path: spec.template.spec.containers[0].args
value: [ "--im-new-here" ]
template: deployment/manifest.yaml
template: statefulset/manifest.yaml
- it: customEntrypoint should overwrite entrypoint
set:
entrypoint: [ "bash", "-c" ]
Expand All @@ -331,7 +357,7 @@ tests:
- equal:
path: spec.template.spec.containers[0].command
value: [ "im-new-here", "let-me-run-something" ]
template: deployment/manifest.yaml
template: statefulset/manifest.yaml
- it: should use externalEnvSecret instead of the environment variables and internalEnvSecret
set:
include: true
Expand All @@ -343,7 +369,7 @@ tests:
- equal:
path: spec.template.spec.containers[0].envFrom[0].secretRef.name
value: 'packages-external-secret'
template: deployment/manifest.yaml
template: statefulset/manifest.yaml
- it: should use built secret resource by its reference name
set:
include: true
Expand All @@ -355,7 +381,7 @@ tests:
- equal:
path: spec.template.spec.containers[0].envFrom[0].secretRef.name
value: 'app-packages-envs'
template: deployment/manifest.yaml
template: statefulset/manifest.yaml
- it: should add volumes and volumeMounts to the application specification
set:
volumes:
Expand Down Expand Up @@ -403,7 +429,7 @@ tests:
secretFile: /etc/ceph/admin.secret
user: admin
name: volume-due
template: deployment/manifest.yaml
template: statefulset/manifest.yaml
- it: should allow to inject all the settings
set:
include: true # This is default
Expand Down Expand Up @@ -631,13 +657,10 @@ tests:
- equal:
path: metadata.name
value: unittest-kubernetes-stateful-chart-sample
- equal:
path: spec.strategy.type
value: Recreate
- equal:
path: spec.replicas
value: 2
template: deployment/manifest.yaml
template: statefulset/manifest.yaml
- it: should allow to use templating in podLabels and podAnnotations
set:
podLabels:
Expand All @@ -652,7 +675,7 @@ tests:
- hasDocuments:
count: 1
- isKind:
of: Deployment
of: StatefulSet
- equal:
path: spec.template.metadata.labels["release/name"]
value: unittest
Expand All @@ -665,38 +688,38 @@ tests:
- equal:
path: spec.template.metadata.annotations["release/namespace"]
value: kube-app
template: deployment/manifest.yaml
template: statefulset/manifest.yaml
- it: should not add checksum annotation on secret, when internalEnvSecret is set
set:
internalEnvSecret: "another-secret-envs"
asserts:
- hasDocuments:
count: 1
- isKind:
of: Deployment
of: StatefulSet
- notExists:
path: spec.template.metadata.annotations["checksum/envs"]
template: deployment/manifest.yaml
template: statefulset/manifest.yaml
- it: should not add checksum annotation on secret, when externalEnvSecret is set
set:
externalEnvSecret: "another-secret-envs"
asserts:
- hasDocuments:
count: 1
- isKind:
of: Deployment
of: StatefulSet
- notExists:
path: spec.template.metadata.annotations["checksum/envs"]
template: deployment/manifest.yaml
template: statefulset/manifest.yaml
- it: should not add checksum annotation on config, when it is not defined
asserts:
- hasDocuments:
count: 1
- isKind:
of: Deployment
of: StatefulSet
- notExists:
path: spec.template.metadata.annotations["checksum/config"]
template: deployment/manifest.yaml
template: statefulset/manifest.yaml
- it: should add checksum annotation on config, when it is defined
set:
defaultConfig.mountPath: "/sample-app"
Expand All @@ -705,10 +728,10 @@ tests:
- hasDocuments:
count: 1
- isKind:
of: Deployment
of: StatefulSet
- exists:
path: spec.template.metadata.annotations["checksum/config"]
template: deployment/manifest.yaml
template: statefulset/manifest.yaml
- it: should merge and overwrite values in probes
set:
startupProbe:
Expand Down Expand Up @@ -775,4 +798,4 @@ tests:
httpGet:
path: "/overwriten"
port: "overwriten"
template: deployment/manifest.yaml
template: statefulset/manifest.yaml

0 comments on commit aa25b68

Please sign in to comment.