All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/3] Launch other test during migration
@ 2010-09-25  9:36 Jason Wang
  2010-09-25  9:36 ` [PATCH 1/3] KVM Test: Introduce a helper class to run a test in the background Jason Wang
                   ` (3 more replies)
  0 siblings, 4 replies; 12+ messages in thread
From: Jason Wang @ 2010-09-25  9:36 UTC (permalink / raw)
  To: lmr, autotest; +Cc: kvm, mst

We could give a further test of migration by launch test during migartion. So
the following series implements:

- A simple class to run a specified test in the background which could be used
to launch other test during migartion. Its design is rather simple and its usage
is a little tricky, but it work well.
- Two sample tests which take advantages of the background class: Test reboot
during guest migration and test file_transfer during guest migration.

In the future, we could even lauch autotest client test during guest migation.

---

Jason Wang (3):
      KVM Test: Introduce a helper class to run a test in the background
      KVM test: Test reboot during migration
      KVM test: Test the file transfer during migartion


 client/tests/kvm/kvm_test_utils.py                 |   44 +++++++++++++++
 .../kvm/tests/migration_with_file_transfer.py      |   59 ++++++++++++++++++++
 client/tests/kvm/tests/migration_with_reboot.py    |   45 +++++++++++++++
 client/tests/kvm/tests_base.cfg.sample             |   12 ++++
 4 files changed, 159 insertions(+), 1 deletions(-)
 create mode 100644 client/tests/kvm/tests/migration_with_file_transfer.py
 create mode 100644 client/tests/kvm/tests/migration_with_reboot.py

-- 
Jason Wang

^ permalink raw reply	[flat|nested] 12+ messages in thread
* [PATCH 1/3] KVM Test: Introduce a helper class to run a test in the background
@ 2010-11-26 23:01 Lucas Meneghel Rodrigues
  2010-11-26 23:01 ` [PATCH 3/3] KVM test: Test the file transfer during migartion Lucas Meneghel Rodrigues
  0 siblings, 1 reply; 12+ messages in thread
From: Lucas Meneghel Rodrigues @ 2010-11-26 23:01 UTC (permalink / raw)
  To: autotest; +Cc: kvm, Lucas Meneghel Rodrigues, Jason Wang

Sometimes, we need to run a test when doing operations on a running VM
(such as migrate the vm during its rebooting ). So this patch introduces
a simple warpper BackgroundTest to run a specified test in the background
through a dedicated thread, it also records the exception raised in the
thead and raise it when master call join().

Changes from v1:
- Rebase against latest upstream

Signed-off-by: Jason Wang <jasowang@redhat.com>
---
 client/tests/kvm/kvm_test_utils.py |   49 +++++++++++++++++++++++++++++++++++-
 1 files changed, 48 insertions(+), 1 deletions(-)

diff --git a/client/tests/kvm/kvm_test_utils.py b/client/tests/kvm/kvm_test_utils.py
index e7c8d33..218bf31 100644
--- a/client/tests/kvm/kvm_test_utils.py
+++ b/client/tests/kvm/kvm_test_utils.py
@@ -21,7 +21,7 @@ More specifically:
 @copyright: 2008-2009 Red Hat Inc.
 """
 
-import time, os, logging, re, commands, signal
+import time, os, logging, re, commands, signal, threading
 from autotest_lib.client.common_lib import error
 from autotest_lib.client.bin import utils
 import kvm_utils, kvm_vm, kvm_subprocess, scan_results
@@ -564,6 +564,53 @@ def run_autotest(vm, session, control_path, timeout, outputdir):
         raise error.TestFail(e_msg)
 
 
+class BackgroundTest(object):
+    """
+    This class would run a test in background through a dedicated thread.
+    """
+
+    def __init__(self, func, params):
+        """
+        Initialize the object and set a few attributes.
+        """
+        self.thread = threading.Thread(target=self.launch,
+                                       args=(func, params))
+        self.exception = None
+
+
+    def launch(self, func, params):
+        """
+        Catch and record the exception.
+        """
+        try:
+            func(*params)
+        except Exception, e:
+            self.exception = e
+
+
+    def start(self):
+        """
+        Run func(params) in a dedicated thread
+        """
+        self.thread.start()
+
+
+    def join(self):
+        """
+        Wait for the join of thread and raise its exception if any.
+        """
+        self.thread.join()
+        if self.exception:
+            raise self.exception
+
+
+    def is_alive(self):
+        """
+        Check whether the test is still alive.
+        """
+        return self.thread.is_alive()
+
+
 def get_loss_ratio(output):
     """
     Get the packet loss ratio from the output of ping
-- 
1.7.2.3


^ permalink raw reply related	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2010-11-26 23:01 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-09-25  9:36 [PATCH 0/3] Launch other test during migration Jason Wang
2010-09-25  9:36 ` [PATCH 1/3] KVM Test: Introduce a helper class to run a test in the background Jason Wang
2010-09-25  9:36 ` [PATCH 2/3] KVM test: Test reboot during migration Jason Wang
2010-09-25  9:36 ` [PATCH 3/3] KVM test: Test the file transfer during migartion Jason Wang
2010-11-01 15:58   ` Michael Goldish
2010-11-02  5:34     ` Jason Wang
2010-11-01 15:45 ` [PATCH 0/3] Launch other test during migration Michael Goldish
2010-11-02  5:34   ` Jason Wang
2010-11-02  8:14     ` Michael Goldish
2010-11-03  2:53       ` Jason Wang
2010-11-03  9:08         ` Michael Goldish
  -- strict thread matches above, loose matches on Subject: below --
2010-11-26 23:01 [PATCH 1/3] KVM Test: Introduce a helper class to run a test in the background Lucas Meneghel Rodrigues
2010-11-26 23:01 ` [PATCH 3/3] KVM test: Test the file transfer during migartion Lucas Meneghel Rodrigues

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.