This commit is contained in:
Stavros kois
2023-01-28 22:59:55 +02:00
parent eae5657116
commit b8ebc68b1b
20 changed files with 342 additions and 180 deletions
@@ -5,9 +5,10 @@ tests:
- it: should pass with default values
documentIndex: &cronJobDoc 2
set:
controller:
type: CronJob
schedule: "*/1 * * * *"
controllers:
main:
type: CronJob
schedule: "*/1 * * * *"
asserts:
- hasDocuments:
count: 3
@@ -20,12 +21,13 @@ tests:
documentIndex: *cronJobDoc
set:
some_key: some_value
controller:
type: CronJob
schedule: "*/1 * * * *"
annotations:
controller_key: controller_value
controller_key2: "{{ .Values.some_key }}"
controllers:
main:
type: CronJob
schedule: "*/1 * * * *"
annotations:
controller_key: controller_value
controller_key2: "{{ .Values.some_key }}"
global:
annotations:
global_key: global_value
@@ -44,13 +46,15 @@ tests:
- it: should pass with podAnnotations set
documentIndex: *cronJobDoc
set:
controller:
type: CronJob
schedule: "*/1 * * * *"
some_key: some_value2
podAnnotations:
test: some_value
test2: "{{ .Values.some_key }}"
controllers:
main:
type: CronJob
schedule: "*/1 * * * *"
pod:
annotations:
test: some_value
test2: "{{ .Values.some_key }}"
asserts:
- isSubset:
path: metadata.annotations
@@ -1,13 +1,14 @@
suite: cronjob strategy test
suite: cronjob controller test
templates:
- common.yaml
tests:
- it: should pass with strategy changed in cronjob
documentIndex: &cronJobDoc 2
set:
controller:
type: CronJob
schedule: "* * * * *"
controllers:
main:
type: CronJob
schedule: "* * * * *"
asserts:
- hasDocuments:
count: 3
@@ -17,20 +18,21 @@ tests:
- it: should pass with job options changed in cronJob
documentIndex: *cronJobDoc
set:
controller:
type: CronJob
backoffLimit: 11
ttlSecondsAfterFinished: 22
activeDeadlineSeconds: 33
parallelism: 44
completions: 55
completionMode: Indexed
schedule: "* * * * *"
concurrencyPolicy: Allow
failedJobsHistoryLimit: 7
successfulJobsHistoryLimit: 11
timezone: "America/New_York"
startingDeadlineSeconds: 13
controllers:
main:
type: CronJob
backoffLimit: 11
ttlSecondsAfterFinished: 22
activeDeadlineSeconds: 33
parallelism: 44
completions: 55
completionMode: Indexed
schedule: "* * * * *"
concurrencyPolicy: Allow
failedJobsHistoryLimit: 7
successfulJobsHistoryLimit: 11
timezone: "America/New_York"
startingDeadlineSeconds: 13
asserts:
- isSubset:
path: spec
@@ -5,9 +5,10 @@ tests:
- it: should pass with controller set to CronJob
documentIndex: &cronjobDoc 2
set:
controller:
type: CronJob
schedule: "*/5 * * * *"
controllers:
main:
type: CronJob
schedule: "*/5 * * * *"
asserts:
- hasDocuments:
count: 3
@@ -63,8 +64,9 @@ tests:
path: spec.jobTemplate.spec.template.spec.priorityClassName
- isNull:
path: spec.jobTemplate.spec.template.spec.hostname
- isNull:
- equal:
path: spec.jobTemplate.spec.template.spec.dnsPolicy
value: ClusterFirst
- isNull:
path: spec.jobTemplate.spec.template.spec.dnsConfig
- isNull:
@@ -5,9 +5,10 @@ tests:
- it: should pass with controller set to CronJob
documentIndex: &cronjobDoc 2
set:
controller:
type: CronJob
schedule: "*/5 * * * *"
controllers:
main:
type: CronJob
schedule: "*/5 * * * *"
asserts:
- hasDocuments:
count: 3
@@ -19,9 +20,32 @@ tests:
- it: should pass with podSecurityContext changed
documentIndex: *cronjobDoc
set:
controller:
type: CronJob
schedule: "* * * * *"
controllers:
main:
type: CronJob
schedule: "* * * * *"
pod:
securityContext:
fsGroup: 0
fsGroupChangePolicy: Always
supplementalGroups:
- 1000
asserts:
- equal:
path: spec.jobTemplate.spec.template.spec.securityContext
value:
fsGroup: 0
fsGroupChangePolicy: Always
supplementalGroups:
- 1000
- it: should pass with podSecurityContext changed from the default
documentIndex: *cronjobDoc
set:
controllers:
main:
type: CronJob
schedule: "* * * * *"
podSecurityContext:
fsGroup: 0
fsGroupChangePolicy: Always
@@ -36,13 +60,45 @@ tests:
supplementalGroups:
- 1000
- it: should pass with podSecurityContext changed
- it: should pass with securityContext changed
documentIndex: *cronjobDoc
set:
controller:
type: CronJob
schedule: "* * * * *"
controllers:
main:
type: CronJob
schedule: "* * * * *"
pod:
containers:
main:
securityContext:
runAsUser: 1000
runAsGroup: 1000
capabilities:
add:
- something
asserts:
- equal:
path: spec.jobTemplate.spec.template.spec.containers[0].securityContext
value:
allowPrivilegeEscalation: false
privileged: false
readOnlyRootFilesystem: true
runAsNonRoot: true
runAsUser: 1000
runAsGroup: 1000
capabilities:
add:
- something
drop:
- ALL
- it: should pass with securityContext changed from the default
documentIndex: *cronjobDoc
set:
controllers:
main:
type: CronJob
schedule: "* * * * *"
securityContext:
runAsUser: 1000
runAsGroup: 1000
@@ -68,16 +124,20 @@ tests:
- it: should pass with multiple envs defined via tpl
documentIndex: *cronjobDoc
set:
controller:
type: CronJob
schedule: "* * * * *"
controllers:
main:
type: CronJob
schedule: "* * * * *"
pod:
containers:
main:
env:
ENVVAR: "{{ .Values.some_string }}"
ENVVAR2: "{{ .Values.some_int }}"
ENVVAR3: "{{ .Values.some_bool }}"
some_string: a_string
some_int: 123
some_bool: false
env:
ENVVAR: "{{ .Values.some_string }}"
ENVVAR2: "{{ .Values.some_int }}"
ENVVAR3: "{{ .Values.some_bool }}"
asserts:
- equal:
path: spec.jobTemplate.spec.template.spec.containers[0].env
@@ -102,9 +162,10 @@ tests:
- it: should pass with addNvidiaRuntimeClass and nvidiaRuntimeClassName set
documentIndex: *cronjobDoc
set:
controller:
type: CronJob
schedule: "* * * * *"
controllers:
main:
type: CronJob
schedule: "* * * * *"
scaleGPU:
something: blabla
global:
@@ -119,9 +180,10 @@ tests:
- it: should pass with deviceList set
documentIndex: *cronjobDoc
set:
controller:
type: CronJob
schedule: "* * * * *"
controllers:
main:
type: CronJob
schedule: "* * * * *"
deviceList:
- enabled: true
hostPath: /dev/usb
@@ -141,9 +203,10 @@ tests:
- it: should pass with added persistence
documentIndex: &cronjobDoc 3
set:
controller:
type: CronJob
schedule: "* * * * *"
controllers:
main:
type: CronJob
schedule: "* * * * *"
persistence:
volume0:
type: pvc
@@ -23,11 +23,11 @@ tests:
controller:
type: CronJob
schedule: "* * * * *"
nameOverride: overrodeName
nameOverride: overrodename
asserts:
- equal:
path: metadata.name
value: RELEASE-NAME-overrodeName
value: RELEASE-NAME-overrodename
- it: should pass with global.nameOverride
documentIndex: *cronjobDoc
@@ -35,10 +35,10 @@ tests:
controller:
type: CronJob
schedule: "* * * * *"
nameOverride: overrodeName
nameOverride: overrodename
global:
nameOverride: globalOverrodeName
nameOverride: globaloverrodename
asserts:
- equal:
path: metadata.name
value: RELEASE-NAME-globalOverrodeName
value: RELEASE-NAME-globaloverrodename
@@ -5,7 +5,9 @@ tests:
- it: should pass with default values
documentIndex: &daemonsetDoc 0
set:
controller.type: DaemonSet
controllers:
main:
type: DaemonSet
asserts:
- hasDocuments:
count: 3
@@ -20,12 +22,13 @@ tests:
- it: should pass with controller and global annotations
documentIndex: *daemonsetDoc
set:
controller.type: DaemonSet
some_key: some_value
controller:
annotations:
controller_key: controller_value
controller_key2: "{{ .Values.some_key }}"
controllers:
main:
type: DaemonSet
annotations:
controller_key: controller_value
controller_key2: "{{ .Values.some_key }}"
global:
annotations:
global_key: global_value
@@ -47,11 +50,14 @@ tests:
- it: should pass with podAnnotations set
documentIndex: *daemonsetDoc
set:
controller.type: DaemonSet
some_key: some_value2
podAnnotations:
test: some_value
test2: "{{ .Values.some_key }}"
controllers:
main:
type: DaemonSet
pod:
annotations:
test: some_value
test2: "{{ .Values.some_key }}"
asserts:
- isSubset:
path: spec.template.metadata.annotations
@@ -5,12 +5,13 @@ tests:
- it: should pass with strategy changed in DaemonSet
documentIndex: &dameonsetDoc 0
set:
controller:
type: DaemonSet
strategy: OnDelete
rollingUpdate:
surge: 5
unavailable: 6
controllers:
main:
type: DaemonSet
strategy: OnDelete
rollingUpdate:
surge: 5
unavailable: 6
asserts:
- hasDocuments:
count: 3
@@ -26,12 +27,13 @@ tests:
- it: should pass with strategy changed in DaemonSet
documentIndex: *dameonsetDoc
set:
controller:
type: DaemonSet
strategy: RollingUpdate
rollingUpdate:
surge: 5
unavailable: 6
controllers:
main:
type: DaemonSet
strategy: RollingUpdate
rollingUpdate:
surge: 5
unavailable: 6
asserts:
- equal:
path: spec.updateStrategy
@@ -44,9 +46,10 @@ tests:
- it: should fail with wrong strategy
documentIndex: *dameonsetDoc
set:
controller:
type: DaemonSet
strategy: not_valid_strategy
controllers:
main:
type: DaemonSet
strategy: not_valid_strategy
asserts:
- failedTemplate:
errorMessage: Not a valid strategy type for DaemonSet (not_valid_strategy)
@@ -54,9 +57,10 @@ tests:
- it: should pass with revisionHistoryLimit changed
documentIndex: *dameonsetDoc
set:
controller:
type: DaemonSet
revisionHistoryLimit: 1
controllers:
main:
type: DaemonSet
revisionHistoryLimit: 1
asserts:
- equal:
path: spec.revisionHistoryLimit
@@ -5,7 +5,9 @@ tests:
- it: should pass with controller set to DaemonSet
documentIndex: &daemonsetDoc 0
set:
controller.type: DaemonSet
controllers:
main:
type: DaemonSet
asserts:
- hasDocuments:
count: 3
@@ -5,7 +5,9 @@ tests:
- it: should pass with controller set to DaemonSet
documentIndex: &daemonsetDoc 0
set:
controller.type: DaemonSet
controllers:
main:
type: DaemonSet
asserts:
- hasDocuments:
count: 3
@@ -14,11 +16,33 @@ tests:
- isAPIVersion:
of: apps/v1
- it: should pass with podSecurityContext changed
documentIndex: *daemonsetDoc
set:
controller.type: DaemonSet
controllers:
main:
type: DaemonSet
pod:
securityContext:
fsGroup: 0
fsGroupChangePolicy: Always
supplementalGroups:
- 1000
asserts:
- equal:
path: spec.template.spec.securityContext
value:
fsGroup: 0
fsGroupChangePolicy: Always
supplementalGroups:
- 1000
- it: should pass with podSecurityContext changed from default
documentIndex: *daemonsetDoc
set:
controllers:
main:
type: DaemonSet
podSecurityContext:
fsGroup: 0
fsGroupChangePolicy: Always
@@ -33,10 +57,43 @@ tests:
supplementalGroups:
- 1000
- it: should pass with podSecurityContext changed from default
documentIndex: *daemonsetDoc
set:
controllers:
main:
type: DaemonSet
pod:
containers:
main:
securityContext:
runAsUser: 1000
runAsGroup: 1000
capabilities:
add:
- something
asserts:
- equal:
path: spec.template.spec.containers[0].securityContext
value:
allowPrivilegeEscalation: false
privileged: false
readOnlyRootFilesystem: true
runAsNonRoot: true
runAsUser: 1000
runAsGroup: 1000
capabilities:
add:
- something
drop:
- ALL
- it: should pass with podSecurityContext changed
documentIndex: *daemonsetDoc
set:
controller.type: DaemonSet
controllers:
main:
type: DaemonSet
securityContext:
runAsUser: 1000
runAsGroup: 1000
@@ -62,14 +119,19 @@ tests:
- it: should pass with multiple envs defined via tpl
documentIndex: *daemonsetDoc
set:
controller.type: DaemonSet
controllers:
main:
type: DaemonSet
pod:
containers:
main:
env:
ENVVAR: "{{ .Values.some_string }}"
ENVVAR2: "{{ .Values.some_int }}"
ENVVAR3: "{{ .Values.some_bool }}"
some_string: a_string
some_int: 123
some_bool: false
env:
ENVVAR: "{{ .Values.some_string }}"
ENVVAR2: "{{ .Values.some_int }}"
ENVVAR3: "{{ .Values.some_bool }}"
asserts:
- equal:
path: spec.template.spec.containers[0].env
@@ -94,7 +156,9 @@ tests:
- it: should pass with image defined in init containers
documentIndex: *daemonsetDoc
set:
controller.type: DaemonSet
controllers:
main:
type: DaemonSet
image:
repository: some-repo
tag: some-tag
@@ -135,7 +199,9 @@ tests:
- it: should pass with added persistence
documentIndex: *daemonsetDoc
set:
controller.type: DaemonSet
controllers:
main:
type: DaemonSet
persistence:
volume0:
type: pvc
@@ -7,7 +7,9 @@ tests:
- it: should pass with default values
documentIndex: &daemonsetDoc 0
set:
controller.type: DaemonSet
controllers:
main:
type: DaemonSet
asserts:
- hasDocuments:
count: 3
@@ -35,12 +37,13 @@ tests:
- it: should pass with controller and global labels
documentIndex: *daemonsetDoc
set:
controller.type: DaemonSet
some_key: some_value
controller:
labels:
controller_key: controller_value
controller_key2: "{{ .Values.some_key }}"
controllers:
main:
type: DaemonSet
labels:
controller_key: controller_value
controller_key2: "{{ .Values.some_key }}"
global:
labels:
global_key: global_value
@@ -65,11 +68,14 @@ tests:
- it: should pass with podLabels set
documentIndex: *daemonsetDoc
set:
controller.type: DaemonSet
some_key: some_value2
podLabels:
test: some_value
test2: "{{ .Values.some_key }}"
controllers:
main:
type: DaemonSet
pod:
labels:
test: some_value
test2: "{{ .Values.some_key }}"
asserts:
- equal:
path: spec.template.metadata.labels.test2
@@ -5,7 +5,9 @@ tests:
- it: should pass with default values
documentIndex: &daemonsetDoc 0
set:
controller.type: DaemonSet
controllers:
main:
type: DaemonSet
asserts:
- hasDocuments:
count: 3
@@ -18,21 +20,25 @@ tests:
- it: should pass with nameOverride
documentIndex: *daemonsetDoc
set:
controller.type: DaemonSet
nameOverride: overrodeName
controllers:
main:
type: DaemonSet
nameOverride: overrodename
asserts:
- equal:
path: metadata.name
value: RELEASE-NAME-overrodeName
value: RELEASE-NAME-overrodename
- it: should pass with global.nameOverride
documentIndex: *daemonsetDoc
set:
controller.type: DaemonSet
nameOverride: overrodeName
controllers:
main:
type: DaemonSet
nameOverride: overrodename
global:
nameOverride: globalOverrodeName
nameOverride: globaloverrodename
asserts:
- equal:
path: metadata.name
value: RELEASE-NAME-globalOverrodeName
value: RELEASE-NAME-globaloverrodename
@@ -19,10 +19,11 @@ tests:
documentIndex: *deploymentDoc
set:
some_key: some_value
controller:
annotations:
controller_key: controller_value
controller_key2: "{{ .Values.some_key }}"
controllers:
main:
annotations:
controller_key: controller_value
controller_key2: "{{ .Values.some_key }}"
global:
annotations:
global_key: global_value
@@ -45,9 +46,12 @@ tests:
documentIndex: *deploymentDoc
set:
some_key: some_value2
podAnnotations:
test: some_value
test2: "{{ .Values.some_key }}"
controllers:
main:
pod:
annotations:
test: some_value
test2: "{{ .Values.some_key }}"
asserts:
- isSubset:
path: spec.template.metadata.annotations
@@ -27,8 +27,9 @@ tests:
- it: should pass with controller disabled
documentIndex: *deploymentDoc
set:
controller:
enabled: false
controllers:
main:
enabled: false
asserts:
- hasDocuments:
count: 2
@@ -36,11 +37,12 @@ tests:
- it: should pass with controller strategy changed and rollingUpdate strategies set
documentIndex: *deploymentDoc
set:
controller:
strategy: RollingUpdate
rollingUpdate:
unavailable: 2
surge: 3
controllers:
main:
strategy: RollingUpdate
rollingUpdate:
unavailable: 2
surge: 3
asserts:
- equal:
path: spec.strategy.type
@@ -54,8 +56,9 @@ tests:
- it: should pass with controller strategy changed
documentIndex: *deploymentDoc
set:
controller:
strategy: RollingUpdate
controllers:
main:
strategy: RollingUpdate
asserts:
- equal:
path: spec.strategy.type
@@ -65,16 +68,18 @@ tests:
- it: should fail with wrong controller
set:
controller:
type: not_valid_controller
controllers:
main:
type: not_valid_controller
asserts:
- failedTemplate:
errorMessage: Not a valid controller.type (not_valid_controller). Valid options are Deployment, DaemonSet, StatefulSet, Job, CronJob
- it: should fail with wrong strategy
set:
controller:
strategy: not_valid_strategy
controllers:
main:
strategy: not_valid_strategy
asserts:
- failedTemplate:
errorMessage: Not a valid strategy type for Deployment (not_valid_strategy)
@@ -82,8 +87,9 @@ tests:
- it: should pass with revisionHistoryLimit changed
documentIndex: *deploymentDoc
set:
controller:
revisionHistoryLimit: 1
controllers:
main:
revisionHistoryLimit: 1
asserts:
- equal:
path: spec.revisionHistoryLimit
@@ -92,8 +98,9 @@ tests:
- it: should pass with replicas changed
documentIndex: *deploymentDoc
set:
controller:
replicas: 6
controllers:
main:
replicas: 6
asserts:
- equal:
path: spec.replicas
@@ -16,19 +16,19 @@ tests:
- it: should pass with nameOverride
documentIndex: *deploymentDoc
set:
nameOverride: overrodeName
nameOverride: overrodename
asserts:
- equal:
path: metadata.name
value: RELEASE-NAME-overrodeName
value: RELEASE-NAME-overrodename
- it: should pass with global.nameOverride
documentIndex: *deploymentDoc
set:
nameOverride: overrodeName
nameOverride: overrodename
global:
nameOverride: globalOverrodeName
nameOverride: globaloverrodename
asserts:
- equal:
path: metadata.name
value: RELEASE-NAME-globalOverrodeName
value: RELEASE-NAME-globaloverrodename
@@ -19,20 +19,20 @@ tests:
documentIndex: *jobDoc
set:
controller.type: Job
nameOverride: overrodeName
nameOverride: overrodename
asserts:
- equal:
path: metadata.name
value: RELEASE-NAME-overrodeName
value: RELEASE-NAME-overrodename
- it: should pass with global.nameOverride
documentIndex: *jobDoc
set:
controller.type: Job
nameOverride: overrodeName
nameOverride: overrodename
global:
nameOverride: globalOverrodeName
nameOverride: globaloverrodename
asserts:
- equal:
path: metadata.name
value: RELEASE-NAME-globalOverrodeName
value: RELEASE-NAME-globaloverrodename
@@ -19,20 +19,20 @@ tests:
documentIndex: *statefulsetDoc
set:
controller.type: StatefulSet
nameOverride: overrodeName
nameOverride: overrodename
asserts:
- equal:
path: metadata.name
value: RELEASE-NAME-overrodeName
value: RELEASE-NAME-overrodename
- it: should pass with global.nameOverride
documentIndex: *statefulsetDoc
set:
controller.type: StatefulSet
nameOverride: overrodeName
nameOverride: overrodename
global:
nameOverride: globalOverrodeName
nameOverride: globaloverrodename
asserts:
- equal:
path: metadata.name
value: RELEASE-NAME-globalOverrodeName
value: RELEASE-NAME-globaloverrodename
@@ -117,7 +117,6 @@ The reason is not splitted, is that on one of the places needs a combo of all va
{{/* Overwrite from values that user/dev passed */}}
{{- $returnValue = mustMergeOverwrite $returnValue $podSecCont -}}
{{- $appendGPUGroup := false -}}
{{- $appendDeviceGroups := false -}}
@@ -14,7 +14,7 @@ nameOverride applies only to the current chart
{{- end -}}
{{/* Order of preference: global.nameOverride -> nameOverride -> Chart.Name */}}
{{- ($globalNameOverride | default .Values.controllers.main.pod.nameOverride) | default .Chart.Name | trunc 63 | trimSuffix "-" -}}
{{- ($globalNameOverride | default .Values.controllers.main.nameOverride) | default .Chart.Name | trunc 63 | trimSuffix "-" -}}
{{- end -}}
{{/* Create a default fully qualified app name. */}}
@@ -26,8 +26,8 @@ nameOverride applies only to the current chart
{{- $globalFullNameOverride = (.Values.global.fullnameOverride | default $globalFullNameOverride) -}}
{{- end -}}
{{- if or .Values.controllers.main.pod.fullnameOverride $globalFullNameOverride -}}
{{- $name = $globalFullNameOverride | default .Values.controllers.main.pod.fullnameOverride -}}
{{- if or .Values.controllers.main.fullnameOverride $globalFullNameOverride -}}
{{- $name = $globalFullNameOverride | default .Values.controllers.main.fullnameOverride -}}
{{- else -}}
{{- if contains $name .Release.Name -}}
{{- $name = .Release.Name -}}
@@ -153,7 +153,7 @@
{{- $runtimeClassName = . -}}
{{- end -}}
{{- end -}}
{{- fail (toYaml $values) -}}
{{- $termSeconds := "" -}}
{{- with $values.terminationGracePeriodSeconds -}}
{{- if eq (toString .) $inherit -}}
-9
View File
@@ -158,15 +158,6 @@ controllers:
tolerations: []
# Defines termination strategy
terminationGracePeriodSeconds: 10
# Default podSecurityContext for main pod
securityContext:
fsGroup: 568
supplementalGroups: []
fsGroupChangePolicy: OnRootMismatch
# Defines the DNS Config
dnsConfig: {}
# Defines the DNS Policy
dnsPolicy: ""
containers:
main:
enabled: true