OLD | NEW |
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/update-util.html"> | 8 <link rel="import" href="../lib/update-util.html"> |
9 <link rel="import" href="ct-builder-revisions.html"> | 9 <link rel="import" href="ct-builder-revisions.html"> |
10 <link rel="import" href="ct-failure.html"> | 10 <link rel="import" href="ct-failure.html"> |
11 <link rel="import" href="ct-failure-group.html"> | 11 <link rel="import" href="ct-failure-group.html"> |
| 12 <link rel="import" href="ct-builder-failure-group-data.html"> |
12 <link rel="import" href="ct-sheriff-failure-group-data.html"> | 13 <link rel="import" href="ct-sheriff-failure-group-data.html"> |
13 <link rel="import" href="ct-trooper-failure-group-data.html"> | 14 <link rel="import" href="ct-trooper-failure-group-data.html"> |
14 <link rel="import" href="ct-commit-list.html"> | 15 <link rel="import" href="ct-commit-list.html"> |
15 | 16 |
16 <script> | 17 <script> |
17 function CTFailures(commitLog) { | 18 function CTFailures(commitLog) { |
18 this.commitLog = commitLog; | 19 this.commitLog = commitLog; |
19 this.builderLatestRevisions = null; | 20 this.builderLatestInfo = null; |
20 // Maps a tree id to an array of CTFailureGroups within that tree. | 21 // Maps a tree id to an array of CTFailureGroups within that tree. |
21 this.failures = null; | 22 this.failures = null; |
22 this.lastUpdateDate = null; | 23 this.lastUpdateDate = null; |
23 } | 24 } |
24 | 25 |
25 (function() { | 26 (function() { |
26 'use strict'; | 27 'use strict'; |
27 | 28 |
28 // FIXME: This could potentially move onto CTSheriffFailureGroupData as it isn't
relevant to | 29 // FIXME: This could potentially move onto CTSheriffFailureGroupData as it isn't
relevant to |
29 // trooper failures. | 30 // trooper failures. |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
86 }; | 87 }; |
87 | 88 |
88 CTFailures.prototype.update = function() { | 89 CTFailures.prototype.update = function() { |
89 var annotationPromise = CTFailureGroup.fetchAnnotations(); | 90 var annotationPromise = CTFailureGroup.fetchAnnotations(); |
90 return Promise.all([annotationPromise, net.json('http://sheriff-o-matic.appspo
t.com/alerts'), | 91 return Promise.all([annotationPromise, net.json('http://sheriff-o-matic.appspo
t.com/alerts'), |
91 net.json('http://trooper-o-matic.appspot.com/alerts')]).then(function(data
_array) { | 92 net.json('http://trooper-o-matic.appspot.com/alerts')]).then(function(data
_array) { |
92 var annotations = data_array[0]; | 93 var annotations = data_array[0]; |
93 var sheriff_data = data_array[1]; | 94 var sheriff_data = data_array[1]; |
94 var trooper_data = data_array[2]; | 95 var trooper_data = data_array[2]; |
95 | 96 |
96 // FIXME: Don't special-case the blink master. | 97 this.builderLatestInfo = {}; |
97 this.builderLatestRevisions = new CTBuilderRevisions(sheriff_data.latest_bui
lder_info['chromium.webkit']); | 98 |
| 99 Object.keys(sheriff_data.latest_builder_info, function (master, data) { |
| 100 this.builderLatestInfo[master] = data |
| 101 }.bind(this)); |
98 var newFailures = {}; | 102 var newFailures = {}; |
99 this.lastUpdateDate = new Date(sheriff_data.date * 1000); | 103 this.lastUpdateDate = new Date(sheriff_data.date * 1000); |
100 this._mungeAlerts(sheriff_data.alerts); | 104 this._mungeAlerts(sheriff_data.alerts); |
101 // FIXME: Change builder_alerts to expose the alerts as a map instead of an
array. | 105 // FIXME: Change builder_alerts to expose the alerts as a map instead of an
array. |
102 var alertsByKey = {} | 106 var alertsByKey = {} |
103 sheriff_data.alerts.forEach(function(alert) { | 107 sheriff_data.alerts.forEach(function(alert) { |
104 alertsByKey[alert.key] = alert; | 108 alertsByKey[alert.key] = alert; |
105 }); | 109 }); |
106 // Update |failures| with the appropriate CTFailureGroup's for each | 110 // Update |failures| with the appropriate CTFailureGroup's for each |
107 // tree. | 111 // tree. |
108 sheriff_data.range_groups.forEach(function(rangeGroup) { | 112 sheriff_data.range_groups.forEach(function(rangeGroup) { |
109 this._processFailuresForRangeGroup(newFailures, rangeGroup, alertsByKey, a
nnotations); | 113 this._processFailuresForRangeGroup(newFailures, rangeGroup, alertsByKey, a
nnotations); |
110 }.bind(this)); | 114 }.bind(this)); |
111 // Sort failure groups so that newer failures are shown at the top | 115 // Sort failure groups so that newer failures are shown at the top |
112 // of the UI. | 116 // of the UI. |
| 117 |
113 Object.keys(newFailures, function (tree, failuresByTree) { | 118 Object.keys(newFailures, function (tree, failuresByTree) { |
114 failuresByTree.sort(this._failureByTreeListComparator.bind(this, tree)); | 119 failuresByTree.sort(this._failureByTreeListComparator.bind(this, tree)); |
115 }.bind(this)); | 120 }.bind(this)); |
| 121 |
| 122 this._checkBuildersForFailures(newFailures); |
116 this.failures = updateUtil.updateLeft(this.failures, newFailures); | 123 this.failures = updateUtil.updateLeft(this.failures, newFailures); |
117 this._processTrooperFailures(trooper_data); | 124 this._processTrooperFailures(trooper_data); |
118 }.bind(this)); | 125 }.bind(this)); |
119 }; | 126 }; |
120 | 127 |
121 CTFailures.prototype._failureComparator = function(a, b) { | 128 CTFailures.prototype._failureComparator = function(a, b) { |
122 if (a.step > b.step) | 129 if (a.step > b.step) |
123 return 1; | 130 return 1; |
124 if (a.step < b.step) | 131 if (a.step < b.step) |
125 return -1 | 132 return -1 |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
194 }) | 201 }) |
195 treeFailures.sort(this._failureComparator); | 202 treeFailures.sort(this._failureComparator); |
196 | 203 |
197 if (!newFailures[tree]) | 204 if (!newFailures[tree]) |
198 newFailures[tree] = []; | 205 newFailures[tree] = []; |
199 var commitList = new CTCommitList(this.commitLog, rangeGroup.likely_revision
s); | 206 var commitList = new CTCommitList(this.commitLog, rangeGroup.likely_revision
s); |
200 newFailures[tree].push(new CTFailureGroup(rangeGroup.sort_key, new CTSheriff
FailureGroupData(treeFailures, commitList))); | 207 newFailures[tree].push(new CTFailureGroup(rangeGroup.sort_key, new CTSheriff
FailureGroupData(treeFailures, commitList))); |
201 }.bind(this)); | 208 }.bind(this)); |
202 }; | 209 }; |
203 | 210 |
| 211 CTFailures.prototype._checkBuildersForFailures = function(newFailures) { |
| 212 var timeThreshold = { |
| 213 "idle": null, // FIXME: We should alert if a bot is idle with jobs queued |
| 214 "building": 3 * 60 * 60, |
| 215 "offline": 0.5 * 60 * 60 |
| 216 }; |
| 217 Object.keys(this.builderLatestInfo, function(master, builders) { |
| 218 // FIXME: Don't special case blink and chromium.webkit |
| 219 if (master == "chromium.webkit") { |
| 220 var tree = "blink"; |
| 221 Object.keys(builders, function(builder, builderInfo) { |
| 222 var timeSinceLastUpdate = (this.lastUpdateDate.valueOf() / 1000) - buil
derInfo.lastUpdateTime; |
| 223 var alert; |
| 224 // This alert logic should live on the buildbot. |
| 225 if (timeSinceLastUpdate > timeThreshold[builderInfo.state] && builderInf
o.state != "idle") |
| 226 alert = (timeSinceLastUpdate / (60 * 60)).toFixed(2) + " hours "; |
| 227 |
| 228 var resultsByBuilder = { }; |
| 229 resultsByBuilder[builder] = { |
| 230 "actual": "UNKNOWN", |
| 231 "masterUrl": "http://build.chromium.org/p/" + master |
| 232 } |
| 233 if (alert) { |
| 234 if (!newFailures[tree]) |
| 235 newFailures[tree] = []; |
| 236 var key = master + "::" + builder + "::" + builderInfo.state; |
| 237 var failure = new CTFailure(builderInfo.state, alert, resultsByBuilder
); |
| 238 var data = new CTBuilderFailureGroupData(failure, builder, "http://bui
ld.chromium.org/p/" + master + "/builders/" + builder); |
| 239 newFailures[tree].push(new CTFailureGroup(key, data, 'builders')); |
| 240 } |
| 241 }.bind(this)); |
| 242 } |
| 243 }.bind(this)); |
| 244 }; |
| 245 |
204 })(); | 246 })(); |
| 247 |
205 </script> | 248 </script> |
OLD | NEW |