qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH v2 2/2] Acceptance tests: add simple migration t


From: Wainer dos Santos Moschetta
Subject: Re: [Qemu-devel] [PATCH v2 2/2] Acceptance tests: add simple migration test
Date: Tue, 29 Jan 2019 16:46:27 -0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.5.2


On 01/28/2019 03:47 PM, Caio Carrara wrote:
From: Cleber Rosa <address@hidden>

This is the simplest possible migration test, exercising the multi
VM capabilities of the test class.

Signed-off-by: Cleber Rosa <address@hidden>
---
  tests/acceptance/migration.py | 45 +++++++++++++++++++++++++++++++++++
  1 file changed, 45 insertions(+)
  create mode 100644 tests/acceptance/migration.py

diff --git a/tests/acceptance/migration.py b/tests/acceptance/migration.py
new file mode 100644
index 0000000000..973ae0ab4b
--- /dev/null
+++ b/tests/acceptance/migration.py
@@ -0,0 +1,45 @@
+# Migration test
+#
+# Copyright (c) 2019 Red Hat, Inc.
+#
+# Author:
+#  Cleber Rosa <address@hidden>
+#
+# This work is licensed under the terms of the GNU GPL, version 2 or
+# later.  See the COPYING file in the top-level directory.
+
+
+from avocado_qemu import Test
+
+from avocado.utils import network
+from avocado.utils import wait
+
+
+class Migration(Test):
+    """
+    :avocado: enable
+    """
+
+    timeout = 10
+
+    @staticmethod
+    def migration_completed(vm):
+        cmd_result = vm.qmp('query-migrate')
+        if cmd_result is not None:
+            result = cmd_result.get('return')
+            if result is not None:
+                return result.get('status') == 'completed'

You could verify other status that indicate failure on the migration to nicely fail the test, because the printed messaged on timeout does not help much to identify what went wrong.

It could be something like:

-    @staticmethod
-    def migration_completed(vm):
+    def migration_completed(self, vm):
         cmd_result = vm.qmp('query-migrate')
         if cmd_result is not None:
             result = cmd_result.get('return')
             if result is not None:
+                self.assertNotEqual(result.get('status'), 'failed')
                 return result.get('status') == 'completed'
         return False


+        return False
+
+    def test_tcp(self):

What if you rename it to something like "test_with_tcp_on_localhost" to better represent the test scenario?

- Wainer

+        source = self.get_vm()
+        port = network.find_free_port()
+        if port is None:
+            self.cancel('Failed to find a free port')
+        dest_uri = 'tcp:localhost:%u' % port
+        dest = self.get_vm('-incoming', dest_uri)
+        dest.launch()
+        source.launch()
+        source.qmp('migrate', uri=dest_uri)
+        wait.wait_for(self.migration_completed, timeout=self.timeout,
+                      step=0.1, args=(source,))




reply via email to

[Prev in Thread] Current Thread [Next in Thread]