[PATCH 2/3] KVM test: migration subtest - Introduce migration_living_guest param

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

 



In order to test a special guest configuration (special blkdebug
config files to inject errors on the block subsystem), added a
migration_living_guest param. If the param is set to "no", no
attempt to have a session on the guest will be made, since the
guest block subsystem will stop when the first error is injected.

Signed-off-by: Lucas Meneghel Rodrigues <lmr@xxxxxxxxxx>
---
 client/tests/kvm/tests/migration.py |   78 ++++++++++++++++++++---------------
 1 files changed, 45 insertions(+), 33 deletions(-)

diff --git a/client/tests/kvm/tests/migration.py b/client/tests/kvm/tests/migration.py
index 7e877fe..1e02784 100644
--- a/client/tests/kvm/tests/migration.py
+++ b/client/tests/kvm/tests/migration.py
@@ -36,34 +36,40 @@ def run_migration(test, params, env):
         mig_speed = params.get("mig_speed", "1G")
         return vm.monitor.migrate_set_speed(mig_speed)
 
-    vm = env.get_vm(params["main_vm"])
-    vm.verify_alive()
-    timeout = int(params.get("login_timeout", 360))
-    session = vm.wait_for_login(timeout=timeout)
-
     mig_timeout = float(params.get("mig_timeout", "3600"))
     mig_protocol = params.get("migration_protocol", "tcp")
     mig_cancel_delay = int(params.get("mig_cancel") == "yes") * 2
     offline = params.get("offline", "no") == "yes"
     check = params.get("vmstate_check", "no") == "yes"
+    living_guest_os = params.get("migration_living_guest", "yes") == "yes"
+
+    vm = env.get_vm(params["main_vm"])
+    vm.verify_alive()
+    timeout = int(params.get("login_timeout", 360))
+    if living_guest_os:
+        session = vm.wait_for_login(timeout=timeout)
 
     # Get the output of migration_test_command
-    test_command = params.get("migration_test_command")
-    reference_output = session.cmd_output(test_command)
+    if living_guest_os:
+        test_command = params.get("migration_test_command")
+        reference_output = session.cmd_output(test_command)
 
     # Start some process in the background (and leave the session open)
-    background_command = params.get("migration_bg_command", "")
-    session.sendline(background_command)
-    time.sleep(5)
+    if living_guest_os:
+        background_command = params.get("migration_bg_command", "")
+        session.sendline(background_command)
+        time.sleep(5)
 
     # Start another session with the guest and make sure the background
     # process is running
-    session2 = vm.wait_for_login(timeout=timeout)
+    if living_guest_os:
+        session2 = vm.wait_for_login(timeout=timeout)
 
     try:
-        check_command = params.get("migration_bg_check_command", "")
-        session2.cmd(check_command, timeout=30)
-        session2.close()
+        if living_guest_os:
+            check_command = params.get("migration_bg_check_command", "")
+            session2.cmd(check_command, timeout=30)
+            session2.close()
 
         # run some functions before migrate start.
         pre_migrate = get_functions(params.get("pre_migrate"), locals())
@@ -79,32 +85,38 @@ def run_migration(test, params, env):
             func()
 
         # Log into the guest again
-        logging.info("Logging into guest after migration...")
-        session2 = vm.wait_for_login(timeout=30)
-        logging.info("Logged in after migration")
+        if living_guest_os:
+            logging.info("Logging into guest after migration...")
+            session2 = vm.wait_for_login(timeout=30)
+            logging.info("Logged in after migration")
 
         # Make sure the background process is still running
-        session2.cmd(check_command, timeout=30)
+        if living_guest_os:
+            session2.cmd(check_command, timeout=30)
 
         # Get the output of migration_test_command
-        output = session2.cmd_output(test_command)
+        if living_guest_os:
+            output = session2.cmd_output(test_command)
 
         # Compare output to reference output
-        if output != reference_output:
-            logging.info("Command output before migration differs from "
-                         "command output after migration")
-            logging.info("Command: %s", test_command)
-            logging.info("Output before:" +
-                         virt_utils.format_str_for_message(reference_output))
-            logging.info("Output after:" +
-                         virt_utils.format_str_for_message(output))
-            raise error.TestFail("Command '%s' produced different output "
-                                 "before and after migration" % test_command)
+        if living_guest_os:
+            if output != reference_output:
+                logging.info("Command output before migration differs from "
+                             "command output after migration")
+                logging.info("Command: %s", test_command)
+                logging.info("Output before:" +
+                             virt_utils.format_str_for_message(reference_output))
+                logging.info("Output after:" +
+                             virt_utils.format_str_for_message(output))
+                raise error.TestFail("Command '%s' produced different output "
+                                     "before and after migration" % test_command)
 
     finally:
         # Kill the background process
-        if session2 and session2.is_alive():
-            session2.cmd_output(params.get("migration_bg_kill_command", ""))
+        if living_guest_os:
+            if session2 and session2.is_alive():
+                session2.cmd_output(params.get("migration_bg_kill_command", ""))
 
-    session2.close()
-    session.close()
+    if living_guest_os:
+        session2.close()
+        session.close()
-- 
1.7.6

--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux