diff --git a/tests/integration/helpers.py b/tests/integration/helpers.py index edc37b5..fd83122 100644 --- a/tests/integration/helpers.py +++ b/tests/integration/helpers.py @@ -27,6 +27,13 @@ S3_INTEGRATOR = "s3-integrator" WORKER_NAME = "tempo-worker" APP_NAME = "tempo" +protocols_endpoints = { + "jaeger_thrift_http": "https://{}:14268/api/traces?format=jaeger.thrift", + "zipkin": "https://{}:9411/v1/traces", + "jaeger_grpc": "{}:14250", + "otlp_http": "https://{}:4318/v1/traces", + "otlp_grpc": "{}:4317", +} logger = logging.getLogger(__name__) diff --git a/tests/integration/test_ingressed_tls.py b/tests/integration/test_ingressed_tls.py index 49c9a0b..9f5a221 100644 --- a/tests/integration/test_ingressed_tls.py +++ b/tests/integration/test_ingressed_tls.py @@ -4,7 +4,12 @@ import pytest import yaml -from helpers import deploy_cluster, emit_trace, get_traces_patiently +from helpers import ( + deploy_cluster, + emit_trace, + get_traces_patiently, + protocols_endpoints, +) from juju.application import Application from pytest_operator.plugin import OpsTest @@ -20,7 +25,7 @@ logger = logging.getLogger(__name__) -async def get_ingress_proxied_endpoint(ops_test: OpsTest): +async def get_ingress_proxied_hostname(ops_test: OpsTest): status = await ops_test.model.get_status() app = status["applications"][TRAEFIK_APP_NAME] status_msg = app["status"]["info"] @@ -31,6 +36,13 @@ async def get_ingress_proxied_endpoint(ops_test: OpsTest): return status_msg.replace("Serving at", "").strip() +async def get_tempo_ingressed_endpoint(hostname, protocol): + protocol_endpoint = protocols_endpoints.get(protocol) + if protocol_endpoint is None: + assert False, f"Invalid {protocol}" + return protocol_endpoint.format(hostname) + + @pytest.mark.setup @pytest.mark.abort_on_fail async def test_build_and_deploy(ops_test: OpsTest): @@ -68,7 +80,8 @@ async def test_push_tracegen_script_and_deps(ops_test: OpsTest): await ops_test.juju( "ssh", f"{APP_NAME}/0", - "python3 -m pip install opentelemetry-exporter-otlp-proto-grpc opentelemetry-exporter-otlp-proto-http", + "python3 -m pip install opentelemetry-exporter-otlp-proto-grpc opentelemetry-exporter-otlp-proto-http" + + " opentelemetry-exporter-zipkin opentelemetry-exporter-jaeger", ) @@ -104,38 +117,34 @@ async def test_relate(ops_test: OpsTest): @pytest.mark.abort_on_fail -async def test_verify_ingressed_trace_http_tls(ops_test: OpsTest, nonce, server_cert): - tempo_host = await get_ingress_proxied_endpoint(ops_test) - - await emit_trace( - f"https://{tempo_host}:4318/v1/traces", nonce=nonce, ops_test=ops_test, use_cert=True - ) - # THEN we can verify it's been ingested - assert await get_traces_patiently(tempo_host) +@pytest.mark.parametrize("protocol", list(protocols_endpoints.keys())) +async def test_verify_traces_force_enabled_protocols_tls(ops_test: OpsTest, nonce, protocol): - -@pytest.mark.abort_on_fail -async def test_verify_ingressed_traces_grpc_tls(ops_test: OpsTest, nonce, server_cert): - # enable otlp grpc receiver tempo_app: Application = ops_test.model.applications[APP_NAME] - await tempo_app.set_config( - { - "always_enable_otlp_grpc": "True", - } - ) - await ops_test.model.wait_for_idle( - apps=[APP_NAME], - status="active", - timeout=1000, - ) - tempo_host = await get_ingress_proxied_endpoint(ops_test) + # enable each protocol receiver + # otlp_http should be enabled by default + if protocol != "otlp_http": + await tempo_app.set_config( + { + f"always_enable_{protocol}": "True", + } + ) + await ops_test.model.wait_for_idle( + apps=[APP_NAME], + status="active", + timeout=1000, + ) + + tempo_host = await get_ingress_proxied_hostname(ops_test) + tempo_endpoint = await get_tempo_ingressed_endpoint(tempo_host, protocol=protocol) + # WHEN we emit a trace secured with TLS await emit_trace( - f"{tempo_host}:4317", nonce=nonce, proto="otlp_grpc", ops_test=ops_test, use_cert=True + tempo_endpoint, ops_test, nonce=nonce, verbose=1, proto=protocol, use_cert=True ) # THEN we can verify it's been ingested - assert await get_traces_patiently(tempo_host, service_name="tracegen-otlp_grpc") + await get_traces_patiently(tempo_host, service_name=f"tracegen-{protocol}") @pytest.mark.teardown diff --git a/tests/integration/test_tls.py b/tests/integration/test_tls.py index 3719c6b..014e836 100644 --- a/tests/integration/test_tls.py +++ b/tests/integration/test_tls.py @@ -10,6 +10,7 @@ get_application_ip, get_traces, get_traces_patiently, + protocols_endpoints, ) from juju.application import Application from pytest_operator.plugin import OpsTest @@ -19,13 +20,7 @@ SSC = "self-signed-certificates" SSC_APP_NAME = "ssc" TRACEGEN_SCRIPT_PATH = Path() / "scripts" / "tracegen.py" -protocols_endpoints = { - "jaeger_thrift_http": "https://{}:14268/api/traces?format=jaeger.thrift", - "zipkin": "https://{}:9411/v1/traces", - "jaeger_grpc": "{}:14250", - "otlp_http": "https://{}:4318/v1/traces", - "otlp_grpc": "{}:4317", -} + logger = logging.getLogger(__name__) @@ -107,8 +102,6 @@ async def test_verify_traces_force_enabled_protocols_tls(ops_test: OpsTest, nonc tempo_app: Application = ops_test.model.applications[APP_NAME] # enable each protocol receiver - # for protocol in protocols_endpoints: - # otlp_http should be enabled by default if protocol != "otlp_http": await tempo_app.set_config(