Skip to content

Commit fd3d00c

Browse files
committed
improve SST test
1 parent 2c0f64b commit fd3d00c

File tree

1 file changed

+13
-8
lines changed

1 file changed

+13
-8
lines changed

tests/integration/ha_tests/test_self_healing.py

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

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

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

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

229229
async with ops_test.fast_forward():
230-
await are_writes_increasing(ops_test, primary_name)
230+
await are_writes_increasing(ops_test, down_unit=primary_name)
231231

232232
# Verify that the database service got restarted and is ready in the old primary.
233233
assert await is_postgresql_ready(ops_test, primary_name)
@@ -310,7 +310,6 @@ async def test_full_cluster_restart(
310310

311311
@pytest.mark.group(1)
312312
@pytest.mark.abort_on_fail
313-
@pytest.mark.unstable
314313
async def test_forceful_restart_without_data_and_transaction_logs(
315314
ops_test: OpsTest,
316315
continuous_writes,
@@ -349,7 +348,7 @@ async def test_forceful_restart_without_data_and_transaction_logs(
349348
assert new_primary_name is not None
350349
assert new_primary_name != primary_name
351350

352-
await are_writes_increasing(ops_test, primary_name)
351+
await are_writes_increasing(ops_test, down_unit=primary_name)
353352

354353
# Change some settings to enable WAL rotation.
355354
for unit in ops_test.model.applications[app].units:
@@ -373,8 +372,14 @@ async def test_forceful_restart_without_data_and_transaction_logs(
373372
# Check that the WAL was correctly rotated.
374373
for unit_name in files:
375374
assert not files[unit_name].intersection(
376-
new_files
375+
new_files[unit_name]
377376
), "WAL segments weren't correctly rotated"
377+
for file in files[unit_name]:
378+
run_command_on_unit(
379+
ops_test,
380+
unit_name,
381+
f"rm -rf /var/snap/charmed-postgresql/common/var/lib/postgresql/pg_wal/{file}",
382+
)
378383

379384
# Start the systemd service in the old primary.
380385
await run_command_on_unit(ops_test, primary_name, "snap start charmed-postgresql.patroni")
@@ -433,7 +438,7 @@ async def test_network_cut(ops_test: OpsTest, continuous_writes, primary_start_t
433438

434439
async with ops_test.fast_forward():
435440
logger.info("checking whether writes are increasing")
436-
await are_writes_increasing(ops_test, primary_name)
441+
await are_writes_increasing(ops_test, down_unit=primary_name)
437442

438443
logger.info("checking whether a new primary was elected")
439444
# Verify that a new primary gets elected (ie old primary is secondary).
@@ -523,7 +528,7 @@ async def test_network_cut_without_ip_change(
523528

524529
async with ops_test.fast_forward():
525530
logger.info("checking whether writes are increasing")
526-
await are_writes_increasing(ops_test, primary_name, use_ip_from_inside=True)
531+
await are_writes_increasing(ops_test, down_unit=primary_name, use_ip_from_inside=True)
527532

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

0 commit comments

Comments
 (0)