diff mbox

[11/19] KVM test: shutdown test: allow shutting down using system_powerdown

Message ID 1252519932-30733-11-git-send-email-mgoldish@redhat.com (mailing list archive)
State New, archived
Headers show

Commit Message

Michael Goldish Sept. 9, 2009, 6:12 p.m. UTC
In addition to using the shutdown command/program, allow using the
system_powerdown monitor command.  The behavior is controlled using the
shutdown_method parameter, which may equal either "shell" or "system_powerdown".

If shutdown_method equals "system_powerdown", the test sleeps a given amount of
time (controlled by the parameter sleep_before_powerdown) and then sends the
system_powerdown monitor command.

Signed-off-by: Michael Goldish <mgoldish@redhat.com>
---
 client/tests/kvm/kvm_tests.cfg.sample |    8 ++++++++
 client/tests/kvm/kvm_tests.py         |   22 ++++++++++++++++------
 2 files changed, 24 insertions(+), 6 deletions(-)
diff mbox

Patch

diff --git a/client/tests/kvm/kvm_tests.cfg.sample b/client/tests/kvm/kvm_tests.cfg.sample
index 0703e64..201b0e1 100644
--- a/client/tests/kvm/kvm_tests.cfg.sample
+++ b/client/tests/kvm/kvm_tests.cfg.sample
@@ -133,8 +133,16 @@  variants:
         sleep_before_reset = 20
         kill_vm_on_error = yes
 
+    - system_powerdown: install setup
+        type = shutdown
+        shutdown_method = system_powerdown
+        sleep_before_powerdown = 20
+        kill_vm = yes
+        kill_vm_gracefully = no
+
     - shutdown:     install setup
         type = shutdown
+        shutdown_method = shell
         kill_vm = yes
         kill_vm_gracefully = no
 
diff --git a/client/tests/kvm/kvm_tests.py b/client/tests/kvm/kvm_tests.py
index 801b84e..863b863 100644
--- a/client/tests/kvm/kvm_tests.py
+++ b/client/tests/kvm/kvm_tests.py
@@ -73,8 +73,9 @@  def run_shutdown(test, params, env):
     """
     KVM shutdown test:
     1) Log into a guest
-    2) Send a shutdown command to the guest
-    3) Wait until it's down
+    2) Send a shutdown command to the guest, or issue a system_powerdown
+       monitor command (depending on the value of shutdown_method)
+    3) Wait until the guest is down
 
     @param test: kvm test object
     @param params: Dictionary with the test parameters
@@ -95,15 +96,24 @@  def run_shutdown(test, params, env):
     try:
         logging.info("Logged in")
 
-        # 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...")
+        if params.get("shutdown_method") == "shell":
+            # Send a shutdown command to the guest's shell
+            session.sendline(vm.get_params().get("shutdown_command"))
+            logging.info("Shutdown command sent; waiting for guest to go "
+                         "down...")
+        elif params.get("shutdown_method") == "system_powerdown":
+            # Sleep for a while -- give the guest a chance to finish booting
+            time.sleep(float(params.get("sleep_before_powerdown", 10)))
+            # Send a system_powerdown monitor command
+            vm.send_monitor_cmd("system_powerdown")
+            logging.info("system_powerdown monitor 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")
 
         logging.info("Guest is down")
+
     finally:
         session.close()