Change do_migrate() to call the migrate_vms() helper and provide it with the two VMs already created. Rename do_migrate -> migrate and adjust the callers.
While here, standardize on the "src" and "dst" names. Signed-off-by: Fabiano Rosas <[email protected]> --- tests/functional/migration.py | 34 ++++++++++++++++++---------------- 1 file changed, 18 insertions(+), 16 deletions(-) diff --git a/tests/functional/migration.py b/tests/functional/migration.py index 3362e5c743..49347a30bb 100644 --- a/tests/functional/migration.py +++ b/tests/functional/migration.py @@ -45,17 +45,19 @@ def migrate_vms(self, dst_uri, src_uri, dst_vm, src_vm): src_vm.qmp('migrate', uri=src_uri) self.assert_migration(src_vm, dst_vm) - def do_migrate(self, dest_uri, src_uri=None): - dest_vm = self.get_vm('-incoming', dest_uri, name="dest-qemu") - dest_vm.add_args('-nodefaults') - dest_vm.launch() + def migrate(self, dst_uri, src_uri=None): + dst_vm = self.get_vm('-incoming', 'defer', name="dst-qemu") + dst_vm.add_args('-nodefaults') + dst_vm.launch() + + src_vm = self.get_vm(name="src-qemu") + src_vm.add_args('-nodefaults') + src_vm.launch() + if src_uri is None: - src_uri = dest_uri - source_vm = self.get_vm(name="source-qemu") - source_vm.add_args('-nodefaults') - source_vm.launch() - source_vm.qmp('migrate', uri=src_uri) - self.assert_migration(source_vm, dest_vm) + src_uri = dst_uri + + self.migrate_vms(dst_uri, src_uri, dst_vm, src_vm) def _get_free_port(self, ports): port = ports.find_free_port() @@ -65,18 +67,18 @@ def _get_free_port(self, ports): def migration_with_tcp_localhost(self): with Ports() as ports: - dest_uri = 'tcp:localhost:%u' % self._get_free_port(ports) - self.do_migrate(dest_uri) + dst_uri = 'tcp:localhost:%u' % self._get_free_port(ports) + self.migrate(dst_uri) def migration_with_unix(self): - dest_uri = 'unix:%s/migration.sock' % self.socket_dir().name - self.do_migrate(dest_uri) + dst_uri = 'unix:%s/migration.sock' % self.socket_dir().name + self.migrate(dst_uri) def migration_with_exec(self): if not which('ncat'): self.skipTest('ncat is not available') with Ports() as ports: free_port = self._get_free_port(ports) - dest_uri = 'exec:ncat -l localhost %u' % free_port + dst_uri = 'exec:ncat -l localhost %u' % free_port src_uri = 'exec:ncat localhost %u' % free_port - self.do_migrate(dest_uri, src_uri) + self.migrate(dst_uri, src_uri) -- 2.51.0
