SigNoz is an open-source, OpenTelemetry-native observability platform for your team and their AI agents. Get logs, metrics, and traces in one tool with features like APM, distributed tracing, log management, infra monitoring, etc. Combined with SigNoz MCP and a native AI teammate (in SigNoz Cloud) it helps you build more resilient apps.
TypeScript apmapplication-monitoringdistributed-tracinggogood-first-issuejaegerloglogsmetricsmonitoringnextjsobservabilityopen-sourceopentelemetryprometheusreactreactjsself-hostedtracingtypescript
fix: improve ttl integration tests (#9917)
Tushar Vats42c38d5d17fe
diff --git a/Makefile b/Makefileindex 14e7b0b57e..a0f041d6c9 100644--- a/Makefile+++ b/Makefile@@ -210,6 +210,23 @@ py-lint: ## Run lint for integration tests@cd tests/integration && poetry run autoflake .@cd tests/integration && poetry run pylint .+.PHONY: py-test-setup+py-test-setup: ## Runs integration tests+ @cd tests/integration && poetry run pytest --basetemp=./tmp/ -vv --reuse --capture=no src/bootstrap/setup.py::test_setup++.PHONY: py-test-teardown+py-test-teardown: ## Runs integration tests with teardown+ @cd tests/integration && poetry run pytest --basetemp=./tmp/ -vv --teardown --capture=no src/bootstrap/setup.py::test_teardown+.PHONY: py-testpy-test: ## Runs integration tests@cd tests/integration && poetry run pytest --basetemp=./tmp/ -vv --capture=no src/++.PHONY: py-clean+py-clean: ## Clear all pycache and pytest cache from tests directory recursively+ @echo ">> cleaning python cache files from tests directory"+ @find tests -type d -name __pycache__ -exec rm -rf {} + 2>/dev/null || true+ @find tests -type d -name .pytest_cache -exec rm -rf {} + 2>/dev/null || true+ @find tests -type f -name "*.pyc" -delete 2>/dev/null || true+ @find tests -type f -name "*.pyo" -delete 2>/dev/null || true+ @echo ">> python cache cleaned"diff --git a/tests/integration/fixtures/clickhouse.py b/tests/integration/fixtures/clickhouse.pyindex 5d79138f36..7dff90fcbd 100644--- a/tests/integration/fixtures/clickhouse.py+++ b/tests/integration/fixtures/clickhouse.py@@ -79,6 +79,41 @@ def clickhouse(<path>/clickhouse/task_queue/ddl</path><profile>default</profile></distributed_ddl>++ <storage_configuration>+ <disks>+ <default>+ <keep_free_space_bytes>1024</keep_free_space_bytes>+ </default>+ <cold>+ <type>local</type>+ <path>/var/lib/clickhouse/cold/</path>+ <keep_free_space_bytes>1024</keep_free_space_bytes>+ </cold>+ </disks>+ <policies>+ <default>+ <volumes>+ <default>+ <disk>default</disk>+ </default>+ <cold>+ <disk>cold</disk>+ </cold>+ </volumes>+ </default>+ <tiered>+ <volumes>+ <default>+ <disk>default</disk>+ </default>+ <cold>+ <disk>cold</disk>+ </cold>+ </volumes>+ </tiered>+ </policies>+ </storage_configuration></clickhouse>"""diff --git a/tests/integration/fixtures/logs.py b/tests/integration/fixtures/logs.pyindex fa67da56ab..44f5e56418 100644--- a/tests/integration/fixtures/logs.py+++ b/tests/integration/fixtures/logs.py@@ -34,8 +34,6 @@ class LogsResource(ABC):self.labels,self.fingerprint,self.seen_at_ts_bucket_start,- np.uint64(10),- np.uint64(15),])@@ -66,7 +64,7 @@ class LogsTagAttributes(ABC):tag_key: str,tag_type: str,tag_data_type: str,- string_value: str,+ string_value: Optional[str],number_value: np.float64,) -> None:self.unix_milli = np.int64(int(timestamp.timestamp() * 1e3))@@ -327,8 +325,6 @@ class Logs(ABC):self.scope_name,self.scope_version,self.scope_string,- np.uint64(10),- np.uint64(15),self.resources_string,])@@ -357,6 +353,11 @@ def insert_logs(database="signoz_logs",table="distributed_logs_v2_resource",data=[resource.np_arr() for resource in resources],+ column_names=[+ "labels",+ "fingerprint",+ "seen_at_ts_bucket_start",+ ],)tag_attributes: List[LogsTagAttributes] = []@@ -396,6 +397,27 @@ def insert_logs(database="signoz_logs",table="distributed_logs_v2",data=[log.np_arr() for log in logs],+ column_names=[+ "ts_bucket_start",+ "resource_fingerprint",+ "timestamp",+ "observed_timestamp",+ "id",+ "trace_id",+ "span_id",+ "trace_flags",+ "severity_text",+ "severity_number",+ "body",+ "attributes_string",+ "attributes_number",+ "attributes_bool",+ "resources_string",+ "scope_name",+ "scope_version",+ "scope_string",+ "resource",+ ],)yield _insert_logs@@ -427,19 +449,19 @@ def ttl_legacy_logs_v2_table_setup(request, signoz: types.SigNoz):# Setup coderesult = signoz.telemetrystore.conn.query(- "RENAME TABLE signoz_logs.logs_v2 TO signoz_logs.logs_v2_backup;"+ f"RENAME TABLE signoz_logs.logs_v2 TO signoz_logs.logs_v2_backup ON CLUSTER '{signoz.telemetrystore.env['SIGNOZ_TELEMETRYSTORE_CLICKHOUSE_CLUSTER']}'").result_rowsassert result is not None# Add cleanup to restore original tablerequest.addfinalizer(lambda: signoz.telemetrystore.conn.query(- "RENAME TABLE signoz_logs.logs_v2_backup TO signoz_logs.logs_v2;"+ f"RENAME TABLE signoz_logs.logs_v2_backup TO signoz_logs.logs_v2 ON CLUSTER '{signoz.telemetrystore.env['SIGNOZ_TELEMETRYSTORE_CLICKHOUSE_CLUSTER']}'"))# Create new test tablesresult = signoz.telemetrystore.conn.query(- """CREATE TABLE signoz_logs.logs_v2+ f"""CREATE TABLE signoz_logs.logs_v2 ON CLUSTER '{signoz.telemetrystore.env['SIGNOZ_TELEMETRYSTORE_CLICKHOUSE_CLUSTER']}'(`id` String,`timestamp` UInt64 CODEC(DoubleDelta, LZ4)@@ -453,7 +475,7 @@ def ttl_legacy_logs_v2_table_setup(request, signoz: types.SigNoz):# Add cleanup to drop test tablerequest.addfinalizer(lambda: signoz.telemetrystore.conn.query(- "DROP TABLE IF EXISTS signoz_logs.logs_v2;"+ f"DROP TABLE IF EXISTS signoz_logs.logs_v2 ON CLUSTER '{signoz.telemetrystore.env['SIGNOZ_TELEMETRYSTORE_CLICKHOUSE_CLUSTER']}'"))@@ -470,19 +492,19 @@ def ttl_legacy_logs_v2_resource_table_setup(request, signoz: types.SigNoz):# Setup coderesult = signoz.telemetrystore.conn.query(- "RENAME TABLE signoz_logs.logs_v2_resource TO signoz_logs.logs_v2_resource_backup;"+ f"RENAME TABLE signoz_logs.logs_v2_resource TO signoz_logs.logs_v2_resource_backup ON CLUSTER '{signoz.telemetrystore.env['SIGNOZ_TELEMETRYSTORE_CLICKHOUSE_CLUSTER']}'").result_rowsassert result is not None# Add cleanup to restore original tablerequest.addfinalizer(lambda: signoz.telemetrystore.conn.query(- "RENAME TABLE signoz_logs.logs_v2_resource_backup TO signoz_logs.logs_v2_resource;"+ f"RENAME TABLE signoz_logs.logs_v2_resource_backup TO signoz_logs.logs_v2_resource ON CLUSTER '{signoz.telemetrystore.env['SIGNOZ_TELEMETRYSTORE_CLICKHOUSE_CLUSTER']}'"))# Create new test tablesresult = signoz.telemetrystore.conn.query(- """CREATE TABLE signoz_logs.logs_v2_resource+ f"""CREATE TABLE signoz_logs.logs_v2_resource ON CLUSTER '{signoz.telemetrystore.env['SIGNOZ_TELEMETRYSTORE_CLICKHOUSE_CLUSTER']}'(`id` String,`seen_at_ts_bucket_start` Int64 CODEC(Delta(8), ZSTD(1))@@ -495,8 +517,54 @@ def ttl_legacy_logs_v2_resource_table_setup(request, signoz: types.SigNoz):# Add cleanup to drop test tablerequest.addfinalizer(lambda: signoz.telemetrystore.conn.query(- "DROP TABLE IF EXISTS signoz_logs.logs_v2_resource;"+ f"DROP TABLE IF EXISTS signoz_logs.logs_v2_resource ON CLUSTER '{signoz.telemetrystore.env['SIGNOZ_TELEMETRYSTORE_CLICKHOUSE_CLUSTER']}';"))yield # Test runs here++[email protected](name="remove_logs_ttl_settings", scope="function")+def remove_logs_ttl_settings(signoz: types.SigNoz):+ """+ Remove TTL settings from the specified logs table.+ This function alters the table to drop any existing TTL configurations+ and resets the _retention_days default value to 0.+ """+ tables = [+ "distributed_logs_v2",+ "distributed_logs_v2_resource",+ "logs_v2",+ "logs_v2_resource",+ "logs_attribute_keys",+ "logs_resource_keys",+ ]+ for table in tables:++ try:+ # Reset _retention_days and _retention_days_cold default values to 0 for tables that have these columns+ if table in [+ "logs_v2",+ "logs_v2_resource",+ "distributed_logs_v2",+ "distributed_logs_v2_resource",+ ]:+ reset_retention_query = f"""+ ALTER TABLE signoz_logs.{table} ON CLUSTER '{signoz.telemetrystore.env['SIGNOZ_TELEMETRYSTORE_CLICKHOUSE_CLUSTER']}'+ MODIFY COLUMN _retention_days UInt16 DEFAULT 0+ """+ signoz.telemetrystore.conn.query(reset_retention_query)++ reset_retention_cold_query = f"""+ ALTER TABLE signoz_logs.{table} ON CLUSTER '{signoz.telemetrystore.env['SIGNOZ_TELEMETRYSTORE_CLICKHOUSE_CLUSTER']}'+ MODIFY COLUMN _retention_days_cold UInt16 DEFAULT 0+ """+ signoz.telemetrystore.conn.query(reset_retention_cold_query)+ else:+ alter_query = f"""+ ALTER TABLE signoz_logs.{table} ON CLUSTER '{signoz.telemetrystore.env['SIGNOZ_TELEMETRYSTORE_CLICKHOUSE_CLUSTER']}'+ REMOVE TTL+ """+ signoz.telemetrystore.conn.query(alter_query)+ except Exception as e: # pylint: disable=broad-exception-caught+ print(f"Error removing TTL from table {table}: {e}")diff --git a/tests/integration/fixtures/metrics.py b/tests/integration/fixtures/metrics.pyindex d4d96398b3..933da11fec 100644--- a/tests/integration/fixtures/metrics.py+++ b/tests/integration/fixtures/metrics.py@@ -12,6 +12,7 @@ from fixtures import typesclass MetricsTimeSeries(ABC):"""Represents a row in the time_series_v4 table."""+env: strtemporality: strmetric_name: str@@ -82,6 +83,7 @@ class MetricsTimeSeries(ABC):class MetricsSample(ABC):"""Represents a row in the samples_v4 table."""+env: strtemporality: strmetric_name: str@@ -122,6 +124,7 @@ class MetricsSample(ABC):class Metrics(ABC):"""High-level metric representation. Produces both time series and sample entries."""+metric_name: strlabels: dict[str, str]temporality: str@@ -129,8 +132,13 @@ class Metrics(ABC):value: floatflags: int- _time_series: MetricsTimeSeries- _sample: MetricsSample+ @property+ def time_series(self) -> MetricsTimeSeries:+ return self._time_series++ @property+ def sample(self) -> MetricsSample:+ return self._sampledef __init__(self,@@ -195,9 +203,9 @@ def insert_metrics("""time_series_map: dict[int, MetricsTimeSeries] = {}for metric in metrics:- fp = int(metric._time_series.fingerprint) # pylint: disable=protected-access+ fp = int(metric.time_series.fingerprint)if fp not in time_series_map:- time_series_map[fp] = metric._time_series # pylint: disable=protected-access+ time_series_map[fp] = metric.time_seriesif len(time_series_map) > 0:clickhouse.conn.insert(@@ -222,7 +230,7 @@ def insert_metrics(data=[ts.to_row() for ts in time_series_map.values()],)- samples = [metric._sample for metric in metrics] # pylint: disable=protected-access+ samples = [metric.sample for metric in metrics]if len(samples) > 0:clickhouse.conn.insert(database="signoz_metrics",@@ -248,3 +256,31 @@ def insert_metrics(clickhouse.conn.query(f"TRUNCATE TABLE signoz_metrics.samples_v4 ON CLUSTER '{clickhouse.env['SIGNOZ_TELEMETRYSTORE_CLICKHOUSE_CLUSTER']}' SYNC")++[email protected](name="remove_metrics_ttl_and_storage_settings", scope="function")+def remove_metrics_ttl_and_storage_settings(signoz: types.SigNoz):+ """+ Remove any custom TTL settings on metrics tables to revert to default retention.+ Also resets storage policy to default by recreating tables if needed.+ """+ tables = [+ "samples_v4",+ "samples_v4_agg_5m",+ "samples_v4_agg_30m",+ "time_series_v4",+ "time_series_v4_6hrs",+ "time_series_v4_1day",+ "time_series_v4_1week",+ ]++ for table in tables:+ try:+ signoz.telemetrystore.conn.query(+ f"ALTER TABLE signoz_metrics.{table} ON CLUSTER '{signoz.telemetrystore.env['SIGNOZ_TELEMETRYSTORE_CLICKHOUSE_CLUSTER']}' REMOVE TTL"+ )+ signoz.telemetrystore.conn.query(+ f"ALTER TABLE signoz_metrics.{table} ON CLUSTER '{signoz.telemetrystore.env['SIGNOZ_TELEMETRYSTORE_CLICKHOUSE_CLUSTER']}' RESET SETTING storage_policy;"+ )+ except Exception as e: # pylint: disable=broad-exception-caught+ print(f"ttl and storage policy reset failed for {table}: {e}")diff --git a/tests/integration/fixtures/signoz.py b/tests/integration/fixtures/signoz.pyindex 6b396eb9f2..cec47afbfc 100644--- a/tests/integration/fixtures/signoz.py+++ b/tests/integration/fixtures/signoz.py@@ -97,14 +97,15 @@ def signoz( # pylint: disable=too-many-arguments,too-many-positional-argumentsf"http://{container.get_container_host_ip()}:{container.get_exposed_port(8080)}/api/v1/health",timeout=2,)- return response.status_code == HTTPStatus.OK+ if response.status_code == HTTPStatus.OK:+ returnexcept Exception: # pylint: disable=broad-exception-caughtlogger.info("Attempt %s at readiness check for SigNoz container %s failed, going to retry ...",attempt + 1,container,)- time.sleep(2)+ time.sleep(2)raise TimeoutError("timeout exceeded while waiting")try:diff --git a/tests/integration/fixtures/traces.py b/tests/integration/fixtures/traces.pyindex 7435714933..fa3da198ee 100644--- a/tests/integration/fixtures/traces.py+++ b/tests/integration/fixtures/traces.py@@ -81,7 +81,9 @@ class TracesResourceOrAttributeKeys(ABC):self.is_column = is_columndef np_arr(self) -> np.array:- return np.array([self.name, self.tag_type, self.datatype, self.is_column], dtype=object)+ return np.array(+ [self.name, self.tag_type, self.datatype, self.is_column], dtype=object+ )class TracesTagAttributes(ABC):@@ -98,7 +100,7 @@ class TracesTagAttributes(ABC):tag_key: str,tag_type: str,tag_data_type: str,- string_value: str,+ string_value: Optional[str],number_value: np.float64,) -> None:self.unix_milli = np.int64(int(timestamp.timestamp() * 1e3))@@ -727,3 +729,31 @@ def insert_traces(clickhouse.conn.query(f"TRUNCATE TABLE signoz_traces.signoz_error_index_v2 ON CLUSTER '{clickhouse.env['SIGNOZ_TELEMETRYSTORE_CLICKHOUSE_CLUSTER']}' SYNC")++[email protected](name="remove_traces_ttl_and_storage_settings", scope="function")+def remove_traces_ttl_and_storage_settings(signoz: types.SigNoz):+ """+ Remove any custom TTL settings on traces tables to revert to default retention.+ Also resets storage policy to default by recreating tables if needed.+ """+ tables = [+ "signoz_index_v3",+ "traces_v3_resource",+ "signoz_error_index_v2",+ "usage_explorer",+ "dependency_graph_minutes_v2",+ "trace_summary",+ "span_attributes_keys",+ ]++ for table in tables:+ try:+ signoz.telemetrystore.conn.query(+ f"ALTER TABLE signoz_traces.{table} ON CLUSTER '{signoz.telemetrystore.env['SIGNOZ_TELEMETRYSTORE_CLICKHOUSE_CLUSTER']}' REMOVE TTL"+ )+ signoz.telemetrystore.conn.query(+ f"ALTER TABLE signoz_traces.{table} ON CLUSTER '{signoz.telemetrystore.env['SIGNOZ_TELEMETRYSTORE_CLICKHOUSE_CLUSTER']}' RESET SETTING storage_policy;"+ )+ except Exception as e: # pylint: disable=broad-exception-caught+ print(f"ttl and storage policy reset failed for {table}: {e}")diff --git a/tests/integration/src/dashboard/a_public_dashboard.py b/tests/integration/src/dashboard/a_public_dashboard.pyindex 9aae955f0d..79c9b4f565 100644--- a/tests/integration/src/dashboard/a_public_dashboard.py+++ b/tests/integration/src/dashboard/a_public_dashboard.py@@ -134,43 +134,29 @@ def test_public_dashboard_widget_query_range("dataSource": "metrics","disabled": False,"expression": "A",- "filter": {- "expression": ""- },+ "filter": {"expression": ""},"functions": [],"groupBy": [],- "having": {- "expression": ""- },+ "having": {"expression": ""},"legend": "","limit": 10,"orderBy": [],"queryName": "A","source": "",- "stepInterval": 10+ "stepInterval": 10,}],"queryFormulas": [],- "queryTraceOperator": []+ "queryTraceOperator": [],},"clickhouse_sql": [- {- "disabled": False,- "legend": "",- "name": "A",- "query": ""- }+ {"disabled": False, "legend": "", "name": "A", "query": ""}],"id": "80f12506-ef72-4013-8282-2713c8114c9e","promql": [- {- "disabled": False,- "legend": "",- "name": "A",- "query": ""- }+ {"disabled": False, "legend": "", "name": "A", "query": ""}],- "queryType": "builder"+ "queryType": "builder",},}],@@ -185,7 +171,6 @@ def test_public_dashboard_widget_query_range(data = create_response.json()["data"]dashboard_id = data["id"]-# create public dashboardresponse = requests.post(signoz.self.host_configs["8080"].get(@@ -217,7 +202,7 @@ def test_public_dashboard_widget_query_range(resp = requests.get(signoz.self.host_configs["8080"].get(- f"/api/v1/public/dashboards/{public_dashboard_id}/widgets/0/query_range"+ f"/api/v1/public/dashboards/{public_dashboard_id}/widgets/0/query_range"),timeout=2,)@@ -225,10 +210,9 @@ def test_public_dashboard_widget_query_range(assert resp.status_code == HTTPStatus.OKassert resp.json().get("status") == "success"-resp = requests.get(signoz.self.host_configs["8080"].get(- f"/api/v1/public/dashboards/{public_dashboard_id}/widgets/-1/query_range"+ f"/api/v1/public/dashboards/{public_dashboard_id}/widgets/-1/query_range"),timeout=2,)@@ -236,7 +220,7 @@ def test_public_dashboard_widget_query_range(resp = requests.get(signoz.self.host_configs["8080"].get(- f"/api/v1/public/dashboards/{public_dashboard_id}/widgets/1/query_range"+ f"/api/v1/public/dashboards/{public_dashboard_id}/widgets/1/query_range"),timeout=2,)diff --git a/tests/integration/src/logspipelines/a_logs_pipelines.py b/tests/integration/src/logspipelines/a_logs_pipelines.pyindex 64469301de..e705e588fc 100644--- a/tests/integration/src/logspipelines/a_logs_pipelines.py+++ b/tests/integration/src/logspipelines/a_logs_pipelines.py@@ -29,7 +29,7 @@ def test_create_logs_pipeline_success(3. Verify the response contains version information4. Verify the pipeline is returned in the response"""- token = get_token(email=USER_ADMIN_EMAIL, password=USER_ADMIN_PASSWORD)+ token = get_token(USER_ADMIN_EMAIL, USER_ADMIN_PASSWORD)pipeline_payload = {"pipelines": [@@ -49,12 +49,12 @@ def test_create_logs_pipeline_success("dataType": "string","type": "","isColumn": True,- "isJSON": False+ "isJSON": False,},"value": ".*",- "op": "regex"+ "op": "regex",}- ]+ ],},"config": [{@@ -64,9 +64,9 @@ def test_create_logs_pipeline_success("parse_from": "body","parse_to": "attributes","regex": r"^(?P<timestamp>\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}) (?P<level>\w+) (?P<message>.*)$",- "on_error": "send"+ "on_error": "send",}- ]+ ],}]}@@ -98,7 +98,9 @@ def test_create_logs_pipeline_success(# Verify version informationassert "version" in response_data["data"]- assert response_data["data"]["version"] >= 1 # Version might be higher if other tests ran first+ assert (+ response_data["data"]["version"] >= 1+ ) # Version might be higher if other tests ran firstdef test_list_logs_pipelines_success(@@ -115,7 +117,7 @@ def test_list_logs_pipelines_success(2. List all pipelines and verify the created pipeline is present3. Verify the response structure"""- token = get_token(email=USER_ADMIN_EMAIL, password=USER_ADMIN_PASSWORD)+ token = get_token(USER_ADMIN_EMAIL, USER_ADMIN_PASSWORD)# Create a pipeline firstcreate_payload = {@@ -136,12 +138,12 @@ def test_list_logs_pipelines_success("dataType": "string","type": "","isColumn": True,- "isJSON": False+ "isJSON": False,},"value": ".*",- "op": "regex"+ "op": "regex",}- ]+ ],},"config": [{@@ -150,9 +152,9 @@ def test_list_logs_pipelines_success("orderId": 1,"parse_from": "body","parse_to": "attributes",- "on_error": "send"+ "on_error": "send",}- ]+ ],}]}@@ -205,7 +207,7 @@ def test_list_logs_pipelines_by_version(3. List pipelines by version 1 and verify it returns the original4. List pipelines by version 2 and verify it returns the updated version"""- token = get_token(email=USER_ADMIN_EMAIL, password=USER_ADMIN_PASSWORD)+ token = get_token(USER_ADMIN_EMAIL, USER_ADMIN_PASSWORD)# Create version 1v1_payload = {@@ -226,12 +228,12 @@ def test_list_logs_pipelines_by_version("dataType": "string","type": "","isColumn": True,- "isJSON": False+ "isJSON": False,},"value": ".*",- "op": "regex"+ "op": "regex",}- ]+ ],},"config": [{@@ -240,9 +242,9 @@ def test_list_logs_pipelines_by_version("orderId": 1,"parse_from": "body","parse_to": "attributes",- "on_error": "send"+ "on_error": "send",}- ]+ ],}]}@@ -282,12 +284,12 @@ def test_list_logs_pipelines_by_version("dataType": "string","type": "","isColumn": True,- "isJSON": False+ "isJSON": False,},"value": ".*",- "op": "regex"+ "op": "regex",}- ]+ ],},"config": [{@@ -296,9 +298,9 @@ def test_list_logs_pipelines_by_version("orderId": 1,"parse_from": "body","parse_to": "attributes",- "on_error": "send"+ "on_error": "send",}- ]+ ],}]}@@ -366,7 +368,7 @@ def test_preview_logs_pipelines_success(2. Verify the preview processes logs correctly3. Verify the response contains processed logs"""- token = get_token(email=USER_ADMIN_EMAIL, password=USER_ADMIN_PASSWORD)+ token = get_token(USER_ADMIN_EMAIL, USER_ADMIN_PASSWORD)preview_payload = {"pipelines": [@@ -385,12 +387,12 @@ def test_preview_logs_pipelines_success("dataType": "string","type": "","isColumn": True,- "isJSON": False+ "isJSON": False,},"value": ".*",- "op": "regex"+ "op": "regex",}- ]+ ],},"config": [{@@ -398,9 +400,9 @@ def test_preview_logs_pipelines_success("id": "json-parser-preview","parse_from": "body","parse_to": "attributes",- "on_error": "send"+ "on_error": "send",}- ]+ ],}],"logs": [@@ -417,11 +419,9 @@ def test_preview_logs_pipelines_success("attributes_int": {},"attributes_float": {},"attributes_bool": {},- "resources_string": {- "service.name": "test-service"- }+ "resources_string": {"service.name": "test-service"},}- ]+ ],}response = requests.post(@@ -460,7 +460,7 @@ def test_create_multiple_pipelines_success(2. Verify all pipelines are created3. Verify pipelines are ordered correctly"""- token = get_token(email=USER_ADMIN_EMAIL, password=USER_ADMIN_PASSWORD)+ token = get_token(USER_ADMIN_EMAIL, USER_ADMIN_PASSWORD)multi_pipeline_payload = {"pipelines": [@@ -480,12 +480,12 @@ def test_create_multiple_pipelines_success("dataType": "string","type": "","isColumn": True,- "isJSON": False+ "isJSON": False,},"value": ".*",- "op": "regex"+ "op": "regex",}- ]+ ],},"config": [{@@ -494,9 +494,9 @@ def test_create_multiple_pipelines_success("orderId": 1,"parse_from": "body","parse_to": "attributes",- "on_error": "send"+ "on_error": "send",}- ]+ ],},{"id": "",@@ -514,12 +514,12 @@ def test_create_multiple_pipelines_success("dataType": "string","type": "","isColumn": True,- "isJSON": False+ "isJSON": False,},"value": ".*",- "op": "regex"+ "op": "regex",}- ]+ ],},"config": [{@@ -529,10 +529,10 @@ def test_create_multiple_pipelines_success("parse_from": "body","parse_to": "attributes","regex": r"^(?P<level>\w+): (?P<message>.*)$",- "on_error": "send"+ "on_error": "send",}- ]- }+ ],+ },]}@@ -575,7 +575,7 @@ def test_delete_all_pipelines_success(3. Verify pipelines are deleted4. Verify new version is created"""- token = get_token(email=USER_ADMIN_EMAIL, password=USER_ADMIN_PASSWORD)+ token = get_token(USER_ADMIN_EMAIL, USER_ADMIN_PASSWORD)# Create a pipeline firstcreate_payload = {@@ -596,12 +596,12 @@ def test_delete_all_pipelines_success("dataType": "string","type": "","isColumn": True,- "isJSON": False+ "isJSON": False,},"value": ".*",- "op": "regex"+ "op": "regex",}- ]+ ],},"config": [{@@ -610,9 +610,9 @@ def test_delete_all_pipelines_success("orderId": 1,"parse_from": "body","parse_to": "attributes",- "on_error": "send"+ "on_error": "send",}- ]+ ],}]}@@ -631,9 +631,7 @@ def test_delete_all_pipelines_success(initial_version = create_response.json()["data"]["version"]# Delete all pipelines by sending empty array- delete_payload = {- "pipelines": []- }+ delete_payload = {"pipelines": []}delete_response = requests.post(signoz.self.host_configs["8080"].get("/api/v1/logs/pipelines"),@@ -668,5 +666,9 @@ def test_delete_all_pipelines_success(assert "data" in list_dataassert "pipelines" in list_data["data"]# Note: Integration pipelines might still be present, so we check user-created ones- user_pipelines = [p for p in list_data["data"]["pipelines"] if p.get("name") == "Pipeline to Delete"]+ user_pipelines = [+ p+ for p in list_data["data"]["pipelines"]+ if p.get("name") == "Pipeline to Delete"+ ]assert len(user_pipelines) == 0diff --git a/tests/integration/src/preference/a_user.py b/tests/integration/src/preference/a_user.pyindex fd8e1b3d20..8012d0a2cd 100644--- a/tests/integration/src/preference/a_user.py+++ b/tests/integration/src/preference/a_user.py@@ -15,7 +15,7 @@ def test_get_user_preference(create_user_admin: types.Operation, # pylint: disable=unused-argumentget_token: Callable[[str, str], str],):- admin_token = get_token(USER_ADMIN_EMAIL, USER_ADMIN_PASSWORD)+ admin_token = get_token(USER_ADMIN_EMAIL, USER_ADMIN_PASSWORD)response = requests.get(signoz.self.host_configs["8080"].get("/api/v1/user/preferences"),@@ -32,7 +32,7 @@ def test_get_set_user_preference_by_name(create_user_admin: types.Operation, # pylint: disable=unused-argumentget_token: Callable[[str, str], str],):- admin_token = get_token(USER_ADMIN_EMAIL, USER_ADMIN_PASSWORD)+ admin_token = get_token(USER_ADMIN_EMAIL, USER_ADMIN_PASSWORD)# preference does not existresponse = requests.get(diff --git a/tests/integration/src/preference/b_org.py b/tests/integration/src/preference/b_org.pyindex c3f8f5e2de..a073090b25 100644--- a/tests/integration/src/preference/b_org.py+++ b/tests/integration/src/preference/b_org.py@@ -48,9 +48,7 @@ def test_get_set_org_preference_by_name(# play with org_onboarding preferenceresponse = requests.put(- signoz.self.host_configs["8080"].get(- "/api/v1/org/preferences/org_onboarding"- ),+ signoz.self.host_configs["8080"].get("/api/v1/org/preferences/org_onboarding"),headers={"Authorization": f"Bearer {admin_token}"},json={"value": True},timeout=2,@@ -60,9 +58,7 @@ def test_get_set_org_preference_by_name(# get preference by nameresponse = requests.get(- signoz.self.host_configs["8080"].get(- "/api/v1/org/preferences/org_onboarding"- ),+ signoz.self.host_configs["8080"].get("/api/v1/org/preferences/org_onboarding"),headers={"Authorization": f"Bearer {admin_token}"},timeout=2,)diff --git a/tests/integration/src/querier/a_logs.py b/tests/integration/src/querier/a_logs.pyindex 600ff27856..5ab3438d0d 100644--- a/tests/integration/src/querier/a_logs.py+++ b/tests/integration/src/querier/a_logs.py@@ -81,7 +81,7 @@ def test_logs_list(])- token = get_token(email=USER_ADMIN_EMAIL, password=USER_ADMIN_PASSWORD)+ token = get_token(USER_ADMIN_EMAIL, USER_ADMIN_PASSWORD)# Query Logs for the last 10 seconds and check if the logs are returned in the correct orderresponse = requests.post(@@ -501,7 +501,7 @@ def test_logs_time_series_count()insert_logs(logs)- token = get_token(email=USER_ADMIN_EMAIL, password=USER_ADMIN_PASSWORD)+ token = get_token(USER_ADMIN_EMAIL, USER_ADMIN_PASSWORD)# count() of all logs for the last 5 minutesresponse = requests.post(@@ -1013,7 +1013,7 @@ def test_datatype_collision(insert_logs(logs)- token = get_token(email=USER_ADMIN_EMAIL, password=USER_ADMIN_PASSWORD)+ token = get_token(USER_ADMIN_EMAIL, USER_ADMIN_PASSWORD)# count() of all logs for the where severity_number > '7'response = requests.post(@@ -1368,7 +1368,7 @@ def test_logs_fill_gaps(]insert_logs(logs)- token = get_token(email=USER_ADMIN_EMAIL, password=USER_ADMIN_PASSWORD)+ token = get_token(USER_ADMIN_EMAIL, USER_ADMIN_PASSWORD)start_ms = int((now - timedelta(minutes=5)).timestamp() * 1000)end_ms = int(now.timestamp() * 1000)@@ -1454,7 +1454,7 @@ def test_logs_fill_gaps_with_group_by(]insert_logs(logs)- token = get_token(email=USER_ADMIN_EMAIL, password=USER_ADMIN_PASSWORD)+ token = get_token(USER_ADMIN_EMAIL, USER_ADMIN_PASSWORD)start_ms = int((now - timedelta(minutes=5)).timestamp() * 1000)end_ms = int(now.timestamp() * 1000)@@ -1478,7 +1478,11 @@ def test_logs_fill_gaps_with_group_by("stepInterval": 60,"disabled": False,"groupBy": [- {"name": "service.name", "fieldDataType": "string", "fieldContext": "resource"}+ {+ "name": "service.name",+ "fieldDataType": "string",+ "fieldContext": "resource",+ }],"having": {"expression": ""},"aggregations": [{"expression": "count()"}],@@ -1510,8 +1514,8 @@ def test_logs_fill_gaps_with_group_by(# service-a has one log at minute -3, service-b at minute -2expectations = {- "service-a": {ts_min_3: 1},- "service-b": {ts_min_2: 1},+ "service-a": {ts_min_3: 1.0},+ "service-b": {ts_min_2: 1.0},}for service_name, s in series_by_service.items():@@ -1551,7 +1555,7 @@ def test_logs_fill_gaps_formula(]insert_logs(logs)- token = get_token(email=USER_ADMIN_EMAIL, password=USER_ADMIN_PASSWORD)+ token = get_token(USER_ADMIN_EMAIL, USER_ADMIN_PASSWORD)start_ms = int((now - timedelta(minutes=5)).timestamp() * 1000)end_ms = int(now.timestamp() * 1000)@@ -1586,9 +1590,7 @@ def test_logs_fill_gaps_formula("signal": "logs","stepInterval": 60,"disabled": True,- "filter": {- "expression": "service.name = 'another-test'"- },+ "filter": {"expression": "service.name = 'another-test'"},"having": {"expression": ""},"aggregations": [{"expression": "count()"}],},@@ -1600,7 +1602,7 @@ def test_logs_fill_gaps_formula("expression": "A + B","disabled": False,},- }+ },]},"formatOptions": {"formatTableResultForUI": False, "fillGaps": True},@@ -1660,7 +1662,7 @@ def test_logs_fill_gaps_formula_with_group_by(]insert_logs(logs)- token = get_token(email=USER_ADMIN_EMAIL, password=USER_ADMIN_PASSWORD)+ token = get_token(USER_ADMIN_EMAIL, USER_ADMIN_PASSWORD)start_ms = int((now - timedelta(minutes=5)).timestamp() * 1000)end_ms = int(now.timestamp() * 1000)@@ -1683,7 +1685,13 @@ def test_logs_fill_gaps_formula_with_group_by("signal": "logs","stepInterval": 60,"disabled": True,- "groupBy": [{"name": "service.name", "fieldDataType": "string", "fieldContext": "resource"}],+ "groupBy": [+ {+ "name": "service.name",+ "fieldDataType": "string",+ "fieldContext": "resource",+ }+ ],"having": {"expression": ""},"aggregations": [{"expression": "count()"}],},@@ -1695,7 +1703,13 @@ def test_logs_fill_gaps_formula_with_group_by("signal": "logs","stepInterval": 60,"disabled": True,- "groupBy": [{"name": "service.name", "fieldDataType": "string", "fieldContext": "resource"}],+ "groupBy": [+ {+ "name": "service.name",+ "fieldDataType": "string",+ "fieldContext": "resource",+ }+ ],"having": {"expression": ""},"aggregations": [{"expression": "count()"}],},@@ -1707,7 +1721,7 @@ def test_logs_fill_gaps_formula_with_group_by("expression": "A + B","disabled": False,},- }+ },]},"formatOptions": {"formatTableResultForUI": False, "fillGaps": True},@@ -1735,8 +1749,8 @@ def test_logs_fill_gaps_formula_with_group_by(assert set(series_by_service.keys()) == {"group1", "group2"}expectations = {- "group1": {ts_min_3: 2},- "group2": {ts_min_2: 2},+ "group1": {ts_min_3: 2.0},+ "group2": {ts_min_2: 2.0},}for service_name, s in series_by_service.items():@@ -1769,7 +1783,7 @@ def test_logs_fill_zero(]insert_logs(logs)- token = get_token(email=USER_ADMIN_EMAIL, password=USER_ADMIN_PASSWORD)+ token = get_token(USER_ADMIN_EMAIL, USER_ADMIN_PASSWORD)start_ms = int((now - timedelta(minutes=5)).timestamp() * 1000)end_ms = int(now.timestamp() * 1000)@@ -1852,7 +1866,7 @@ def test_logs_fill_zero_with_group_by(]insert_logs(logs)- token = get_token(email=USER_ADMIN_EMAIL, password=USER_ADMIN_PASSWORD)+ token = get_token(USER_ADMIN_EMAIL, USER_ADMIN_PASSWORD)start_ms = int((now - timedelta(minutes=5)).timestamp() * 1000)end_ms = int(now.timestamp() * 1000)@@ -1875,7 +1889,13 @@ def test_logs_fill_zero_with_group_by("signal": "logs","stepInterval": 60,"disabled": False,- "groupBy": [{"name": "service.name", "fieldDataType": "string", "fieldContext": "resource"}],+ "groupBy": [+ {+ "name": "service.name",+ "fieldDataType": "string",+ "fieldContext": "resource",+ }+ ],"having": {"expression": ""},"aggregations": [{"expression": "count()"}],"functions": [{"name": "fillZero"}],@@ -1905,8 +1925,8 @@ def test_logs_fill_zero_with_group_by(assert set(series_by_service.keys()) == {"service-a", "service-b"}expectations = {- "service-a": {ts_min_3: 1},- "service-b": {ts_min_2: 1},+ "service-a": {ts_min_3: 1.0},+ "service-b": {ts_min_2: 1.0},}for service_name, s in series_by_service.items():@@ -1946,7 +1966,7 @@ def test_logs_fill_zero_formula(]insert_logs(logs)- token = get_token(email=USER_ADMIN_EMAIL, password=USER_ADMIN_PASSWORD)+ token = get_token(USER_ADMIN_EMAIL, USER_ADMIN_PASSWORD)start_ms = int((now - timedelta(minutes=5)).timestamp() * 1000)end_ms = int(now.timestamp() * 1000)@@ -1994,7 +2014,7 @@ def test_logs_fill_zero_formula("disabled": False,"functions": [{"name": "fillZero"}],},- }+ },]},"formatOptions": {"formatTableResultForUI": False, "fillGaps": False},@@ -2054,7 +2074,7 @@ def test_logs_fill_zero_formula_with_group_by(]insert_logs(logs)- token = get_token(email=USER_ADMIN_EMAIL, password=USER_ADMIN_PASSWORD)+ token = get_token(USER_ADMIN_EMAIL, USER_ADMIN_PASSWORD)start_ms = int((now - timedelta(minutes=5)).timestamp() * 1000)end_ms = int(now.timestamp() * 1000)@@ -2077,7 +2097,13 @@ def test_logs_fill_zero_formula_with_group_by("signal": "logs","stepInterval": 60,"disabled": True,- "groupBy": [{"name": "service.name", "fieldDataType": "string", "fieldContext": "resource"}],+ "groupBy": [+ {+ "name": "service.name",+ "fieldDataType": "string",+ "fieldContext": "resource",+ }+ ],"having": {"expression": ""},"aggregations": [{"expression": "count()"}],},@@ -2089,7 +2115,13 @@ def test_logs_fill_zero_formula_with_group_by("signal": "logs","stepInterval": 60,"disabled": True,- "groupBy": [{"name": "service.name", "fieldDataType": "string", "fieldContext": "resource"}],+ "groupBy": [+ {+ "name": "service.name",+ "fieldDataType": "string",+ "fieldContext": "resource",+ }+ ],"having": {"expression": ""},"aggregations": [{"expression": "count()"}],},@@ -2102,7 +2134,7 @@ def test_logs_fill_zero_formula_with_group_by("disabled": False,"functions": [{"name": "fillZero"}],},- }+ },]},"formatOptions": {"formatTableResultForUI": False, "fillGaps": False},@@ -2130,8 +2162,8 @@ def test_logs_fill_zero_formula_with_group_by(assert set(series_by_service.keys()) == {"group1", "group2"}expectations = {- "group1": {ts_min_3: 2},- "group2": {ts_min_2: 2},+ "group1": {ts_min_3: 2.0},+ "group2": {ts_min_2: 2.0},}for service_name, s in series_by_service.items():diff --git a/tests/integration/src/querier/b_traces.py b/tests/integration/src/querier/b_traces.pyindex e5ed821fc2..304fd73bf6 100644--- a/tests/integration/src/querier/b_traces.py+++ b/tests/integration/src/querier/b_traces.py@@ -143,7 +143,7 @@ def test_traces_list(])- token = get_token(email=USER_ADMIN_EMAIL, password=USER_ADMIN_PASSWORD)+ token = get_token(USER_ADMIN_EMAIL, USER_ADMIN_PASSWORD)# Query all traces for the past 5 minutesresponse = requests.post(@@ -449,7 +449,7 @@ def test_traces_fill_gaps(]insert_traces(traces)- token = get_token(email=USER_ADMIN_EMAIL, password=USER_ADMIN_PASSWORD)+ token = get_token(USER_ADMIN_EMAIL, USER_ADMIN_PASSWORD)start_ms = int((now - timedelta(minutes=5)).timestamp() * 1000)end_ms = int(now.timestamp() * 1000)@@ -545,7 +545,7 @@ def test_traces_fill_gaps_with_group_by(]insert_traces(traces)- token = get_token(email=USER_ADMIN_EMAIL, password=USER_ADMIN_PASSWORD)+ token = get_token(USER_ADMIN_EMAIL, USER_ADMIN_PASSWORD)start_ms = int((now - timedelta(minutes=5)).timestamp() * 1000)end_ms = int(now.timestamp() * 1000)@@ -569,7 +569,11 @@ def test_traces_fill_gaps_with_group_by("stepInterval": 60,"disabled": False,"groupBy": [- {"name": "service.name", "fieldDataType": "string", "fieldContext": "resource"}+ {+ "name": "service.name",+ "fieldDataType": "string",+ "fieldContext": "resource",+ }],"having": {"expression": ""},"aggregations": [{"expression": "count()"}],@@ -654,7 +658,7 @@ def test_traces_fill_gaps_formula(]insert_traces(traces)- token = get_token(email=USER_ADMIN_EMAIL, password=USER_ADMIN_PASSWORD)+ token = get_token(USER_ADMIN_EMAIL, USER_ADMIN_PASSWORD)start_ms = int((now - timedelta(minutes=5)).timestamp() * 1000)end_ms = int(now.timestamp() * 1000)@@ -701,7 +705,7 @@ def test_traces_fill_gaps_formula("expression": "A + B","disabled": False,},- }+ },]},"formatOptions": {"formatTableResultForUI": False, "fillGaps": True},@@ -774,7 +778,7 @@ def test_traces_fill_gaps_formula_with_group_by(]insert_traces(traces)- token = get_token(email=USER_ADMIN_EMAIL, password=USER_ADMIN_PASSWORD)+ token = get_token(USER_ADMIN_EMAIL, USER_ADMIN_PASSWORD)start_ms = int((now - timedelta(minutes=5)).timestamp() * 1000)end_ms = int(now.timestamp() * 1000)@@ -797,7 +801,13 @@ def test_traces_fill_gaps_formula_with_group_by("signal": "traces","stepInterval": 60,"disabled": True,- "groupBy": [{"name": "service.name", "fieldDataType": "string", "fieldContext": "resource"}],+ "groupBy": [+ {+ "name": "service.name",+ "fieldDataType": "string",+ "fieldContext": "resource",+ }+ ],"having": {"expression": ""},"aggregations": [{"expression": "count()"}],},@@ -809,7 +819,13 @@ def test_traces_fill_gaps_formula_with_group_by("signal": "traces","stepInterval": 60,"disabled": True,- "groupBy": [{"name": "service.name", "fieldDataType": "string", "fieldContext": "resource"}],+ "groupBy": [+ {+ "name": "service.name",+ "fieldDataType": "string",+ "fieldContext": "resource",+ }+ ],"having": {"expression": ""},"aggregations": [{"expression": "count()"}],},@@ -821,7 +837,7 @@ def test_traces_fill_gaps_formula_with_group_by("expression": "A + B","disabled": False,},- }+ },]},"formatOptions": {"formatTableResultForUI": False, "fillGaps": True},@@ -890,7 +906,7 @@ def test_traces_fill_zero(]insert_traces(traces)- token = get_token(email=USER_ADMIN_EMAIL, password=USER_ADMIN_PASSWORD)+ token = get_token(USER_ADMIN_EMAIL, USER_ADMIN_PASSWORD)start_ms = int((now - timedelta(minutes=5)).timestamp() * 1000)end_ms = int(now.timestamp() * 1000)@@ -986,7 +1002,7 @@ def test_traces_fill_zero_with_group_by(]insert_traces(traces)- token = get_token(email=USER_ADMIN_EMAIL, password=USER_ADMIN_PASSWORD)+ token = get_token(USER_ADMIN_EMAIL, USER_ADMIN_PASSWORD)start_ms = int((now - timedelta(minutes=5)).timestamp() * 1000)end_ms = int(now.timestamp() * 1000)@@ -1009,7 +1025,13 @@ def test_traces_fill_zero_with_group_by("signal": "traces","stepInterval": 60,"disabled": False,- "groupBy": [{"name": "service.name", "fieldDataType": "string", "fieldContext": "resource"}],+ "groupBy": [+ {+ "name": "service.name",+ "fieldDataType": "string",+ "fieldContext": "resource",+ }+ ],"having": {"expression": ""},"aggregations": [{"expression": "count()"}],"functions": [{"name": "fillZero"}],@@ -1094,7 +1116,7 @@ def test_traces_fill_zero_formula(]insert_traces(traces)- token = get_token(email=USER_ADMIN_EMAIL, password=USER_ADMIN_PASSWORD)+ token = get_token(USER_ADMIN_EMAIL, USER_ADMIN_PASSWORD)start_ms = int((now - timedelta(minutes=5)).timestamp() * 1000)end_ms = int(now.timestamp() * 1000)@@ -1142,7 +1164,7 @@ def test_traces_fill_zero_formula("disabled": False,"functions": [{"name": "fillZero"}],},- }+ },]},"formatOptions": {"formatTableResultForUI": False, "fillGaps": False},@@ -1214,7 +1236,7 @@ def test_traces_fill_zero_formula_with_group_by(]insert_traces(traces)- token = get_token(email=USER_ADMIN_EMAIL, password=USER_ADMIN_PASSWORD)+ token = get_token(USER_ADMIN_EMAIL, USER_ADMIN_PASSWORD)start_ms = int((now - timedelta(minutes=5)).timestamp() * 1000)end_ms = int(now.timestamp() * 1000)@@ -1237,7 +1259,13 @@ def test_traces_fill_zero_formula_with_group_by("signal": "traces","stepInterval": 60,"disabled": True,- "groupBy": [{"name": "service.name", "fieldDataType": "string", "fieldContext": "resource"}],+ "groupBy": [+ {+ "name": "service.name",+ "fieldDataType": "string",+ "fieldContext": "resource",+ }+ ],"having": {"expression": ""},"aggregations": [{"expression": "count()"}],},@@ -1249,7 +1277,13 @@ def test_traces_fill_zero_formula_with_group_by("signal": "traces","stepInterval": 60,"disabled": True,- "groupBy": [{"name": "service.name", "fieldDataType": "string", "fieldContext": "resource"}],+ "groupBy": [+ {+ "name": "service.name",+ "fieldDataType": "string",+ "fieldContext": "resource",+ }+ ],"having": {"expression": ""},"aggregations": [{"expression": "count()"}],},@@ -1262,7 +1296,7 @@ def test_traces_fill_zero_formula_with_group_by("disabled": False,"functions": [{"name": "fillZero"}],},- }+ },]},"formatOptions": {"formatTableResultForUI": False, "fillGaps": False},diff --git a/tests/integration/src/querier/c_metrics.py b/tests/integration/src/querier/c_metrics.pyindex fd7b2378fc..16027d051d 100644--- a/tests/integration/src/querier/c_metrics.py+++ b/tests/integration/src/querier/c_metrics.py@@ -46,7 +46,7 @@ def test_metrics_fill_gaps(]insert_metrics(metrics)- token = get_token(email=USER_ADMIN_EMAIL, password=USER_ADMIN_PASSWORD)+ token = get_token(USER_ADMIN_EMAIL, USER_ADMIN_PASSWORD)start_ms = int((now - timedelta(minutes=5)).timestamp() * 1000)end_ms = int(now.timestamp() * 1000)@@ -67,12 +67,14 @@ def test_metrics_fill_gaps("spec": {"name": "A","signal": "metrics",- "aggregations": [{- "metricName": metric_name,- "temporality": "cumulative",- "timeAggregation": "increase",- "spaceAggregation": "sum"- }],+ "aggregations": [+ {+ "metricName": metric_name,+ "temporality": "cumulative",+ "timeAggregation": "increase",+ "spaceAggregation": "sum",+ }+ ],"stepInterval": 60,"disabled": False,},@@ -137,7 +139,7 @@ def test_metrics_fill_gaps_with_group_by(]insert_metrics(metrics)- token = get_token(email=USER_ADMIN_EMAIL, password=USER_ADMIN_PASSWORD)+ token = get_token(USER_ADMIN_EMAIL, USER_ADMIN_PASSWORD)start_ms = int((now - timedelta(minutes=5)).timestamp() * 1000)end_ms = int(now.timestamp() * 1000)@@ -158,15 +160,23 @@ def test_metrics_fill_gaps_with_group_by("spec": {"name": "A","signal": "metrics",- "aggregations": [{- "metricName": metric_name,- "temporality": "cumulative",- "timeAggregation": "increase",- "spaceAggregation": "sum"- }],+ "aggregations": [+ {+ "metricName": metric_name,+ "temporality": "cumulative",+ "timeAggregation": "increase",+ "spaceAggregation": "sum",+ }+ ],"stepInterval": 60,"disabled": False,- "groupBy": [{"name": "my_tag", "fieldDataType": "string", "fieldContext": "attribute"}],+ "groupBy": [+ {+ "name": "my_tag",+ "fieldDataType": "string",+ "fieldContext": "attribute",+ }+ ],},}]@@ -239,7 +249,7 @@ def test_metrics_fill_gaps_formula(]insert_metrics(metrics)- token = get_token(email=USER_ADMIN_EMAIL, password=USER_ADMIN_PASSWORD)+ token = get_token(USER_ADMIN_EMAIL, USER_ADMIN_PASSWORD)start_ms = int((now - timedelta(minutes=5)).timestamp() * 1000)end_ms = int(now.timestamp() * 1000)@@ -260,12 +270,14 @@ def test_metrics_fill_gaps_formula("spec": {"name": "A","signal": "metrics",- "aggregations": [{- "metricName": metric_name_a,- "temporality": "cumulative",- "timeAggregation": "increase",- "spaceAggregation": "sum"- }],+ "aggregations": [+ {+ "metricName": metric_name_a,+ "temporality": "cumulative",+ "timeAggregation": "increase",+ "spaceAggregation": "sum",+ }+ ],"stepInterval": 60,"disabled": True,},@@ -275,12 +287,14 @@ def test_metrics_fill_gaps_formula("spec": {"name": "B","signal": "metrics",- "aggregations": [{- "metricName": metric_name_b,- "temporality": "cumulative",- "timeAggregation": "increase",- "spaceAggregation": "sum"- }],+ "aggregations": [+ {+ "metricName": metric_name_b,+ "temporality": "cumulative",+ "timeAggregation": "increase",+ "spaceAggregation": "sum",+ }+ ],"stepInterval": 60,"disabled": True,},@@ -292,7 +306,7 @@ def test_metrics_fill_gaps_formula("expression": "A + B","disabled": False,},- }+ },]},"formatOptions": {"formatTableResultForUI": False, "fillGaps": True},@@ -314,7 +328,9 @@ def test_metrics_fill_gaps_formula(aggregations = f1.get("aggregations") or []assert len(aggregations) == 1series = aggregations[0].get("series") or []- assert len(series) >= 1, f"Expected at least one series for F1, got {aggregations[0]}"+ assert (+ len(series) >= 1+ ), f"Expected at least one series for F1, got {aggregations[0]}"assert_minutely_bucket_values(series[0]["values"],@@ -369,7 +385,7 @@ def test_metrics_fill_gaps_formula_with_group_by(]insert_metrics(metrics)- token = get_token(email=USER_ADMIN_EMAIL, password=USER_ADMIN_PASSWORD)+ token = get_token(USER_ADMIN_EMAIL, USER_ADMIN_PASSWORD)start_ms = int((now - timedelta(minutes=5)).timestamp() * 1000)end_ms = int(now.timestamp() * 1000)@@ -390,15 +406,23 @@ def test_metrics_fill_gaps_formula_with_group_by("spec": {"name": "A","signal": "metrics",- "aggregations": [{- "metricName": metric_name_a,- "temporality": "cumulative",- "timeAggregation": "increase",- "spaceAggregation": "sum"- }],+ "aggregations": [+ {+ "metricName": metric_name_a,+ "temporality": "cumulative",+ "timeAggregation": "increase",+ "spaceAggregation": "sum",+ }+ ],"stepInterval": 60,"disabled": True,- "groupBy": [{"name": "my_tag", "fieldDataType": "string", "fieldContext": "attribute"}],+ "groupBy": [+ {+ "name": "my_tag",+ "fieldDataType": "string",+ "fieldContext": "attribute",+ }+ ],},},{@@ -406,15 +430,23 @@ def test_metrics_fill_gaps_formula_with_group_by("spec": {"name": "B","signal": "metrics",- "aggregations": [{- "metricName": metric_name_b,- "temporality": "cumulative",- "timeAggregation": "increase",- "spaceAggregation": "sum"- }],+ "aggregations": [+ {+ "metricName": metric_name_b,+ "temporality": "cumulative",+ "timeAggregation": "increase",+ "spaceAggregation": "sum",+ }+ ],"stepInterval": 60,"disabled": True,- "groupBy": [{"name": "my_tag", "fieldDataType": "string", "fieldContext": "attribute"}],+ "groupBy": [+ {+ "name": "my_tag",+ "fieldDataType": "string",+ "fieldContext": "attribute",+ }+ ],},},{@@ -424,7 +456,7 @@ def test_metrics_fill_gaps_formula_with_group_by("expression": "A + B","disabled": False,},- }+ },]},"formatOptions": {"formatTableResultForUI": False, "fillGaps": True},@@ -488,7 +520,7 @@ def test_metrics_fill_zero(]insert_metrics(metrics)- token = get_token(email=USER_ADMIN_EMAIL, password=USER_ADMIN_PASSWORD)+ token = get_token(USER_ADMIN_EMAIL, USER_ADMIN_PASSWORD)start_ms = int((now - timedelta(minutes=5)).timestamp() * 1000)end_ms = int(now.timestamp() * 1000)@@ -509,12 +541,14 @@ def test_metrics_fill_zero("spec": {"name": "A","signal": "metrics",- "aggregations": [{- "metricName": metric_name,- "temporality": "cumulative",- "timeAggregation": "increase",- "spaceAggregation": "sum"- }],+ "aggregations": [+ {+ "metricName": metric_name,+ "temporality": "cumulative",+ "timeAggregation": "increase",+ "spaceAggregation": "sum",+ }+ ],"stepInterval": 60,"disabled": False,"functions": [{"name": "fillZero"}],@@ -577,7 +611,7 @@ def test_metrics_fill_zero_with_group_by(]insert_metrics(metrics)- token = get_token(email=USER_ADMIN_EMAIL, password=USER_ADMIN_PASSWORD)+ token = get_token(USER_ADMIN_EMAIL, USER_ADMIN_PASSWORD)start_ms = int((now - timedelta(minutes=5)).timestamp() * 1000)end_ms = int(now.timestamp() * 1000)@@ -598,15 +632,23 @@ def test_metrics_fill_zero_with_group_by("spec": {"name": "A","signal": "metrics",- "aggregations": [{- "metricName": metric_name,- "temporality": "cumulative",- "timeAggregation": "increase",- "spaceAggregation": "sum"- }],+ "aggregations": [+ {+ "metricName": metric_name,+ "temporality": "cumulative",+ "timeAggregation": "increase",+ "spaceAggregation": "sum",+ }+ ],"stepInterval": 60,"disabled": False,- "groupBy": [{"name": "my_tag", "fieldDataType": "string", "fieldContext": "attribute"}],+ "groupBy": [+ {+ "name": "my_tag",+ "fieldDataType": "string",+ "fieldContext": "attribute",+ }+ ],"functions": [{"name": "fillZero"}],},}@@ -678,7 +720,7 @@ def test_metrics_fill_zero_formula(]insert_metrics(metrics)- token = get_token(email=USER_ADMIN_EMAIL, password=USER_ADMIN_PASSWORD)+ token = get_token(USER_ADMIN_EMAIL, USER_ADMIN_PASSWORD)start_ms = int((now - timedelta(minutes=5)).timestamp() * 1000)end_ms = int(now.timestamp() * 1000)@@ -699,12 +741,14 @@ def test_metrics_fill_zero_formula("spec": {"name": "A","signal": "metrics",- "aggregations": [{- "metricName": metric_name_a,- "temporality": "cumulative",- "timeAggregation": "increase",- "spaceAggregation": "sum"- }],+ "aggregations": [+ {+ "metricName": metric_name_a,+ "temporality": "cumulative",+ "timeAggregation": "increase",+ "spaceAggregation": "sum",+ }+ ],"stepInterval": 60,"disabled": True,},@@ -714,12 +758,14 @@ def test_metrics_fill_zero_formula("spec": {"name": "B","signal": "metrics",- "aggregations": [{- "metricName": metric_name_b,- "temporality": "cumulative",- "timeAggregation": "increase",- "spaceAggregation": "sum"- }],+ "aggregations": [+ {+ "metricName": metric_name_b,+ "temporality": "cumulative",+ "timeAggregation": "increase",+ "spaceAggregation": "sum",+ }+ ],"stepInterval": 60,"disabled": True,},@@ -732,7 +778,7 @@ def test_metrics_fill_zero_formula("disabled": False,"functions": [{"name": "fillZero"}],},- }+ },]},"formatOptions": {"formatTableResultForUI": False, "fillGaps": False},@@ -753,9 +799,9 @@ def test_metrics_fill_zero_formula(aggregations = f1.get("aggregations") or []assert len(aggregations) == 1series = aggregations[0].get("series") or []- assert len(series) >= 1, (- f"Expected at least one series for F1, got {aggregations[0]}"- )+ assert (+ len(series) >= 1+ ), f"Expected at least one series for F1, got {aggregations[0]}"assert_minutely_bucket_values(series[0]["values"],@@ -810,7 +856,7 @@ def test_metrics_fill_zero_formula_with_group_by(]insert_metrics(metrics)- token = get_token(email=USER_ADMIN_EMAIL, password=USER_ADMIN_PASSWORD)+ token = get_token(USER_ADMIN_EMAIL, USER_ADMIN_PASSWORD)start_ms = int((now - timedelta(minutes=5)).timestamp() * 1000)end_ms = int(now.timestamp() * 1000)@@ -831,15 +877,23 @@ def test_metrics_fill_zero_formula_with_group_by("spec": {"name": "A","signal": "metrics",- "aggregations": [{- "metricName": metric_name_a,- "temporality": "cumulative",- "timeAggregation": "increase",- "spaceAggregation": "sum"- }],+ "aggregations": [+ {+ "metricName": metric_name_a,+ "temporality": "cumulative",+ "timeAggregation": "increase",+ "spaceAggregation": "sum",+ }+ ],"stepInterval": 60,"disabled": True,- "groupBy": [{"name": "my_tag", "fieldDataType": "string", "fieldContext": "attribute"}],+ "groupBy": [+ {+ "name": "my_tag",+ "fieldDataType": "string",+ "fieldContext": "attribute",+ }+ ],},},{@@ -847,15 +901,23 @@ def test_metrics_fill_zero_formula_with_group_by("spec": {"name": "B","signal": "metrics",- "aggregations": [{- "metricName": metric_name_b,- "temporality": "cumulative",- "timeAggregation": "increase",- "spaceAggregation": "sum"- }],+ "aggregations": [+ {+ "metricName": metric_name_b,+ "temporality": "cumulative",+ "timeAggregation": "increase",+ "spaceAggregation": "sum",+ }+ ],"stepInterval": 60,"disabled": True,- "groupBy": [{"name": "my_tag", "fieldDataType": "string", "fieldContext": "attribute"}],+ "groupBy": [+ {+ "name": "my_tag",+ "fieldDataType": "string",+ "fieldContext": "attribute",+ }+ ],},},{@@ -866,7 +928,7 @@ def test_metrics_fill_zero_formula_with_group_by("disabled": False,"functions": [{"name": "fillZero"}],},- }+ },]},"formatOptions": {"formatTableResultForUI": False, "fillGaps": False},diff --git a/tests/integration/src/querier/timeseries_utils.py b/tests/integration/src/querier/timeseries_utils.pyindex 492453e708..f9ef86edf5 100644--- a/tests/integration/src/querier/timeseries_utils.py+++ b/tests/integration/src/querier/timeseries_utils.py@@ -4,8 +4,7 @@ from typing import Any, Dict, List, Optionaldef expected_minutely_bucket_timestamps_ms(now: datetime) -> List[List[int]]:previous_five = [- int((now - timedelta(minutes=m)).timestamp() * 1000)- for m in range(5, 0, -1)+ int((now - timedelta(minutes=m)).timestamp() * 1000) for m in range(5, 0, -1)]with_current = previous_five + [int(now.timestamp() * 1000)]return [previous_five, with_current]diff --git a/tests/integration/src/ttl/a_ttl.py b/tests/integration/src/ttl/a_ttl.pyindex 57b574c319..2128b4190c 100644--- a/tests/integration/src/ttl/a_ttl.py+++ b/tests/integration/src/ttl/a_ttl.py@@ -1,7 +1,9 @@"""Summary:-This test file contains integration tests for Time-To-Live (TTL) and custom retention policies in SigNoz's query service.-It verifies the correct behavior of TTL settings for traces, metrics, and logs, including support for cold storage, custom retention conditions, error handling for invalid configurations, and retrieval of TTL settings.+This test file contains integration tests for Time-To-Live (TTL) and custom retention policies+in SigNoz's query service. It verifies the correct behavior of TTL settings for traces, metrics,+and logs, including support for cold storage, custom retention conditions, error handling for+invalid configurations, and retrieval of TTL settings."""import time@@ -18,6 +20,83 @@ from fixtures.logs import Logslogger = setup_logger(__name__)+"""+Helper functions to verify TTL and partition settings in Clickhouse tables.+NOTE: These functions only works when last inserted data is in the latest partition.+"""+++def verify_table_partition_expressions(+ signoz: types.SigNoz,+ expected_partition_expressions_map: dict[str, tuple[int, int, int]],+):+ """+ Verify table partitions exist with data and have correct retention values.++ Args:+ signoz: SigNoz fixture providing access to telemetry store+ expected_partition_expressions_map: Dictionary mapping table names to expected count of partitions+ Example: {"logs_v2": (10, 15, 1), "logs_v2_resource": (10, 15, 1)}+ """++ time.sleep(2) # Wait for partitions to be created+ for table in expected_partition_expressions_map:+ # Query to check if ANY row exists with the expected retention values+ # This verifies that data was inserted into a partition with the correct TTL+ retention, retention_cold, count = expected_partition_expressions_map[table]++ retention_query = (+ f"SELECT COUNT(*) FROM {table} "+ f"WHERE _retention_days = {retention} AND _retention_days_cold = {retention_cold}"+ )+ retention_result = signoz.telemetrystore.conn.query(retention_query).result_rows++ assert retention_result[0][0] == count, (+ f"No data found with retention values '{retention}, {retention_cold}' in table {table}. "+ f"Expected at least one row with these retention settings."+ )++ partition_query = (+ "SELECT rows FROM system.parts "+ f"WHERE `table` = '{table.split('.')[-1]}' AND active = 1 AND partition LIKE '%{retention},{retention_cold}%' "+ "ORDER BY partition ASC"+ )++ partition_result = signoz.telemetrystore.conn.query(partition_query).result_rows+ assert (+ len(partition_result) >= 1+ ), f"No active partitions found for table {table}"++ assert partition_result[0][0] >= count+++def verify_table_retention_expression(+ signoz: types.SigNoz, table_expected_retention_expression_map: dict[str, str]+):+ """+ Verify table partitions exist with data and have correct retention values.++ Args:+ signoz: SigNoz fixture providing access to telemetry store+ table_expected_retention_expression_map: Dictionary mapping table names to expected retention expressions+ Example: {"logs_v2": "created_at + INTERVAL 100 DAY", "logs_v2_resource": "created_at + INTERVAL 100 DAY"}+ """++ for table in table_expected_retention_expression_map:+ query = f"SELECT engine_full FROM system.tables WHERE table = '{table}'"+ result = signoz.telemetrystore.conn.query(query).result_rows+ assert len(result) == 1, f"Table {table} not found in system.tables"++ assert all("TTL" in r[0] for r in result)++ assert all(" SETTINGS" in r[0] for r in result)++ ttl_part = result[0][0].split("TTL ")[1].split(" SETTINGS")[0]+ assert table_expected_retention_expression_map[table] in ttl_part, (+ f"Expected retention expression {table_expected_retention_expression_map[table]} "+ f"not found in table {table} TTL part {ttl_part}"+ )+@pytest.fixture(name="ttl_test_suite_setup", scope="package", autouse=True)def ttl_test_suite_setup(create_user_admin): # pylint: disable=unused-argument@@ -28,12 +107,17 @@ def ttl_test_suite_setup(create_user_admin): # pylint: disable=unused-argumentdef test_set_ttl_traces_success(- signoz: types.SigNoz, get_token: Callable[[str, str], str]+ signoz: types.SigNoz,+ get_token: Callable[[str, str], str],+ remove_traces_ttl_and_storage_settings, # pylint: disable=unused-argument):"""Test setting TTL for traces with new ttlConfig structure."""++ test_duration_hours = 3601 # 3601 hours+payload = {"type": "traces",- "duration": "3600h",+ "duration": f"{test_duration_hours}h", # Don't choose a round number to avoid matching any residual test data}headers = {@@ -52,46 +136,38 @@ def test_set_ttl_traces_success(assert "message" in response_dataassert "successfully set up" in response_data["message"].lower()- # Verify TTL settings in Clickhouse# Allow some time for the TTL to be appliedtime.sleep(2)- # Check TTL settings on relevant tables- tables_to_check = [- "signoz_index_v3",- "traces_v3_resource",- "signoz_error_index_v2",- "usage_explorer",- "dependency_graph_minutes_v2",- "trace_summary",- "span_attributes_keys",- ]-- # Query to get table engine info which includes TTL- table_list = ", ".join(f"'{table}'" for table in tables_to_check)- query = f"SELECT engine_full FROM system.tables WHERE table in [{table_list}]"-- result = signoz.telemetrystore.conn.query(query).result_rows-- # Verify TTL exists in all table definitions- assert all("TTL" in r[0] for r in result)-- assert all(" SETTINGS" in r[0] for r in result)-- ttl_parts = [r[0].split("TTL ")[1].split(" SETTINGS")[0] for r in result]- # All TTLs should include toIntervalSecond(12960000) which is 3600h- assert all("toIntervalSecond(12960000)" in ttl_part for ttl_part in ttl_parts)+ verify_table_retention_expression(+ signoz,+ {+ "signoz_index_v3": f"toIntervalSecond({test_duration_hours*3600})", # 3601 hours in seconds+ "traces_v3_resource": f"toIntervalSecond({test_duration_hours*3600})", # 3601 hours in seconds+ "signoz_error_index_v2": f"toIntervalSecond({test_duration_hours*3600})", # 3601 hours in seconds+ "usage_explorer": f"toIntervalSecond({test_duration_hours*3600})", # 3601 hours in seconds+ "dependency_graph_minutes_v2": f"toIntervalSecond({test_duration_hours*3600})", # 3601 hours in seconds+ "trace_summary": f"toIntervalSecond({test_duration_hours*3600})", # 3601 hours in seconds+ "span_attributes_keys": f"toIntervalSecond({test_duration_hours*3600})", # 3601 hours in seconds+ },+ )def test_set_ttl_traces_with_cold_storage(- signoz: types.SigNoz, get_token: Callable[[str, str], str]+ signoz: types.SigNoz,+ get_token: Callable[[str, str], str],+ remove_traces_ttl_and_storage_settings, # pylint: disable=unused-argument):"""Test setting TTL for traces with cold storage configuration."""++ test_duration_hours = 91 * 24 # 91 days in hours+ test_cold_duration_hours = 32 * 24 # 32 days in hours+payload = {"type": "traces",- "duration": f"{90*24}h", # 90 days in hours- "coldStorageVolume": "cold_storage_vol",- "toColdStorageDuration": f"{30*24}h", # 30 days in hours+ "duration": f"{test_duration_hours}h", # 91 days in hours+ "coldStorage": "cold",+ "toColdDuration": f"{test_cold_duration_hours}h", # 32 days in hours}headers = {@@ -110,16 +186,50 @@ def test_set_ttl_traces_with_cold_storage(assert "message" in response_dataassert "successfully set up" in response_data["message"].lower()+ time.sleep(2)++ verify_table_retention_expression(+ signoz,+ {+ "signoz_index_v3": f"toIntervalSecond({test_duration_hours*3600})", # 91 days in seconds+ "traces_v3_resource": f"toIntervalSecond({test_duration_hours*3600})", # 91 days in seconds+ "signoz_error_index_v2": f"toIntervalSecond({test_duration_hours*3600})", # 91 days in seconds+ "usage_explorer": f"toIntervalSecond({test_duration_hours*3600})", # 91 days in seconds+ "dependency_graph_minutes_v2": f"toIntervalSecond({test_duration_hours*3600})", # 91 days in seconds+ "trace_summary": f"toIntervalSecond({test_duration_hours*3600})", # 91 days in seconds+ "span_attributes_keys": f"toIntervalSecond({test_duration_hours*3600})", # 91 days in seconds+ },+ )++ verify_table_retention_expression(+ signoz,+ {+ "signoz_index_v3": f"toIntervalSecond({test_cold_duration_hours*3600}) TO VOLUME 'cold'",+ "traces_v3_resource": f"toIntervalSecond({test_cold_duration_hours*3600}) TO VOLUME 'cold'",+ "signoz_error_index_v2": f"toIntervalSecond({test_cold_duration_hours*3600}) TO VOLUME 'cold'",+ "usage_explorer": f"toIntervalSecond({test_cold_duration_hours*3600}) TO VOLUME 'cold'",+ "dependency_graph_minutes_v2": f"toIntervalSecond({test_cold_duration_hours*3600}) TO VOLUME 'cold'",+ "trace_summary": f"toIntervalSecond({test_cold_duration_hours*3600}) TO VOLUME 'cold'",+ # "span_attributes_keys": f"toIntervalSecond({test_cold_duration_hours*3600}) TO VOLUME",+ # Span attributes keys table does not have cold storage configured+ },+ )+def test_set_ttl_metrics_success(- signoz: types.SigNoz, get_token: Callable[[str, str], str]+ signoz: types.SigNoz,+ get_token: Callable[[str, str], str],+ remove_metrics_ttl_and_storage_settings, # pylint: disable=unused-argument):"""Test setting TTL for metrics using the new setTTLMetrics method."""++ test_duration_hours = 92 * 24 # 92 days in hours+payload = {"type": "metrics",- "duration": f"{90*24}h", # 90 days in hours- "coldStorageVolume": "",- "toColdStorageDuration": 0,+ "duration": f"{test_duration_hours}h", # 92 days in hours+ "coldStorage": "",+ "toColdDuration": 0,}headers = {@@ -143,42 +253,35 @@ def test_set_ttl_metrics_success(time.sleep(2)# Check TTL settings on relevant metrics tables- tables_to_check = [- "samples_v4",- "samples_v4_agg_5m",- "samples_v4_agg_30m",- "time_series_v4",- "time_series_v4_6hrs",- "time_series_v4_1day",- "time_series_v4_1week",- ]-- # Query to get table engine info which includes TTL- table_list = "', '".join(tables_to_check)- query = f"SELECT engine_full FROM system.tables WHERE table in ['{table_list}']"-- result = signoz.telemetrystore.conn.query(query).result_rows-- # Verify TTL exists in all table definitions- assert all("TTL" in r[0] for r in result)-- assert all(" SETTINGS" in r[0] for r in result)-- ttl_parts = [r[0].split("TTL ")[1].split(" SETTINGS")[0] for r in result]-- # All TTLs should include toIntervalSecond(7776000) which is 90*24h- assert all("toIntervalSecond(7776000)" in ttl_part for ttl_part in ttl_parts)+ verify_table_retention_expression(+ signoz,+ {+ "samples_v4": f"toIntervalSecond({test_duration_hours * 3600})", # 92 days in seconds+ "samples_v4_agg_5m": f"toIntervalSecond({test_duration_hours * 3600})", # 92 days in seconds+ "samples_v4_agg_30m": f"toIntervalSecond({test_duration_hours * 3600})", # 92 days in seconds+ "time_series_v4": f"toIntervalSecond({test_duration_hours * 3600})", # 92 days in seconds+ "time_series_v4_6hrs": f"toIntervalSecond({test_duration_hours * 3600})", # 92 days in seconds+ "time_series_v4_1day": f"toIntervalSecond({test_duration_hours * 3600})", # 92 days in seconds+ "time_series_v4_1week": f"toIntervalSecond({test_duration_hours * 3600})", # 92 days in seconds+ },+ )def test_set_ttl_metrics_with_cold_storage(- signoz: types.SigNoz, get_token: Callable[[str, str], str]+ signoz: types.SigNoz,+ get_token: Callable[[str, str], str],+ remove_metrics_ttl_and_storage_settings, # pylint: disable=unused-argument):"""Test setting TTL for metrics with cold storage configuration."""++ test_duration_hours = 91 * 24 # 91 days in hours+ test_cold_duration_hours = 21 * 24 # 21 days in hours+payload = {"type": "metrics",- "duration": f"{90*24}h", # 90 days in hours- "coldStorageVolume": "metrics_cold_vol",- "toColdStorageDuration": f"{20*24}h", # 20 days in hours+ "duration": f"{test_duration_hours}h", # 91 days in hours+ "coldStorage": "cold",+ "toColdDuration": f"{test_cold_duration_hours}h", # 21 days in hours}headers = {@@ -197,6 +300,43 @@ def test_set_ttl_metrics_with_cold_storage(assert "message" in response_dataassert "successfully set up" in response_data["message"].lower()+ time.sleep(2)++ # Check TTL settings on relevant metrics tables+ verify_table_retention_expression(+ signoz,+ {+ "samples_v4": f"toIntervalSecond({test_duration_hours * 3600})", # 92 days in seconds+ "samples_v4_agg_5m": f"toIntervalSecond({test_duration_hours * 3600})", # 92 days in seconds+ "samples_v4_agg_30m": f"toIntervalSecond({test_duration_hours * 3600})", # 92 days in seconds+ "time_series_v4": f"toIntervalSecond({test_duration_hours * 3600})", # 92 days in seconds+ "time_series_v4_6hrs": f"toIntervalSecond({test_duration_hours * 3600})", # 92 days in seconds+ "time_series_v4_1day": f"toIntervalSecond({test_duration_hours * 3600})", # 92 days in seconds+ "time_series_v4_1week": f"toIntervalSecond({test_duration_hours * 3600})", # 92 days in seconds+ },+ )++ # Check cold storage settings on relevant metrics tables+ verify_table_retention_expression(+ signoz,+ {+ # 21 days in seconds+ "samples_v4": f"toIntervalSecond({test_cold_duration_hours * 3600}) TO VOLUME 'cold'",+ # 21 days in seconds+ "samples_v4_agg_5m": f"toIntervalSecond({test_cold_duration_hours * 3600}) TO VOLUME 'cold'",+ # 21 days in seconds+ "samples_v4_agg_30m": f"toIntervalSecond({test_cold_duration_hours * 3600}) TO VOLUME 'cold'",+ # 21 days in seconds+ "time_series_v4": f"toIntervalSecond({test_cold_duration_hours * 3600}) TO VOLUME 'cold'",+ # 21 days in seconds+ "time_series_v4_6hrs": f"toIntervalSecond({test_cold_duration_hours * 3600}) TO VOLUME 'cold'",+ # 21 days in seconds+ "time_series_v4_1day": f"toIntervalSecond({test_cold_duration_hours * 3600}) TO VOLUME 'cold'",+ # 21 days in seconds+ "time_series_v4_1week": f"toIntervalSecond({test_cold_duration_hours * 3600}) TO VOLUME 'cold'",+ },+ )+def test_set_ttl_invalid_type(signoz: types.SigNoz, get_token: Callable[[str, str], str]@@ -205,8 +345,8 @@ def test_set_ttl_invalid_type(payload = {"type": "invalid_type","duration": f"{90*24}h",- "coldStorageVolume": "",- "toColdStorageDuration": 0,+ "coldStorage": "",+ "toColdDuration": 0,}headers = {@@ -224,12 +364,18 @@ def test_set_ttl_invalid_type(def test_set_custom_retention_ttl_basic(- signoz: types.SigNoz, get_token: Callable[[str, str], str]+ signoz: types.SigNoz,+ get_token: Callable[[str, str], str],+ insert_logs,+ remove_logs_ttl_settings, # pylint: disable=unused-argument):"""Test setting custom retention TTL with basic configuration."""++ test_retention_days = 103 # 103 days+payload = {"type": "logs",- "defaultTTLDays": 100,+ "defaultTTLDays": test_retention_days,"ttlConditions": [],"coldStorageVolume": "","coldStorageDurationDays": 0,@@ -250,82 +396,119 @@ def test_set_custom_retention_ttl_basic(response_data = response.json()assert "message" in response_data- # Verify TTL settings in Clickhouse- # Allow some time for the TTL to be applied- time.sleep(2)-- # Check TTL settings on relevant tables- tables_to_check = [- "logs_v2",- "logs_v2_resource",+ logs = [+ Logs(+ body="test",+ resources={"service_name": "test-service"},+ severity_text="INFO",+ ),]+ insert_logs(logs)- # Query to get table engine info which includes TTL- table_list = "', '".join(tables_to_check)- query = f"SELECT engine_full FROM system.tables WHERE table in ['{table_list}']"- result = signoz.telemetrystore.conn.query(query).result_rows-- # Verify TTL exists in all table definitions- assert all("TTL" in r[0] for r in result)+ # Verify partitions for logs tables+ verify_table_partition_expressions(+ signoz,+ {+ "signoz_logs.logs_v2": (test_retention_days, 0, 1),+ "signoz_logs.logs_v2_resource": (test_retention_days, 0, 1),+ },+ )- assert all(" SETTINGS" in r[0] for r in result)+ # Verify retention settings for logs tables+ verify_table_retention_expression(+ signoz,+ {+ "logs_attribute_keys": f"toIntervalDay({test_retention_days})",+ "logs_resource_keys": f"toIntervalDay({test_retention_days})",+ },+ )- ttl_parts = [r[0].split("TTL ")[1].split(" SETTINGS")[0] for r in result]- # Also verify the TTL parts contain retention_days- assert all("_retention_days" in ttl_part for ttl_part in ttl_parts)+def test_set_custom_retention_ttl_basic_with_cold_storage(+ signoz: types.SigNoz,+ get_token: Callable[[str, str], str],+ insert_logs,+ remove_logs_ttl_settings, # pylint: disable=unused-argument+):+ """Test setting custom retention TTL with basic configuration."""- # Query to describe tables and check retention_days column- for table in tables_to_check:- describe_query = f"DESCRIBE TABLE signoz_logs.{table}"- describe_result = signoz.telemetrystore.conn.query(describe_query).result_rows+ test_retention_days = 104 # 104 days+ test_retention_days_cold = 27 # 27 days- # Find the _retention_days column- retention_col = next(- (row for row in describe_result if row[0] == "_retention_days"), None- )- assert (- retention_col is not None- ), f"_retention_days column not found in table {table}"- assert (- retention_col[1] == "UInt16"- ), f"Expected _retention_days to be UInt16 in table {table}, but got {retention_col[1]}"- assert (- retention_col[3] == "100"- ), f"Expected default value of _retention_days to be 100 in table {table}, but got {retention_col[3]}"+ payload = {+ "type": "logs",+ "defaultTTLDays": test_retention_days,+ "ttlConditions": [],+ "coldStorageVolume": "cold",+ "coldStorageDurationDays": test_retention_days_cold,+ }- tables_to_check = ["logs_attribute_keys", "logs_resource_keys"]+ headers = {+ "Authorization": f"Bearer {get_token(USER_ADMIN_EMAIL, USER_ADMIN_PASSWORD)}"+ }- # Query to get table engine info which includes TTL- table_list = "', '".join(tables_to_check)- query = f"SELECT engine_full FROM system.tables WHERE table in ['{table_list}']"- result = signoz.telemetrystore.conn.query(query).result_rows+ response = requests.post(+ signoz.self.host_configs["8080"].get("/api/v2/settings/ttl"),+ json=payload,+ headers=headers,+ timeout=30,+ )- # Verify TTL exists in all table definitions- assert all("TTL" in r[0] for r in result)+ assert response.status_code == HTTPStatus.OK+ response_data = response.json()+ assert "message" in response_data- assert all(" SETTINGS" in r[0] for r in result)+ logs = [+ Logs(+ body="test",+ resources={"service_name": "test-service"},+ severity_text="INFO",+ ),+ ]+ insert_logs(logs)- ttl_parts = [r[0].split("TTL ")[1].split(" SETTINGS")[0] for r in result]+ # Verify partitions and retention for logs tables+ verify_table_partition_expressions(+ signoz,+ {+ "signoz_logs.logs_v2": (test_retention_days, test_retention_days_cold, 1),+ "signoz_logs.logs_v2_resource": (+ test_retention_days,+ test_retention_days_cold,+ 1,+ ),+ },+ )- # Also verify the TTL parts contain retention_days- assert all("toIntervalDay(100)" in ttl_part for ttl_part in ttl_parts)+ verify_table_retention_expression(+ signoz,+ {+ "logs_v2": "toIntervalDay(_retention_days_cold) TO VOLUME 'cold'",+ "logs_v2_resource": "toIntervalDay(_retention_days_cold) TO VOLUME 'cold'",+ # Cold storage retention is not applicable for attribute keys table+ "logs_attribute_keys": f"toIntervalDay({test_retention_days})",+ # Cold storage retention is not applicable for resource keys table+ "logs_resource_keys": f"toIntervalDay({test_retention_days})",+ },+ )def test_set_custom_retention_ttl_basic_fallback(signoz: types.SigNoz,get_token,ttl_legacy_logs_v2_table_setup, # pylint: disable=unused-argument- ttl_legacy_logs_v2_resource_table_setup, # pylint: disable=unused-argument+ ttl_legacy_logs_v2_resource_table_setup, # pylint: disable=unused-argument,):"""Test setting TTL for logs using the new setTTLLogs method."""+ test_retention_days = 101 # 101 days+ test_retention_days_cold = 17 # 17 dayspayload = {"type": "logs",- "defaultTTLDays": 100,+ "defaultTTLDays": test_retention_days,"ttlConditions": [],- "coldStorageVolume": "",- "coldStorageDurationDays": 0,+ "coldStorageVolume": "cold",+ "coldStorageDurationDays": test_retention_days_cold,}headers = {@@ -349,37 +532,44 @@ def test_set_custom_retention_ttl_basic_fallback(time.sleep(2)# Check TTL settings on relevant logs tables- tables_to_check = [- "logs_v2",- "logs_v2_resource",- "logs_attribute_keys",- "logs_resource_keys",- ]-- # Query to get table engine info which includes TTL- table_list = "', '".join(tables_to_check)- query = f"SELECT engine_full FROM system.tables WHERE table in ['{table_list}']"-- result = signoz.telemetrystore.conn.query(query).result_rows-- # Verify TTL exists in all table definitions- assert all("TTL" in r[0] for r in result)-- assert all(" SETTINGS" in r[0] for r in result)-- ttl_parts = [r[0].split("TTL ")[1].split(" SETTINGS")[0] for r in result]+ verify_table_retention_expression(+ signoz,+ {+ # 101 days in seconds+ "logs_v2": f"toIntervalSecond({test_retention_days * 24 * 3600})",+ # 101 days in seconds+ "logs_v2_resource": f"toIntervalSecond({test_retention_days * 24 * 3600})",+ # Cold storage retention is not applicable for attribute keys table+ "logs_attribute_keys": f"toIntervalSecond({test_retention_days * 24 * 3600})",+ # Cold storage retention is not applicable for resource keys table+ "logs_resource_keys": f"toIntervalSecond({test_retention_days * 24 * 3600})",+ },+ )- # All TTLs should include toIntervalSecond(8640000) which is 100 days- assert all("toIntervalSecond(8640000)" in ttl_part for ttl_part in ttl_parts)+ verify_table_retention_expression(+ signoz,+ {+ # 17 days in seconds+ "logs_v2": f"toIntervalSecond({test_retention_days_cold * 24 * 3600}) TO VOLUME 'cold'",+ # 17 days in seconds+ "logs_v2_resource": f"toIntervalSecond({test_retention_days_cold * 24 * 3600}) TO VOLUME 'cold'",+ },+ )-def test_set_custom_retention_ttl_basic_101_times(signoz: types.SigNoz, get_token):+def test_set_custom_retention_ttl_basic_101_times(+ signoz: types.SigNoz,+ get_token,+ remove_logs_ttl_settings, # pylint: disable=unused-argument+):"""Test setting custom retention TTL with basic configuration to trigger housekeeping."""+ test_retention_days = 113 # 113 days+for _ in range(101):payload = {"type": "logs",- "defaultTTLDays": 100,+ "defaultTTLDays": test_retention_days,"ttlConditions": [],"coldStorageVolume": "","coldStorageDurationDays": 0,@@ -400,65 +590,41 @@ def test_set_custom_retention_ttl_basic_101_times(signoz: types.SigNoz, get_tokeresponse_data = response.json()assert "message" in response_data- # Check TTL settings on relevant tables- tables_to_check = [- "logs_v2",- "logs_v2_resource",- ]-- # Query to get table engine info which includes TTL- table_list = "', '".join(tables_to_check)- query = f"SELECT engine_full FROM system.tables WHERE table in ['{table_list}']"- result = signoz.telemetrystore.conn.query(query).result_rows-- # Verify TTL exists in all table definitions- assert all("TTL" in r[0] for r in result)-- assert all(" SETTINGS" in r[0] for r in result)-- ttl_parts = [r[0].split("TTL ")[1].split(" SETTINGS")[0] for r in result]-- # Also verify the TTL parts contain retention_days- assert all("_retention_days" in ttl_part for ttl_part in ttl_parts)-- # Query to describe tables and check retention_days column- for table in tables_to_check:- describe_query = f"DESCRIBE TABLE signoz_logs.{table}"- describe_result = signoz.telemetrystore.conn.query(describe_query).result_rows-- # Find the _retention_days column- retention_col = next(- (row for row in describe_result if row[0] == "_retention_days"), None- )- assert (- retention_col is not None- ), f"_retention_days column not found in table {table}"- assert (- retention_col[1] == "UInt16"- ), f"Expected _retention_days to be UInt16 in table {table}, but got {retention_col[1]}"- assert (- retention_col[3] == "100"- ), f"Expected default value of _retention_days to be 100 in table {table}, but got {retention_col[3]}"+ # Verify retention settings for logs tables+ verify_table_retention_expression(+ signoz,+ {+ "logs_attribute_keys": f"toIntervalDay({test_retention_days})",+ "logs_resource_keys": f"toIntervalDay({test_retention_days})",+ },+ )def test_set_custom_retention_ttl_with_conditions(- signoz: types.SigNoz, get_token: Callable[[str, str], str], insert_logs+ signoz: types.SigNoz,+ get_token: Callable[[str, str], str],+ insert_logs,+ remove_logs_ttl_settings, # pylint: disable=unused-argument):"""Test setting custom retention TTL with filter conditions."""+ test_retention_days = 30 # 30 days+ test_retention_days_condition = 60 # 60 days+ test_retention_days_cold = 5 # 5 days+payload = {"type": "logs",- "defaultTTLDays": 30,+ "defaultTTLDays": test_retention_days,"ttlConditions": [{"conditions": [{"key": "service_name", "values": ["frontend", "backend"]}],- "ttlDays": 60,+ "ttlDays": test_retention_days_condition,}],- "coldStorageVolume": "",- "coldStorageDurationDays": 0,+ "coldStorageVolume": "cold",+ "coldStorageDurationDays": test_retention_days_cold,}headers = {@@ -491,9 +657,66 @@ def test_set_custom_retention_ttl_with_conditions(response_data = response.json()assert "message" in response_data+ # insert some logs, these should go test_retention_days_condition (60 days) partition+ logs = [+ Logs(resources={"service_name": "frontend"}, severity_text="ERROR"),+ ]+ insert_logs(logs)-def test_set_custom_retention_ttl_with_cold_storage(- signoz: types.SigNoz, get_token: Callable[[str, str], str], insert_logs+ # Verify partitions and retention for logs tables+ verify_table_partition_expressions(+ signoz,+ {+ "signoz_logs.logs_v2": (+ test_retention_days_condition,+ test_retention_days_cold,+ 1,+ ),+ "signoz_logs.logs_v2_resource": (+ test_retention_days_condition,+ test_retention_days_cold,+ 1,+ ),+ },+ )++ # insert some logs, these should go test_retention_days (30 days) partition+ logs = [+ Logs(resources={"service_name": "others"}, severity_text="ERROR"),+ ]+ insert_logs(logs)++ # Verify partitions and retention for logs tables+ verify_table_partition_expressions(+ signoz,+ {+ "signoz_logs.logs_v2": (test_retention_days, test_retention_days_cold, 1),+ "signoz_logs.logs_v2_resource": (+ test_retention_days,+ test_retention_days_cold,+ 1,+ ),+ },+ )++ verify_table_retention_expression(+ signoz,+ {+ "logs_v2": "toIntervalDay(_retention_days_cold) TO VOLUME 'cold'",+ "logs_v2_resource": "toIntervalDay(_retention_days_cold) TO VOLUME 'cold'",+ # Cold storage retention is not applicable for attribute keys table+ "logs_attribute_keys": f"toIntervalDay({max(test_retention_days, test_retention_days_condition)})",+ # Cold storage retention is not applicable for resource keys table+ "logs_resource_keys": f"toIntervalDay({max(test_retention_days, test_retention_days_condition)})",+ },+ )+++def test_set_custom_retention_ttl_with_invalid_cold_storage(+ signoz: types.SigNoz,+ get_token: Callable[[str, str], str],+ insert_logs,+ remove_logs_ttl_settings, # pylint: disable=unused-argument):"""Test setting custom retention TTL with cold storage configuration."""payload = {@@ -530,7 +753,7 @@ def test_set_custom_retention_ttl_with_cold_storage(response_data = response.json()assert "error" in response_dataassert "message" in response_data["error"]- assert "Unknown storage policy `tiered`" in response_data["error"]["message"]+ assert "No such volume `logs_cold_storage`" in response_data["error"]["message"]def test_set_custom_retention_ttl_duplicate_conditions(@@ -682,9 +905,10 @@ def test_set_ttl_logs_success():"""Test setting TTL for logs using the new setTTLLogs method."""+ test_retention_days = 150 # 150 dayspayload = {"type": "logs",- "duration": "3600h",+ "duration": f"{test_retention_days * 24}h",}headers = {@@ -703,31 +927,18 @@ def test_set_ttl_logs_success(assert "message" in response_dataassert "successfully set up" in response_data["message"].lower()- # Verify TTL settings in Clickhouse- # Allow some time for the TTL to be applied- time.sleep(5)-- # Check TTL settings on relevant logs tables- tables_to_check = [- "logs_v2",- "logs_v2_resource",- ]-- # Query to get table engine info which includes TTL- table_list = "', '".join(tables_to_check)- query = f"SELECT engine_full FROM system.tables WHERE table in ['{table_list}']"-- result = signoz.telemetrystore.conn.query(query).result_rows-- # Verify TTL exists in all table definitions- assert all("TTL" in r[0] for r in result)-- assert all(" SETTINGS" in r[0] for r in result)-- ttl_parts = [r[0].split("TTL ")[1].split(" SETTINGS")[0] for r in result]+ time.sleep(2)- # All TTLs should include toIntervalSecond(12960000) which is 3600h- assert all("toIntervalSecond(12960000)" in ttl_part for ttl_part in ttl_parts)+ # Verify TTL settings in Clickhouse+ verify_table_retention_expression(+ signoz,+ {+ "logs_v2": f"toIntervalSecond({test_retention_days * 24 * 3600})", # 150 days in seconds+ "logs_v2_resource": f"toIntervalSecond({test_retention_days * 24 * 3600})", # 150 days in seconds+ "logs_attribute_keys": f"toIntervalSecond({test_retention_days * 24 * 3600})", # 150 days in seconds+ "logs_resource_keys": f"toIntervalSecond({test_retention_days * 24 * 3600})", # 150 days in seconds+ },+ )def test_get_ttl_traces_success(@@ -735,9 +946,11 @@ def test_get_ttl_traces_success():"""Test getting TTL for traces."""# First set a TTL configuration for traces++ test_retention_days = 33 # 33 daysset_payload = {"type": "traces",- "duration": "720h", # 30 days in hours+ "duration": f"{test_retention_days * 24}h", # 33 days in hours}headers = {@@ -772,7 +985,7 @@ def test_get_ttl_traces_success(assert "traces_ttl_duration_hrs" in response_dataassert "traces_move_ttl_duration_hrs" in response_dataassert (- response_data["traces_ttl_duration_hrs"] == 720+ response_data["traces_ttl_duration_hrs"] == test_retention_days * 24) # Note: response is in hours as integerassert (response_data["traces_move_ttl_duration_hrs"] == -1@@ -780,7 +993,10 @@ def test_get_ttl_traces_success(def test_large_ttl_conditions_list(- signoz: types.SigNoz, get_token: Callable[[str, str], str], insert_logs+ signoz: types.SigNoz,+ get_token: Callable[[str, str], str],+ insert_logs,+ remove_logs_ttl_settings, # pylint: disable=unused-argument):"""Test custom retention TTL with many conditions."""# Create a list of many TTL conditions to test performance and limits