From fd3d00ca1766236184ce9526a090651117416612 Mon Sep 17 00:00:00 2001 From: Mykola Marzhan Date: Wed, 28 Feb 2024 17:41:59 +0100 Subject: [PATCH] improve SST test --- .../integration/ha_tests/test_self_healing.py | 21 ++++++++++++------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/tests/integration/ha_tests/test_self_healing.py b/tests/integration/ha_tests/test_self_healing.py index f23094169b..9fe85521ac 100644 --- a/tests/integration/ha_tests/test_self_healing.py +++ b/tests/integration/ha_tests/test_self_healing.py @@ -159,7 +159,7 @@ async def test_kill_db_process( await send_signal_to_process(ops_test, primary_name, process, "SIGKILL") async with ops_test.fast_forward(): - await are_writes_increasing(ops_test, primary_name) + await are_writes_increasing(ops_test, down_unit=primary_name) # Verify that the database service got restarted and is ready in the old primary. assert await is_postgresql_ready(ops_test, primary_name) @@ -193,7 +193,7 @@ async def test_freeze_db_process( # considered to trigger a fail-over after primary_start_timeout is changed, and also # when freezing the DB process it take some more time to trigger the fail-over). try: - await are_writes_increasing(ops_test, primary_name) + await are_writes_increasing(ops_test, down_unit=primary_name) # Verify that a new primary gets elected (ie old primary is secondary). for attempt in Retrying(stop=stop_after_delay(60 * 3), wait=wait_fixed(3)): @@ -227,7 +227,7 @@ async def test_restart_db_process( await send_signal_to_process(ops_test, primary_name, process, "SIGTERM") async with ops_test.fast_forward(): - await are_writes_increasing(ops_test, primary_name) + await are_writes_increasing(ops_test, down_unit=primary_name) # Verify that the database service got restarted and is ready in the old primary. assert await is_postgresql_ready(ops_test, primary_name) @@ -310,7 +310,6 @@ async def test_full_cluster_restart( @pytest.mark.group(1) @pytest.mark.abort_on_fail -@pytest.mark.unstable async def test_forceful_restart_without_data_and_transaction_logs( ops_test: OpsTest, continuous_writes, @@ -349,7 +348,7 @@ async def test_forceful_restart_without_data_and_transaction_logs( assert new_primary_name is not None assert new_primary_name != primary_name - await are_writes_increasing(ops_test, primary_name) + await are_writes_increasing(ops_test, down_unit=primary_name) # Change some settings to enable WAL rotation. for unit in ops_test.model.applications[app].units: @@ -373,8 +372,14 @@ async def test_forceful_restart_without_data_and_transaction_logs( # Check that the WAL was correctly rotated. for unit_name in files: assert not files[unit_name].intersection( - new_files + new_files[unit_name] ), "WAL segments weren't correctly rotated" + for file in files[unit_name]: + run_command_on_unit( + ops_test, + unit_name, + f"rm -rf /var/snap/charmed-postgresql/common/var/lib/postgresql/pg_wal/{file}", + ) # Start the systemd service in the old primary. 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 async with ops_test.fast_forward(): logger.info("checking whether writes are increasing") - await are_writes_increasing(ops_test, primary_name) + await are_writes_increasing(ops_test, down_unit=primary_name) logger.info("checking whether a new primary was elected") # Verify that a new primary gets elected (ie old primary is secondary). @@ -523,7 +528,7 @@ async def test_network_cut_without_ip_change( async with ops_test.fast_forward(): logger.info("checking whether writes are increasing") - await are_writes_increasing(ops_test, primary_name, use_ip_from_inside=True) + await are_writes_increasing(ops_test, down_unit=primary_name, use_ip_from_inside=True) logger.info("checking whether a new primary was elected") # Verify that a new primary gets elected (ie old primary is secondary).