fix: introduce unit tests for service monitor and metrics secret
Signed-off-by: Hitesh Nayak <hiteshnayak305@gmail.com>
This commit is contained in:
@ -0,0 +1,21 @@
|
||||
suite: Metrics secret template (gitea.metrics.serviceMonitor disabled)
|
||||
release:
|
||||
name: gitea-unittests
|
||||
namespace: testing
|
||||
templates:
|
||||
- templates/gitea/metrics-secret.yaml
|
||||
tests:
|
||||
- it: renders nothing if gitea.metrics.serviceMonitor disabled and gitea.config.metrics.TOKEN empty
|
||||
set:
|
||||
gitea.metrics.serviceMonitor.enabled: false
|
||||
gitea.config.metrics.TOKEN: ""
|
||||
asserts:
|
||||
- hasDocuments:
|
||||
count: 0
|
||||
- it: renders nothing if gitea.metrics.serviceMonitor disabled and gitea.config.metrics.TOKEN not empty
|
||||
set:
|
||||
gitea.metrics.serviceMonitor.enabled: false
|
||||
gitea.config.metrics.TOKEN: "test-token"
|
||||
asserts:
|
||||
- hasDocuments:
|
||||
count: 0
|
@ -0,0 +1,31 @@
|
||||
suite: Metrics secret template (gitea.metrics.serviceMonitor enabled)
|
||||
release:
|
||||
name: gitea-unittests
|
||||
namespace: testing
|
||||
templates:
|
||||
- templates/gitea/metrics-secret.yaml
|
||||
tests:
|
||||
- it: renders nothing if gitea.metrics.serviceMonitor enabled and gitea.config.metrics.TOKEN empty
|
||||
set:
|
||||
gitea.metrics.serviceMonitor.enabled: true
|
||||
gitea.config.metrics.TOKEN: ""
|
||||
asserts:
|
||||
- hasDocuments:
|
||||
count: 0
|
||||
- it: renders Secret if gitea.metrics.serviceMonitor enabled and gitea.config.metrics.TOKEN not empty
|
||||
set:
|
||||
gitea.metrics.serviceMonitor.enabled: true
|
||||
gitea.config.metrics.TOKEN: "test-token"
|
||||
asserts:
|
||||
- hasDocuments:
|
||||
count: 1
|
||||
- documentIndex: 0
|
||||
containsDocument:
|
||||
kind: Secret
|
||||
apiVersion: v1
|
||||
name: gitea-unittests-metrics-secret
|
||||
- isNotNullOrEmpty:
|
||||
path: metadata.labels
|
||||
- equal:
|
||||
path: data.token
|
||||
value: "dGVzdC10b2tlbg=="
|
21
unittests/servicemonitor/servicemonitor-disabled.yaml
Normal file
21
unittests/servicemonitor/servicemonitor-disabled.yaml
Normal file
@ -0,0 +1,21 @@
|
||||
suite: ServiceMonitor template (gitea.metrics.serviceMonitor disabled)
|
||||
release:
|
||||
name: gitea-unittests
|
||||
namespace: testing
|
||||
templates:
|
||||
- templates/gitea/servicemonitor.yaml
|
||||
tests:
|
||||
- it: renders nothing if gitea.metrics.serviceMonitor disabled and gitea.config.metrics.TOKEN empty
|
||||
set:
|
||||
gitea.metrics.serviceMonitor.enabled: false
|
||||
gitea.config.metrics.TOKEN: ""
|
||||
asserts:
|
||||
- hasDocuments:
|
||||
count: 0
|
||||
- it: renders nothing if gitea.metrics.serviceMonitor disabled and gitea.config.metrics.TOKEN not empty
|
||||
set:
|
||||
gitea.metrics.serviceMonitor.enabled: false
|
||||
gitea.config.metrics.TOKEN: "test-token"
|
||||
asserts:
|
||||
- hasDocuments:
|
||||
count: 0
|
49
unittests/servicemonitor/servicemonitor-enabled.yaml
Normal file
49
unittests/servicemonitor/servicemonitor-enabled.yaml
Normal file
@ -0,0 +1,49 @@
|
||||
suite: ServiceMonitor template (gitea.metrics.serviceMonitor enabled)
|
||||
release:
|
||||
name: gitea-unittests
|
||||
namespace: testing
|
||||
templates:
|
||||
- templates/gitea/servicemonitor.yaml
|
||||
tests:
|
||||
- it: renders unsecure ServiceMonitor if gitea.metrics.serviceMonitor enabled and gitea.config.metrics.TOKEN empty
|
||||
set:
|
||||
gitea.metrics.serviceMonitor.enabled: true
|
||||
gitea.config.metrics.TOKEN: ""
|
||||
asserts:
|
||||
- hasDocuments:
|
||||
count: 1
|
||||
- documentIndex: 0
|
||||
containsDocument:
|
||||
kind: ServiceMonitor
|
||||
apiVersion: monitoring.coreos.com/v1
|
||||
name: gitea-unittests
|
||||
- isNotNullOrEmpty:
|
||||
path: metadata.labels
|
||||
- equal:
|
||||
path: spec.endpoints
|
||||
value:
|
||||
- port: http
|
||||
- it: renders secure ServiceMonitor if gitea.metrics.serviceMonitor enabled and gitea.config.metrics.TOKEN not empty
|
||||
set:
|
||||
gitea.metrics.serviceMonitor.enabled: true
|
||||
gitea.config.metrics.TOKEN: "test-token"
|
||||
asserts:
|
||||
- hasDocuments:
|
||||
count: 1
|
||||
- documentIndex: 0
|
||||
containsDocument:
|
||||
kind: ServiceMonitor
|
||||
apiVersion: monitoring.coreos.com/v1
|
||||
name: gitea-unittests
|
||||
- isNotNullOrEmpty:
|
||||
path: metadata.labels
|
||||
- equal:
|
||||
path: spec.endpoints
|
||||
value:
|
||||
- port: http
|
||||
authorization:
|
||||
type: Bearer
|
||||
credentials:
|
||||
name: gitea-unittests-metrics-secret
|
||||
key: token
|
||||
optional: true
|
Reference in New Issue
Block a user