From 475b25a85b9c3438d66d3aeeb2dd47440ba2903f Mon Sep 17 00:00:00 2001 From: Ishaan Jaff Date: Tue, 29 Sep 2026 22:45:49 -0700 Subject: [PATCH] test(agent-tracing): cover clickhouse schema ddl --- .../integrations/clickhouse/test_schema.py | 51 +++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 tests/test_litellm/integrations/clickhouse/test_schema.py diff --git a/tests/test_litellm/integrations/clickhouse/test_schema.py b/tests/test_litellm/integrations/clickhouse/test_schema.py new file mode 100644 index 00000000000..2e40a7dfbab --- /dev/null +++ b/tests/test_litellm/integrations/clickhouse/test_schema.py @@ -0,0 +1,51 @@ +""" +Tests for the agent tracing ClickHouse DDL. +""" + +import os +import sys + +sys.path.insert(0, os.path.abspath("../../..")) + +from litellm.integrations.clickhouse.schema import ( + AGENT_TRACES_TABLE, + OTEL_TRACES_TABLE, + SPEND_LOGS_TABLE, + schema_statements, +) + + +def test_schema_statements_cover_all_tables_and_retention(): + statements = schema_statements( + "litellm", trace_retention_days=7, spend_log_retention_days=45 + ) + ddl = "\n".join(statements) + + for table in (OTEL_TRACES_TABLE, AGENT_TRACES_TABLE, SPEND_LOGS_TABLE): + assert f"litellm.{table}" in ddl + assert f"litellm.{AGENT_TRACES_TABLE}_mv TO litellm.{AGENT_TRACES_TABLE}" in ddl + assert "INTERVAL 7 DAY" in ddl + assert "INTERVAL 45 DAY" in ddl + + +def test_otel_traces_keeps_collector_compatible_columns(): + otel_ddl = next( + s + for s in schema_statements("litellm", 30, 90) + if f"TABLE IF NOT EXISTS litellm.{OTEL_TRACES_TABLE}" in s + ) + for column in ( + "Timestamp", + "TraceId", + "SpanId", + "ParentSpanId", + "SpanName", + "ServiceName", + "ResourceAttributes", + "SpanAttributes", + "Duration", + "StatusCode", + ): + assert f"{column} " in otel_ddl + # join key to spend logs + assert "LiteLLMRequestId" in otel_ddl