Skip to content
Snippets Groups Projects
Commit d41fd63b authored by Nacho Barrientos's avatar Nacho Barrientos
Browse files

[MONIT-4147] Add some units tests

parent 11c444bd
No related branches found
No related tags found
No related merge requests found
Pipeline #10937887 failed
......@@ -42,6 +42,12 @@ helm_lint:
- helm dep update .
- helm lint --strict .
unittest:
stage: test
image: registry.cern.ch/docker.io/helmunittest/helm-unittest:3.17.0-0.7.2
script:
- helm unittest -f 'tests/**/*.yaml' .
version_test:
stage: test
rules:
......
......@@ -27,4 +27,5 @@ README.md
.idea/
*.tmproj
.vscode/
config
\ No newline at end of file
config
tests/
\ No newline at end of file
suite: test fluentbit-logs configmap
templates:
- fluentbit-logs/configmap.yaml
tests:
- it: should deploy nothing by default
asserts:
- containsDocument:
kind: ConfigMap
not: true
- it: should fail to deploy if enabled due to missing cluster name
set:
logs.enabled: true
logs.fluentbit.enabled: true
asserts:
- failedTemplate:
errorMessage: "kubernetes.clusterName is missing"
- it: should fail to deploy if enabled due to missing tenant details
set:
logs.enabled: true
logs.fluentbit.enabled: true
kubernetes.clusterName: test
asserts:
- failedTemplate:
errorMessage: "Tenant name is required"
- it: should fail to deploy if enabled when tenant name available but no tenant password
set:
logs.enabled: true
logs.fluentbit.enabled: true
tenant.name: test
kubernetes.clusterName: test
asserts:
- failedTemplate:
errorMessage: "Tenant password is required"
- it: should deploy if logs processing is enabled and required values are fed
set:
tenant.name: test
tenant.password: test
kubernetes.clusterName: test
logs.enabled: true
logs.fluentbit.enabled: true
asserts:
- containsDocument:
kind: ConfigMap
apiVersion: v1
suite: test fluentbit-logs daemonset
templates:
- fluentbit-logs/daemonset.yaml
tests:
- it: should not be deployed by default
asserts:
- containsDocument:
kind: DaemonSet
not: true
- it: should be deployed if logs.enabled and logs.fluentbit.enabled is true
set:
logs.enabled: true
logs.fluentbit.enabled: true
asserts:
- containsDocument:
kind: DaemonSet
apiVersion: "apps/v1"
- it: should not be deployed if logs.enabled is false
set:
logs.enabled: false
asserts:
- containsDocument:
kind: DaemonSet
not: true
- it: should not be deployed if logs.enabled is true and logs.fluentbit.enabled is false
set:
logs.enabled: true
logs.fluentbit.enabled: false
asserts:
- containsDocument:
kind: DaemonSet
not: true
suite: test fluentbit-metrics configmap
templates:
- fluentbit-metrics/configmap.yaml
tests:
- it: should fail to deploy by default due to missing tenant details
asserts:
- failedTemplate:
errorMessage: "Tenant name is required"
- it: should fail to deploy if tenant name available but no tenant password
set:
tenant.name: test
asserts:
- failedTemplate:
errorMessage: "Tenant password is required"
- it: should deploy nothing by default when required values are fed
set:
tenant.name: test
tenant.password: test
asserts:
- containsDocument:
kind: ConfigMap
not: true
- it: should deploy if metrics processing is enabled and required values are fed
set:
tenant.name: test
tenant.password: test
metrics.enabled: true
metrics.fluentbit.enabled: true
asserts:
- containsDocument:
kind: ConfigMap
apiVersion: v1
suite: test fluentbit-metrics statefulset
templates:
- fluentbit-metrics/statefulset.yaml
tests:
- it: should be deployed by default
asserts:
- containsDocument:
kind: StatefulSet
apiVersion: "apps/v1"
- it: should not be deployed if metrics.enabled is false
set:
metrics.enabled: false
asserts:
- containsDocument:
kind: StatefulSet
not: true
- it: should not be deployed if metrics.enabled is true and metrics.fluentbit.enabled is false
set:
metrics.enabled: true
metrics.fluentbit.enabled: false
asserts:
- containsDocument:
kind: StatefulSet
not: true
suite: test prometheus prometheus
templates:
- prometheus/prometheus.yaml
tests:
- it: should be deployed with cluster-local remote write by default
set:
kubernetes.clusterName: test
asserts:
- containsDocument:
kind: Prometheus
apiVersion: "monitoring.coreos.com/v1"
- lengthEqual:
path: spec.remoteWrite
count: 1
- equal:
path: spec.remoteWrite[0].url
value: "http://it-monit-metrics-fluentbit:8080/api/prom/push"
- it: should be deployed with no remoteWrites if no fluentbit is available
set:
kubernetes.clusterName: test
metrics.fluentbit.enabled: false
asserts:
- containsDocument:
kind: Prometheus
apiVersion: "monitoring.coreos.com/v1"
- lengthEqual:
path: spec.remoteWrite
count: 0
- it: should be deployed with external remote write if configured
set:
kubernetes.clusterName: test
metrics.fluentbit.enabled: false
metrics.prometheus.server.remoteWrite.endpoint: "http://foo:123"
asserts:
- containsDocument:
kind: Prometheus
apiVersion: "monitoring.coreos.com/v1"
- contains:
path: spec.remoteWrite
content:
url: "http://foo:123"
tlsConfig:
insecureSkipVerify: true
basicAuth:
username:
name: it-monit-metrics-collector-prometheus
key: username
password:
name: it-monit-metrics-collector-prometheus
key: password
- lengthEqual:
path: spec.remoteWrite
count: 1
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment