5
5
import logging
6
6
import os
7
7
import pathlib
8
- import platform
9
- import re
10
8
import shutil
11
9
import typing
12
10
import zipfile
13
11
14
12
import pytest
15
13
import tenacity
14
+ import tomli
15
+ import tomli_w
16
16
from pytest_operator .plugin import OpsTest
17
17
18
- import snap
19
-
20
18
from .helpers import (
21
19
APPLICATION_DEFAULT_APP_NAME ,
22
20
MYSQL_DEFAULT_APP_NAME ,
@@ -107,8 +105,8 @@ async def test_upgrade_from_edge(ops_test: OpsTest, charm, continuous_writes) ->
107
105
lambda : mysql_router_application .status == "blocked" , timeout = TIMEOUT
108
106
)
109
107
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 "
112
110
113
111
for attempt in tenacity .Retrying (
114
112
reraise = True ,
@@ -122,8 +120,8 @@ async def test_upgrade_from_edge(ops_test: OpsTest, charm, continuous_writes) ->
122
120
123
121
mysql_router_leader_unit = await get_leader_unit (ops_test , MYSQL_ROUTER_APP_NAME )
124
122
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 " )
127
125
128
126
logger .info ("Waiting for upgrade to complete on all units" )
129
127
await ops_test .model .wait_for_idle (
@@ -218,17 +216,11 @@ def create_valid_upgrade_charm(charm_file: typing.Union[str, pathlib.Path]) -> N
218
216
with zipfile .ZipFile (charm_file , mode = "a" ) as charm_zip :
219
217
charm_zip .writestr ("workload_version" , f"{ workload_version } +testupgrade\n " )
220
218
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 ))
232
224
233
225
234
226
def create_invalid_upgrade_charm (charm_file : typing .Union [str , pathlib .Path ]) -> None :
0 commit comments