mirror of
https://github.com/bjw-s-labs/helm-charts.git
synced 2025-07-03 08:37:03 +02:00
226 lines
6.3 KiB
YAML
226 lines
6.3 KiB
YAML
---
|
|
# yaml-language-server: $schema=https://raw.githubusercontent.com/helm-unittest/helm-unittest/main/schema/helm-testsuite.json
|
|
suite: serviceMonitor values
|
|
templates:
|
|
- common.yaml
|
|
values:
|
|
- ../_values/controllers_main_default_container.yaml
|
|
tests:
|
|
- it: a serviceMonitor is not created by default
|
|
asserts:
|
|
- hasDocuments:
|
|
count: 1
|
|
- documentIndex: 0
|
|
not: true
|
|
isKind:
|
|
of: ServiceMonitor
|
|
|
|
- it: a serviceMonitor is not created when disabled
|
|
set:
|
|
serviceMonitor:
|
|
main:
|
|
enabled: false
|
|
serviceName: "{{ .Release.Name }}"
|
|
asserts:
|
|
- hasDocuments:
|
|
count: 1
|
|
- documentIndex: 0
|
|
not: true
|
|
isKind:
|
|
of: ServiceMonitor
|
|
|
|
- it: a serviceMonitor is created
|
|
set:
|
|
serviceMonitor:
|
|
main:
|
|
labels:
|
|
test.label: testvalue
|
|
serviceName: "{{ .Release.Name }}"
|
|
endpoints:
|
|
- port: http
|
|
scheme: http
|
|
path: /metrics
|
|
interval: 1m
|
|
scrapeTimeout: 10s
|
|
asserts:
|
|
- hasDocuments:
|
|
count: 2
|
|
- documentIndex: &ServiceMonitorDocument 1
|
|
isKind:
|
|
of: ServiceMonitor
|
|
- documentIndex: *ServiceMonitorDocument
|
|
equal:
|
|
path: metadata.name
|
|
value: RELEASE-NAME
|
|
- documentIndex: *ServiceMonitorDocument
|
|
equal:
|
|
path: spec.namespaceSelector
|
|
value:
|
|
matchNames:
|
|
- NAMESPACE
|
|
- documentIndex: *ServiceMonitorDocument
|
|
equal:
|
|
path: spec.jobLabel
|
|
value: RELEASE-NAME
|
|
- documentIndex: *ServiceMonitorDocument
|
|
equal:
|
|
path: spec.selector.matchLabels
|
|
value:
|
|
app.kubernetes.io/instance: RELEASE-NAME
|
|
app.kubernetes.io/name: RELEASE-NAME
|
|
app.kubernetes.io/service: RELEASE-NAME
|
|
- documentIndex: *ServiceMonitorDocument
|
|
equal:
|
|
path: spec.endpoints
|
|
value:
|
|
- port: http
|
|
scheme: http
|
|
path: /metrics
|
|
interval: 1m
|
|
scrapeTimeout: 10s
|
|
- documentIndex: *ServiceMonitorDocument
|
|
equal:
|
|
path: metadata.labels
|
|
value:
|
|
app.kubernetes.io/instance: RELEASE-NAME
|
|
app.kubernetes.io/managed-by: Helm
|
|
app.kubernetes.io/name: RELEASE-NAME
|
|
helm.sh/chart: common-test-1.0.0
|
|
test.label: testvalue
|
|
|
|
- it: a serviceMonitor is created with nameOverride
|
|
set:
|
|
serviceMonitor:
|
|
main:
|
|
nameOverride: test
|
|
serviceName: "{{ .Release.Name }}"
|
|
endpoints:
|
|
- port: http
|
|
scheme: http
|
|
path: /metrics
|
|
interval: 1m
|
|
scrapeTimeout: 10s
|
|
asserts:
|
|
- hasDocuments:
|
|
count: 2
|
|
- documentIndex: &ServiceMonitorDocument 1
|
|
isKind:
|
|
of: ServiceMonitor
|
|
- documentIndex: *ServiceMonitorDocument
|
|
equal:
|
|
path: metadata.name
|
|
value: RELEASE-NAME-test
|
|
- documentIndex: *ServiceMonitorDocument
|
|
equal:
|
|
path: spec.selector.matchLabels
|
|
value:
|
|
app.kubernetes.io/instance: RELEASE-NAME
|
|
app.kubernetes.io/name: RELEASE-NAME
|
|
app.kubernetes.io/service: RELEASE-NAME
|
|
|
|
- it: a serviceMonitor is created with a templated service
|
|
set:
|
|
serviceMonitor:
|
|
main:
|
|
serviceName: "{{ .Release.Name }}"
|
|
endpoints:
|
|
- port: http
|
|
scheme: http
|
|
path: /metrics
|
|
interval: 1m
|
|
scrapeTimeout: 10s
|
|
asserts:
|
|
- hasDocuments:
|
|
count: 2
|
|
- documentIndex: &ServiceMonitorDocument 1
|
|
isKind:
|
|
of: ServiceMonitor
|
|
- documentIndex: *ServiceMonitorDocument
|
|
equal:
|
|
path: metadata.name
|
|
value: RELEASE-NAME
|
|
- documentIndex: *ServiceMonitorDocument
|
|
equal:
|
|
path: spec.selector.matchLabels
|
|
value:
|
|
app.kubernetes.io/instance: RELEASE-NAME
|
|
app.kubernetes.io/name: RELEASE-NAME
|
|
app.kubernetes.io/service: RELEASE-NAME
|
|
|
|
- it: a serviceMonitor is created with a custom selector
|
|
set:
|
|
serviceMonitor:
|
|
main:
|
|
selector:
|
|
matchExpressions:
|
|
test: "true"
|
|
endpoints:
|
|
- port: http
|
|
scheme: http
|
|
path: /metrics
|
|
interval: 1m
|
|
scrapeTimeout: 10s
|
|
asserts:
|
|
- hasDocuments:
|
|
count: 2
|
|
- documentIndex: &ServiceMonitorDocument 1
|
|
isKind:
|
|
of: ServiceMonitor
|
|
- documentIndex: *ServiceMonitorDocument
|
|
equal:
|
|
path: metadata.name
|
|
value: RELEASE-NAME
|
|
- documentIndex: *ServiceMonitorDocument
|
|
equal:
|
|
path: spec.selector
|
|
value:
|
|
matchExpressions:
|
|
test: "true"
|
|
|
|
- it: a serviceMonitor is created with targetLabels
|
|
set:
|
|
serviceMonitor:
|
|
main:
|
|
enabled: true
|
|
serviceName: "{{ .Release.Name }}"
|
|
endpoints:
|
|
- port: http
|
|
scheme: http
|
|
path: /metrics
|
|
interval: 1m
|
|
scrapeTimeout: 10s
|
|
targetLabels:
|
|
- testlabel1
|
|
- testlabel2
|
|
asserts:
|
|
- hasDocuments:
|
|
count: 2
|
|
- documentIndex: &ServiceMonitorDocument 1
|
|
isKind:
|
|
of: ServiceMonitor
|
|
- documentIndex: *ServiceMonitorDocument
|
|
equal:
|
|
path: metadata.name
|
|
value: RELEASE-NAME
|
|
- documentIndex: *ServiceMonitorDocument
|
|
equal:
|
|
path: spec.selector.matchLabels
|
|
value:
|
|
app.kubernetes.io/instance: RELEASE-NAME
|
|
app.kubernetes.io/name: RELEASE-NAME
|
|
app.kubernetes.io/service: RELEASE-NAME
|
|
- documentIndex: *ServiceMonitorDocument
|
|
equal:
|
|
path: spec.endpoints
|
|
value:
|
|
- port: http
|
|
scheme: http
|
|
path: /metrics
|
|
interval: 1m
|
|
scrapeTimeout: 10s
|
|
- documentIndex: *ServiceMonitorDocument
|
|
equal:
|
|
path: spec.targetLabels
|
|
value:
|
|
- testlabel1
|
|
- testlabel2
|