mirror of
https://github.com/aljazceru/turso.git
synced 2025-12-18 17:14:20 +01:00
antithesis: Add DROP TABLE parallel driver
This commit is contained in:
44
antithesis-tests/stress-composer/parallel_driver_drop_table.py
Executable file
44
antithesis-tests/stress-composer/parallel_driver_drop_table.py
Executable file
@@ -0,0 +1,44 @@
|
||||
#!/usr/bin/env -S python3 -u
|
||||
|
||||
|
||||
import turso
|
||||
from antithesis.random import get_random
|
||||
|
||||
# Get initial state
|
||||
try:
|
||||
con_init = turso.connect("init_state.db")
|
||||
except Exception as e:
|
||||
print(f"Error connecting to database: {e}")
|
||||
exit(0)
|
||||
|
||||
cur_init = con_init.cursor()
|
||||
|
||||
# Get all existing tables from schemas
|
||||
existing_schemas = cur_init.execute("SELECT tbl FROM schemas").fetchall()
|
||||
if not existing_schemas:
|
||||
print("No tables found in schemas")
|
||||
exit(0)
|
||||
|
||||
# Select a random table
|
||||
selected_idx = get_random() % len(existing_schemas)
|
||||
selected_tbl = existing_schemas[selected_idx][0]
|
||||
|
||||
try:
|
||||
con = turso.connect("stress_composer.db", experimental_indexes=True)
|
||||
except Exception as e:
|
||||
print(f"Failed to open stress_composer.db. Exiting... {e}")
|
||||
exit(0)
|
||||
|
||||
cur = con.cursor()
|
||||
|
||||
cur.execute(f"DROP TABLE tbl_{selected_tbl}")
|
||||
|
||||
con.commit()
|
||||
|
||||
con.close()
|
||||
|
||||
cur_init.execute("DELETE FROM schemas WHERE tbl = ?", (selected_tbl,))
|
||||
|
||||
con_init.commit()
|
||||
|
||||
con_init.close()
|
||||
Reference in New Issue
Block a user