diff mbox

[KVM-AUTOTEST,6/7] KVM test: shutdown test: do not close session immediately after shutdown command

Message ID f7cb42547b5bb42dd09703acd7b852f9ac9c596a.1249835925.git.mgoldish@redhat.com (mailing list archive)
State New, archived
Headers show

Commit Message

Michael Goldish Aug. 9, 2009, 4:51 p.m. UTC
If the session is closed immediately after a command is sent, the command may
not be executed.
To overcome this, first wait for the guest to shut down, and then close
the session.

Signed-off-by: Michael Goldish <mgoldish@redhat.com>
---
 client/tests/kvm/kvm_tests.py |   18 ++++++++++--------
 1 files changed, 10 insertions(+), 8 deletions(-)
diff mbox

Patch

diff --git a/client/tests/kvm/kvm_tests.py b/client/tests/kvm/kvm_tests.py
index d98dbae..9cd01e2 100644
--- a/client/tests/kvm/kvm_tests.py
+++ b/client/tests/kvm/kvm_tests.py
@@ -80,18 +80,20 @@  def run_shutdown(test, params, env):
     if not session:
         raise error.TestFail("Could not log into guest")
 
-    logging.info("Logged in")
+    try:
+        logging.info("Logged in")
 
-    # Send the VM's shutdown command
-    session.sendline(vm.get_params().get("shutdown_command"))
-    session.close()
+        # Send the VM's shutdown command
+        session.sendline(vm.get_params().get("shutdown_command"))
+        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):