Skip to content

Commit

Permalink
tests: test nested bind mount restore
Browse files Browse the repository at this point in the history
This adds a checkpoint/restore test to ensure that nested bind mount
mountpoints are correctly re-created.

Signed-off-by: Adrian Reber <areber@redhat.com>
  • Loading branch information
adrianreber committed Feb 9, 2021
1 parent 28ea6e6 commit 11c7d94
Showing 1 changed file with 50 additions and 0 deletions.
50 changes: 50 additions & 0 deletions tests/integration/checkpoint.bats
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

load helpers

# This is a placeholder for things that need to be cleaned up if set.
CR_TMP=""

function setup() {
# XXX: currently criu require root containers.
requires criu root
Expand All @@ -13,6 +16,11 @@ function setup() {
function teardown() {
teardown_busybox
teardown_running_container test_busybox_restore

if [ -n "$CR_TMP" ]; then
rm -rf "$CR_TMP"
CR_TMP=""
fi
}

function setup_pipes() {
Expand Down Expand Up @@ -315,3 +323,45 @@ function simple_cr() {
unlink "$tmp"
test -f ./work-dir/"$tmplog2" && unlink ./work-dir/"$tmplog2"
}

@test "checkpoint and restore with nested bind mounts" {
CR_TMP=$(mktemp -d)
bind1=$(mktemp -d -p "$CR_TMP")
bind2=$(mktemp -d -p "$CR_TMP")
update_config ' .mounts += [{
type: "bind",
source: "'"$bind1"'",
destination: "/test",
options: ["rw", "bind"]
},
{
type: "bind",
source: "'"$bind2"'",
destination: "/test/for/nested",
options: ["rw", "bind"]
}]'

runc run -d --console-socket "$CONSOLE_SOCKET" test_busybox
[ "$status" -eq 0 ]

testcontainer test_busybox running

# checkpoint the running container
runc --criu "$CRIU" checkpoint --work-path ./work-dir test_busybox
grep -B 5 Error ./work-dir/dump.log || true
[ "$status" -eq 0 ]

# after checkpoint busybox is no longer running
testcontainer test_busybox checkpointed

# mount it again so that runc re-creates missing mountpoints
rm -rf "${bind1:?}"/*

# restore from checkpoint
runc --criu "$CRIU" restore -d --work-path ./work-dir --console-socket "$CONSOLE_SOCKET" test_busybox
grep -B 5 Error ./work-dir/restore.log || true
[ "$status" -eq 0 ]

# busybox should be back up and running
testcontainer test_busybox running
}

0 comments on commit 11c7d94

Please sign in to comment.