Skip to content

Commit d5ee2e4

Browse files
Apply #2276 changes to async tests
1 parent 325b9b6 commit d5ee2e4

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

test/integ/aio/sso/test_unit_mfa_cache_async.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,16 @@
1212
import pytest
1313

1414
import snowflake.connector.aio
15-
from snowflake.connector.compat import IS_LINUX
1615
from snowflake.connector.errors import DatabaseError
1716

1817
try:
19-
from snowflake.connector.compat import IS_MACOS
18+
from snowflake.connector.compat import IS_LINUX, IS_MACOS, IS_WINDOWS
2019
except ImportError:
2120
import platform
2221

2322
IS_MACOS = platform.system() == "Darwin"
23+
IS_LINUX = platform.system() == "Linux"
24+
IS_WINDOWS = platform.system() == "Windows"
2425

2526
try:
2627
import keyring # noqa
@@ -180,7 +181,7 @@ async def test_body(conn_cfg):
180181
if IS_LINUX:
181182
conn_cfg["client_request_mfa_token"] = True
182183

183-
if IS_MACOS:
184+
if IS_MACOS or IS_WINDOWS:
184185
with patch(
185186
"keyring.delete_password", Mock(side_effect=mock_del_password)
186187
), patch("keyring.set_password", Mock(side_effect=mock_set_password)), patch(

test/unit/aio/test_ocsp.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,7 @@ async def test_ocsp_bad_validity():
232232
del environ["SF_TEST_OCSP_FORCE_BAD_RESPONSE_VALIDITY"]
233233

234234

235+
@pytest.mark.flaky(reruns=3)
235236
async def test_ocsp_single_endpoint():
236237
environ["SF_OCSP_ACTIVATE_NEW_ENDPOINT"] = "True"
237238
SnowflakeOCSP.clear_cache()
@@ -255,6 +256,7 @@ async def test_ocsp_by_post_method():
255256
assert await ocsp.validate(url, connection), f"Failed to validate: {url}"
256257

257258

259+
@pytest.mark.flaky(reruns=3)
258260
async def test_ocsp_with_file_cache(tmpdir):
259261
"""OCSP tests and the cache server and file."""
260262
tmp_dir = str(tmpdir.mkdir("ocsp_response_cache"))
@@ -268,6 +270,7 @@ async def test_ocsp_with_file_cache(tmpdir):
268270
assert await ocsp.validate(url, connection), f"Failed to validate: {url}"
269271

270272

273+
@pytest.mark.flaky(reruns=3)
271274
async def test_ocsp_with_bogus_cache_files(
272275
tmpdir, random_ocsp_response_validation_cache
273276
):
@@ -308,6 +311,7 @@ async def test_ocsp_with_bogus_cache_files(
308311
), f"Failed to validate: {hostname}"
309312

310313

314+
@pytest.mark.flaky(reruns=3)
311315
async def test_ocsp_with_outdated_cache(tmpdir, random_ocsp_response_validation_cache):
312316
with mock.patch(
313317
"snowflake.connector.ocsp_snowflake.OCSP_RESPONSE_VALIDATION_CACHE",
@@ -367,6 +371,7 @@ async def _store_cache_in_file(tmpdir, target_hosts=None):
367371
return filename, target_hosts
368372

369373

374+
@pytest.mark.flaky(reruns=3)
370375
async def test_ocsp_with_invalid_cache_file():
371376
"""OCSP tests with an invalid cache file."""
372377
SnowflakeOCSP.clear_cache() # reset the memory cache
@@ -376,6 +381,7 @@ async def test_ocsp_with_invalid_cache_file():
376381
assert await ocsp.validate(url, connection), f"Failed to validate: {url}"
377382

378383

384+
@pytest.mark.flaky(reruns=3)
379385
@mock.patch(
380386
"snowflake.connector.aio._ocsp_snowflake.SnowflakeOCSP._fetch_ocsp_response",
381387
new_callable=mock.AsyncMock,
@@ -399,6 +405,7 @@ async def test_ocsp_cache_when_server_is_down(
399405
assert not cache_data, "no cache should present because of broken pipe"
400406

401407

408+
@pytest.mark.flaky(reruns=3)
402409
async def test_concurrent_ocsp_requests(tmpdir):
403410
"""Run OCSP revocation checks in parallel. The memory and file caches are deleted randomly."""
404411
cache_file_name = path.join(str(tmpdir), "cache_file.txt")

0 commit comments

Comments
 (0)