Skip to content

Commit 548f1b8

Browse files
fix integration test
1 parent 8d4ed98 commit 548f1b8

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
@@ -104,7 +103,35 @@ async def test_upgrade_from_edge(ops_test: OpsTest, charm, continuous_writes) ->
104103
logger.info("Refresh the charm")
105104
await mysql_router_application.refresh(path=temporary_charm)
106105

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

123-
# Highest to lowest unit number
124-
refresh_order = sorted(
125-
mysql_router_application.units,
126-
key=lambda unit: int(unit.name.split("/")[1]),
127-
reverse=True,
128-
)
129-
130-
logger.info("Running resume-refresh on the mysql router leader unit")
150+
logger.info("Running resume-refresh")
131151
await run_action(refresh_order[1], "resume-refresh")
132152

133153
logger.info("Waiting for upgrade to complete on all units")
@@ -206,6 +226,7 @@ def create_valid_upgrade_charm(charm_file: typing.Union[str, pathlib.Path]) -> N
206226
# set an old revision of the snap
207227
versions["snap"]["revisions"]["x86_64"] = "121"
208228
versions["snap"]["revisions"]["aarch64"] = "122"
229+
versions["workload"] = "8.0.39"
209230

210231
with zipfile.ZipFile(charm_file, mode="a") as charm_zip:
211232
charm_zip.writestr("refresh_versions.toml", tomli_w.dumps(versions))
@@ -216,9 +237,6 @@ def create_invalid_upgrade_charm(charm_file: typing.Union[str, pathlib.Path]) ->
216237
with pathlib.Path("refresh_versions.toml").open("rb") as file:
217238
versions = tomli.load(file)
218239

219-
old_version = Version(versions["workload"])
220-
new_version = Version(f"{old_version.major - 1}.{old_version.minor}.{old_version.micro}")
221-
versions["workload"] = str(new_version)
222240
versions["charm"] = "8.0/0.0.0"
223241

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

0 commit comments

Comments
 (0)