Skip to content

Commit c37d433

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

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
@@ -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)
@@ -306,7 +306,6 @@ async def test_full_cluster_restart(
306306

307307

308308
@pytest.mark.group(1)
309-
@pytest.mark.unstable
310309
async def test_forceful_restart_without_data_and_transaction_logs(
311310
ops_test: OpsTest,
312311
continuous_writes,
@@ -345,7 +344,7 @@ async def test_forceful_restart_without_data_and_transaction_logs(
345344
assert new_primary_name is not None
346345
assert new_primary_name != primary_name
347346

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

350349
# Change some settings to enable WAL rotation.
351350
for unit in ops_test.model.applications[app].units:
@@ -369,8 +368,14 @@ async def test_forceful_restart_without_data_and_transaction_logs(
369368
# Check that the WAL was correctly rotated.
370369
for unit_name in files:
371370
assert not files[unit_name].intersection(
372-
new_files
371+
new_files[unit_name]
373372
), "WAL segments weren't correctly rotated"
373+
for file in files[unit_name]:
374+
run_command_on_unit(
375+
ops_test,
376+
unit_name,
377+
f"rm -rf /var/snap/charmed-postgresql/common/var/lib/postgresql/pg_wal/{file}",
378+
)
374379

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

429434
async with ops_test.fast_forward():
430435
logger.info("checking whether writes are increasing")
431-
await are_writes_increasing(ops_test, primary_name)
436+
await are_writes_increasing(ops_test, down_unit=primary_name)
432437

433438
logger.info("checking whether a new primary was elected")
434439
# Verify that a new primary gets elected (ie old primary is secondary).
@@ -517,7 +522,7 @@ async def test_network_cut_without_ip_change(
517522

518523
async with ops_test.fast_forward():
519524
logger.info("checking whether writes are increasing")
520-
await are_writes_increasing(ops_test, primary_name, use_ip_from_inside=True)
525+
await are_writes_increasing(ops_test, down_unit=primary_name, use_ip_from_inside=True)
521526

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

0 commit comments

Comments
 (0)