diff mbox

[10/19] KVM test: boot test: add option to reboot using system_reset

Message ID 1252519932-30733-10-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
The boot test now behaves as follows:
- Normally it just waits for the guest to go up and logs into it.
- If reboot_method is specified and equals "shell", the guest is sent a reboot
  shell command, and the test waits until the guest comes back up.
- If reboot method is specified and equals "system_reset", the VM is sent a
  system_reset monitor command, and the test waits until the guest comes back
  up.
  Before sending the system_reset command the test sleeps for a given duration.
  The duration is controlled by the parameter 'sleep_before_reset'.

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

Patch

diff --git a/client/tests/kvm/kvm_tests.cfg.sample b/client/tests/kvm/kvm_tests.cfg.sample
index 73e929f..0703e64 100644
--- a/client/tests/kvm/kvm_tests.cfg.sample
+++ b/client/tests/kvm/kvm_tests.cfg.sample
@@ -58,7 +58,7 @@  variants:
 
     - reboot:       install setup
         type = boot
-        reboot = yes
+        reboot_method = shell
         kill_vm_on_error = yes
 
     - migrate:      install setup
@@ -127,6 +127,12 @@  variants:
             - notepad:
                 autoit_script = autoit/notepad1.au3
 
+    - system_reset: install setup
+        type = boot
+        reboot_method = system_reset
+        sleep_before_reset = 20
+        kill_vm_on_error = yes
+
     - shutdown:     install setup
         type = shutdown
         kill_vm = yes
diff --git a/client/tests/kvm/kvm_tests.py b/client/tests/kvm/kvm_tests.py
index c2bfb8a..801b84e 100644
--- a/client/tests/kvm/kvm_tests.py
+++ b/client/tests/kvm/kvm_tests.py
@@ -13,9 +13,9 @@  def run_boot(test, params, env):
     """
     KVM reboot test:
     1) Log into a guest
-    2) Send a reboot command to the guest
-    3) Wait until it's up.
-    4) Log into the guest to verify it's up again.
+    2) Send a reboot command or a system_reset monitor command (optional)
+    3) Wait until the guest is up again
+    4) Log into the guest to verify it's up again
 
     @param test: kvm test object
     @param params: Dictionary with the test parameters
@@ -33,13 +33,24 @@  def run_boot(test, params, env):
     if not session:
         raise error.TestFail("Could not log into guest")
 
-    logging.info("Logged in")
-
-    if params.get("reboot") == "yes":
-        # Send the VM's reboot command
-        session.sendline(vm.get_params().get("reboot_command"))
-        logging.info("Reboot command sent; waiting for guest to go down...")
+    try:
+        logging.info("Logged in")
 
+        if params.get("reboot_method") == "shell":
+            # Send a reboot command to the guest's shell
+            session.sendline(vm.get_params().get("reboot_command"))
+            logging.info("Reboot command sent; waiting for guest to go "
+                         "down...")
+        elif params.get("reboot_method") == "system_reset":
+            # Sleep for a while -- give the guest a chance to finish booting
+            time.sleep(float(params.get("sleep_before_reset", 10)))
+            # Send a system_reset monitor command
+            vm.send_monitor_cmd("system_reset")
+            logging.info("system_reset monitor command sent; waiting for "
+                         "guest to go down...")
+        else: return
+
+        # Wait for the session to become unresponsive
         if not kvm_utils.wait_for(lambda: not session.is_responsive(),
                                   120, 0, 1):
             raise error.TestFail("Guest refuses to go down")
@@ -54,7 +65,8 @@  def run_boot(test, params, env):
 
         logging.info("Guest is up again")
 
-    session.close()
+    finally:
+        session.close()
 
 
 def run_shutdown(test, params, env):