Skip to content
This repository was archived by the owner on Aug 9, 2024. It is now read-only.

Commit

Permalink
test: remove unneeded slurmd deployment on tests
Browse files Browse the repository at this point in the history
We don't really need to deploy against slurmd to check that slurmrestd works. This saves some CI time.
  • Loading branch information
jedel1043 committed Jul 17, 2024
1 parent 19e1e4e commit 97c8b51
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 42 deletions.
27 changes: 0 additions & 27 deletions tests/integration/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,10 @@
from typing import Union

import pytest
from helpers import NHC
from pytest_operator.plugin import OpsTest

logger = logging.getLogger(__name__)
SLURMCTLD_DIR = Path(os.getenv("SLURMCTLD_DIR", "../slurmctld-operator"))
SLURMD_DIR = Path(os.getenv("SLURMD_DIR", "../slurmd-operator"))
SLURMDBD_DIR = Path(os.getenv("SLURMDBD_DIR", "../slurmdbd-operator"))


Expand Down Expand Up @@ -77,26 +75,6 @@ async def slurmctld_charm(request, ops_test: OpsTest) -> Union[str, Path]:
return "slurmctld"


@pytest.fixture(scope="module")
async def slurmd_charm(request, ops_test: OpsTest) -> Union[str, Path]:
"""Pack slurmd charm to use for integration tests when --use-local is specified.
Returns:
`str` "slurmd" if --use-local not specified or if SLURMD_DIR does not exist.
"""
if request.config.option.use_local:
logger.info("Using local slurmd operator rather than pulling from Charmhub")
if SLURMD_DIR.exists():
return await ops_test.build_charm(SLURMD_DIR)
else:
logger.warning(
f"{SLURMD_DIR} not found. "
f"Defaulting to latest/edge slurmd operator from Charmhub"
)

return "slurmd"


@pytest.fixture(scope="module")
async def slurmdbd_charm(request, ops_test: OpsTest) -> Union[str, Path]:
"""Pack slurmdbd charm to use for integration tests when --use-local is specified.
Expand All @@ -115,8 +93,3 @@ async def slurmdbd_charm(request, ops_test: OpsTest) -> Union[str, Path]:
)

return "slurmdbd"


def pytest_sessionfinish(session, exitstatus) -> None:
"""Clean up repository after test session has completed."""
Path(NHC).unlink(missing_ok=True)
18 changes: 3 additions & 15 deletions tests/integration/test_charm.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
logger = logging.getLogger(__name__)

SLURMCTLD = "slurmctld"
SLURMD = "slurmd"
SLURMDBD = "slurmdbd"
SLURMRESTD = "slurmrestd"
DATABASE = "mysql"
Expand All @@ -41,16 +40,13 @@ async def test_build_and_deploy(
charm_base: str,
slurmrestd_charm,
slurmctld_charm,
slurmd_charm,
slurmdbd_charm,
) -> None:
"""Test that the slurmrestd charm can stabilize against slurmctld, slurmd, and slurmdbd."""
logger.info(
f"Deploying {SLURMRESTD} against {SLURMCTLD}, {SLURMD}, {SLURMDBD}, and {DATABASE}"
)
logger.info(f"Deploying {SLURMRESTD} against {SLURMCTLD}, {SLURMDBD}, and {DATABASE}")
# Pack charms and download NHC resource for slurmd operator.
slurmrestd, slurmctld, slurmd_res, slurmd, slurmdbd = await asyncio.gather(
slurmrestd_charm, slurmctld_charm, slurmd_charm, slurmdbd_charm
slurmrestd, slurmctld, slurmdbd = await asyncio.gather(
slurmrestd_charm, slurmctld_charm, slurmdbd_charm
)
# Deploy the test Charmed SLURM cloud.
await asyncio.gather(
Expand All @@ -67,13 +63,6 @@ async def test_build_and_deploy(
num_units=1,
base=charm_base,
),
ops_test.model.deploy(
str(slurmd),
application_name=SLURMD,
channel="edge" if isinstance(slurmd, str) else None,
num_units=1,
base=charm_base,
),
ops_test.model.deploy(
str(slurmdbd),
application_name=SLURMDBD,
Expand Down Expand Up @@ -101,7 +90,6 @@ async def test_build_and_deploy(
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}:{SLURMCTLD}", f"{SLURMCTLD}:{SLURMRESTD}")
await ops_test.model.integrate(f"{SLURMD}:{SLURMCTLD}", 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)
Expand Down

0 comments on commit 97c8b51

Please sign in to comment.