<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[186033] trunk/Websites/perf.webkit.org</title>
</head>
<body>
<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; }
#msg dl a { font-weight: bold}
#msg dl a:link { color:#fc3; }
#msg dl a:active { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/186033">186033</a></dd>
<dt>Author</dt> <dd>rniwa@webkit.org</dd>
<dt>Date</dt> <dd>2015-06-27 14:31:13 -0700 (Sat, 27 Jun 2015)</dd>
</dl>
<h3>Log Message</h3>
<pre>build-requests should use conform to JSON API format
https://bugs.webkit.org/show_bug.cgi?id=146375
Reviewed by Stephanie Lewis.
Instead of returning single dictionary that maps root set id to a dictionary of repository names
to revisions, timestamps, simply return root sets and roots "rows" or "objects" as defined in
JSON API (http://jsonapi.org/). This API change makes it easier to resolve the bug 146374 and
matches what we do in /api/test-groups.
Also add the support for /api/build-requests/?id=<id> to fetch the build request with <id>.
This is useful for debugging purposes.
* public/api/build-requests.php:
(main): Added the support for $_GET['id']. Also return "rootSets" and "roots".
(update_builds): Extracted from main.
* public/include/build-requests-fetcher.php:
(BuildRequestFetcher::fetch_request): Added. Used for /api/build-requests/?id=<id>.
(BuildRequestFetcher::results_internal): Always call fetch_roots_for_set_if_needed.
(BuildRequestFetcher::fetch_roots_for_set_if_needed): Renamed from fetch_roots_for_set.
Moved the logic to exit early when the root set had already been fetched here.
* public/v2/analysis.js:
(App.TestGroup._fetchTestResults): Fixed the bug that test groups without any successful results
won't be shown.
* tools/pull-os-versions.py:
(main):
(setup_auth): Moved to util.py
* tools/sync-with-buildbot.py:
(main): Replaced a bunch of perf dashboard related options by --server-config-json.
(update_and_fetch_build_requests): No longer takes build_request_auth since that's now taken care
of by setup_auth.
(organize_root_sets_by_id_and_repository_names): Added. Builds the old rootsSets directory based
on "roots" and "rootSets" dictionaries returned by /api/build-requests.
(config_for_request): Fixed a bug that the script blows up when the build request is missing
the repository specified in the configuration. This tolerance is necessary when a new repository
dependency is added but we want to run A/B tests for old builds without the dependency.
(fetch_json): No longer takes auth.
* tools/util.py:
(setup_auth): Moved from pull-os-versions.py to be shared with sync-with-buildbot.py.</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkWebsitesperfwebkitorgChangeLog">trunk/Websites/perf.webkit.org/ChangeLog</a></li>
<li><a href="#trunkWebsitesperfwebkitorgpublicapibuildrequestsphp">trunk/Websites/perf.webkit.org/public/api/build-requests.php</a></li>
<li><a href="#trunkWebsitesperfwebkitorgpublicincludebuildrequestsfetcherphp">trunk/Websites/perf.webkit.org/public/include/build-requests-fetcher.php</a></li>
<li><a href="#trunkWebsitesperfwebkitorgpublicv2analysisjs">trunk/Websites/perf.webkit.org/public/v2/analysis.js</a></li>
<li><a href="#trunkWebsitesperfwebkitorgtoolspullosversionspy">trunk/Websites/perf.webkit.org/tools/pull-os-versions.py</a></li>
<li><a href="#trunkWebsitesperfwebkitorgtoolssyncwithbuildbotpy">trunk/Websites/perf.webkit.org/tools/sync-with-buildbot.py</a></li>
<li><a href="#trunkWebsitesperfwebkitorgtoolsutilpy">trunk/Websites/perf.webkit.org/tools/util.py</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkWebsitesperfwebkitorgChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Websites/perf.webkit.org/ChangeLog (186032 => 186033)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Websites/perf.webkit.org/ChangeLog        2015-06-27 21:11:18 UTC (rev 186032)
+++ trunk/Websites/perf.webkit.org/ChangeLog        2015-06-27 21:31:13 UTC (rev 186033)
</span><span class="lines">@@ -1,3 +1,50 @@
</span><ins>+2015-06-27 Ryosuke Niwa <rniwa@webkit.org>
+
+ build-requests should use conform to JSON API format
+ https://bugs.webkit.org/show_bug.cgi?id=146375
+
+ Reviewed by Stephanie Lewis.
+
+ Instead of returning single dictionary that maps root set id to a dictionary of repository names
+ to revisions, timestamps, simply return root sets and roots "rows" or "objects" as defined in
+ JSON API (http://jsonapi.org/). This API change makes it easier to resolve the bug 146374 and
+ matches what we do in /api/test-groups.
+
+ Also add the support for /api/build-requests/?id=<id> to fetch the build request with <id>.
+ This is useful for debugging purposes.
+
+ * public/api/build-requests.php:
+ (main): Added the support for $_GET['id']. Also return "rootSets" and "roots".
+ (update_builds): Extracted from main.
+
+ * public/include/build-requests-fetcher.php:
+ (BuildRequestFetcher::fetch_request): Added. Used for /api/build-requests/?id=<id>.
+ (BuildRequestFetcher::results_internal): Always call fetch_roots_for_set_if_needed.
+ (BuildRequestFetcher::fetch_roots_for_set_if_needed): Renamed from fetch_roots_for_set.
+ Moved the logic to exit early when the root set had already been fetched here.
+
+ * public/v2/analysis.js:
+ (App.TestGroup._fetchTestResults): Fixed the bug that test groups without any successful results
+ won't be shown.
+
+ * tools/pull-os-versions.py:
+ (main):
+ (setup_auth): Moved to util.py
+
+ * tools/sync-with-buildbot.py:
+ (main): Replaced a bunch of perf dashboard related options by --server-config-json.
+ (update_and_fetch_build_requests): No longer takes build_request_auth since that's now taken care
+ of by setup_auth.
+ (organize_root_sets_by_id_and_repository_names): Added. Builds the old rootsSets directory based
+ on "roots" and "rootSets" dictionaries returned by /api/build-requests.
+ (config_for_request): Fixed a bug that the script blows up when the build request is missing
+ the repository specified in the configuration. This tolerance is necessary when a new repository
+ dependency is added but we want to run A/B tests for old builds without the dependency.
+ (fetch_json): No longer takes auth.
+
+ * tools/util.py:
+ (setup_auth): Moved from pull-os-versions.py to be shared with sync-with-buildbot.py.
+
</ins><span class="cx"> 2015-06-23 Ryosuke Niwa <rniwa@webkit.org>
</span><span class="cx">
</span><span class="cx"> Build fix. A/B testing is broken when continuous builders report revisions out of order.
</span></span></pre></div>
<a id="trunkWebsitesperfwebkitorgpublicapibuildrequestsphp"></a>
<div class="modfile"><h4>Modified: trunk/Websites/perf.webkit.org/public/api/build-requests.php (186032 => 186033)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Websites/perf.webkit.org/public/api/build-requests.php        2015-06-27 21:11:18 UTC (rev 186032)
+++ trunk/Websites/perf.webkit.org/public/api/build-requests.php        2015-06-27 21:31:13 UTC (rev 186033)
</span><span class="lines">@@ -3,54 +3,63 @@
</span><span class="cx"> require_once('../include/json-header.php');
</span><span class="cx"> require_once('../include/build-requests-fetcher.php');
</span><span class="cx">
</span><del>-function main($path, $post_data) {
- if (count($path) < 1 || count($path) > 2)
</del><ins>+function main($id, $path, $post_data) {
+ if (!$id && (count($path) < 1 || count($path) > 2))
</ins><span class="cx"> exit_with_error('InvalidRequest');
</span><span class="cx">
</span><span class="cx"> $db = new Database;
</span><span class="cx"> if (!$db->connect())
</span><span class="cx"> exit_with_error('DatabaseConnectionFailure');
</span><span class="cx">
</span><del>- $triggerable_query = array('name' => array_get($path, 0));
- $triggerable = $db->select_first_row('build_triggerables', 'triggerable', $triggerable_query);
- if (!$triggerable)
- exit_with_error('TriggerableNotFound', $triggerable_query);
-
</del><span class="cx"> $report = $post_data ? json_decode($post_data, true) : array();
</span><span class="cx"> $updates = array_get($report, 'buildRequestUpdates');
</span><span class="cx"> if ($updates) {
</span><span class="cx"> verify_slave($db, $report);
</span><del>-
- $db->begin_transaction();
- foreach ($updates as $id => $info) {
- $id = intval($id);
- $status = $info['status'];
- $url = array_get($info, 'url');
- if ($status == 'failedIfNotCompleted') {
- $db->query_and_get_affected_rows('UPDATE build_requests SET (request_status, request_url) = ($1, $2)
- WHERE request_id = $3 AND request_status != $4', array('failed', $url, $id, 'completed'));
- } else {
- if (!in_array($status, array('pending', 'scheduled', 'running', 'failed', 'completed'))) {
- $db->rollback_transaction();
- exit_with_error('UnknownBuildRequestStatus', array('buildRequest' => $id, 'status' => $status));
- }
- $db->update_row('build_requests', 'request', array('id' => $id), array('status' => $status, 'url' => $url));
- }
- }
- $db->commit_transaction();
</del><ins>+ update_builds($db, $updates);
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> $requests_fetcher = new BuildRequestsFetcher($db);
</span><del>- $requests_fetcher->fetch_incomplete_requests_for_triggerable($triggerable['triggerable_id']);
</del><span class="cx">
</span><ins>+ if ($id)
+ $requests_fetcher->fetch_request($id);
+ else {
+ $triggerable_query = array('name' => array_get($path, 0));
+ $triggerable = $db->select_first_row('build_triggerables', 'triggerable', $triggerable_query);
+ if (!$triggerable)
+ exit_with_error('TriggerableNotFound', $triggerable_query);
+ $requests_fetcher->fetch_incomplete_requests_for_triggerable($triggerable['triggerable_id']);
+ }
+
</ins><span class="cx"> exit_with_success(array(
</span><span class="cx"> 'buildRequests' => $requests_fetcher->results_with_resolved_ids(),
</span><del>- 'rootSets' => $requests_fetcher->root_sets_by_id(),
</del><ins>+ 'rootSets' => $requests_fetcher->root_sets(),
+ 'roots' => $requests_fetcher->roots(),
</ins><span class="cx"> 'updates' => $updates,
</span><span class="cx"> ));
</span><span class="cx"> }
</span><span class="cx">
</span><del>-main(array_key_exists('PATH_INFO', $_SERVER) ? explode('/', trim($_SERVER['PATH_INFO'], '/')) : array(),
</del><ins>+function update_builds($db, $updates) {
+ $db->begin_transaction();
+ foreach ($updates as $id => $info) {
+ $id = intval($id);
+ $status = $info['status'];
+ $url = array_get($info, 'url');
+ if ($status == 'failedIfNotCompleted') {
+ $db->query_and_get_affected_rows('UPDATE build_requests SET (request_status, request_url) = ($1, $2)
+ WHERE request_id = $3 AND request_status != $4', array('failed', $url, $id, 'completed'));
+ } else {
+ if (!in_array($status, array('pending', 'scheduled', 'running', 'failed', 'completed'))) {
+ $db->rollback_transaction();
+ exit_with_error('UnknownBuildRequestStatus', array('buildRequest' => $id, 'status' => $status));
+ }
+ $db->update_row('build_requests', 'request', array('id' => $id), array('status' => $status, 'url' => $url));
+ }
+ }
+ $db->commit_transaction();
+}
+
+main(array_get($_GET, 'id'),
+ array_key_exists('PATH_INFO', $_SERVER) ? explode('/', trim($_SERVER['PATH_INFO'], '/')) : array(),
</ins><span class="cx"> file_get_contents("php://input"));
</span><span class="cx">
</span><span class="cx"> ?>
</span></span></pre></div>
<a id="trunkWebsitesperfwebkitorgpublicincludebuildrequestsfetcherphp"></a>
<div class="modfile"><h4>Modified: trunk/Websites/perf.webkit.org/public/include/build-requests-fetcher.php (186032 => 186033)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Websites/perf.webkit.org/public/include/build-requests-fetcher.php        2015-06-27 21:11:18 UTC (rev 186032)
+++ trunk/Websites/perf.webkit.org/public/include/build-requests-fetcher.php        2015-06-27 21:31:13 UTC (rev 186033)
</span><span class="lines">@@ -30,6 +30,10 @@
</span><span class="cx"> ORDER BY request_created_at, request_group, request_order', array($triggerable_id));
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+ function fetch_request($request_id) {
+ $this->rows = $this->db->select_rows('build_requests', 'request', array('id' => $request_id));
+ }
+
</ins><span class="cx"> function has_results() { return is_array($this->rows); }
</span><span class="cx"> function results() { return $this->results_internal(false); }
</span><span class="cx"> function results_with_resolved_ids() { return $this->results_internal(true); }
</span><span class="lines">@@ -51,8 +55,7 @@
</span><span class="cx"> $platform_id = $row['request_platform'];
</span><span class="cx"> $root_set_id = $row['request_root_set'];
</span><span class="cx">
</span><del>- if (!array_key_exists($root_set_id, $this->root_sets_by_id))
- $this->root_sets_by_id[$root_set_id] = $this->fetch_roots_for_set($root_set_id, $resolve_ids);
</del><ins>+ $this->fetch_roots_for_set_if_needed($root_set_id, $resolve_ids);
</ins><span class="cx">
</span><span class="cx"> array_push($requests, array(
</span><span class="cx"> 'id' => $row['request_id'],
</span><span class="lines">@@ -71,10 +74,6 @@
</span><span class="cx"> return $requests;
</span><span class="cx"> }
</span><span class="cx">
</span><del>- function root_sets_by_id() {
- return $this->root_sets_by_id;
- }
-
</del><span class="cx"> function root_sets() {
</span><span class="cx"> return $this->root_sets;
</span><span class="cx"> }
</span><span class="lines">@@ -83,12 +82,14 @@
</span><span class="cx"> return $this->roots;
</span><span class="cx"> }
</span><span class="cx">
</span><del>- private function fetch_roots_for_set($root_set_id, $resolve_ids) {
</del><ins>+ private function fetch_roots_for_set_if_needed($root_set_id, $resolve_ids) {
+ if (array_key_exists($root_set_id, $this->root_sets_by_id))
+ return;
+
</ins><span class="cx"> $root_rows = $this->db->query_and_fetch_all('SELECT *
</span><span class="cx"> FROM roots, commits LEFT OUTER JOIN repositories ON commit_repository = repository_id
</span><span class="cx"> WHERE root_commit = commit_id AND root_set = $1', array($root_set_id));
</span><span class="cx">
</span><del>- $roots = array();
</del><span class="cx"> $root_ids = array();
</span><span class="cx"> foreach ($root_rows as $row) {
</span><span class="cx"> $repository = $row['repository_id'];
</span><span class="lines">@@ -96,13 +97,17 @@
</span><span class="cx"> $commit_time = $row['commit_time'];
</span><span class="cx"> $root_id = $root_set_id . '-' . $repository;
</span><span class="cx"> array_push($root_ids, $root_id);
</span><del>- array_push($this->roots, array('id' => $root_id, 'repository' => $repository, 'revision' => $revision));
- $roots[$resolve_ids ? $row['repository_name'] : $row['repository_id']] = array(
- 'revision' => $revision, 'time' => Database::to_js_time($commit_time));
</del><ins>+ $repository_id = $resolve_ids ? $row['repository_name'] : $row['repository_id'];
+ array_push($this->roots, array(
+ 'id' => $root_id,
+ 'repository' => $repository_id,
+ 'revision' => $revision,
+ 'time' => Database::to_js_time($commit_time)));
</ins><span class="cx"> }
</span><ins>+
+ $this->root_sets_by_id[$root_set_id] = TRUE;
+
</ins><span class="cx"> array_push($this->root_sets, array('id' => $root_set_id, 'roots' => $root_ids));
</span><del>-
- return $roots;
</del><span class="cx"> }
</span><span class="cx"> }
</span><span class="cx">
</span></span></pre></div>
<a id="trunkWebsitesperfwebkitorgpublicv2analysisjs"></a>
<div class="modfile"><h4>Modified: trunk/Websites/perf.webkit.org/public/v2/analysis.js (186032 => 186033)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Websites/perf.webkit.org/public/v2/analysis.js        2015-06-27 21:11:18 UTC (rev 186032)
+++ trunk/Websites/perf.webkit.org/public/v2/analysis.js        2015-06-27 21:31:13 UTC (rev 186033)
</span><span class="lines">@@ -133,7 +133,7 @@
</span><span class="cx"> _fetchTestResults: function ()
</span><span class="cx"> {
</span><span class="cx"> var task = this.get('task');
</span><del>- var platform = this.get('platform');
</del><ins>+ var platform = this.get('platform') || (task ? task.get('platform') : null)
</ins><span class="cx"> if (!task || !platform)
</span><span class="cx"> return null;
</span><span class="cx"> var self = this;
</span></span></pre></div>
<a id="trunkWebsitesperfwebkitorgtoolspullosversionspy"></a>
<div class="modfile"><h4>Modified: trunk/Websites/perf.webkit.org/tools/pull-os-versions.py (186032 => 186033)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Websites/perf.webkit.org/tools/pull-os-versions.py        2015-06-27 21:11:18 UTC (rev 186032)
+++ trunk/Websites/perf.webkit.org/tools/pull-os-versions.py        2015-06-27 21:31:13 UTC (rev 186033)
</span><span class="lines">@@ -12,14 +12,9 @@
</span><span class="cx"> from xml.dom.minidom import parseString as parseXmlString
</span><span class="cx"> from util import submit_commits
</span><span class="cx"> from util import text_content
</span><ins>+from util import setup_auth
</ins><span class="cx">
</span><span class="cx">
</span><del>-HTTP_AUTH_HANDLERS = {
- 'basic': urllib2.HTTPBasicAuthHandler,
- 'digest': urllib2.HTTPDigestAuthHandler,
-}
-
-
</del><span class="cx"> def main(argv):
</span><span class="cx"> parser = argparse.ArgumentParser()
</span><span class="cx"> parser.add_argument('--config', required=True, help='Path to a config JSON file')
</span><span class="lines">@@ -63,17 +58,6 @@
</span><span class="cx"> time.sleep(config['fetchInterval'])
</span><span class="cx">
</span><span class="cx">
</span><del>-def setup_auth(server):
- auth = server.get('auth')
- if not auth:
- return
-
- password_manager = urllib2.HTTPPasswordMgr()
- password_manager.add_password(realm=auth['realm'], uri=server['url'], user=auth['username'], passwd=auth['password'])
- auth_handler = HTTP_AUTH_HANDLERS[auth['type']](password_manager)
- urllib2.install_opener(urllib2.build_opener(auth_handler))
-
-
</del><span class="cx"> def available_builds_from_command(repository_name, command, lines_to_ignore):
</span><span class="cx"> try:
</span><span class="cx"> output = subprocess.check_output(command, stderr=subprocess.STDOUT)
</span></span></pre></div>
<a id="trunkWebsitesperfwebkitorgtoolssyncwithbuildbotpy"></a>
<div class="modfile"><h4>Modified: trunk/Websites/perf.webkit.org/tools/sync-with-buildbot.py (186032 => 186033)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Websites/perf.webkit.org/tools/sync-with-buildbot.py        2015-06-27 21:11:18 UTC (rev 186032)
+++ trunk/Websites/perf.webkit.org/tools/sync-with-buildbot.py        2015-06-27 21:31:13 UTC (rev 186033)
</span><span class="lines">@@ -9,24 +9,30 @@
</span><span class="cx"> import urllib
</span><span class="cx"> import urllib2
</span><span class="cx">
</span><ins>+from util import setup_auth
</ins><span class="cx">
</span><ins>+
</ins><span class="cx"> def main():
</span><span class="cx"> parser = argparse.ArgumentParser()
</span><del>- parser.add_argument('--build-requests-url', required=True, help='URL for the build requests JSON API; e.g. https://perf.webkit.org/api/build-requests/build.webkit.org/')
- parser.add_argument('--build-requests-user', help='The username for Basic Authentication to access the build requests JSON API')
- parser.add_argument('--build-requests-password', help='The password for Basic Authentication to access the build requests JSON API')
- parser.add_argument('--slave-name', required=True, help='The slave name used to update the build requets status')
- parser.add_argument('--slave-password', required=True, help='The slave password used to update the build requets status')
</del><ins>+ parser.add_argument('--triggerable', required=True, help='The name of the triggerable to process. e.g. build-webkit')
</ins><span class="cx"> parser.add_argument('--buildbot-url', required=True, help='URL for a buildbot builder; e.g. "https://build.webkit.org/"')
</span><span class="cx"> parser.add_argument('--builder-config-json', required=True, help='The path to a JSON file that specifies which test and platform will be posted to which builder. '
</span><span class="cx"> 'The JSON should contain an array of dictionaries with keys "platform", "test", and "builder" '
</span><span class="cx"> 'with the platform name (e.g. mountainlion), the test path (e.g. ["Parser", "html5-full-render"]), and the builder name (e.g. Apple MountainLion Release (Perf)) as values.')
</span><ins>+ parser.add_argument('--server-config-json', required=True, help='The path to a JSON file that specifies the perf dashboard.')
+
</ins><span class="cx"> parser.add_argument('--lookback-count', type=int, default=10, help='The number of builds to look back when finding in-progress builds on the buildbot')
</span><span class="cx"> parser.add_argument('--seconds-to-sleep', type=float, default=120, help='The seconds to sleep between iterations')
</span><span class="cx"> args = parser.parse_args()
</span><span class="cx">
</span><span class="cx"> configurations = load_config(args.builder_config_json, args.buildbot_url.strip('/'))
</span><del>- build_request_auth = {'user': args.build_requests_user, 'password': args.build_requests_password or ''} if args.build_requests_user else None
</del><ins>+
+ with open(args.server_config_json) as server_config_json:
+ server_config = json.load(server_config_json)
+ setup_auth(server_config['server'])
+
+ build_requests_url = server_config['server']['url'] + '/api/build-requests/' + args.triggerable
+
</ins><span class="cx"> request_updates = {}
</span><span class="cx"> while True:
</span><span class="cx"> request_updates.update(find_request_updates(configurations, args.lookback_count))
</span><span class="lines">@@ -35,14 +41,21 @@
</span><span class="cx"> else:
</span><span class="cx"> print 'No updates...'
</span><span class="cx">
</span><del>- payload = {'buildRequestUpdates': request_updates, 'slaveName': args.slave_name, 'slavePassword': args.slave_password}
- response = update_and_fetch_build_requests(args.build_requests_url, build_request_auth, payload)
- root_sets = response.get('rootSets', {})
</del><ins>+ payload = {
+ 'buildRequestUpdates': request_updates,
+ 'slaveName': server_config['slave']['name'],
+ 'slavePassword': server_config['slave']['password']}
+ response = update_and_fetch_build_requests(build_requests_url, payload)
</ins><span class="cx"> open_requests = response.get('buildRequests', [])
</span><span class="cx">
</span><ins>+ root_sets = organize_root_sets_by_id_and_repository_names(response.get('rootSets', {}), response.get('roots', []))
+
</ins><span class="cx"> for request in filter(lambda request: request['status'] == 'pending', open_requests):
</span><span class="cx"> config = config_for_request(configurations, request)
</span><del>- if len(config['scheduledRequests']) < 1:
</del><ins>+ if not config:
+ print >> sys.stderr, "Failed to find the configuration for request %s: %s" % (str(request['id']), json.dumps(request))
+ continue
+ if config and len(config['scheduledRequests']) < 1:
</ins><span class="cx"> print "Scheduling the build request %s..." % str(request['id'])
</span><span class="cx"> schedule_request(config, request, root_sets)
</span><span class="cx">
</span><span class="lines">@@ -109,9 +122,9 @@
</span><span class="cx"> return request_updates
</span><span class="cx">
</span><span class="cx">
</span><del>-def update_and_fetch_build_requests(build_requests_url, build_request_auth, payload):
</del><ins>+def update_and_fetch_build_requests(build_requests_url, payload):
</ins><span class="cx"> try:
</span><del>- response = fetch_json(build_requests_url, payload=json.dumps(payload), auth=build_request_auth)
</del><ins>+ response = fetch_json(build_requests_url, payload=json.dumps(payload))
</ins><span class="cx"> if response['status'] != 'OK':
</span><span class="cx"> raise ValueError(response['status'])
</span><span class="cx"> return response
</span><span class="lines">@@ -132,15 +145,32 @@
</span><span class="cx"> return request_updates
</span><span class="cx">
</span><span class="cx">
</span><ins>+def organize_root_sets_by_id_and_repository_names(root_sets, roots):
+ result = {}
+ root_by_id = {}
+ for root in roots:
+ root_by_id[root['id']] = root
+
+ for root_set in root_sets:
+ roots_by_repository = {}
+ for root_id in root_set['roots']:
+ root = root_by_id[root_id]
+ roots_by_repository[root['repository']] = root
+ result[root_set['id']] = roots_by_repository
+
+ return result
+
+
</ins><span class="cx"> def schedule_request(config, request, root_sets):
</span><del>- roots = root_sets.get(request['rootSet'], {})
-
</del><ins>+ roots = root_sets[request['rootSet']]
</ins><span class="cx"> payload = {}
</span><span class="cx"> for property_name, property_value in config['arguments'].iteritems():
</span><span class="cx"> if not isinstance(property_value, dict):
</span><span class="cx"> payload[property_name] = property_value
</span><span class="cx"> elif 'root' in property_value:
</span><del>- payload[property_name] = roots[property_value['root']]['revision']
</del><ins>+ repository_name = property_value['root']
+ if repository_name in roots:
+ payload[property_name] = roots[repository_name]['revision']
</ins><span class="cx"> elif 'rootsExcluding' in property_value:
</span><span class="cx"> excluded_roots = property_value['rootsExcluding']
</span><span class="cx"> filtered_roots = {}
</span><span class="lines">@@ -150,6 +180,7 @@
</span><span class="cx"> payload[property_name] = json.dumps(filtered_roots)
</span><span class="cx"> else:
</span><span class="cx"> print >> sys.stderr, "Failed to process an argument %s: %s" % (property_name, property_value)
</span><ins>+ return
</ins><span class="cx"> payload[config['buildRequestArgument']] = request['id']
</span><span class="cx">
</span><span class="cx"> try:
</span><span class="lines">@@ -166,10 +197,8 @@
</span><span class="cx"> return None
</span><span class="cx">
</span><span class="cx">
</span><del>-def fetch_json(url, auth={}, payload=None):
</del><ins>+def fetch_json(url, payload=None):
</ins><span class="cx"> request = urllib2.Request(url)
</span><del>- if auth:
- request.add_header('Authorization', "Basic %s" % base64.encodestring('%s:%s' % (auth['user'], auth['password'])).rstrip('\n'))
</del><span class="cx"> response = urllib2.urlopen(request, payload).read()
</span><span class="cx"> try:
</span><span class="cx"> return json.loads(response)
</span></span></pre></div>
<a id="trunkWebsitesperfwebkitorgtoolsutilpy"></a>
<div class="modfile"><h4>Modified: trunk/Websites/perf.webkit.org/tools/util.py (186032 => 186033)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Websites/perf.webkit.org/tools/util.py        2015-06-27 21:11:18 UTC (rev 186032)
+++ trunk/Websites/perf.webkit.org/tools/util.py        2015-06-27 21:31:13 UTC (rev 186033)
</span><span class="lines">@@ -34,3 +34,20 @@
</span><span class="cx"> else:
</span><span class="cx"> text += text_content(child)
</span><span class="cx"> return text
</span><ins>+
+
+HTTP_AUTH_HANDLERS = {
+ 'basic': urllib2.HTTPBasicAuthHandler,
+ 'digest': urllib2.HTTPDigestAuthHandler,
+}
+
+
+def setup_auth(server):
+ auth = server.get('auth')
+ if not auth:
+ return
+
+ password_manager = urllib2.HTTPPasswordMgr()
+ password_manager.add_password(realm=auth['realm'], uri=server['url'], user=auth['username'], passwd=auth['password'])
+ auth_handler = HTTP_AUTH_HANDLERS[auth['type']](password_manager)
+ urllib2.install_opener(urllib2.build_opener(auth_handler))
</ins></span></pre>
</div>
</div>
</body>
</html>