Skip to content

Commit 18233e1

Browse files
committed
testin integ parallel
1 parent cebfba4 commit 18233e1

File tree

3 files changed

+32
-8
lines changed

3 files changed

+32
-8
lines changed

.github/workflows/build_test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ jobs:
173173
- name: Run tests
174174
# To run a single test on GHA use the below command:
175175
# run: python -m tox run -e `echo py${PYTHON_VERSION/\./}-single-ci | sed 's/ /,/g'`
176-
run: python -m tox run -e `echo py${PYTHON_VERSION/\./}-{extras,unit-parallel,integ,pandas,sso}-ci | sed 's/ /,/g'`
176+
run: python -m tox run -e `echo py${PYTHON_VERSION/\./}-{extras,unit-parallel,integ-parallel,pandas,sso}-ci | sed 's/ /,/g'`
177177

178178
env:
179179
PYTHON_VERSION: ${{ matrix.python-version }}

test/integ/conftest.py

Lines changed: 30 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,27 @@
4141

4242
logger = getLogger(__name__)
4343

44-
if RUNNING_ON_GH:
45-
TEST_SCHEMA = "GH_JOB_{}".format(str(uuid.uuid4()).replace("-", "_"))
46-
else:
47-
TEST_SCHEMA = "python_connector_tests_" + str(uuid.uuid4()).replace("-", "_")
44+
def _get_worker_specific_schema():
45+
"""Generate worker-specific schema name for parallel test execution."""
46+
base_uuid = str(uuid.uuid4()).replace("-", "_")
47+
48+
# Check if running in pytest-xdist parallel mode
49+
worker_id = os.getenv("PYTEST_XDIST_WORKER")
50+
if worker_id:
51+
# Use worker ID to ensure unique schema per worker
52+
worker_suffix = worker_id.replace("-", "_")
53+
if RUNNING_ON_GH:
54+
return f"GH_JOB_{worker_suffix}_{base_uuid}"
55+
else:
56+
return f"python_connector_tests_{worker_suffix}_{base_uuid}"
57+
else:
58+
# Single worker mode (original behavior)
59+
if RUNNING_ON_GH:
60+
return f"GH_JOB_{base_uuid}"
61+
else:
62+
return f"python_connector_tests_{base_uuid}"
63+
64+
TEST_SCHEMA = _get_worker_specific_schema()
4865

4966
if TEST_USING_VENDORED_ARROW:
5067
snowflake.connector.cursor.NANOARR_USAGE = (
@@ -131,8 +148,15 @@ def get_db_parameters(connection_name: str = "default") -> dict[str, Any]:
131148
print_help()
132149
sys.exit(2)
133150

134-
# a unique table name
135-
ret["name"] = "python_tests_" + str(uuid.uuid4()).replace("-", "_")
151+
# a unique table name (worker-specific for parallel execution)
152+
base_uuid = str(uuid.uuid4()).replace("-", "_")
153+
worker_id = os.getenv("PYTEST_XDIST_WORKER")
154+
if worker_id:
155+
# Include worker ID to prevent conflicts between parallel workers
156+
worker_suffix = worker_id.replace("-", "_")
157+
ret["name"] = f"python_tests_{worker_suffix}_{base_uuid}"
158+
else:
159+
ret["name"] = f"python_tests_{base_uuid}"
136160
ret["name_wh"] = ret["name"] + "wh"
137161

138162
ret["schema"] = TEST_SCHEMA

tox.ini

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ source = src/snowflake/connector
1818
[tox]
1919
minversion = 4
2020
envlist = fix_lint,
21-
py{39,310,311,312,313}-{extras,unit-parallel,integ,pandas,sso,single},
21+
py{39,310,311,312,313}-{extras,unit-parallel,integ,integ-parallel,pandas,sso,single},
2222
coverage
2323
skip_missing_interpreters = true
2424

0 commit comments

Comments
 (0)