|
38 | 38 | from tests import notwindows |
39 | 39 | from tests.integration import use_singledc, PROTOCOL_VERSION, get_server_versions, CASSANDRA_VERSION, \ |
40 | 40 | execute_until_pass, execute_with_long_wait_retry, get_node, MockLoggingHandler, get_unsupported_lower_protocol, \ |
41 | | - get_unsupported_upper_protocol, protocolv5, local, CASSANDRA_IP |
| 41 | + get_unsupported_upper_protocol, protocolv5, local, CASSANDRA_IP, greaterthanorequalcass30, lessthanorequalcass40 |
42 | 42 | from tests.integration.util import assert_quiescent_pool_state |
43 | 43 | import sys |
44 | 44 |
|
@@ -1062,6 +1062,63 @@ def test_replicas_are_queried(self): |
1062 | 1062 |
|
1063 | 1063 | session.execute('''DROP TABLE test1rf.table_with_big_key''') |
1064 | 1064 |
|
| 1065 | + @unittest.skip |
| 1066 | + @greaterthanorequalcass30 |
| 1067 | + @lessthanorequalcass40 |
| 1068 | + def test_compact_option(self): |
| 1069 | + """ |
| 1070 | + Test the driver can connect with the no_compact option and the results |
| 1071 | + are as expected. This test is very similar to the corresponding dtest |
| 1072 | +
|
| 1073 | + @since 3.12 |
| 1074 | + @jira_ticket PYTHON-366 |
| 1075 | + @expected_result only one hosts' metadata will be populated |
| 1076 | +
|
| 1077 | + @test_category connection |
| 1078 | + """ |
| 1079 | + nc_cluster = Cluster(protocol_version=PROTOCOL_VERSION, no_compact=True) |
| 1080 | + nc_session = nc_cluster.connect() |
| 1081 | + |
| 1082 | + cluster = Cluster(protocol_version=PROTOCOL_VERSION, no_compact=False) |
| 1083 | + session = cluster.connect() |
| 1084 | + |
| 1085 | + self.addCleanup(cluster.shutdown) |
| 1086 | + self.addCleanup(nc_cluster.shutdown) |
| 1087 | + |
| 1088 | + nc_session.set_keyspace("test3rf") |
| 1089 | + session.set_keyspace("test3rf") |
| 1090 | + |
| 1091 | + nc_session.execute( |
| 1092 | + "CREATE TABLE IF NOT EXISTS compact_table (k int PRIMARY KEY, v1 int, v2 int) WITH COMPACT STORAGE;") |
| 1093 | + |
| 1094 | + for i in range(1, 5): |
| 1095 | + nc_session.execute( |
| 1096 | + "INSERT INTO compact_table (k, column1, v1, v2, value) VALUES " |
| 1097 | + "({i}, 'a{i}', {i}, {i}, textAsBlob('b{i}'))".format(i=i)) |
| 1098 | + nc_session.execute( |
| 1099 | + "INSERT INTO compact_table (k, column1, v1, v2, value) VALUES " |
| 1100 | + "({i}, 'a{i}{i}', {i}{i}, {i}{i}, textAsBlob('b{i}{i}'))".format(i=i)) |
| 1101 | + |
| 1102 | + nc_results = nc_session.execute("SELECT * FROM compact_table") |
| 1103 | + self.assertEqual( |
| 1104 | + set(nc_results.current_rows), |
| 1105 | + {(1, u'a1', 11, 11, 'b1'), |
| 1106 | + (1, u'a11', 11, 11, 'b11'), |
| 1107 | + (2, u'a2', 22, 22, 'b2'), |
| 1108 | + (2, u'a22', 22, 22, 'b22'), |
| 1109 | + (3, u'a3', 33, 33, 'b3'), |
| 1110 | + (3, u'a33', 33, 33, 'b33'), |
| 1111 | + (4, u'a4', 44, 44, 'b4'), |
| 1112 | + (4, u'a44', 44, 44, 'b44')}) |
| 1113 | + |
| 1114 | + results = session.execute("SELECT * FROM compact_table") |
| 1115 | + self.assertEqual( |
| 1116 | + set(results.current_rows), |
| 1117 | + {(1, 11, 11), |
| 1118 | + (2, 22, 22), |
| 1119 | + (3, 33, 33), |
| 1120 | + (4, 44, 44)}) |
| 1121 | + |
1065 | 1122 | def _assert_replica_queried(self, trace, only_replicas=True): |
1066 | 1123 | queried_hosts = set() |
1067 | 1124 | for row in trace.events: |
@@ -1255,6 +1312,7 @@ def test_down_event_with_active_connection(self): |
1255 | 1312 | time.sleep(.01) |
1256 | 1313 | self.assertTrue(was_marked_down) |
1257 | 1314 |
|
| 1315 | + |
1258 | 1316 | @local |
1259 | 1317 | class DontPrepareOnIgnoredHostsTest(unittest.TestCase): |
1260 | 1318 | ignored_addresses = ['127.0.0.3'] |
@@ -1292,6 +1350,7 @@ def test_prepare_on_ignored_hosts(self): |
1292 | 1350 | self.assertEqual(call(unignored_address), c) |
1293 | 1351 | cluster.shutdown() |
1294 | 1352 |
|
| 1353 | + |
1295 | 1354 | @local |
1296 | 1355 | class DuplicateRpcTest(unittest.TestCase): |
1297 | 1356 |
|
@@ -1331,7 +1390,6 @@ def test_duplicate(self): |
1331 | 1390 | test_cluster.shutdown() |
1332 | 1391 |
|
1333 | 1392 |
|
1334 | | - |
1335 | 1393 | @protocolv5 |
1336 | 1394 | class BetaProtocolTest(unittest.TestCase): |
1337 | 1395 |
|
|
0 commit comments