2
0
mirror of https://github.com/checkpoint-restore/criu synced 2025-08-26 11:57:52 +00:00

231 Commits

Author SHA1 Message Date
Pavel Tikhomirov
06c6867bfd zdtm.py: ignore unicode encode errors
We have a problem after commit 212e4c771a1b ("test: make zdtm.py
python2/python3 compatible") when running tests on python2:

https://ci.openvz.org/job/CRIU/job/CRIU-virtuozzo/job/criu-dev/3804/console

Traceback (most recent call last):
  File "./test/zdtm.py", line 2249, in <module>
    opts['action'](opts)
  File "./test/zdtm.py", line 2001, in run_tests
    launcher.run_test(t, tdesc, run_flavs)
  File "./test/zdtm.py", line 1680, in run_test
    self.wait()
  File "./test/zdtm.py", line 1737, in wait
    self.__wait_one(0)
  File "./test/zdtm.py", line 1725, in __wait_one
    print(open(sub['log']).read())
UnicodeEncodeError: 'ascii' codec can't encode character u'\u2018' in
position 258: ordinal not in range(128)

print does not like "‘" symbol in zdtm_static_cgroup04.log:
...
rmdir: failed to remove ‘cgclean.sKFHLm/zdtmtst/special_prop_check’: No
such file or directory

Small reproducer:

[snorch@snorch ~]$ cat test_ascii.py
from __future__ import absolute_import, division, print_function, unicode_literals
from builtins import (str, open, range, zip, int, input)

f = open('./zdtm_static_cgroup04.log')
s = f.read()
print(s)

[snorch@snorch ~]$ python test_ascii.py | grep ""
Traceback (most recent call last):
  File "test_ascii.py", line 6, in <module>
    print(s)
UnicodeEncodeError: 'ascii' codec can't encode character u'\u2018' in
position 258: ordinal not in range(128)

So just ignore these quote symbol when printing logs.

Signed-off-by: Pavel Tikhomirov <ptikhomirov@virtuozzo.com>
Signed-off-by: Andrei Vagin <avagin@virtuozzo.com>
2018-06-20 21:20:22 +03:00
Andrei Vagin
e1799382e0 zdtm.py: exclude a vsyscall vma for x32 tests
We alwasy exclude vsyscall vma-s for x32 tests, but
this part was broken by python3 patches.

1: Old maps lost: set([])
1: New maps appeared: set([u"ffffffffff600000-ffffffffff601000 [u'r-xp']"])

Reported-by: Mr Jenkins
Signed-off-by: Andrei Vagin <avagin@virtuozzo.com>
2018-06-18 02:25:12 +03:00
Andrei Vagin
9715eb2de5 zdtm: fix a lint warning about undefined 'raw_input'
test/zdtm.py:1238:3: F821 undefined name 'raw_input'

v2: ask to press enter, not just any key
Signed-off-by: Andrei Vagin <avagin@virtuozzo.com>
2018-06-14 20:29:20 +03:00
Adrian Reber
39b6fec0a9 test/zdtm.py: add option to specify external criu for test suite
I am regularly running zdtm.py after updating the CRIU rpm to test if
the new rpm still works. Until know I usually did:

-criu_bin = "../criu/criu"
-crit_bin = "../crit/crit"
+criu_bin = "/usr/sbin/criu"
+crit_bin = "/usr/bin/crit"

This commit adds two arguments to zdtm.py:

  --criu-bin CRIU_BIN   Path to criu binary
  --crit-bin CRIT_BIN   Path to crit binary

It still defaults to the old values from above, but can now easily be
changed to the CRIU binary provided by the packaging system.

This change was more complicated than expected which is probably related
to the fact that zdtm restarts itself in namespaces.

v2:
 - rebase
v3:
 - fix errors reported by 'make lint'

Signed-off-by: Adrian Reber <areber@redhat.com>
Signed-off-by: Andrei Vagin <avagin@virtuozzo.com>
2018-06-14 20:26:25 +03:00
Andrei Vagin
9fd4436063 zdtm: open notify file descriptors in a binary mode
Send pre-dump notify to 36
  Traceback (most recent call last):
    File "zdtm.py", line 2161, in <module>
      do_run_test(tinfo[0], tinfo[1], tinfo[2], tinfo[3])
    File "zdtm.py", line 1549, in do_run_test
      cr(cr_api, t, opts)
    File "zdtm.py", line 1264, in cr
      test.pre_dump_notify()
    File "zdtm.py", line 490, in pre_dump_notify
      fdin.write(struct.pack("i", 0))
  TypeError: write() argument 1 must be unicode, not str

Signed-off-by: Andrei Vagin <avagin@virtuozzo.com>
2018-06-10 02:07:44 +03:00
Andrei Vagin
af4dbcd1ee zdtm: fix collecting libraries on Alpine Linux
Here is an example of ldd output:

/musl # ldd /usr/lib/libxtables.so.12
	ldd (0x7fae8e06c000)
	libc.musl-x86_64.so.1 => ldd (0x7fae8e06c000)

We need to skip the "ldd (0x7fae8e06c000)" line.

Signed-off-by: Andrei Vagin <avagin@virtuozzo.com>
2018-06-08 09:54:22 +03:00
Andrei Vagin
1509147abe travis: set python3 as default for fedora containers
We need a few jobs to check a compatibility with python3

v2: fix inhfd and rpc tests
Signed-off-by: Andrei Vagin <avagin@virtuozzo.com>
2018-06-08 09:54:22 +03:00
Andrei Vagin
212e4c771a test: make zdtm.py python2/python3 compatible
Cc: Adrian Reber <areber@redhat.com>
Signed-off-by: Andrei Vagin <avagin@virtuozzo.com>
2018-06-08 09:54:22 +03:00
Adrian Reber
a91da7d449 Adapt zdtm for python3 compatibility
As python3 imports are working a bit differently the structure of the
imported files needs to change. Instead of having symlinks to criu.py
and rpc_pb2.py which does not match the import structure just create
symlink to ../lib/py (like crit) to make zdtm usable again with the
python3 compatibility.

Signed-off-by: Adrian Reber <areber@redhat.com>
Signed-off-by: Andrei Vagin <avagin@virtuozzo.com>
2018-05-25 00:23:00 +03:00
Andrey Vagin
7c74f41ab7 zdtm: don't print one line twice
(00.566486)pie: 1: seccomp: mode 0 on tid 1
(00.566601)pie: 1: Error (criu/pie/restorer.c:460): seccomp: Unexpected tid ->
(00.566601)pie: 1: 1 != 1
(00.566601)pie: 1: 1 != 1
(00.566639)pie: 1: Error (criu/pie/restorer.c:1817): Restorer fail 1

Signed-off-by: Andrei Vagin <avagin@virtuozzo.com>
2018-05-16 08:27:17 +03:00
Cyrill Gorcunov
b44d39ba5d zdtm: Don't fail in __construct_root if entries exist
Otherwise we might get

 | OSError: [Errno 17] File exists: '/tmp/criu-root-f8klhI/bin'
 |     os.symlink(".." + ldir, self.root + "/usr" + ldir)
 | OSError: [Errno 17] File exists
 |  File "zdtm.py", line 209, in __mknod
 |     os.mknod(name, stat.S_IFCHR, rdev)
 | OSError: [Errno 17] File exists

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
Signed-off-by: Andrei Vagin <avagin@virtuozzo.com>
2018-05-16 08:23:06 +03:00
Andrei Vagin
938c966ad3 zdtm: create /run in a test root
iptables 1.6.2 fails without /run, because it tries to create
the /run/xtables.lock file

Test output: ================================
Fatal: can't open lock file /run/xtables.lock: No such file or directory
23:29:06.098:     4: ERR: netns-nf.c:21: Can't set input rule (errno = 2 (No such file or directory))
23:29:06.098:     3: ERR: test.c:315: Test exited unexpectedly with code 255

Signed-off-by: Andrei Vagin <avagin@virtuozzo.com>
2018-05-12 06:35:19 +03:00
Andrei Vagin
0771942c73 zdtm: always run criu dump with --track-mem if --snaps is set
Signed-off-by: Andrei Vagin <avagin@virtuozzo.com>
2018-04-30 00:30:21 +03:00
Pavel Tikhomirov
348c39bf14 zdtm/lib: add pre-dump-notify test flag
If pre-dump-notify flag is set, zdtm sends a notify to the test after
pre-dump was finished and waits for the test to send back a reply that
test did all it's work and now is ready for a next pre-dump/dump.

How it can be used:

while (!test_wait_pre_dump()) {
	/* Do something after predump */
	test_wait_pre_dump_ack();
}
/* Do something after restore */

Internally we open two pipes for the test one for receiving notify (with
two open ends) and one for replying to it (only write end open). Fds of
pipes are dupped to predefined numbers and zdtm opens these fds through
/proc/<test-pid>/fd/{100,101} and communicates with the test.

v9: switch to two way interface to remove race then operation we try to
run after predump may be yet unfinished at the time of next dump.

Suggested-by: Andrei Vagin <avagin@virtuozzo.com>
Signed-off-by: Pavel Tikhomirov <ptikhomirov@virtuozzo.com>
Signed-off-by: Andrei Vagin <avagin@virtuozzo.com>
2018-04-27 01:04:15 +03:00
Andrei Vagin
a83620dc0b zdtm: handle --tcp-established in the rpc mode
Signed-off-by: Andrei Vagin <avagin@virtuozzo.com>
2018-04-06 21:08:50 +03:00
Andrey Vagin
251dad530b zdtm: check an exit code of a straced restore
Currently zdtm doesn't detect when restore failed, if it is executed
with strace. With this patch, fake-restore.sh creates a test file, and
zdtm is able to distinguish when restore failed.

Signed-off-by: Andrei Vagin <avagin@virtuozzo.com>
2018-03-28 00:31:53 +03:00
Andrei Vagin
509fac32dd zdtm.py: fix a logic about determing a test flavor in a error case
The get() method requires a key and now we are using an index. That
will never work correctly as it is now.

Acked-by: Adrian Reber <adrian@lisas.de>
Reported-by: Adrian Reber <adrian@lisas.de>
Signed-off-by: Andrei Vagin <avagin@virtuozzo.com>
2018-03-23 01:04:56 +03:00
Andrei Vagin
4ef926192c zdtm: enable lazy migration testing
The --lazy-migrate option allows testing of lazy migration when running ns
or uns flavor.

Signed-off-by: Andrei Vagin <avagin@virtuozzo.com>
Signed-off-by: Mike Rapoport <rppt@linux.vnet.ibm.com>
2018-02-19 20:37:49 +03:00
Andrei Vagin
4fa17310ba zdtm: fix a lint warning
$ make lint
flake8 --config=scripts/flake8.cfg test/zdtm.py
test/zdtm.py:323:19: F841 local variable 'e' is assigned to but never used

Signed-off-by: Andrei Vagin <avagin@virtuozzo.com>
2018-02-02 00:55:51 +03:00
Andrei Vagin
a180cf7ee1 zdtm: suppress useless error messages
Start test
./mxcsr --pidfile=mxcsr.pid --outfile=mxcsr.out
Run criu dump
Unable to kill 44: [Errno 3] No such process <--------------- this one
Run criu restore
Run criu dump

Signed-off-by: Andrei Vagin <avagin@virtuozzo.com>
Reviewed-by: Dmitry Safonov <0x7f454c46@gmail.com>
2018-01-31 21:13:51 +03:00
Andrei Vagin
7b8de6bce6 zdtm: don't mix images from dump with and without check_only
The idea of the check-only option is that criu dump and criu
restore is executed with this option to check whether c/r is
possible for a set of processes. This has to work faster than
without the check-only option.

Now we run criu restore --check-only for images which have
been generated by criu dump without --check-only, it is obviously wrong.

Cc: Adrian Reber <areber@redhat.com>
Signed-off-by: Andrei Vagin <avagin@virtuozzo.com>
2017-11-30 01:34:50 +03:00
Andrei Vagin
9c8d9f1f08 zdtm: don't overwrite logs if the check-only option is set
If the check-only option is set, dump and restore is executed twice,
and we need to set separate logs for both cases.

Signed-off-by: Andrei Vagin <avagin@virtuozzo.com>
2017-11-30 01:34:50 +03:00
Andrei Vagin
f951a3cc92 zdtm: restore ns_last_pid before executing restore in a second time
Otherwise a criu process can get a pid of one of restored processes.

Signed-off-by: Andrei Vagin <avagin@virtuozzo.com>
2017-11-30 01:34:50 +03:00
Andrei Vagin
14ab677ef2 restore: wait restored tasks in the check-only case
If the restore was exexuted with the check-only option,
after restoring all resources tasks waits children and
exits with the 0 code.

Signed-off-by: Andrei Vagin <avagin@virtuozzo.com>
2017-11-30 01:34:50 +03:00
Veronika Kabatova
18c22b77c5 Modify and add test for configuration file functionality
Creating a test for verifying configuration parsing feature. The
test is created by reusing already present inotify_irmap test.

Because of addition of default configuration files, --no-default-config
option is added to zdtm.py to not break the test suite on systems with
these files present.

Signed-off-by: Veronika Kabatova <vkabatov@redhat.com>
Signed-off-by: Andrei Vagin <avagin@virtuozzo.com>
2017-11-30 01:29:44 +03:00
Adrian Reber
4864af0d91 zdtm: also dump and restore tests with --check-only
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>
Signed-off-by: Andrei Vagin <avagin@virtuozzo.com>
2017-11-30 01:29:42 +03:00
Adrian Reber
bab458b0d6 zdtm: call getpid() during gone if pid is zero
If calling gone() without ever calling getpid() before leads to
backtrace. Just call getpid() to avoid that.

Signed-off-by: Adrian Reber <areber@redhat.com>
Signed-off-by: Andrei Vagin <avagin@virtuozzo.com>
2017-11-30 01:28:57 +03:00
Adrian Reber
59d18c8028 zdtm: add reset_pid() function
In preparation for the zdtm option '--check-only' a new helper function
reset_pid() is added which writes to ns_last_pid to avoid PID collisions
during check-only restore and the real restore.

Signed-off-by: Adrian Reber <areber@redhat.com>
Signed-off-by: Andrei Vagin <avagin@virtuozzo.com>
2017-11-30 01:28:57 +03:00
Kirill Tkhai
d82cd43b78 zdtm: Make possible to claim for features list
Currently, one feature is supported. Add possibility
for a test to depend on several features.

v2: Delete excess "if" as suggested by Andrey Vagin.
    Rename variables to decrise patch size.

Signed-off-by: Kirill Tkhai <ktkhai@virtuozzo.com>
Signed-off-by: Andrei Vagin <avagin@virtuozzo.com>
2017-11-30 01:26:43 +03:00
Andrei Vagin
e84540e1f1 zdtm: show a process tree if a test doesn't show signs of life
Call "ps axf" if waitpid() is running more than 10 seconds

Signed-off-by: Andrei Vagin <avagin@virtuozzo.com>
2017-11-30 01:22:15 +03:00
rbruno@gsd.inesc-id.pt
15ee55f404 zdtm: Add support for image-proxy/image-cache
Signed-off-by: Rodrigo Bruno <rbruno@gsd.inesc-id.pt>
Signed-off-by: Katerina Koukiou <k.koukiou@gmail.com>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
2017-11-30 01:22:11 +03:00
root
638c14f2ed zdtm: grep errors from page-server.log and lazy-pages.log
This can help to investigate logs from Mr Jenkins.

Cc: Mike Rapoport <rppt@linux.vnet.ibm.com>
Signed-off-by: Andrei Vagin <avagin@openvz.org>
Signed-off-by: Andrei Vagin <avagin@virtuozzo.com>
2017-11-23 20:23:23 +03:00
Andrei Vagin
008db0cb7a zdtm: run page-server via rpc
v2: typo fix
v3: run criu pre-dump via rpc
v4: don't use status-fd for rpc

Signed-off-by: Andrei Vagin <avagin@virtuozzo.com>
2017-11-23 20:23:23 +03:00
Andrei Vagin
cae6262ce9 zdtm: add an option to show criu statistics
v2: defining crit_bin and using it for Popen() // Mike

Acked-by: Mike Rapoport <rppt@linux.vnet.ibm.com>
Signed-off-by: Andrei Vagin <avagin@virtuozzo.com>
2017-11-23 20:23:14 +03:00
Andrei Vagin
5785dbd93d zdtm.py: fix decode_flav()
Signed-off-by: Andrei Vagin <avagin@virtuozzo.com>
2017-11-23 20:23:13 +03:00
Andrei Vagin
c9ca83f05a tests: fix lint warnings for zdtm.py
flake8 was updated recently and now it shows a few new warnings:

[root@fc24 criu]# make lint
flake8 --config=scripts/flake8.cfg test/zdtm.py
test/zdtm.py:181:4: E722 do not use bare except'
test/zdtm.py:304:2: E722 do not use bare except'
test/zdtm.py:325:3: E722 do not use bare except'
test/zdtm.py:445:3: E722 do not use bare except'
test/zdtm.py:573:4: E722 do not use bare except'
test/zdtm.py:1369:2: E722 do not use bare except'
test/zdtm.py:1385:3: E722 do not use bare except'
test/zdtm.py:1396:2: E722 do not use bare except'
test/zdtm.py:1420:3: E722 do not use bare except'
test/zdtm.py:1820:2: E741 ambiguous variable name 'l'
make: *** [Makefile:369: lint] Error 1

Signed-off-by: Andrei Vagin <avagin@virtuozzo.com>
2017-11-23 20:23:13 +03:00
Andrei Vagin
105765830b zdtm: skip vsyscall vmas for x32 tests
It is known issue that a vsyscall vmas are not unmapped
from x32 processes.

Signed-off-by: Andrei Vagin <avagin@virtuozzo.com>
2017-10-17 10:21:45 +03:00
Andrei Vagin
f54acb48f9 zdtm: fix warnings from flake8
test/zdtm.py:1535:30: E711 comparison to None should be 'if cond is not None:'
test/zdtm.py:1538:31: E711 comparison to None should be 'if cond is not None:'
test/zdtm.py:1601:31: E711 comparison to None should be 'if cond is not None:'

Signed-off-by: Andrei Vagin <avagin@virtuozzo.com>
2017-10-17 08:40:44 +03:00
Andrei Vagin
251b4d06a9 zdtm: report test results in the junit format
We found a good plugin for Jenkins to analize test results,
but it can handle only the junit format.

v2: work without the junit python module
v3: install junit-xml, because zdtm.py is executed
    with the --report option from jenkins scripts.

Signed-off-by: Andrei Vagin <avagin@virtuozzo.com>
2017-10-17 08:40:44 +03:00
Andrei Vagin
d5d41bac19 zdtm: don't use find to get executable files
find: unrecognized: -executable
Signed-off-by: Andrei Vagin <avagin@virtuozzo.com>
2017-10-17 08:40:44 +03:00
Mike Rapoport
1dc55aef45 test/zdtm: do not allow running with --lazy-pages on kernel without uffd
Raise an exception for kernels that do not have userfaultfd. For the
kernels that have userfaultfd but do not provide non-cooperative events
(4.3 - 4.11) just print a warning.

Fixes: #363

Signed-off-by: Mike Rapoport <rppt@linux.vnet.ibm.com>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
2017-09-17 03:27:02 +03:00
Mike Rapoport
eb261b579d zdtm: introduce 'noremotelazy' flag
This allows skipping tests that are not yet run with --remote-lazy-pages,
but can be run with --lazy-pages

Signed-off-by: Mike Rapoport <rppt@linux.vnet.ibm.com>
Signed-off-by: Andrei Vagin <avagin@virtuozzo.com>
2017-09-16 12:29:43 +03:00
Mike Rapoport
a9ea60f8b3 zdtm: check lazy-pages and page-server exit status after test is gone
When running with --lazy-pages or --remote-lazy-pages, the daemons should
run in the background, rather than complete before t.stop() is called.
Many tests try to verify things are ok after test_waitsig() and that's
exactly the place where they access memory and cause page faults.

Signed-off-by: Mike Rapoport <rppt@linux.vnet.ibm.com>
Signed-off-by: Andrei Vagin <avagin@virtuozzo.com>
2017-09-16 12:29:43 +03:00
Andrei Vagin
6110ce00a1 zdtm.py: use --status-fd instead of --daemon for lazy stuff
It works faster and allows to check exit codes.

travis-ci: success for series starting with [1/2] page-server: don't return a server pid from page-server
Signed-off-by: Andrei Vagin <avagin@virtuozzo.com>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
2017-09-16 11:47:02 +03:00
Andrei Vagin
f75db3cdc9 test: check exit codes for criu criu lazy-pages
travis-ci: success for crtools: close a signal descriptor after passing a preparation stage (rev6)
Cc: Mike Rapoport <rppt@linux.vnet.ibm.com>
Signed-off-by: Andrei Vagin <avagin@virtuozzo.com>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
2017-09-16 11:47:02 +03:00
Mike Rapoport
e5b4fcb6cd zdtm.py: postpone waiting for lazy-pages daemon
Currently we are waiting for lazy-pages daemon to finish as a part of
.restore method, which may cause filling test process memory before the
test process resumed it's execution after call to test_waitsig(). In such
case, no page faults occur, but rather all the memory is copied in
handle_remaining_pages method in uffd.c.
Let's move wait(<lazy-pages-pid>,..) after call to test.stop().

travis-ci: success for lazy-pages: add non-#PF events handling
Signed-off-by: Mike Rapoport <rppt@linux.vnet.ibm.com>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
2017-09-16 11:47:02 +03:00
Mike Rapoport
c89a22a8e9 zdtm: simulate lazy migration with page server that can send pages
Lazy migration requires both dumped and restored processes to coexist at
the same time. This breaks some basic assumptions in the zdtm design.
Simulation of lazy migration with the page server allows testing most of
the involved code paths without major intervention into zdtm
infrastructure.

travis-ci: success for lazy-pages: improve testability (rev2)
Signed-off-by: Mike Rapoport <rppt@linux.vnet.ibm.com>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
2017-09-16 11:47:02 +03:00
Mike Rapoport
ac6b3b0a1e zdtm: add 'nolazy' flag for tests not compatible with lazy pages
The kernel support for lazy pages (userfaultfd) lacks many important
features which effectively prevents success in certain tests.
Allow skipping such test with somewhat informative message

travis-ci: success for lazy-pages: improve testability (rev2)
Signed-off-by: Mike Rapoport <rppt@linux.vnet.ibm.com>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
2017-09-16 11:47:01 +03:00
Pavel Emelyanov
0086dca47d uffdd: Implement --daemon mode
Right now the zdtm.py hacks around core code and waits for
a second for the socket to appear. Let's better make proper
--daemon mode for lazy-pages daemon and pidfile generation.

Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
Acked-by: Mike Rapoport <rppt@linux.vnet.ibm.com>
2017-09-16 09:16:33 +03:00
Mike Rapoport
b711f89cf4 test: allow lazy-pages tests in namespaces
Signed-off-by: Mike Rapoport <rppt@linux.vnet.ibm.com>
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
2017-09-16 09:16:33 +03:00