Skip to content

Commit 27a4a9a

Browse files
NO-SNOW mark OCSP unit tests flaky (#2276)
1 parent 8c744de commit 27a4a9a

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

test/integ/sso/test_unit_mfa_cache.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,16 @@
88
import pytest
99

1010
import snowflake.connector
11-
from snowflake.connector.compat import IS_LINUX
1211
from snowflake.connector.errors import DatabaseError
1312

1413
try:
15-
from snowflake.connector.compat import IS_MACOS
14+
from snowflake.connector.compat import IS_LINUX, IS_MACOS, IS_WINDOWS
1615
except ImportError:
1716
import platform
1817

1918
IS_MACOS = platform.system() == "Darwin"
19+
IS_LINUX = platform.system() == "Linux"
20+
IS_WINDOWS = platform.system() == "Windows"
2021

2122

2223
# Although this is an unit test, we put it under test/integ/sso, since it needs keyring package installed
@@ -162,7 +163,7 @@ def test_body(conn_cfg):
162163
if IS_LINUX:
163164
conn_cfg["client_request_mfa_token"] = True
164165

165-
if IS_MACOS:
166+
if IS_MACOS or IS_WINDOWS:
166167
with patch(
167168
"keyring.delete_password", Mock(side_effect=mock_del_password)
168169
), patch("keyring.set_password", Mock(side_effect=mock_set_password)), patch(

test/unit/test_ocsp.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -257,6 +257,7 @@ def test_ocsp_bad_validity():
257257
del environ["SF_TEST_OCSP_FORCE_BAD_RESPONSE_VALIDITY"]
258258

259259

260+
@pytest.mark.flaky(reruns=3)
260261
def test_ocsp_single_endpoint():
261262
environ["SF_OCSP_ACTIVATE_NEW_ENDPOINT"] = "True"
262263
SnowflakeOCSP.clear_cache()
@@ -280,6 +281,7 @@ def test_ocsp_by_post_method():
280281
assert ocsp.validate(url, connection), f"Failed to validate: {url}"
281282

282283

284+
@pytest.mark.flaky(reruns=3)
283285
def test_ocsp_with_file_cache(tmpdir):
284286
"""OCSP tests and the cache server and file."""
285287
tmp_dir = str(tmpdir.mkdir("ocsp_response_cache"))
@@ -293,6 +295,7 @@ def test_ocsp_with_file_cache(tmpdir):
293295
assert ocsp.validate(url, connection), f"Failed to validate: {url}"
294296

295297

298+
@pytest.mark.flaky(reruns=3)
296299
@pytest.mark.skipolddriver
297300
def test_ocsp_with_bogus_cache_files(tmpdir, random_ocsp_response_validation_cache):
298301
with mock.patch(
@@ -332,6 +335,7 @@ def test_ocsp_with_bogus_cache_files(tmpdir, random_ocsp_response_validation_cac
332335
)
333336

334337

338+
@pytest.mark.flaky(reruns=3)
335339
@pytest.mark.skipolddriver
336340
def test_ocsp_with_outdated_cache(tmpdir, random_ocsp_response_validation_cache):
337341
with mock.patch(
@@ -392,6 +396,7 @@ def _store_cache_in_file(tmpdir, target_hosts=None):
392396
return filename, target_hosts
393397

394398

399+
@pytest.mark.flaky(reruns=3)
395400
def test_ocsp_with_invalid_cache_file():
396401
"""OCSP tests with an invalid cache file."""
397402
SnowflakeOCSP.clear_cache() # reset the memory cache
@@ -401,6 +406,7 @@ def test_ocsp_with_invalid_cache_file():
401406
assert ocsp.validate(url, connection), f"Failed to validate: {url}"
402407

403408

409+
@pytest.mark.flaky(reruns=3)
404410
@mock.patch(
405411
"snowflake.connector.ocsp_snowflake.SnowflakeOCSP._fetch_ocsp_response",
406412
side_effect=BrokenPipeError("fake error"),
@@ -423,6 +429,7 @@ def test_ocsp_cache_when_server_is_down(
423429
assert not cache_data, "no cache should present because of broken pipe"
424430

425431

432+
@pytest.mark.flaky(reruns=3)
426433
def test_concurrent_ocsp_requests(tmpdir):
427434
"""Run OCSP revocation checks in parallel. The memory and file caches are deleted randomly."""
428435
cache_file_name = path.join(str(tmpdir), "cache_file.txt")
@@ -467,6 +474,7 @@ def test_ocsp_revoked_certificate():
467474
assert ex.value.errno == ex.value.errno == ER_OCSP_RESPONSE_CERT_STATUS_REVOKED
468475

469476

477+
@pytest.mark.flaky(reruns=3)
470478
def test_ocsp_incomplete_chain():
471479
"""Tests incomplete chained certificate."""
472480
incomplete_chain_cert = path.join(

0 commit comments

Comments
 (0)