@samitouri / QOSamiQemu / commits / 502357bbcb

tests/functional/ppc64/pseries: Remove custom migration routine

Don't implement a custom migration routine at PpcMigrationTest and instead reuse the generic one from MigrationTest. This removes the dependency of PpcMigrationTest from PseriesMachine. Having one test import another causes unittest code to instantiate the imported test, resulting in the setup and teardown methods being invoked for the imported test class, even if no test from that class will be executed. If run in parallel, the extra setup/teardown methods that result from importing can race with the ones from the actual test being executed and cause the following error: File "<SRC_DIR>/tests/functional/qemu_test/testcase.py", line 238, in tearDown shutil.rmtree(self.workdir) ... FileNotFoundError: [Errno 2] No such file or directory: '<SRC_DIR>/build/tests/functional/ppc64/.../test_migration_with_exec/scratch' The PseriesMachine class is changed to inherit from MigrationTest so both the migration routines and the class attributes of PseriesMachine can be accessed without the need to instantiate another object. Fixes: f4e34d0fd5 ("tests/functional: Add a OS level migration test for pseries") Reported-by: Aditya Gupta <adityag@linux.ibm.com> Reviewed-by: Thomas Huth <thuth@redhat.com> Signed-off-by: Fabiano Rosas <farosas@suse.de> Reviewed-by: Peter Xu <peterx@redhat.com> Tested-by: Aditya Gupta <adityag@linux.ibm.com> Message-ID: <20260303173320.10942-5-farosas@suse.de> [thuth: Remove superfluous ";" as suggested by Aditya] Signed-off-by: Thomas Huth <thuth@redhat.com>

Fabiano Rosas committed Mar 3, 2026 at 14:33 UTC 502357bbcb11bba5b7c4e94af42e274bbecefa26
3 files changed +10 -16
tests/functional/migration.py
+5
@@ -65,6 +65,11 @@ class MigrationTest(QemuSystemTest):
65 self.skipTest('Failed to find a free port')
66 return port
67
68 + def migration_with_tcp_localhost_vms(self, dst_vm, src_vm):
69 + with Ports() as ports:
70 + uri = 'tcp:localhost:%u' % self._get_free_port(ports)
71 + self.migrate_vms(uri, uri, dst_vm, src_vm)
72 +
73 def migration_with_tcp_localhost(self):
74 with Ports() as ports:
75 dst_uri = 'tcp:localhost:%u' % self._get_free_port(ports)
tests/functional/ppc64/test_migration.py
-11
@@ -22,17 +22,6 @@ class PpcMigrationTest(MigrationTest):
22 self.set_machine('mac99')
23 self.migration_with_exec()
24
25 - def do_migrate_ppc64_linux(self, source_vm, dest_vm):
26 - with Ports() as ports:
27 - port = ports.find_free_port()
28 - if port is None:
29 - self.skipTest('Failed to find a free port')
30 - uri = 'tcp:localhost:%u' % port
31 -
32 - dest_vm.qmp('migrate-incoming', uri=uri)
33 - source_vm.qmp('migrate', uri=uri)
34 - self.assert_migration(source_vm, dest_vm)
35 -
25
26 if __name__ == '__main__':
27 MigrationTest.main()
tests/functional/ppc64/test_pseries.py
+5 -5
@@ -7,11 +7,11 @@
7 # This work is licensed under the terms of the GNU GPL, version 2 or
8 # later. See the COPYING file in the top-level directory.
9
10 -from qemu_test import QemuSystemTest, Asset
10 +from qemu_test import Asset
11 from qemu_test import wait_for_console_pattern
12 -from test_migration import PpcMigrationTest
12 +from migration import MigrationTest
13
14 -class PseriesMachine(QemuSystemTest):
14 +class PseriesMachine(MigrationTest):
15
16 timeout = 90
17 KERNEL_COMMON_COMMAND_LINE = 'printk.time=0 console=hvc0 '
@@ -116,11 +116,11 @@ class PseriesMachine(QemuSystemTest):
116 wait_for_console_pattern(self, console_pattern, self.panic_message,
117 vm=source_vm)
118
119 - PpcMigrationTest().do_migrate_ppc64_linux(source_vm, dest_vm);
119 + self.migration_with_tcp_localhost_vms(dest_vm, source_vm)
120
121 # ensure the boot proceeds after migration
122 wait_for_console_pattern(self, self.good_message, self.panic_message,
123 vm=dest_vm)
124
125 if __name__ == '__main__':
126 - QemuSystemTest.main()
126 + MigrationTest.main()