SHA256
1
0
forked from pool/systemd
systemd/5008-test-Add-effective-cgroup-limits-testing.patch
Franck Bui 94f1d69402 - Upgrade to v255.3 (commit 96edf7ad1866172b994cafb4df49e27d68ce8e87)
See https://github.com/openSUSE/systemd/blob/SUSE/v255/NEWS for details.
  - This includes the following bug fixes:
    - commit 6e10405aa25fe5e76b740d9ec59730e3f4470c7a (bsc#1219766)
  - The following patches have been rebased:
    - 0002-rc-local-fix-ordering-startup-for-etc-init.d-boot.lo.patch
    - 0008-sysv-generator-translate-Required-Start-into-a-Wants.patch
    - 0009-pid1-handle-console-specificities-weirdness-for-s390.patch
    - 5001-Revert-udev-update-devlink-with-the-newer-device-nod.patch
    - 5002-Revert-udev-revert-workarounds-for-issues-caused-by-.patch
  - The following patches have been removed since they're part of v255:
    - 5003-cgroup-rename-TasksMax-structure-to-CGroupTasksMax.patch
    - 5004-bus-print-properties-ignore-CGROUP_LIMIT_MAX-for-Mem.patch
    - 5005-bus-print-properties-prettify-more-unset-properties.patch
  - systemd-boot has been added to the list of the dependencies of the
    systemd-testsuite package as the installation of the bootloader is now
    tested.
  - the following patches have been backported on top of v255.3:
    96edf7ad18 service: Demote log level of NotifyAccess= messages to debug (bsc#1210113 jsc#PED-6214)
    fdde7f26d6 vconsole-setup: don't fail if the only found vc is already used by plymouth (bsc#1218618)
    f96c587d41 rules: set up tty permissions and group for /dev/hvc* nodes (bsc#1218137)
    63a41b8899 vconsole-setup: remember the correct error value when open_terminal() fails
    f51a2e038c vconsole-setup: handle the case where the vc is in KD_GRAPHICS mode more gracefully (bsc#1215282)
    15025a04c4 test: make sure to install the filesystem package in the test image on SUSE
    06fecfb635 test: make sure that sd-boot is installed before testing bootctl
    1e8788ea68 test: install systemd-boot in openSUSE test images
    6e2875ad43 test/test-shutdown.py: optionally display the test I/Os in a dedicated log file
    4be1a801b4 test-69: send SIGTERM to ask systemd-nspawn to properly stop the container
    7bdab7b7c7 man: Document ranges for distributions config files and local config files
    3f12a6c22f test: systemd-update-utmp is optional

OBS-URL: https://build.opensuse.org/package/show/Base:System/systemd?expand=0&rev=1497
2024-02-23 16:24:26 +00:00

112 lines
2.8 KiB
Diff

From 10d8f042c0bf685d41b95d7151214999a8ff68c2 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Michal=20Koutn=C3=BD?= <mkoutny@suse.com>
Date: Wed, 9 Aug 2023 22:43:31 +0200
Subject: [PATCH 5008/5010] test: Add effective cgroup limits testing
(cherry picked from commit ce35bb95c7b6fe9a48d2b8628bd690279b17fffa)
[mkoutny: fixes jsc#PED-5659]
---
test/units/testsuite-05.effective-limit.sh | 68 ++++++++++++++++++++++
test/units/util.sh | 9 +++
2 files changed, 77 insertions(+)
create mode 100755 test/units/testsuite-05.effective-limit.sh
diff --git a/test/units/testsuite-05.effective-limit.sh b/test/units/testsuite-05.effective-limit.sh
new file mode 100755
index 0000000000..3ff8e83140
--- /dev/null
+++ b/test/units/testsuite-05.effective-limit.sh
@@ -0,0 +1,68 @@
+#!/usr/bin/env bash
+# SPDX-License-Identifier: LGPL-2.1-or-later
+set -eux
+set -o pipefail
+
+# shellcheck source=test/units/util.sh
+. "$(dirname "$0")"/util.sh
+
+pre=test05
+cat >/run/systemd/system/"$pre"alpha.slice <<EOF
+[Slice]
+MemoryMax=40M
+MemoryHigh=40M
+TasksMax=400
+EOF
+
+cat >/run/systemd/system/"$pre"alpha-beta.slice <<EOF
+[Slice]
+MemoryMax=10M
+MemoryHigh=10M
+TasksMax=100
+EOF
+
+cat >/run/systemd/system/"$pre"alpha-beta-gamma.slice <<EOF
+[Slice]
+MemoryMax=20M
+MemoryHigh=20M
+TasksMax=200
+EOF
+
+systemctl daemon-reload
+
+srv=probe.service
+slc0="$pre"alpha.slice
+slc="$pre"alpha-beta-gamma.slice
+
+systemd-run --unit "$srv" --slice "$slc" \
+ -p MemoryMax=5M \
+ -p MemoryHigh=5M \
+ -p TasksMax=50 \
+ sleep inf
+
+# Compare with inequality because test can run in a constrained container
+assert_le "$(systemctl show -P EffectiveMemoryMax "$srv")" "5242880"
+assert_le "$(systemctl show -P EffectiveMemoryHigh "$srv")" "5242880"
+assert_le "$(systemctl show -P EffectiveTasksMax "$srv")" "50"
+
+systemctl stop "$srv"
+
+systemd-run --unit "$srv" --slice "$slc" \
+ sleep inf
+
+assert_le "$(systemctl show -P EffectiveMemoryMax "$srv")" "10485760"
+assert_le "$(systemctl show -P EffectiveMemoryHigh "$srv")" "10485760"
+assert_le "$(systemctl show -P EffectiveTasksMax "$srv")" "100"
+
+systemctl set-property "$slc0" \
+ MemoryMax=5M \
+ MemoryHigh=5M \
+ TasksMax=50
+
+assert_le "$(systemctl show -P EffectiveMemoryMax "$srv")" "5242880"
+assert_le "$(systemctl show -P EffectiveMemoryHigh "$srv")" "5242880"
+assert_le "$(systemctl show -P EffectiveTasksMax "$srv")" "50"
+
+systemctl stop "$srv"
+
+rm -f /run/systemd/system/"$pre"* || :
diff --git a/test/units/util.sh b/test/units/util.sh
index b5ed73237c..567cda2845 100755
--- a/test/units/util.sh
+++ b/test/units/util.sh
@@ -28,6 +28,15 @@ assert_eq() {(
fi
)}
+assert_le() {(
+ set +ex
+
+ if [[ "${1:?}" -gt "${2:?}" ]]; then
+ echo "FAIL: '$1' > '$2'" >&2
+ exit 1
+ fi
+)}
+
assert_in() {(
set +ex
--
2.35.3