Skip to content

[DRAFT] improve SST test #373

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 13 additions & 8 deletions tests/integration/ha_tests/test_self_healing.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)):
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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:
Expand All @@ -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")
Expand Down Expand Up @@ -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).
Expand Down Expand Up @@ -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).
Expand Down
Loading