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

Side by Side Diff: Tools/GardeningServer/model/ct-failures.html

Issue 526633002: Apply object updates from the network without blowing away object identity or UI attributes. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Initial Created 6 years, 3 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 unified diff | Download patch
OLDNEW
1 <!-- 1 <!--
2 Copyright 2014 The Chromium Authors. All rights reserved. 2 Copyright 2014 The Chromium Authors. All rights reserved.
3 Use of this source code is governed by a BSD-style license that can be 3 Use of this source code is governed by a BSD-style license that can be
4 found in the LICENSE file. 4 found in the LICENSE file.
5 --> 5 -->
6 6
7 <link rel="import" href="../lib/net.html"> 7 <link rel="import" href="../lib/net.html">
8 <link rel="import" href="../lib/util.html">
8 <link rel="import" href="ct-builder-revisions.html"> 9 <link rel="import" href="ct-builder-revisions.html">
9 <link rel="import" href="ct-failure.html"> 10 <link rel="import" href="ct-failure.html">
10 <link rel="import" href="ct-failure-group.html"> 11 <link rel="import" href="ct-failure-group.html">
11 <link rel="import" href="ct-commit-list.html"> 12 <link rel="import" href="ct-commit-list.html">
12 13
13 <script> 14 <script>
14 function CTFailures(commitLog) { 15 function CTFailures(commitLog) {
15 this.commitLog = commitLog; 16 this.commitLog = commitLog;
16 this.builderLatestRevisions = null; 17 this.builderLatestRevisions = null;
17 this.failures = null; 18 // Maps a tree id to an array of CTFailureGroups within that tree.
19 this.failures = {};
18 this.lastUpdateDate = null; 20 this.lastUpdateDate = null;
19 21
20 // FIXME: Get this from 22 // FIXME: Get this from
21 // https://chromium.googlesource.com/chromium/tools/build/+/master/scripts/sla ve/gatekeeper_trees.json?format=text. 23 // https://chromium.googlesource.com/chromium/tools/build/+/master/scripts/sla ve/gatekeeper_trees.json?format=text.
22 this._trees = { 24 this._trees = {
23 blink: [ 25 blink: [
24 "https://build.chromium.org/p/chromium.webkit", 26 "https://build.chromium.org/p/chromium.webkit",
25 ], 27 ],
26 chromium: [ 28 chromium: [
27 "https://build.chromium.org/p/chromium", 29 "https://build.chromium.org/p/chromium",
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
74 } 76 }
75 return 0; 77 return 0;
76 }; 78 };
77 79
78 CTFailures.prototype.update = function() { 80 CTFailures.prototype.update = function() {
79 var annotationPromise = CTFailureGroup.fetchAnnotations(); 81 var annotationPromise = CTFailureGroup.fetchAnnotations();
80 net.json('http://sheriff-o-matic.appspot.com/alerts').then(function(data) { 82 net.json('http://sheriff-o-matic.appspot.com/alerts').then(function(data) {
81 annotationPromise.then(function(annotations) { 83 annotationPromise.then(function(annotations) {
82 // FIXME: Don't special-case the blink master. 84 // FIXME: Don't special-case the blink master.
83 this.builderLatestRevisions = new CTBuilderRevisions(data.latest_builder_i nfo['chromium.webkit']); 85 this.builderLatestRevisions = new CTBuilderRevisions(data.latest_builder_i nfo['chromium.webkit']);
84 this.failures = {}; 86 var newFailures = {};
85 this.lastUpdateDate = new Date(data.date * 1000); 87 this.lastUpdateDate = new Date(data.date * 1000);
86 // Update |failures| with the appropriate CTFailureGroup's for each 88 // Update |failures| with the appropriate CTFailureGroup's for each
87 // tree. 89 // tree.
88 data.range_groups.forEach(function(rangeGroup) { 90 data.range_groups.forEach(function(rangeGroup) {
89 this._processFailuresForRangeGroup(rangeGroup, data.alerts, annotations) ; 91 this._processFailuresForRangeGroup(newFailures, rangeGroup, data.alerts, annotations);
90 }.bind(this)); 92 }.bind(this));
91 // Sort failure groups so that newer failures are shown at the top 93 // Sort failure groups so that newer failures are shown at the top
92 // of the UI. 94 // of the UI.
93 Object.keys(this.failures, function (tree, failuresByTree) { 95 Object.keys(newFailures, function (tree, failuresByTree) {
94 this.failures[tree].sort(this._failureByTreeListComparator.bind(this, tr ee)); 96 failuresByTree.sort(this._failureByTreeListComparator.bind(this, tree));
95 }.bind(this)); 97 }.bind(this));
98 util.updateLeft(this.failures, newFailures);
96 }.bind(this)); 99 }.bind(this));
97 }.bind(this)); 100 }.bind(this));
98 }; 101 };
99 102
100 CTFailures.prototype._failureComparator = function(a, b) { 103 CTFailures.prototype._failureComparator = function(a, b) {
101 if (a.step > b.step) 104 if (a.step > b.step)
102 return 1; 105 return 1;
103 if (a.step < b.step) 106 if (a.step < b.step)
104 return -1 107 return -1
105 if (a.testName > b.testName) 108 if (a.testName > b.testName)
106 return 1; 109 return 1;
107 if (a.testName < b.testName) 110 if (a.testName < b.testName)
108 return -1 111 return -1
109 return 0; 112 return 0;
110 }; 113 };
111 114
112 CTFailures.prototype._processFailuresForRangeGroup = function(rangeGroup, alerts , annotations) { 115 CTFailures.prototype._processFailuresForRangeGroup = function(newFailures, range Group, alerts, annotations) {
113 var masterToTree = {}; 116 var masterToTree = {};
114 Object.keys(this._trees, function(tree, masters) { 117 Object.keys(this._trees, function(tree, masters) {
115 masters.forEach(function(master) { 118 masters.forEach(function(master) {
116 masterToTree[master] = tree; 119 masterToTree[master] = tree;
117 }); 120 });
118 }); 121 });
119 122
120 // A rangeGroup may be related to multiple alerts (via |failure_keys|). Catego rize 123 // A rangeGroup may be related to multiple alerts (via |failure_keys|). Catego rize
121 // these failures by reason (cause of failure), so that they can be grouped in the UI 124 // these failures by reason (cause of failure), so that they can be grouped in the UI
122 // (via a CTFailureGroup). Failures will be grouped in |failuresByReason|. 125 // (via a CTFailureGroup). Failures will be grouped in |failuresByReason|.
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
159 earliestFailingBuild: failure.failing_build, 162 earliestFailingBuild: failure.failing_build,
160 masterUrl: failure.master_url, 163 masterUrl: failure.master_url,
161 failingBuildCount: failure.failing_build_count, 164 failingBuildCount: failure.failing_build_count,
162 annotation: annotations[failureKey], 165 annotation: annotations[failureKey],
163 }; 166 };
164 }.bind(this)); 167 }.bind(this));
165 168
166 if (!Object.keys(failuresByReason).length) 169 if (!Object.keys(failuresByReason).length)
167 return; 170 return;
168 171
172 // Maps a tree id to a list of CTFailures in that tree.
169 var groupedFailures = {}; 173 var groupedFailures = {};
170 Object.keys(failuresByReason, function(reasonKey, resultsByTree) { 174 Object.keys(failuresByReason, function(reasonKey, resultsByTree) {
171 var failure = JSON.parse(reasonKey); 175 var failure = JSON.parse(reasonKey);
172 Object.keys(resultsByTree, function(tree, resultsByBuilder) { 176 Object.keys(resultsByTree, function(tree, resultsByBuilder) {
173 if (!groupedFailures[tree]) 177 if (!groupedFailures[tree])
174 groupedFailures[tree] = []; 178 groupedFailures[tree] = [];
175 groupedFailures[tree].push( 179 groupedFailures[tree].push(
176 new CTFailure(failure.step, failure.reason, resultsByBuilder)); 180 new CTFailure(failure.step, failure.reason, resultsByBuilder));
177 }) 181 })
178 }); 182 });
179 183
180 Object.keys(groupedFailures, function(tree, failures) { 184 Object.keys(groupedFailures, function(tree, failures) {
181 failures.sort(this._failureComparator); 185 failures.sort(this._failureComparator);
182 186
183 if (!this.failures[tree]) 187 if (!newFailures[tree])
184 this.failures[tree] = []; 188 newFailures[tree] = [];
185 var commitList = new CTCommitList(this.commitLog, rangeGroup.likely_revision s); 189 var commitList = new CTCommitList(this.commitLog, rangeGroup.likely_revision s);
186 this.failures[tree].push(new CTFailureGroup(failures, commitList)); 190 newFailures[tree].push(new CTFailureGroup(rangeGroup.sort_key, failures, com mitList));
187 }.bind(this)); 191 }.bind(this));
188 }; 192 };
189 193
190 </script> 194 </script>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698