test(ingress): pin the position of the target-stage identity drop

A containment check passes even if a rule added after the drop sets the
identity labels again. Asserting both endpoints' full target relabel
lists fixes the drop as the last rule, so such a change fails the test.

Assisted-by: LLM
Signed-off-by: ZverGuy <maximbel2003@gmail.com>
This commit is contained in:
ZverGuy committed 2026-11-05 00:35:37 +07:00
1 parent 1018eaa3b6
commit 699b5ce78e
1 file changed
+35 -5
@@ -20,13 +20,43 @@ tests:
- lengthEqual:
path: spec.podMetricsEndpoints
count: 1
- contains:
path: spec.podMetricsEndpoints[0].relabelConfigs
content:
action: labeldrop
regex: apps_cozystack_io_application_(group|kind|name)
- equal:
path: spec.podMetricsEndpoints[0].metricRelabelConfigs
value:
- action: labeldrop
regex: apps_cozystack_io_application_(group|kind|name)
# Endpoint rules run after the scrape class rules, so the drop takes
# effect wherever it sits in this list; it is pinned last so that no
# later rule can set the identity again.
- it: drops the identity from the basic endpoint's target as its last rule
documentIndex: 0
asserts:
- equal:
path: spec.podMetricsEndpoints[0].relabelConfigs
value:
- replacement: nginx-ingress-controller
targetLabel: job
- sourceLabels: [__meta_kubernetes_pod_node_name]
targetLabel: node
- targetLabel: tier
replacement: cluster
- action: labeldrop
regex: apps_cozystack_io_application_(group|kind|name)
- it: drops the identity from the detailed endpoint's target as its last rule
documentIndex: 1
asserts:
- equal:
path: spec.podMetricsEndpoints[0].relabelConfigs
value:
- replacement: nginx-ingress-controller
targetLabel: job
- sourceLabels: [__meta_kubernetes_pod_node_name]
targetLabel: node
- sourceLabels: [__meta_kubernetes_pod_label_app_kubernetes_io_name]
targetLabel: controller
- targetLabel: tier
replacement: cluster
- action: labeldrop
regex: apps_cozystack_io_application_(group|kind|name)