[CRIU] Process Migration using Sockets v4 - Patch 3/3
Rodrigo Bruno
rbruno at gsd.inesc-id.pt
Fri Dec 11 14:26:43 PST 2015
Here is the third part.
This patch includes some basic tests. I took some inpiration from some othe tests
already available in CRIU.
Let me know if you think there is more stuff that needs to be tested. The tests
are quite simple for now: one test with dump-restore and one with
predump-dump-restore.
Both tests use both img-proxy and img-cache to work.
Signed-off-by: Rodrigo Bruno <rbruno at gsd.inesc-id.pt>
>From 8be5534a253fa6248f12270c8687327e781065c8 Mon Sep 17 00:00:00 2001
From: rodrigo-bruno <rbruno at gsd.inesc-id.pt>
Date: Fri, 11 Dec 2015 22:08:04 +0000
Subject: [PATCH 3/3] Process Migration using Sockets v4 (3/3)
---
test/proxy-cache/Makefile | 29 +++++++++++++
test/proxy-cache/loop.sh | 8 ++++
test/proxy-cache/run.sh | 106 ++++++++++++++++++++++++++++++++++++++++++++++
3 files changed, 143 insertions(+)
create mode 100644 test/proxy-cache/Makefile
create mode 100755 test/proxy-cache/loop.sh
create mode 100755 test/proxy-cache/run.sh
diff --git a/test/proxy-cache/Makefile b/test/proxy-cache/Makefile
new file mode 100644
index 0000000..420a207
--- /dev/null
+++ b/test/proxy-cache/Makefile
@@ -0,0 +1,29 @@
+DIR := $(shell pwd)/data
+CRIU := $(DIR)/criu
+
+LOOP := $(DIR)/loop.sh
+PIDFILE := $(DIR)/loop.pid
+
+DUMPDIR := $(DIR)/dump
+PREDIR := $(DIR)/predump
+LOG := $(DIR)/log
+
+PROXY_CACHE_TCP_PORT := 9997
+LOCAL_CACHE_PATH := $(DIR)/image-cache.sock
+LOCAL_PROXY_PATH := $(DIR)/image-proxy.sock
+
+export DIR LOOP PIDFILE DUMPDIR PREDIR CRIU LOG PROXY_CACHE_TCP_PORT LOCAL_CACHE_PATH LOCAL_PROXY_PATH
+
+run: testdir
+ ./run.sh
+
+testdir: ../../criu
+ mkdir -p $(DIR)
+ mkdir -p $(DUMPDIR)
+ mkdir -p $(PREDIR)
+ mkdir -p $(LOG)
+ cp ../../criu $(CRIU)
+ cp loop.sh $(LOOP)
+
+clean:
+ rm -rf $(DIR)
diff --git a/test/proxy-cache/loop.sh b/test/proxy-cache/loop.sh
new file mode 100755
index 0000000..a5fcb08
--- /dev/null
+++ b/test/proxy-cache/loop.sh
@@ -0,0 +1,8 @@
+#!/bin/bash
+
+echo $$ > $1.int
+mv $1.int $1
+
+while :; do
+ sleep 1
+done
diff --git a/test/proxy-cache/run.sh b/test/proxy-cache/run.sh
new file mode 100755
index 0000000..34fc8ff
--- /dev/null
+++ b/test/proxy-cache/run.sh
@@ -0,0 +1,106 @@
+#!/bin/bash
+
+set -x
+
+PID=
+CACHE_PID=
+PROXY_PID=
+
+function run {
+ echo "== Run ${LOOP}"
+ echo ${PIDFILE}
+ rm -f ${PIDFILE}
+ setsid ${LOOP} ${PIDFILE} < /dev/null &> /dev/null &
+ for i in `seq 100`; do
+ test -f ${PIDFILE} && break
+ sleep 1
+ done
+ PID=`cat ${PIDFILE}`
+ echo ${PID}
+}
+
+function prepare {
+ ${CRIU} image-cache -vvvv -o ${LOG}/image-cache.log \
+ --local-cache-path ${LOCAL_CACHE_PATH} \
+ --port ${PROXY_CACHE_TCP_PORT} < /dev/null &> /dev/null &
+ CACHE_PID=$!
+ sleep 1
+
+ ${CRIU} image-proxy -vvvv -o ${LOG}/image-proxy.log \
+ --local-proxy-path ${LOCAL_PROXY_PATH} \
+ --address localhost \
+ --port ${PROXY_CACHE_TCP_PORT} < /dev/null &> /dev/null &
+ PROXY_PID=$!
+ sleep 1
+}
+
+function predump {
+ test -d ${PREDIR} && rm -rf ${PREDIR}
+ mkdir -p ${PREDIR}
+ echo "== Predump ${PID}"
+ ${CRIU} pre-dump -vvvv --tree ${PID} --images-dir ${PREDIR} \
+ -o ${LOG}/predump.log \
+ --remote --local-proxy-path ${LOCAL_PROXY_PATH}
+ return $?
+}
+
+function dump {
+ test -d ${DUMPDIR} && rm -rf ${DUMPDIR}
+ mkdir -p ${DUMPDIR}
+ echo "== Dump ${PID}"
+ ${CRIU} dump -vvvv --tree ${PID} --images-dir ${DUMPDIR} \
+ -o ${LOG}/dump.log --prev-images-dir ${PREDIR} --track-mem \
+ --remote --local-proxy-path ${LOCAL_PROXY_PATH}
+ return $?
+}
+
+function restore {
+ echo "== Restore ${DUMPDIR}"
+ ${CRIU} restore -vvvv --images-dir ${DUMPDIR} --restore-detached \
+ -o ${LOG}/restore.log \
+ --remote --local-cache-path ${LOCAL_CACHE_PATH}
+ return $?
+}
+
+function result {
+ local BGRED='\033[41m'
+ local BGGREEN='\033[42m'
+ local NORMAL=$(tput sgr0)
+
+ if [ $1 -ne 0 ]; then
+ echo -e "${BGRED}FAIL${NORMAL}"
+ exit 1
+ else
+ echo -e "${BGGREEN}PASS${NORMAL}"
+ fi
+}
+
+function test_dump-restore {
+ echo "==== Check if dump-restore works with proxy-cache"
+
+ run
+ prepare
+ dump; result $(($?))
+ restore ; result $(($?))
+
+ kill -SIGKILL ${PID}
+ kill -SIGKILL ${CACHE_PID}
+ kill -SIGKILL ${PROXY_PID}
+}
+
+function test_predump-dump-restore {
+ echo "==== Check if predump-dump-restore works with proxy-cache"
+
+ run
+ prepare
+ predump; result $(($?))
+ dump; result $(($?))
+ restore ; result $(($?))
+
+ kill -SIGKILL ${PID}
+ kill -SIGKILL ${CACHE_PID}
+ kill -SIGKILL ${PROXY_PID}
+}
+
+test_dump-restore
+test_predump-dump-restore
--
1.9.1
--
Rodrigo Bruno <rbruno at gsd.inesc-id.pt>
More information about the CRIU
mailing list