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 10, 2021
1 parent 705b6cc commit 051646a
Showing 1 changed file with 42 additions and 0 deletions.
42 changes: 42 additions & 0 deletions tests/integration/checkpoint.bats
Original file line number Diff line number Diff line change
Expand Up @@ -315,3 +315,45 @@ function simple_cr() {
unlink "$tmp"
test -f ./work-dir/"$tmplog2" && unlink ./work-dir/"$tmplog2"
}

@test "checkpoint and restore with nested bind mounts" {
bind1=$(mktemp -d -p .)
bind2=$(mktemp -d -p .)
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

# cleanup mountpoints created by runc during creation
# the mountpoints should be recreated during restore - that is the actual thing tested here
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 051646a

Please sign in to comment.