Add more unit tests to helm chart

Signed-off-by: Stavros Foteinopoulos <stafot@gmail.com>
This commit is contained in:
Stavros Foteinopoulos 2023-12-06 18:39:43 +02:00
parent 8dfdc30958
commit edd94f07a0
No known key found for this signature in database
GPG key ID: 7187B9E13C5E5E93
12 changed files with 269 additions and 0 deletions

View file

@ -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

View file

@ -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

View 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

View 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

View 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"

View 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

View 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

View file

@ -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

View file

@ -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

View file

@ -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

View 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

View 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