Add more unit tests to helm chart
Signed-off-by: Stavros Foteinopoulos <stafot@gmail.com>
This commit is contained in:
parent
8dfdc30958
commit
edd94f07a0
12 changed files with 269 additions and 0 deletions
|
@ -0,0 +1,25 @@
|
||||||
|
suite: test controller addHeaders configmap
|
||||||
|
templates:
|
||||||
|
- controller-configmap-addheaders.yaml
|
||||||
|
|
||||||
|
tests:
|
||||||
|
- it: should not create a configmap if addHeaders is not set
|
||||||
|
set:
|
||||||
|
controller.addHeaders: null
|
||||||
|
asserts:
|
||||||
|
- hasDocuments:
|
||||||
|
count: 0
|
||||||
|
|
||||||
|
- it: should create a configmap if addHeaders is set
|
||||||
|
set:
|
||||||
|
controller.addHeaders:
|
||||||
|
X-Another-Custom-Header: "Value"
|
||||||
|
asserts:
|
||||||
|
- hasDocuments:
|
||||||
|
count: 1
|
||||||
|
- isKind:
|
||||||
|
of: ConfigMap
|
||||||
|
- equal:
|
||||||
|
path: metadata.name
|
||||||
|
value: RELEASE-NAME-ingress-nginx-custom-add-headers
|
||||||
|
|
|
@ -0,0 +1,26 @@
|
||||||
|
suite: test controller proxySetHeaders configmap
|
||||||
|
templates:
|
||||||
|
- controller-configmap-proxyheaders.yaml
|
||||||
|
|
||||||
|
tests:
|
||||||
|
- it: should not create a configmap if proxySetHeaders is not set
|
||||||
|
set:
|
||||||
|
controller.proxySetHeaders: null
|
||||||
|
asserts:
|
||||||
|
- hasDocuments:
|
||||||
|
count: 0
|
||||||
|
|
||||||
|
- it: should create a configmap if proxySetHeaders is set
|
||||||
|
set:
|
||||||
|
controller.proxySetHeaders:
|
||||||
|
X-Custom-Header: "Value"
|
||||||
|
asserts:
|
||||||
|
- hasDocuments:
|
||||||
|
count: 1
|
||||||
|
- isKind:
|
||||||
|
of: ConfigMap
|
||||||
|
- equal:
|
||||||
|
path: metadata.name
|
||||||
|
value: RELEASE-NAME-ingress-nginx-custom-proxy-headers
|
||||||
|
|
||||||
|
|
12
charts/ingress-nginx/tests/controller-configmap_test.yaml
Normal file
12
charts/ingress-nginx/tests/controller-configmap_test.yaml
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
|
||||||
|
suite: test controller configmap
|
||||||
|
templates:
|
||||||
|
- controller-configmap.yaml
|
||||||
|
|
||||||
|
tests:
|
||||||
|
- it: should create a configmap
|
||||||
|
asserts:
|
||||||
|
- hasDocuments:
|
||||||
|
count: 1
|
||||||
|
- isKind:
|
||||||
|
of: ConfigMap
|
14
charts/ingress-nginx/tests/controller-daemonset_test.yaml
Normal file
14
charts/ingress-nginx/tests/controller-daemonset_test.yaml
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
suite: test controller daemonset
|
||||||
|
templates:
|
||||||
|
- controller-daemonset.yaml
|
||||||
|
|
||||||
|
tests:
|
||||||
|
- it: should create a daemonset when controller kind is DaemonSet
|
||||||
|
set:
|
||||||
|
controller.kind: DaemonSet
|
||||||
|
asserts:
|
||||||
|
- hasDocuments:
|
||||||
|
count: 1
|
||||||
|
- isKind:
|
||||||
|
of: DaemonSet
|
||||||
|
|
33
charts/ingress-nginx/tests/controller-deployment_test.yaml
Normal file
33
charts/ingress-nginx/tests/controller-deployment_test.yaml
Normal file
|
@ -0,0 +1,33 @@
|
||||||
|
suite: test controller deployment
|
||||||
|
templates:
|
||||||
|
- controller-deployment.yaml
|
||||||
|
|
||||||
|
tests:
|
||||||
|
- it: should always create a deployment
|
||||||
|
asserts:
|
||||||
|
- hasDocuments:
|
||||||
|
count: 1
|
||||||
|
- isKind:
|
||||||
|
of: Deployment
|
||||||
|
|
||||||
|
- it: custom replica count
|
||||||
|
set:
|
||||||
|
controller.enabled: true
|
||||||
|
controller.replicaCount: 3
|
||||||
|
asserts:
|
||||||
|
- equal:
|
||||||
|
path: spec.replicas
|
||||||
|
value: 3
|
||||||
|
|
||||||
|
- it: custom resource limits
|
||||||
|
set:
|
||||||
|
controller.enabled: true
|
||||||
|
controller.resources.limits.cpu: "500m"
|
||||||
|
controller.resources.limits.memory: "512Mi"
|
||||||
|
asserts:
|
||||||
|
- equal:
|
||||||
|
path: spec.template.spec.containers[0].resources.limits.cpu
|
||||||
|
value: "500m"
|
||||||
|
- equal:
|
||||||
|
path: spec.template.spec.containers[0].resources.limits.memory
|
||||||
|
value: "512Mi"
|
16
charts/ingress-nginx/tests/controller-hpa_test.yaml
Normal file
16
charts/ingress-nginx/tests/controller-hpa_test.yaml
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
suite: test controller hpa
|
||||||
|
templates:
|
||||||
|
- controller-hpa.yaml
|
||||||
|
|
||||||
|
tests:
|
||||||
|
- it: should create an hpa when controller kind is Deployment and autoscaling is enabled
|
||||||
|
set:
|
||||||
|
controller.kind: Deployment
|
||||||
|
controller.autoscaling.enabled: true
|
||||||
|
controller.keda.enabled: false
|
||||||
|
asserts:
|
||||||
|
- hasDocuments:
|
||||||
|
count: 1
|
||||||
|
- isKind:
|
||||||
|
of: HorizontalPodAutoscaler
|
||||||
|
|
15
charts/ingress-nginx/tests/controller-keda_test.yaml
Normal file
15
charts/ingress-nginx/tests/controller-keda_test.yaml
Normal file
|
@ -0,0 +1,15 @@
|
||||||
|
suite: test controller keda
|
||||||
|
templates:
|
||||||
|
- controller-keda.yaml
|
||||||
|
|
||||||
|
tests:
|
||||||
|
- it: should create a keda scaled object when controller kind is Deployment and keda is enabled
|
||||||
|
set:
|
||||||
|
controller.kind: Deployment
|
||||||
|
controller.keda.enabled: true
|
||||||
|
asserts:
|
||||||
|
- hasDocuments:
|
||||||
|
count: 1
|
||||||
|
- isKind:
|
||||||
|
of: ScaledObject
|
||||||
|
|
|
@ -0,0 +1,20 @@
|
||||||
|
suite: test controller network policy
|
||||||
|
templates:
|
||||||
|
- controller-networkpolicy.yaml
|
||||||
|
|
||||||
|
tests:
|
||||||
|
- it: should not create a network policy by default
|
||||||
|
set:
|
||||||
|
controller.networkPolicy.enabled: false
|
||||||
|
asserts:
|
||||||
|
- hasDocuments:
|
||||||
|
count: 0
|
||||||
|
|
||||||
|
- it: should create a network policy when enabled
|
||||||
|
set:
|
||||||
|
controller.networkPolicy.enabled: true
|
||||||
|
asserts:
|
||||||
|
- hasDocuments:
|
||||||
|
count: 1
|
||||||
|
- isKind:
|
||||||
|
of: NetworkPolicy
|
|
@ -0,0 +1,24 @@
|
||||||
|
suite: test controller internal service
|
||||||
|
templates:
|
||||||
|
- controller-service-internal.yaml
|
||||||
|
|
||||||
|
tests:
|
||||||
|
- it: should not create an internal service by default
|
||||||
|
set:
|
||||||
|
controller.service.enabled: true
|
||||||
|
controller.service.internal.enabled: false
|
||||||
|
asserts:
|
||||||
|
- hasDocuments:
|
||||||
|
count: 0
|
||||||
|
|
||||||
|
- it: should create an internal service when enabled
|
||||||
|
set:
|
||||||
|
controller.service.enabled: true
|
||||||
|
controller.service.internal.enabled: true
|
||||||
|
controller.service.internal.annotations:
|
||||||
|
test.annotation: "true"
|
||||||
|
asserts:
|
||||||
|
- hasDocuments:
|
||||||
|
count: 1
|
||||||
|
- isKind:
|
||||||
|
of: Service
|
|
@ -0,0 +1,20 @@
|
||||||
|
suite: test controller metrics service
|
||||||
|
templates:
|
||||||
|
- controller-service-metrics.yaml
|
||||||
|
|
||||||
|
tests:
|
||||||
|
- it: should not create a metrics service by default
|
||||||
|
set:
|
||||||
|
controller.metrics.enabled: false
|
||||||
|
asserts:
|
||||||
|
- hasDocuments:
|
||||||
|
count: 0
|
||||||
|
|
||||||
|
- it: should create a metrics service when enabled
|
||||||
|
set:
|
||||||
|
controller.metrics.enabled: true
|
||||||
|
asserts:
|
||||||
|
- hasDocuments:
|
||||||
|
count: 1
|
||||||
|
- isKind:
|
||||||
|
of: Service
|
32
charts/ingress-nginx/tests/controller-service_test.yaml
Normal file
32
charts/ingress-nginx/tests/controller-service_test.yaml
Normal file
|
@ -0,0 +1,32 @@
|
||||||
|
suite: test controller service
|
||||||
|
templates:
|
||||||
|
- controller-service.yaml
|
||||||
|
|
||||||
|
tests:
|
||||||
|
- it: should not create any service by default
|
||||||
|
set:
|
||||||
|
controller.service.enabled: false
|
||||||
|
asserts:
|
||||||
|
- hasDocuments:
|
||||||
|
count: 0
|
||||||
|
|
||||||
|
- it: should create a service when enabled
|
||||||
|
set:
|
||||||
|
controller.service.enabled: true
|
||||||
|
asserts:
|
||||||
|
- hasDocuments:
|
||||||
|
count: 1
|
||||||
|
- isKind:
|
||||||
|
of: Service
|
||||||
|
- equal:
|
||||||
|
path: metadata.name
|
||||||
|
value: RELEASE-NAME-ingress-nginx-controller
|
||||||
|
|
||||||
|
- it: custom service type
|
||||||
|
set:
|
||||||
|
controller.service.enabled: true
|
||||||
|
controller.service.type: NodePort
|
||||||
|
asserts:
|
||||||
|
- equal:
|
||||||
|
path: spec.type
|
||||||
|
value: NodePort
|
32
charts/ingress-nginx/tests/default-backend-service_test.yaml
Normal file
32
charts/ingress-nginx/tests/default-backend-service_test.yaml
Normal file
|
@ -0,0 +1,32 @@
|
||||||
|
suite: test default backend service
|
||||||
|
templates:
|
||||||
|
- default-backend-service.yaml
|
||||||
|
|
||||||
|
tests:
|
||||||
|
- it: should not create any default backend service by default
|
||||||
|
set:
|
||||||
|
defaultBackend.enabled: false
|
||||||
|
asserts:
|
||||||
|
- hasDocuments:
|
||||||
|
count: 0
|
||||||
|
|
||||||
|
- it: should create a default backend service when enabled
|
||||||
|
set:
|
||||||
|
defaultBackend.enabled: true
|
||||||
|
asserts:
|
||||||
|
- hasDocuments:
|
||||||
|
count: 1
|
||||||
|
- isKind:
|
||||||
|
of: Service
|
||||||
|
- equal:
|
||||||
|
path: metadata.name
|
||||||
|
value: RELEASE-NAME-ingress-nginx-defaultbackend
|
||||||
|
|
||||||
|
- it: verify service port configuration
|
||||||
|
set:
|
||||||
|
defaultBackend.enabled: true
|
||||||
|
defaultBackend.service.port: 80
|
||||||
|
asserts:
|
||||||
|
- equal:
|
||||||
|
path: spec.ports[0].port
|
||||||
|
value: 80
|
Loading…
Reference in a new issue