]> git.proxmox.com Git - mirror_qemu.git/blob - tests/acceptance/migration.py
Merge remote-tracking branch 'remotes/rth/tags/pull-tcg-20190903' into staging
[mirror_qemu.git] / tests / acceptance / migration.py
1 # Migration test
2 #
3 # Copyright (c) 2019 Red Hat, Inc.
4 #
5 # Authors:
6 # Cleber Rosa <crosa@redhat.com>
7 # Caio Carrara <ccarrara@redhat.com>
8 #
9 # This work is licensed under the terms of the GNU GPL, version 2 or
10 # later. See the COPYING file in the top-level directory.
11
12
13 from avocado_qemu import Test
14
15 from avocado.utils import network
16 from avocado.utils import wait
17
18
19 class Migration(Test):
20
21 timeout = 10
22
23 @staticmethod
24 def migration_finished(vm):
25 return vm.command('query-migrate')['status'] in ('completed', 'failed')
26
27 def _get_free_port(self):
28 port = network.find_free_port()
29 if port is None:
30 self.cancel('Failed to find a free port')
31 return port
32
33
34 def test_migration_with_tcp_localhost(self):
35 source_vm = self.get_vm()
36 dest_uri = 'tcp:localhost:%u' % self._get_free_port()
37 dest_vm = self.get_vm('-incoming', dest_uri)
38 dest_vm.launch()
39 source_vm.launch()
40 source_vm.qmp('migrate', uri=dest_uri)
41 wait.wait_for(
42 self.migration_finished,
43 timeout=self.timeout,
44 step=0.1,
45 args=(source_vm,)
46 )
47 self.assertEqual(dest_vm.command('query-migrate')['status'], 'completed')
48 self.assertEqual(source_vm.command('query-migrate')['status'], 'completed')
49 self.assertEqual(dest_vm.command('query-status')['status'], 'running')
50 self.assertEqual(source_vm.command('query-status')['status'], 'postmigrate')