Skip to content

Commit 6821b27

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

22 files changed

+128
-188
lines changed

charmcraft.yaml

Lines changed: 8 additions & 9 deletions
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

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

src/constants.py

Lines changed: 0 additions & 1 deletion
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

Lines changed: 6 additions & 5 deletions
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

Lines changed: 0 additions & 27 deletions
This file was deleted.

tests/integration/conftest.py

Lines changed: 0 additions & 32 deletions
This file was deleted.

tests/integration/high_availability/high_availability_helpers.py

Lines changed: 3 additions & 8 deletions
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

Lines changed: 17 additions & 19 deletions
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

Lines changed: 14 additions & 18 deletions
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

0 commit comments

Comments
 (0)