Skip to content

Commit fc4fcba

Browse files
Make release tests parallelizable
1 parent ef5671e commit fc4fcba

File tree

9 files changed

+115
-79
lines changed

9 files changed

+115
-79
lines changed

tests/integration/release/high_availability/conftest.py

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

tests/integration/release/high_availability/high_availability_helpers.py

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -148,33 +148,6 @@ async def get_mysql_max_written_value(juju: Juju, app_name: str, unit_name: str)
148148
return output[0]
149149

150150

151-
async def get_mysql_variable_value(
152-
juju: Juju, app_name: str, unit_name: str, variable_name: str
153-
) -> str:
154-
"""Retrieve a database variable value as a string.
155-
156-
Args:
157-
juju: The Juju model.
158-
app_name: The application name.
159-
unit_name: The unit name.
160-
variable_name: The variable name.
161-
"""
162-
credentials_task = juju.run(
163-
unit=unit_name,
164-
action="get-password",
165-
params={"username": SERVER_CONFIG_USERNAME},
166-
)
167-
credentials_task.raise_on_failure()
168-
169-
output = await execute_queries_on_unit(
170-
get_unit_ip(juju, app_name, unit_name),
171-
credentials_task.results["username"],
172-
credentials_task.results["password"],
173-
[f"SELECT @@{variable_name};"],
174-
)
175-
return output[0]
176-
177-
178151
def wait_for_apps_status(jubilant_status_func: JujuAppsStatusFn, *apps: str) -> JujuModelStatusFn:
179152
"""Waits for Juju agents to be idle, and for applications to reach a certain status.
180153

tests/integration/release/high_availability/test_upgrade_from_stable.py

Lines changed: 59 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,19 @@
22
# See LICENSE file for licensing details.
33

44
import logging
5+
import os
6+
from collections.abc import Generator
7+
from contextlib import contextmanager
58

69
import jubilant_backports
710
import pytest
811
from jubilant_backports import Juju
912

13+
from ... import architecture, markers
1014
from .high_availability_helpers import (
1115
check_mysql_units_writes_increment,
1216
get_app_leader,
13-
get_app_units,
1417
get_mysql_primary_unit,
15-
get_mysql_variable_value,
1618
wait_for_apps_status,
1719
)
1820

@@ -24,16 +26,63 @@
2426
logging.getLogger("jubilant.wait").setLevel(logging.WARNING)
2527

2628

27-
@pytest.mark.abort_on_fail
28-
def test_deploy_stable(juju: Juju) -> None:
29-
"""Simple test to ensure that the MySQL and application charms get deployed."""
29+
@contextmanager
30+
def continuous_writes(juju: Juju) -> Generator:
31+
"""Starts continuous writes to the MySQL cluster for a test and clear the writes at the end."""
32+
test_app_leader = get_app_leader(juju, MYSQL_TEST_APP_NAME)
33+
34+
logging.info("Clearing continuous writes")
35+
juju.run(test_app_leader, "clear-continuous-writes")
36+
logging.info("Starting continuous writes")
37+
juju.run(test_app_leader, "start-continuous-writes")
38+
39+
yield
40+
41+
logging.info("Clearing continuous writes")
42+
juju.run(test_app_leader, "clear-continuous-writes")
43+
44+
45+
@markers.amd64_only
46+
def test_upgrade_from_stable_amd(juju: Juju, charm: str):
47+
"""Simple test to ensure that all MySQL stable revisions can be upgraded."""
48+
revision = os.getenv("CHARM_REVISION_AMD64")
49+
if revision is None:
50+
pytest.skip(f"No revision for {architecture.architecture} architecture")
51+
52+
deploy_stable(juju, int(revision))
53+
run_upgrade_check(juju)
54+
55+
with continuous_writes(juju):
56+
upgrade_from_stable(juju, charm)
57+
58+
59+
@markers.arm64_only
60+
def test_upgrade_from_stable_arm(juju: Juju, charm: str):
61+
"""Simple test to ensure that all MySQL stable revisions can be upgraded."""
62+
revision = os.getenv("CHARM_REVISION_ARM64")
63+
if revision is None:
64+
pytest.skip(f"No revision for {architecture.architecture} architecture")
65+
66+
deploy_stable(juju, int(revision))
67+
run_upgrade_check(juju)
68+
69+
with continuous_writes(juju):
70+
upgrade_from_stable(juju, charm)
71+
72+
73+
# TODO: add s390x test
74+
75+
76+
def deploy_stable(juju: Juju, revision: int) -> None:
77+
"""Ensure that the MySQL and application charms get deployed."""
3078
logging.info("Deploying MySQL cluster")
3179
juju.deploy(
3280
charm=MYSQL_APP_NAME,
3381
app=MYSQL_APP_NAME,
3482
3583
channel="8.0/stable",
36-
config={"profile": "testing"},
84+
config={"profile": "testing"} if revision >= 196 else {},
85+
revision=revision,
3786
num_units=3,
3887
)
3988
juju.deploy(
@@ -59,31 +108,21 @@ def test_deploy_stable(juju: Juju) -> None:
59108
)
60109

61110

62-
@pytest.mark.abort_on_fail
63-
async def test_pre_upgrade_check(juju: Juju) -> None:
64-
"""Test that the pre-upgrade-check action runs successfully."""
111+
async def run_upgrade_check(juju: Juju) -> None:
112+
"""Run the pre-upgrade-check action runs successfully."""
65113
mysql_leader = get_app_leader(juju, MYSQL_APP_NAME)
66-
mysql_units = get_app_units(juju, MYSQL_APP_NAME)
67114

68115
logging.info("Run pre-upgrade-check action")
69116
task = juju.run(unit=mysql_leader, action="pre-upgrade-check")
70117
task.raise_on_failure()
71118

72-
logging.info("Assert slow shutdown is enabled")
73-
for unit_name in mysql_units:
74-
value = await get_mysql_variable_value(
75-
juju, MYSQL_APP_NAME, unit_name, "innodb_fast_shutdown"
76-
)
77-
assert value == 0
78-
79119
logging.info("Assert primary is set to leader")
80120
mysql_primary = get_mysql_primary_unit(juju, MYSQL_APP_NAME)
81121
assert mysql_primary == mysql_leader, "Primary unit not set to leader"
82122

83123

84-
@pytest.mark.abort_on_fail
85-
async def test_upgrade_from_stable(juju: Juju, charm: str, continuous_writes) -> None:
86-
"""Update the second cluster."""
124+
async def upgrade_from_stable(juju: Juju, charm: str) -> None:
125+
"""Update the cluster."""
87126
logging.info("Ensure continuous writes are incrementing")
88127
await check_mysql_units_writes_increment(juju, MYSQL_APP_NAME)
89128

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
summary: test_upgrade_from_stable.py
2+
environment:
3+
TEST_MODULE: high_availability/test_upgrade_from_stable.py
4+
CHARM_REVISION_AMD64: 151
5+
CHARM_REVISION_ARM64:
6+
execute: |
7+
tox run -e integration -- "tests/integration/release/$TEST_MODULE" --model testing --alluredir="$SPREAD_TASK/allure-results"
8+
artifacts:
9+
- allure-results
10+
backends:
11+
- -lxd-vm # This task requires charm built on different architecture from host
12+
systems:
13+
- -ubuntu-24.04-arm
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
summary: test_upgrade_from_stable.py
2+
environment:
3+
TEST_MODULE: high_availability/test_upgrade_from_stable.py
4+
CHARM_REVISION_AMD64: 196
5+
CHARM_REVISION_ARM64:
6+
execute: |
7+
tox run -e integration -- "tests/integration/release/$TEST_MODULE" --model testing --alluredir="$SPREAD_TASK/allure-results"
8+
artifacts:
9+
- allure-results
10+
backends:
11+
- -lxd-vm # This task requires charm built on different architecture from host
12+
systems:
13+
- -ubuntu-24.04-arm
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
summary: test_upgrade_from_stable.py
2+
environment:
3+
TEST_MODULE: high_availability/test_upgrade_from_stable.py
4+
CHARM_REVISION_AMD64: 240
5+
CHARM_REVISION_ARM64:
6+
execute: |
7+
tox run -e integration -- "tests/integration/release/$TEST_MODULE" --model testing --alluredir="$SPREAD_TASK/allure-results"
8+
artifacts:
9+
- allure-results
10+
backends:
11+
- -lxd-vm # This task requires charm built on different architecture from host
12+
systems:
13+
- -ubuntu-24.04-arm
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
summary: test_upgrade_from_stable.py
22
environment:
33
TEST_MODULE: high_availability/test_upgrade_from_stable.py
4+
CHARM_REVISION_AMD64: 313
5+
CHARM_REVISION_ARM64: 312
46
execute: |
57
tox run -e integration -- "tests/integration/release/$TEST_MODULE" --model testing --alluredir="$SPREAD_TASK/allure-results"
68
artifacts:
79
- allure-results
10+
backends:
11+
- -lxd-vm # This task requires charm built on different architecture from host
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
summary: test_upgrade_from_stable.py
2+
environment:
3+
TEST_MODULE: high_availability/test_upgrade_from_stable.py
4+
CHARM_REVISION_AMD64: 366
5+
CHARM_REVISION_ARM64: 367
6+
execute: |
7+
tox run -e integration -- "tests/integration/release/$TEST_MODULE" --model testing --alluredir="$SPREAD_TASK/allure-results"
8+
artifacts:
9+
- allure-results
10+
backends:
11+
- -lxd-vm # This task requires charm built on different architecture from host

tox.ini

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,8 @@ commands =
7070
description = Run integration tests
7171
pass_env =
7272
CI
73+
CHARM_REVISION_AMD64
74+
CHARM_REVISION_ARM64
7375
AWS_ACCESS_KEY
7476
AWS_SECRET_KEY
7577
GCP_ACCESS_KEY

0 commit comments

Comments
 (0)