This repository has been archived by the owner on Aug 9, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #10 from canonical/upgrade-jammy
Add support for Ubuntu 22.04: part 2
- Loading branch information
Showing
5 changed files
with
54 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -53,7 +53,13 @@ jobs: | |
run: tox -e unit | ||
|
||
integration-test: | ||
name: Integration tests (LXD) | ||
strategy: | ||
fail-fast: true | ||
matrix: | ||
bases: | ||
- [email protected] | ||
- [email protected] | ||
name: Integration tests (LXD) | ${{ matrix.bases }} | ||
runs-on: ubuntu-latest | ||
needs: | ||
- inclusive-naming-check | ||
|
@@ -68,4 +74,4 @@ jobs: | |
provider: lxd | ||
juju-channel: 3.1/stable | ||
- name: Run tests | ||
run: tox -e integration | ||
run: tox run -e integration -- --charm-base=${{ matrix.bases }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,12 +17,25 @@ | |
|
||
import pathlib | ||
|
||
import pytest | ||
from _pytest.config.argparsing import Parser | ||
from helpers import ETCD, NHC, VERSION | ||
from pytest import fixture | ||
from pytest_operator.plugin import OpsTest | ||
|
||
|
||
@fixture(scope="module") | ||
def pytest_addoption(parser: Parser) -> None: | ||
parser.addoption( | ||
"--charm-base", action="store", default="[email protected]", help="Charm base to test." | ||
) | ||
|
||
|
||
@pytest.fixture(scope="module") | ||
def charm_base(request) -> str: | ||
"""Get slurmdbd charm base to use.""" | ||
return request.config.getoption("--charm-base") | ||
|
||
|
||
@pytest.fixture(scope="module") | ||
async def slurmrestd_charm(ops_test: OpsTest): | ||
"""Slurmrestd charm used for integration testing.""" | ||
charm = await ops_test.build_charm(".") | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,7 +27,6 @@ | |
|
||
logger = logging.getLogger(__name__) | ||
|
||
SERIES = ["focal"] | ||
SLURMCTLD = "slurmctld" | ||
SLURMD = "slurmd" | ||
SLURMDBD = "slurmdbd" | ||
|
@@ -38,14 +37,13 @@ | |
|
||
@pytest.mark.abort_on_fail | ||
@pytest.mark.skip_if_deployed | ||
@pytest.mark.parametrize("series", SERIES) | ||
@pytest.mark.order(1) | ||
async def test_build_and_deploy( | ||
ops_test: OpsTest, slurmrestd_charm: Coroutine[Any, Any, pathlib.Path], series: str | ||
ops_test: OpsTest, slurmrestd_charm: Coroutine[Any, Any, pathlib.Path], charm_base: str | ||
) -> None: | ||
"""Deploy minimal working slurmrestd charm.""" | ||
res_slurmd = get_slurmd_res() | ||
res_slurmctld = get_slurmctld_res() | ||
|
||
await asyncio.gather( | ||
# Fetch from charmhub slurmctld | ||
ops_test.model.deploy( | ||
|
@@ -54,68 +52,69 @@ async def test_build_and_deploy( | |
channel="edge", | ||
num_units=1, | ||
resources=res_slurmctld, | ||
series=series, | ||
base=charm_base, | ||
), | ||
ops_test.model.deploy( | ||
SLURMD, | ||
application_name=SLURMD, | ||
channel="edge", | ||
num_units=1, | ||
resources=res_slurmd, | ||
series=series, | ||
base=charm_base, | ||
), | ||
ops_test.model.deploy( | ||
SLURMDBD, | ||
application_name=SLURMDBD, | ||
channel="edge", | ||
num_units=1, | ||
series=series, | ||
base=charm_base, | ||
), | ||
ops_test.model.deploy( | ||
str(await slurmrestd_charm), | ||
application_name=SLURMRESTD, | ||
num_units=1, | ||
series=series, | ||
base=charm_base, | ||
), | ||
ops_test.model.deploy( | ||
ROUTER, | ||
application_name=f"{SLURMDBD}-{ROUTER}", | ||
channel="dpe/edge", | ||
num_units=1, | ||
series=series, | ||
num_units=0, | ||
base=charm_base, | ||
), | ||
ops_test.model.deploy( | ||
DATABASE, | ||
application_name=DATABASE, | ||
channel="edge", | ||
channel="8.0/edge", | ||
num_units=1, | ||
series="jammy", | ||
base="[email protected]", | ||
), | ||
) | ||
# Attach resources to charms. | ||
await ops_test.juju("attach-resource", SLURMCTLD, f"etcd={res_slurmctld['etcd']}") | ||
await ops_test.juju("attach-resource", SLURMD, f"nhc={res_slurmd['nhc']}") | ||
# Set relations for charmed applications. | ||
await ops_test.model.relate(f"{SLURMCTLD}:{SLURMDBD}", f"{SLURMDBD}:{SLURMDBD}") | ||
await ops_test.model.relate(f"{SLURMDBD}-{ROUTER}:backend-database", f"{DATABASE}:database") | ||
await ops_test.model.relate(f"{SLURMDBD}:database", f"{SLURMDBD}-{ROUTER}:database") | ||
await ops_test.model.relate(f"{SLURMRESTD}:slurmrestd", f"{SLURMCTLD}:slurmrestd") | ||
await ops_test.model.add_relation(f"{SLURMD}:{SLURMD}", f"{SLURMCTLD}:{SLURMD}") | ||
await ops_test.model.integrate(f"{SLURMCTLD}:{SLURMDBD}", f"{SLURMDBD}:{SLURMDBD}") | ||
await ops_test.model.integrate(f"{SLURMDBD}-{ROUTER}:backend-database", f"{DATABASE}:database") | ||
await ops_test.model.integrate(f"{SLURMDBD}:database", f"{SLURMDBD}-{ROUTER}:database") | ||
await ops_test.model.integrate(f"{SLURMRESTD}:slurmrestd", f"{SLURMCTLD}:slurmrestd") | ||
await ops_test.model.integrate(f"{SLURMD}:{SLURMD}", f"{SLURMCTLD}:{SLURMD}") | ||
# Reduce the update status frequency to accelerate the triggering of deferred events. | ||
async with ops_test.fast_forward(): | ||
await ops_test.model.wait_for_idle(apps=[SLURMRESTD], status="active", timeout=1000) | ||
assert ops_test.model.applications[SLURMRESTD].units[0].workload_status == "active" | ||
|
||
|
||
@pytest.mark.abort_on_fail | ||
@pytest.mark.order(2) | ||
@tenacity.retry( | ||
wait=tenacity.wait.wait_exponential(multiplier=2, min=1, max=30), | ||
stop=tenacity.stop_after_attempt(3), | ||
reraise=True, | ||
) | ||
async def test_munge_is_active(ops_test: OpsTest) -> None: | ||
"""Test that munge is active.""" | ||
logger.info("Checking that munge is active inside Juju unit...") | ||
logger.info("Checking that munge is active inside Juju unit") | ||
slurmctld_unit = ops_test.model.applications[SLURMCTLD].units[0] | ||
res = (await slurmctld_unit.ssh("systemctl is-active munge")).strip("\n") | ||
assert res == "active" | ||
|
@@ -125,14 +124,15 @@ async def test_munge_is_active(ops_test: OpsTest) -> None: | |
# systemd service failing. Error is "unable to get address" and "Temporary failure in | ||
# name resolution". | ||
@pytest.mark.xfail | ||
@pytest.mark.order(3) | ||
@tenacity.retry( | ||
wait=tenacity.wait.wait_exponential(multiplier=2, min=1, max=30), | ||
stop=tenacity.stop_after_attempt(3), | ||
reraise=True, | ||
) | ||
async def test_slurmrestd_is_active(ops_test: OpsTest) -> None: | ||
"""Test that slurmrestd is active.""" | ||
logger.info("Checking that slurmrestd is active inside Juju unit...") | ||
logger.info("Checking that slurmrestd is active inside Juju unit") | ||
unit = ops_test.model.applications[SLURMRESTD].units[0] | ||
cmd_res = (await unit.ssh("systemctl is-active slurmrestd")).strip("\n") | ||
assert cmd_res == "active" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters