From d4586090c41abe78edb20ecba8ba4c268d8cb27f Mon Sep 17 00:00:00 2001 From: Filipe Brandenburger Date: Thu, 14 Mar 2019 14:37:34 -0700 Subject: [PATCH] Update tests that depend on cgroupfs paths to consider systemd cgroups When $RUNC_USE_SYSTEMD is set, then use a systemd syntax for the cgroupsPath. Also fix $CGROUPS_PATH to look under the actual path to the slice/scope created by systemd. Tested: $ sudo make localintegration TESTPATH='/cgroups.bats' RUNC_USE_SYSTEMD=1 That test will fail without this commit. Signed-off-by: Filipe Brandenburger --- tests/integration/helpers.bash | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/tests/integration/helpers.bash b/tests/integration/helpers.bash index 809b4767..14181332 100644 --- a/tests/integration/helpers.bash +++ b/tests/integration/helpers.bash @@ -39,7 +39,11 @@ CONSOLE_SOCKET="$BATS_TMPDIR/console.sock" # Cgroup paths CGROUP_MEMORY_BASE_PATH=$(grep "cgroup" /proc/self/mountinfo | gawk 'toupper($NF) ~ /\/ { print $5; exit }') CGROUP_CPU_BASE_PATH=$(grep "cgroup" /proc/self/mountinfo | gawk 'toupper($NF) ~ /\/ { print $5; exit }') -CGROUPS_PATH="/runc-cgroups-integration-test/test-cgroup" +if [[ -n "${RUNC_USE_SYSTEMD}" ]] ; then + CGROUPS_PATH="/machine.slice/runc-cgroups-integration-test.scope" +else + CGROUPS_PATH="/runc-cgroups-integration-test/test-cgroup" +fi CGROUP_MEMORY="${CGROUP_MEMORY_BASE_PATH}${CGROUPS_PATH}" # CONFIG_MEMCG_KMEM support @@ -118,7 +122,11 @@ function runc_rootless_cgroup() { # Helper function to set cgroupsPath to the value of $CGROUPS_PATH function set_cgroups_path() { bundle="${1:-.}" - sed -i 's/\("linux": {\)/\1\n "cgroupsPath": "\/runc-cgroups-integration-test\/test-cgroup",/' "$bundle/config.json" + cgroups_path="/runc-cgroups-integration-test/test-cgroup" + if [[ -n "${RUNC_USE_SYSTEMD}" ]] ; then + cgroups_path="machine.slice:runc-cgroups:integration-test" + fi + sed -i 's#\("linux": {\)#\1\n "cgroupsPath": "'"${cgroups_path}"'",#' "$bundle/config.json" } # Helper function to set a resources limit