[CRIU] [PATCH 3/3] Process Migration using Sockets

Rodrigo Bruno rbruno at gsd.inesc-id.pt
Wed Jan 11 09:16:18 PST 2017


 test/proxy-cache/Makefile |  29 ++++++++++++++
 test/proxy-cache/loop.sh  |   8 ++++
 test/proxy-cache/run.sh   | 100
++++++++++++++++++++++++++++++++++++++++++++++
 test/zdtm.py              |  30 +++++++++++++-
 4 files changed, 166 insertions(+), 1 deletion(-)

    Add testcases for image-proxy/image-cache.

    Signed-off-by: Rodrigo Bruno <rbruno at gsd.inesc-id.pt>
    Signed-off-by: Katerina Koukiou <k.koukiou at gmail.com>

diff --git a/test/proxy-cache/Makefile b/test/proxy-cache/Makefile
new file mode 100644
index 0000000..674c493
--- /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 $(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..e403d5f
--- /dev/null
+++ b/test/proxy-cache/run.sh
@@ -0,0 +1,100 @@
+#!/bin/bash
+
+set -x
+
+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 -d -vvvv -o ${LOG}/image-cache.log \
+ --port ${PROXY_CACHE_TCP_PORT} --images-dir $1
+ sleep 1
+
+ ${CRIU} image-proxy -d -vvvv -o ${LOG}/image-proxy.log \
+ --address localhost \
+ --port ${PROXY_CACHE_TCP_PORT} --images-dir $1
+ sleep 1
+}
+
+function predump {
+ echo "== Predump ${PID}"
+ ${CRIU} pre-dump -vvvv --tree ${PID} --images-dir ${PREDIR} \
+ -o ${LOG}/predump.log \
+ --remote
+ return $?
+}
+
+function dump {
+ echo "== Dump ${PID}"
+ ${CRIU} dump -vvvv --tree ${PID} --images-dir ${DUMPDIR} \
+ -o ${LOG}/dump.log --prev-images-dir ${PREDIR} --track-mem \
+ --remote
+ return $?
+}
+
+function restore {
+ echo "== Restore ${DUMPDIR}"
+ ${CRIU} restore -vvvv --images-dir ${DUMPDIR} --restore-detached \
+ -o ${LOG}/restore.log \
+ --remote
+ 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
+ test -d ${DUMPDIR} && rm -rf ${DUMPDIR}
+ mkdir -p ${DUMPDIR}
+ prepare ${DUMPDIR}
+ dump; result $(($?))
+ restore ; result $(($?))
+
+ kill -SIGKILL ${PID}
+}
+
+function test_predump_dump_restore {
+ echo "==== Check if predump-dump-restore works with proxy-cache"
+ run
+ test -d ${PREDIR} && rm -rf ${PREDIR}
+ mkdir -p ${PREDIR}
+ prepare ${PREDIR}
+ predump; result $(($?))
+ test -d ${DUMPDIR} && rm -rf ${DUMPDIR}
+ mkdir -p ${DUMPDIR}
+ ln -s ${PREDIR}"/img-proxy.sock" ${DUMPDIR}"/img-proxy.sock"
+ ln -s ${PREDIR}"/img-cache.sock" ${DUMPDIR}"/img-cache.sock"
+ dump; result $(($?))
+ restore ; result $(($?))
+
+ kill -SIGKILL ${PID}
+}
+
+test_dump_restore
+sleep 1
+test_predump_dump_restore
diff --git a/test/zdtm.py b/test/zdtm.py
index 7cd9dc4..8d389a3 100755
--- a/test/zdtm.py
+++ b/test/zdtm.py
@@ -777,6 +777,7 @@ class criu:
  self.__mdedup = (opts['noauto_dedup'] and True or False)
  self.__user = (opts['user'] and True or False)
  self.__leave_stopped = (opts['stop'] and True or False)
+ self.__remote = (opts['remote'] and True or False)
  self.__criu = (opts['rpc'] and criu_rpc or criu_cli)

  def logs(self):
@@ -884,6 +885,29 @@ class criu:

  a_opts += self.__test.getdopts()

+ if self.__remote:
+ from subprocess import check_output
+
+ logdir = os.getcwd() + "/" + self.__dump_path + "/" + str(self.__iter)
+ print "Adding image cache"
+
+ cache_opts = [criu_bin, "image-cache", "--port", "12345", "-v4", "-o",
+      logdir + "/image-cache.log", "-D", logdir]
+
+ cpid = subprocess.Popen(cache_opts).pid
+ time.sleep(1)
+
+ print "Adding image proxy"
+
+ proxy_opts = [criu_bin, "image-proxy", "--port", "12345", "--address",
+      "localhost", "-v4", "-o", logdir + "/image-proxy.log",
+                                      "-D", logdir]
+
+ ppid = subprocess.Popen(proxy_opts).pid
+ time.sleep(1)
+
+ a_opts += ["--remote"]
+
  if self.__dedup:
  a_opts += ["--auto-dedup"]

@@ -923,6 +947,9 @@ class criu:
  r_opts += ['--empty-ns', 'net']
  r_opts += ['--action-script', os.getcwd() + '/empty-netns-prep.sh']

+ if self.__remote:
+ r_opts += ["--remote"]
+
  self.__prev_dump_iter = None
  criu_dir = os.path.dirname(os.getcwd())
  if os.getenv("GCOV"):
@@ -1362,7 +1389,7 @@ class launcher:

  nd = ('nocr', 'norst', 'pre', 'iters', 'page_server', 'sibling', 'stop',
'empty_ns',
  'fault', 'keep_img', 'report', 'snaps', 'sat', 'script', 'rpc',
- 'join_ns', 'dedup', 'sbs', 'freezecg', 'user', 'dry_run', 'noauto_dedup')
+ 'join_ns', 'dedup', 'sbs', 'freezecg', 'user', 'dry_run', 'noauto_dedup',
'remote')
  arg = repr((name, desc, flavor, {d: self.__opts[d] for d in nd}))

  if self.__use_log:
@@ -1834,6 +1861,7 @@ rp.add_argument("--user", help = "Run CRIU as regular
user", action = 'store_tru
 rp.add_argument("--rpc", help = "Run CRIU via RPC rather than CLI", action
= 'store_true')

 rp.add_argument("--page-server", help = "Use page server dump", action =
'store_true')
+rp.add_argument("--remote", help = "Use remote option for diskless C/R",
action = 'store_true')
 rp.add_argument("-p", "--parallel", help = "Run test in parallel")
 rp.add_argument("--dry-run", help="Don't run tests, just pretend to",
action='store_true')
 rp.add_argument("--script", help="Add script to get notified by criu")
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openvz.org/pipermail/criu/attachments/20170111/4d3e33a8/attachment-0001.html>


More information about the CRIU mailing list