autotest: generate a report of a suite job run
BUG=chromium:641093
TEST=verify data is viewable via datastore
Change-Id: Ib08da5ce438b120e67296966aff8bdde52815dca
Reviewed-on: https://chromium-review.googlesource.com/386993
Commit-Ready: Aviv Keshet <akeshet@chromium.org>
Tested-by: David Riley <davidriley@chromium.org>
Reviewed-by: David Riley <davidriley@chromium.org>
diff --git a/site_utils/dump_suite_report.py b/site_utils/dump_suite_report.py
new file mode 100755
index 0000000..24176f7
--- /dev/null
+++ b/site_utils/dump_suite_report.py
@@ -0,0 +1,53 @@
+#!/usr/bin/env python
+# Copyright 2016 The Chromium OS Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+"""Generate a report on a given suite run."""
+
+from __future__ import print_function
+
+import common
+import sys
+
+from autotest_lib.server.lib import suite_report
+from chromite.lib import commandline
+from chromite.lib import cros_logging as logging
+
+def GetParser():
+ """Creates the argparse parser."""
+ parser = commandline.ArgumentParser(description=__doc__)
+ parser.add_argument('job_ids', type=int, nargs='+',
+ help='Suite job ids to dump')
+ parser.add_argument('--output', '-o', type=str, action='store',
+ help='Path to write JSON file to')
+ return parser
+
+
+def main(argv):
+ """Standard main() for command line processing.
+
+ @param argv Command line arguments (normally sys.argv).
+ """
+
+ parser = GetParser()
+ options = parser.parse_args(argv[1:])
+
+ # Look up and generate entries for all jobs.
+ entries = []
+ for suite_job_id in options.job_ids:
+ logging.debug('Suite job %s:' % suite_job_id)
+ suite_entries = suite_report.generate_suite_report(suite_job_id)
+ logging.debug('... generated %d entries' % len(suite_entries))
+ entries.extend(suite_entries)
+
+ # Write all entries as JSON.
+ if options.output:
+ with open(options.output, 'w') as f:
+ suite_report.dump_entries_as_json(entries, f)
+ else:
+ suite_report.dump_entries_as_json(entries, sys.stdout)
+
+
+if __name__ == '__main__':
+ main(sys.argv)