Skip to content

Commit 26ac320

Browse files
committed
integration: add userns and checkpoint integration test
Signed-off-by: Efim Verzakov <efimverzakov@gmail.com>
1 parent a51b20a commit 26ac320

File tree

2 files changed

+43
-0
lines changed

2 files changed

+43
-0
lines changed

tests/integration/helpers.bash

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -491,6 +491,19 @@ function have_criu() {
491491
run ! grep -q '^criu-3\.17-[123]\.el9' <<<"$ver"
492492
}
493493

494+
function have_criu_version() {
495+
local major_required minor_required
496+
major_required=$(echo "$1" | cut -d. -f1)
497+
minor_required=$(echo "$1" | cut -d. -f2)
498+
499+
local current_ver major_current minor_current
500+
current_ver=$(criu --version | grep Version | awk '{print $2}')
501+
major_current=$(echo "$current_ver" | cut -d. -f1)
502+
minor_current=$(echo "$current_ver" | cut -d. -f2)
503+
504+
[[ $major_current -gt $major_required || ($major_current -eq $major_required && $minor_current -ge $minor_required) ]]
505+
}
506+
494507
# Allows a test to specify what things it requires. If the environment can't
495508
# support it, the test is skipped with a message.
496509
function requires() {
@@ -508,6 +521,12 @@ function requires() {
508521
skip "requires CRIU feature ${var}"
509522
fi
510523
;;
524+
criu_version_*)
525+
var=${var#criu_version_}
526+
if ! have_criu_version "$var"; then
527+
skip "requires CRIU version ${var}"
528+
fi
529+
;;
511530
root)
512531
if [ $EUID -ne 0 ] || in_userns; then
513532
skip_me=1

tests/integration/userns.bats

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -280,3 +280,27 @@ function teardown() {
280280
# is deleted during the namespace cleanup.
281281
run ! ip link del dummy0
282282
}
283+
284+
@test "checkpoint userns container" {
285+
requires criu root criu_version_4.3
286+
287+
runc run -d --console-socket "$CONSOLE_SOCKET" test_busybox
288+
[ "$status" -eq 0 ]
289+
290+
testcontainer test_busybox running
291+
292+
for _ in $(seq 2); do
293+
runc checkpoint --work-path ./work-dir test_busybox
294+
[ "$status" -eq 0 ]
295+
296+
testcontainer test_busybox checkpointed
297+
298+
# we need to chown images because child process can try to read them.
299+
chown -R 100000:200000 ./checkpoint
300+
301+
runc restore -d --work-path ./work-dir --console-socket "$CONSOLE_SOCKET" test_busybox
302+
[ "$status" -eq 0 ]
303+
304+
testcontainer test_busybox running
305+
done
306+
}

0 commit comments

Comments
 (0)