3 # Copyright (c) 2019 Red Hat, Inc.
6 # Cleber Rosa <crosa@redhat.com>
7 # Caio Carrara <ccarrara@redhat.com>
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.
13 from avocado_qemu
import Test
15 from avocado
.utils
import network
16 from avocado
.utils
import wait
19 class Migration(Test
):
27 def migration_finished(vm
):
28 return vm
.command('query-migrate')['status'] in ('completed', 'failed')
30 def _get_free_port(self
):
31 port
= network
.find_free_port()
33 self
.cancel('Failed to find a free port')
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
)
43 source_vm
.qmp('migrate', uri
=dest_uri
)
45 self
.migration_finished
,
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')