From 4fef1f940973ba2f754b1e4da75702d21c9a6255 Mon Sep 17 00:00:00 2001 From: cookieark Date: Tue, 15 Sep 2026 22:11:31 +0530 Subject: [PATCH] fix(tests): prevent schema collisions between integration test params Signed-off-by: cookieark --- tests/core/engine_adapter/integration/__init__.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/tests/core/engine_adapter/integration/__init__.py b/tests/core/engine_adapter/integration/__init__.py index 11bf95f3d6..bb5bc2c850 100644 --- a/tests/core/engine_adapter/integration/__init__.py +++ b/tests/core/engine_adapter/integration/__init__.py @@ -1,7 +1,9 @@ from __future__ import annotations +import hashlib import os import pathlib +import secrets import sys import typing as t import time @@ -20,7 +22,7 @@ from sqlmesh.core.engine_adapter import SparkEngineAdapter, TrinoEngineAdapter, AthenaEngineAdapter from sqlmesh.core.engine_adapter.shared import DataObject from sqlmesh.core.model.definition import SqlModel, load_sql_based_model -from sqlmesh.utils import random_id +from sqlmesh.utils import ALPHANUMERIC, random_id from sqlmesh.utils.date import to_ds from sqlmesh.utils.pydantic import PydanticModel from tests.utils.pandas import compare_dataframes @@ -205,7 +207,13 @@ def __init__( self.mark = mark self.gateway = gateway self._columns_to_types = columns_to_types - self.test_id = random_id(short=True) + # The id is appended to schema names, so it has to keep concurrent test params apart + # while staying short: temp table names built from these schemas are already close to + # Postgres's 63 character identifier limit. A tag derived from the param guarantees two + # params never share a schema, and the random part separates concurrent runs and retries. + param_tag = hashlib.sha1(mark.encode()).hexdigest()[:3] + random_part = "".join(secrets.choice(ALPHANUMERIC) for _ in range(5)) + self.test_id = f"{param_tag}{random_part}" self._context: t.Optional[Context] = None self.is_remote = is_remote self._schemas: t.List[