Skip to content

Commit 8085ce2

Browse files
fix integration test
1 parent 48e3d03 commit 8085ce2

File tree

1 file changed

+31
-13
lines changed

1 file changed

+31
-13
lines changed

tests/integration/test_upgrade.py

Lines changed: 31 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
import pytest
1313
import tomli
1414
import tomli_w
15-
from packaging.version import Version
1615
from pytest_operator.plugin import OpsTest
1716

1817
from . import markers
@@ -100,7 +99,35 @@ async def test_upgrade_from_edge(ops_test: OpsTest, charm, continuous_writes) ->
10099
logger.info("Refresh the charm")
101100
await mysql_router_application.refresh(path=temporary_charm)
102101

103-
logger.info("Wait for the first unit to be refreshed and the app to move to blocked status")
102+
# Refresh will always be incompatible since we are downgrading the workload
103+
# Refresh will additionally be incompatible on PR CI (not edge CI) since unrelease charm
104+
# versions are always marked as incompatible
105+
logger.info("Wait for refresh to block as incompatible")
106+
await ops_test.model.block_until(
107+
lambda: mysql_router_application.status == "blocked", timeout=TIMEOUT
108+
)
109+
assert (
110+
"incompatible" in mysql_router_application.status_message
111+
), "mysql router application status not indicating that refresh incompatible"
112+
113+
# Highest to lowest unit number
114+
refresh_order = sorted(
115+
mysql_router_application.units,
116+
key=lambda unit: int(unit.name.split("/")[1]),
117+
reverse=True,
118+
)
119+
120+
logger.info("Running force-refresh-start action with check-compatibility=false")
121+
await run_action(refresh_order[0], "force-refresh-start", **{"check-compatibility": False})
122+
123+
logger.info("Wait for app status to update")
124+
await ops_test.model.wait_for_idle(
125+
[MYSQL_ROUTER_APP_NAME],
126+
idle_period=30,
127+
timeout=60,
128+
)
129+
130+
logger.info("Wait for refresh to start")
104131
await ops_test.model.block_until(
105132
lambda: mysql_router_application.status == "blocked", timeout=TIMEOUT
106133
)
@@ -116,14 +143,7 @@ async def test_upgrade_from_edge(ops_test: OpsTest, charm, continuous_writes) ->
116143
timeout=TIMEOUT,
117144
)
118145

119-
# Highest to lowest unit number
120-
refresh_order = sorted(
121-
mysql_router_application.units,
122-
key=lambda unit: int(unit.name.split("/")[1]),
123-
reverse=True,
124-
)
125-
126-
logger.info("Running resume-refresh on the mysql router leader unit")
146+
logger.info("Running resume-refresh")
127147
await run_action(refresh_order[1], "resume-refresh")
128148

129149
logger.info("Waiting for upgrade to complete on all units")
@@ -202,6 +222,7 @@ def create_valid_upgrade_charm(charm_file: typing.Union[str, pathlib.Path]) -> N
202222
# set an old revision of the snap
203223
versions["snap"]["revisions"]["x86_64"] = "121"
204224
versions["snap"]["revisions"]["aarch64"] = "122"
225+
versions["workload"] = "8.0.39"
205226

206227
with zipfile.ZipFile(charm_file, mode="a") as charm_zip:
207228
charm_zip.writestr("refresh_versions.toml", tomli_w.dumps(versions))
@@ -212,9 +233,6 @@ def create_invalid_upgrade_charm(charm_file: typing.Union[str, pathlib.Path]) ->
212233
with pathlib.Path("refresh_versions.toml").open("rb") as file:
213234
versions = tomli.load(file)
214235

215-
old_version = Version(versions["workload"])
216-
new_version = Version(f"{old_version.major - 1}.{old_version.minor}.{old_version.micro}")
217-
versions["workload"] = str(new_version)
218236
versions["charm"] = "8.0/0.0.0"
219237

220238
with zipfile.ZipFile(charm_file, mode="a") as charm_zip:

0 commit comments

Comments
 (0)