[RESEND,v2,5/5] zdtm: also dump and restore tests with --check-only

Submitted by Adrian Reber on May 23, 2017, 9:42 a.m.

Details

Message ID 1495532535-22405-5-git-send-email-adrian@lisas.de
State New
Series "Series without cover letter"
Headers show

Commit Message

Adrian Reber May 23, 2017, 9:42 a.m.
From: Adrian Reber <areber@redhat.com>

This adds the option '--check-only' to zdtm.py. If specified each test
cases is first dumped with the '--check-only' option enabled before the
real dump. Also during restore the test case is first restored with
--check-only before doing the real restore.

Signed-off-by: Adrian Reber <areber@redhat.com>
---
 test/zdtm.py | 24 ++++++++++++++++++++++--
 1 file changed, 22 insertions(+), 2 deletions(-)

Patch hide | download patch | download mbox

diff --git a/test/zdtm.py b/test/zdtm.py
index b5062ea..f983ee7 100755
--- a/test/zdtm.py
+++ b/test/zdtm.py
@@ -804,6 +804,7 @@  class criu:
 		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)
+		self.__check_only = (opts['check_only'] and True or False)
 		self.__lazy_pages_p = None
 		self.__page_server_p = None
 
@@ -848,7 +849,10 @@  class criu:
 
 		with open(os.path.join(self.__ddir(), action + '.cropt'), 'w') as f:
 			f.write(' '.join(s_args) + '\n')
-		print "Run criu " + action
+		if '--check-only' in opts:
+			print "Run criu " + action + " in check-only mode"
+		else:
+			print "Run criu " + action
 
 		strace = []
 		if self.__sat:
@@ -886,6 +890,13 @@  class criu:
 			os.close(status_fds[0])
 			return ret
 
+		if '--check-only' in opts and action == "restore":
+			# Although the restored process never starts
+			# running in check-only mode, it sometimes takes
+			# some time for the process to disappear.
+			# Wait until it is gone.
+			self.__test.gone()
+
 		grep_errors(os.path.join(__ddir, log))
 		if ret != 0:
 			if self.__fault and int(self.__fault) < 128:
@@ -970,6 +981,9 @@  class criu:
 		if self.__empty_ns:
 			a_opts += ['--empty-ns', 'net']
 
+		if self.__check_only:
+			self.__criu_act(action, opts = a_opts + opts + ['--check-only'])
+
 		self.__criu_act(action, opts = a_opts + opts)
 		if self.__mdedup and self.__iter > 1:
 			self.__criu_act("dedup", opts = [])
@@ -1019,6 +1033,11 @@  class criu:
 		if self.__leave_stopped:
 			r_opts += ['--leave-stopped']
 
+		if self.__check_only:
+			self.__criu_act("restore", opts = r_opts + ["--restore-detached"] + ['--check-only'])
+			# sometimes the real restore fails with PID conflicts without this
+			reset_pid()
+
 		self.__criu_act("restore", opts = r_opts + ["--restore-detached"])
 
 		if self.__lazy_pages_p:
@@ -1475,7 +1494,7 @@  class launcher:
 		nd = ('nocr', 'norst', 'pre', 'iters', 'page_server', 'sibling', 'stop', 'empty_ns',
 				'fault', 'keep_img', 'report', 'snaps', 'sat', 'script', 'rpc', 'lazy_pages',
 				'join_ns', 'dedup', 'sbs', 'freezecg', 'user', 'dry_run', 'noauto_dedup',
-				'remote_lazy_pages', 'remote')
+				'remote_lazy_pages', 'remote', 'check_only')
 		arg = repr((name, desc, flavor, {d: self.__opts[d] for d in nd}))
 
 		if self.__use_log:
@@ -1989,6 +2008,7 @@  rp.add_argument("--report", help = "Generate summary report in directory")
 rp.add_argument("--keep-going", help = "Keep running tests in spite of failures", action = 'store_true')
 rp.add_argument("--lazy-pages", help = "restore pages on demand", action = 'store_true')
 rp.add_argument("--remote-lazy-pages", help = "simulate lazy migration", action = 'store_true')
+rp.add_argument("--check-only", help = "Additionally try to dump/restore in --check-only mode", action = 'store_true')
 
 lp = sp.add_parser("list", help = "List tests")
 lp.set_defaults(action = list_tests)

Comments

Andrey Vagin June 1, 2017, 6:18 a.m.
[root@fc24 criu]# python test/zdtm.py run -t zdtm/transition/ipc  --check-only
=== Run 1/1 ================ zdtm/transition/ipc

======================== Run zdtm/transition/ipc in ns =========================
Start test
./ipc --pidfile=ipc.pid --outfile=ipc.out
Run criu dump in check-only mode
Only checking if requested operation will succeed
Run criu dump
Run criu restore in check-only mode
Only checking if requested operation will succeed
Checking mode enabled
Traceback (most recent call last):
  File "zdtm.py", line 1987, in <module>
    do_run_test(tinfo[0], tinfo[1], tinfo[2], tinfo[3])
  File "zdtm.py", line 1438, in do_run_test
    cr(cr_api, t, opts)
  File "zdtm.py", line 1179, in cr
    cr_api.restore()
  File "zdtm.py", line 1072, in restore
    self.__criu_act("restore", opts = r_opts + ["--restore-detached"] + ['--check-only'])
  File "zdtm.py", line 932, in __criu_act
    self.__test.gone()
  File "zdtm.py", line 498, in gone
    self.getpid()
  File "zdtm.py", line 475, in getpid
    self.__pid = rpidfile(self.__pidfile())
  File "zdtm.py", line 316, in rpidfile
    return open(path).readline().strip()
IOError: [Errno 2] No such file or directory: 'zdtm/transition/ipc.pid'


On Tue, May 23, 2017 at 09:42:15AM +0000, Adrian Reber wrote:
> From: Adrian Reber <areber@redhat.com>
> 
> This adds the option '--check-only' to zdtm.py. If specified each test
> cases is first dumped with the '--check-only' option enabled before the
> real dump. Also during restore the test case is first restored with
> --check-only before doing the real restore.
> 
> Signed-off-by: Adrian Reber <areber@redhat.com>
> ---
>  test/zdtm.py | 24 ++++++++++++++++++++++--
>  1 file changed, 22 insertions(+), 2 deletions(-)
> 
> diff --git a/test/zdtm.py b/test/zdtm.py
> index b5062ea..f983ee7 100755
> --- a/test/zdtm.py
> +++ b/test/zdtm.py
> @@ -804,6 +804,7 @@ class criu:
>  		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)
> +		self.__check_only = (opts['check_only'] and True or False)
>  		self.__lazy_pages_p = None
>  		self.__page_server_p = None
>  
> @@ -848,7 +849,10 @@ class criu:
>  
>  		with open(os.path.join(self.__ddir(), action + '.cropt'), 'w') as f:
>  			f.write(' '.join(s_args) + '\n')
> -		print "Run criu " + action
> +		if '--check-only' in opts:
> +			print "Run criu " + action + " in check-only mode"
> +		else:
> +			print "Run criu " + action
>  
>  		strace = []
>  		if self.__sat:
> @@ -886,6 +890,13 @@ class criu:
>  			os.close(status_fds[0])
>  			return ret
>  
> +		if '--check-only' in opts and action == "restore":
> +			# Although the restored process never starts
> +			# running in check-only mode, it sometimes takes
> +			# some time for the process to disappear.
> +			# Wait until it is gone.
> +			self.__test.gone()
> +
>  		grep_errors(os.path.join(__ddir, log))
>  		if ret != 0:
>  			if self.__fault and int(self.__fault) < 128:
> @@ -970,6 +981,9 @@ class criu:
>  		if self.__empty_ns:
>  			a_opts += ['--empty-ns', 'net']
>  
> +		if self.__check_only:
> +			self.__criu_act(action, opts = a_opts + opts + ['--check-only'])
> +
>  		self.__criu_act(action, opts = a_opts + opts)
>  		if self.__mdedup and self.__iter > 1:
>  			self.__criu_act("dedup", opts = [])
> @@ -1019,6 +1033,11 @@ class criu:
>  		if self.__leave_stopped:
>  			r_opts += ['--leave-stopped']
>  
> +		if self.__check_only:
> +			self.__criu_act("restore", opts = r_opts + ["--restore-detached"] + ['--check-only'])
> +			# sometimes the real restore fails with PID conflicts without this
> +			reset_pid()
> +
>  		self.__criu_act("restore", opts = r_opts + ["--restore-detached"])
>  
>  		if self.__lazy_pages_p:
> @@ -1475,7 +1494,7 @@ class launcher:
>  		nd = ('nocr', 'norst', 'pre', 'iters', 'page_server', 'sibling', 'stop', 'empty_ns',
>  				'fault', 'keep_img', 'report', 'snaps', 'sat', 'script', 'rpc', 'lazy_pages',
>  				'join_ns', 'dedup', 'sbs', 'freezecg', 'user', 'dry_run', 'noauto_dedup',
> -				'remote_lazy_pages', 'remote')
> +				'remote_lazy_pages', 'remote', 'check_only')
>  		arg = repr((name, desc, flavor, {d: self.__opts[d] for d in nd}))
>  
>  		if self.__use_log:
> @@ -1989,6 +2008,7 @@ rp.add_argument("--report", help = "Generate summary report in directory")
>  rp.add_argument("--keep-going", help = "Keep running tests in spite of failures", action = 'store_true')
>  rp.add_argument("--lazy-pages", help = "restore pages on demand", action = 'store_true')
>  rp.add_argument("--remote-lazy-pages", help = "simulate lazy migration", action = 'store_true')
> +rp.add_argument("--check-only", help = "Additionally try to dump/restore in --check-only mode", action = 'store_true')
>  
>  lp = sp.add_parser("list", help = "List tests")
>  lp.set_defaults(action = list_tests)
> -- 
> 1.8.3.1
>
Andrey Vagin June 1, 2017, 6:24 a.m.
Hi Adrian,

Today I tried to improve the check-only mode:
https://github.com/avagin/criu/commit/97a7af0881715dc98b1b6c7cf7fea23472bc2a76

My idea is that restored processes call sys_exit_group() instead of
rt_sigreturn().

But a few tests still fails.

On Tue, May 23, 2017 at 09:42:15AM +0000, Adrian Reber wrote:
> From: Adrian Reber <areber@redhat.com>
> 
> This adds the option '--check-only' to zdtm.py. If specified each test
> cases is first dumped with the '--check-only' option enabled before the
> real dump. Also during restore the test case is first restored with
> --check-only before doing the real restore.
> 
> Signed-off-by: Adrian Reber <areber@redhat.com>
> ---
>  test/zdtm.py | 24 ++++++++++++++++++++++--
>  1 file changed, 22 insertions(+), 2 deletions(-)
> 
> diff --git a/test/zdtm.py b/test/zdtm.py
> index b5062ea..f983ee7 100755
> --- a/test/zdtm.py
> +++ b/test/zdtm.py
> @@ -804,6 +804,7 @@ class criu:
>  		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)
> +		self.__check_only = (opts['check_only'] and True or False)
>  		self.__lazy_pages_p = None
>  		self.__page_server_p = None
>  
> @@ -848,7 +849,10 @@ class criu:
>  
>  		with open(os.path.join(self.__ddir(), action + '.cropt'), 'w') as f:
>  			f.write(' '.join(s_args) + '\n')
> -		print "Run criu " + action
> +		if '--check-only' in opts:
> +			print "Run criu " + action + " in check-only mode"
> +		else:
> +			print "Run criu " + action
>  
>  		strace = []
>  		if self.__sat:
> @@ -886,6 +890,13 @@ class criu:
>  			os.close(status_fds[0])
>  			return ret
>  
> +		if '--check-only' in opts and action == "restore":
> +			# Although the restored process never starts
> +			# running in check-only mode, it sometimes takes
> +			# some time for the process to disappear.
> +			# Wait until it is gone.
> +			self.__test.gone()
> +
>  		grep_errors(os.path.join(__ddir, log))
>  		if ret != 0:
>  			if self.__fault and int(self.__fault) < 128:
> @@ -970,6 +981,9 @@ class criu:
>  		if self.__empty_ns:
>  			a_opts += ['--empty-ns', 'net']
>  
> +		if self.__check_only:
> +			self.__criu_act(action, opts = a_opts + opts + ['--check-only'])
> +
>  		self.__criu_act(action, opts = a_opts + opts)
>  		if self.__mdedup and self.__iter > 1:
>  			self.__criu_act("dedup", opts = [])
> @@ -1019,6 +1033,11 @@ class criu:
>  		if self.__leave_stopped:
>  			r_opts += ['--leave-stopped']
>  
> +		if self.__check_only:
> +			self.__criu_act("restore", opts = r_opts + ["--restore-detached"] + ['--check-only'])
> +			# sometimes the real restore fails with PID conflicts without this
> +			reset_pid()
> +
>  		self.__criu_act("restore", opts = r_opts + ["--restore-detached"])
>  
>  		if self.__lazy_pages_p:
> @@ -1475,7 +1494,7 @@ class launcher:
>  		nd = ('nocr', 'norst', 'pre', 'iters', 'page_server', 'sibling', 'stop', 'empty_ns',
>  				'fault', 'keep_img', 'report', 'snaps', 'sat', 'script', 'rpc', 'lazy_pages',
>  				'join_ns', 'dedup', 'sbs', 'freezecg', 'user', 'dry_run', 'noauto_dedup',
> -				'remote_lazy_pages', 'remote')
> +				'remote_lazy_pages', 'remote', 'check_only')
>  		arg = repr((name, desc, flavor, {d: self.__opts[d] for d in nd}))
>  
>  		if self.__use_log:
> @@ -1989,6 +2008,7 @@ rp.add_argument("--report", help = "Generate summary report in directory")
>  rp.add_argument("--keep-going", help = "Keep running tests in spite of failures", action = 'store_true')
>  rp.add_argument("--lazy-pages", help = "restore pages on demand", action = 'store_true')
>  rp.add_argument("--remote-lazy-pages", help = "simulate lazy migration", action = 'store_true')
> +rp.add_argument("--check-only", help = "Additionally try to dump/restore in --check-only mode", action = 'store_true')
>  
>  lp = sp.add_parser("list", help = "List tests")
>  lp.set_defaults(action = list_tests)
> -- 
> 1.8.3.1
>
Andrey Vagin June 2, 2017, 5:24 a.m.
On Wed, May 31, 2017 at 11:18:53PM -0700, Andrei Vagin wrote:
> [root@fc24 criu]# python test/zdtm.py run -t zdtm/transition/ipc  --check-only
> === Run 1/1 ================ zdtm/transition/ipc
> 
> ======================== Run zdtm/transition/ipc in ns =========================
> Start test
> ./ipc --pidfile=ipc.pid --outfile=ipc.out
> Run criu dump in check-only mode
> Only checking if requested operation will succeed
> Run criu dump
> Run criu restore in check-only mode
> Only checking if requested operation will succeed
> Checking mode enabled

The problem is in prepare_vma_ios(). I think this function doesn't have
to be called in the check-only mode.

> Traceback (most recent call last):
>   File "zdtm.py", line 1987, in <module>
>     do_run_test(tinfo[0], tinfo[1], tinfo[2], tinfo[3])
>   File "zdtm.py", line 1438, in do_run_test
>     cr(cr_api, t, opts)
>   File "zdtm.py", line 1179, in cr
>     cr_api.restore()
>   File "zdtm.py", line 1072, in restore
>     self.__criu_act("restore", opts = r_opts + ["--restore-detached"] + ['--check-only'])
>   File "zdtm.py", line 932, in __criu_act
>     self.__test.gone()
>   File "zdtm.py", line 498, in gone
>     self.getpid()
>   File "zdtm.py", line 475, in getpid
>     self.__pid = rpidfile(self.__pidfile())
>   File "zdtm.py", line 316, in rpidfile
>     return open(path).readline().strip()
> IOError: [Errno 2] No such file or directory: 'zdtm/transition/ipc.pid'
> 
> 
> On Tue, May 23, 2017 at 09:42:15AM +0000, Adrian Reber wrote:
> > From: Adrian Reber <areber@redhat.com>
> > 
> > This adds the option '--check-only' to zdtm.py. If specified each test
> > cases is first dumped with the '--check-only' option enabled before the
> > real dump. Also during restore the test case is first restored with
> > --check-only before doing the real restore.
> > 
> > Signed-off-by: Adrian Reber <areber@redhat.com>
> > ---
> >  test/zdtm.py | 24 ++++++++++++++++++++++--
> >  1 file changed, 22 insertions(+), 2 deletions(-)
> > 
> > diff --git a/test/zdtm.py b/test/zdtm.py
> > index b5062ea..f983ee7 100755
> > --- a/test/zdtm.py
> > +++ b/test/zdtm.py
> > @@ -804,6 +804,7 @@ class criu:
> >  		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)
> > +		self.__check_only = (opts['check_only'] and True or False)
> >  		self.__lazy_pages_p = None
> >  		self.__page_server_p = None
> >  
> > @@ -848,7 +849,10 @@ class criu:
> >  
> >  		with open(os.path.join(self.__ddir(), action + '.cropt'), 'w') as f:
> >  			f.write(' '.join(s_args) + '\n')
> > -		print "Run criu " + action
> > +		if '--check-only' in opts:
> > +			print "Run criu " + action + " in check-only mode"
> > +		else:
> > +			print "Run criu " + action
> >  
> >  		strace = []
> >  		if self.__sat:
> > @@ -886,6 +890,13 @@ class criu:
> >  			os.close(status_fds[0])
> >  			return ret
> >  
> > +		if '--check-only' in opts and action == "restore":
> > +			# Although the restored process never starts
> > +			# running in check-only mode, it sometimes takes
> > +			# some time for the process to disappear.
> > +			# Wait until it is gone.
> > +			self.__test.gone()
> > +
> >  		grep_errors(os.path.join(__ddir, log))
> >  		if ret != 0:
> >  			if self.__fault and int(self.__fault) < 128:
> > @@ -970,6 +981,9 @@ class criu:
> >  		if self.__empty_ns:
> >  			a_opts += ['--empty-ns', 'net']
> >  
> > +		if self.__check_only:
> > +			self.__criu_act(action, opts = a_opts + opts + ['--check-only'])
> > +
> >  		self.__criu_act(action, opts = a_opts + opts)
> >  		if self.__mdedup and self.__iter > 1:
> >  			self.__criu_act("dedup", opts = [])
> > @@ -1019,6 +1033,11 @@ class criu:
> >  		if self.__leave_stopped:
> >  			r_opts += ['--leave-stopped']
> >  
> > +		if self.__check_only:
> > +			self.__criu_act("restore", opts = r_opts + ["--restore-detached"] + ['--check-only'])
> > +			# sometimes the real restore fails with PID conflicts without this
> > +			reset_pid()
> > +
> >  		self.__criu_act("restore", opts = r_opts + ["--restore-detached"])
> >  
> >  		if self.__lazy_pages_p:
> > @@ -1475,7 +1494,7 @@ class launcher:
> >  		nd = ('nocr', 'norst', 'pre', 'iters', 'page_server', 'sibling', 'stop', 'empty_ns',
> >  				'fault', 'keep_img', 'report', 'snaps', 'sat', 'script', 'rpc', 'lazy_pages',
> >  				'join_ns', 'dedup', 'sbs', 'freezecg', 'user', 'dry_run', 'noauto_dedup',
> > -				'remote_lazy_pages', 'remote')
> > +				'remote_lazy_pages', 'remote', 'check_only')
> >  		arg = repr((name, desc, flavor, {d: self.__opts[d] for d in nd}))
> >  
> >  		if self.__use_log:
> > @@ -1989,6 +2008,7 @@ rp.add_argument("--report", help = "Generate summary report in directory")
> >  rp.add_argument("--keep-going", help = "Keep running tests in spite of failures", action = 'store_true')
> >  rp.add_argument("--lazy-pages", help = "restore pages on demand", action = 'store_true')
> >  rp.add_argument("--remote-lazy-pages", help = "simulate lazy migration", action = 'store_true')
> > +rp.add_argument("--check-only", help = "Additionally try to dump/restore in --check-only mode", action = 'store_true')
> >  
> >  lp = sp.add_parser("list", help = "List tests")
> >  lp.set_defaults(action = list_tests)
> > -- 
> > 1.8.3.1
> > 
> _______________________________________________
> CRIU mailing list
> CRIU@openvz.org
> https://lists.openvz.org/mailman/listinfo/criu