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

Commit

Permalink
refactor: Update tests to use proctrack/linuxproc
Browse files Browse the repository at this point in the history
  • Loading branch information
NucciTheBoss authored and jamesbeedy committed May 31, 2023
1 parent 8d2751a commit 1e18fa9
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 23 deletions.
4 changes: 2 additions & 2 deletions src/charm.py
Original file line number Diff line number Diff line change
Expand Up @@ -405,8 +405,8 @@ def _on_set_partition_info_on_app_relation_data(self, event):
if self._slurmd.is_joined:
if partition := {
"partition_name": self.app.name,
"partition_state": self.config.get("partition-config"),
"partition_config": self.config.get("partition-state"),
"partition_config": self.config.get("partition-config"),
"partition_state": self.config.get("partition-state"),
}:
self._slurmd.set_partition_info_on_app_relation_data(partition)
else:
Expand Down
21 changes: 2 additions & 19 deletions tests/integration/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,40 +16,23 @@

import logging
import pathlib
import shlex
import subprocess
from typing import Dict
from urllib import request

from pylxd import Client

logger = logging.getLogger(__name__)

ETCD = "etcd-v3.5.0-linux-amd64.tar.gz"
ETCD_URL = f"https://github.com/etcd-io/etcd/releases/download/v3.5.0/{ETCD}"
NHC = "lbnl-nhc-1.4.3.tar.gz"
NHC_URL = f"https://github.com/mej/nhc/releases/download/1.4.3/{NHC}"
OVERLAY = "overlay.yaml"
VERSION = "version"
VERSION_NUM = subprocess.run(
shlex.split("git describe --always"), stdout=subprocess.PIPE, text=True
["git", "describe", "--always"], stdout=subprocess.PIPE, text=True
).stdout.strip("\n")


def modify_default_profile() -> None:
"""Modify the default LXD profile.
Notes:
The default profile needs to be modified so that slurmd can
use proctrack/cgroup for process tracking inside an LXD container.
"""
client = Client()
config = {"security.nesting": "true"}
logger.info(f"Updating default LXD profile configuration to {config}")
default = client.profiles.get("default")
default.config.update(config)
default.save()


def get_slurmctld_res() -> Dict[str, pathlib.Path]:
"""Get slurmctld resources needed for charm deployment."""
if not (version := pathlib.Path(VERSION)).exists():
Expand Down
4 changes: 2 additions & 2 deletions tests/integration/test_charm.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
from typing import Any, Coroutine

import pytest
from helpers import get_slurmctld_res, get_slurmd_res, modify_default_profile
from helpers import get_slurmctld_res, get_slurmd_res
from pytest_operator.plugin import OpsTest

logger = logging.getLogger(__name__)
Expand All @@ -41,13 +41,13 @@ async def test_build_and_deploy(
) -> None:
"""Test that the slurmd charm can stabilize against slurmctld, slurmdbd and MySQL."""
logger.info(f"Deploying {SLURMD} against {SLURMCTLD}, {SLURMDBD}, and {DATABASE}")
modify_default_profile()
res_slurmd = get_slurmd_res()
res_slurmctld = get_slurmctld_res()
await asyncio.gather(
ops_test.model.deploy(
SLURMCTLD,
application_name=SLURMCTLD,
config={"proctrack-type": "proctrack/linuxproc"},
channel="edge",
num_units=1,
resources=res_slurmctld,
Expand Down

0 comments on commit 1e18fa9

Please sign in to comment.