Skip to content

Commit 98f314e

Browse files
SNOW-3192362: Fix AWS integration regressions without matrix changes (#2819)
1 parent d743057 commit 98f314e

8 files changed

Lines changed: 38 additions & 14 deletions

test/integ/aio_it/conftest.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,11 @@
99
get_db_parameters,
1010
is_public_testaccount,
1111
)
12-
from typing import Any, AsyncContextManager, AsyncGenerator, Callable
12+
from typing import Any, AsyncContextManager, AsyncGenerator, Callable, Generator
1313

1414
import pytest
1515

16+
import snowflake.connector
1617
from snowflake.connector.aio import SnowflakeConnection
1718
from snowflake.connector.aio import connect as async_connect
1819
from snowflake.connector.aio._telemetry import TelemetryClient
@@ -143,6 +144,16 @@ def conn_cnx():
143144
return db
144145

145146

147+
@pytest.fixture(autouse=True)
148+
def reset_default_paramstyle() -> Generator[None, None, None]:
149+
"""Keep async integration tests isolated from global paramstyle changes."""
150+
snowflake.connector.paramstyle = "pyformat"
151+
try:
152+
yield
153+
finally:
154+
snowflake.connector.paramstyle = "pyformat"
155+
156+
146157
@pytest.fixture()
147158
async def conn_testaccount() -> AsyncGenerator[SnowflakeConnection, None]:
148159
connection = await create_connection("default")

test/integ/aio_it/test_multi_statement_async.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ async def _check_multi_statement_results(
7373

7474
async def test_multi_statement_basic(conn_cnx, skip_to_last_set: bool):
7575
"""Selects fixed integer data using statement level parameters."""
76-
async with conn_cnx() as con:
76+
async with conn_cnx(paramstyle="pyformat") as con:
7777
async with con.cursor() as cur:
7878
statement_params = dict()
7979
await cur.execute(
@@ -144,7 +144,7 @@ async def test_binding_multi(conn_cnx, style: str, skip_to_last_set: bool):
144144
@pytest.mark.parametrize("cursor_class", [SnowflakeCursor, DictCursor])
145145
async def test_async_exec_multi(conn_cnx, cursor_class, skip_to_last_set: bool):
146146
"""Tests whether async execution query works within a multi-statement"""
147-
async with conn_cnx() as con:
147+
async with conn_cnx(paramstyle="pyformat") as con:
148148
async with con.cursor(cursor_class) as cur:
149149
await cur.execute_async(
150150
"select 1; select 2; select count(*) from table(generator(timeLimit => 1)); select 'b';",
@@ -153,7 +153,7 @@ async def test_async_exec_multi(conn_cnx, cursor_class, skip_to_last_set: bool):
153153
q_id = cur.sfqid
154154
assert con.is_still_running(await con.get_query_status(q_id))
155155
await _wait_while_query_running_async(con, q_id, sleep_time=1)
156-
async with conn_cnx() as con:
156+
async with conn_cnx(paramstyle="pyformat") as con:
157157
async with con.cursor(cursor_class) as cur:
158158
await _wait_until_query_success_async(
159159
con, q_id, num_checks=3, sleep_per_check=1
@@ -318,7 +318,7 @@ async def test_executemany_multi(conn_cnx, skip_to_last_set: bool):
318318
"""Tests executemany with multi-statement optimizations enabled through the num_statements parameter."""
319319
table1 = random_string(5, "test_executemany_multi_")
320320
table2 = random_string(5, "test_executemany_multi_")
321-
async with conn_cnx() as con:
321+
async with conn_cnx(paramstyle="pyformat") as con:
322322
async with con.cursor() as cur:
323323
await cur.execute(
324324
f"create temp table {table1} (aa number); create temp table {table2} (bb number);",

test/integ/aio_it/test_numpy_binding_async.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ async def test_numpy_datatype_binding(conn_cnx, db_parameters):
6262
},
6363
]
6464
try:
65-
async with conn_cnx(numpy=True) as cnx:
65+
async with conn_cnx(numpy=True, paramstyle="pyformat") as cnx:
6666
await cnx.cursor().execute(
6767
"""
6868
CREATE OR REPLACE TABLE {name} (

test/integ/conftest.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -406,6 +406,16 @@ def fin():
406406
return connection
407407

408408

409+
@pytest.fixture(autouse=True)
410+
def reset_default_paramstyle() -> Generator[None]:
411+
"""Keep tests isolated from process-global paramstyle changes."""
412+
snowflake.connector.paramstyle = "pyformat"
413+
try:
414+
yield
415+
finally:
416+
snowflake.connector.paramstyle = "pyformat"
417+
418+
409419
@pytest.fixture()
410420
def conn_cnx() -> Callable[..., ContextManager[SnowflakeConnection]]:
411421
return db

test/integ/test_large_result_set.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import logging
55
import threading
66
from unittest.mock import Mock
7+
from urllib.parse import urlparse
78

89
import pytest
910

@@ -274,7 +275,8 @@ def send_strip_encoding(self, request, *args, **kwargs):
274275
HTTP round-trip but before requests reads the body."""
275276
nonlocal chunks_intercepted
276277
response = original_send(self, request, *args, **kwargs)
277-
if response.status_code == 200:
278+
hostname = urlparse(request.url).hostname or ""
279+
if response.status_code == 200 and "snowflakecomputing." not in hostname:
278280
_strip_content_encoding(response)
279281
with chunks_intercepted_lock:
280282
chunks_intercepted += 1

test/integ/test_multi_statement.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ def _check_multi_statement_results(
8686

8787
def test_multi_statement_basic(conn_cnx, skip_to_last_set: bool):
8888
"""Selects fixed integer data using statement level parameters."""
89-
with conn_cnx() as con:
89+
with conn_cnx(paramstyle="pyformat") as con:
9090
with con.cursor() as cur:
9191
statement_params = dict()
9292
cur.execute(
@@ -157,7 +157,7 @@ def test_binding_multi(conn_cnx, style: str, skip_to_last_set: bool):
157157
@pytest.mark.parametrize("cursor_class", [SnowflakeCursor, DictCursor])
158158
def test_async_exec_multi(conn_cnx, cursor_class, skip_to_last_set: bool):
159159
"""Tests whether async execution query works within a multi-statement"""
160-
with conn_cnx() as con:
160+
with conn_cnx(paramstyle="pyformat") as con:
161161
with con.cursor(cursor_class) as cur:
162162
cur.execute_async(
163163
"select 1; select 2; select count(*) from table(generator(timeLimit => 1)); select 'b';",
@@ -166,7 +166,7 @@ def test_async_exec_multi(conn_cnx, cursor_class, skip_to_last_set: bool):
166166
q_id = cur.sfqid
167167
assert con.is_still_running(con.get_query_status(q_id))
168168
_wait_while_query_running(con, q_id, sleep_time=1)
169-
with conn_cnx() as con:
169+
with conn_cnx(paramstyle="pyformat") as con:
170170
with con.cursor(cursor_class) as cur:
171171
_wait_until_query_success(con, q_id, num_checks=3, sleep_per_check=1)
172172
assert con.get_query_status_throw_if_error(q_id) == QueryStatus.SUCCESS
@@ -322,7 +322,7 @@ def test_executemany_multi(conn_cnx, skip_to_last_set: bool):
322322
"""Tests executemany with multi-statement optimizations enabled through the num_statements parameter."""
323323
table1 = random_string(5, "test_executemany_multi_")
324324
table2 = random_string(5, "test_executemany_multi_")
325-
with conn_cnx() as con:
325+
with conn_cnx(paramstyle="pyformat") as con:
326326
with con.cursor() as cur:
327327
cur.execute(
328328
f"create temp table {table1} (aa number); create temp table {table2} (bb number);",

test/integ/test_numpy_binding.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ def test_numpy_datatype_binding(conn_cnx, db_parameters):
5858
},
5959
]
6060
try:
61-
with conn_cnx(numpy=True) as cnx:
61+
with conn_cnx(numpy=True, paramstyle="pyformat") as cnx:
6262
cnx.cursor().execute(
6363
"""
6464
CREATE OR REPLACE TABLE {name} (

tox.ini

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ setenv =
4040
unit: SNOWFLAKE_TEST_TYPE = unit
4141
integ: SNOWFLAKE_TEST_TYPE = integ
4242
single: SNOWFLAKE_TEST_TYPE = single
43-
parallel: SNOWFLAKE_PYTEST_OPTS = {env:SNOWFLAKE_PYTEST_OPTS:} -n auto
43+
parallel: SNOWFLAKE_PYTEST_OPTS = {env:SNOWFLAKE_PYTEST_OPTS:} -n auto --dist worksteal
4444
# Add common parts into pytest command
4545
SNOWFLAKE_PYTEST_COV_LOCATION = {env:JUNIT_REPORT_DIR:{toxworkdir}}/junit.{envname}-{env:cloud_provider:dev}.xml
4646
SNOWFLAKE_PYTEST_COV_CMD = --cov snowflake.connector --junitxml {env:SNOWFLAKE_PYTEST_COV_LOCATION} --cov-report=
@@ -185,8 +185,9 @@ depends = py39, py310, py311, py312, py313, py314
185185

186186
[pytest]
187187
log_level = info
188-
addopts = -ra --strict-markers
188+
addopts = -ra --strict-markers -vvv
189189
junit_family = xunit2
190+
timeout = 1200
190191
filterwarnings =
191192
error::UserWarning:cryptography.*
192193
error::cryptography.utils.CryptographyDeprecationWarning

0 commit comments

Comments
 (0)