[autotest] Make test faster by avoiding unnecessary servo check
Looking at dummy_Pass, you will see we do servo check
three times. They come from create_host in control segments of
client_wrapper, crashdumps, and verify_job_repo_url. If a test
choose to log sysinfo, in test.py there are two calls of
create_host which will trigger two more servo check.
None of them really need servo.
This CL allows code to explicitly skip servo when initializing
a host. Each servo check takes 10-20 seconds.
By doing this, I anticipate we can save 30~60 seconds per
test (which has servo), ~20secs on provision.
TEST=Run verify, repair, cleanup, provision
TEST=Test doesn't need servo don't check servo:
Run dummy_Pass, observe no servo check in the log
TEST=Test that need servo do check servo:
Run infra_ServoDiagnosis.py on a host with servo, servo check
was run.
TEST=Run infra_ServoDiagnosis.py on a host with servo,
manually pass servo_args={} in its control file,
fail the servo verify, and make sure servo repair is triggered.
TEST=Run a dummy suite with run_suite.
BUG=chromium:445677, chromium:426141
Change-Id: I06ec28e81b3abb20637f36c717f0d32e2310bd9d
Reviewed-on: https://chromium-review.googlesource.com/238223
Reviewed-by: Fang Deng <fdeng@chromium.org>
Commit-Queue: Fang Deng <fdeng@chromium.org>
Trybot-Ready: Fang Deng <fdeng@chromium.org>
Tested-by: Fang Deng <fdeng@chromium.org>
diff --git a/server/hosts/servo_host.py b/server/hosts/servo_host.py
index 215cba3..7711e6e 100644
--- a/server/hosts/servo_host.py
+++ b/server/hosts/servo_host.py
@@ -607,20 +607,27 @@
return self._servo
-def create_servo_host(dut, servo_args):
+def create_servo_host(dut, servo_args, try_lab_servo=False):
"""Create a ServoHost object.
- There three possible cases:
- 1) If the DUT is in Cros Lab and has a beaglebone and a servo, then
- create a ServoHost object pointing to the beaglebone. servo_args
- is ignored.
- 2) If not case 1) and servo_args is neither None nor empty, then
- create a ServoHost object using servo_args.
- 3) If neither case 1) or 2) applies, return None.
- When the servo_args is not None, we assume the servo is required by the
- test. If servo failed to be verified, we will attempt to repair it. If servo
- is not required, we will initialize ServoHost without initializing a servo
- object.
+ The `servo_args` parameter is a dictionary specifying optional
+ Servo client parameter overrides (i.e. a specific host or port).
+ When specified, the caller requires that an exception be raised
+ unless both the ServoHost and the Servo are successfully
+ created.
+
+ There are three possible cases:
+ 1. If the DUT is in the Cros test lab then the ServoHost object
+ is only created for the host in the lab. Alternate host or
+ port settings in `servo_host` will be ignored.
+ 2. When not case 1., but `servo_args` is not `None`, then create
+ a ServoHost object using `servo_args`.
+ 3. Otherwise, return `None`.
+
+ When the `try_lab_servo` parameter is false, it indicates that a
+ ServoHost should not be created for a device in the Cros test
+ lab. The setting of `servo_args` takes precedence over the
+ setting of `try_lab_servo`.
@param dut: host name of the host that servo connects. It can be used to
lookup the servo in test lab using naming convention.
@@ -629,6 +636,8 @@
e.g. {'servo_host': '172.11.11.111',
'servo_port': 9999}.
See comments above.
+ @param try_lab_servo: Boolean. Whether to create ServoHost for a device
+ in test lab. See above.
@returns: A ServoHost object or None. See comments above.
@@ -636,7 +645,11 @@
lab_servo_hostname = make_servo_hostname(dut)
is_in_lab = utils.host_is_in_lab_zone(lab_servo_hostname)
- if is_in_lab:
+ if not is_in_lab:
+ if servo_args is None:
+ return None
+ return ServoHost(required_by_test=True, is_in_lab=False, **servo_args)
+ elif servo_args is not None or try_lab_servo:
# Technically, this duplicates the SSH ping done early in the servo
# proxy initialization code. However, this ping ends in a couple
# seconds when if fails, rather than the 60 seconds it takes to decide
@@ -653,7 +666,5 @@
if host_is_up:
return ServoHost(servo_host=lab_servo_hostname, is_in_lab=is_in_lab,
required_by_test=(servo_args is not None))
- elif servo_args is not None:
- return ServoHost(required_by_test=True, is_in_lab=False, **servo_args)
else:
return None