From 015a3b8cb1d40d420eaa961e27cdee463f57f8a0 Mon Sep 17 00:00:00 2001 From: Sea-Eun Lee Date: Mon, 18 Nov 2024 19:13:40 +0000 Subject: oomd: support reloading configuration at runtime --- test/units/TEST-55-OOMD.sh | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) (limited to 'test') diff --git a/test/units/TEST-55-OOMD.sh b/test/units/TEST-55-OOMD.sh index 3c9b4391a9..6679337858 100755 --- a/test/units/TEST-55-OOMD.sh +++ b/test/units/TEST-55-OOMD.sh @@ -264,6 +264,40 @@ EOF systemctl daemon-reload } +testcase_reload() { + # Check if the oomd.conf drop-in config is loaded. + assert_in 'Swap Used Limit: 90.00%' "$(oomctl)" + assert_in 'Default Memory Pressure Limit: 60.00%' "$(oomctl)" + assert_in 'Default Memory Pressure Duration: 2s' "$(oomctl)" + + # Test oomd reload + mkdir -p /run/systemd/oomd.conf.d/ + { + echo "[OOM]" + echo "SwapUsedLimit=80%" + echo "DefaultMemoryPressureLimit=55%" + echo "DefaultMemoryPressureDurationSec=5s" + } >/run/systemd/oomd.conf.d/99-oomd-test.conf + + systemctl reload systemd-oomd.service + assert_in 'Swap Used Limit: 80.00%' "$(oomctl)" + assert_in 'Default Memory Pressure Limit: 55.00%' "$(oomctl)" + assert_in 'Default Memory Pressure Duration: 5s' "$(oomctl)" + + # Set back to default via reload + mkdir -p /run/systemd/oomd.conf.d/ + { + echo "[OOM]" + echo "DefaultMemoryPressureDurationSec=2s" + } >/run/systemd/oomd.conf.d/99-oomd-test.conf + + systemctl reload systemd-oomd.service + + assert_in 'Swap Used Limit: 90.00%' "$(oomctl)" + assert_in 'Default Memory Pressure Limit: 60.00%' "$(oomctl)" + assert_in 'Default Memory Pressure Duration: 2s' "$(oomctl)" +} + run_testcases systemd-analyze log-level info -- cgit v1.2.3