tests/acceptance/migration: Factor out assert_migration()

We are going to reuse this code when testing different transport
methods, so factor it out first

Signed-off-by: Oksana Vohchana <ovoshcha@redhat.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Message-Id: <20200203111631.18796-2-ovoshcha@redhat.com>
[PMD: Split patch in 2, reworded subject and description]
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
This commit is contained in:
Oksana Vohchana 2020-02-03 13:16:30 +02:00 committed by Philippe Mathieu-Daudé
parent b79e55f09b
commit d7c9a83344
1 changed files with 11 additions and 10 deletions

View File

@ -24,6 +24,16 @@ class Migration(Test):
def migration_finished(vm):
return vm.command('query-migrate')['status'] in ('completed', 'failed')
def assert_migration(self, src_vm, dst_vm):
wait.wait_for(self.migration_finished,
timeout=self.timeout,
step=0.1,
args=(src_vm,))
self.assertEqual(src_vm.command('query-migrate')['status'], 'completed')
self.assertEqual(dst_vm.command('query-migrate')['status'], 'completed')
self.assertEqual(dst_vm.command('query-status')['status'], 'running')
self.assertEqual(src_vm.command('query-status')['status'],'postmigrate')
def _get_free_port(self):
port = network.find_free_port()
if port is None:
@ -38,13 +48,4 @@ class Migration(Test):
dest_vm.launch()
source_vm.launch()
source_vm.qmp('migrate', uri=dest_uri)
wait.wait_for(
self.migration_finished,
timeout=self.timeout,
step=0.1,
args=(source_vm,)
)
self.assertEqual(dest_vm.command('query-migrate')['status'], 'completed')
self.assertEqual(source_vm.command('query-migrate')['status'], 'completed')
self.assertEqual(dest_vm.command('query-status')['status'], 'running')
self.assertEqual(source_vm.command('query-status')['status'], 'postmigrate')
self.assert_migration(source_vm, dest_vm)