Transaction Configuration Tests¶
These tests cover WAL flush modes and their database-wide scope, read-your-writes, auto-transaction control, and combinations of these settings (plus error handling on a closed database).
Key Config Options¶
- WAL flush:
set_wal_flush("no" | "yes_nometadata" | "yes_full") - Read-your-writes:
set_read_your_writes(bool) - Auto-transaction:
set_auto_transaction(bool)
test_set_wal_flush_modes¶
Calls set_wal_flush() with each valid mode. The test has no assertion: it passes when none of the calls raises, and it does not read the mode back.
What it calls:
set_wal_flush("no")(default / maximum performance)set_wal_flush("yes_nometadata")set_wal_flush("yes_full")(maximum durability)- Resetting back to
"no"
Pattern:
temp_db.set_wal_flush("no")
temp_db.set_wal_flush("yes_nometadata")
temp_db.set_wal_flush("yes_full")
temp_db.set_wal_flush("no")
test_set_wal_flush_is_database_wide¶
Pins that set_wal_flush() reaches the transactions of every thread on the database: a thread that never called it
commits with the mode another thread set. If the scope ever narrows to the calling thread, the test fails and the
durability section of the transactions guide must change with it. The process default is read from a fresh thread
first rather than assumed to be NO, because a production-mode server anywhere in the process raises it to 1 for
every database opened afterwards (test_server.py starts one, and CI runs it first).
Pattern:
default = flush_of_a_new_thread() # the process default, NO unless something raised it
temp_db.set_wal_flush("yes_full") # or "no" when the default is already YES_FULL
# this thread's transactions and a new thread's both carry YES_FULL
test_set_wal_flush_invalid_mode¶
Tests that invalid WAL flush modes raise ValueError.
What it tests:
- An unknown mode (
"invalid_mode") raisesValueErrormatching "Invalid WAL flush mode" - An uppercase mode (
"YES_FULL") is rejected; the mode must be lowercase
Pattern:
with pytest.raises(ValueError, match="Invalid WAL flush mode"):
temp_db.set_wal_flush("invalid_mode")
with pytest.raises(ValueError, match="Invalid WAL flush mode"):
temp_db.set_wal_flush("YES_FULL") # Must be lowercase
test_set_read_your_writes¶
Toggles read-your-writes. The test has no assertion: it passes when none of the calls raises, and it does not read the setting back.
What it calls:
- Enabling read-your-writes (
True, the default) - Disabling it (
False, for better concurrency) - Re-enabling it
Pattern:
temp_db.set_read_your_writes(True)
temp_db.set_read_your_writes(False)
temp_db.set_read_your_writes(True)
test_set_auto_transaction¶
Toggles auto-transaction. The test has no assertion: it passes when none of the calls raises, and it does not read the setting back.
What it calls:
- Enabling auto-transaction (
True, the default) - Disabling it (
False, for manual control) - Re-enabling it
Pattern:
temp_db.set_auto_transaction(True)
temp_db.set_auto_transaction(False)
temp_db.set_auto_transaction(True)
test_transaction_config_with_operations¶
Tests config methods alongside normal operations.
What it tests:
- Configuring durability (
set_wal_flush("yes_full"),set_read_your_writes(True)) then writing inside a transaction - Switching to performance mode (
set_wal_flush("no"),set_read_your_writes(False)) and writing more - Verifying counts via
SELECT count(*)queries (2, then 3)
Pattern:
temp_db.command("sql", "CREATE VERTEX TYPE ConfigTest")
temp_db.set_wal_flush("yes_full")
temp_db.set_read_your_writes(True)
with temp_db.transaction():
temp_db.command("sql", "CREATE VERTEX ConfigTest SET name = 'test1'")
temp_db.command("sql", "CREATE VERTEX ConfigTest SET name = 'test2'")
count = next(temp_db.query("sql", "SELECT count(*) as cnt FROM ConfigTest")).get("cnt")
assert count == 2
test_manual_transaction_mode¶
Tests manual transaction control with auto-transaction disabled.
What it tests:
- With
set_auto_transaction(False), writes inside an explicitdb.transaction()context are visible to a later query (count == 2); the test does not try a write outside a transaction - Auto-transaction is re-enabled in a
finallyblock
Pattern:
temp_db.command("sql", "CREATE VERTEX TYPE ManualTest")
temp_db.set_auto_transaction(False)
try:
with temp_db.transaction():
temp_db.command("sql", "CREATE VERTEX ManualTest SET name = 'manual1'")
temp_db.command("sql", "CREATE VERTEX ManualTest SET name = 'manual2'")
finally:
temp_db.set_auto_transaction(True)
test_wal_flush_with_bulk_operations¶
Tests WAL flush modes with chunked bulk inserts.
What it tests:
- Bulk inserting with
set_wal_flush("yes_full")in 200-record chunks up to 500 - Switching to
set_wal_flush("no")and continuing up to 1000 - Verifying counts (500, then 1000)
Pattern:
temp_db.command("sql", "CREATE VERTEX TYPE BatchTest")
temp_db.set_wal_flush("yes_full")
chunk_size = 200
total = 500
for start in range(0, total, chunk_size):
with temp_db.transaction():
for i in range(start, min(start + chunk_size, total)):
temp_db.command(
"sql", "CREATE VERTEX BatchTest SET value = :value", {"value": i}
)
test_config_methods_on_closed_database¶
Tests that config methods raise on a closed database.
What it tests:
set_wal_flush(...),set_read_your_writes(...), andset_auto_transaction(...)each raiseArcadeDBErrormatching "closed" afterdb.close()
Pattern:
db = create_database(temp_db_path)
db.close()
with pytest.raises(ArcadeDBError, match="closed"):
db.set_wal_flush("no")
test_combined_config_changes¶
Tests changing multiple config settings together.
What it tests:
- Starting with durability settings (
yes_full, read-your-writes on, auto-transaction on) - Switching to performance settings (
no, read-your-writes off) and writing more - Verifying the final count (2) and restoring durability settings
Pattern:
temp_db.set_wal_flush("yes_full")
temp_db.set_read_your_writes(True)
temp_db.set_auto_transaction(True)
temp_db.command("sql", "CREATE VERTEX TYPE Combined")
with temp_db.transaction():
temp_db.command("sql", "CREATE VERTEX Combined SET value = 1")
temp_db.set_wal_flush("no")
temp_db.set_read_your_writes(False)
with temp_db.transaction():
temp_db.command("sql", "CREATE VERTEX Combined SET value = 2")
Common Assertions¶
# Invalid WAL mode rejected
with pytest.raises(ValueError, match="Invalid WAL flush mode"):
db.set_wal_flush("invalid_mode")
# Config methods raise on a closed database
with pytest.raises(ArcadeDBError, match="closed"):
db.set_wal_flush("no")
# Records written under any flush mode are visible to a later query
count = next(db.query("sql", "SELECT count(*) as cnt FROM ConfigTest")).get("cnt")
assert count == 2
Configuration Methods¶
| Method | Argument | Notes |
|---|---|---|
set_wal_flush(mode) |
"no", "yes_nometadata", "yes_full" |
Lowercase only; invalid modes raise ValueError |
set_read_your_writes(flag) |
bool |
Default True |
set_auto_transaction(flag) |
bool |
Default True; when False, use explicit db.transaction() |
Key Takeaways¶
- WAL flush modes -
"yes_full"for durability,"no"for performance - Lowercase modes only - Uppercase or unknown modes raise
ValueError - Read-your-writes - Toggle for concurrency vs immediate visibility
- Manual transactions - Disable auto-transaction and use
db.transaction()contexts - Closed database - Config methods raise
ArcadeDBErroronce closed
See Also¶
- Transactions API - Full API reference
- Concurrency Tests - Concurrent access patterns
- Database API - Database operations
- Testing Overview - Testing strategies