|
| 1 | +""" |
| 2 | +Unit tests for ClientContext / build_client_context retry-policy defaults. |
| 3 | +
|
| 4 | +Regression tests for issue #709: CloudFetch downloads go through |
| 5 | +UnifiedHttpClient, which builds its DatabricksRetryPolicy from ClientContext. |
| 6 | +When the user does not override the retry settings, those defaults must match |
| 7 | +the connector-wide defaults used by the Thrift and SEA backends (30 attempts / |
| 8 | +900.0s), which are anchored to the ODBC/JDBC drivers (see |
| 9 | +thrift_backend.py: "900s attempts-duration lines up w ODBC/JDBC drivers"). |
| 10 | +Previously ClientContext fell back to 5 attempts / 300.0s, cutting cloudfetch |
| 11 | +retries off far earlier than the rest of the connector. |
| 12 | +""" |
| 13 | + |
| 14 | +from databricks.sql.auth.common import ClientContext |
| 15 | +from databricks.sql.utils import build_client_context |
| 16 | + |
| 17 | + |
| 18 | +class TestClientContextRetryDefaults: |
| 19 | + def test_default_max_retry_duration_is_900(self): |
| 20 | + """With no override, retry duration defaults to 900.0s (not 300.0).""" |
| 21 | + context = build_client_context("test.databricks.com", "test-version") |
| 22 | + assert context.retry_stop_after_attempts_duration == 900.0 |
| 23 | + |
| 24 | + def test_default_max_retry_count_is_30(self): |
| 25 | + """With no override, retry attempt count defaults to 30 (not 5).""" |
| 26 | + context = build_client_context("test.databricks.com", "test-version") |
| 27 | + assert context.retry_stop_after_attempts_count == 30 |
| 28 | + |
| 29 | + def test_user_override_still_honored(self): |
| 30 | + """Explicit user overrides are propagated unchanged.""" |
| 31 | + context = build_client_context( |
| 32 | + "test.databricks.com", |
| 33 | + "test-version", |
| 34 | + _retry_stop_after_attempts_duration=120.0, |
| 35 | + _retry_stop_after_attempts_count=7, |
| 36 | + ) |
| 37 | + assert context.retry_stop_after_attempts_duration == 120.0 |
| 38 | + assert context.retry_stop_after_attempts_count == 7 |
0 commit comments