From: Fabiano Rosas <farosas@suse.de>
To: qemu-devel@nongnu.org
Cc: "Nicholas Piggin" <npiggin@gmail.com>,
"Thomas Huth" <thuth@redhat.com>, "Fabian Vogt" <fvogt@suse.de>,
"Peter Xu" <peterx@redhat.com>,
"Philippe Mathieu-Daudé" <philmd@linaro.org>,
"Daniel P. Berrangé" <berrange@redhat.com>
Subject: [RFC PATCH 2/4] tests/functional: Extract migration code into a new class
Date: Tue, 19 Aug 2025 19:39:03 -0300 [thread overview]
Message-ID: <20250819223905.2247-3-farosas@suse.de> (raw)
In-Reply-To: <20250819223905.2247-1-farosas@suse.de>
Move some of the code from test_migration.py to a new class so it can
be reused to invoke migrations from other tests.
Signed-off-by: Fabiano Rosas <farosas@suse.de>
---
I see this conflicts with Thomas' series, I'll update accordingly.
---
tests/functional/qemu_test/migration.py | 40 +++++++++++++++++++++++++
tests/functional/test_migration.py | 24 ++-------------
2 files changed, 43 insertions(+), 21 deletions(-)
create mode 100644 tests/functional/qemu_test/migration.py
diff --git a/tests/functional/qemu_test/migration.py b/tests/functional/qemu_test/migration.py
new file mode 100644
index 0000000000..37988704e8
--- /dev/null
+++ b/tests/functional/qemu_test/migration.py
@@ -0,0 +1,40 @@
+# SPDX-License-Identifier: GPL-2.0-or-later
+#
+# Migration test
+#
+# Copyright (c) 2019 Red Hat, Inc.
+#
+# Authors:
+# Cleber Rosa <crosa@redhat.com>
+# Caio Carrara <ccarrara@redhat.com>
+#
+# This work is licensed under the terms of the GNU GPL, version 2 or
+# later. See the COPYING file in the top-level directory.
+
+import time
+
+
+class Migration():
+
+ @staticmethod
+ def migration_finished(vm):
+ return vm.cmd('query-migrate')['status'] in ('completed', 'failed')
+
+ def assert_migration(self, test, src_vm, dst_vm, timeout):
+
+ end = time.monotonic() + timeout
+ while time.monotonic() < end and not self.migration_finished(src_vm):
+ time.sleep(0.1)
+
+ end = time.monotonic() + timeout
+ while time.monotonic() < end and not self.migration_finished(dst_vm):
+ time.sleep(0.1)
+
+ test.assertEqual(src_vm.cmd('query-migrate')['status'], 'completed')
+ test.assertEqual(dst_vm.cmd('query-migrate')['status'], 'completed')
+ test.assertEqual(dst_vm.cmd('query-status')['status'], 'running')
+ test.assertEqual(src_vm.cmd('query-status')['status'],'postmigrate')
+
+ def migrate(self, test, source_vm, dest_vm, src_uri, timeout):
+ source_vm.qmp('migrate', uri=src_uri)
+ self.assert_migration(test, source_vm, dest_vm, timeout)
diff --git a/tests/functional/test_migration.py b/tests/functional/test_migration.py
index c4393c3543..1c75a98330 100755
--- a/tests/functional/test_migration.py
+++ b/tests/functional/test_migration.py
@@ -15,6 +15,7 @@
import time
from qemu_test import QemuSystemTest, skipIfMissingCommands
+from qemu_test.migration import Migration
from qemu_test.ports import Ports
@@ -22,25 +23,6 @@ class MigrationTest(QemuSystemTest):
timeout = 10
- @staticmethod
- def migration_finished(vm):
- return vm.cmd('query-migrate')['status'] in ('completed', 'failed')
-
- def assert_migration(self, src_vm, dst_vm):
-
- end = time.monotonic() + self.timeout
- while time.monotonic() < end and not self.migration_finished(src_vm):
- time.sleep(0.1)
-
- end = time.monotonic() + self.timeout
- while time.monotonic() < end and not self.migration_finished(dst_vm):
- time.sleep(0.1)
-
- self.assertEqual(src_vm.cmd('query-migrate')['status'], 'completed')
- self.assertEqual(dst_vm.cmd('query-migrate')['status'], 'completed')
- self.assertEqual(dst_vm.cmd('query-status')['status'], 'running')
- self.assertEqual(src_vm.cmd('query-status')['status'],'postmigrate')
-
def select_machine(self):
target_machine = {
'aarch64': 'quanta-gsj',
@@ -67,8 +49,8 @@ def do_migrate(self, dest_uri, src_uri=None):
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)
+
+ Migration().migrate(self, source_vm, dest_vm, src_uri, self.timeout)
def _get_free_port(self, ports):
port = ports.find_free_port()
--
2.35.3
next prev parent reply other threads:[~2025-08-19 22:40 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-08-19 22:39 [PATCH 0/4] ppc: Fix migration issues with XICS and quiesce Fabiano Rosas
2025-08-19 22:39 ` [PATCH 1/4] hw/intc/xics: Add missing call to register vmstate_icp_server Fabiano Rosas
2025-09-18 15:28 ` Gautam Menghani
2025-08-19 22:39 ` Fabiano Rosas [this message]
2025-08-20 6:50 ` [RFC PATCH 2/4] tests/functional: Extract migration code into a new class Thomas Huth
2025-08-19 22:39 ` [RFC PATCH 3/4] tests/functional: Add a OS level migration test for pseries Fabiano Rosas
2025-08-20 7:03 ` Thomas Huth
2025-08-20 15:08 ` Fabiano Rosas
2025-08-19 22:39 ` [PATCH 4/4] target/ppc: Fix env->quiesced migration Fabiano Rosas
2025-08-20 6:55 ` Thomas Huth
2025-08-20 15:07 ` Fabiano Rosas
2025-08-20 15:20 ` Thomas Huth
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250819223905.2247-3-farosas@suse.de \
--to=farosas@suse.de \
--cc=berrange@redhat.com \
--cc=fvogt@suse.de \
--cc=npiggin@gmail.com \
--cc=peterx@redhat.com \
--cc=philmd@linaro.org \
--cc=qemu-devel@nongnu.org \
--cc=thuth@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).