Skip to content

Commit cb03dd8

Browse files
committed
improve SST test
1 parent 15b921c commit cb03dd8

File tree

1 file changed

+13
-7
lines changed

1 file changed

+13
-7
lines changed

tests/integration/ha_tests/test_self_healing.py

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ async def test_kill_db_process(
157157
await send_signal_to_process(ops_test, primary_name, process, "SIGKILL")
158158

159159
async with ops_test.fast_forward():
160-
await are_writes_increasing(ops_test, primary_name)
160+
await are_writes_increasing(ops_test, down_unit=primary_name)
161161

162162
# Verify that the database service got restarted and is ready in the old primary.
163163
assert await is_postgresql_ready(ops_test, primary_name)
@@ -190,7 +190,7 @@ async def test_freeze_db_process(
190190
# considered to trigger a fail-over after primary_start_timeout is changed, and also
191191
# when freezing the DB process it take some more time to trigger the fail-over).
192192
try:
193-
await are_writes_increasing(ops_test, primary_name)
193+
await are_writes_increasing(ops_test, down_unit=primary_name)
194194

195195
# Verify that a new primary gets elected (ie old primary is secondary).
196196
for attempt in Retrying(stop=stop_after_delay(60 * 3), wait=wait_fixed(3)):
@@ -223,7 +223,7 @@ async def test_restart_db_process(
223223
await send_signal_to_process(ops_test, primary_name, process, "SIGTERM")
224224

225225
async with ops_test.fast_forward():
226-
await are_writes_increasing(ops_test, primary_name)
226+
await are_writes_increasing(ops_test, down_unit=primary_name)
227227

228228
# Verify that the database service got restarted and is ready in the old primary.
229229
assert await is_postgresql_ready(ops_test, primary_name)
@@ -345,7 +345,7 @@ async def test_forceful_restart_without_data_and_transaction_logs(
345345
assert new_primary_name is not None
346346
assert new_primary_name != primary_name
347347

348-
await are_writes_increasing(ops_test, primary_name)
348+
await are_writes_increasing(ops_test, down_unit=primary_name)
349349

350350
# Change some settings to enable WAL rotation.
351351
for unit in ops_test.model.applications[app].units:
@@ -369,8 +369,14 @@ async def test_forceful_restart_without_data_and_transaction_logs(
369369
# Check that the WAL was correctly rotated.
370370
for unit_name in files:
371371
assert not files[unit_name].intersection(
372-
new_files
372+
new_files[unit_name]
373373
), "WAL segments weren't correctly rotated"
374+
for file in files[unit_name]:
375+
run_command_on_unit(
376+
ops_test,
377+
unit_name,
378+
f"rm -rf /var/snap/charmed-postgresql/common/var/lib/postgresql/pg_wal/{file}",
379+
)
374380

375381
# Start the systemd service in the old primary.
376382
await run_command_on_unit(ops_test, primary_name, "snap start charmed-postgresql.patroni")
@@ -428,7 +434,7 @@ async def test_network_cut(ops_test: OpsTest, continuous_writes, primary_start_t
428434

429435
async with ops_test.fast_forward():
430436
logger.info("checking whether writes are increasing")
431-
await are_writes_increasing(ops_test, primary_name)
437+
await are_writes_increasing(ops_test, down_unit=primary_name)
432438

433439
logger.info("checking whether a new primary was elected")
434440
# Verify that a new primary gets elected (ie old primary is secondary).
@@ -517,7 +523,7 @@ async def test_network_cut_without_ip_change(
517523

518524
async with ops_test.fast_forward():
519525
logger.info("checking whether writes are increasing")
520-
await are_writes_increasing(ops_test, primary_name, use_ip_from_inside=True)
526+
await are_writes_increasing(ops_test, down_unit=primary_name, use_ip_from_inside=True)
521527

522528
logger.info("checking whether a new primary was elected")
523529
# Verify that a new primary gets elected (ie old primary is secondary).

0 commit comments

Comments
 (0)