<!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>[182438] 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/182438">182438</a></dd>
<dt>Author</dt> <dd>rniwa@webkit.org</dd>
<dt>Date</dt> <dd>2015-04-06 14:08:26 -0700 (Mon, 06 Apr 2015)</dd>
</dl>

<h3>Log Message</h3>
<pre>Perf dashboard should be able to trigger A/B testing jobs for iOS
https://bugs.webkit.org/show_bug.cgi?id=143398

Reviewed by Chris Dumez.

Fix various bugs in the perf dashboard so that it can schedule A/B testing jobs for iOS.

Also generalized sync-with-buildbot.py slightly to meet the requirements of iOS builders.

* public/api/triggerables.php:
(main): Avoid spitting a warning when $id_to_triggerable doesn't contain the triggerable.
* public/v2/analysis.js:
(App.AnalysisTask.triggerable): Log an error when failed to fetch triggerables for debugging purposes.
* public/v2/app.js:
(App.AnalysisTaskController.updateRootConfigurations): Show 'None' when a revision is missing from
some of the data points. This will happen when we modify the list of projects we build for iOS.
(App.AnalysisTaskController.actions.createTestGroup): Gracefully fail by showing alerts when an user
attempts to create an invalid test group; when there is already another test group of the same or when
only either configuration specifies the revision for some repository.
(App.AnalysisTaskController._updateRootsBySelectedPoints): Fixed a typo: sets[i] -&gt; set.
* public/v2/index.html: Don't show the form to create a new test group if it's not available.
* tools/sync-with-buildbot.py:
(find_request_updates):
(schedule_request): iOS builders take a JSON that contains the list of roots. Generate this JSON when
a dictionary of the form {rootsExcluding: [&quot;WebKit&quot;]} is specified. Also replaced the way we refer to
a revision from $-based text replacements to an explicit dictionary of the form {root: &quot;WebKit&quot;}.
(request_id_from_build): Don't hard code the parameter name here. Retrieve the name from the config.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkWebsitesperfwebkitorgChangeLog">trunk/Websites/perf.webkit.org/ChangeLog</a></li>
<li><a href="#trunkWebsitesperfwebkitorgpublicapitriggerablesphp">trunk/Websites/perf.webkit.org/public/api/triggerables.php</a></li>
<li><a href="#trunkWebsitesperfwebkitorgpublicv2analysisjs">trunk/Websites/perf.webkit.org/public/v2/analysis.js</a></li>
<li><a href="#trunkWebsitesperfwebkitorgpublicv2appjs">trunk/Websites/perf.webkit.org/public/v2/app.js</a></li>
<li><a href="#trunkWebsitesperfwebkitorgpublicv2indexhtml">trunk/Websites/perf.webkit.org/public/v2/index.html</a></li>
<li><a href="#trunkWebsitesperfwebkitorgtoolssyncwithbuildbotpy">trunk/Websites/perf.webkit.org/tools/sync-with-buildbot.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 (182437 => 182438)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Websites/perf.webkit.org/ChangeLog        2015-04-06 20:49:40 UTC (rev 182437)
+++ trunk/Websites/perf.webkit.org/ChangeLog        2015-04-06 21:08:26 UTC (rev 182438)
</span><span class="lines">@@ -1,5 +1,35 @@
</span><span class="cx"> 2015-04-03  Ryosuke Niwa  &lt;rniwa@webkit.org&gt;
</span><span class="cx"> 
</span><ins>+        Perf dashboard should be able to trigger A/B testing jobs for iOS
+        https://bugs.webkit.org/show_bug.cgi?id=143398
+
+        Reviewed by Chris Dumez.
+
+        Fix various bugs in the perf dashboard so that it can schedule A/B testing jobs for iOS.
+
+        Also generalized sync-with-buildbot.py slightly to meet the requirements of iOS builders.
+
+        * public/api/triggerables.php:
+        (main): Avoid spitting a warning when $id_to_triggerable doesn't contain the triggerable.
+        * public/v2/analysis.js:
+        (App.AnalysisTask.triggerable): Log an error when failed to fetch triggerables for debugging purposes.
+        * public/v2/app.js:
+        (App.AnalysisTaskController.updateRootConfigurations): Show 'None' when a revision is missing from
+        some of the data points. This will happen when we modify the list of projects we build for iOS.
+        (App.AnalysisTaskController.actions.createTestGroup): Gracefully fail by showing alerts when an user
+        attempts to create an invalid test group; when there is already another test group of the same or when
+        only either configuration specifies the revision for some repository.
+        (App.AnalysisTaskController._updateRootsBySelectedPoints): Fixed a typo: sets[i] -&gt; set.
+        * public/v2/index.html: Don't show the form to create a new test group if it's not available.
+        * tools/sync-with-buildbot.py:
+        (find_request_updates):
+        (schedule_request): iOS builders take a JSON that contains the list of roots. Generate this JSON when
+        a dictionary of the form {rootsExcluding: [&quot;WebKit&quot;]} is specified. Also replaced the way we refer to
+        a revision from $-based text replacements to an explicit dictionary of the form {root: &quot;WebKit&quot;}.
+        (request_id_from_build): Don't hard code the parameter name here. Retrieve the name from the config.
+
+2015-04-03  Ryosuke Niwa  &lt;rniwa@webkit.org&gt;
+
</ins><span class="cx">         Add time series segmentation algorithms as moving averages
</span><span class="cx">         https://bugs.webkit.org/show_bug.cgi?id=143362
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkWebsitesperfwebkitorgpublicapitriggerablesphp"></a>
<div class="modfile"><h4>Modified: trunk/Websites/perf.webkit.org/public/api/triggerables.php (182437 => 182438)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Websites/perf.webkit.org/public/api/triggerables.php        2015-04-06 20:49:40 UTC (rev 182437)
+++ trunk/Websites/perf.webkit.org/public/api/triggerables.php        2015-04-06 21:08:26 UTC (rev 182438)
</span><span class="lines">@@ -27,7 +27,7 @@
</span><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     foreach ($db-&gt;select_rows('triggerable_repositories', 'trigrepo', array()) as $row) {
</span><del>-        $triggerable = $id_to_triggerable[$row['trigrepo_triggerable']];
</del><ins>+        $triggerable = array_get($id_to_triggerable, $row['trigrepo_triggerable']);
</ins><span class="cx">         if ($triggerable)
</span><span class="cx">             array_push($triggerable['acceptedRepositories'], $row['trigrepo_repository']);
</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 (182437 => 182438)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Websites/perf.webkit.org/public/v2/analysis.js        2015-04-06 20:49:40 UTC (rev 182437)
+++ trunk/Websites/perf.webkit.org/public/v2/analysis.js        2015-04-06 21:08:26 UTC (rev 182438)
</span><span class="lines">@@ -12,7 +12,8 @@
</span><span class="cx">     triggerable: function () {
</span><span class="cx">         return this.store.find('triggerable', {task: this.get('id')}).then(function (triggerables) {
</span><span class="cx">             return triggerables.objectAt(0);
</span><del>-        }, function () {
</del><ins>+        }, function (error) {
+            console.log('Failed to fetch triggerables', error);
</ins><span class="cx">             return null;
</span><span class="cx">         });
</span><span class="cx">     }.property(),
</span></span></pre></div>
<a id="trunkWebsitesperfwebkitorgpublicv2appjs"></a>
<div class="modfile"><h4>Modified: trunk/Websites/perf.webkit.org/public/v2/app.js (182437 => 182438)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Websites/perf.webkit.org/public/v2/app.js        2015-04-06 20:49:40 UTC (rev 182437)
+++ trunk/Websites/perf.webkit.org/public/v2/app.js        2015-04-06 21:08:26 UTC (rev 182438)
</span><span class="lines">@@ -1149,7 +1149,11 @@
</span><span class="cx">             self.set('configurations', ['A', 'B']);
</span><span class="cx">             self.set('rootConfigurations', triggerable.get('acceptedRepositories').map(function (repository) {
</span><span class="cx">                 var repositoryId = repository.get('id');
</span><del>-                var options = [{value: ' ', label: 'None'}].concat(repositoryToRevisions[repositoryId]);
</del><ins>+                var options = [{label: 'None'}].concat((repositoryToRevisions[repositoryId] || []).map(function (option, index) {
+                    if (!option || !option['value'])
+                        return {value: '', label: analysisPoints[index].label + ': None'}; 
+                    return option;
+                }));
</ins><span class="cx">                 return Ember.Object.create({
</span><span class="cx">                     repository: repository,
</span><span class="cx">                     name: repository.get('name'),
</span><span class="lines">@@ -1178,11 +1182,27 @@
</span><span class="cx">         },
</span><span class="cx">         createTestGroup: function (name, repetitionCount)
</span><span class="cx">         {
</span><ins>+            var analysisTask = this.get('model');
+            if (analysisTask.get('testGroups').isAny('name', name)) {
+                alert('Cannot create two test groups of the same name.');
+                return;
+            }
+
</ins><span class="cx">             var roots = {};
</span><del>-            this.get('rootConfigurations').map(function (root) {
-                roots[root.get('name')] = root.get('sets').map(function (item) { return item.get('selection').value; });
-            });
-            App.TestGroup.create(this.get('model'), name, roots, repetitionCount).then(function () {
</del><ins>+            var rootConfigurations = this.get('rootConfigurations').toArray();
+            for (var root of rootConfigurations) {
+                var sets = root.get('sets');
+                var hasSelection = function (item) { return item.get('selection') &amp;&amp; item.get('selection').value; };
+                if (!sets.any(hasSelection))
+                    continue;
+                if (!sets.every(hasSelection)) {
+                    alert('Only some configuration specifies ' + root.get('name'));
+                    return;
+                }
+                roots[root.get('name')] = sets.map(function (item) { return item.get('selection').value; });                
+            }
+
+            App.TestGroup.create(analysisTask, name, roots, repetitionCount).then(function () {
</ins><span class="cx">             }, function (error) {
</span><span class="cx">                 alert('Failed to create a new test group:' + error);
</span><span class="cx">             });
</span><span class="lines">@@ -1216,7 +1236,7 @@
</span><span class="cx">                 var selectedOption;
</span><span class="cx">                 if (targetRevision)
</span><span class="cx">                     selectedOption = set.get('options').find(function (option) { return option.value == targetRevision; });
</span><del>-                set.set('selection', selectedOption || sets[i].get('options')[0]);
</del><ins>+                set.set('selection', selectedOption || set.get('options')[0]);
</ins><span class="cx">             });
</span><span class="cx">         });
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkWebsitesperfwebkitorgpublicv2indexhtml"></a>
<div class="modfile"><h4>Modified: trunk/Websites/perf.webkit.org/public/v2/index.html (182437 => 182438)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Websites/perf.webkit.org/public/v2/index.html        2015-04-06 20:49:40 UTC (rev 182437)
+++ trunk/Websites/perf.webkit.org/public/v2/index.html        2015-04-06 21:08:26 UTC (rev 182438)
</span><span class="lines">@@ -648,6 +648,7 @@
</span><span class="cx">     &lt;/script&gt;
</span><span class="cx"> 
</span><span class="cx">     &lt;script type=&quot;text/x-handlebars&quot; data-template-name=&quot;testGroupForm&quot;&gt;
</span><ins>+    {{#if rootConfigurations}}
</ins><span class="cx">         &lt;form method=&quot;POST&quot; {{action &quot;createTestGroup&quot; newTestGroupName repetitionCount on=&quot;submit&quot;}}&gt;
</span><span class="cx">             &lt;section class=&quot;analysis-group&quot;&gt;
</span><span class="cx">                 &lt;h1&gt;{{input name=&quot;name&quot; value=newTestGroupName placeholder=&quot;Test group name&quot; required=true type=&quot;text&quot;}}&lt;/h1&gt;
</span><span class="lines">@@ -665,7 +666,7 @@
</span><span class="cx">                             &lt;tr&gt;
</span><span class="cx">                                 &lt;th&gt;{{name}}&lt;/th&gt;
</span><span class="cx">                                 {{#each sets}}
</span><del>-                                    &lt;td&gt;{{view Ember.Select name=name content=options disabled=true
</del><ins>+                                    &lt;td&gt;{{view Ember.Select name=name content=options
</ins><span class="cx">                                         optionValuePath=&quot;content.value&quot; optionLabelPath=&quot;content.label&quot;
</span><span class="cx">                                         selection=selection}}&lt;/td&gt;
</span><span class="cx">                                 {{/each}}
</span><span class="lines">@@ -677,6 +678,7 @@
</span><span class="cx">                 &lt;button type=&quot;submit&quot;&gt;Start A/B testing&lt;/button&gt;
</span><span class="cx">             &lt;/section&gt;
</span><span class="cx">         &lt;/form&gt;
</span><ins>+    {{/if}}
</ins><span class="cx">     &lt;/script&gt;
</span><span class="cx"> 
</span><span class="cx"> &lt;/head&gt;
</span></span></pre></div>
<a id="trunkWebsitesperfwebkitorgtoolssyncwithbuildbotpy"></a>
<div class="modfile"><h4>Modified: trunk/Websites/perf.webkit.org/tools/sync-with-buildbot.py (182437 => 182438)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Websites/perf.webkit.org/tools/sync-with-buildbot.py        2015-04-06 20:49:40 UTC (rev 182437)
+++ trunk/Websites/perf.webkit.org/tools/sync-with-buildbot.py        2015-04-06 21:08:26 UTC (rev 182438)
</span><span class="lines">@@ -72,7 +72,7 @@
</span><span class="cx">     for config in configurations:
</span><span class="cx">         try:
</span><span class="cx">             pending_builds = fetch_json(config['jsonURL'] + 'pendingBuilds')
</span><del>-            scheduled_requests = filter(None, [request_id_from_build(build) for build in pending_builds])
</del><ins>+            scheduled_requests = filter(None, [request_id_from_build(config, build) for build in pending_builds])
</ins><span class="cx">             for request_id in scheduled_requests:
</span><span class="cx">                 request_updates[request_id] = {'status': 'scheduled', 'url': config['url']}
</span><span class="cx">             config['scheduledRequests'] = set(scheduled_requests)
</span><span class="lines">@@ -85,7 +85,7 @@
</span><span class="cx">             build_index = -i
</span><span class="cx">             try:
</span><span class="cx">                 build = fetch_json(config['jsonURL'] + 'builds/%d' % build_index)
</span><del>-                request_id = request_id_from_build(build)
</del><ins>+                request_id = request_id_from_build(config, build)
</ins><span class="cx">                 if not request_id:
</span><span class="cx">                     continue
</span><span class="cx"> 
</span><span class="lines">@@ -133,14 +133,25 @@
</span><span class="cx"> 
</span><span class="cx"> 
</span><span class="cx"> def schedule_request(config, request, root_sets):
</span><del>-    replacements = root_sets.get(request['rootSet'], {})
-    replacements['buildRequest'] = request['id']
</del><ins>+    roots = root_sets.get(request['rootSet'], {})
+    replacements = roots.copy()
</ins><span class="cx"> 
</span><span class="cx">     payload = {}
</span><span class="cx">     for property_name, property_value in config['arguments'].iteritems():
</span><del>-        for key, value in replacements.iteritems():
-            property_value = property_value.replace('$' + key, value)
-        payload[property_name] = property_value
</del><ins>+        if not isinstance(property_value, dict):
+            payload[property_name] = property_value
+        elif 'root' in property_value:
+            payload[property_name] = replacements[property_value['root']]
+        elif 'rootsExcluding' in property_value:
+            excluded_roots = property_value['rootsExcluding']
+            filtered_roots = {}
+            for root_name in roots:
+                if root_name not in excluded_roots:
+                    filtered_roots[root_name] = roots[root_name]
+            payload[property_name] = json.dumps(filtered_roots)
+        else:
+            print &gt;&gt; sys.stderr, &quot;Failed to process an argument %s: %s&quot; % (property_name, property_value)
+    payload[config['buildRequestArgument']] = request['id']
</ins><span class="cx"> 
</span><span class="cx">     try:
</span><span class="cx">         urllib2.urlopen(urllib2.Request(config['url'] + 'force'), urllib.urlencode(payload))
</span><span class="lines">@@ -174,8 +185,8 @@
</span><span class="cx">     return None
</span><span class="cx"> 
</span><span class="cx"> 
</span><del>-def request_id_from_build(build):
-    job_id = property_value_from_build(build, 'jobid')
</del><ins>+def request_id_from_build(config, build):
+    job_id = property_value_from_build(build, config['buildRequestArgument'])
</ins><span class="cx">     return int(job_id) if job_id and job_id.isdigit() else None
</span><span class="cx"> 
</span><span class="cx"> 
</span></span></pre>
</div>
</div>

</body>
</html>