Commit 6e1bf9ab authored by Ben Pastene's avatar Ben Pastene Committed by Commit Bot

Upload invocation-level artifacts to RDB for Tast tests.

Some files (like system logs) apply to a test run as a whole, and not
necessarily to a single test case. These artifacts can be uploaded to
RDB as "invocation-level" artifacts. So this crawls the system_logs
and crash dirs after a Tast test and uploads them as "invocation-level"
artifacts.

Bug: 1129654
Change-Id: I27f4cd27b4293a69364d37aa4be89a4185aa4900
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2541747Reviewed-by: default avatarBrian Sheedy <bsheedy@chromium.org>
Commit-Queue: Ben Pastene <bpastene@chromium.org>
Cr-Commit-Position: refs/heads/master@{#828292}
parent 0ea1a3df
...@@ -233,6 +233,24 @@ class RemoteTest(object): ...@@ -233,6 +233,24 @@ class RemoteTest(object):
with open(self._test_launcher_summary_output, 'w') as f: with open(self._test_launcher_summary_output, 'w') as f:
json.dump(json_results.GenerateResultsDict([run_results]), f) json.dump(json_results.GenerateResultsDict([run_results]), f)
@staticmethod
def get_artifacts(path):
"""Crawls a given directory for file artifacts to attach to a test.
Args:
path: Path to a directory to search for artifacts.
Returns:
A dict mapping name of the artifact to its absolute filepath.
"""
artifacts = {}
for dirpath, _, filenames in os.walk(path):
for f in filenames:
artifact_path = os.path.join(dirpath, f)
artifacts[os.path.relpath(artifact_path, path)] = {
'filePath': artifact_path,
}
return artifacts
class TastTest(RemoteTest): class TastTest(RemoteTest):
...@@ -378,17 +396,17 @@ class TastTest(RemoteTest): ...@@ -378,17 +396,17 @@ class TastTest(RemoteTest):
# Walk the contents of the test's "outDir" and atttach any file found # Walk the contents of the test's "outDir" and atttach any file found
# inside as an RDB 'artifact'. (This could include system logs, screen # inside as an RDB 'artifact'. (This could include system logs, screen
# shots, etc.) # shots, etc.)
artifacts = {} artifacts = self.get_artifacts(test['outDir'])
artifacts_dir = test['outDir']
for dirpath, _, filenames in os.walk(artifacts_dir):
for f in filenames:
artifact_path = os.path.join(dirpath, f)
artifacts[os.path.relpath(artifact_path, artifacts_dir)] = {
'filePath': artifact_path,
}
self._rdb_client.Post(test['name'], result, error_log, artifacts) self._rdb_client.Post(test['name'], result, error_log, artifacts)
if self._rdb_client and self._logs_dir:
# Attach artifacts from the device that don't apply to a single test.
artifacts = self.get_artifacts(
os.path.join(self._logs_dir, 'system_logs'))
artifacts.update(
self.get_artifacts(os.path.join(self._logs_dir, 'crashes')))
self._rdb_client.ReportInvocationLevelArtifacts(artifacts)
if self._test_launcher_summary_output: if self._test_launcher_summary_output:
with open(self._test_launcher_summary_output, 'w') as f: with open(self._test_launcher_summary_output, 'w') as f:
json.dump(json_results.GenerateResultsDict([suite_results]), f) json.dump(json_results.GenerateResultsDict([suite_results]), f)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment