public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
From: Glauber Costa <glommer@redhat.com>
To: kvm@vger.kernel.org
Subject: [PATCH kvm-autotest] commonize log_into_alive_vm code
Date: Tue, 24 Mar 2009 09:20:04 -0400	[thread overview]
Message-ID: <1237900804-5352-1-git-send-email-glommer@redhat.com> (raw)

Almost all tests that are and will be have the common
need to log into the vm, and verify it is alive.
It's currently duplicated across all tests, so rip it
to a common location.

Signed-off-by: Glauber Costa <glommer@redhat.com>
---
 client/tests/kvm_runtest_2/kvm_tests.py |   46 ++++++-------------------------
 1 files changed, 9 insertions(+), 37 deletions(-)

diff --git a/client/tests/kvm_runtest_2/kvm_tests.py b/client/tests/kvm_runtest_2/kvm_tests.py
index 31e2f7c..38bc3be 100644
--- a/client/tests/kvm_runtest_2/kvm_tests.py
+++ b/client/tests/kvm_runtest_2/kvm_tests.py
@@ -9,8 +9,7 @@ import ppm_utils
 import scan_results
 
 
-def run_boot(test, params, env):
-    vm = kvm_utils.env_get_vm(env, params.get("main_vm"))
+def log_into_alive_vm(vm):
     if not vm:
         message = "VM object not found in environment"
         kvm_log.error(message)
@@ -30,6 +29,12 @@ def run_boot(test, params, env):
 
     kvm_log.info("Logged in")
 
+
+def run_boot(test, params, env):
+    vm = kvm_utils.env_get_vm(env, params.get("main_vm"))
+
+    log_into_alive_vm(vm)
+
     if params.get("reboot") == "yes":
         session.sendline(params.get("cmd_reboot"))
         kvm_log.info("Reboot command sent; waiting for guest to go down...")
@@ -202,24 +207,8 @@ def run_migration(test, params, env):
 
 def run_autotest(test, params, env):
     vm = kvm_utils.env_get_vm(env, params.get("main_vm"))
-    if not vm:
-        message = "VM object not found in environment"
-        kvm_log.error(message)
-        raise error.TestError, message
-    if not vm.is_alive():
-        message = "VM seems to be dead; Test requires a living VM"
-        kvm_log.error(message)
-        raise error.TestError, message
 
-    kvm_log.info("Logging into guest...")
-
-    session = kvm_utils.wait_for(vm.ssh_login, 240, 0, 2)
-    if not session:
-        message = "Could not log into guest"
-        kvm_log.error(message)
-        raise error.TestFail, message
-
-    kvm_log.info("Logged in")
+    log_into_alive_vm(vm)
 
     # Collect some info
     test_name = params.get("test_name")
@@ -378,25 +367,8 @@ def internal_yum_update(session, command, prompt, timeout):
 
 
 def run_yum_update(test, params, env):
-    vm = kvm_utils.env_get_vm(env, params.get("main_vm"))
-    if not vm:
-        message = "VM object not found in environment"
-        kvm_log.error(message)
-        raise error.TestError, message
-    if not vm.is_alive():
-        message = "VM seems to be dead; Test requires a living VM"
-        kvm_log.error(message)
-        raise error.TestError, message
-
-    kvm_log.info("Logging into guest...")
 
-    session = kvm_utils.wait_for(vm.ssh_login, 120, 0, 2)
-    if not session:
-        message = "Could not log into guest"
-        kvm_log.error(message)
-        raise error.TestFail, message
-
-    kvm_log.info("Logged in")
+    log_into_alive_vm(vm)
 
     internal_yum_update(session, "yum update", params.get("ssh_prompt"), 600)
     internal_yum_update(session, "yum update kernel", params.get("ssh_prompt"), 600)
-- 
1.5.6.6


             reply	other threads:[~2009-03-24 13:20 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-03-24 13:20 Glauber Costa [this message]
2009-03-24 13:47 ` [PATCH kvm-autotest] commonize log_into_alive_vm code Glauber Costa

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=1237900804-5352-1-git-send-email-glommer@redhat.com \
    --to=glommer@redhat.com \
    --cc=kvm@vger.kernel.org \
    /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