Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(175)

Unified Diff: scripts/slave/results_dashboard.py

Issue 12317053: Sends test results to new perf dashboard (Closed) Base URL: https://chromium.googlesource.com/chromium/tools/build.git@master
Patch Set: First pass at implementing a cache file (still need a real location for the file) Created 7 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | scripts/slave/runtest.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: scripts/slave/results_dashboard.py
diff --git a/scripts/slave/results_dashboard.py b/scripts/slave/results_dashboard.py
new file mode 100644
index 0000000000000000000000000000000000000000..ed64bf3783efbc4041300eb1a4775790b98060d7
--- /dev/null
+++ b/scripts/slave/results_dashboard.py
@@ -0,0 +1,109 @@
+#!/usr/bin/env python
+# Copyright (c) 2013 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+"""Functions for adding results to perf dashboard."""
+
+import httplib
+import json
+import urllib
+import urllib2
+
+SEND_RESULTS_PATH = "/add_point"
+RESULTS_LINK_PATH = "/report?masters=%s&bots=%s&tests=%s&rev=%s"
+CACHE_FILE = "/tmp/my_log_file"
Mike Stip (use stip instead) 2013/02/27 09:53:35 in a later version this will be build_dir/results_
+
+
+def SendResults(logname, lines, master, system, test, url, stdio_url):
+ if not logname.endswith("-summary.dat"):
+ return
+
+ new_results_line = _GetResultsJson(
+ logname, lines, master, system, test, url, stdio_url)
+ # Write the new request line to the cache, in case of errors.
+ cache = open(CACHE_FILE, "a+b")
+ cache.write("\n" + new_results_line)
+ cache.close()
+
+ # Send all the results from this run and the previous cache to the dashboard.
+ cache = open(CACHE_FILE, "r")
+ cache_lines = cache.readlines()
+ cache.close()
+ errors = []
+ lines_to_retry = []
+ fatal_error = False
+ for index, line in enumerate(cache_lines):
+ line = line.strip()
+ if not line:
+ continue
+ error = _SendResultsJson(url, line)
+ if error:
+ if index != len(cache_lines) -1:
+ # This request has already been tried before, now it's fatal.
+ fatal_error = True
+ lines_to_retry.append(line)
+ errors.append(error)
+
+ # Write any failing requests to the cache.
+ cache = open(CACHE_FILE, "w+b")
+ cache.write("\n".join(set(lines_to_retry)))
+ cache.close()
+
+ # Print any errors, and if there was a fatal error, it should be an exception.
+ for error in errors:
+ print error
+ if fatal_error:
+ print "Multiple failures uploading to dashboard."
+ print "@@@STEP_EXCEPTION@@@"
+
+def _GetResultsJson(logname, lines, master, system, test, url, stdio_url):
+ results_to_add = []
+ bot = system
+ graph = logname.replace("-summary.dat", "")
+ for line in lines:
+ data = json.loads(line)
+ revision = data["rev"]
+ for (trace, values) in data["traces"].iteritems():
+ # TODO(sullivan): Handle special trace names:
+ # Reference builds
+ # by_url builds
+ test_path = "%s/%s/%s" % (test, graph, trace)
+ if graph == trace:
+ test_path = "%s/%s" % (test, graph)
+ result = {
+ "master": master,
+ "bot": system,
+ "test": test_path,
+ "revision": revision,
+ "value": values[0],
+ "error": values[1],
+ }
+ if "webkit_rev" in data and data["webkit_rev"] != "undefined":
+ result["supplemental_columns"] = {"r_webkit_rev": data["webkit_rev"]}
+ if stdio_url:
+ result["supplemental_columns"] = {"s_stdio_url": stdio_url}
+ results_to_add.append(result)
+ _PrintLinkStep(url, master, bot, test_path, revision)
+ return json.dumps(results_to_add)
+
+def _SendResultsJson(url, results_json):
+ data = urllib.urlencode({"data": results_json})
+ req = urllib2.Request(url + SEND_RESULTS_PATH, data)
+ try:
+ urllib2.urlopen(req)
+ except urllib2.HTTPError, e:
+ return "HTTPError: %d for JSON %s\n" % (e.code, results_json)
+ except urllib2.URLError, e:
+ return "URLError: %s for JSON %s\n" % (str(e.reason), results_json)
+ except httplib.HTTPException, e:
+ return "HTTPException for JSON %s\n" % results_json
+ return None
+
+def _PrintLinkStep(url, master, bot, test_path, revision):
+ results_link = url + RESULTS_LINK_PATH % (
+ urllib.quote(master),
+ urllib.quote(bot),
+ urllib.quote(test_path),
+ revision)
+ print "@@@STEP_LINK@%s@%s@@@" % ("Results Dashboard", results_link)
« no previous file with comments | « no previous file | scripts/slave/runtest.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698