[RFC PATCH 3/4] tests/functional: Add a OS level migration test for pseries

Fabiano Rosas posted 4 patches 2 months, 3 weeks ago
Maintainers: Eduardo Habkost <eduardo@habkost.net>, Marcel Apfelbaum <marcel.apfelbaum@gmail.com>, "Philippe Mathieu-Daudé" <philmd@linaro.org>, Yanan Wang <wangyanan55@huawei.com>, Zhao Liu <zhao1.liu@intel.com>, Nicholas Piggin <npiggin@gmail.com>, Harsh Prateek Bora <harshpb@linux.ibm.com>, Chinmay Rath <rathc@linux.ibm.com>, Thomas Huth <thuth@redhat.com>, "Daniel P. Berrangé" <berrange@redhat.com>, Peter Xu <peterx@redhat.com>, Fabiano Rosas <farosas@suse.de>
[RFC PATCH 3/4] tests/functional: Add a OS level migration test for pseries
Posted by Fabiano Rosas 2 months, 3 weeks ago
There's currently no OS level test for ppc64le. Add one such test by
reusing the boot level tests that are already present.

The test boots the source machine, waits for it to reach a mid-boot
message, migrates and checks that the destination has reached the
final boot message (VFS error due to no disk).

Signed-off-by: Fabiano Rosas <farosas@suse.de>
---
 tests/functional/test_ppc64_pseries.py | 41 ++++++++++++++++++++++++++
 1 file changed, 41 insertions(+)

diff --git a/tests/functional/test_ppc64_pseries.py b/tests/functional/test_ppc64_pseries.py
index 67057934e8..7a7e0fe8ae 100755
--- a/tests/functional/test_ppc64_pseries.py
+++ b/tests/functional/test_ppc64_pseries.py
@@ -9,6 +9,8 @@
 
 from qemu_test import QemuSystemTest, Asset
 from qemu_test import wait_for_console_pattern
+from qemu_test.migration import Migration
+from qemu_test.ports import Ports
 
 class pseriesMachine(QemuSystemTest):
 
@@ -87,5 +89,44 @@ def test_ppc64_linux_big_boot(self):
         wait_for_console_pattern(self, console_pattern, self.panic_message)
         wait_for_console_pattern(self, self.good_message, self.panic_message)
 
+    def test_ppc64_linux_migration(self):
+        with Ports() as ports:
+            port = ports.find_free_port()
+            if port is None:
+                self.skipTest('Failed to find a free port')
+        uri = 'tcp:localhost:%u' % port
+
+        kernel_path = self.ASSET_KERNEL.fetch()
+        kernel_command_line = self.KERNEL_COMMON_COMMAND_LINE
+
+        self.set_machine('pseries')
+
+        dest_vm = self.get_vm('-incoming', uri, name="dest-qemu")
+        dest_vm.add_args('-smp', '4')
+        dest_vm.add_args('-nodefaults')
+        dest_vm.add_args('-kernel', kernel_path,
+                         '-append', kernel_command_line)
+        dest_vm.set_console()
+        dest_vm.launch()
+
+        source_vm = self.get_vm(name="source-qemu")
+        source_vm.add_args('-smp', '4')
+        source_vm.add_args('-nodefaults')
+        source_vm.add_args('-kernel', kernel_path,
+                           '-append', kernel_command_line)
+        source_vm.set_console()
+        source_vm.launch()
+
+        # ensure the boot has reached Linux
+        console_pattern = 'smp: Brought up 1 node, 4 CPUs'
+        wait_for_console_pattern(self, console_pattern, self.panic_message,
+                                 vm=source_vm)
+
+        Migration().migrate(self, source_vm, dest_vm, uri, self.timeout)
+
+        # ensure the boot proceeds after migration
+        wait_for_console_pattern(self, self.good_message, self.panic_message,
+                                 vm=dest_vm)
+
 if __name__ == '__main__':
     QemuSystemTest.main()
-- 
2.35.3
Re: [RFC PATCH 3/4] tests/functional: Add a OS level migration test for pseries
Posted by Thomas Huth 2 months, 3 weeks ago
On 20/08/2025 00.39, Fabiano Rosas wrote:
> There's currently no OS level test for ppc64le. Add one such test by
> reusing the boot level tests that are already present.
> 
> The test boots the source machine, waits for it to reach a mid-boot
> message, migrates and checks that the destination has reached the
> final boot message (VFS error due to no disk).
> 
> Signed-off-by: Fabiano Rosas <farosas@suse.de>
> ---
>   tests/functional/test_ppc64_pseries.py | 41 ++++++++++++++++++++++++++
>   1 file changed, 41 insertions(+)
> 
> diff --git a/tests/functional/test_ppc64_pseries.py b/tests/functional/test_ppc64_pseries.py
> index 67057934e8..7a7e0fe8ae 100755
> --- a/tests/functional/test_ppc64_pseries.py
> +++ b/tests/functional/test_ppc64_pseries.py
> @@ -9,6 +9,8 @@
>   
>   from qemu_test import QemuSystemTest, Asset
>   from qemu_test import wait_for_console_pattern
> +from qemu_test.migration import Migration
> +from qemu_test.ports import Ports
>   
>   class pseriesMachine(QemuSystemTest):
>   
> @@ -87,5 +89,44 @@ def test_ppc64_linux_big_boot(self):
>           wait_for_console_pattern(self, console_pattern, self.panic_message)
>           wait_for_console_pattern(self, self.good_message, self.panic_message)
>   
> +    def test_ppc64_linux_migration(self):
> +        with Ports() as ports:
> +            port = ports.find_free_port()
> +            if port is None:
> +                self.skipTest('Failed to find a free port')
> +        uri = 'tcp:localhost:%u' % port

  Hi,

this is not how to use the context for Ports: Once the "with" block is left, 
the locking for the free port will be gone and you're subject to a race 
condition with other tests running in parallel (see the __enter__ and 
__exit__ methods in tests/functional/qemu_test/ports.py ... and yes, there 
should be more documentation for this).

You've got to put everything up to the point where QEMU takes the port into 
the "with" block, i.e. everything up to including the Migration().migrate() 
line.

  Thomas

> +        kernel_path = self.ASSET_KERNEL.fetch()
> +        kernel_command_line = self.KERNEL_COMMON_COMMAND_LINE
> +
> +        self.set_machine('pseries')
> +
> +        dest_vm = self.get_vm('-incoming', uri, name="dest-qemu")
> +        dest_vm.add_args('-smp', '4')
> +        dest_vm.add_args('-nodefaults')
> +        dest_vm.add_args('-kernel', kernel_path,
> +                         '-append', kernel_command_line)
> +        dest_vm.set_console()
> +        dest_vm.launch()
> +
> +        source_vm = self.get_vm(name="source-qemu")
> +        source_vm.add_args('-smp', '4')
> +        source_vm.add_args('-nodefaults')
> +        source_vm.add_args('-kernel', kernel_path,
> +                           '-append', kernel_command_line)
> +        source_vm.set_console()
> +        source_vm.launch()
> +
> +        # ensure the boot has reached Linux
> +        console_pattern = 'smp: Brought up 1 node, 4 CPUs'
> +        wait_for_console_pattern(self, console_pattern, self.panic_message,
> +                                 vm=source_vm)
> +
> +        Migration().migrate(self, source_vm, dest_vm, uri, self.timeout)
> +
> +        # ensure the boot proceeds after migration
> +        wait_for_console_pattern(self, self.good_message, self.panic_message,
> +                                 vm=dest_vm)
> +
>   if __name__ == '__main__':
>       QemuSystemTest.main()
Re: [RFC PATCH 3/4] tests/functional: Add a OS level migration test for pseries
Posted by Fabiano Rosas 2 months, 3 weeks ago
Thomas Huth <thuth@redhat.com> writes:

> On 20/08/2025 00.39, Fabiano Rosas wrote:
>> There's currently no OS level test for ppc64le. Add one such test by
>> reusing the boot level tests that are already present.
>> 
>> The test boots the source machine, waits for it to reach a mid-boot
>> message, migrates and checks that the destination has reached the
>> final boot message (VFS error due to no disk).
>> 
>> Signed-off-by: Fabiano Rosas <farosas@suse.de>
>> ---
>>   tests/functional/test_ppc64_pseries.py | 41 ++++++++++++++++++++++++++
>>   1 file changed, 41 insertions(+)
>> 
>> diff --git a/tests/functional/test_ppc64_pseries.py b/tests/functional/test_ppc64_pseries.py
>> index 67057934e8..7a7e0fe8ae 100755
>> --- a/tests/functional/test_ppc64_pseries.py
>> +++ b/tests/functional/test_ppc64_pseries.py
>> @@ -9,6 +9,8 @@
>>   
>>   from qemu_test import QemuSystemTest, Asset
>>   from qemu_test import wait_for_console_pattern
>> +from qemu_test.migration import Migration
>> +from qemu_test.ports import Ports
>>   
>>   class pseriesMachine(QemuSystemTest):
>>   
>> @@ -87,5 +89,44 @@ def test_ppc64_linux_big_boot(self):
>>           wait_for_console_pattern(self, console_pattern, self.panic_message)
>>           wait_for_console_pattern(self, self.good_message, self.panic_message)
>>   
>> +    def test_ppc64_linux_migration(self):
>> +        with Ports() as ports:
>> +            port = ports.find_free_port()
>> +            if port is None:
>> +                self.skipTest('Failed to find a free port')
>> +        uri = 'tcp:localhost:%u' % port
>
>   Hi,
>
> this is not how to use the context for Ports: Once the "with" block is left, 
> the locking for the free port will be gone and you're subject to a race 
> condition with other tests running in parallel (see the __enter__ and 
> __exit__ methods in tests/functional/qemu_test/ports.py ... and yes, there 
> should be more documentation for this).
>

Haha, I'm dumb. It never crossed my mind.

Thanks