Skip to content

Commit 6821b27

Browse files
authoredJul 1, 2024··
Build & release arm64 (#472)
1 parent 3468102 commit 6821b27

22 files changed

+128
-188
lines changed
 

‎charmcraft.yaml

+8-9
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,12 @@
33

44
type: charm
55
bases:
6-
# Whenever "bases" is changed:
7-
# - Update tests/integration/conftest.py::pytest_configure()
8-
# - Update .github/workflow/ci.yaml integration-test matrix
9-
- build-on:
10-
- name: "ubuntu"
11-
channel: "22.04"
12-
run-on:
13-
- name: "ubuntu"
14-
channel: "22.04"
6+
- name: ubuntu
7+
channel: "22.04"
8+
architectures: [amd64]
9+
- name: ubuntu
10+
channel: "22.04"
11+
architectures: [arm64]
1512
parts:
1613
charm:
1714
override-pull: |
@@ -22,6 +19,8 @@ parts:
2219
exit 1
2320
fi
2421
charm-strict-dependencies: true
22+
prime:
23+
- snap_revisions.json
2524
build-packages:
2625
- libffi-dev
2726
- libssl-dev

‎snap_revisions.json

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"x86_64": "106",
3+
"aarch64": "107"
4+
}

‎src/constants.py

-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
TLS_SSL_CERT_FILE = "custom-server-cert.pem"
2626
MYSQL_EXPORTER_PORT = 9104
2727
CHARMED_MYSQL_SNAP_NAME = "charmed-mysql"
28-
CHARMED_MYSQL_SNAP_REVISION = 105 # MySQL v8.0.37
2928
CHARMED_MYSQLD_EXPORTER_SERVICE = "mysqld-exporter"
3029
CHARMED_MYSQLD_SERVICE = "mysqld"
3130
CHARMED_MYSQL = "charmed-mysql.mysql"

‎src/mysql_vm_helpers.py

+6-5
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,11 @@
33

44
"""Helper class to manage the MySQL InnoDB cluster lifecycle with MySQL Shell."""
55

6+
import json
67
import logging
78
import os
89
import pathlib
10+
import platform
911
import shutil
1012
import subprocess
1113
import tempfile
@@ -35,7 +37,6 @@
3537
CHARMED_MYSQL,
3638
CHARMED_MYSQL_COMMON_DIRECTORY,
3739
CHARMED_MYSQL_SNAP_NAME,
38-
CHARMED_MYSQL_SNAP_REVISION,
3940
CHARMED_MYSQL_XBCLOUD_LOCATION,
4041
CHARMED_MYSQL_XBSTREAM_LOCATION,
4142
CHARMED_MYSQL_XTRABACKUP_LOCATION,
@@ -167,10 +168,10 @@ def install_and_configure_mysql_dependencies() -> None:
167168

168169
try:
169170
# install the charmed-mysql snap
170-
logger.debug(
171-
f"Installing {CHARMED_MYSQL_SNAP_NAME} revision {CHARMED_MYSQL_SNAP_REVISION}"
172-
)
173-
charmed_mysql.ensure(snap.SnapState.Present, revision=str(CHARMED_MYSQL_SNAP_REVISION))
171+
with pathlib.Path("snap_revisions.json").open("r") as file:
172+
revision = json.load(file)[platform.machine()]
173+
logger.debug(f"Installing {CHARMED_MYSQL_SNAP_NAME} revision {revision}")
174+
charmed_mysql.ensure(snap.SnapState.Present, revision=revision)
174175
if not charmed_mysql.held:
175176
# hold the snap in charm determined revision
176177
charmed_mysql.hold()

‎tests/conftest.py

-27
This file was deleted.

‎tests/integration/conftest.py

-32
This file was deleted.

‎tests/integration/high_availability/high_availability_helpers.py

+3-8
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,6 @@ async def ensure_n_online_mysql_members(
110110

111111
async def deploy_and_scale_mysql(
112112
ops_test: OpsTest,
113-
mysql_charm_series: str,
114113
check_for_existing_application: bool = True,
115114
mysql_application_name: str = MYSQL_DEFAULT_APP_NAME,
116115
num_units: int = 3,
@@ -119,7 +118,6 @@ async def deploy_and_scale_mysql(
119118
120119
Args:
121120
ops_test: The ops test framework
122-
mysql_charm_series: series to test on
123121
check_for_existing_application: Whether to check for existing mysql applications
124122
in the model
125123
mysql_application_name: The name of the mysql application if it is to be deployed
@@ -144,7 +142,7 @@ async def deploy_and_scale_mysql(
144142
application_name=mysql_application_name,
145143
config=config,
146144
num_units=num_units,
147-
series=mysql_charm_series,
145+
series="jammy",
148146
)
149147

150148
await ops_test.model.wait_for_idle(
@@ -219,16 +217,13 @@ async def relate_mysql_and_application(
219217
)
220218

221219

222-
async def high_availability_test_setup(
223-
ops_test: OpsTest, mysql_charm_series: str
224-
) -> Tuple[str, str]:
220+
async def high_availability_test_setup(ops_test: OpsTest) -> Tuple[str, str]:
225221
"""Run the set up for high availability tests.
226222
227223
Args:
228224
ops_test: The ops test framework
229-
mysql_charm_series: Series to run mysql charm (defaults to focal)
230225
"""
231-
mysql_application_name = await deploy_and_scale_mysql(ops_test, mysql_charm_series)
226+
mysql_application_name = await deploy_and_scale_mysql(ops_test)
232227
application_name = await deploy_and_scale_application(ops_test)
233228

234229
await relate_mysql_and_application(ops_test, mysql_application_name, application_name)

‎tests/integration/high_availability/test_replication.py

+17-19
Original file line numberDiff line numberDiff line change
@@ -48,16 +48,16 @@
4848

4949
@pytest.mark.group(1)
5050
@pytest.mark.abort_on_fail
51-
async def test_build_and_deploy(ops_test: OpsTest, mysql_charm_series: str) -> None:
51+
async def test_build_and_deploy(ops_test: OpsTest) -> None:
5252
"""Build the charm and deploy 3 units to ensure a cluster is formed."""
53-
await high_availability_test_setup(ops_test, mysql_charm_series)
53+
await high_availability_test_setup(ops_test)
5454

5555

5656
@pytest.mark.group(1)
5757
@pytest.mark.abort_on_fail
58-
async def test_exporter_endpoints(ops_test: OpsTest, mysql_charm_series: str) -> None:
58+
async def test_exporter_endpoints(ops_test: OpsTest) -> None:
5959
"""Test that endpoints are running."""
60-
mysql_application_name, _ = await high_availability_test_setup(ops_test, mysql_charm_series)
60+
mysql_application_name, _ = await high_availability_test_setup(ops_test)
6161
application = ops_test.model.applications[mysql_application_name]
6262
http = urllib3.PoolManager()
6363

@@ -116,9 +116,9 @@ async def test_exporter_endpoints(ops_test: OpsTest, mysql_charm_series: str) ->
116116

117117
@pytest.mark.group(1)
118118
@pytest.mark.abort_on_fail
119-
async def test_custom_variables(ops_test: OpsTest, mysql_charm_series) -> None:
119+
async def test_custom_variables(ops_test: OpsTest) -> None:
120120
"""Query database for custom variables."""
121-
mysql_application_name, _ = await high_availability_test_setup(ops_test, mysql_charm_series)
121+
mysql_application_name, _ = await high_availability_test_setup(ops_test)
122122
application = ops_test.model.applications[mysql_application_name]
123123

124124
for unit in application.units:
@@ -132,11 +132,9 @@ async def test_custom_variables(ops_test: OpsTest, mysql_charm_series) -> None:
132132

133133
@pytest.mark.group(1)
134134
@pytest.mark.abort_on_fail
135-
async def test_consistent_data_replication_across_cluster(
136-
ops_test: OpsTest, mysql_charm_series: str
137-
) -> None:
135+
async def test_consistent_data_replication_across_cluster(ops_test: OpsTest) -> None:
138136
"""Confirm that data is replicated from the primary node to all the replicas."""
139-
mysql_application_name, _ = await high_availability_test_setup(ops_test, mysql_charm_series)
137+
mysql_application_name, _ = await high_availability_test_setup(ops_test)
140138

141139
# assert that there are 3 units in the mysql cluster
142140
assert len(ops_test.model.applications[mysql_application_name].units) == 3
@@ -150,9 +148,9 @@ async def test_consistent_data_replication_across_cluster(
150148

151149
@pytest.mark.group(1)
152150
@pytest.mark.abort_on_fail
153-
async def test_kill_primary_check_reelection(ops_test: OpsTest, mysql_charm_series: str) -> None:
151+
async def test_kill_primary_check_reelection(ops_test: OpsTest) -> None:
154152
"""Confirm that a new primary is elected when the current primary is torn down."""
155-
mysql_application_name, _ = await high_availability_test_setup(ops_test, mysql_charm_series)
153+
mysql_application_name, _ = await high_availability_test_setup(ops_test)
156154
application = ops_test.model.applications[mysql_application_name]
157155

158156
await ensure_all_units_continuous_writes_incrementing(ops_test)
@@ -198,10 +196,10 @@ async def test_kill_primary_check_reelection(ops_test: OpsTest, mysql_charm_seri
198196

199197
@pytest.mark.group(2)
200198
@pytest.mark.abort_on_fail
201-
async def test_scaling_without_data_loss(ops_test: OpsTest, mysql_charm_series: str) -> None:
199+
async def test_scaling_without_data_loss(ops_test: OpsTest) -> None:
202200
"""Test that data is preserved during scale up and scale down."""
203201
# Insert values into test table from the primary unit
204-
app, _ = await high_availability_test_setup(ops_test, mysql_charm_series)
202+
app, _ = await high_availability_test_setup(ops_test)
205203
application = ops_test.model.applications[app]
206204

207205
random_unit = application.units[0]
@@ -275,14 +273,14 @@ async def test_scaling_without_data_loss(ops_test: OpsTest, mysql_charm_series:
275273

276274

277275
@pytest.mark.group(3)
278-
async def test_cluster_isolation(ops_test: OpsTest, mysql_charm_series: str) -> None:
276+
async def test_cluster_isolation(ops_test: OpsTest) -> None:
279277
"""Test for cluster data isolation.
280278
281279
This test creates a new cluster, create a new table on both cluster, write a single record with
282280
the application name for each cluster, retrieve and compare these records, asserting they are
283281
not the same.
284282
"""
285-
app, _ = await high_availability_test_setup(ops_test, mysql_charm_series)
283+
app, _ = await high_availability_test_setup(ops_test)
286284
apps = [app, ANOTHER_APP_NAME]
287285

288286
# Build and deploy secondary charm
@@ -292,7 +290,7 @@ async def test_cluster_isolation(ops_test: OpsTest, mysql_charm_series: str) ->
292290
charm,
293291
application_name=ANOTHER_APP_NAME,
294292
num_units=1,
295-
series=mysql_charm_series,
293+
series="jammy",
296294
)
297295
async with ops_test.fast_forward("60s"):
298296
await ops_test.model.block_until(
@@ -358,9 +356,9 @@ async def test_cluster_isolation(ops_test: OpsTest, mysql_charm_series: str) ->
358356

359357
@pytest.mark.group(1)
360358
@pytest.mark.abort_on_fail
361-
async def test_log_rotation(ops_test: OpsTest, mysql_charm_series: str) -> None:
359+
async def test_log_rotation(ops_test: OpsTest) -> None:
362360
"""Test the log rotation of text files."""
363-
app, _ = await high_availability_test_setup(ops_test, mysql_charm_series)
361+
app, _ = await high_availability_test_setup(ops_test)
364362
unit = ops_test.model.applications[app].units[0]
365363

366364
# Exclude slowquery log files as slowquery logs are not enabled by default

‎tests/integration/high_availability/test_self_healing.py

+14-18
Original file line numberDiff line numberDiff line change
@@ -49,18 +49,16 @@
4949

5050
@pytest.mark.group(1)
5151
@pytest.mark.abort_on_fail
52-
async def test_build_and_deploy(ops_test: OpsTest, mysql_charm_series: str) -> None:
52+
async def test_build_and_deploy(ops_test: OpsTest) -> None:
5353
"""Build and deploy."""
54-
await high_availability_test_setup(ops_test, mysql_charm_series)
54+
await high_availability_test_setup(ops_test)
5555

5656

5757
@pytest.mark.group(1)
5858
@pytest.mark.abort_on_fail
59-
async def test_kill_db_process(
60-
ops_test: OpsTest, continuous_writes, mysql_charm_series: str
61-
) -> None:
59+
async def test_kill_db_process(ops_test: OpsTest, continuous_writes) -> None:
6260
"""Kill mysqld process and check for auto cluster recovery."""
63-
mysql_application_name, _ = await high_availability_test_setup(ops_test, mysql_charm_series)
61+
mysql_application_name, _ = await high_availability_test_setup(ops_test)
6462

6563
await ensure_all_units_continuous_writes_incrementing(ops_test)
6664

@@ -97,9 +95,9 @@ async def test_kill_db_process(
9795

9896
@pytest.mark.group(1)
9997
@pytest.mark.abort_on_fail
100-
async def test_freeze_db_process(ops_test: OpsTest, continuous_writes, mysql_charm_series: str):
98+
async def test_freeze_db_process(ops_test: OpsTest, continuous_writes):
10199
"""Freeze and unfreeze process and check for auto cluster recovery."""
102-
mysql_application_name, _ = await high_availability_test_setup(ops_test, mysql_charm_series)
100+
mysql_application_name, _ = await high_availability_test_setup(ops_test)
103101
# ensure continuous writes still incrementing for all units
104102
await ensure_all_units_continuous_writes_incrementing(ops_test)
105103

@@ -144,9 +142,9 @@ async def test_freeze_db_process(ops_test: OpsTest, continuous_writes, mysql_cha
144142

145143
@pytest.mark.group(1)
146144
@pytest.mark.abort_on_fail
147-
async def test_network_cut(ops_test: OpsTest, continuous_writes, mysql_charm_series: str):
145+
async def test_network_cut(ops_test: OpsTest, continuous_writes):
148146
"""Completely cut and restore network."""
149-
mysql_application_name, _ = await high_availability_test_setup(ops_test, mysql_charm_series)
147+
mysql_application_name, _ = await high_availability_test_setup(ops_test)
150148
primary_unit = await get_primary_unit_wrapper(ops_test, mysql_application_name)
151149
all_units = ops_test.model.applications[mysql_application_name].units
152150

@@ -224,11 +222,9 @@ async def test_network_cut(ops_test: OpsTest, continuous_writes, mysql_charm_ser
224222

225223
@pytest.mark.group(1)
226224
@pytest.mark.abort_on_fail
227-
async def test_replicate_data_on_restart(
228-
ops_test: OpsTest, continuous_writes, mysql_charm_series: str
229-
):
225+
async def test_replicate_data_on_restart(ops_test: OpsTest, continuous_writes):
230226
"""Stop server, write data, start and validate replication."""
231-
mysql_application_name, _ = await high_availability_test_setup(ops_test, mysql_charm_series)
227+
mysql_application_name, _ = await high_availability_test_setup(ops_test)
232228

233229
# ensure continuous writes still incrementing for all units
234230
await ensure_all_units_continuous_writes_incrementing(ops_test)
@@ -309,13 +305,13 @@ async def test_replicate_data_on_restart(
309305

310306
@pytest.mark.group(1)
311307
@pytest.mark.abort_on_fail
312-
async def test_cluster_pause(ops_test: OpsTest, continuous_writes, mysql_charm_series: str):
308+
async def test_cluster_pause(ops_test: OpsTest, continuous_writes):
313309
"""Pause test.
314310
315311
A graceful simultaneous restart of all instances,
316312
check primary election after the start, write and read data
317313
"""
318-
mysql_application_name, _ = await high_availability_test_setup(ops_test, mysql_charm_series)
314+
mysql_application_name, _ = await high_availability_test_setup(ops_test)
319315
all_units = ops_test.model.applications[mysql_application_name].units
320316

321317
config = {
@@ -374,12 +370,12 @@ async def test_cluster_pause(ops_test: OpsTest, continuous_writes, mysql_charm_s
374370

375371
@pytest.mark.group(1)
376372
@pytest.mark.abort_on_fail
377-
async def test_sst_test(ops_test: OpsTest, continuous_writes, mysql_charm_series: str):
373+
async def test_sst_test(ops_test: OpsTest, continuous_writes):
378374
"""The SST test.
379375
380376
A forceful restart instance with deleted data and without transaction logs (forced clone).
381377
"""
382-
mysql_application_name, _ = await high_availability_test_setup(ops_test, mysql_charm_series)
378+
mysql_application_name, _ = await high_availability_test_setup(ops_test)
383379
primary_unit = await get_primary_unit_wrapper(ops_test, mysql_application_name)
384380
server_config_password = await get_system_user_password(primary_unit, SERVER_CONFIG_USERNAME)
385381
all_units = ops_test.model.applications[mysql_application_name].units

‎tests/integration/high_availability/test_upgrade.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535

3636
@pytest.mark.group(1)
3737
@pytest.mark.abort_on_fail
38-
async def test_deploy_latest(ops_test: OpsTest, mysql_charm_series: str) -> None:
38+
async def test_deploy_latest(ops_test: OpsTest) -> None:
3939
"""Simple test to ensure that the mysql and application charms get deployed."""
4040
await asyncio.gather(
4141
ops_test.model.deploy(
@@ -44,7 +44,7 @@ async def test_deploy_latest(ops_test: OpsTest, mysql_charm_series: str) -> None
4444
num_units=3,
4545
channel="8.0/edge",
4646
config={"profile": "testing"},
47-
series=mysql_charm_series,
47+
series="jammy",
4848
),
4949
ops_test.model.deploy(
5050
TEST_APP_NAME,

‎tests/integration/high_availability/test_upgrade_from_stable.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,15 @@
2424

2525
@pytest.mark.group(1)
2626
@pytest.mark.abort_on_fail
27-
async def test_deploy_stable(ops_test: OpsTest, mysql_charm_series: str) -> None:
27+
async def test_deploy_stable(ops_test: OpsTest) -> None:
2828
"""Simple test to ensure that the mysql and application charms get deployed."""
2929
await asyncio.gather(
3030
ops_test.model.deploy(
3131
MYSQL_APP_NAME,
3232
application_name=MYSQL_APP_NAME,
3333
num_units=3,
3434
channel="8.0/stable",
35-
series=mysql_charm_series,
35+
series="jammy",
3636
config={"profile": "testing"},
3737
),
3838
ops_test.model.deploy(

‎tests/integration/high_availability/test_upgrade_rollback_incompat.py

+23-9
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
# See LICENSE file for licensing details.
33

44
import ast
5+
import json
56
import logging
67
import os
78
import pathlib
@@ -29,13 +30,20 @@
2930

3031
@pytest.mark.group(1)
3132
@pytest.mark.abort_on_fail
32-
async def test_build_and_deploy(ops_test: OpsTest, mysql_charm_series: str) -> None:
33+
async def test_build_and_deploy(ops_test: OpsTest) -> None:
3334
"""Simple test to ensure that the mysql and application charms get deployed."""
34-
sub_regex_older_snap = "s/CHARMED_MYSQL_SNAP_REVISION.*/CHARMED_MYSQL_SNAP_REVISION = 69/"
35-
src_patch(sub_regex=sub_regex_older_snap, file_name="src/constants.py")
35+
snap_revisions = pathlib.Path("snap_revisions.json")
36+
with snap_revisions.open("r") as file:
37+
old_revisions: dict = json.load(file)
38+
new_revisions = old_revisions.copy()
39+
# TODO: mark as amd64 only or support arm64
40+
new_revisions["x86_64"] = "69"
41+
with snap_revisions.open("w") as file:
42+
json.dump(new_revisions, file)
3643
charm = await charm_local_build(ops_test)
3744

38-
src_patch(revert=True)
45+
with snap_revisions.open("w") as file:
46+
json.dump(old_revisions, file)
3947
config = {"profile": "testing"}
4048

4149
async with ops_test.fast_forward("10s"):
@@ -44,7 +52,7 @@ async def test_build_and_deploy(ops_test: OpsTest, mysql_charm_series: str) -> N
4452
application_name=MYSQL_APP_NAME,
4553
config=config,
4654
num_units=3,
47-
series=mysql_charm_series,
55+
series="jammy",
4856
)
4957

5058
await ops_test.model.deploy(
@@ -124,9 +132,15 @@ async def test_upgrade_to_failling(
124132
async def test_rollback(ops_test, continuous_writes) -> None:
125133
application = ops_test.model.applications[MYSQL_APP_NAME]
126134

127-
sub_regex_older_snap = "s/CHARMED_MYSQL_SNAP_REVISION.*/CHARMED_MYSQL_SNAP_REVISION = 69/"
128-
src_patch(sub_regex=sub_regex_older_snap, file_name="src/constants.py")
129-
charm = await charm_local_build(ops_test, refresh=True)
135+
snap_revisions = pathlib.Path("snap_revisions.json")
136+
with snap_revisions.open("r") as file:
137+
old_revisions: dict = json.load(file)
138+
new_revisions = old_revisions.copy()
139+
# TODO: mark as amd64 only or support arm64
140+
new_revisions["x86_64"] = "69"
141+
with snap_revisions.open("w") as file:
142+
json.dump(new_revisions, file)
143+
charm = await charm_local_build(ops_test)
130144

131145
logger.info("Get leader unit")
132146
leader_unit = await get_leader_unit(ops_test, MYSQL_APP_NAME)
@@ -177,7 +191,7 @@ async def charm_local_build(ops_test: OpsTest, refresh: bool = False):
177191
# CI will get charm from common cache
178192
# make local copy and update charm zip
179193

180-
update_files = ["src/constants.py", "src/upgrade.py"]
194+
update_files = ["snap_revisions.json", "src/upgrade.py"]
181195

182196
charm = pathlib.Path(shutil.copy(charm, f"local-{charm.stem}.charm"))
183197

‎tests/integration/relations/test_database.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545
@pytest.mark.group(1)
4646
@pytest.mark.abort_on_fail
4747
@pytest.mark.skip_if_deployed
48-
async def test_build_and_deploy(ops_test: OpsTest, mysql_charm_series: str) -> None:
48+
async def test_build_and_deploy(ops_test: OpsTest) -> None:
4949
"""Build the charm and deploy 3 units to ensure a cluster is formed."""
5050
db_charm = await ops_test.build_charm(".")
5151

@@ -57,7 +57,7 @@ async def test_build_and_deploy(ops_test: OpsTest, mysql_charm_series: str) -> N
5757
application_name=DATABASE_APP_NAME,
5858
config=config,
5959
num_units=3,
60-
series=mysql_charm_series,
60+
series="jammy",
6161
),
6262
ops_test.model.deploy(
6363
APPLICATION_APP_NAME,

‎tests/integration/relations/test_db_router.py

+2-3
Original file line numberDiff line numberDiff line change
@@ -107,19 +107,18 @@ async def check_keystone_users_existence(
107107

108108
@pytest.mark.group(1)
109109
@pytest.mark.abort_on_fail
110-
async def test_keystone_bundle_db_router(ops_test: OpsTest, mysql_charm_series: str) -> None:
110+
async def test_keystone_bundle_db_router(ops_test: OpsTest) -> None:
111111
"""Deploy the keystone bundle to test the 'db-router' relation.
112112
113113
Args:
114114
ops_test: The ops test framework
115-
mysql_charm_series: The series for the database machine
116115
"""
117116
charm = await ops_test.build_charm(".")
118117

119118
config = {"cluster-name": CLUSTER_NAME, "profile": "testing"}
120119

121120
mysql_app = await ops_test.model.deploy(
122-
charm, application_name=APP_NAME, config=config, num_units=1, series=mysql_charm_series
121+
charm, application_name=APP_NAME, config=config, num_units=1, series="jammy"
123122
)
124123

125124
# Deploy keystone

‎tests/integration/relations/test_relation_mysql_legacy.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
@pytest.mark.group(1)
3737
@pytest.mark.abort_on_fail
3838
@pytest.mark.skip_if_deployed
39-
async def test_build_and_deploy(ops_test: OpsTest, mysql_charm_series: str) -> None:
39+
async def test_build_and_deploy(ops_test: OpsTest) -> None:
4040
"""Build the charm and deploy 3 units to ensure a cluster is formed."""
4141
db_charm = await ops_test.build_charm(".")
4242

@@ -52,7 +52,7 @@ async def test_build_and_deploy(ops_test: OpsTest, mysql_charm_series: str) -> N
5252
application_name=DATABASE_APP_NAME,
5353
config=config,
5454
num_units=3,
55-
series=mysql_charm_series,
55+
series="jammy",
5656
),
5757
ops_test.model.deploy(
5858
APPLICATION_APP_NAME,

‎tests/integration/relations/test_shared_db.py

+2-3
Original file line numberDiff line numberDiff line change
@@ -147,12 +147,11 @@ async def check_keystone_users_existence(
147147

148148
@pytest.mark.group(1)
149149
@pytest.mark.abort_on_fail
150-
async def test_keystone_bundle_shared_db(ops_test: OpsTest, mysql_charm_series: str) -> None:
150+
async def test_keystone_bundle_shared_db(ops_test: OpsTest) -> None:
151151
"""Deploy the keystone bundle to test the 'shared-db' relation.
152152
153153
Args:
154154
ops_test: The ops test framework
155-
mysql_charm_series: The series for the database machine
156155
"""
157156
charm = await ops_test.build_charm(".")
158157

@@ -162,7 +161,7 @@ async def test_keystone_bundle_shared_db(ops_test: OpsTest, mysql_charm_series:
162161
application_name=APP_NAME,
163162
config=config,
164163
num_units=3,
165-
series=mysql_charm_series,
164+
series="jammy",
166165
)
167166

168167
# Reduce the update_status frequency for the duration of the test

‎tests/integration/test_backup_aws.py

+7-12
Original file line numberDiff line numberDiff line change
@@ -83,9 +83,9 @@ def clean_backups_from_buckets(cloud_configs, cloud_credentials):
8383

8484

8585
@pytest.mark.group(1)
86-
async def test_build_and_deploy(ops_test: OpsTest, mysql_charm_series: str) -> None:
86+
async def test_build_and_deploy(ops_test: OpsTest) -> None:
8787
"""Simple test to ensure that the mysql charm gets deployed."""
88-
mysql_application_name = await deploy_and_scale_mysql(ops_test, mysql_charm_series)
88+
mysql_application_name = await deploy_and_scale_mysql(ops_test)
8989

9090
primary_mysql = await get_primary_unit_wrapper(ops_test, mysql_application_name)
9191

@@ -114,11 +114,9 @@ async def test_build_and_deploy(ops_test: OpsTest, mysql_charm_series: str) -> N
114114

115115
@pytest.mark.group(1)
116116
@pytest.mark.abort_on_fail
117-
async def test_backup(
118-
ops_test: OpsTest, mysql_charm_series: str, cloud_configs, cloud_credentials
119-
) -> None:
117+
async def test_backup(ops_test: OpsTest, cloud_configs, cloud_credentials) -> None:
120118
"""Test to create a backup and list backups."""
121-
mysql_application_name = await deploy_and_scale_mysql(ops_test, mysql_charm_series)
119+
mysql_application_name = await deploy_and_scale_mysql(ops_test)
122120

123121
global backup_id, value_before_backup, value_after_backup
124122

@@ -190,10 +188,10 @@ async def test_backup(
190188
@pytest.mark.group(1)
191189
@pytest.mark.abort_on_fail
192190
async def test_restore_on_same_cluster(
193-
ops_test: OpsTest, mysql_charm_series: str, cloud_configs, cloud_credentials
191+
ops_test: OpsTest, cloud_configs, cloud_credentials
194192
) -> None:
195193
"""Test to restore a backup to the same mysql cluster."""
196-
mysql_application_name = await deploy_and_scale_mysql(ops_test, mysql_charm_series)
194+
mysql_application_name = await deploy_and_scale_mysql(ops_test)
197195

198196
logger.info("Scaling mysql application to 1 unit")
199197
async with ops_test.fast_forward():
@@ -281,15 +279,12 @@ async def test_restore_on_same_cluster(
281279

282280
@pytest.mark.group(1)
283281
@pytest.mark.abort_on_fail
284-
async def test_restore_on_new_cluster(
285-
ops_test: OpsTest, mysql_charm_series: str, cloud_configs, cloud_credentials
286-
) -> None:
282+
async def test_restore_on_new_cluster(ops_test: OpsTest, cloud_configs, cloud_credentials) -> None:
287283
"""Test to restore a backup on a new mysql cluster."""
288284
logger.info("Deploying a new mysql cluster")
289285

290286
new_mysql_application_name = await deploy_and_scale_mysql(
291287
ops_test,
292-
mysql_charm_series,
293288
check_for_existing_application=False,
294289
mysql_application_name="another-mysql",
295290
num_units=1,

‎tests/integration/test_backup_ceph.py

+7-12
Original file line numberDiff line numberDiff line change
@@ -83,9 +83,9 @@ def clean_backups_from_buckets(cloud_configs, cloud_credentials):
8383

8484

8585
@pytest.mark.group(1)
86-
async def test_build_and_deploy(ops_test: OpsTest, mysql_charm_series: str) -> None:
86+
async def test_build_and_deploy(ops_test: OpsTest) -> None:
8787
"""Simple test to ensure that the mysql charm gets deployed."""
88-
mysql_application_name = await deploy_and_scale_mysql(ops_test, mysql_charm_series)
88+
mysql_application_name = await deploy_and_scale_mysql(ops_test)
8989

9090
primary_mysql = await get_primary_unit_wrapper(ops_test, mysql_application_name)
9191

@@ -114,11 +114,9 @@ async def test_build_and_deploy(ops_test: OpsTest, mysql_charm_series: str) -> N
114114

115115
@pytest.mark.group(1)
116116
@pytest.mark.abort_on_fail
117-
async def test_backup(
118-
ops_test: OpsTest, mysql_charm_series: str, cloud_configs, cloud_credentials
119-
) -> None:
117+
async def test_backup(ops_test: OpsTest, cloud_configs, cloud_credentials) -> None:
120118
"""Test to create a backup and list backups."""
121-
mysql_application_name = await deploy_and_scale_mysql(ops_test, mysql_charm_series)
119+
mysql_application_name = await deploy_and_scale_mysql(ops_test)
122120

123121
global backup_id, value_before_backup, value_after_backup
124122

@@ -190,10 +188,10 @@ async def test_backup(
190188
@pytest.mark.group(1)
191189
@pytest.mark.abort_on_fail
192190
async def test_restore_on_same_cluster(
193-
ops_test: OpsTest, mysql_charm_series: str, cloud_configs, cloud_credentials
191+
ops_test: OpsTest, cloud_configs, cloud_credentials
194192
) -> None:
195193
"""Test to restore a backup to the same mysql cluster."""
196-
mysql_application_name = await deploy_and_scale_mysql(ops_test, mysql_charm_series)
194+
mysql_application_name = await deploy_and_scale_mysql(ops_test)
197195

198196
logger.info("Scaling mysql application to 1 unit")
199197
async with ops_test.fast_forward():
@@ -281,15 +279,12 @@ async def test_restore_on_same_cluster(
281279

282280
@pytest.mark.group(1)
283281
@pytest.mark.abort_on_fail
284-
async def test_restore_on_new_cluster(
285-
ops_test: OpsTest, mysql_charm_series: str, cloud_configs, cloud_credentials
286-
) -> None:
282+
async def test_restore_on_new_cluster(ops_test: OpsTest, cloud_configs, cloud_credentials) -> None:
287283
"""Test to restore a backup on a new mysql cluster."""
288284
logger.info("Deploying a new mysql cluster")
289285

290286
new_mysql_application_name = await deploy_and_scale_mysql(
291287
ops_test,
292-
mysql_charm_series,
293288
check_for_existing_application=False,
294289
mysql_application_name="another-mysql",
295290
num_units=1,

‎tests/integration/test_backup_gcp.py

+7-12
Original file line numberDiff line numberDiff line change
@@ -83,9 +83,9 @@ def clean_backups_from_buckets(cloud_configs, cloud_credentials):
8383

8484

8585
@pytest.mark.group(1)
86-
async def test_build_and_deploy(ops_test: OpsTest, mysql_charm_series: str) -> None:
86+
async def test_build_and_deploy(ops_test: OpsTest) -> None:
8787
"""Simple test to ensure that the mysql charm gets deployed."""
88-
mysql_application_name = await deploy_and_scale_mysql(ops_test, mysql_charm_series)
88+
mysql_application_name = await deploy_and_scale_mysql(ops_test)
8989

9090
primary_mysql = await get_primary_unit_wrapper(ops_test, mysql_application_name)
9191

@@ -114,11 +114,9 @@ async def test_build_and_deploy(ops_test: OpsTest, mysql_charm_series: str) -> N
114114

115115
@pytest.mark.group(1)
116116
@pytest.mark.abort_on_fail
117-
async def test_backup(
118-
ops_test: OpsTest, mysql_charm_series: str, cloud_configs, cloud_credentials
119-
) -> None:
117+
async def test_backup(ops_test: OpsTest, cloud_configs, cloud_credentials) -> None:
120118
"""Test to create a backup and list backups."""
121-
mysql_application_name = await deploy_and_scale_mysql(ops_test, mysql_charm_series)
119+
mysql_application_name = await deploy_and_scale_mysql(ops_test)
122120

123121
global backup_id, value_before_backup, value_after_backup
124122

@@ -190,10 +188,10 @@ async def test_backup(
190188
@pytest.mark.group(1)
191189
@pytest.mark.abort_on_fail
192190
async def test_restore_on_same_cluster(
193-
ops_test: OpsTest, mysql_charm_series: str, cloud_configs, cloud_credentials
191+
ops_test: OpsTest, cloud_configs, cloud_credentials
194192
) -> None:
195193
"""Test to restore a backup to the same mysql cluster."""
196-
mysql_application_name = await deploy_and_scale_mysql(ops_test, mysql_charm_series)
194+
mysql_application_name = await deploy_and_scale_mysql(ops_test)
197195

198196
logger.info("Scaling mysql application to 1 unit")
199197
async with ops_test.fast_forward():
@@ -281,15 +279,12 @@ async def test_restore_on_same_cluster(
281279

282280
@pytest.mark.group(1)
283281
@pytest.mark.abort_on_fail
284-
async def test_restore_on_new_cluster(
285-
ops_test: OpsTest, mysql_charm_series: str, cloud_configs, cloud_credentials
286-
) -> None:
282+
async def test_restore_on_new_cluster(ops_test: OpsTest, cloud_configs, cloud_credentials) -> None:
287283
"""Test to restore a backup on a new mysql cluster."""
288284
logger.info("Deploying a new mysql cluster")
289285

290286
new_mysql_application_name = await deploy_and_scale_mysql(
291287
ops_test,
292-
mysql_charm_series,
293288
check_for_existing_application=False,
294289
mysql_application_name="another-mysql",
295290
num_units=1,

‎tests/integration/test_subordinate_charms.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,14 @@
1414

1515

1616
@pytest.mark.group(1)
17-
async def test_ubuntu_pro(ops_test, mysql_charm_series, github_secrets):
17+
async def test_ubuntu_pro(ops_test, github_secrets):
1818
db_charm = await ops_test.build_charm(".")
1919
await asyncio.gather(
2020
ops_test.model.deploy(
2121
db_charm,
2222
application_name=DATABASE_APP_NAME,
2323
config={"cluster-name": CLUSTER_NAME, "profile": "testing"},
24-
series=mysql_charm_series,
24+
series="jammy",
2525
),
2626
ops_test.model.deploy(
2727
APPLICATION_APP_NAME,

‎tests/integration/test_tls.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838

3939
@pytest.mark.group(1)
4040
@pytest.mark.abort_on_fail
41-
async def test_build_and_deploy(ops_test: OpsTest, mysql_charm_series: str) -> None:
41+
async def test_build_and_deploy(ops_test: OpsTest) -> None:
4242
"""Build the charm and deploy 3 units to ensure a cluster is formed."""
4343
if app := await app_name(ops_test):
4444
if len(ops_test.model.applications[app].units) == 3:
@@ -54,7 +54,7 @@ async def test_build_and_deploy(ops_test: OpsTest, mysql_charm_series: str) -> N
5454
charm,
5555
application_name=APP_NAME,
5656
num_units=3,
57-
series=mysql_charm_series,
57+
series="jammy",
5858
)
5959

6060
# Reduce the update_status frequency until the cluster is deployed

‎tests/unit/test_mysqlsh_helpers.py

+16-6
Original file line numberDiff line numberDiff line change
@@ -451,22 +451,32 @@ def test_start_mysqld_failure(
451451
self.mysql.start_mysqld()
452452

453453
@patch("os.system")
454-
@patch("pathlib.Path")
454+
@patch("pathlib.Path.touch")
455+
@patch("pathlib.Path.owner")
456+
@patch("pathlib.Path.exists")
455457
@patch("subprocess.check_call")
456458
@patch("subprocess.run")
457459
@patch("os.path.exists", return_value=True)
458460
@patch("mysql_vm_helpers.snap.SnapCache")
459-
def test_install_snap(self, _cache, _path_exists, _run, _check_call, _pathlib, _system):
461+
def test_install_snap(
462+
self,
463+
_cache,
464+
_path_exists,
465+
_run,
466+
_check_call,
467+
_pathlib_exists,
468+
_pathlib_owner,
469+
_touch,
470+
_system,
471+
):
460472
"""Test execution of install_snap()."""
461473
_mysql_snap = MagicMock()
462474
_cache.return_value = {CHARMED_MYSQL_SNAP_NAME: _mysql_snap}
463475

464-
common_path_mock = MagicMock()
465-
466476
_mysql_snap.present = False
467477
_path_exists.return_value = False
468-
_pathlib.return_value = common_path_mock
469-
common_path_mock.exists.return_value = False
478+
_pathlib_exists.return_value = False
479+
_pathlib_owner.return_value = None
470480

471481
self.mysql.install_and_configure_mysql_dependencies()
472482

0 commit comments

Comments
 (0)
Please sign in to comment.