Skip to content

Commit 3dd00a0

Browse files
Fix integration tests
1 parent ae8aaab commit 3dd00a0

File tree

3 files changed

+15
-21
lines changed

3 files changed

+15
-21
lines changed

poetry.lock

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,8 @@ mysql-connector-python = "~8.0.33"
5858
tenacity = "^9.0.0"
5959
ops = "^2.9.0"
6060
allure-pytest-default-results = "^0.1.2"
61+
tomli = "^2.2.1"
62+
tomli-w = "^1.2.0"
6163

6264
[tool.poetry.group.build-refresh-version]
6365
optional = true

tests/integration/test_upgrade.py

Lines changed: 11 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,16 @@
55
import logging
66
import os
77
import pathlib
8-
import platform
9-
import re
108
import shutil
119
import typing
1210
import zipfile
1311

1412
import pytest
1513
import tenacity
14+
import tomli
15+
import tomli_w
1616
from pytest_operator.plugin import OpsTest
1717

18-
import snap
19-
2018
from .helpers import (
2119
APPLICATION_DEFAULT_APP_NAME,
2220
MYSQL_DEFAULT_APP_NAME,
@@ -107,8 +105,8 @@ async def test_upgrade_from_edge(ops_test: OpsTest, charm, continuous_writes) ->
107105
lambda: mysql_router_application.status == "blocked", timeout=TIMEOUT
108106
)
109107
assert (
110-
"resume-upgrade" in mysql_router_application.status_message
111-
), "mysql router application status not indicating that user should resume upgrade"
108+
"resume-refresh" in mysql_router_application.status_message
109+
), "mysql router application status not indicating that user should resume refresh"
112110

113111
for attempt in tenacity.Retrying(
114112
reraise=True,
@@ -122,8 +120,8 @@ async def test_upgrade_from_edge(ops_test: OpsTest, charm, continuous_writes) ->
122120

123121
mysql_router_leader_unit = await get_leader_unit(ops_test, MYSQL_ROUTER_APP_NAME)
124122

125-
logger.info("Running resume-upgrade on the mysql router leader unit")
126-
await run_action(mysql_router_leader_unit, "resume-upgrade")
123+
logger.info("Running resume-refresh on the mysql router leader unit")
124+
await run_action(mysql_router_leader_unit, "resume-refresh")
127125

128126
logger.info("Waiting for upgrade to complete on all units")
129127
await ops_test.model.wait_for_idle(
@@ -218,17 +216,11 @@ def create_valid_upgrade_charm(charm_file: typing.Union[str, pathlib.Path]) -> N
218216
with zipfile.ZipFile(charm_file, mode="a") as charm_zip:
219217
charm_zip.writestr("workload_version", f"{workload_version}+testupgrade\n")
220218

221-
# charm needs to refresh snap to be able to avoid no-op when upgrading.
222-
# set an old revision of the snap
223-
snap_file = pathlib.Path("src/snap.py")
224-
content = snap_file.read_text()
225-
old_revision = {"x86_64": "121", "aarch64": "122"}[platform.machine()]
226-
new_snap_content = re.sub(
227-
f'"{platform.machine()}": "{snap.revision}"',
228-
f'"{platform.machine()}": "{old_revision}"',
229-
str(content),
230-
)
231-
charm_zip.writestr("src/snap.py", new_snap_content)
219+
with pathlib.Path("refresh_versions.toml").open("rb") as file:
220+
versions = tomli.load(file)
221+
versions["snap"]["revisions"]["x86_64"] = "121"
222+
versions["snap"]["revisions"]["aarch64"] = "122"
223+
charm_zip.writestr("refresh_versions.toml", tomli_w.dumps(versions))
232224

233225

234226
def create_invalid_upgrade_charm(charm_file: typing.Union[str, pathlib.Path]) -> None:

0 commit comments

Comments
 (0)