forked from databricks/databricks-sql-python
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathretry_test_mixins.py
More file actions
38 lines (33 loc) · 1.77 KB
/
retry_test_mixins.py
File metadata and controls
38 lines (33 loc) · 1.77 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
class Client429ResponseMixin:
def test_client_should_retry_automatically_when_getting_429(self):
with self.cursor() as cursor:
for _ in range(10):
cursor.execute("SELECT 1")
rows = cursor.fetchall()
self.assertEqual(len(rows), 1)
self.assertEqual(rows[0][0], 1)
def test_client_should_not_retry_429_if_RateLimitRetry_is_0(self):
with self.assertRaises(self.error_type) as cm:
with self.cursor(self.conf_to_disable_rate_limit_retries) as cursor:
for _ in range(10):
cursor.execute("SELECT 1")
rows = cursor.fetchall()
self.assertEqual(len(rows), 1)
self.assertEqual(rows[0][0], 1)
expected = "Maximum rate of 1 requests per SECOND has been exceeded. " \
"Please reduce the rate of requests and try again after 1 seconds."
exception_str = str(cm.exception)
# FIXME (Ali Smesseim, 7-Jul-2020): ODBC driver does not always return the
# X-Thriftserver-Error-Message as-is. Re-enable once Simba resolves this flakiness.
# Simba support ticket: https://magnitudesoftware.force.com/support/5001S000018RlaD
# self.assertIn(expected, exception_str)
class Client503ResponseMixin:
def test_wait_cluster_startup(self):
with self.cursor() as cursor:
cursor.execute("SELECT 1")
cursor.fetchall()
def _test_retry_disabled_with_message(self, error_msg_substring, exception_type):
with self.assertRaises(exception_type) as cm:
with self.connection(self.conf_to_disable_temporarily_unavailable_retries):
pass
self.assertIn(error_msg_substring, str(cm.exception))