Autotest: Add host class check, and change parameter of
machine_install_by_devserver.
This CL handles two cases:
1. if the DUT has job_url, and pass it into provision_AutoUpdate test as
update_url, the machine_install_by_devserver func will fail since it does
not have a parameter 'update_url'.
2. Only trigger devserver to do auto-update if the host is a CrosHost.
BUG=chromium:638728
TEST=Run /usr/local/autotest/server/autoserv -p -r
/tmp/chromeos2-row3-rack3-host16-16-provision -m chromeos2-row3-rack3-host16
--verbose --lab True --provision --job-labels
cros-version:gandof-release/R54-8630.0.0 on hot.
Run repair/provision_AutoUpdate.double on local autotest.
Change-Id: Ia411f91727516b61e8a9af69b56b1759115f2031
Reviewed-on: https://chromium-review.googlesource.com/375939
Commit-Ready: Xixuan Wu <xixuan@chromium.org>
Tested-by: Xixuan Wu <xixuan@chromium.org>
Reviewed-by: Allen Li <ayatane@chromium.org>
Reviewed-by: Dan Shi <dshi@google.com>
Reviewed-on: https://chromium-review.googlesource.com/391221
Commit-Queue: Xixuan Wu <xixuan@chromium.org>
diff --git a/server/afe_utils.py b/server/afe_utils.py
index b6e000e..8c41ef3 100644
--- a/server/afe_utils.py
+++ b/server/afe_utils.py
@@ -230,11 +230,13 @@
"""
clear_version_labels(host)
clear_host_attributes_before_provision(host)
- if not ENABLE_DEVSERVER_TRIGGER_AUTO_UPDATE:
- image_name, host_attributes = host.machine_install(*args, **dargs)
- else:
+ # If ENABLE_DEVSERVER_TRIGGER_AUTO_UPDATE is enabled and the host is a
+ # CrosHost, devserver will be used to trigger auto-update.
+ if host.support_devserver_provision:
image_name, host_attributes = host.machine_install_by_devserver(
*args, **dargs)
+ else:
+ image_name, host_attributes = host.machine_install(*args, **dargs)
for attribute, value in host_attributes.items():
update_host_attribute(host, attribute, value)
add_version_label(host, image_name)
diff --git a/server/hosts/base_classes.py b/server/hosts/base_classes.py
index 2359258..63f6f28 100644
--- a/server/hosts/base_classes.py
+++ b/server/hosts/base_classes.py
@@ -49,6 +49,7 @@
"""
bootloader = None
+ support_devserver_provision = False
def __init__(self, *args, **dargs):
diff --git a/server/hosts/cros_host.py b/server/hosts/cros_host.py
index 49c25a2..ea68416 100644
--- a/server/hosts/cros_host.py
+++ b/server/hosts/cros_host.py
@@ -44,6 +44,9 @@
CONFIG = global_config.global_config
+ENABLE_DEVSERVER_TRIGGER_AUTO_UPDATE = CONFIG.get_config_value(
+ 'CROS', 'enable_devserver_trigger_auto_update', type=bool,
+ default=False)
LUCID_SLEEP_BOARDS = ['samus', 'lulu']
@@ -60,6 +63,7 @@
_parser = autoserv_parser.autoserv_parser
_AFE = frontend_wrappers.RetryingAFE(timeout_min=5, delay_sec=10)
+ support_devserver_provision = ENABLE_DEVSERVER_TRIGGER_AUTO_UPDATE
# Timeout values (in seconds) associated with various Chrome OS
# state changes.
@@ -646,7 +650,7 @@
return tools.factory_image_url_pattern() % (devserver.url(), image_name)
- def machine_install_by_devserver(self, build=None, force_update=False,
+ def machine_install_by_devserver(self, update_url=None, force_update=False,
local_devserver=False, repair=False,
force_full_update=False):
"""Ultiize devserver to install the DUT.
@@ -655,7 +659,7 @@
with those in function machine_install. The merge will be done later,
not in the same CL.
- @param build: The build name to be updated on the host.
+ @param update_url: The update_url or build for the host to update.
@param force_update: Force an update even if the version installed
is the same. Default:False
@param local_devserver: Used by test_that to allow people to
@@ -678,25 +682,27 @@
devserver = None
logging.debug('Resolving a devserver for auto-update')
if repair:
- build = self.get_repair_image_name()
+ update_url = self.get_repair_image_name()
force_update = True
- if not build and not self._parser.options.image:
+ if not update_url and not self._parser.options.image:
raise error.AutoservError(
'There is no update URL, nor a method to get one.')
- if not build and self._parser.options.image:
- build = self._parser.options.image
+ if not update_url and self._parser.options.image:
+ update_url = self._parser.options.image
- logging.info('Staging build for AU: %s', build)
+ logging.info('Staging build for AU: %s', update_url)
# Get build from parameter or AFE.
# If the build is not a URL, let devserver to stage it first.
# Otherwise, choose a devserver to trigger auto-update.
- if build.startswith('http://'):
- build = autoupdater.url_to_image_name(build)
+ build = None
+ if update_url.startswith('http://'):
+ build = autoupdater.url_to_image_name(update_url)
devserver = dev_server.ImageServer.resolve(build, self.hostname)
else:
+ build = update_url
devserver = dev_server.ImageServer.resolve(build, self.hostname)
devserver.trigger_download(build, synchronous=False)
@@ -705,6 +711,7 @@
server_name = server_name.replace('.', '_')
autotest_stats.Counter('cros_host_provision.' + server_name).increment()
autotest_stats.Counter('cros_host_provision.total').increment()
+ logging.debug('Resolved devserver for auto-update: %s', devserver.url())
devserver.auto_update(self.hostname, build,
log_dir=self.job.sysinfo.sysinfodir,