public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
From: Marcelo Tosatti <mtosatti@redhat.com>
To: Lucas Meneghel Rodrigues <lmr@redhat.com>
Cc: kvm <kvm@vger.kernel.org>
Subject: KVM autotest: add boot_savevm test
Date: Thu, 15 Apr 2010 16:09:40 -0300	[thread overview]
Message-ID: <20100415190940.GA5303@amt.cnet> (raw)


This test boots a guest while periodically running savevm/loadvm.

Adjust savevm_delay/guest memory size to reduce run time, if 
excessive.

Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>

Index: autotest/client/tests/kvm/tests/boot_savevm.py
===================================================================
--- /dev/null
+++ autotest/client/tests/kvm/tests/boot_savevm.py
@@ -0,0 +1,54 @@
+import logging, time
+from autotest_lib.client.common_lib import error
+import kvm_subprocess, kvm_test_utils, kvm_utils
+
+def run_boot_savevm(test, params, env):
+    """
+    KVM boot savevm test:
+    1) Start guest
+    2) Periodically savevm/loadvm
+    4) Log into the guest to verify it's up, fail after timeout seconds
+
+    @param test: kvm test object
+    @param params: Dictionary with the test parameters
+    @param env: Dictionary with test environment.
+    """
+    vm = kvm_test_utils.get_living_vm(env, params.get("main_vm"))
+    savevm_delay = float(params.get("savevm_delay"))
+    savevm_login_delay = float(params.get("savevm_login_delay"))
+    logging.info("savevm_delay = %f" % savevm_delay)
+    login_expire = time.time() + savevm_login_delay
+    end_time = time.time() + float(params.get("savevm_timeout"))
+
+    while time.time() < end_time:
+        time.sleep(savevm_delay)
+
+        s, o = vm.send_monitor_cmd("stop")
+        if s:
+            logging.error("stop failed: %r" % o)
+        s, o = vm.send_monitor_cmd("savevm 1")
+        if s:
+            logging.error("savevm failed: %r" % o)
+        s, o = vm.send_monitor_cmd("system_reset")
+        if s:
+            logging.error("system_reset: %r" % o)
+        s, o = vm.send_monitor_cmd("loadvm 1")
+        if s:
+            logging.error("loadvm failed: %r" % o)
+        s, o = vm.send_monitor_cmd("cont")
+        if s:
+            logging.error("cont failed: %r" % o)
+
+         # Log in
+        if (time.time() > login_expire):
+            login_expire = time.time() + savevm_login_delay
+            logging.info("Logging in after loadvm...")
+            session = kvm_utils.wait_for(vm.remote_login, 1, 0, 1)
+            if not session:
+                logging.info("Failed to login")
+            else:
+                logging.info("Logged in to guest!")
+                break
+
+    if (time.time() > end_time):
+        raise error.TestFail("fail: timeout")
Index: autotest/client/tests/kvm/tests_base.cfg.sample
===================================================================
--- autotest.orig/client/tests/kvm/tests_base.cfg.sample
+++ autotest/client/tests/kvm/tests_base.cfg.sample
@@ -105,6 +105,15 @@ variants:
         iterations = 2
         used_mem = 1024
 
+    - boot_savevm: install setup unattended_install
+        type = boot_savevm
+        savevm_delay = 0.3
+        savevm_login_delay = 120
+        savevm_timeout = 2000
+        kill_vm_on_error = yes
+        kill_vm_gracefully = yes
+        kill_vm = yes
+
     - autotest:     install setup unattended_install
         type = autotest
         test_timeout = 1800

             reply	other threads:[~2010-04-15 19:09 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-04-15 19:09 Marcelo Tosatti [this message]
2010-04-17 18:18 ` KVM autotest: add boot_savevm test Lucas Meneghel Rodrigues

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20100415190940.GA5303@amt.cnet \
    --to=mtosatti@redhat.com \
    --cc=kvm@vger.kernel.org \
    --cc=lmr@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox