]> Git Repo - qemu.git/blob - tests/acceptance/migration.py
tests/docker: Install Sphinx in the Fedora image
[qemu.git] / tests / acceptance / migration.py
1 # Migration test
2 #
3 # Copyright (c) 2019 Red Hat, Inc.
4 #
5 # Authors:
6 #  Cleber Rosa <[email protected]>
7 #  Caio Carrara <[email protected]>
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     :avocado: enable
22     """
23
24     timeout = 10
25
26     @staticmethod
27     def migration_finished(vm):
28         return vm.command('query-migrate')['status'] in ('completed', 'failed')
29
30     def _get_free_port(self):
31         port = network.find_free_port()
32         if port is None:
33             self.cancel('Failed to find a free port')
34         return port
35
36
37     def test_migration_with_tcp_localhost(self):
38         source_vm = self.get_vm()
39         dest_uri = 'tcp:localhost:%u' % self._get_free_port()
40         dest_vm = self.get_vm('-incoming', dest_uri)
41         dest_vm.launch()
42         source_vm.launch()
43         source_vm.qmp('migrate', uri=dest_uri)
44         wait.wait_for(
45             self.migration_finished,
46             timeout=self.timeout,
47             step=0.1,
48             args=(source_vm,)
49         )
50         self.assertEqual(dest_vm.command('query-migrate')['status'], 'completed')
51         self.assertEqual(source_vm.command('query-migrate')['status'], 'completed')
52         self.assertEqual(dest_vm.command('query-status')['status'], 'running')
53         self.assertEqual(source_vm.command('query-status')['status'], 'postmigrate')
This page took 0.027331 seconds and 4 git commands to generate.