]> xenbits.xensource.com Git - qemu-xen.git/commitdiff
tests/acceptance/migration: Factor out do_migrate()
authorOksana Vohchana <ovoshcha@redhat.com>
Mon, 3 Feb 2020 11:16:30 +0000 (13:16 +0200)
committerPhilippe Mathieu-Daudé <philmd@redhat.com>
Fri, 7 Feb 2020 14:12:48 +0000 (15:12 +0100)
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>
tests/acceptance/migration.py

index 3db733b1ced332e5356c20e35cac467475887f3e..03686d7de3ecf7bf45ea5316d749f89dafec873e 100644 (file)
@@ -34,6 +34,16 @@ class Migration(Test):
         self.assertEqual(dst_vm.command('query-status')['status'], 'running')
         self.assertEqual(src_vm.command('query-status')['status'],'postmigrate')
 
+    def do_migrate(self, dest_uri, src_uri=None):
+        source_vm = self.get_vm()
+        dest_vm = self.get_vm('-incoming', dest_uri)
+        dest_vm.launch()
+        if src_uri is None:
+            src_uri = dest_uri
+        source_vm.launch()
+        source_vm.qmp('migrate', uri=src_uri)
+        self.assert_migration(source_vm, dest_vm)
+
     def _get_free_port(self):
         port = network.find_free_port()
         if port is None:
@@ -42,10 +52,5 @@ class Migration(Test):
 
 
     def test_migration_with_tcp_localhost(self):
-        source_vm = self.get_vm()
         dest_uri = 'tcp:localhost:%u' % self._get_free_port()
-        dest_vm = self.get_vm('-incoming', dest_uri)
-        dest_vm.launch()
-        source_vm.launch()
-        source_vm.qmp('migrate', uri=dest_uri)
-        self.assert_migration(source_vm, dest_vm)
+        self.do_migrate(dest_uri)