diff mbox

Autotest 0.11.1: KVM test: Fixing shutdown test

Message ID 1253126876.2882.8.camel@localhost.localdomain (mailing list archive)
State New, archived
Headers show

Commit Message

Lucas Meneghel Rodrigues Sept. 16, 2009, 6:47 p.m. UTC
Only close session after we are sure the guest is down on shutdown test.
Backport of a fix present on trunk.

Signed-off-by: Lucas Meneghel Rodrigues <lmr@redhat.com>
---


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

Patch

Index: 0.11.1/client/tests/kvm/kvm_tests.py
===================================================================
--- 0.11.1/client/tests/kvm/kvm_tests.py	(revision 3662)
+++ 0.11.1/client/tests/kvm/kvm_tests.py	(working copy)
@@ -74,26 +74,29 @@ 
     if not vm.is_alive():
         raise error.TestError("VM seems to be dead; Test requires a living VM")
 
-    logging.info("Waiting for guest to be up...")
+    try:
+        logging.info("Waiting for guest to be up...")
 
-    session = kvm_utils.wait_for(vm.ssh_login, 240, 0, 2)
-    if not session:
-        raise error.TestFail("Could not log into guest")
+        session = kvm_utils.wait_for(vm.ssh_login, 240, 0, 2)
+        if not session:
+            raise error.TestFail("Could not log into guest")
 
-    logging.info("Logged in")
+        logging.info("Logged in")
 
-    # Send the VM's shutdown command
-    session.sendline(vm.get_params().get("cmd_shutdown"))
-    session.close()
+        # Send the VM's shutdown command
+        session.sendline(vm.get_params().get("cmd_shutdown"))
 
-    logging.info("Shutdown command sent; waiting for guest to go down...")
+        logging.info("Shutdown command sent; waiting for guest to go down...")
 
-    if not kvm_utils.wait_for(vm.is_dead, 240, 0, 1):
-        raise error.TestFail("Guest refuses to go down")
+        if not kvm_utils.wait_for(vm.is_dead, 240, 0, 1):
+            raise error.TestFail("Guest refuses to go down")
 
-    logging.info("Guest is down")
+        logging.info("Guest is down")
 
+    finally:
+        session.close()
 
+
 def run_migration(test, params, env):
     """
     KVM migration test: