From ad7d73608e1cbe5b8c97ca7e7b63b8779dd1be7a Mon Sep 17 00:00:00 2001 From: mwiegand Date: Sat, 9 May 2026 09:48:41 +0200 Subject: [PATCH] feat(deploy): l4d2-game.slice + l4d2-build.slice with 100:1 weight ratio Flat top-level slices. Game wins under contention; build still gets the box when uncontended. Referenced by left4me-server@.service and the script-sandbox systemd-run invocation. --- .../local/lib/systemd/system/l4d2-build.slice | 7 +++++++ .../local/lib/systemd/system/l4d2-game.slice | 7 +++++++ deploy/tests/test_deploy_artifacts.py | 18 ++++++++++++++++++ 3 files changed, 32 insertions(+) create mode 100644 deploy/files/usr/local/lib/systemd/system/l4d2-build.slice create mode 100644 deploy/files/usr/local/lib/systemd/system/l4d2-game.slice diff --git a/deploy/files/usr/local/lib/systemd/system/l4d2-build.slice b/deploy/files/usr/local/lib/systemd/system/l4d2-build.slice new file mode 100644 index 0000000..34c1af3 --- /dev/null +++ b/deploy/files/usr/local/lib/systemd/system/l4d2-build.slice @@ -0,0 +1,7 @@ +[Unit] +Description=left4me script-sandbox build slice +Before=slices.target + +[Slice] +CPUWeight=10 +IOWeight=10 diff --git a/deploy/files/usr/local/lib/systemd/system/l4d2-game.slice b/deploy/files/usr/local/lib/systemd/system/l4d2-game.slice new file mode 100644 index 0000000..f7284df --- /dev/null +++ b/deploy/files/usr/local/lib/systemd/system/l4d2-game.slice @@ -0,0 +1,7 @@ +[Unit] +Description=left4me game-server slice +Before=slices.target + +[Slice] +CPUWeight=1000 +IOWeight=1000 diff --git a/deploy/tests/test_deploy_artifacts.py b/deploy/tests/test_deploy_artifacts.py index 20ef2ce..059b3d3 100644 --- a/deploy/tests/test_deploy_artifacts.py +++ b/deploy/tests/test_deploy_artifacts.py @@ -9,6 +9,8 @@ DEPLOY = ROOT / "deploy" WEB_UNIT = DEPLOY / "files/usr/local/lib/systemd/system/left4me-web.service" SERVER_UNIT = DEPLOY / "files/usr/local/lib/systemd/system/left4me-server@.service" +GAME_SLICE = DEPLOY / "files/usr/local/lib/systemd/system/l4d2-game.slice" +BUILD_SLICE = DEPLOY / "files/usr/local/lib/systemd/system/l4d2-build.slice" GLOBAL_REFRESH_SERVICE = DEPLOY / "files/usr/local/lib/systemd/system/left4me-refresh-global-overlays.service" GLOBAL_REFRESH_TIMER = DEPLOY / "files/usr/local/lib/systemd/system/left4me-refresh-global-overlays.timer" SANDBOX_UNIT_DIR = DEPLOY / "files/usr/local/lib/systemd/system" @@ -110,6 +112,22 @@ def test_server_unit_contains_perf_baseline_directives(): assert "LogRateLimitIntervalSec=0" in unit +def test_l4d2_game_slice_exists_with_high_weights(): + assert GAME_SLICE.is_file() + text = GAME_SLICE.read_text() + assert "[Slice]" in text + assert "CPUWeight=1000" in text + assert "IOWeight=1000" in text + + +def test_l4d2_build_slice_exists_with_low_weights(): + assert BUILD_SLICE.is_file() + text = BUILD_SLICE.read_text() + assert "[Slice]" in text + assert "CPUWeight=10" in text + assert "IOWeight=10" in text + + def _fake_command(tmp_path, command_name): marker = tmp_path / f"{command_name}.args" command = tmp_path / command_name