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

Commit

Permalink
snapshot: Initial integration tests and lint fixes (#10)
Browse files Browse the repository at this point in the history
Co-authored-by: dvdgomez <[email protected]>
  • Loading branch information
NucciTheBoss and dvdgomez authored Jan 27, 2023
1 parent a070cc7 commit 9fff6e8
Show file tree
Hide file tree
Showing 7 changed files with 29 additions and 29 deletions.
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/bug_report.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ body:
attributes:
value: >
Thanks for taking the time to fill out this bug report! Before submitting your issue, please make
sure you are using the latest version of the charm. If not, please switch to the lastest version of this charm
sure you are using the latest version of the charm. If not, please switch to the latest version of this charm
before posting your report to make sure it's not already solved.
- type: textarea
id: bug-description
Expand Down
7 changes: 4 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,6 @@
# See the License for the specific language governing permissions and
# limitations under the License.

[tool.codespell]
skip = "./build,./lib,./venv,./icon.svg"

# Testing tools configuration
[tool.coverage.run]
branch = true
Expand All @@ -26,6 +23,10 @@ show_missing = true
minversion = "6.0"
log_cli_level = "INFO"

# Spell checking tools configuration
[tool.codespell]
skip = "build,lib,venv,icon.svg,.tox,.git,.mypy_cache,.ruff_cache,.vscode,.coverage"

# Formatting tools configuration
[tool.black]
line-length = 99
Expand Down
20 changes: 10 additions & 10 deletions src/charm.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ def _check_status(self) -> bool:

def ensure_slurmd_starts(self, max_attemps=10) -> bool:
"""Ensure slurmd is up and running."""
logger.debug("## Stoping slurmd")
logger.debug("## Stopping slurmd")
self._slurm_manager.slurm_systemctl("stop")

for i in range(max_attemps):
Expand Down Expand Up @@ -243,7 +243,7 @@ def _on_slurmctld_available(self, event):

@property
def etcd_use_tls(self) -> bool:
"""Return wether TLS certificates are available."""
"""Return whether TLS certificates are available."""
return bool(self.etcd_tls_cert)

@property
Expand Down Expand Up @@ -393,12 +393,12 @@ def _set_partition_name(self, name: str):
self._slurmd_peer.partition_name = name

def _write_munge_key_and_restart_munge(self):
logger.debug("#### slurmd charm - writting munge key")
logger.debug("#### slurmd charm - writing munge key")

self._slurm_manager.configure_munge_key(self._slurmd.get_stored_munge_key())

if self._slurm_manager.restart_munged():
logger.debug("## Munge restarted succesfully")
logger.debug("## Munge restarted successfully")
else:
logger.error("## Unable to restart munge")

Expand Down Expand Up @@ -460,7 +460,7 @@ def install_infiniband(self, event):
"""Install infiniband."""
logger.debug("#### Installing Infiniband")
self._slurm_manager.infiniband.install()
event.set_results({"installation": "Successfull. Please reboot node."})
event.set_results({"installation": "Successful. Please reboot node."})
self.unit.status = BlockedStatus("Need reboot for Infiniband")

def uninstall_infiniband(self, event):
Expand All @@ -480,7 +480,7 @@ def enable_infiniband(self, event):

def stop_infiniband(self, event):
"""Stop Infiniband systemd service."""
logger.debug("#### Stoping Infiniband service")
logger.debug("#### Stopping Infiniband service")
self._slurm_manager.infiniband.stop()

def is_active_infiniband(self, event):
Expand Down Expand Up @@ -510,7 +510,7 @@ def nvidia_install(self, event):
"""Install nvidia drivers."""
logger.debug("#### Installing nvidia drivers: %s", self._slurm_manager.nvidia.package)
self._slurm_manager.nvidia.install()
event.set_results({"installation": "Successfull. Please reboot node."})
event.set_results({"installation": "Successful. Please reboot node."})
self.unit.status = BlockedStatus("Need reboot for nvidia")

def singularity_install(self, event):
Expand All @@ -525,7 +525,7 @@ def singularity_install(self, event):
resource_path = self.model.resources.fetch(resource_name)
logger.debug(f"#### Found singularity resource: {resource_path}")
self._slurm_manager.singularity.install(resource_path)
event.set_results({"installation": "Successfull."})
event.set_results({"installation": "Successful."})
except ModelError as e:
logger.error(f"## Missing singularity resource - {e}")
event.fail(message=f"Error installing Singularity: {e.output}")
Expand All @@ -535,7 +535,7 @@ def mpi_install(self, event):
self._slurm_manager.mpi.install()

if self._slurm_manager.mpi.installed:
event.set_results({'installation': 'Successfull.'})
event.set_results({"installation": "Successful."})
else:
event.fail(message="Error installing mpich. Check the logs.")

Expand All @@ -551,7 +551,7 @@ def _on_set_partition_info_on_app_relation_data(self, event):
# If the relation with slurmctld exists then set our
# partition info on the application relation data.
# This handler shouldn't fire if the relation isn't made,
# but add this extra check here just incase.
# but add this extra check here just in case.
if self._slurmd.is_joined:
partition = self._assemble_partition()
if partition:
Expand Down
5 changes: 3 additions & 2 deletions tests/integration/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,18 @@

import pathlib

from helpers import ETCD, NHC, VERSION
from pytest import fixture
from pytest_operator.plugin import OpsTest

from helpers import ETCD, NHC, VERSION


@fixture(scope="module")
async def slurmd_charm(ops_test: OpsTest):
"""Build slurmd charm to use for integration tests."""
charm = await ops_test.build_charm(".")
return charm


def pytest_sessionfinish(session, exitstatus) -> None:
"""Clean up repository after test session has completed."""
pathlib.Path(ETCD).unlink(missing_ok=True)
Expand Down
2 changes: 1 addition & 1 deletion tests/integration/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
import pathlib
import shlex
import subprocess

from typing import Dict
from urllib import request

Expand All @@ -46,6 +45,7 @@ def get_slurmctld_res() -> Dict[str, pathlib.Path]:

return {"etcd": etcd}


def get_slurmd_res() -> Dict[str, pathlib.Path]:
"""Get slurmd resources needed for charm deployment."""
if not (nhc := pathlib.Path(NHC)).exists():
Expand Down
19 changes: 7 additions & 12 deletions tests/integration/test_charm.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,13 @@
"""Test slurmd charm against other SLURM charms in the latest/edge channel."""

import asyncio
import pytest

import pytest
from helpers import (
get_slurmd_res,
get_slurmctld_res,
get_slurmd_res,
)

from pathlib import Path
from pytest_operator.plugin import OpsTest
from tenacity import retry
from tenacity.stop import stop_after_attempt
from tenacity.wait import wait_exponential as wexp

SERIES = ["focal"]
SLURMD = "slurmd"
Expand Down Expand Up @@ -85,11 +80,11 @@ async def test_build_and_deploy(ops_test: OpsTest, series: str, slurmd_charm):

# Build and Deploy Slurmd
await ops_test.model.deploy(
str(await slurmd_charm),
application_name=SLURMD,
num_units=1,
resources=res_slurmd,
series=series,
str(await slurmd_charm),
application_name=SLURMD,
num_units=1,
resources=res_slurmd,
series=series,
)

# Attach NHC resource to the slurmd controller
Expand Down
3 changes: 3 additions & 0 deletions tests/unit/test_charm.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,10 @@


class TestCharm(unittest.TestCase):
"""Unit test slurmd charm."""

def setUp(self) -> None:
"""Set up unit test."""
self.harness = Harness(SlurmdCharm)
self.addCleanup(self.harness.cleanup)
self.harness.begin()
Expand Down

0 comments on commit 9fff6e8

Please sign in to comment.