From 027efce0cbf4d0591686d3a5ff7bbce1dc7135a2 Mon Sep 17 00:00:00 2001 From: Adrian Reber Date: Wed, 12 Dec 2018 15:54:48 +0000 Subject: [PATCH] Added test for container specific CRIU configuration files Signed-off-by: Adrian Reber --- tests/integration/checkpoint.bats | 44 +++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/tests/integration/checkpoint.bats b/tests/integration/checkpoint.bats index 8ee28112242..57c9adef454 100644 --- a/tests/integration/checkpoint.bats +++ b/tests/integration/checkpoint.bats @@ -292,3 +292,47 @@ function teardown() { ip netns del $ns_name } +@test "checkpoint and restore with container specific CRIU config" { + # XXX: currently criu require root containers. + requires criu root + + tmp=`mktemp` + # This adds the annotation 'org.criu.config' to set a container + # specific CRIU config file. + sed -i "s;\"process\";\"annotations\":{\"org.criu.config\": \"$tmp\"},\"process\";" config.json + # Tell CRIU to run with verbosity=0 + echo "verbosity=0" > $tmp + + 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 + [ "$status" -eq 0 ] + # Using verbosity=0 should create really small log files. + # Because CRIU's criu.kdat files do not seem to work on travis + # 'Warn (criu/kerndat.c:881): Can't keep kdat cache on non-tempfs' + # there will be at least 37 lines. A full dump of the container + # in this test will generate over 1000 lines. So 45 is still + # much smaller and verbosity=0 works. + lines=`wc -l ./work-dir/dump.log | cut -d\ -f1` + [ "$lines" -lt "45" ] + + # after checkpoint busybox is no longer running + runc state test_busybox + [ "$status" -ne 0 ] + + # restore from checkpoint + runc --criu "$CRIU" restore -d --work-path ./work-dir --console-socket $CONSOLE_SOCKET test_busybox + [ "$status" -eq 0 ] + # Using verbosity=0 should create really small log files + lines=`wc -l ./work-dir/restore.log | cut -d\ -f1` + [ "$lines" -lt "45" ] + + # busybox should be back up and running + testcontainer test_busybox running + rm -f $tmp +} +