Skip to content

Commit 2ec474a

Browse files
committed
test/topology_experimental_raft: Prevent keyspace creation conflicts with IF NOT EXISTS
Background: - Python driver exhibits unexpected behavior causing duplicate keyspace creation attempts (scylladb/python-driver#317) - Existing test cases can fail with cassandra.AlreadyExists exception: ``` cassandra.AlreadyExists: Keyspace 'test_1732631552019_lxagp' already exists ``` Resolution: - Added `IF NOT EXISTS` clause to keyspace and table creation statements - Mitigates potential race conditions during test setup - Aligns with previous mitigation approach in commit 8876b9b Specific Changes: - Ensures safe keyspace creation in concurrent test scenarios - Prevents test failures due to duplicate keyspace generation Fixes scylladb#21701 Signed-off-by: Kefu Chai <[email protected]>
1 parent c752383 commit 2ec474a

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

test/topology_experimental_raft/test_tablets.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -1546,8 +1546,8 @@ async def create_and_populate_table(manager: ManagerClient, rf: int = 3, initial
15461546

15471547
cql = manager.get_cql()
15481548
try:
1549-
await cql.run_async(f"CREATE KEYSPACE {ks} WITH replication = {{'class': 'NetworkTopologyStrategy', 'replication_factor': {rf}}} AND tablets = {{'initial': {initial_tablets}}}")
1550-
await cql.run_async(f"CREATE TABLE {ks}.{table} (pk int PRIMARY KEY, c int)")
1549+
await cql.run_async(f"CREATE KEYSPACE IF NOT EXISTS {ks} WITH replication = {{'class': 'NetworkTopologyStrategy', 'replication_factor': {rf}}} AND tablets = {{'initial': {initial_tablets}}}")
1550+
await cql.run_async(f"CREATE TABLE IF NOT EXISTS {ks}.{table} (pk int PRIMARY KEY, c int)")
15511551
await asyncio.gather(*[cql.run_async(f"INSERT INTO {ks}.{table} (pk, c) VALUES ({k}, 1);") for k in range(num_keys)])
15521552
yield TestContext(ks, table, rf, initial_tablets, num_keys)
15531553
finally:

0 commit comments

Comments
 (0)