Skip to content

SLURM periodic limits tests

Tests for the agent side of periodic limits: receiving a RESOURCE_PERIODIC_LIMITS message and applying it to SLURM through SlurmBackend.apply_periodic_settings — fairshare, GrpTRESMins / MaxTRESMins, and RawUsage=0 resets. The policy calculations that produce those settings live in Waldur Mastermind (SlurmPeriodicUsagePolicy); some tests use a mock of that policy to generate realistic messages, but the agent does not compute or enforce thresholds, carryover or decay itself.

Modules

  • test_periodic_limits_plugin.py — STOMP handler → backend flow with mocked Mastermind signals
  • test_mock_mastermind_signals.py — Messages generated by a mock SlurmPeriodicUsagePolicy, applied by the handler
  • test_backend_integration.py — Production vs emulator mode in apply_periodic_settings, commands produced, error handling
  • test_idempotent_apply.py — Production apply skips fairshare / TRES values SLURM already holds
  • test_configuration_validation.py — periodic_limits settings handling
  • test_emulator_scenarios_direct.py, test_emulator_scenarios_working.py, test_real_emulator_scenarios.py — slurm-emulator's built-in scenarios, imported as a Python package
  • test_emulator_integration.py — The emulator's HTTP API; skipped unless it is running (below)

Running

slurm-emulator is in the plugin's dev dependency group, so uv sync --all-packages installs it.

1
2
cd plugins/slurm
uv run pytest tests/test_periodic_limits/

test_emulator_integration.py needs the emulator's HTTP API on localhost:8080; without it those tests are skipped. To run them:

1
2
3
4
cd plugins/slurm
export SLURM_EMULATOR_STATE_FILE=$(mktemp -d)/emulator.json   # keep state private
uv run uvicorn emulator.api.emulator_server:app --host 127.0.0.1 --port 8080 &
uv run pytest tests/test_periodic_limits/test_emulator_integration.py

With slurm-emulator 0.9.7, three of those tests fail because they call API endpoints (usage injection, limit calculation) that this emulator version does not provide.

The emulator's command-line tools (sacctmgr, sacct, …) and the HTTP API keep their state in /tmp/slurm_emulator_db.json unless SLURM_EMULATOR_STATE_FILE points elsewhere. Set it when other test runs or a live agent use the emulator on the same machine.

Adding tests

  • Agent behaviour (what gets written to SLURM, and when) belongs here.
  • Policy behaviour (what the settings should be) belongs to Mastermind's tests; use the mock policy here only to produce realistic input.