Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add $RUNC_USE_SYSTEMD to run tests using systemd cgroup driver #2014

Merged
merged 5 commits into from
Mar 15, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,13 @@ go:
- tip

matrix:
include:
- go: 1.11.x
env:
- RUNC_USE_SYSTEMD=1
script:
- make BUILDTAGS="${BUILDTAGS}" all
- sudo PATH="$PATH" make localintegration RUNC_USE_SYSTEMD=1
allow_failures:
- go: tip

Expand Down
2 changes: 1 addition & 1 deletion libcontainer/specconv/spec_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,7 @@ func createCgroupConfig(opts *CreateOpts) (*configs.Cgroup, error) {
// for e.g. "system.slice:docker:1234"
parts := strings.Split(myCgroupPath, ":")
if len(parts) != 3 {
return nil, fmt.Errorf("expected cgroupsPath to be of format \"slice:prefix:name\" for systemd cgroups")
return nil, fmt.Errorf("expected cgroupsPath to be of format \"slice:prefix:name\" for systemd cgroups, got %q instead", myCgroupPath)
}
c.Parent = parts[0]
c.ScopePrefix = parts[1]
Expand Down
4 changes: 4 additions & 0 deletions tests/integration/checkpoint.bats
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
load helpers

function setup() {
if [[ -n "${RUNC_USE_SYSTEMD}" ]] ; then
skip "CRIU test suite is skipped on systemd cgroup driver for now."
fi

teardown_busybox
setup_busybox
}
Expand Down
2 changes: 1 addition & 1 deletion tests/integration/exec.bats
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ function teardown() {
runc run -d --console-socket $CONSOLE_SOCKET test_busybox
[ "$status" -eq 0 ]

run bash -c "cat hello > preserve-fds.test; exec 3<preserve-fds.test; $RUNC --log /proc/self/fd/2 --root $ROOT exec --preserve-fds=1 test_busybox cat /proc/self/fd/3"
run bash -c "cat hello > preserve-fds.test; exec 3<preserve-fds.test; $RUNC ${RUNC_USE_SYSTEMD:+--systemd-cgroup} --log /proc/self/fd/2 --root $ROOT exec --preserve-fds=1 test_busybox cat /proc/self/fd/3"
[ "$status" -eq 0 ]

[[ "${output}" == *"hello"* ]]
Expand Down
14 changes: 11 additions & 3 deletions tests/integration/helpers.bash
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,11 @@ CONSOLE_SOCKET="$BATS_TMPDIR/console.sock"
# Cgroup paths
CGROUP_MEMORY_BASE_PATH=$(grep "cgroup" /proc/self/mountinfo | gawk 'toupper($NF) ~ /\<MEMORY\>/ { print $5; exit }')
CGROUP_CPU_BASE_PATH=$(grep "cgroup" /proc/self/mountinfo | gawk 'toupper($NF) ~ /\<CPU\>/ { 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
Expand All @@ -61,7 +65,7 @@ function runc() {

# Raw wrapper for runc.
function __runc() {
"$RUNC" --log /proc/self/fd/2 --root "$ROOT" "$@"
"$RUNC" ${RUNC_USE_SYSTEMD+--systemd-cgroup} --log /proc/self/fd/2 --root "$ROOT" "$@"
}

# Wrapper for runc spec, which takes only one argument (the bundle path).
Expand Down Expand Up @@ -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
Expand Down