feat(common)!: Migrate library chart

This commit is contained in:
Bᴇʀɴᴅ Sᴄʜᴏʀɢᴇʀs 2022-08-07 11:45:41 +02:00
parent 49ebc2bb2f
commit a1a80f5ff5
No known key found for this signature in database
GPG key ID: BC5E2BD907F9A8EC
59 changed files with 499 additions and 885 deletions

View file

@ -0,0 +1,167 @@
suite: addon codeserver
templates:
- common.yaml
tests:
- it: default should pass
asserts:
- hasDocuments:
count: 2
- documentIndex: &DeploymentDocument 0
isKind:
of: Deployment
- documentIndex: 1
isKind:
of: Service
- documentIndex: *DeploymentDocument
not: true
equal:
path: spec.template.spec.containers[0].name
value: codeserver
- it: addon enabled should pass
set:
addons:
codeserver:
enabled: true
volumeMounts:
- name: "config"
mountPath: "/data/config"
asserts:
- hasDocuments:
count: 3
- documentIndex: 0
isKind:
of: Service
- documentIndex: &DeploymentDocument 1
isKind:
of: Deployment
- documentIndex: &AddonServiceDocument 2
isKind:
of: Service
- documentIndex: *DeploymentDocument
equal:
path: spec.template.spec.containers[1].name
value: codeserver
- documentIndex: *AddonServiceDocument
equal:
path: metadata.name
value: RELEASE-NAME-common-chart
- it: addon enabled with deployKey should pass
set:
addons:
codeserver:
enabled: true
git:
deployKey: test
volumeMounts:
- name: "config"
mountPath: "/data/config"
asserts:
- hasDocuments:
count: 4
- documentIndex: &AddonDeployKeySecretDocument 0
isKind:
of: Secret
- documentIndex: &DeploymentDocument 2
isKind:
of: Deployment
- documentIndex: *DeploymentDocument
contains:
path: spec.template.spec.containers[1].volumeMounts
content:
mountPath: /root/.ssh/id_rsa
name: deploykey
subPath: id_rsa
- documentIndex: *DeploymentDocument
contains:
path: spec.template.spec.volumes
content:
name: deploykey
secret:
defaultMode: 256
items:
- key: id_rsa
path: id_rsa
secretName: RELEASE-NAME-common-chart-deploykey
- documentIndex: *AddonDeployKeySecretDocument
equal:
path: metadata.name
value: RELEASE-NAME-common-chart-deploykey
- it: addon enabled with InlineBase64 deployKey should pass
set:
addons:
codeserver:
enabled: true
git:
deployKeyBase64: dGVzdEtleQ==
volumeMounts:
- name: "config"
mountPath: "/data/config"
asserts:
- hasDocuments:
count: 4
- documentIndex: &AddonDeployKeySecretDocument 0
isKind:
of: Secret
- documentIndex: &DeploymentDocument 2
isKind:
of: Deployment
- documentIndex: *DeploymentDocument
contains:
path: spec.template.spec.containers[1].volumeMounts
content:
mountPath: /root/.ssh/id_rsa
name: deploykey
subPath: id_rsa
- documentIndex: *DeploymentDocument
contains:
path: spec.template.spec.volumes
content:
name: deploykey
secret:
defaultMode: 256
items:
- key: id_rsa
path: id_rsa
secretName: RELEASE-NAME-common-chart-deploykey
- documentIndex: *AddonDeployKeySecretDocument
equal:
path: metadata.name
value: RELEASE-NAME-common-chart-deploykey
- it: addon enabled with existingSecret deployKey should pass
set:
addons:
codeserver:
enabled: true
git:
deployKeySecret: test-secret
volumeMounts:
- name: "config"
mountPath: "/data/config"
asserts:
- hasDocuments:
count: 3
- documentIndex: &DeploymentDocument 1
isKind:
of: Deployment
- documentIndex: *DeploymentDocument
contains:
path: spec.template.spec.containers[1].volumeMounts
content:
mountPath: /root/.ssh/id_rsa
name: deploykey
subPath: id_rsa
- documentIndex: *DeploymentDocument
contains:
path: spec.template.spec.volumes
content:
name: deploykey
secret:
defaultMode: 256
items:
- key: id_rsa
path: id_rsa
secretName: test-secret

View file

@ -0,0 +1,38 @@
suite: addon netshoot
templates:
- common.yaml
tests:
- it: default should pass
asserts:
- hasDocuments:
count: 2
- documentIndex: &DeploymentDocument 0
isKind:
of: Deployment
- documentIndex: 1
isKind:
of: Service
- documentIndex: *DeploymentDocument
not: true
equal:
path: spec.template.spec.containers[0].name
value: netshoot
- it: addon enabled should pass
set:
addons:
netshoot:
enabled: true
asserts:
- hasDocuments:
count: 2
- documentIndex: &DeploymentDocument 0
isKind:
of: Deployment
- documentIndex: 1
isKind:
of: Service
- documentIndex: *DeploymentDocument
equal:
path: spec.template.spec.containers[1].name
value: netshoot

View file

@ -0,0 +1,180 @@
suite: addon vpn
templates:
- common.yaml
tests:
- it: default should pass
asserts:
- hasDocuments:
count: 2
- documentIndex: &DeploymentDocument 0
isKind:
of: Deployment
- documentIndex: 1
isKind:
of: Service
- documentIndex: *DeploymentDocument
not: true
equal:
path: spec.template.spec.containers[0].name
value: vpn
- it: addon enabled should pass
set:
addons:
vpn:
enabled: true
asserts:
- hasDocuments:
count: 2
- documentIndex: &DeploymentDocument 0
isKind:
of: Deployment
- documentIndex: 1
isKind:
of: Service
- documentIndex: *DeploymentDocument
equal:
path: spec.template.spec.containers[1].name
value: openvpn
- it: addon enabled with configFile should pass
set:
addons:
vpn:
enabled: true
configFile: test
asserts:
- hasDocuments:
count: 3
- documentIndex: &AddonVPNConfigSecretDocument 0
isKind:
of: Secret
- documentIndex: &DeploymentDocument 1
isKind:
of: Deployment
- documentIndex: *DeploymentDocument
contains:
path: spec.template.spec.containers[1].volumeMounts
content:
mountPath: /vpn/vpn.conf
name: vpnconfig
subPath: vpnConfigfile
- documentIndex: *DeploymentDocument
contains:
path: spec.template.spec.volumes
content:
name: vpnconfig
secret:
items:
- key: vpnConfigfile
path: vpnConfigfile
secretName: RELEASE-NAME-common-chart-vpnconfig
- documentIndex: *AddonVPNConfigSecretDocument
equal:
path: metadata.name
value: RELEASE-NAME-common-chart-vpnconfig
- it: addon enabled with existing configFile secret should pass
set:
addons:
vpn:
enabled: true
configFileSecret: test-secret
asserts:
- hasDocuments:
count: 2
- documentIndex: &DeploymentDocument 0
isKind:
of: Deployment
- documentIndex: *DeploymentDocument
contains:
path: spec.template.spec.containers[1].volumeMounts
content:
mountPath: /vpn/vpn.conf
name: vpnconfig
subPath: vpnConfigfile
- documentIndex: *DeploymentDocument
contains:
path: spec.template.spec.volumes
content:
name: vpnconfig
secret:
items:
- key: vpnConfigfile
path: vpnConfigfile
secretName: test-secret
- it: addon enabled with managed secret should pass
set:
addons:
vpn:
enabled: true
openvpn:
auth: |
<auth>
asserts:
- hasDocuments:
count: 3
- documentIndex: &SecretDocument 0
isKind:
of: Secret
- documentIndex: &DeploymentDocument 1
isKind:
of: Deployment
- documentIndex: 2
isKind:
of: Service
- documentIndex: *DeploymentDocument
not: true
equal:
path: spec.template.spec.containers[0].name
value: vpn
- it: addon enabled with custom env vars dict should pass
set:
addons:
vpn:
enabled: true
env:
int: 1
float: 1.5
string: value_of_env
template: "{{ .Release.Name }}-admin"
asserts:
- hasDocuments:
count: 2
- documentIndex: &DeploymentDocument 0
isKind:
of: Deployment
- documentIndex: &ServiceDocument 1
isKind:
of: Service
- documentIndex: *DeploymentDocument
not: true
equal:
path: spec.template.spec.containers[1].name
value: vpn
- documentIndex: *DeploymentDocument
equal:
path: spec.template.spec.containers[1].env[0]
value:
name: float
value: "1.5"
- documentIndex: *DeploymentDocument
equal:
path: spec.template.spec.containers[1].env[1]
value:
name: int
value: "1"
- documentIndex: *DeploymentDocument
equal:
path: spec.template.spec.containers[1].env[2]
value:
name: string
value: value_of_env
- documentIndex: *DeploymentDocument
equal:
path: spec.template.spec.containers[1].env[3]
value:
name: template
value: RELEASE-NAME-admin

View file

@ -0,0 +1,87 @@
suite: configmap metadata
templates:
- common.yaml
tests:
- it: default metadata should pass
set:
configmap:
config:
enabled: true
asserts:
- documentIndex: &ConfigmapDocument 0
isKind:
of: ConfigMap
- documentIndex: *ConfigmapDocument
isNull:
path: metadata.annotations
- documentIndex: *ConfigmapDocument
equal:
path: metadata.labels
value:
app.kubernetes.io/instance: RELEASE-NAME
app.kubernetes.io/managed-by: Helm
app.kubernetes.io/name: common-chart
helm.sh/chart: common-chart-0.1.0
- it: custom metadata should pass
set:
configmap:
config:
enabled: true
annotations:
test_annotation: test
labels:
test_label: test
asserts:
- documentIndex: &ConfigmapDocument 0
isKind:
of: ConfigMap
- documentIndex: *ConfigmapDocument
equal:
path: metadata.annotations
value:
test_annotation: test
- documentIndex: *ConfigmapDocument
equal:
path: metadata.labels
value:
app.kubernetes.io/instance: RELEASE-NAME
app.kubernetes.io/managed-by: Helm
app.kubernetes.io/name: common-chart
helm.sh/chart: common-chart-0.1.0
test_label: test
- it: custom metadata with global metadata should pass
set:
global:
labels:
global_label: test
annotations:
global_annotation: test
configmap:
config:
enabled: true
annotations:
test_annotation: test
labels:
test_label: test
asserts:
- documentIndex: &ConfigmapDocument 0
isKind:
of: ConfigMap
- documentIndex: *ConfigmapDocument
equal:
path: metadata.annotations
value:
global_annotation: test
test_annotation: test
- documentIndex: *ConfigmapDocument
equal:
path: metadata.labels
value:
app.kubernetes.io/instance: RELEASE-NAME
app.kubernetes.io/managed-by: Helm
app.kubernetes.io/name: common-chart
global_label: test
helm.sh/chart: common-chart-0.1.0
test_label: test

View file

@ -0,0 +1,91 @@
suite: configMap names
templates:
- common.yaml
tests:
- it: default should pass
asserts:
- hasDocuments:
count: 2
- documentIndex: 0
not: true
isKind:
of: ConfigMap
- documentIndex: 1
not: true
isKind:
of: ConfigMap
- it: with disabled configMap should pass
set:
configmap:
config:
enabled: false
asserts:
- hasDocuments:
count: 2
- documentIndex: 0
not: true
isKind:
of: ConfigMap
- documentIndex: 1
not: true
isKind:
of: ConfigMap
- it: with multiple configMap should pass
set:
configmap:
config:
enabled: true
data:
foo: bar
secondary:
enabled: true
asserts:
- hasDocuments:
count: 4
- documentIndex: 0
isKind:
of: ConfigMap
- documentIndex: 0
isNotNull:
path: metadata.name
- documentIndex: 1
isKind:
of: ConfigMap
- documentIndex: 1
isNotNull:
path: metadata.name
- it: default name should pass
set:
configmap:
config:
enabled: true
asserts:
- hasDocuments:
count: 3
- documentIndex: 0
isKind:
of: ConfigMap
- documentIndex: 0
equal:
path: metadata.name
value: RELEASE-NAME-common-chart-config
- it: with nameOverride should pass
set:
configmap:
config:
enabled: true
nameOverride: http
asserts:
- hasDocuments:
count: 3
- documentIndex: 0
isKind:
of: ConfigMap
- documentIndex: 0
equal:
path: metadata.name
value: RELEASE-NAME-common-chart-http

View file

@ -0,0 +1,18 @@
suite: configmap Pod metadata
templates:
- common.yaml
tests:
- it: default metadata should pass
set:
configmap:
config:
enabled: true
asserts:
- documentIndex: &ControllerDoc 1
isKind:
of: Deployment
- documentIndex: *ControllerDoc
equal:
path: spec.template.metadata.annotations
value:
checksum/config: 3cd90a9f7d2c08b3d9d41d1be650110f4974009dcaf0a3d9e0616c90d80e1d38

View file

@ -0,0 +1,41 @@
suite: container args override
templates:
- common.yaml
tests:
- it: default should pass
asserts:
- documentIndex: 0
isKind:
of: Deployment
- documentIndex: 0
isNull:
path: spec.template.spec.containers[0].args
- it: single string should pass
set:
args: sleep infinity
asserts:
- documentIndex: 0
isKind:
of: Deployment
- documentIndex: 0
equal:
path: spec.template.spec.containers[0].args
value:
- sleep infinity
- it: list of strings should pass
set:
args:
- sleep
- infinity
asserts:
- documentIndex: 0
isKind:
of: Deployment
- documentIndex: 0
equal:
path: spec.template.spec.containers[0].args
value:
- sleep
- infinity

View file

@ -0,0 +1,41 @@
suite: container command override
templates:
- common.yaml
tests:
- it: default should pass
asserts:
- documentIndex: 0
isKind:
of: Deployment
- documentIndex: 0
isNull:
path: spec.template.spec.containers[0].command
- it: single string should pass
set:
command: /bin/sh
asserts:
- documentIndex: 0
isKind:
of: Deployment
- documentIndex: 0
equal:
path: spec.template.spec.containers[0].command
value:
- /bin/sh
- it: list of strings should pass
set:
command:
- /bin/sh
- -c
asserts:
- documentIndex: 0
isKind:
of: Deployment
- documentIndex: 0
equal:
path: spec.template.spec.containers[0].command
value:
- /bin/sh
- -c

View file

@ -0,0 +1,154 @@
suite: container env values
templates:
- common.yaml
tests:
- it: default should pass
asserts:
- documentIndex: &DeploymentDoc 0
isKind:
of: Deployment
- documentIndex: *DeploymentDoc
isNull:
path: spec.template.spec.containers[0].env
- it: KeyValue string should pass
set:
env:
string: value_of_env
asserts:
- documentIndex: &DeploymentDoc 0
isKind:
of: Deployment
- documentIndex: *DeploymentDoc
equal:
path: spec.template.spec.containers[0].env[0]
value:
name: string
value: value_of_env
- it: KeyValue float should pass
set:
env:
string: 4.2
asserts:
- documentIndex: &DeploymentDoc 0
isKind:
of: Deployment
- documentIndex: *DeploymentDoc
equal:
path: spec.template.spec.containers[0].env[0]
value:
name: string
value: "4.2"
- it: KeyValue int should pass
set:
env:
string: 1
asserts:
- documentIndex: &DeploymentDoc 0
isKind:
of: Deployment
- documentIndex: *DeploymentDoc
equal:
path: spec.template.spec.containers[0].env[0]
value:
name: string
value: "1"
- it: List should pass
set:
env:
- name: STATIC_ENV_FROM_LIST
value: STATIC_ENV_VALUE_FROM_LIST
asserts:
- documentIndex: &DeploymentDoc 0
isKind:
of: Deployment
- documentIndex: *DeploymentDoc
equal:
path: spec.template.spec.containers[0].env[0]
value:
name: STATIC_ENV_FROM_LIST
value: STATIC_ENV_VALUE_FROM_LIST
- it: Explicit ValueFrom in list should pass
set:
env:
- name: DYNAMIC_ENV_FROM_LIST
valueFrom:
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:
env:
DYNAMIC_ENV:
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
valueFrom:
fieldRef:
fieldPath: spec.nodeName
- it: Templated value should pass
set:
env:
DYNAMIC_ENV: "{{ .Release.Name }}-admin"
asserts:
- documentIndex: &DeploymentDoc 0
isKind:
of: Deployment
- documentIndex: *DeploymentDoc
equal:
path: spec.template.spec.containers[0].env[0]
value:
name: DYNAMIC_ENV
value: RELEASE-NAME-admin
- it: Combined KeyValue with Explicit ValueFrom should pass
set:
env:
STATIC_ENV: static
DYNAMIC_ENV:
valueFrom:
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
valueFrom:
fieldRef:
fieldPath: spec.nodeName
- documentIndex: *DeploymentDoc
equal:
path: spec.template.spec.containers[0].env[1]
value:
name: STATIC_ENV
value: static

View file

@ -0,0 +1,43 @@
suite: container envFrom values
templates:
- common.yaml
tests:
- it: default should pass
asserts:
- documentIndex: &DeploymentDoc 0
isKind:
of: Deployment
- documentIndex: *DeploymentDoc
isNull:
path: spec.template.spec.containers[0].envFrom
- it: explicit envFrom should pass
set:
envFrom:
- secretRef:
name: myCustomSecret
asserts:
- documentIndex: &DeploymentDoc 0
isKind:
of: Deployment
- documentIndex: *DeploymentDoc
equal:
path: spec.template.spec.containers[0].envFrom[0]
value:
secretRef:
name: myCustomSecret
- it: from secret should pass
set:
secret:
STATIC_SECRET: value_of_secret
asserts:
- documentIndex: &DeploymentDoc 0
isKind:
of: Deployment
- documentIndex: *DeploymentDoc
equal:
path: spec.template.spec.containers[0].envFrom[0]
value:
secretRef:
name: RELEASE-NAME-common-chart

View file

@ -0,0 +1,95 @@
suite: container ports
templates:
- common.yaml
tests:
- it: default should pass
asserts:
- documentIndex: 0
isKind:
of: Deployment
- documentIndex: 0
equal:
path: spec.template.spec.containers[0].ports[0]
value:
containerPort: null
name: http
protocol: TCP
- it: custom port should pass
set:
service:
main:
ports:
http:
enabled: false
server:
enabled: true
port: 8080
asserts:
- documentIndex: 0
isKind:
of: Deployment
- documentIndex: 0
equal:
path: spec.template.spec.containers[0].ports[0]
value:
containerPort: 8080
name: server
protocol: TCP
- it: HTTP protocol should pass
set:
service:
main:
ports:
http:
protocol: HTTP
asserts:
- documentIndex: 0
isKind:
of: Deployment
- documentIndex: 0
equal:
path: spec.template.spec.containers[0].ports[0]
value:
containerPort: null
name: http
protocol: TCP
- it: HTTPS protocol should pass
set:
service:
main:
ports:
http:
protocol: HTTPS
asserts:
- documentIndex: 0
isKind:
of: Deployment
- documentIndex: 0
equal:
path: spec.template.spec.containers[0].ports[0]
value:
containerPort: null
name: http
protocol: TCP
- it: UDP protocol should pass
set:
service:
main:
ports:
http:
protocol: UDP
asserts:
- documentIndex: 0
isKind:
of: Deployment
- documentIndex: 0
equal:
path: spec.template.spec.containers[0].ports[0]
value:
containerPort: null
name: http
protocol: UDP

View file

@ -0,0 +1,122 @@
suite: container volumeMounts
templates:
- common.yaml
tests:
- it: no persistence should pass
asserts:
- documentIndex: &DeploymentDoc 0
isKind:
of: Deployment
- documentIndex: *DeploymentDoc
isNull:
path: spec.template.spec.containers[0].volumeMounts
- it: default should pass
set:
persistence:
config:
enabled: true
asserts:
- documentIndex: &DeploymentDoc 1
isKind:
of: Deployment
- documentIndex: *DeploymentDoc
equal:
path: spec.template.spec.containers[0].volumeMounts[0]
value:
name: config
mountPath: /config
- it: emptyDir should pass
set:
persistence:
cache:
enabled: true
type: emptyDir
asserts:
- documentIndex: &DeploymentDoc 0
isKind:
of: Deployment
- documentIndex: *DeploymentDoc
equal:
path: spec.template.spec.containers[0].volumeMounts[0]
value:
name: cache
mountPath: /cache
- it: custom mountPath should pass
set:
persistence:
config:
enabled: true
mountPath: /custom
accessMode: ReadWriteMany
size: 1G
asserts:
- documentIndex: &DeploymentDoc 1
isKind:
of: Deployment
- documentIndex: *DeploymentDoc
equal:
path: spec.template.spec.containers[0].volumeMounts[0]
value:
name: config
mountPath: /custom
- it: mount with subPath should pass
set:
persistence:
config:
enabled: true
existingClaim: myClaim
subPath: "mySubPath"
asserts:
- documentIndex: &DeploymentDoc 0
isKind:
of: Deployment
- documentIndex: *DeploymentDoc
equal:
path: spec.template.spec.containers[0].volumeMounts[0]
value:
name: config
mountPath: /config
subPath: mySubPath
- it: hostPath with custom mountPath should pass
set:
persistence:
config:
enabled: true
type: hostPath
mountPath: /data
hostPath: /tmp
asserts:
- documentIndex: &DeploymentDoc 0
isKind:
of: Deployment
- documentIndex: *DeploymentDoc
equal:
path: spec.template.spec.containers[0].volumeMounts[0]
value:
name: config
mountPath: /data
- it: hostPath mount with subPath should pass
set:
persistence:
config:
enabled: true
type: hostPath
hostPath: /dev
subPath: mySubPath
asserts:
- documentIndex: &DeploymentDoc 0
isKind:
of: Deployment
- documentIndex: *DeploymentDoc
equal:
path: spec.template.spec.containers[0].volumeMounts[0]
value:
name: config
mountPath: /dev
subPath: mySubPath

View file

@ -0,0 +1,83 @@
suite: controller metadata daemonset
templates:
- common.yaml
tests:
- it: default metadata should pass
set:
controller.type: daemonset
asserts:
- documentIndex: &ControllerDoc 0
isKind:
of: DaemonSet
- documentIndex: *ControllerDoc
isNull:
path: metadata.annotations
- documentIndex: *ControllerDoc
equal:
path: metadata.labels
value:
app.kubernetes.io/instance: RELEASE-NAME
app.kubernetes.io/managed-by: Helm
app.kubernetes.io/name: common-chart
helm.sh/chart: common-chart-0.1.0
- it: custom metadata should pass
set:
controller:
type: daemonset
annotations:
test_annotation: test
labels:
test_label: test
asserts:
- documentIndex: &ControllerDoc 0
isKind:
of: DaemonSet
- documentIndex: *ControllerDoc
equal:
path: metadata.annotations
value:
test_annotation: test
- documentIndex: *ControllerDoc
equal:
path: metadata.labels
value:
app.kubernetes.io/instance: RELEASE-NAME
app.kubernetes.io/managed-by: Helm
app.kubernetes.io/name: common-chart
helm.sh/chart: common-chart-0.1.0
test_label: test
- it: custom metadata with global metadata should pass
set:
global:
labels:
global_label: test
annotations:
global_annotation: test
controller:
type: daemonset
annotations:
test_annotation: test
labels:
test_label: test
asserts:
- documentIndex: &ControllerDoc 0
isKind:
of: DaemonSet
- documentIndex: *ControllerDoc
equal:
path: metadata.annotations
value:
global_annotation: test
test_annotation: test
- documentIndex: *ControllerDoc
equal:
path: metadata.labels
value:
app.kubernetes.io/instance: RELEASE-NAME
app.kubernetes.io/managed-by: Helm
app.kubernetes.io/name: common-chart
global_label: test
helm.sh/chart: common-chart-0.1.0
test_label: test

View file

@ -0,0 +1,83 @@
suite: controller metadata deployment
templates:
- common.yaml
tests:
- it: default metadata should pass
set:
controller.type: deployment
asserts:
- documentIndex: &ControllerDoc 0
isKind:
of: Deployment
- documentIndex: *ControllerDoc
isNull:
path: metadata.annotations
- documentIndex: *ControllerDoc
equal:
path: metadata.labels
value:
app.kubernetes.io/instance: RELEASE-NAME
app.kubernetes.io/managed-by: Helm
app.kubernetes.io/name: common-chart
helm.sh/chart: common-chart-0.1.0
- it: custom metadata should pass
set:
controller:
type: deployment
annotations:
test_annotation: test
labels:
test_label: test
asserts:
- documentIndex: &ControllerDoc 0
isKind:
of: Deployment
- documentIndex: *ControllerDoc
equal:
path: metadata.annotations
value:
test_annotation: test
- documentIndex: *ControllerDoc
equal:
path: metadata.labels
value:
app.kubernetes.io/instance: RELEASE-NAME
app.kubernetes.io/managed-by: Helm
app.kubernetes.io/name: common-chart
helm.sh/chart: common-chart-0.1.0
test_label: test
- it: custom metadata with global metadata should pass
set:
global:
labels:
global_label: test
annotations:
global_annotation: test
controller:
type: deployment
annotations:
test_annotation: test
labels:
test_label: test
asserts:
- documentIndex: &ControllerDoc 0
isKind:
of: Deployment
- documentIndex: *ControllerDoc
equal:
path: metadata.annotations
value:
global_annotation: test
test_annotation: test
- documentIndex: *ControllerDoc
equal:
path: metadata.labels
value:
app.kubernetes.io/instance: RELEASE-NAME
app.kubernetes.io/managed-by: Helm
app.kubernetes.io/name: common-chart
global_label: test
helm.sh/chart: common-chart-0.1.0
test_label: test

View file

@ -0,0 +1,83 @@
suite: controller metadata statefulset
templates:
- common.yaml
tests:
- it: default metadata should pass
set:
controller.type: statefulset
asserts:
- documentIndex: &ControllerDoc 0
isKind:
of: StatefulSet
- documentIndex: *ControllerDoc
isNull:
path: metadata.annotations
- documentIndex: *ControllerDoc
equal:
path: metadata.labels
value:
app.kubernetes.io/instance: RELEASE-NAME
app.kubernetes.io/managed-by: Helm
app.kubernetes.io/name: common-chart
helm.sh/chart: common-chart-0.1.0
- it: custom metadata should pass
set:
controller:
type: statefulset
annotations:
test_annotation: test
labels:
test_label: test
asserts:
- documentIndex: &ControllerDoc 0
isKind:
of: StatefulSet
- documentIndex: *ControllerDoc
equal:
path: metadata.annotations
value:
test_annotation: test
- documentIndex: *ControllerDoc
equal:
path: metadata.labels
value:
app.kubernetes.io/instance: RELEASE-NAME
app.kubernetes.io/managed-by: Helm
app.kubernetes.io/name: common-chart
helm.sh/chart: common-chart-0.1.0
test_label: test
- it: custom metadata with global metadata should pass
set:
global:
labels:
global_label: test
annotations:
global_annotation: test
controller:
type: statefulset
annotations:
test_annotation: test
labels:
test_label: test
asserts:
- documentIndex: &ControllerDoc 0
isKind:
of: StatefulSet
- documentIndex: *ControllerDoc
equal:
path: metadata.annotations
value:
global_annotation: test
test_annotation: test
- documentIndex: *ControllerDoc
equal:
path: metadata.labels
value:
app.kubernetes.io/instance: RELEASE-NAME
app.kubernetes.io/managed-by: Helm
app.kubernetes.io/name: common-chart
global_label: test
helm.sh/chart: common-chart-0.1.0
test_label: test

View file

@ -0,0 +1,56 @@
suite: controller types
templates:
- common.yaml
tests:
- it: default should pass
asserts:
- documentIndex: &ControllerDoc 0
isKind:
of: Deployment
- documentIndex: *ControllerDoc
equal:
path: metadata.name
value: RELEASE-NAME-common-chart
- it: daemonset should pass
set:
controller.type: daemonset
asserts:
- documentIndex: &ControllerDoc 0
isKind:
of: DaemonSet
- documentIndex: *ControllerDoc
equal:
path: metadata.name
value: RELEASE-NAME-common-chart
- it: statefulset should pass
set:
controller.type: statefulset
asserts:
- documentIndex: &ControllerDoc 0
isKind:
of: StatefulSet
- documentIndex: *ControllerDoc
equal:
path: metadata.name
value: RELEASE-NAME-common-chart
- it: disabled should pass
set:
controller.enabled: false
asserts:
- hasDocuments:
count: 1
- documentIndex: &ControllerDoc 0
not: true
isKind:
of: StatefulSet
- documentIndex: *ControllerDoc
not: true
isKind:
of: DaemonSet
- documentIndex: *ControllerDoc
not: true
isKind:
of: Controller

View file

@ -0,0 +1,83 @@
suite: ingress metadata
templates:
- common.yaml
tests:
- it: default metadata should pass
set:
ingress.main.enabled: true
asserts:
- documentIndex: &IngressDocument 2
isKind:
of: Ingress
- documentIndex: *IngressDocument
isNull:
path: metadata.annotations
- documentIndex: *IngressDocument
equal:
path: metadata.labels
value:
app.kubernetes.io/instance: RELEASE-NAME
app.kubernetes.io/managed-by: Helm
app.kubernetes.io/name: common-chart
helm.sh/chart: common-chart-0.1.0
- it: custom metadata should pass
set:
ingress.main:
enabled: true
annotations:
test_annotation: test
labels:
test_label: test
asserts:
- documentIndex: &IngressDocument 2
isKind:
of: Ingress
- documentIndex: *IngressDocument
equal:
path: metadata.annotations
value:
test_annotation: test
- documentIndex: *IngressDocument
equal:
path: metadata.labels
value:
app.kubernetes.io/instance: RELEASE-NAME
app.kubernetes.io/managed-by: Helm
app.kubernetes.io/name: common-chart
helm.sh/chart: common-chart-0.1.0
test_label: test
- it: custom metadata with global metadata should pass
set:
global:
labels:
global_label: test
annotations:
global_annotation: test
ingress.main:
enabled: true
annotations:
test_annotation: test
labels:
test_label: test
asserts:
- documentIndex: &IngressDocument 2
isKind:
of: Ingress
- documentIndex: *IngressDocument
equal:
path: metadata.annotations
value:
global_annotation: test
test_annotation: test
- documentIndex: *IngressDocument
equal:
path: metadata.labels
value:
app.kubernetes.io/instance: RELEASE-NAME
app.kubernetes.io/managed-by: Helm
app.kubernetes.io/name: common-chart
global_label: test
helm.sh/chart: common-chart-0.1.0
test_label: test

View file

@ -0,0 +1,71 @@
suite: ingress presence
templates:
- common.yaml
tests:
- it: default should pass
asserts:
- hasDocuments:
count: 2
- documentIndex: 0
not: true
isKind:
of: Ingress
- documentIndex: 1
not: true
isKind:
of: Ingress
- it: explicitly disabled should pass
set:
ingress.main.enabled: false
asserts:
- hasDocuments:
count: 2
- documentIndex: 0
not: true
isKind:
of: Ingress
- documentIndex: 1
not: true
isKind:
of: Ingress
- it: explicitly enabled should pass
set:
ingress.main.enabled: true
asserts:
- hasDocuments:
count: 3
- documentIndex: 0
not: true
isKind:
of: Ingress
- documentIndex: 1
not: true
isKind:
of: Ingress
- documentIndex: 2
isKind:
of: Ingress
- it: multiple enabled should pass
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

View file

@ -0,0 +1,39 @@
suite: ingress service reference
templates:
- common.yaml
tests:
- it: default should pass
set:
ingress.main.enabled: true
asserts:
- documentIndex: &IngressDocument 2
isKind:
of: Ingress
- documentIndex: *IngressDocument
equal:
path: spec.rules[0].http.paths[0].backend
value:
serviceName: RELEASE-NAME-common-chart
servicePort: null
- it: custom service reference should pass
set:
ingress.main:
enabled: true
hosts:
- host: chart-test.local
paths:
- path: /
service:
name: pathService
port: 1234
asserts:
- documentIndex: &IngressDocument 2
isKind:
of: Ingress
- documentIndex: *IngressDocument
equal:
path: spec.rules[0].http.paths[0].backend
value:
serviceName: pathService
servicePort: 1234

View file

@ -0,0 +1,72 @@
suite: ingress tls
templates:
- common.yaml
tests:
- it: default should pass
set:
ingress.main.enabled: true
asserts:
- documentIndex: &IngressDocument 2
isKind:
of: Ingress
- documentIndex: *IngressDocument
isNull:
path: spec.tls
- it: tls enabled should pass
set:
ingress.main:
enabled: true
tls:
- secretName: test
hosts:
- hostname
asserts:
- documentIndex: &IngressDocument 2
isKind:
of: Ingress
- documentIndex: *IngressDocument
equal:
path: spec.tls[0]
value:
secretName: test
hosts:
- hostname
- it: tls enabled without secret should pass
set:
ingress.main:
enabled: true
tls:
- hosts:
- hostname
asserts:
- documentIndex: &IngressDocument 2
isKind:
of: Ingress
- documentIndex: *IngressDocument
equal:
path: spec.tls[0]
value:
hosts:
- hostname
- it: tls enabled with secret template should pass
set:
ingress.main:
enabled: true
tls:
- secretName: "{{ .Release.Name }}-secret"
hosts:
- hostname
asserts:
- documentIndex: &IngressDocument 2
isKind:
of: Ingress
- documentIndex: *IngressDocument
equal:
path: spec.tls[0]
value:
secretName: RELEASE-NAME-secret
hosts:
- hostname

View file

@ -0,0 +1,72 @@
suite: ingress values
templates:
- common.yaml
tests:
- it: default should pass
set:
ingress.main.enabled: true
asserts:
- documentIndex: &IngressDocument 2
isKind:
of: Ingress
- documentIndex: *IngressDocument
equal:
path: spec.rules[0].host
value: chart-example.local
- documentIndex: *IngressDocument
equal:
path: spec.rules[0].http.paths[0].path
value: "/"
- it: custom host and path should pass
set:
ingress.main:
enabled: true
hosts:
- host: chart-test.local
paths:
- path: /test
asserts:
- documentIndex: &IngressDocument 2
isKind:
of: Ingress
- documentIndex: *IngressDocument
equal:
path: spec.rules[0].host
value: chart-test.local
- documentIndex: *IngressDocument
equal:
path: spec.rules[0].http.paths[0].path
value: "/test"
- it: host with template should pass
set:
ingress.main:
enabled: true
hosts:
- host: "{{ .Release.Name }}.hostname"
asserts:
- documentIndex: &IngressDocument 2
isKind:
of: Ingress
- documentIndex: *IngressDocument
equal:
path: spec.rules[0].host
value: RELEASE-NAME.hostname
- it: path with template should pass
set:
ingress.main:
enabled: true
hosts:
- host: chart-test.local
paths:
- path: "/{{ .Release.Name }}.path"
asserts:
- documentIndex: &IngressDocument 2
isKind:
of: Ingress
- documentIndex: *IngressDocument
equal:
path: spec.rules[0].http.paths[0].path
value: "/RELEASE-NAME.path"

View file

@ -0,0 +1,78 @@
suite: persistence claimnames
templates:
- common.yaml
tests:
- it: default should pass
set:
persistence:
config:
enabled: true
asserts:
- documentIndex: 1
isKind:
of: Deployment
- documentIndex: 1
equal:
path: spec.template.spec.volumes[0]
value:
name: config
persistentVolumeClaim:
claimName: RELEASE-NAME-common-chart-config
- it: with existingClaim should pass
set:
persistence:
existingClaim:
enabled: true
existingClaim: myClaim
asserts:
- documentIndex: 0
isKind:
of: Deployment
- documentIndex: 0
equal:
path: spec.template.spec.volumes[0]
value:
name: existingClaim
persistentVolumeClaim:
claimName: myClaim
- it: disabled suffix should pass
set:
persistence:
claimWithoutSuffix:
enabled: true
nameOverride: "-"
accessMode: ReadWriteMany
size: 1G
asserts:
- documentIndex: 1
isKind:
of: Deployment
- documentIndex: 1
equal:
path: spec.template.spec.volumes[0]
value:
name: claimWithoutSuffix
persistentVolumeClaim:
claimName: RELEASE-NAME-common-chart
- it: custom suffix should pass
set:
persistence:
claimWithNameOverride:
enabled: true
nameOverride: suffix
accessMode: ReadWriteMany
size: 1G
asserts:
- documentIndex: 1
isKind:
of: Deployment
- documentIndex: 1
equal:
path: spec.template.spec.volumes[0]
value:
name: claimWithNameOverride
persistentVolumeClaim:
claimName: RELEASE-NAME-common-chart-suffix

View file

@ -0,0 +1,60 @@
suite: persistence emptydir
templates:
- common.yaml
tests:
- it: default emptyDir should pass
set:
persistence:
config:
enabled: true
type: emptyDir
asserts:
- documentIndex: 0
isKind:
of: Deployment
- documentIndex: 0
equal:
path: spec.template.spec.volumes[0]
value:
name: config
emptyDir: {}
- it: emptyDir with medium should pass
set:
persistence:
config:
enabled: true
type: emptyDir
medium: memory
asserts:
- documentIndex: 0
isKind:
of: Deployment
- documentIndex: 0
equal:
path: spec.template.spec.volumes[0]
value:
name: config
emptyDir:
medium: memory
- it: emptyDir with medium and sizeLimit should pass
set:
persistence:
config:
enabled: true
type: emptyDir
medium: memory
sizeLimit: 1Gi
asserts:
- documentIndex: 0
isKind:
of: Deployment
- documentIndex: 0
equal:
path: spec.template.spec.volumes[0]
value:
name: config
emptyDir:
medium: memory
sizeLimit: 1Gi

View file

@ -0,0 +1,45 @@
suite: persistence hostpath
templates:
- common.yaml
tests:
- it: hostPath should pass
set:
persistence:
hostpathmounts-data:
enabled: true
type: hostPath
hostPath: "/tmp1"
mountPath: "/data"
asserts:
- documentIndex: 0
isKind:
of: Deployment
- documentIndex: 0
equal:
path: spec.template.spec.volumes[0]
value:
name: hostpathmounts-data
hostPath:
path: /tmp1
- it: hostPath with type should pass
set:
persistence:
hostpathmounts-with-type:
enabled: true
type: hostPath
hostPath: "/tmp2"
hostPathType: "Directory"
mountPath: "/data2"
asserts:
- documentIndex: 0
isKind:
of: Deployment
- documentIndex: 0
equal:
path: spec.template.spec.volumes[0]
value:
name: hostpathmounts-with-type
hostPath:
path: /tmp2
type: Directory

View file

@ -0,0 +1,127 @@
suite: persistence types
templates:
- common.yaml
tests:
- it: custom persistence type should pass
set:
persistence:
custom-mount:
enabled: true
type: custom
volumeSpec:
downwardAPI:
items:
- path: "labels"
fieldRef:
fieldPath: metadata.labels
asserts:
- documentIndex: 0
isKind:
of: Deployment
- documentIndex: 0
equal:
path: spec.template.spec.volumes[0]
value:
name: custom-mount
downwardAPI:
items:
- fieldRef:
fieldPath: metadata.labels
path: labels
- it: configmap persistence type should pass
set:
persistence:
configmap:
enabled: true
type: configMap
name: mySettings
asserts:
- documentIndex: 0
isKind:
of: Deployment
- documentIndex: 0
equal:
path: spec.template.spec.volumes[0]
value:
name: configmap
configMap:
name: mySettings
- it: configmap persistence type with name template should pass
set:
persistence:
configmap:
enabled: true
type: configMap
name: "{{ include \"common.names.fullname\" $ }}-config"
asserts:
- documentIndex: 0
isKind:
of: Deployment
- documentIndex: 0
equal:
path: spec.template.spec.volumes[0]
value:
name: configmap
configMap:
name: RELEASE-NAME-common-chart-config
- it: secret persistence type should pass
set:
persistence:
secret:
enabled: true
type: secret
name: mySettings
asserts:
- documentIndex: 0
isKind:
of: Deployment
- documentIndex: 0
equal:
path: spec.template.spec.volumes[0]
value:
name: secret
secret:
secretName: mySettings
- it: secret persistence type with name template should pass
set:
persistence:
secret:
enabled: true
type: secret
name: "{{ .Release.Name }}-config"
asserts:
- documentIndex: 0
isKind:
of: Deployment
- documentIndex: 0
equal:
path: spec.template.spec.volumes[0]
value:
name: secret
secret:
secretName: RELEASE-NAME-config
- it: nfs persistence type should pass
set:
persistence:
nfs:
enabled: true
type: nfs
server: 10.10.0.8
path: /tank/nas/library
asserts:
- documentIndex: 0
isKind:
of: Deployment
- documentIndex: 0
equal:
path: spec.template.spec.volumes[0]
value:
name: nfs
nfs:
path: /tank/nas/library
server: 10.10.0.8

View file

@ -0,0 +1,30 @@
suite: persistence volumeclaimtemplates
templates:
- common.yaml
tests:
- it: volumeClaimTemplates should pass
set:
controller:
type: statefulset
volumeClaimTemplates:
- name: "storage"
accessMode: "ReadWriteOnce"
size: "10Gi"
storageClass: "storage"
asserts:
- documentIndex: 0
isKind:
of: StatefulSet
- documentIndex: 0
equal:
path: spec.volumeClaimTemplates[0]
value:
metadata:
name: storage
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 10Gi
storageClassName: storage

View file

@ -0,0 +1,91 @@
suite: pod additional containers
templates:
- common.yaml
tests:
- it: with explicit name should pass
set:
additionalContainers:
additional1:
name: template-test
asserts:
- documentIndex: 0
isKind:
of: Deployment
- documentIndex: 0
equal:
path: spec.template.spec.containers[1].name
value: template-test
- it: with implicit name should pass
set:
additionalContainers:
additional1:
image: template-test
asserts:
- documentIndex: 0
isKind:
of: Deployment
- documentIndex: 0
equal:
path: spec.template.spec.containers[1].name
value: additional1
- it: with templated name should pass
set:
additionalContainers:
additional1:
name: "{{ .Release.Name }}-container"
asserts:
- documentIndex: 0
isKind:
of: Deployment
- documentIndex: 0
equal:
path: spec.template.spec.containers[1].name
value: RELEASE-NAME-container
- it: with custom env vars dict should pass
set:
env:
main_env: value
additionalContainers:
additional1:
env:
int: 1
float: 1.5
string: value_of_env
template: "{{ .Release.Name }}-admin"
asserts:
- documentIndex: &DeploymentDocument 0
isKind:
of: Deployment
- documentIndex: *DeploymentDocument
equal:
path: spec.template.spec.containers[0].env[0]
value:
name: main_env
value: "value"
- documentIndex: *DeploymentDocument
equal:
path: spec.template.spec.containers[1].env[0]
value:
name: float
value: "1.5"
- documentIndex: *DeploymentDocument
equal:
path: spec.template.spec.containers[1].env[1]
value:
name: int
value: "1"
- documentIndex: *DeploymentDocument
equal:
path: spec.template.spec.containers[1].env[2]
value:
name: string
value: value_of_env
- documentIndex: *DeploymentDocument
equal:
path: spec.template.spec.containers[1].env[3]
value:
name: template
value: RELEASE-NAME-admin

View file

@ -0,0 +1,83 @@
suite: pod initContainers
templates:
- common.yaml
tests:
- it: with explicit name should pass
set:
initContainers:
init1:
name: template-test
asserts:
- documentIndex: 0
isKind:
of: Deployment
- documentIndex: 0
equal:
path: spec.template.spec.initContainers[0].name
value: template-test
- it: with implicit name should pass
set:
initContainers:
init1:
image: template-test
asserts:
- documentIndex: 0
isKind:
of: Deployment
- documentIndex: 0
equal:
path: spec.template.spec.initContainers[0].name
value: init1
- it: with templated name should pass
set:
initContainers:
init1:
name: "{{ .Release.Name }}-container"
asserts:
- documentIndex: 0
isKind:
of: Deployment
- documentIndex: 0
equal:
path: spec.template.spec.initContainers[0].name
value: RELEASE-NAME-container
- it: with custom env vars dict should pass
set:
initContainers:
init1:
env:
int: 1
float: 1.5
string: value_of_env
template: "{{ .Release.Name }}-admin"
asserts:
- documentIndex: &DeploymentDocument 0
isKind:
of: Deployment
- documentIndex: *DeploymentDocument
equal:
path: spec.template.spec.initContainers[0].env[0]
value:
name: float
value: "1.5"
- documentIndex: *DeploymentDocument
equal:
path: spec.template.spec.initContainers[0].env[1]
value:
name: int
value: "1"
- documentIndex: *DeploymentDocument
equal:
path: spec.template.spec.initContainers[0].env[2]
value:
name: string
value: value_of_env
- documentIndex: *DeploymentDocument
equal:
path: spec.template.spec.initContainers[0].env[3]
value:
name: template
value: RELEASE-NAME-admin

View file

@ -0,0 +1,59 @@
suite: pod replicas
templates:
- common.yaml
tests:
- it: default should pass
asserts:
- documentIndex: 0
isKind:
of: Deployment
- documentIndex: 0
isNull:
path: spec.template.spec.hostNetwork
- documentIndex: 0
equal:
path: spec.template.spec.dnsPolicy
value: ClusterFirst
- it: hostNetwork disabled should pass
set:
hostNetwork: false
asserts:
- documentIndex: 0
isKind:
of: Deployment
- documentIndex: 0
isNull:
path: spec.template.spec.hostNetwork
- documentIndex: 0
equal:
path: spec.template.spec.dnsPolicy
value: ClusterFirst
- it: hostNetwork enabled should pass
set:
hostNetwork: true
asserts:
- documentIndex: 0
isKind:
of: Deployment
- documentIndex: 0
equal:
path: spec.template.spec.hostNetwork
value: true
- documentIndex: 0
equal:
path: spec.template.spec.dnsPolicy
value: ClusterFirstWithHostNet
- it: custom dnsPolicy should pass
set:
dnsPolicy: None
asserts:
- documentIndex: 0
isKind:
of: Deployment
- documentIndex: 0
equal:
path: spec.template.spec.dnsPolicy
value: None

View file

@ -0,0 +1,25 @@
suite: pod replicas
templates:
- common.yaml
tests:
- it: default should pass
asserts:
- documentIndex: 0
isKind:
of: Deployment
- documentIndex: 0
equal:
path: spec.replicas
value: 1
- it: custom replicas should pass
set:
controller.replicas: 3
asserts:
- documentIndex: 0
isKind:
of: Deployment
- documentIndex: 0
equal:
path: spec.replicas
value: 3

View file

@ -0,0 +1,106 @@
suite: pvc metadata
templates:
- common.yaml
tests:
- it: default should pass
set:
persistence.config.enabled: true
asserts:
- documentIndex: &PersistentVolumeClaimDocument 0
isKind:
of: PersistentVolumeClaim
- documentIndex: *PersistentVolumeClaimDocument
isNull:
path: metadata.annotations
- documentIndex: *PersistentVolumeClaimDocument
equal:
path: metadata.labels
value:
app.kubernetes.io/instance: RELEASE-NAME
app.kubernetes.io/managed-by: Helm
app.kubernetes.io/name: common-chart
helm.sh/chart: common-chart-0.1.0
- it: retain enabled should pass
set:
persistence.config:
enabled: true
retain: true
asserts:
- documentIndex: &PersistentVolumeClaimDocument 0
isKind:
of: PersistentVolumeClaim
- documentIndex: *PersistentVolumeClaimDocument
equal:
path: metadata.annotations
value:
helm.sh/resource-policy: keep
- documentIndex: *PersistentVolumeClaimDocument
equal:
path: metadata.labels
value:
app.kubernetes.io/instance: RELEASE-NAME
app.kubernetes.io/managed-by: Helm
app.kubernetes.io/name: common-chart
helm.sh/chart: common-chart-0.1.0
- it: custom metadata should pass
set:
persistence.config:
enabled: true
labels:
test_label: test
annotations:
test_annotation: test
asserts:
- documentIndex: &PersistentVolumeClaimDocument 0
isKind:
of: PersistentVolumeClaim
- documentIndex: *PersistentVolumeClaimDocument
equal:
path: metadata.annotations
value:
test_annotation: test
- documentIndex: *PersistentVolumeClaimDocument
equal:
path: metadata.labels
value:
app.kubernetes.io/instance: RELEASE-NAME
app.kubernetes.io/managed-by: Helm
app.kubernetes.io/name: common-chart
helm.sh/chart: common-chart-0.1.0
test_label: test
- it: custom metadata with global metadata should pass
set:
global:
labels:
global_label: test
annotations:
global_annotation: test
persistence.config:
enabled: true
labels:
test_label: test
annotations:
test_annotation: test
asserts:
- documentIndex: &PersistentVolumeClaimDocument 0
isKind:
of: PersistentVolumeClaim
- documentIndex: *PersistentVolumeClaimDocument
equal:
path: metadata.annotations
value:
test_annotation: test
global_annotation: test
- documentIndex: *PersistentVolumeClaimDocument
equal:
path: metadata.labels
value:
app.kubernetes.io/instance: RELEASE-NAME
app.kubernetes.io/managed-by: Helm
app.kubernetes.io/name: common-chart
global_label: test
helm.sh/chart: common-chart-0.1.0
test_label: test

View file

@ -0,0 +1,66 @@
suite: pvc names
templates:
- common.yaml
tests:
- it: disabled should pass
asserts:
- hasDocuments:
count: 2
- documentIndex: 0
not: true
isKind:
of: PersistentVolumeClaim
- documentIndex: 1
not: true
isKind:
of: PersistentVolumeClaim
- it: default should pass
set:
persistence.config.enabled: true
asserts:
- hasDocuments:
count: 3
- documentIndex: &PersistentVolumeClaimDocument 0
isKind:
of: PersistentVolumeClaim
- documentIndex: 1
not: true
isKind:
of: PersistentVolumeClaim
- documentIndex: 2
not: true
isKind:
of: PersistentVolumeClaim
- documentIndex: *PersistentVolumeClaimDocument
equal:
path: metadata.name
value: RELEASE-NAME-common-chart-config
- it: without suffix should pass
set:
persistence.config:
enabled: true
nameOverride: "-"
asserts:
- documentIndex: &PersistentVolumeClaimDocument 0
isKind:
of: PersistentVolumeClaim
- documentIndex: *PersistentVolumeClaimDocument
equal:
path: metadata.name
value: RELEASE-NAME-common-chart
- it: with custom suffix should pass
set:
persistence.config:
enabled: true
nameOverride: "custom"
asserts:
- documentIndex: &PersistentVolumeClaimDocument 0
isKind:
of: PersistentVolumeClaim
- documentIndex: *PersistentVolumeClaimDocument
equal:
path: metadata.name
value: RELEASE-NAME-common-chart-custom

View file

@ -0,0 +1,42 @@
suite: pvc storageclass
templates:
- common.yaml
tests:
- it: default should pass
set:
persistence.config.enabled: true
asserts:
- documentIndex: &PersistentVolumeClaimDocument 0
isKind:
of: PersistentVolumeClaim
- documentIndex: *PersistentVolumeClaimDocument
isNull:
path: spec.storageClassName
- it: custom should pass
set:
persistence.config:
enabled: true
storageClass: custom
asserts:
- documentIndex: &PersistentVolumeClaimDocument 0
isKind:
of: PersistentVolumeClaim
- documentIndex: *PersistentVolumeClaimDocument
equal:
path: spec.storageClassName
value: custom
- it: empty should pass
set:
persistence.config:
enabled: true
storageClass: "-"
asserts:
- documentIndex: &PersistentVolumeClaimDocument 0
isKind:
of: PersistentVolumeClaim
- documentIndex: *PersistentVolumeClaimDocument
equal:
path: spec.storageClassName
value: ""

View file

@ -0,0 +1,81 @@
suite: service metadata
templates:
- common.yaml
tests:
- it: default metadata should pass
asserts:
- documentIndex: &ServiceDocument 1
isKind:
of: Service
- documentIndex: *ServiceDocument
isNull:
path: metadata.annotations
- documentIndex: *ServiceDocument
equal:
path: metadata.labels
value:
app.kubernetes.io/instance: RELEASE-NAME
app.kubernetes.io/managed-by: Helm
app.kubernetes.io/name: common-chart
helm.sh/chart: common-chart-0.1.0
- it: custom metadata should pass
set:
service:
main:
annotations:
test_annotation: test
labels:
test_label: test
asserts:
- documentIndex: &ServiceDocument 1
isKind:
of: Service
- documentIndex: *ServiceDocument
equal:
path: metadata.annotations
value:
test_annotation: test
- documentIndex: *ServiceDocument
equal:
path: metadata.labels
value:
app.kubernetes.io/instance: RELEASE-NAME
app.kubernetes.io/managed-by: Helm
app.kubernetes.io/name: common-chart
helm.sh/chart: common-chart-0.1.0
test_label: test
- it: custom metadata with global metadata should pass
set:
global:
labels:
global_label: test
annotations:
global_annotation: test
service:
main:
annotations:
test_annotation: test
labels:
test_label: test
asserts:
- documentIndex: &ServiceDocument 1
isKind:
of: Service
- documentIndex: *ServiceDocument
equal:
path: metadata.annotations
value:
global_annotation: test
test_annotation: test
- documentIndex: *ServiceDocument
equal:
path: metadata.labels
value:
app.kubernetes.io/instance: RELEASE-NAME
app.kubernetes.io/managed-by: Helm
app.kubernetes.io/name: common-chart
global_label: test
helm.sh/chart: common-chart-0.1.0
test_label: test

View file

@ -0,0 +1,29 @@
suite: service names
templates:
- common.yaml
tests:
- it: default should pass
asserts:
- hasDocuments:
count: 2
- documentIndex: &ServiceDocument 1
isKind:
of: Service
- documentIndex: *ServiceDocument
equal:
path: metadata.name
value: RELEASE-NAME-common-chart
- it: custom name suffix should pass
set:
service:
main:
nameOverride: http
asserts:
- documentIndex: &ServiceDocument 1
isKind:
of: Service
- documentIndex: *ServiceDocument
equal:
path: metadata.name
value: RELEASE-NAME-common-chart-http

View file

@ -0,0 +1,63 @@
suite: service port names
templates:
- common.yaml
tests:
- it: default should pass
asserts:
- hasDocuments:
count: 2
- documentIndex: &ServiceDocument 1
isKind:
of: Service
- documentIndex: *ServiceDocument
equal:
path: spec.ports[0]
value:
name: http
port: null
protocol: TCP
targetPort: http
- it: custom name should pass
set:
service:
main:
ports:
http:
enabled: false
server:
enabled: true
port: 8080
asserts:
- documentIndex: &ServiceDocument 1
isKind:
of: Service
- documentIndex: *ServiceDocument
equal:
path: spec.ports[0]
value:
name: server
port: 8080
protocol: TCP
targetPort: server
- it: custom target port should pass
set:
service:
main:
ports:
http:
enabled: true
targetPort: 80
asserts:
- documentIndex: &ServiceDocument 1
isKind:
of: Service
- documentIndex: *ServiceDocument
equal:
path: spec.ports[0]
value:
name: http
port: null
protocol: TCP
targetPort: 80

View file

@ -0,0 +1,71 @@
suite: service protocols
templates:
- common.yaml
tests:
- it: default should pass
asserts:
- hasDocuments:
count: 2
- documentIndex: &ServiceDocument 1
isKind:
of: Service
- documentIndex: *ServiceDocument
equal:
path: spec.ports[0].protocol
value: TCP
- it: explicit TCP should pass
set:
service.main.ports.http.protocol: TCP
asserts:
- documentIndex: &ServiceDocument 1
isKind:
of: Service
- documentIndex: *ServiceDocument
equal:
path: spec.ports[0].protocol
value: TCP
- it: explicit UDP should pass
set:
service.main.ports.http.protocol: UDP
asserts:
- documentIndex: &ServiceDocument 1
isKind:
of: Service
- documentIndex: *ServiceDocument
equal:
path: spec.ports[0].protocol
value: UDP
- it: explicit HTTP should pass
set:
service.main.ports.http.protocol: HTTP
asserts:
- documentIndex: &ServiceDocument 1
isKind:
of: Service
- documentIndex: *ServiceDocument
equal:
path: spec.ports[0].protocol
value: TCP
- documentIndex: *ServiceDocument
isNull:
path: metadata.annotations
- it: explicit HTTPS should pass
set:
service.main.ports.http.protocol: HTTPS
asserts:
- documentIndex: &ServiceDocument 1
isKind:
of: Service
- documentIndex: *ServiceDocument
equal:
path: spec.ports[0].protocol
value: TCP
- documentIndex: *ServiceDocument
equal:
path: metadata.annotations
value:
traefik.ingress.kubernetes.io/service.serversscheme: https

View file

@ -0,0 +1,33 @@
suite: service values
templates:
- common.yaml
tests:
- it: externalTrafficPolicy should pass for NodePort service
set:
service:
main:
type: NodePort
externalTrafficPolicy: Local
asserts:
- documentIndex: &ServiceDocument 1
isKind:
of: Service
- documentIndex: *ServiceDocument
equal:
path: spec.externalTrafficPolicy
value: Local
- it: externalTrafficPolicy should pass for LoadBalancer service
set:
service:
main:
type: LoadBalancer
externalTrafficPolicy: Local
asserts:
- documentIndex: &ServiceDocument 1
isKind:
of: Service
- documentIndex: *ServiceDocument
equal:
path: spec.externalTrafficPolicy
value: Local