mirror of
https://github.com/opencontainers/runc.git
synced 2026-07-10 21:53:57 +08:00
tests/int: run rootless_cgroup tests for v2+systemd
Before this commit, "require rootless_cgroup" feature check required "cgroup" to be present in ROOTLESS_FEATURES. The idea of the requirement, though, is to ensure that rootless runc can manage cgroups. In case of systemd + cgroup v2, rootless runc can manage cgroups, thanks to systemd delegation, so modify the feature check accordingly. Next, convert (simplify) some of the existing users to the modified check. Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
This commit is contained in:
@@ -16,10 +16,7 @@ function setup() {
|
||||
}
|
||||
|
||||
@test "runc create (rootless + no limits + cgrouppath + no permission) fails with permission error" {
|
||||
requires rootless
|
||||
requires rootless_no_cgroup
|
||||
# systemd controls the permission, so error does not happen
|
||||
requires no_systemd
|
||||
requires rootless rootless_no_cgroup
|
||||
|
||||
set_cgroups_path
|
||||
|
||||
@@ -29,10 +26,7 @@ function setup() {
|
||||
}
|
||||
|
||||
@test "runc create (rootless + limits + no cgrouppath + no permission) fails with informative error" {
|
||||
requires rootless
|
||||
requires rootless_no_cgroup
|
||||
# systemd controls the permission, so error does not happen
|
||||
requires no_systemd
|
||||
requires rootless rootless_no_cgroup
|
||||
|
||||
set_resources_limit
|
||||
|
||||
|
||||
@@ -271,6 +271,11 @@ function fail() {
|
||||
exit 1
|
||||
}
|
||||
|
||||
# Check whether rootless runc can use cgroups.
|
||||
function rootless_cgroup() {
|
||||
[[ "$ROOTLESS_FEATURES" == *"cgroup"* || -n "$RUNC_USE_SYSTEMD" ]]
|
||||
}
|
||||
|
||||
# Allows a test to specify what things it requires. If the environment can't
|
||||
# support it, the test is skipped with a message.
|
||||
function requires() {
|
||||
@@ -298,12 +303,12 @@ function requires() {
|
||||
fi
|
||||
;;
|
||||
rootless_cgroup)
|
||||
if [[ "$ROOTLESS_FEATURES" != *"cgroup"* ]]; then
|
||||
if ! rootless_cgroup; then
|
||||
skip_me=1
|
||||
fi
|
||||
;;
|
||||
rootless_no_cgroup)
|
||||
if [[ "$ROOTLESS_FEATURES" == *"cgroup"* ]]; then
|
||||
if rootless_cgroup; then
|
||||
skip_me=1
|
||||
fi
|
||||
;;
|
||||
|
||||
@@ -21,7 +21,7 @@ function setup() {
|
||||
# Tests whatever limits are (more or less) common between cgroup
|
||||
# v1 and v2: memory/swap, pids, and cpuset.
|
||||
@test "update cgroup v1/v2 common limits" {
|
||||
[[ "$ROOTLESS" -ne 0 && -z "$RUNC_USE_SYSTEMD" ]] && requires rootless_cgroup
|
||||
[[ "$ROOTLESS" -ne 0 ]] && requires rootless_cgroup
|
||||
requires cgroups_memory cgroups_pids cgroups_cpuset
|
||||
init_cgroup_paths
|
||||
|
||||
|
||||
Reference in New Issue
Block a user