Skip to content

Commit c6fa5b8

Browse files
committed
add test to ensure otel is disabled if endpoint is missing
1 parent 15b8fbb commit c6fa5b8

File tree

2 files changed

+61
-0
lines changed

2 files changed

+61
-0
lines changed
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
kind: ConfigMap
2+
apiVersion: v1
3+
metadata:
4+
name: nginx-config
5+
namespace: nginx-ingress
6+
data:
7+
otel-exporter-header-name: "x-otel-header"
8+
otel-exporter-header-value: "otel-header-value"
9+
otel-service-name: "nginx-ingress-controller:nginx"
10+
otel-trace-in-http: "true"

tests/suite/test_otel.py

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
cm_service_name = f"{TEST_DATA}/otel/configmap-with-service-name.yaml"
1717
cm_otel_trace = f"{TEST_DATA}/otel/configmap-with-otel-trace.yaml"
1818
cm_all = f"{TEST_DATA}/otel/configmap-with-all.yaml"
19+
cm_all_except_endpoint = f"{TEST_DATA}/otel/configmap-with-all-except-endpoint.yaml"
1920
otel_module = "modules/ngx_otel_module.so"
2021
exporter = "otel.example.com:4317"
2122
otel_exporter_header_name = "x-otel-header"
@@ -420,3 +421,53 @@ def test_otel_all(
420421
cm_default,
421422
)
422423
wait_before_test(WAIT_TIME)
424+
425+
def test_otel_all_except_endpoint(
426+
self,
427+
kube_apis,
428+
ingress_controller_prerequisites,
429+
ingress_controller,
430+
):
431+
"""
432+
Test:
433+
1. NIC starts with all otel configuration except endpoint configured in the `nginx-config`
434+
2. Ensure that the `ngx_otel_module.so` is not in the nginx.conf
435+
3. Ensure that the `otel_exporter` is not in the nginx.conf
436+
4. Ensure that the `service-name` is not in the nginx.conf
437+
5. Ensure that `otel_trace` is not in the nginx.conf
438+
"""
439+
configmap_name = "nginx-config"
440+
441+
print("Step 1: apply nginx-config map")
442+
replace_configmap_from_yaml(
443+
kube_apis.v1,
444+
configmap_name,
445+
ingress_controller_prerequisites.namespace,
446+
cm_all_except_endpoint,
447+
)
448+
449+
wait_before_test(WAIT_TIME)
450+
nginx_config = get_nginx_template_conf(
451+
kube_apis.v1, ingress_controller_prerequisites.namespace, print_log=False
452+
)
453+
454+
print("Step 2: Ensure that the otel module is not loaded")
455+
assert otel_module not in (nginx_config)
456+
457+
print("Step 3: Ensure that the otel_exporter is not enabled")
458+
assert "otel_exporter" not in (nginx_config)
459+
460+
print("Step 4: Ensure that the service-name is not correctly configured")
461+
assert f"otel_service_name {otel_service_name}" not in (nginx_config)
462+
463+
print("Step 5: Ensure that otel_trace is not configured")
464+
assert "otel_trace on;" not in (nginx_config)
465+
466+
print("Step 6: reset the configmap to default")
467+
replace_configmap_from_yaml(
468+
kube_apis.v1,
469+
configmap_name,
470+
ingress_controller_prerequisites.namespace,
471+
cm_default,
472+
)
473+
wait_before_test(WAIT_TIME)

0 commit comments

Comments
 (0)