]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
test: make TEST-56-OOMD service unit files static
authorAnita Zhang <the.anitazha@gmail.com>
Fri, 23 Oct 2020 22:47:07 +0000 (15:47 -0700)
committerAnita Zhang <the.anitazha@gmail.com>
Fri, 23 Oct 2020 22:59:00 +0000 (15:59 -0700)
test/units/testsuite-56-testbloat.service [new file with mode: 0644]
test/units/testsuite-56-testchill.service [new file with mode: 0644]
test/units/testsuite-56-workload.slice [new file with mode: 0644]
test/units/testsuite-56.sh

diff --git a/test/units/testsuite-56-testbloat.service b/test/units/testsuite-56-testbloat.service
new file mode 100644 (file)
index 0000000..40cf5a9
--- /dev/null
@@ -0,0 +1,9 @@
+[Unit]
+Description=Create a lot of memory pressure
+
+[Service]
+# A very small memory.high will cause the script (trying to use a lot of memory)
+# to throttle and be put under heavy pressure
+MemoryHigh=2M
+Slice=testsuite-56-workload.slice
+ExecStart=/usr/lib/systemd/tests/testdata/units/testsuite-56-slowgrowth.sh
diff --git a/test/units/testsuite-56-testchill.service b/test/units/testsuite-56-testchill.service
new file mode 100644 (file)
index 0000000..6cae3d8
--- /dev/null
@@ -0,0 +1,6 @@
+[Unit]
+Description=No memory pressure
+
+[Service]
+Slice=testsuite-56-workload.slice
+ExecStart=sleep infinity
diff --git a/test/units/testsuite-56-workload.slice b/test/units/testsuite-56-workload.slice
new file mode 100644 (file)
index 0000000..3d542ec
--- /dev/null
@@ -0,0 +1,10 @@
+[Unit]
+Description=Test slice for memory pressure kills
+
+[Slice]
+CPUAccounting=true
+MemoryAccounting=true
+IOAccounting=true
+TasksAccounting=true
+ManagedOOMMemoryPressure=kill
+ManagedOOMMemoryPressureLimitPercent=50%
index 5be66589721921218adcf7efd3098927c6fd86e7..37d62d943c0fbb47582a9b948a55d65b68713d88 100755 (executable)
@@ -14,54 +14,26 @@ if [[ "$cgroup_type" != *"cgroup2"* ]] && [[ "$cgroup_type" != *"0x63677270"* ]]
 fi
 [[ -e /skipped ]] && exit 0 || true
 
-cat > /etc/systemd/system/testworkload.slice <<EOF
-[Slice]
-CPUAccounting=true
-MemoryAccounting=true
-IOAccounting=true
-TasksAccounting=true
-ManagedOOMMemoryPressure=kill
-ManagedOOMMemoryPressureLimitPercent=50%
-EOF
-
-# Create a lot of memory pressure by setting memory.high to a very small value
-cat > /etc/systemd/system/testbloat.service <<EOF
-[Service]
-MemoryHigh=2M
-Slice=testworkload.slice
-ExecStart=/usr/lib/systemd/tests/testdata/units/testsuite-56-slowgrowth.sh
-EOF
-
-# This generates no memory pressure
-cat > /etc/systemd/system/testchill.service <<EOF
-[Service]
-MemoryHigh=2M
-Slice=testworkload.slice
-ExecStart=sleep infinity
-EOF
-
-systemctl daemon-reload
-
-systemctl start testbloat.service
-systemctl start testchill.service
+systemctl start testsuite-56-testbloat.service
+systemctl start testsuite-56-testchill.service
 
 # Verify systemd-oomd is monitoring the expected units
-oomctl | grep "/testworkload.slice"
+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 testbloat.service; then
+    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 testbloat.service; then exit 42; fi
-if ! systemctl status testchill.service; then exit 24; fi
+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