|
35 | 35 | from tests.integration import use_singledc, PROTOCOL_VERSION, get_server_versions, CASSANDRA_VERSION, execute_until_pass, execute_with_long_wait_retry, get_node,\ |
36 | 36 | MockLoggingHandler, get_unsupported_lower_protocol, get_unsupported_upper_protocol, protocolv5 |
37 | 37 | from tests.integration.util import assert_quiescent_pool_state |
| 38 | +import sys |
38 | 39 |
|
39 | 40 |
|
40 | 41 | def setup_module(): |
@@ -74,6 +75,7 @@ def test_ignored_host_up(self): |
74 | 75 | self.assertTrue(host.is_up) |
75 | 76 | else: |
76 | 77 | self.assertIsNone(host.is_up) |
| 78 | + cluster.shutdown() |
77 | 79 |
|
78 | 80 | def test_host_resolution(self): |
79 | 81 | """ |
@@ -129,6 +131,7 @@ def test_raise_error_on_control_connection_timeout(self): |
129 | 131 |
|
130 | 132 | with self.assertRaisesRegexp(NoHostAvailable, "OperationTimedOut\('errors=Timed out creating connection \(1 seconds\)"): |
131 | 133 | cluster.connect() |
| 134 | + cluster.shutdown() |
132 | 135 |
|
133 | 136 | get_node(1).resume() |
134 | 137 |
|
@@ -431,7 +434,7 @@ def test_refresh_schema_type(self): |
431 | 434 | self.assertEqual(original_test1rf_meta.export_as_string(), current_test1rf_meta.export_as_string()) |
432 | 435 | self.assertIsNot(original_type_meta, current_type_meta) |
433 | 436 | self.assertEqual(original_type_meta.as_cql_query(), current_type_meta.as_cql_query()) |
434 | | - session.shutdown() |
| 437 | + cluster.shutdown() |
435 | 438 |
|
436 | 439 | def test_refresh_schema_no_wait(self): |
437 | 440 |
|
@@ -879,7 +882,17 @@ def test_add_profile_timeout(self): |
879 | 882 | self.assertEqual(set(h.address for h in pools), set(('127.0.0.1',))) |
880 | 883 |
|
881 | 884 | node2 = ExecutionProfile(load_balancing_policy=WhiteListRoundRobinPolicy(['127.0.0.2'])) |
882 | | - self.assertRaises(cassandra.OperationTimedOut, cluster.add_execution_profile, 'node2', node2, pool_wait_timeout=0.000000001) |
| 885 | + |
| 886 | + max_retry_count = 10 |
| 887 | + for i in range(max_retry_count): |
| 888 | + start = time.time() |
| 889 | + try: |
| 890 | + self.assertRaises(cassandra.OperationTimedOut, cluster.add_execution_profile, 'node2', |
| 891 | + node2, pool_wait_timeout=sys.float_info.min) |
| 892 | + except Exception: |
| 893 | + end = time.time() |
| 894 | + self.assertAlmostEqual(start, end, 1) |
| 895 | + break |
883 | 896 |
|
884 | 897 |
|
885 | 898 | class LocalHostAdressTranslator(AddressTranslator): |
@@ -933,6 +946,7 @@ def test_address_translator_with_mixed_nodes(self): |
933 | 946 | c.connect() |
934 | 947 | for host in c.metadata.all_hosts(): |
935 | 948 | self.assertEqual(adder_map.get(str(host)), host.broadcast_address) |
| 949 | + c.shutdown() |
936 | 950 |
|
937 | 951 |
|
938 | 952 | class ContextManagementTest(unittest.TestCase): |
@@ -1090,6 +1104,7 @@ def test_prepare_on_ignored_hosts(self): |
1090 | 1104 | # address |
1091 | 1105 | for c in cluster.connection_factory.mock_calls: |
1092 | 1106 | self.assertEqual(call(unignored_address), c) |
| 1107 | + cluster.shutdown() |
1093 | 1108 |
|
1094 | 1109 |
|
1095 | 1110 | class DuplicateRpcTest(unittest.TestCase): |
@@ -1120,12 +1135,14 @@ def test_duplicate(self): |
1120 | 1135 | mock_handler = MockLoggingHandler() |
1121 | 1136 | logger = logging.getLogger(cassandra.cluster.__name__) |
1122 | 1137 | logger.addHandler(mock_handler) |
1123 | | - test_cluster = self.cluster = Cluster(protocol_version=PROTOCOL_VERSION, load_balancing_policy=self.load_balancing_policy) |
| 1138 | + test_cluster = Cluster(protocol_version=PROTOCOL_VERSION, load_balancing_policy=self.load_balancing_policy) |
1124 | 1139 | test_cluster.connect() |
1125 | 1140 | warnings = mock_handler.messages.get("warning") |
1126 | 1141 | self.assertEqual(len(warnings), 1) |
1127 | 1142 | self.assertTrue('multiple' in warnings[0]) |
1128 | 1143 | logger.removeHandler(mock_handler) |
| 1144 | + test_cluster.shutdown() |
| 1145 | + |
1129 | 1146 |
|
1130 | 1147 |
|
1131 | 1148 | @protocolv5 |
@@ -1166,3 +1183,4 @@ def test_valid_protocol_version_beta_options_connect(self): |
1166 | 1183 | session = cluster.connect() |
1167 | 1184 | self.assertEqual(cluster.protocol_version, cassandra.ProtocolVersion.MAX_SUPPORTED) |
1168 | 1185 | self.assertTrue(session.execute("select release_version from system.local")[0]) |
| 1186 | + cluster.shutdown() |
0 commit comments