Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 12 additions & 3 deletions azure-slurm/test/slurmcc_test/allocation_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
from . import testutil

import logging
import pytest
import sys
logging.basicConfig(level=logging.DEBUG, format="%(message)s", stream=sys.stderr)

Expand Down Expand Up @@ -93,8 +94,18 @@ def test_mixed_resume_names() -> None:
assert len(bootup_result.nodes) == 2
assert node_list == [n.name for n in bootup_result.nodes]



@pytest.fixture(autouse=True)
def mock_is_slurmctld_up() -> None:
implementation = slutil.is_slurmctld_up
slutil.is_slurmctld_up = lambda: True
yield
slutil.is_slurmctld_up = implementation


def test_resume_dynamic_by_feature() -> None:


node_mgr = testutil.make_test_node_manager()
bindings: MockClusterBinding = node_mgr.cluster_bindings # type: ignore
native_cli = testutil.make_native_cli()
Expand Down Expand Up @@ -130,8 +141,6 @@ def test_resume_dynamic_by_feature() -> None:
assert 2 == len(result.nodes)




def test_failure_mode() -> None:
node_mgr = testutil.make_test_node_manager()
bindings: MockClusterBinding = node_mgr.cluster_bindings # type: ignore
Expand Down
12 changes: 6 additions & 6 deletions azure-slurm/test/slurmcc_test/cli_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def make_partition(
use_pcpu: bool = True,
slurm_memory: str = "",
dampen_memory: Optional[float] = None,
dynamic_config: str = "",
dynamic_feature: str = "",
) -> Partition:
resources = {"slurm_memory": Memory.value_of(slurm_memory)} if slurm_memory else {}
node_def = NodeDefinition(
Expand Down Expand Up @@ -64,7 +64,7 @@ def make_partition(
[bucket],
100,
use_pcpu,
dynamic_config,
dynamic_feature,
{},
["Standard_f4"],
dampen_memory,
Expand All @@ -76,7 +76,7 @@ def test_partitions() -> None:
partitions = [
make_partition("htc", False, False),
make_partition("hpc", True, True),
make_partition("dynamic", False, False, dynamic_config="-Z Feature=dyn"),
make_partition("dynamic", False, False, dynamic_feature="dyn"),
]

# Define neither slurm_memory nor dampen_memory, autoscale=true
Expand Down Expand Up @@ -123,7 +123,7 @@ def test_partitions() -> None:
make_partition("htc", False, False, slurm_memory="15g"),
make_partition("hpc", True, True, slurm_memory="14g"),
make_partition(
"dynamic", False, False, dynamic_config="-Z Feature=dyn", slurm_memory="13g"
"dynamic", False, False, dynamic_feature="dyn", slurm_memory="13g"
),
]
# No slurm.dampen_memory or slurm_memory resource, autoscale=FALSE
Expand Down Expand Up @@ -151,7 +151,7 @@ def test_partitions() -> None:
"dynamic",
False,
False,
dynamic_config="-Z Feature=dyn",
dynamic_feature="dyn",
slurm_memory="13g",
dampen_memory=0.75,
),
Expand Down Expand Up @@ -181,7 +181,7 @@ def test_partitions() -> None:
"dynamic",
False,
False,
dynamic_config="-Z Feature=dyn",
dynamic_feature="dyn",
slurm_memory="13g",
dampen_memory=0.75,
),
Expand Down
3 changes: 3 additions & 0 deletions azure-slurm/test/slurmcc_test/testutil.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,9 @@ def create_nodes(self, node_names: List[str], features: List[str] = [], partitio
}
clear_caches()

def srun(self, args: List[str], retry: bool = True) -> str:
raise RuntimeError("srun not implemented")


set_slurm_cli(MockNativeSlurmCLI())

Expand Down
4 changes: 2 additions & 2 deletions azure-slurm/test/slurmcc_test/util_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,6 @@ def test_run_function() -> None:

# test case for permissions errors
try:
out=run(['touch', '/root/.test'])
run(['touch', '/root/.test'])
except subprocess.CalledProcessError as e:
assert out.returncode != 0
assert e.returncode != 0