Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(59)

Unified Diff: client/tests/kvm/tests/stress_boot.py

Issue 6246035: Merge remote branch 'cros/upstream' into master (Closed) Base URL: ssh://git@gitrw.chromium.org:9222/autotest.git@master
Patch Set: patch Created 9 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: client/tests/kvm/tests/stress_boot.py
diff --git a/client/tests/kvm/tests/stress_boot.py b/client/tests/kvm/tests/stress_boot.py
index b7916b490499beca3ab75368ea40742c36502d6c..0c422c03c93413d0840512f66f38996ea6bbf23a 100644
--- a/client/tests/kvm/tests/stress_boot.py
+++ b/client/tests/kvm/tests/stress_boot.py
@@ -1,9 +1,10 @@
-import logging, time
+import logging
from autotest_lib.client.common_lib import error
-import kvm_subprocess, kvm_test_utils, kvm_utils, kvm_preprocessing
+import 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,51 +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
- vm = kvm_test_utils.get_living_vm(env, params.get("main_vm"))
-
- logging.info("Waiting for first guest to be up...")
-
+ error.base_context("waiting for the first guest to be up", logging.info)
+ vm = env.get_vm(params["main_vm"])
+ vm.verify_alive()
login_timeout = float(params.get("login_timeout", 240))
- session = kvm_utils.wait_for(vm.remote_login, login_timeout, 0, 2)
- if not session:
- raise error.TestFail("Could not log into first guest")
+ 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)
- kvm_utils.env_register_vm(env, vm_name, curr_vm)
- logging.info("Booting guest #%d" % num)
- kvm_preprocessing.preprocess_vm(tests, vm_params, env, vm_name)
- params['vms'] += " " + vm_name
+ env.register_vm(vm_name, curr_vm)
+ kvm_preprocessing.preprocess_vm(test, vm_params, env, vm_name)
+ params["vms"] += " " + vm_name
- curr_vm_session = kvm_utils.wait_for(curr_vm.remote_login,
- login_timeout, 0, 2)
- if not curr_vm_session:
- raise error.TestFail("Could not log into guest #%d" % num)
+ sessions.append(curr_vm.wait_for_login(timeout=login_timeout))
+ logging.info("Guest #%d booted up successfully", num)
- logging.info("Guest #%d boots up successfully" % num)
- sessions.append(curr_vm_session)
-
- # check whether all previous shell sessions are responsive
+ # Check whether all previous shell sessions are responsive
for i, se in enumerate(sessions):
- if se.get_command_status(params.get("alive_test_cmd")) != 0:
- 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))

Powered by Google App Engine
This is Rietveld 408576698