criu: check that stdout, stdin pipes are restore correctly

Signed-off-by: Andrei Vagin <avagin@virtuozzo.com>
This commit is contained in:
Andrei Vagin 2017-05-03 00:17:31 +03:00
parent abd0515816
commit a9e15e7e07
1 changed files with 42 additions and 22 deletions

View File

@ -67,21 +67,33 @@ function teardown() {
# setting terminal and root:readonly: to false # setting terminal and root:readonly: to false
sed -i 's;"terminal": true;"terminal": false;' config.json sed -i 's;"terminal": true;"terminal": false;' config.json
sed -i 's;"readonly": true;"readonly": false;' config.json sed -i 's;"readonly": true;"readonly": false;' config.json
sed -i 's/"sh"/"sh","-c","while :; do date; sleep 1; done"/' config.json sed -i 's/"sh"/"sh","-c","for i in `seq 10`; do read xxx || continue; echo ponG $xxx; done"/' config.json
# The following code creates pipes for stdin and stdout.
# CRIU can't handle fifo-s, so we need all these tricks.
fifo=`mktemp -u /tmp/runc-fifo-XXXXXX`
mkfifo $fifo
# stdout
cat $fifo | cat $fifo &
pid=$!
exec 50</proc/$pid/fd/0
exec 51>/proc/$pid/fd/0
# stdin
cat $fifo | cat $fifo &
pid=$!
exec 60</proc/$pid/fd/0
exec 61>/proc/$pid/fd/0
echo -n > $fifo
unlink $fifo
(
# run busybox (not detached) # run busybox (not detached)
runc run test_busybox __runc run -d test_busybox <&60 >&51 2>&51
[ "$status" -eq 0 ] [ $? -eq 0 ]
) &
# check state
wait_for_container 15 1 test_busybox
runc state test_busybox
[ "$status" -eq 0 ]
[[ "${output}" == *"running"* ]]
testcontainer test_busybox running
#test checkpoint pre-dump #test checkpoint pre-dump
mkdir parent-dir mkdir parent-dir
@ -95,7 +107,9 @@ function teardown() {
# checkpoint the running container # checkpoint the running container
mkdir image-dir mkdir image-dir
runc --criu "$CRIU" checkpoint --parent-path ./parent-dir --image-path ./image-dir test_busybox mkdir work-dir
runc --criu "$CRIU" checkpoint --parent-path ./parent-dir --work-path ./work-dir --image-path ./image-dir test_busybox
cat ./work-dir/dump.log | grep -B 5 Error || true
[ "$status" -eq 0 ] [ "$status" -eq 0 ]
# after checkpoint busybox is no longer running # after checkpoint busybox is no longer running
@ -103,16 +117,22 @@ function teardown() {
[ "$status" -ne 0 ] [ "$status" -ne 0 ]
# restore from checkpoint # restore from checkpoint
( __runc --criu "$CRIU" restore -d --work-path ./work-dir --image-path ./image-dir test_busybox <&60 >&51 2>&51
runc --criu "$CRIU" restore --image-path ./image-dir test_busybox ret=$?
[ "$status" -eq 0 ] cat ./work-dir/restore.log | grep -B 5 Error || true
) & [ $ret -eq 0 ]
# check state
wait_for_container 15 1 test_busybox
# busybox should be back up and running # busybox should be back up and running
runc state test_busybox testcontainer test_busybox running
runc exec --cwd /bin test_busybox echo ok
[ "$status" -eq 0 ] [ "$status" -eq 0 ]
[[ "${output}" == *"running"* ]] [[ ${output} == "ok" ]]
echo Ping >&61
exec 61>&-
exec 51>&-
run cat <&50
[ "$status" -eq 0 ]
[[ "${output}" == *"ponG Ping"* ]]
} }