-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[DPE-5369] rs int tests for upgrades (#332)
- Loading branch information
1 parent
b2aa4b2
commit 1991e9e
Showing
7 changed files
with
185 additions
and
57 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
#!/usr/bin/env python3 | ||
# Copyright 2024 Canonical Ltd. | ||
# See LICENSE file for licensing details. | ||
|
||
import pytest | ||
import pytest_asyncio | ||
from pytest_operator.plugin import OpsTest | ||
|
||
from .ha_tests.helpers import ( | ||
deploy_chaos_mesh, | ||
destroy_chaos_mesh, | ||
get_application_name, | ||
) | ||
|
||
|
||
@pytest_asyncio.fixture | ||
async def continuous_writes(ops_test: OpsTest) -> None: | ||
"""Starts continuous writes to the MongoDB cluster and clear the writes at the end.""" | ||
application_name = await get_application_name(ops_test, "application") | ||
|
||
application_unit = ops_test.model.applications[application_name].units[0] | ||
|
||
clear_writes_action = await application_unit.run_action("clear-continuous-writes") | ||
await clear_writes_action.wait() | ||
|
||
start_writes_action = await application_unit.run_action("start-continuous-writes") | ||
await start_writes_action.wait() | ||
|
||
yield | ||
|
||
clear_writes_action = await application_unit.run_action("clear-continuous-writes") | ||
await clear_writes_action.wait() | ||
|
||
|
||
@pytest.fixture(scope="module") | ||
def chaos_mesh(ops_test: OpsTest) -> None: | ||
deploy_chaos_mesh(ops_test.model.info.name) | ||
|
||
yield | ||
|
||
destroy_chaos_mesh(ops_test.model.info.name) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
#!/usr/bin/env python3 | ||
# Copyright 2024 Canonical Ltd. | ||
# See LICENSE file for licensing details. | ||
|
||
import logging | ||
from pathlib import Path | ||
|
||
from pytest_operator.plugin import OpsTest | ||
|
||
from ..backup_tests import helpers as backup_helpers | ||
|
||
logger = logging.getLogger(__name__) | ||
|
||
|
||
async def assert_successful_run_upgrade_sequence( | ||
ops_test: OpsTest, app_name: str, new_charm: Path | ||
) -> None: | ||
"""Runs the upgrade sequence on a given app.""" | ||
leader_unit = await backup_helpers.get_leader_unit(ops_test, app_name) | ||
# action = await leader_unit.run_action("pre-upgrade-check") | ||
# await action.wait() | ||
# assert action.status == "completed", "pre-upgrade-check failed, expected to succeed." | ||
|
||
await ops_test.model.applications[app_name].refresh(path=new_charm) | ||
await ops_test.model.wait_for_idle( | ||
apps=[app_name], status="active", timeout=1000, idle_period=30 | ||
) | ||
|
||
# resume upgrade only needs to be ran when: | ||
# 1. there are more than one units in the application | ||
# 2. AND the underlying workload was updated | ||
if len(ops_test.model.applications[app_name].units) < 2: | ||
return | ||
|
||
if "resume-upgrade" not in ops_test.model.applications[app_name].status_message: | ||
return | ||
|
||
logger.info(f"Calling resume-upgrade for {app_name}") | ||
action = await leader_unit.run_action("resume-upgrade") | ||
await action.wait() | ||
assert action.status == "completed", "resume-upgrade failed, expected to succeed." | ||
|
||
await ops_test.model.wait_for_idle( | ||
apps=[app_name], status="active", timeout=1000, idle_period=30 | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters