From patchwork Fri Mar 27 15:48:03 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Glauber Costa X-Patchwork-Id: 14756 Received: from vger.kernel.org (vger.kernel.org [209.132.176.167]) by demeter.kernel.org (8.14.2/8.14.2) with ESMTP id n2RFnFbX016575 for ; Fri, 27 Mar 2009 15:49:15 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756030AbZC0Psa (ORCPT ); Fri, 27 Mar 2009 11:48:30 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1758065AbZC0Psa (ORCPT ); Fri, 27 Mar 2009 11:48:30 -0400 Received: from mx2.redhat.com ([66.187.237.31]:36397 "EHLO mx2.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756030AbZC0Ps3 (ORCPT ); Fri, 27 Mar 2009 11:48:29 -0400 Received: from int-mx2.corp.redhat.com (int-mx2.corp.redhat.com [172.16.27.26]) by mx2.redhat.com (8.13.8/8.13.8) with ESMTP id n2RFmSS4031470 for ; Fri, 27 Mar 2009 11:48:28 -0400 Received: from ns3.rdu.redhat.com (ns3.rdu.redhat.com [10.11.255.199]) by int-mx2.corp.redhat.com (8.13.1/8.13.1) with ESMTP id n2RFmKUn032225 for ; Fri, 27 Mar 2009 11:48:20 -0400 Received: from localhost.localdomain (virtlab1.virt.bos.redhat.com [10.16.72.21]) by ns3.rdu.redhat.com (8.13.8/8.13.8) with ESMTP id n2RFmRbV016963 for ; Fri, 27 Mar 2009 11:48:27 -0400 From: Glauber Costa To: kvm@vger.kernel.org Subject: [PATCH autotest] commonize log_into_alive_vm code Date: Fri, 27 Mar 2009 11:48:03 -0400 Message-Id: <1238168883-28482-1-git-send-email-glommer@redhat.com> X-Scanned-By: MIMEDefang 2.58 on 172.16.27.26 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org 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 --- client/tests/kvm_runtest_2/kvm_tests.py | 47 ++++++------------------------ 1 files changed, 10 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..317e076 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,13 @@ def run_boot(test, params, env): kvm_log.info("Logged in") + return session + +def run_boot(test, params, env): + vm = kvm_utils.env_get_vm(env, params.get("main_vm")) + + session = 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 +208,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") + session = log_into_alive_vm(vm) # Collect some info test_name = params.get("test_name") @@ -378,25 +368,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") + session = 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)