More paving the way

This commit is contained in:
Bᴇʀɴᴅ Sᴄʜᴏʀɢᴇʀs 2022-07-27 19:40:55 +02:00
parent 33f207c563
commit 4863146ad9
No known key found for this signature in database
GPG key ID: BC5E2BD907F9A8EC
62 changed files with 2761 additions and 13 deletions

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,169 @@
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: 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: 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-test

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