Skip to content

Commit 699b5ce

Browse files
committed
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 <[email protected]>
1 parent 1018eaa commit 699b5ce

1 file changed

Lines changed: 35 additions & 5 deletions

File tree

‎packages/extra/ingress/tests/application_identity_test.yaml‎

Lines changed: 35 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,43 @@ tests:
2020
- lengthEqual:
2121
path: spec.podMetricsEndpoints
2222
count: 1
23-
- contains:
24-
path: spec.podMetricsEndpoints[0].relabelConfigs
25-
content:
26-
action: labeldrop
27-
regex: apps_cozystack_io_application_(group|kind|name)
2823
- equal:
2924
path: spec.podMetricsEndpoints[0].metricRelabelConfigs
3025
value:
3126
- action: labeldrop
3227
regex: apps_cozystack_io_application_(group|kind|name)
28+
29+
# Endpoint rules run after the scrape class rules, so the drop takes
30+
# effect wherever it sits in this list; it is pinned last so that no
31+
# later rule can set the identity again.
32+
- it: drops the identity from the basic endpoint's target as its last rule
33+
documentIndex: 0
34+
asserts:
35+
- equal:
36+
path: spec.podMetricsEndpoints[0].relabelConfigs
37+
value:
38+
- replacement: nginx-ingress-controller
39+
targetLabel: job
40+
- sourceLabels: [__meta_kubernetes_pod_node_name]
41+
targetLabel: node
42+
- targetLabel: tier
43+
replacement: cluster
44+
- action: labeldrop
45+
regex: apps_cozystack_io_application_(group|kind|name)
46+
47+
- it: drops the identity from the detailed endpoint's target as its last rule
48+
documentIndex: 1
49+
asserts:
50+
- equal:
51+
path: spec.podMetricsEndpoints[0].relabelConfigs
52+
value:
53+
- replacement: nginx-ingress-controller
54+
targetLabel: job
55+
- sourceLabels: [__meta_kubernetes_pod_node_name]
56+
targetLabel: node
57+
- sourceLabels: [__meta_kubernetes_pod_label_app_kubernetes_io_name]
58+
targetLabel: controller
59+
- targetLabel: tier
60+
replacement: cluster
61+
- action: labeldrop
62+
regex: apps_cozystack_io_application_(group|kind|name)

0 commit comments

Comments
 (0)