Skip to content

Commit e377f15

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 fa7b198 commit e377f15

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

test/topology_custom/test_tablets2.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1553,8 +1553,8 @@ async def create_and_populate_table(manager: ManagerClient, rf: int = 3, initial
15531553

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

0 commit comments

Comments
 (0)