5 systemd-analyze log-level debug
6 systemd-analyze log-target console
8 # Loose checks to ensure the environment has the necessary features for systemd-oomd
9 [[ -e /proc
/pressure
]] ||
echo "no PSI" >> /skipped
10 cgroup_type
=$
(stat
-fc %T
/sys
/fs
/cgroup
/)
11 if [[ "$cgroup_type" != *"cgroup2"* ]] && [[ "$cgroup_type" != *"0x63677270"* ]]; then
12 echo "no cgroup2" >> /skipped
14 if [ ! -f /usr
/lib
/systemd
/systemd-oomd
] && [ ! -f /lib
/systemd
/systemd-oomd
]; then
15 echo "no oomd" >> /skipped
17 [[ -e /skipped
]] && exit 0 || true
19 rm -rf /etc
/systemd
/system
/testsuite-55-testbloat.service.d
21 echo "DefaultMemoryPressureDurationSec=5s" >> /etc
/systemd
/oomd.conf
23 systemctl start testsuite-55-testchill.service
24 systemctl start testsuite-55-testbloat.service
26 # Verify systemd-oomd is monitoring the expected units
27 oomctl |
grep "/testsuite-55-workload.slice"
29 oomctl |
grep "Default Memory Pressure Duration: 5s"
31 # systemd-oomd watches for elevated pressure for 5 seconds before acting.
32 # It can take time to build up pressure so either wait 2 minutes or for the service to fail.
33 timeout
=$
(date -ud "2 minutes" +%s
)
34 while [[ $
(date -u +%s
) -le $timeout ]]; do
35 if ! systemctl status testsuite-55-testbloat.service
; then
41 # testbloat should be killed and testchill should be fine
42 if systemctl status testsuite-55-testbloat.service
; then exit 42; fi
43 if ! systemctl status testsuite-55-testchill.service
; then exit 24; fi
45 # only run this portion of the test if we can set xattrs
46 if setfattr
-n user.xattr_test
-v 1 /sys
/fs
/cgroup
/; then
47 sleep 120 # wait for systemd-oomd kill cool down and elevated memory pressure to come down
49 mkdir
-p /etc
/systemd
/system
/testsuite-55-testbloat.service.d
/
50 echo "[Service]" > /etc
/systemd
/system
/testsuite-55-testbloat.service.d
/override.conf
51 echo "ManagedOOMPreference=avoid" >> /etc
/systemd
/system
/testsuite-55-testbloat.service.d
/override.conf
53 systemctl daemon-reload
54 systemctl start testsuite-55-testchill.service
55 systemctl start testsuite-55-testmunch.service
56 systemctl start testsuite-55-testbloat.service
58 timeout
=$
(date -ud "2 minutes" +%s
)
59 while [[ $
(date -u +%s
) -le $timeout ]]; do
60 if ! systemctl status testsuite-55-testmunch.service
; then
66 # testmunch should be killed since testbloat had the avoid xattr on it
67 if ! systemctl status testsuite-55-testbloat.service
; then exit 25; fi
68 if systemctl status testsuite-55-testmunch.service
; then exit 43; fi
69 if ! systemctl status testsuite-55-testchill.service
; then exit 24; fi
72 systemd-analyze log-level info