From patchwork Tue Jan 11 13:13:23 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Goldish X-Patchwork-Id: 471531 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.3) with ESMTP id p0BDDSji008028 for ; Tue, 11 Jan 2011 13:13:35 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932150Ab1AKNNc (ORCPT ); Tue, 11 Jan 2011 08:13:32 -0500 Received: from mx1.redhat.com ([209.132.183.28]:4659 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932137Ab1AKNN0 (ORCPT ); Tue, 11 Jan 2011 08:13:26 -0500 Received: from int-mx12.intmail.prod.int.phx2.redhat.com (int-mx12.intmail.prod.int.phx2.redhat.com [10.5.11.25]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id p0BDDQ0S015379 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Tue, 11 Jan 2011 08:13:26 -0500 Received: from ns3.rdu.redhat.com (ns3.rdu.redhat.com [10.11.255.199]) by int-mx12.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id p0BDDPbZ013225; Tue, 11 Jan 2011 08:13:25 -0500 Received: from qu0061.eng.lab.tlv.redhat.com ([10.35.16.61]) by ns3.rdu.redhat.com (8.13.8/8.13.8) with ESMTP id p0BDD9nX025030; Tue, 11 Jan 2011 08:13:24 -0500 From: Michael Goldish To: autotest@test.kernel.org, kvm@vger.kernel.org Cc: Michael Goldish Subject: [KVM-AUTOTEST PATCH 11/26] KVM test: cleanup and contextify stress_boot Date: Tue, 11 Jan 2011 15:13:23 +0200 Message-Id: <1294751618-21631-11-git-send-email-mgoldish@redhat.com> In-Reply-To: <1294751618-21631-1-git-send-email-mgoldish@redhat.com> References: <1294751618-21631-1-git-send-email-mgoldish@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.25 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter1.kernel.org [140.211.167.41]); Tue, 11 Jan 2011 13:13:36 +0000 (UTC) diff --git a/client/tests/kvm/tests/stress_boot.py b/client/tests/kvm/tests/stress_boot.py index 752bd72..15ebd20 100644 --- a/client/tests/kvm/tests/stress_boot.py +++ b/client/tests/kvm/tests/stress_boot.py @@ -3,7 +3,8 @@ from autotest_lib.client.common_lib import error import kvm_subprocess, kvm_test_utils, kvm_utils, kvm_preprocessing -def run_stress_boot(tests, params, env): +@error.context_aware +def run_stress_boot(test, params, env): """ Boots VMs until one of them becomes unresponsive, and records the maximum number of VMs successfully started: @@ -16,47 +17,37 @@ def run_stress_boot(tests, params, env): @param params: Dictionary with the test parameters @param env: Dictionary with test environment. """ - # boot the first vm + error.base_context("waiting for the first guest to be up", logging.info) vm = env.get_vm(params["main_vm"]) vm.verify_alive() - - logging.info("Waiting for first guest to be up...") - login_timeout = float(params.get("login_timeout", 240)) session = vm.wait_for_login(timeout=login_timeout) num = 2 sessions = [session] - # boot the VMs - while num <= int(params.get("max_vms")): - try: - # clone vm according to the first one - vm_name = "vm" + str(num) - vm_params = vm.get_params().copy() + # Boot the VMs + try: + while num <= int(params.get("max_vms")): + # Clone vm according to the first one + error.base_context("booting guest #%d" % num, logging.info) + vm_name = "vm%d" % num + vm_params = vm.params.copy() curr_vm = vm.clone(vm_name, vm_params) env.register_vm(vm_name, curr_vm) - logging.info("Booting guest #%d" % num) - kvm_preprocessing.preprocess_vm(tests, vm_params, env, vm_name) - params['vms'] += " " + vm_name + kvm_preprocessing.preprocess_vm(test, vm_params, env, vm_name) + params["vms"] += " " + vm_name sessions.append(curr_vm.wait_for_login(timeout=login_timeout)) - logging.info("Guest #%d boots up successfully" % num) + logging.info("Guest #%d booted up successfully" % num) - # check whether all previous shell sessions are responsive + # Check whether all previous shell sessions are responsive for i, se in enumerate(sessions): - try: - se.cmd(params.get("alive_test_cmd")) - except kvm_subprocess.ShellError: - raise error.TestFail("Session #%d is not responsive" % i) + error.context("checking responsiveness of guest #%d" % (i + 1), + logging.debug) + se.cmd(params.get("alive_test_cmd")) num += 1 - - except (error.TestFail, OSError): - for se in sessions: - se.close() - logging.info("Total number booted: %d" % (num - 1)) - raise - else: + finally: for se in sessions: se.close() logging.info("Total number booted: %d" % (num -1))