summaryrefslogtreecommitdiffstats
path: root/test/units/testsuite-56.sh
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-27 13:00:47 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-27 13:00:47 +0000
commit2cb7e0aaedad73b076ea18c6900b0e86c5760d79 (patch)
treeda68ca54bb79f4080079bf0828acda937593a4e1 /test/units/testsuite-56.sh
parentInitial commit. (diff)
downloadsystemd-2cb7e0aaedad73b076ea18c6900b0e86c5760d79.tar.xz
systemd-2cb7e0aaedad73b076ea18c6900b0e86c5760d79.zip
Adding upstream version 247.3.upstream/247.3upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'test/units/testsuite-56.sh')
-rwxr-xr-xtest/units/testsuite-56.sh42
1 files changed, 42 insertions, 0 deletions
diff --git a/test/units/testsuite-56.sh b/test/units/testsuite-56.sh
new file mode 100755
index 0000000..37d62d9
--- /dev/null
+++ b/test/units/testsuite-56.sh
@@ -0,0 +1,42 @@
+#!/usr/bin/env bash
+set -ex
+set -o pipefail
+
+systemd-analyze log-level debug
+systemd-analyze log-target console
+
+# Loose checks to ensure the environment has the necessary features for systemd-oomd
+[[ "$( awk '/SwapTotal/ { print $2 }' /proc/meminfo )" != "0" ]] || echo "no swap" >> /skipped
+[[ -e /proc/pressure ]] || echo "no PSI" >> /skipped
+cgroup_type=$(stat -fc %T /sys/fs/cgroup/)
+if [[ "$cgroup_type" != *"cgroup2"* ]] && [[ "$cgroup_type" != *"0x63677270"* ]]; then
+ echo "no cgroup2" >> /skipped
+fi
+[[ -e /skipped ]] && exit 0 || true
+
+systemctl start testsuite-56-testbloat.service
+systemctl start testsuite-56-testchill.service
+
+# Verify systemd-oomd is monitoring the expected units
+oomctl | grep "/testsuite-56-workload.slice"
+oomctl | grep "50%"
+
+# systemd-oomd watches for elevated pressure for 30 seconds before acting.
+# It can take time to build up pressure so either wait 5 minutes or for the service to fail.
+timeout=$(date -ud "5 minutes" +%s)
+while [[ $(date -u +%s) -le $timeout ]]; do
+ if ! systemctl status testsuite-56-testbloat.service; then
+ break
+ fi
+ sleep 15
+done
+
+# testbloat should be killed and testchill should be fine
+if systemctl status testsuite-56-testbloat.service; then exit 42; fi
+if ! systemctl status testsuite-56-testchill.service; then exit 24; fi
+
+systemd-analyze log-level info
+
+echo OK > /testok
+
+exit 0