Skip to content

Commit

Permalink
Build & release arm64 (#472)
Browse files Browse the repository at this point in the history
  • Loading branch information
carlcsaposs-canonical authored Jul 1, 2024
1 parent 3468102 commit 6821b27
Show file tree
Hide file tree
Showing 22 changed files with 128 additions and 188 deletions.
17 changes: 8 additions & 9 deletions charmcraft.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,12 @@

type: charm
bases:
# Whenever "bases" is changed:
# - Update tests/integration/conftest.py::pytest_configure()
# - Update .github/workflow/ci.yaml integration-test matrix
- build-on:
- name: "ubuntu"
channel: "22.04"
run-on:
- name: "ubuntu"
channel: "22.04"
- name: ubuntu
channel: "22.04"
architectures: [amd64]
- name: ubuntu
channel: "22.04"
architectures: [arm64]
parts:
charm:
override-pull: |
Expand All @@ -22,6 +19,8 @@ parts:
exit 1
fi
charm-strict-dependencies: true
prime:
- snap_revisions.json
build-packages:
- libffi-dev
- libssl-dev
Expand Down
4 changes: 4 additions & 0 deletions snap_revisions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"x86_64": "106",
"aarch64": "107"
}
1 change: 0 additions & 1 deletion src/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
TLS_SSL_CERT_FILE = "custom-server-cert.pem"
MYSQL_EXPORTER_PORT = 9104
CHARMED_MYSQL_SNAP_NAME = "charmed-mysql"
CHARMED_MYSQL_SNAP_REVISION = 105 # MySQL v8.0.37
CHARMED_MYSQLD_EXPORTER_SERVICE = "mysqld-exporter"
CHARMED_MYSQLD_SERVICE = "mysqld"
CHARMED_MYSQL = "charmed-mysql.mysql"
Expand Down
11 changes: 6 additions & 5 deletions src/mysql_vm_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@

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

import json
import logging
import os
import pathlib
import platform
import shutil
import subprocess
import tempfile
Expand Down Expand Up @@ -35,7 +37,6 @@
CHARMED_MYSQL,
CHARMED_MYSQL_COMMON_DIRECTORY,
CHARMED_MYSQL_SNAP_NAME,
CHARMED_MYSQL_SNAP_REVISION,
CHARMED_MYSQL_XBCLOUD_LOCATION,
CHARMED_MYSQL_XBSTREAM_LOCATION,
CHARMED_MYSQL_XTRABACKUP_LOCATION,
Expand Down Expand Up @@ -167,10 +168,10 @@ def install_and_configure_mysql_dependencies() -> None:

try:
# install the charmed-mysql snap
logger.debug(
f"Installing {CHARMED_MYSQL_SNAP_NAME} revision {CHARMED_MYSQL_SNAP_REVISION}"
)
charmed_mysql.ensure(snap.SnapState.Present, revision=str(CHARMED_MYSQL_SNAP_REVISION))
with pathlib.Path("snap_revisions.json").open("r") as file:
revision = json.load(file)[platform.machine()]
logger.debug(f"Installing {CHARMED_MYSQL_SNAP_NAME} revision {revision}")
charmed_mysql.ensure(snap.SnapState.Present, revision=revision)
if not charmed_mysql.held:
# hold the snap in charm determined revision
charmed_mysql.hold()
Expand Down
27 changes: 0 additions & 27 deletions tests/conftest.py

This file was deleted.

32 changes: 0 additions & 32 deletions tests/integration/conftest.py

This file was deleted.

11 changes: 3 additions & 8 deletions tests/integration/high_availability/high_availability_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,6 @@ async def ensure_n_online_mysql_members(

async def deploy_and_scale_mysql(
ops_test: OpsTest,
mysql_charm_series: str,
check_for_existing_application: bool = True,
mysql_application_name: str = MYSQL_DEFAULT_APP_NAME,
num_units: int = 3,
Expand All @@ -119,7 +118,6 @@ async def deploy_and_scale_mysql(
Args:
ops_test: The ops test framework
mysql_charm_series: series to test on
check_for_existing_application: Whether to check for existing mysql applications
in the model
mysql_application_name: The name of the mysql application if it is to be deployed
Expand All @@ -144,7 +142,7 @@ async def deploy_and_scale_mysql(
application_name=mysql_application_name,
config=config,
num_units=num_units,
series=mysql_charm_series,
series="jammy",
)

await ops_test.model.wait_for_idle(
Expand Down Expand Up @@ -219,16 +217,13 @@ async def relate_mysql_and_application(
)


async def high_availability_test_setup(
ops_test: OpsTest, mysql_charm_series: str
) -> Tuple[str, str]:
async def high_availability_test_setup(ops_test: OpsTest) -> Tuple[str, str]:
"""Run the set up for high availability tests.
Args:
ops_test: The ops test framework
mysql_charm_series: Series to run mysql charm (defaults to focal)
"""
mysql_application_name = await deploy_and_scale_mysql(ops_test, mysql_charm_series)
mysql_application_name = await deploy_and_scale_mysql(ops_test)
application_name = await deploy_and_scale_application(ops_test)

await relate_mysql_and_application(ops_test, mysql_application_name, application_name)
Expand Down
36 changes: 17 additions & 19 deletions tests/integration/high_availability/test_replication.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,16 +48,16 @@

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


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

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

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

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

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

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

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

await ensure_all_units_continuous_writes_incrementing(ops_test)
Expand Down Expand Up @@ -198,10 +196,10 @@ async def test_kill_primary_check_reelection(ops_test: OpsTest, mysql_charm_seri

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

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


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

# Build and deploy secondary charm
Expand All @@ -292,7 +290,7 @@ async def test_cluster_isolation(ops_test: OpsTest, mysql_charm_series: str) ->
charm,
application_name=ANOTHER_APP_NAME,
num_units=1,
series=mysql_charm_series,
series="jammy",
)
async with ops_test.fast_forward("60s"):
await ops_test.model.block_until(
Expand Down Expand Up @@ -358,9 +356,9 @@ async def test_cluster_isolation(ops_test: OpsTest, mysql_charm_series: str) ->

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

# Exclude slowquery log files as slowquery logs are not enabled by default
Expand Down
32 changes: 14 additions & 18 deletions tests/integration/high_availability/test_self_healing.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,18 +49,16 @@

@pytest.mark.group(1)
@pytest.mark.abort_on_fail
async def test_build_and_deploy(ops_test: OpsTest, mysql_charm_series: str) -> None:
async def test_build_and_deploy(ops_test: OpsTest) -> None:
"""Build and deploy."""
await high_availability_test_setup(ops_test, mysql_charm_series)
await high_availability_test_setup(ops_test)


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

await ensure_all_units_continuous_writes_incrementing(ops_test)

Expand Down Expand Up @@ -97,9 +95,9 @@ async def test_kill_db_process(

@pytest.mark.group(1)
@pytest.mark.abort_on_fail
async def test_freeze_db_process(ops_test: OpsTest, continuous_writes, mysql_charm_series: str):
async def test_freeze_db_process(ops_test: OpsTest, continuous_writes):
"""Freeze and unfreeze process and check for auto cluster recovery."""
mysql_application_name, _ = await high_availability_test_setup(ops_test, mysql_charm_series)
mysql_application_name, _ = await high_availability_test_setup(ops_test)
# ensure continuous writes still incrementing for all units
await ensure_all_units_continuous_writes_incrementing(ops_test)

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

@pytest.mark.group(1)
@pytest.mark.abort_on_fail
async def test_network_cut(ops_test: OpsTest, continuous_writes, mysql_charm_series: str):
async def test_network_cut(ops_test: OpsTest, continuous_writes):
"""Completely cut and restore network."""
mysql_application_name, _ = await high_availability_test_setup(ops_test, mysql_charm_series)
mysql_application_name, _ = await high_availability_test_setup(ops_test)
primary_unit = await get_primary_unit_wrapper(ops_test, mysql_application_name)
all_units = ops_test.model.applications[mysql_application_name].units

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

@pytest.mark.group(1)
@pytest.mark.abort_on_fail
async def test_replicate_data_on_restart(
ops_test: OpsTest, continuous_writes, mysql_charm_series: str
):
async def test_replicate_data_on_restart(ops_test: OpsTest, continuous_writes):
"""Stop server, write data, start and validate replication."""
mysql_application_name, _ = await high_availability_test_setup(ops_test, mysql_charm_series)
mysql_application_name, _ = await high_availability_test_setup(ops_test)

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

@pytest.mark.group(1)
@pytest.mark.abort_on_fail
async def test_cluster_pause(ops_test: OpsTest, continuous_writes, mysql_charm_series: str):
async def test_cluster_pause(ops_test: OpsTest, continuous_writes):
"""Pause test.
A graceful simultaneous restart of all instances,
check primary election after the start, write and read data
"""
mysql_application_name, _ = await high_availability_test_setup(ops_test, mysql_charm_series)
mysql_application_name, _ = await high_availability_test_setup(ops_test)
all_units = ops_test.model.applications[mysql_application_name].units

config = {
Expand Down Expand Up @@ -374,12 +370,12 @@ async def test_cluster_pause(ops_test: OpsTest, continuous_writes, mysql_charm_s

@pytest.mark.group(1)
@pytest.mark.abort_on_fail
async def test_sst_test(ops_test: OpsTest, continuous_writes, mysql_charm_series: str):
async def test_sst_test(ops_test: OpsTest, continuous_writes):
"""The SST test.
A forceful restart instance with deleted data and without transaction logs (forced clone).
"""
mysql_application_name, _ = await high_availability_test_setup(ops_test, mysql_charm_series)
mysql_application_name, _ = await high_availability_test_setup(ops_test)
primary_unit = await get_primary_unit_wrapper(ops_test, mysql_application_name)
server_config_password = await get_system_user_password(primary_unit, SERVER_CONFIG_USERNAME)
all_units = ops_test.model.applications[mysql_application_name].units
Expand Down
Loading

0 comments on commit 6821b27

Please sign in to comment.