feat(common)!: Release v3.0.0-beta1 (#278)

This commit is contained in:
Bernd Schorgers 2024-03-07 19:53:41 +01:00 committed by GitHub
parent deafcf75a1
commit b78483b0b8
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
88 changed files with 3697 additions and 1209 deletions

View file

@ -50,7 +50,16 @@ controllers:
ingress:
main:
enabled: true
hosts:
- host: "test.local"
paths:
- path: /
service:
name: main
port: http
tls:
- hosts:
- "test.local"
configMaps:
config:
@ -59,9 +68,6 @@ configMaps:
test: value 1
persistence:
config:
enabled: true
data:
type: configMap
name: |-

View file

@ -17,13 +17,19 @@ controllers:
ingress:
main:
enabled: true
hosts:
- host: "test.local"
paths:
- path: /
service:
name: main
port: http
tls:
- hosts:
- "test.local"
persistence:
config:
enabled: true
media:
enabled: true
type: persistentVolumeClaim
accessMode: ReadWriteOnce
size: 1Gi

View file

@ -3,6 +3,7 @@ controllers:
type: cronjob
cronjob:
timeZone: UTC
schedule: "*/20 * * * *"
containers:
main:
image:

View file

@ -11,10 +11,6 @@ service:
main:
enabled: false
ingress:
main:
enabled: false
probes:
liveness:
enabled: false

View file

@ -32,7 +32,6 @@ service:
ingress:
# -- Enable and configure ingress settings for the chart under this key.
main:
enabled: true
hosts:
- host: chart-example.local
paths:
@ -55,7 +54,6 @@ ingress:
# -- Configure persistence settings for the chart under this key.
persistence:
config:
enabled: true
type: persistentVolumeClaim
accessMode: ReadWriteOnce
size: 1Gi

View file

@ -0,0 +1,9 @@
ingress:
main:
hosts:
- host: "chart-example.local"
paths:
- path: /
service:
name: main
port: http

View file

@ -8,7 +8,8 @@ tests:
set:
configMaps:
config:
enabled: true
data:
test: test
asserts:
- hasDocuments:
count: 3
@ -31,7 +32,8 @@ tests:
set:
configMaps:
config:
enabled: true
data:
test: test
annotations:
test_annotation: test
labels:
@ -66,7 +68,8 @@ tests:
global_annotation: test
configMaps:
config:
enabled: true
data:
test: test
annotations:
test_annotation: test
labels:

View file

@ -22,6 +22,8 @@ tests:
configMaps:
config:
enabled: false
data:
test: test
asserts:
- hasDocuments:
count: 2
@ -38,11 +40,11 @@ tests:
set:
configMaps:
config:
enabled: true
data:
foo: bar
secondary:
enabled: true
data:
test: test
asserts:
- hasDocuments:
count: 4
@ -63,7 +65,8 @@ tests:
set:
configMaps:
config:
enabled: true
data:
test: test
asserts:
- hasDocuments:
count: 3
@ -79,7 +82,8 @@ tests:
set:
configMaps:
config:
enabled: true
data:
test: test
nameOverride: http
asserts:
- hasDocuments:

View file

@ -39,7 +39,7 @@ tests:
equal:
path: spec.template.spec.containers[0].args
value:
- |
- |-
echo hello
echo world

View file

@ -39,7 +39,7 @@ tests:
equal:
path: spec.template.spec.containers[0].command
value:
- |
- |-
/bin/sh
-c

View file

@ -94,6 +94,25 @@ tests:
fieldRef:
fieldPath: spec.nodeName
- it: Implicit ValueFrom in list should pass
set:
controllers.main.containers.main.env:
- name: DYNAMIC_ENV_FROM_LIST
fieldRef:
fieldPath: spec.nodeName
asserts:
- documentIndex: &DeploymentDoc 0
isKind:
of: Deployment
- documentIndex: *DeploymentDoc
equal:
path: spec.template.spec.containers[0].env[0]
value:
name: DYNAMIC_ENV_FROM_LIST
valueFrom:
fieldRef:
fieldPath: spec.nodeName
- it: Implicit ValueFrom should pass
set:
controllers.main.containers.main.env:

View file

@ -46,6 +46,10 @@ tests:
prefix: test
- configMapRef:
identifier: config
configMaps:
config:
data:
test: test
asserts:
- documentIndex: &DeploymentDoc 0
isKind:
@ -72,6 +76,10 @@ tests:
- secretRef:
identifier: secret
prefix: test
secrets:
secret:
stringData:
test: test
asserts:
- documentIndex: &DeploymentDoc 0
isKind:

View file

@ -0,0 +1,29 @@
---
# yaml-language-server: $schema=https://raw.githubusercontent.com/helm-unittest/helm-unittest/main/schema/helm-testsuite.json
suite: container restartPolicy
templates:
- common.yaml
tests:
- it: default should pass
asserts:
- documentIndex: 0
isKind:
of: Deployment
- documentIndex: 0
notExists:
path: spec.template.spec.containers[0].restartPolicy
- it: custom restartPolicy should pass
set:
controllers.main.containers:
main:
restartPolicy: Always
asserts:
- documentIndex: 0
isKind:
of: Deployment
- documentIndex: 0
equal:
path: spec.template.spec.containers[0].restartPolicy
value: Always

View file

@ -9,7 +9,6 @@ tests:
controllers.main.containers:
main:
nameOverride: template-test
controller: main
image:
repository: ghcr.io/mendhak/http-https-echo
asserts:
@ -25,7 +24,6 @@ tests:
set:
controllers.main.containers:
main:
controller: main
image:
repository: ghcr.io/mendhak/http-https-echo
asserts:
@ -42,7 +40,6 @@ tests:
controllers.main.containers:
main:
nameOverride: "{{ .Release.Name }}-container"
controller: main
image:
repository: ghcr.io/mendhak/http-https-echo
asserts:

View file

@ -3,6 +3,12 @@
suite: container probes
templates:
- common.yaml
set:
controllers.main.containers.main.probes.liveness.enabled: true
controllers.main.containers.main.probes.readiness.enabled: true
controllers.main.containers.main.probes.startup.enabled: true
tests:
- it: default should pass
set:
@ -40,9 +46,9 @@ tests:
equal:
path: spec.template.spec.containers[0].startupProbe
value:
failureThreshold: 30
failureThreshold: 3
initialDelaySeconds: 0
periodSeconds: 5
periodSeconds: 10
tcpSocket:
port: *port
timeoutSeconds: 1
@ -87,9 +93,9 @@ tests:
equal:
path: spec.template.spec.containers[0].startupProbe
value:
failureThreshold: 30
failureThreshold: 3
initialDelaySeconds: 0
periodSeconds: 5
periodSeconds: 10
tcpSocket:
port: *port
timeoutSeconds: 1
@ -130,9 +136,9 @@ tests:
equal:
path: spec.template.spec.containers[0].startupProbe
value:
failureThreshold: 30
failureThreshold: 3
initialDelaySeconds: 0
periodSeconds: 5
periodSeconds: 10
tcpSocket:
port: 80
timeoutSeconds: 1
@ -162,6 +168,7 @@ tests:
main:
ports:
http:
protocol: HTTP
port: &port 80
controllers.main.containers.main.probes:
@ -462,9 +469,9 @@ tests:
equal:
path: spec.template.spec.containers[0].startupProbe
value:
failureThreshold: 30
failureThreshold: 3
initialDelaySeconds: 0
periodSeconds: 5
periodSeconds: 10
tcpSocket:
port: *port
timeoutSeconds: 1

View file

@ -4,17 +4,6 @@ suite: Container validations
templates:
- common.yaml
tests:
- it: image required to be a dictionary
set:
controllers:
main:
containers:
test:
image: "test:latest"
asserts:
- failedTemplate:
errorMessage: "Image required to be a dictionary with repository and tag fields. (controller main, container test)"
- it: image repository is required
set:
controllers:

View file

@ -17,7 +17,8 @@ tests:
set:
persistence:
config:
enabled: true
accessMode: ReadWriteOnce
size: 1Gi
asserts:
- documentIndex: &DeploymentDoc 1
isKind:
@ -123,7 +124,6 @@ tests:
set:
persistence:
config:
enabled: true
accessMode: ReadWriteMany
size: 1G
globalMounts:
@ -143,7 +143,6 @@ tests:
set:
persistence:
config:
enabled: true
existingClaim: myClaim
globalMounts:
- path: /config
@ -164,7 +163,6 @@ tests:
set:
persistence:
config:
enabled: true
type: hostPath
hostPath: /tmp
globalMounts:
@ -184,7 +182,6 @@ tests:
set:
persistence:
config:
enabled: true
type: hostPath
hostPath: /dev
globalMounts:

View file

@ -6,16 +6,16 @@ templates:
tests:
- it: default cronjob configuration should pass
set:
controllers:
main:
type: cronjob
controllers.main.type: cronjob
controllers.main.cronjob.schedule: "*/20 * * * *"
asserts:
- documentIndex: &ControllerDoc 0
isKind:
of: CronJob
- documentIndex: *ControllerDoc
notExists:
equal:
path: spec.suspend
value: false
- documentIndex: *ControllerDoc
equal:
path: spec.schedule

View file

@ -14,8 +14,9 @@ tests:
isKind:
of: Job
- documentIndex: *ControllerDoc
notExists:
equal:
path: spec.suspend
value: false
- documentIndex: *ControllerDoc
notExists:
path: spec.ttlSecondsAfterFinished

View file

@ -3,6 +3,10 @@
suite: controller metadata cronjob
templates:
- common.yaml
set:
controllers.main.cronjob.schedule: "*/20 * * * *"
tests:
- it: default metadata should pass
set:

View file

@ -116,6 +116,7 @@ tests:
- it: cronjob should pass
set:
controllers.main.type: cronjob
controllers.main.cronjob.schedule: "*/20 * * * *"
asserts:
- documentIndex: &ControllerDoc 0
isKind:

View file

@ -3,10 +3,12 @@
suite: ingress metadata
templates:
- common.yaml
values:
- ../_values/ingress_main_default_hosts.yaml
tests:
- it: default metadata should pass
set:
ingress.main.enabled: true
asserts:
- documentIndex: &IngressDocument 2
isKind:
@ -26,7 +28,6 @@ tests:
- it: custom metadata should pass
set:
ingress.main:
enabled: true
annotations:
test_annotation: test
labels:
@ -58,7 +59,6 @@ tests:
annotations:
global_annotation: test
ingress.main:
enabled: true
annotations:
test_annotation: test
labels:

View file

@ -18,6 +18,8 @@ tests:
of: Ingress
- it: explicitly disabled should pass
values:
- ../_values/ingress_main_default_hosts.yaml
set:
ingress.main.enabled: false
asserts:
@ -33,6 +35,8 @@ tests:
of: Ingress
- it: explicitly enabled should pass
values:
- ../_values/ingress_main_default_hosts.yaml
set:
ingress.main.enabled: true
asserts:
@ -50,33 +54,18 @@ tests:
isKind:
of: Ingress
- it: multiple enabled should pass
- it: multiple ingress should pass
values:
- ../_values/ingress_main_default_hosts.yaml
set:
ingress.main.enabled: true
ingress.test.enabled: true
asserts:
- hasDocuments:
count: 4
- documentIndex: 0
not: true
isKind:
of: Ingress
- documentIndex: 1
not: true
isKind:
of: Ingress
- documentIndex: 2
isKind:
of: Ingress
- documentIndex: 3
isKind:
of: Ingress
- it: multiple with default enabled should pass
set:
ingress.main.enabled: true
ingress.test: {}
ingress.test:
hosts:
- host: "chart-example.local"
paths:
- path: /
service:
name: main
port: http
asserts:
- hasDocuments:
count: 4
@ -102,3 +91,35 @@ tests:
equal:
path: metadata.name
value: RELEASE-NAME-test
- it: multiple ingress with explicit disabled should pass
values:
- ../_values/ingress_main_default_hosts.yaml
set:
ingress.test:
enabled: false
hosts:
- host: "chart-example.local"
paths:
- path: /
service:
name: main
port: http
asserts:
- hasDocuments:
count: 3
- documentIndex: 0
not: true
isKind:
of: Ingress
- documentIndex: 1
not: true
isKind:
of: Ingress
- documentIndex: &FirstIngressDocument 2
isKind:
of: Ingress
- documentIndex: *FirstIngressDocument
equal:
path: metadata.name
value: RELEASE-NAME

View file

@ -3,10 +3,12 @@
suite: ingress service reference
templates:
- common.yaml
values:
- ../_values/ingress_main_default_hosts.yaml
tests:
- it: default should pass
set:
ingress.main.enabled: true
asserts:
- documentIndex: &IngressDocument 2
isKind:
@ -23,7 +25,6 @@ tests:
- it: custom service reference should pass
set:
ingress.main:
enabled: true
hosts:
- host: chart-test.local
paths:
@ -56,7 +57,6 @@ tests:
port: &http2Port 1880
ingress:
main:
enabled: true
className: "nginx"
hosts:
- host: http.chart-test.local

View file

@ -3,10 +3,12 @@
suite: ingress tls
templates:
- common.yaml
values:
- ../_values/ingress_main_default_hosts.yaml
tests:
- it: default should pass
set:
ingress.main.enabled: true
asserts:
- documentIndex: &IngressDocument 2
isKind:
@ -18,7 +20,6 @@ tests:
- it: tls enabled should pass
set:
ingress.main:
enabled: true
tls:
- secretName: test
hosts:
@ -38,7 +39,6 @@ tests:
- it: tls enabled without secret should pass
set:
ingress.main:
enabled: true
tls:
- hosts:
- hostname
@ -56,7 +56,6 @@ tests:
- it: tls enabled with secret template should pass
set:
ingress.main:
enabled: true
tls:
- secretName: "{{ .Release.Name }}-secret"
hosts:
@ -76,7 +75,6 @@ tests:
- it: tls enabled with secret template evaluate empty should pass
set:
ingress.main:
enabled: true
tls:
- secretName: '{{ "" }}'
hosts:

View file

@ -3,10 +3,12 @@
suite: ingress values
templates:
- common.yaml
values:
- ../_values/ingress_main_default_hosts.yaml
tests:
- it: default should pass
set:
ingress.main.enabled: true
asserts:
- documentIndex: &IngressDocument 2
isKind:
@ -23,7 +25,6 @@ tests:
- it: custom host and path should pass
set:
ingress.main:
enabled: true
hosts:
- host: chart-test.local
paths:
@ -46,10 +47,13 @@ tests:
- it: host with template should pass
set:
ingress.main:
enabled: true
hosts:
- host: "{{ .Release.Name }}.hostname"
paths:
- path: /
service:
name: main
port: http
asserts:
- documentIndex: &IngressDocument 2
isKind:
@ -62,7 +66,6 @@ tests:
- it: path with template should pass
set:
ingress.main:
enabled: true
hosts:
- host: chart-test.local
paths:
@ -81,7 +84,6 @@ tests:
- it: with defaultBackend should pass
set:
ingress.main:
enabled: true
defaultBackend: test
asserts:
- documentIndex: &IngressDocument 2

View file

@ -1,14 +1,19 @@
---
# yaml-language-server: $schema=https://raw.githubusercontent.com/helm-unittest/helm-unittest/main/schema/helm-testsuite.json
suite: networkPolicy metadata
set:
networkpolicies.main:
controller: main
policyTypes:
- Ingress
- Egress
rules: {}
templates:
- common.yaml
tests:
- it: default metadata should pass
set:
networkpolicies:
main:
enabled: true
asserts:
- documentIndex: &NetworkPolicyDocument 2
isKind:
@ -29,7 +34,6 @@ tests:
set:
networkpolicies:
main:
enabled: true
annotations:
test_annotation: test
labels:
@ -62,7 +66,6 @@ tests:
global_annotation: test
networkpolicies:
main:
enabled: true
annotations:
test_annotation: test
labels:

View file

@ -8,7 +8,11 @@ tests:
set:
networkpolicies:
main:
enabled: true
controller: main
policyTypes:
- Ingress
- Egress
rules: {}
asserts:
- hasDocuments:
count: 3
@ -24,7 +28,11 @@ tests:
set:
networkpolicies:
main:
enabled: true
controller: main
policyTypes:
- Ingress
- Egress
rules: {}
nameOverride: block-ingress
asserts:
- documentIndex: &NetworkPolicyDocument 2

View file

@ -8,8 +8,8 @@ tests:
set:
networkpolicies:
main:
enabled: true
controller: ""
rules: {}
asserts:
- failedTemplate:
errorMessage: "controller reference or podSelector is required for NetworkPolicy. (NetworkPolicy main)"
@ -18,8 +18,9 @@ tests:
set:
networkpolicies:
main:
enabled: true
controller: main
policyTypes: []
rules: {}
asserts:
- failedTemplate:
errorMessage: "policyTypes is required for NetworkPolicy. (NetworkPolicy main)"
@ -28,9 +29,10 @@ tests:
set:
networkpolicies:
main:
enabled: true
controller: main
policyTypes:
- test
rules: {}
asserts:
- failedTemplate:
errorMessage: "Not a valid policyType for NetworkPolicy. (NetworkPolicy main, value test)"

View file

@ -3,6 +3,7 @@
suite: NetworkPolicy values
templates:
- common.yaml
tests:
- it: main networkpolicy is disabled by default
asserts:
@ -17,9 +18,12 @@ tests:
- it: main networkpolicy can be enabled
set:
networkpolicies:
main:
enabled: true
networkpolicies.main:
controller: main
policyTypes:
- Ingress
- Egress
rules: {}
asserts:
- hasDocuments:
count: 3
@ -37,8 +41,11 @@ tests:
set:
networkpolicies:
main:
enabled: true
controller: main
policyTypes:
- Ingress
- Egress
rules: {}
asserts:
- documentIndex: &NetworkPolicyDocument 2
isKind:
@ -56,9 +63,12 @@ tests:
set:
networkpolicies:
main:
enabled: true
controller: main
policyTypes:
- Ingress
- Egress
podSelector: {}
rules: {}
asserts:
- documentIndex: &NetworkPolicyDocument 2
isKind:
@ -72,8 +82,10 @@ tests:
set:
networkpolicies:
main:
enabled: true
controller: main
policyTypes:
- Ingress
- Egress
rules:
ingress:
- {}

View file

@ -8,7 +8,8 @@ tests:
set:
persistence:
config:
enabled: true
accessMode: ReadWriteOnce
size: 1Gi
asserts:
- documentIndex: 1
isKind:
@ -25,12 +26,7 @@ tests:
set:
persistence:
existingClaim:
enabled: true
existingClaim: myClaim
mounts:
- controllers:
- main
mountPath: "/data"
asserts:
- documentIndex: 0
isKind:
@ -47,14 +43,9 @@ tests:
set:
persistence:
claimWithoutSuffix:
enabled: true
nameOverride: "-"
accessMode: ReadWriteMany
size: 1G
mounts:
- controllers:
- main
mountPath: "/data"
asserts:
- documentIndex: 1
isKind:
@ -71,14 +62,9 @@ tests:
set:
persistence:
claimWithNameOverride:
enabled: true
nameOverride: suffix
accessMode: ReadWriteMany
size: 1G
mounts:
- controllers:
- main
mountPath: "/data"
asserts:
- documentIndex: 1
isKind:

View file

@ -11,10 +11,6 @@ tests:
enabled: true
type: hostPath
hostPath: "/tmp1"
mounts:
- controllers:
- main
mountPath: "/data"
asserts:
- documentIndex: 0
isKind:
@ -35,10 +31,6 @@ tests:
type: hostPath
hostPath: "/tmp2"
hostPathType: "Directory"
mounts:
- controllers:
- main
mountPath: "/data2"
asserts:
- documentIndex: 0
isKind:

View file

@ -16,10 +16,6 @@ tests:
- path: "labels"
fieldRef:
fieldPath: metadata.labels
mounts:
- controllers:
- main
mountPath: "/data"
asserts:
- documentIndex: 0
isKind:
@ -42,10 +38,6 @@ tests:
enabled: true
type: configMap
name: mySettings
mounts:
- controllers:
- main
mountPath: "/data"
asserts:
- documentIndex: 0
isKind:
@ -65,10 +57,6 @@ tests:
enabled: true
type: configMap
name: '{{ include "bjw-s.common.lib.chart.names.fullname" $ }}-config'
mounts:
- controllers:
- main
mountPath: "/data"
asserts:
- documentIndex: 0
isKind:
@ -88,10 +76,6 @@ tests:
enabled: true
type: secret
name: mySettings
mounts:
- controllers:
- main
mountPath: "/data"
asserts:
- documentIndex: 0
isKind:
@ -111,10 +95,6 @@ tests:
enabled: true
type: secret
name: "{{ .Release.Name }}-config"
mounts:
- controllers:
- main
mountPath: "/data"
asserts:
- documentIndex: 0
isKind:
@ -135,10 +115,6 @@ tests:
type: nfs
server: 10.10.0.8
path: /tank/nas/library
mounts:
- controllers:
- main
mountPath: "/data"
asserts:
- documentIndex: 0
isKind:

View file

@ -17,7 +17,8 @@ tests:
set:
persistence:
config:
enabled: true
accessMode: ReadWriteOnce
size: 1Gi
asserts:
- documentIndex: &DeploymentDoc 1
isKind:
@ -48,7 +49,6 @@ tests:
persistence:
config:
enabled: true
existingClaim: test
advancedMounts:
main:

View file

@ -1,6 +1,6 @@
---
# yaml-language-server: $schema=https://raw.githubusercontent.com/helm-unittest/helm-unittest/main/schema/helm-testsuite.json
suite: pod sidecar containers
suite: pod with multiple containers
templates:
- common.yaml
tests:
@ -9,6 +9,7 @@ tests:
controllers.main.containers:
additional1:
nameOverride: template-test
dependsOn: main
image:
repository: test
tag: test
@ -25,6 +26,7 @@ tests:
set:
controllers.main.containers:
additional1:
dependsOn: main
image:
repository: test
tag: test
@ -42,6 +44,7 @@ tests:
controllers.main.containers:
additional1:
nameOverride: "{{ .Release.Name }}-container"
dependsOn: main
image:
repository: test
tag: test
@ -61,6 +64,7 @@ tests:
env:
main_env: value
additional1:
dependsOn: main
image:
repository: test
tag: test

View file

@ -7,6 +7,10 @@ tests:
- it: with default order
set:
controllers.main.containers:
main:
image:
repository: test
tag: test
additional1:
image:
repository: test
@ -26,60 +30,15 @@ tests:
- documentIndex: *DeploymentDocument
equal:
path: spec.template.spec.containers[0].name
value: main
- documentIndex: *DeploymentDocument
equal:
path: spec.template.spec.containers[1].name
value: additional1
- documentIndex: *DeploymentDocument
equal:
path: spec.template.spec.containers[2].name
value: additional2
# TODO: Remove this test case after "order" removal in v3
- it: with custom order
set:
controllers.main.containers:
main:
order: 2
additional1:
order: 3
image:
repository: test
tag: test
additional2:
order: 1
image:
repository: test
tag: test
additional3:
image:
repository: test
tag: test
asserts:
- documentIndex: &DeploymentDocument 0
isKind:
of: Deployment
- documentIndex: *DeploymentDocument
lengthEqual:
path: spec.template.spec.containers
count: 4
- documentIndex: *DeploymentDocument
equal:
path: spec.template.spec.containers[0].name
value: additional2
- documentIndex: *DeploymentDocument
equal:
path: spec.template.spec.containers[1].name
value: main
value: additional2
- documentIndex: *DeploymentDocument
equal:
path: spec.template.spec.containers[2].name
value: additional1
- documentIndex: *DeploymentDocument
equal:
path: spec.template.spec.containers[3].name
value: additional3
value: main
- it: with dependsOn
set:
@ -123,48 +82,3 @@ tests:
equal:
path: spec.template.spec.containers[3].name
value: additional2
# TODO: Remove this test case after "order" removal in v3
- it: with both order and dependsOn
set:
controllers.main.containers:
additional1:
dependsOn: additional3
image:
repository: test
tag: test
additional2:
dependsOn: additional3
order: 1
image:
repository: test
tag: test
additional3:
dependsOn: main
image:
repository: test
tag: test
asserts:
- documentIndex: &DeploymentDocument 0
isKind:
of: Deployment
- documentIndex: *DeploymentDocument
lengthEqual:
path: spec.template.spec.containers
count: 4
- documentIndex: *DeploymentDocument
equal:
path: spec.template.spec.containers[0].name
value: main
- documentIndex: *DeploymentDocument
equal:
path: spec.template.spec.containers[1].name
value: additional3
- documentIndex: *DeploymentDocument
equal:
path: spec.template.spec.containers[2].name
value: additional1
- documentIndex: *DeploymentDocument
equal:
path: spec.template.spec.containers[3].name
value: additional2

View file

@ -0,0 +1,39 @@
---
# yaml-language-server: $schema=https://raw.githubusercontent.com/helm-unittest/helm-unittest/main/schema/helm-testsuite.json
suite: pod enableServiceLinks
templates:
- common.yaml
tests:
- it: default should pass
asserts:
- documentIndex: 0
isKind:
of: Deployment
- documentIndex: 0
equal:
path: spec.template.spec.enableServiceLinks
value: false
- it: enabled in defaultPodOptions should pass
set:
defaultPodOptions.enableServiceLinks: true
asserts:
- documentIndex: 0
isKind:
of: Deployment
- documentIndex: 0
equal:
path: spec.template.spec.enableServiceLinks
value: true
- it: enabled in pod options should pass
set:
controllers.main.pod.enableServiceLinks: true
asserts:
- documentIndex: 0
isKind:
of: Deployment
- documentIndex: 0
equal:
path: spec.template.spec.enableServiceLinks
value: true

View file

@ -14,6 +14,17 @@ tests:
path: spec.replicas
value: 1
- it: nil should pass
set:
controllers.main.replicas: null
asserts:
- documentIndex: 0
isKind:
of: Deployment
- documentIndex: 0
notExists:
path: spec.replicas
- it: custom replicas should pass
set:
controllers.main.replicas: 3

View file

@ -52,6 +52,7 @@ tests:
enabled: false
image:
repository: ghcr.io/mendhak/http-https-echo
tag: test
asserts:
- documentIndex: &DeploymentDocument 0
isKind:
@ -60,37 +61,6 @@ tests:
notExists:
path: spec.template.spec.initContainers
# TODO: Remove this test case after "order" removal in v3
- it: custom order should pass
set:
controllers.main.initContainers:
init1:
order: 2
image:
repository: ghcr.io/mendhak/http-https-echo
tag: latest
init2:
order: 1
image:
repository: ghcr.io/mendhak/http-https-echo
tag: latest
asserts:
- documentIndex: &DeploymentDocument 0
isKind:
of: Deployment
- documentIndex: *DeploymentDocument
lengthEqual:
path: spec.template.spec.initContainers
count: 2
- documentIndex: *DeploymentDocument
equal:
path: spec.template.spec.initContainers[0].name
value: init2
- documentIndex: *DeploymentDocument
equal:
path: spec.template.spec.initContainers[1].name
value: init1
- it: with dependsOn
set:
controllers.main.initContainers:
@ -119,3 +89,28 @@ tests:
equal:
path: spec.template.spec.initContainers[1].name
value: init1
- it: with custom restartPolicy (sidecar)
set:
controllers.main.initContainers:
test:
image:
repository: ghcr.io/mendhak/http-https-echo
tag: latest
restartPolicy: Always
asserts:
- documentIndex: &DeploymentDocument 0
isKind:
of: Deployment
- documentIndex: *DeploymentDocument
lengthEqual:
path: spec.template.spec.initContainers
count: 1
- documentIndex: *DeploymentDocument
equal:
path: spec.template.spec.initContainers[0].name
value: test
- documentIndex: *DeploymentDocument
equal:
path: spec.template.spec.initContainers[0].restartPolicy
value: Always

View file

@ -3,10 +3,14 @@
suite: pvc datasource
templates:
- common.yaml
set:
persistence.config:
accessMode: ReadWriteOnce
size: 1Gi
tests:
- it: default should pass
set:
persistence.config.enabled: true
asserts:
- documentIndex: &PersistentVolumeClaimDocument 0
isKind:
@ -21,7 +25,6 @@ tests:
- it: with dataSource should pass
set:
persistence.config:
enabled: true
dataSource:
apiGroup: snapshot.storage.k8s.io
kind: VolumeSnapshot
@ -44,7 +47,6 @@ tests:
- it: templated dataSource name should pass
set:
persistence.config:
enabled: true
dataSource:
apiGroup: snapshot.storage.k8s.io
kind: VolumeSnapshot
@ -67,7 +69,6 @@ tests:
- it: with dataSourceRef should pass
set:
persistence.config:
enabled: true
dataSourceRef:
apiGroup: snapshot.storage.k8s.io
kind: VolumeSnapshot
@ -90,7 +91,6 @@ tests:
- it: templated dataSourceRef name should pass
set:
persistence.config:
enabled: true
dataSourceRef:
apiGroup: snapshot.storage.k8s.io
kind: VolumeSnapshot

View file

@ -3,10 +3,14 @@
suite: pvc metadata
templates:
- common.yaml
set:
persistence.config:
accessMode: ReadWriteOnce
size: 1Gi
tests:
- it: default should pass
set:
persistence.config.enabled: true
asserts:
- documentIndex: &PersistentVolumeClaimDocument 0
isKind:
@ -26,7 +30,6 @@ tests:
- it: retain enabled should pass
set:
persistence.config:
enabled: true
retain: true
asserts:
- documentIndex: &PersistentVolumeClaimDocument 0
@ -49,7 +52,6 @@ tests:
- it: custom metadata should pass
set:
persistence.config:
enabled: true
labels:
test_label: test
annotations:
@ -81,7 +83,6 @@ tests:
annotations:
global_annotation: test
persistence.config:
enabled: true
labels:
test_label: test
annotations:

View file

@ -3,8 +3,16 @@
suite: pvc names
templates:
- common.yaml
set:
persistence.config:
accessMode: ReadWriteOnce
size: 1Gi
tests:
- it: disabled should pass
set:
persistence.config.enabled: false
asserts:
- hasDocuments:
count: 2
@ -17,7 +25,7 @@ tests:
isKind:
of: PersistentVolumeClaim
- it: default should pass
- it: enabled should pass
set:
persistence.config.enabled: true
asserts:
@ -42,7 +50,6 @@ tests:
- it: without suffix should pass
set:
persistence.config:
enabled: true
nameOverride: "-"
asserts:
- documentIndex: &PersistentVolumeClaimDocument 0
@ -56,7 +63,6 @@ tests:
- it: with custom suffix should pass
set:
persistence.config:
enabled: true
nameOverride: "custom"
asserts:
- documentIndex: &PersistentVolumeClaimDocument 0

View file

@ -3,10 +3,14 @@
suite: pvc storageclass
templates:
- common.yaml
set:
persistence.config:
accessMode: ReadWriteOnce
size: 1Gi
tests:
- it: default should pass
set:
persistence.config.enabled: true
asserts:
- documentIndex: &PersistentVolumeClaimDocument 0
isKind:
@ -18,7 +22,6 @@ tests:
- it: custom should pass
set:
persistence.config:
enabled: true
storageClass: custom
asserts:
- documentIndex: &PersistentVolumeClaimDocument 0
@ -32,7 +35,6 @@ tests:
- it: empty should pass
set:
persistence.config:
enabled: true
storageClass: "-"
asserts:
- documentIndex: &PersistentVolumeClaimDocument 0

View file

@ -8,7 +8,8 @@ tests:
set:
secrets:
secret:
enabled: true
stringData:
test: test
asserts:
- hasDocuments:
count: 3
@ -31,7 +32,8 @@ tests:
set:
secrets:
secret:
enabled: true
stringData:
test: test
annotations:
test_annotation: test
labels:
@ -66,7 +68,8 @@ tests:
global_annotation: test
secrets:
secret:
enabled: true
stringData:
test: test
annotations:
test_annotation: test
labels:
@ -98,7 +101,8 @@ tests:
set:
secrets:
secret:
enabled: true
stringData:
test: test
type: &type kubernetes.io/service-account-token
asserts:
- hasDocuments:

View file

@ -22,6 +22,8 @@ tests:
secrets:
secret:
enabled: false
stringData:
test: test
asserts:
- hasDocuments:
count: 2
@ -39,10 +41,12 @@ tests:
secrets:
secret:
enabled: true
data:
stringData:
foo: bar
secondary:
enabled: true
stringData:
test: test
asserts:
- hasDocuments:
count: 4
@ -63,7 +67,8 @@ tests:
set:
secrets:
secret:
enabled: true
stringData:
test: test
asserts:
- hasDocuments:
count: 3
@ -79,7 +84,8 @@ tests:
set:
secrets:
secret:
enabled: true
stringData:
test: test
nameOverride: http
asserts:
- hasDocuments:

View file

@ -8,16 +8,15 @@ tests:
set:
secrets:
secret_1:
enabled: true
data:
stringData:
test: value 1
secret_2: # default enabled
data:
stringData:
test_1: value 1
test_2: value 2
test_disabled:
enabled: false
data:
stringData:
test: value 1
asserts:
- documentIndex: &ControllerDoc 0
@ -27,4 +26,4 @@ tests:
equal:
path: spec.template.metadata.annotations
value:
checksum/secrets: 4107837201f46be5279f7accdf3942edabd38f0eb534a61c91d2d7cba7ffc557
checksum/secrets: cd4e5076088172611ca1c43c659a275232d9eeb887acc20575ac141038b9aacb

View file

@ -3,6 +3,7 @@
suite: serviceMonitor values
templates:
- common.yaml
tests:
- it: a serviceMonitor is not created by default
asserts:
@ -20,6 +21,7 @@ tests:
serviceMonitor:
main:
enabled: false
serviceName: "{{ .Release.Name }}"
asserts:
- hasDocuments:
count: 2
@ -34,9 +36,9 @@ tests:
set:
serviceMonitor:
main:
enabled: true
labels:
test.label: testvalue
serviceName: "{{ .Release.Name }}"
endpoints:
- port: http
scheme: http
@ -83,8 +85,14 @@ tests:
set:
serviceMonitor:
main:
enabled: true
nameOverride: test
serviceName: "{{ .Release.Name }}"
endpoints:
- port: http
scheme: http
path: /metrics
interval: 1m
scrapeTimeout: 10s
asserts:
- hasDocuments:
count: 3
@ -107,8 +115,13 @@ tests:
set:
serviceMonitor:
main:
enabled: true
serviceName: "{{ .Release.Name }}"
endpoints:
- port: http
scheme: http
path: /metrics
interval: 1m
scrapeTimeout: 10s
asserts:
- hasDocuments:
count: 3
@ -131,10 +144,15 @@ tests:
set:
serviceMonitor:
main:
enabled: true
selector:
mySelector:
matchExpressions:
test: "true"
endpoints:
- port: http
scheme: http
path: /metrics
interval: 1m
scrapeTimeout: 10s
asserts:
- hasDocuments:
count: 3
@ -149,13 +167,15 @@ tests:
equal:
path: spec.selector
value:
mySelector:
matchExpressions:
test: "true"
- it: a serviceMonitor is created with targetLabels
set:
serviceMonitor:
main:
enabled: true
serviceName: "{{ .Release.Name }}"
endpoints:
- port: http
scheme: http
@ -163,8 +183,8 @@ tests:
interval: 1m
scrapeTimeout: 10s
targetLabels:
- testlabel1
- testlabel2
- testlabel1
- testlabel2
asserts:
- hasDocuments:
count: 3

View file

@ -0,0 +1,3 @@
{
"$ref": "file://../common/values.schema.json"
}

View file

@ -10,6 +10,7 @@ controllers:
service:
main:
controller: main
ports:
http:
port: 8080