devserver: Update collect_cros_au_log RPC to return the host logs.
The collect_cros_au_log RPC currently returns just the executing log.
We will need it to return the host logs saved during the update so that
the autoupdate_EndToEndTest test can analyse them.
BUG=chromium:709710
TEST=dev_server.auto_update() and verify that the host logs are saved
into job.resultdir when the test is finished.
Change-Id: I7cf14a81da5481ba8474de9cf1d115280eb93dda
Reviewed-on: https://chromium-review.googlesource.com/503616
Commit-Ready: David Haddock <dhaddock@chromium.org>
Tested-by: David Haddock <dhaddock@chromium.org>
Reviewed-by: Xixuan Wu <xixuan@chromium.org>
diff --git a/cros_update_progress.py b/cros_update_progress.py
index 72b872a..c337e0a 100644
--- a/cros_update_progress.py
+++ b/cros_update_progress.py
@@ -57,6 +57,8 @@
# update engine log.
_CROS_UPDATE_TEMP_PATH = '/tmp/cros-update_%s_%s'
+_CROS_HOSTLOG_PATTERN = 'devserver_hostlog*'
+
# The string for update process finished
FINISHED = 'Completed'
ERROR_TAG = 'Error'
@@ -186,6 +188,16 @@
return osutils.ReadFile(GetExecuteLogFile(host_name, pid))
+def ReadAUHostLogFiles(host_name, pid):
+ """Returns a dictionary containing the devserver host log files."""
+ au_dir = GetAUTempDirectory(host_name, pid)
+ hostlog_filenames = glob.glob(os.path.join(au_dir, _CROS_HOSTLOG_PATTERN))
+ hostlog_files = {}
+ for f in hostlog_filenames:
+ hostlog_files[os.path.basename(f)] = osutils.ReadFile(f)
+ return hostlog_files
+
+
def DelTrackStatusFile(host_name, pid):
"""Delete the track status log."""
osutils.SafeUnlink(GetTrackStatusFile(host_name, pid))
diff --git a/devserver.py b/devserver.py
index fafeb53..5e6cc0f 100755
--- a/devserver.py
+++ b/devserver.py
@@ -1074,7 +1074,7 @@
pid: the background process id of cros-update.
Returns:
- A string contains the whole content of the execute log file.
+ A dictionary containing the execute log file and any hostlog files.
"""
if 'host_name' not in kwargs:
raise common_util.DevServerHTTPError((KEY_ERROR_MSG % 'host_name'))
@@ -1088,7 +1088,9 @@
# Fetch the execute log recorded by cros_update_progress.
au_log = cros_update_progress.ReadExecuteLogFile(host_name, pid)
cros_update_progress.DelExecuteLogFile(host_name, pid)
- return au_log
+ # Fetch the cros_au host_logs if they exist
+ au_hostlogs = cros_update_progress.ReadAUHostLogFiles(host_name, pid)
+ return json.dumps({'cros_au_log': au_log, 'host_logs': au_hostlogs})
@cherrypy.expose
def locate_file(self, **kwargs):