From 6f3e13cc48ead674ed94b1ac89e4607db6bc0f6e 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 | 50 +++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) diff --git a/tests/integration/checkpoint.bats b/tests/integration/checkpoint.bats index 8ee28112..92fe559e 100644 --- a/tests/integration/checkpoint.bats +++ b/tests/integration/checkpoint.bats @@ -292,3 +292,53 @@ 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 /tmp/runc-criu-XXXXXX.conf` + # This is the file we write to /etc/criu/default.conf + tmplog1=`mktemp /tmp/runc-criu-log-XXXXXX.log` + unlink $tmplog1 + tmplog1=`basename $tmplog1` + # That is the actual configuration file to be used + tmplog2=`mktemp /tmp/runc-criu-log-XXXXXX.log` + unlink $tmplog2 + tmplog2=`basename $tmplog2` + # 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 use another configuration file + mkdir -p /etc/criu + echo "log-file=$tmplog1" > /etc/criu/default.conf + # Make sure the RPC defined configuration file overwrites the previous + echo "log-file=$tmplog2" > $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 ] + ! test -f ./work-dir/$tmplog1 + test -f ./work-dir/$tmplog2 + + # after checkpoint busybox is no longer running + runc state test_busybox + [ "$status" -ne 0 ] + + test -f ./work-dir/$tmplog2 && unlink ./work-dir/$tmplog2 + # restore from checkpoint + runc --criu "$CRIU" restore -d --work-path ./work-dir --console-socket $CONSOLE_SOCKET test_busybox + [ "$status" -eq 0 ] + ! test -f ./work-dir/$tmplog1 + test -f ./work-dir/$tmplog2 + + # busybox should be back up and running + testcontainer test_busybox running + unlink $tmp + test -f ./work-dir/$tmplog2 && unlink ./work-dir/$tmplog2 +} +