|
2 | 2 | # See LICENSE file for licensing details.
|
3 | 3 |
|
4 | 4 | import logging
|
5 |
| -import pathlib |
6 | 5 | import platform
|
7 | 6 | import shutil
|
8 | 7 | import zipfile
|
@@ -40,7 +39,7 @@ async def test_deploy_latest(ops_test: OpsTest) -> None:
|
40 | 39 | "-n",
|
41 | 40 | 3,
|
42 | 41 | "--channel",
|
43 |
| - "16/edge/test-refresh-v3-workload2", # TODO remove branch |
| 42 | + "16/edge", |
44 | 43 | "--config",
|
45 | 44 | "profile=testing",
|
46 | 45 | "--base",
|
@@ -90,21 +89,44 @@ async def test_upgrade_from_edge(ops_test: OpsTest, continuous_writes, charm) ->
|
90 | 89 | await application.refresh(path=charm)
|
91 | 90 |
|
92 | 91 | logger.info("Wait for upgrade to start")
|
93 |
| - await ops_test.model.block_until(lambda: application.status == "blocked", timeout=TIMEOUT) |
94 |
| - |
95 |
| - logger.info("Wait for first unit to upgrade") |
96 |
| - async with ops_test.fast_forward("60s"): |
97 |
| - await ops_test.model.wait_for_idle( |
98 |
| - apps=[DATABASE_APP_NAME], idle_period=30, timeout=TIMEOUT |
| 92 | + try: |
| 93 | + # Blocked status is expected due to compatibility checks. |
| 94 | + await ops_test.model.block_until(lambda: application.status == "blocked", timeout=60 * 3) |
| 95 | + |
| 96 | + logger.info("Wait for refresh to block due to compatibility checks") |
| 97 | + async with ops_test.fast_forward("60s"): |
| 98 | + await ops_test.model.wait_for_idle( |
| 99 | + apps=[DATABASE_APP_NAME], idle_period=30, timeout=TIMEOUT |
| 100 | + ) |
| 101 | + |
| 102 | + assert "Refresh incompatible" in application.status_message, ( |
| 103 | + "Application refresh not blocked due to incompatibility" |
99 | 104 | )
|
100 | 105 |
|
101 |
| - logger.info("Run resume-refresh action") |
102 |
| - # Highest to lowest unit number |
103 |
| - refresh_order = sorted( |
104 |
| - application.units, key=lambda unit: int(unit.name.split("/")[1]), reverse=True |
105 |
| - ) |
106 |
| - action = await refresh_order[1].run_action("resume-refresh") |
107 |
| - await action.wait() |
| 106 | + # Highest to lowest unit number |
| 107 | + refresh_order = sorted( |
| 108 | + application.units, key=lambda unit: int(unit.name.split("/")[1]), reverse=True |
| 109 | + ) |
| 110 | + action = await refresh_order[0].run_action( |
| 111 | + "force-refresh-start", **{"check-compatibility": False} |
| 112 | + ) |
| 113 | + await action.wait() |
| 114 | + |
| 115 | + logger.info("Wait for first unit to upgrade") |
| 116 | + async with ops_test.fast_forward("60s"): |
| 117 | + await ops_test.model.wait_for_idle( |
| 118 | + apps=[DATABASE_APP_NAME], idle_period=30, timeout=TIMEOUT |
| 119 | + ) |
| 120 | + |
| 121 | + logger.info("Run resume-refresh action") |
| 122 | + action = await refresh_order[1].run_action("resume-refresh") |
| 123 | + await action.wait() |
| 124 | + except TimeoutError: |
| 125 | + # If the application didn't get into the blocked state, it should have upgraded only |
| 126 | + # the charm code because the snap revision didn't change. |
| 127 | + assert application.status == "active", ( |
| 128 | + "Application didn't reach blocked or active state after refresh attempt" |
| 129 | + ) |
108 | 130 |
|
109 | 131 | logger.info("Wait for upgrade to complete")
|
110 | 132 | async with ops_test.fast_forward("60s"):
|
@@ -147,7 +169,7 @@ async def test_fail_and_rollback(ops_test, charm, continuous_writes) -> None:
|
147 | 169 | await action.wait()
|
148 | 170 |
|
149 | 171 | filename = Path(charm).name
|
150 |
| - fault_charm = Path("/tmp/", filename) |
| 172 | + fault_charm = Path("/tmp", f"{filename}.fault.charm") |
151 | 173 | shutil.copy(charm, fault_charm)
|
152 | 174 |
|
153 | 175 | logger.info("Inject dependency fault")
|
@@ -194,7 +216,7 @@ async def test_fail_and_rollback(ops_test, charm, continuous_writes) -> None:
|
194 | 216 |
|
195 | 217 | async def inject_dependency_fault(charm_file: str | Path) -> None:
|
196 | 218 | """Inject a dependency fault into the PostgreSQL charm."""
|
197 |
| - with pathlib.Path("refresh_versions.toml").open("rb") as file: |
| 219 | + with Path("refresh_versions.toml").open("rb") as file: |
198 | 220 | versions = tomli.load(file)
|
199 | 221 |
|
200 | 222 | versions["charm"] = "16/0.0.0"
|
|
0 commit comments