Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Chart: Add tests for PrometheusRule & ServiceMonitor. #11888

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion charts/ingress-nginx/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,7 @@ As of version `1.26.0` of this chart, by simply not providing any clusterIP valu
| controller.metrics.service.servicePort | int | `10254` | |
| controller.metrics.service.type | string | `"ClusterIP"` | |
| controller.metrics.serviceMonitor.additionalLabels | object | `{}` | |
| controller.metrics.serviceMonitor.annotations | object | `{}` | |
| controller.metrics.serviceMonitor.annotations | object | `{}` | Annotations to be added to the ServiceMonitor. |
| controller.metrics.serviceMonitor.enabled | bool | `false` | |
| controller.metrics.serviceMonitor.metricRelabelings | list | `[]` | |
| controller.metrics.serviceMonitor.namespace | string | `""` | |
Expand Down
17 changes: 17 additions & 0 deletions charts/ingress-nginx/tests/controller-prometheusrule_test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
suite: Controller > PrometheusRule
templates:
- controller-prometheusrule.yaml

tests:
- it: should create a PrometheusRule if `controller.metrics.prometheusRule.enabled` is true
set:
controller.metrics.enabled: true
controller.metrics.prometheusRule.enabled: true
asserts:
- hasDocuments:
count: 1
- isKind:
of: PrometheusRule
- equal:
path: metadata.name
value: RELEASE-NAME-ingress-nginx-controller
29 changes: 29 additions & 0 deletions charts/ingress-nginx/tests/controller-servicemonitor_test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
suite: Controller > ServiceMonitor
templates:
- controller-servicemonitor.yaml

tests:
- it: should create a ServiceMonitor if `controller.metrics.serviceMonitor.enabled` is true
set:
controller.metrics.enabled: true
controller.metrics.serviceMonitor.enabled: true
asserts:
- hasDocuments:
count: 1
- isKind:
of: ServiceMonitor
- equal:
path: metadata.name
value: RELEASE-NAME-ingress-nginx-controller

- it: should create a ServiceMonitor with annotations if `controller.metrics.serviceMonitor.annotations` is set
set:
controller.metrics.enabled: true
controller.metrics.serviceMonitor.enabled: true
controller.metrics.serviceMonitor.annotations:
my-little-annotation: test-value
asserts:
- equal:
path: metadata.annotations
value:
my-little-annotation: test-value
1 change: 1 addition & 0 deletions charts/ingress-nginx/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -847,6 +847,7 @@ controller:
serviceMonitor:
enabled: false
additionalLabels: {}
# -- Annotations to be added to the ServiceMonitor.
annotations: {}
## The label to use to retrieve the job name from.
## jobLabel: "app.kubernetes.io/name"
Expand Down