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 signalstest_mock_mastermind_signals.py— Messages generated by a mockSlurmPeriodicUsagePolicy, applied by the handlertest_backend_integration.py— Production vs emulator mode inapply_periodic_settings, commands produced, error handlingtest_idempotent_apply.py— Production apply skips fairshare / TRES values SLURM already holdstest_configuration_validation.py—periodic_limitssettings handlingtest_emulator_scenarios_direct.py,test_emulator_scenarios_working.py,test_real_emulator_scenarios.py— slurm-emulator's built-in scenarios, imported as a Python packagetest_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 | |
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 | |
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.