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 <link href="../model/ct-builder-revisions.html" rel="import"> | 6 <link href="../model/ct-builder-revisions.html" rel="import"> |
7 | 7 |
8 <link rel="import" href="../lib/net.html"> | 8 <link rel="import" href="../lib/net.html"> |
9 <link rel="import" href="../model/ct-failure.html"> | 9 <link rel="import" href="../model/ct-failure.html"> |
10 <link rel="import" href="../model/ct-failure-group.html"> | 10 <link rel="import" href="../model/ct-failure-group.html"> |
11 | 11 |
12 <polymer-element name="ct-failure-analyzer" attributes="failures builderLatestRe
visions lastUpdateDate"> | 12 <polymer-element name="ct-failure-analyzer" attributes="commitLog failures build
erLatestRevisions lastUpdateDate"> |
13 <script> | 13 <script> |
14 // FIXME: Don't use a polymer component for this. Instead use a Failures mod
el | 14 // FIXME: Don't use a polymer component for this. Instead use a Failures mod
el |
15 // object that knows how to do the XHR and process the data appropriately. | 15 // object that knows how to do the XHR and process the data appropriately. |
16 Polymer({ | 16 Polymer({ |
| 17 commitLog: null, |
17 builderLatestRevisions: null, | 18 builderLatestRevisions: null, |
18 failures: null, | 19 failures: null, |
19 lastUpdateDate: null, | 20 lastUpdateDate: null, |
20 | 21 |
21 // FIXME: Get this from https://chromium.googlesource.com/chromium/tools/b
uild/+/master/scripts/slave/gatekeeper_trees.json?format=text. | 22 // FIXME: Get this from https://chromium.googlesource.com/chromium/tools/b
uild/+/master/scripts/slave/gatekeeper_trees.json?format=text. |
22 _trees: { | 23 _trees: { |
23 blink: [ | 24 blink: [ |
24 "https://build.chromium.org/p/chromium.webkit", | 25 "https://build.chromium.org/p/chromium.webkit", |
25 ], | 26 ], |
26 chromium: [ | 27 chromium: [ |
27 "https://build.chromium.org/p/chromium", | 28 "https://build.chromium.org/p/chromium", |
28 "https://build.chromium.org/p/chromium.chrome", | 29 "https://build.chromium.org/p/chromium.chrome", |
29 "https://build.chromium.org/p/chromium.chromiumos", | 30 "https://build.chromium.org/p/chromium.chromiumos", |
30 "https://build.chromium.org/p/chromium.gpu", | 31 "https://build.chromium.org/p/chromium.gpu", |
31 "https://build.chromium.org/p/chromium.linux", | 32 "https://build.chromium.org/p/chromium.linux", |
32 "https://build.chromium.org/p/chromium.mac", | 33 "https://build.chromium.org/p/chromium.mac", |
33 "https://build.chromium.org/p/chromium.memory", | 34 "https://build.chromium.org/p/chromium.memory", |
34 "https://build.chromium.org/p/chromium.win" | 35 "https://build.chromium.org/p/chromium.win" |
35 ], | 36 ], |
36 }, | 37 }, |
37 | 38 |
38 _failureListComparator: function(tree, a, b) { | 39 // Reverse sorting order, if a > b, return a negative number. |
| 40 _failureByTreeListComparator: function(tree, a, b) { |
39 if (tree === undefined) | 41 if (tree === undefined) |
40 tree = 'chromium'; | 42 tree = 'chromium'; |
41 | 43 |
42 var rev_a = a.failures[0].firstFailingRevisions; | 44 var rev_a = a.commitList.revisions; |
43 var rev_b = b.failures[0].firstFailingRevisions; | 45 var rev_b = b.commitList.revisions; |
44 | 46 |
45 // Handle missing revision. | 47 if (!rev_a || !Object.keys(rev_a).length) { |
46 if (!rev_a) { | 48 if (!rev_b || !Object.keys(rev_b).length) |
47 if (!rev_b) { | |
48 return 0; | 49 return 0; |
49 } | 50 return 1; |
| 51 } else if (!rev_b || !Object.keys(rev_b).length) { |
50 return -1; | 52 return -1; |
51 } else if (!rev_b) { | |
52 return 1; | |
53 } | 53 } |
54 | 54 |
55 // Prioritize the tree's revision. | 55 // Prioritize the tree's revision, if they are unequal (else, fallback |
56 if (rev_a[tree] != rev_b[tree]) | 56 // below). |
57 return rev_b[tree] - rev_a[tree]; | 57 if (rev_a[tree] && rev_b[tree] && |
| 58 rev_a[tree].last() != rev_b[tree].last()) { |
| 59 return rev_b[tree].last() - rev_a[tree].last(); |
| 60 } |
58 | 61 |
59 // Compare other revisions in alphabetical order. | 62 // Compare other revisions in alphabetical order. |
60 var keys = Object.keys(rev_a).sort(); | 63 var keys = Object.keys(rev_a).sort(); |
61 for (var i = 0; i < keys.length; i++) { | 64 for (var i = 0; i < keys.length; i++) { |
62 if (rev_a[keys[i]] != rev_b[keys[i]]) | 65 if (keys[i] == tree) // Already taken care of, above. |
63 return rev_b[keys[i]] - rev_a[keys[i]]; | 66 continue; |
| 67 |
| 68 var a_list = rev_a[keys[i]]; |
| 69 var b_list = rev_b[keys[i]]; |
| 70 if (!b_list) |
| 71 return -1; |
| 72 |
| 73 if (a_list.last() != b_list.last()) |
| 74 return b_list.last() - a_list.last(); |
64 } | 75 } |
65 return 0; | 76 return 0; |
66 }, | 77 }, |
67 | 78 |
68 update: function() { | 79 update: function() { |
69 var annotationPromise = CTFailureGroup.fetchAnnotations(); | 80 var annotationPromise = CTFailureGroup.fetchAnnotations(); |
70 net.json('http://sheriff-o-matic.appspot.com/alerts').then(function(data
) { | 81 net.json('http://sheriff-o-matic.appspot.com/alerts').then(function(data
) { |
71 annotationPromise.then(function(annotations) { | 82 annotationPromise.then(function(annotations) { |
72 // FIXME: Don't special-case the blink master. | 83 // FIXME: Don't special-case the blink master. |
73 this.builderLatestRevisions = new CTBuilderRevisions(data.latest_bui
lder_info['chromium.webkit']); | 84 this.builderLatestRevisions = new CTBuilderRevisions(data.latest_bui
lder_info['chromium.webkit']); |
74 this.failures = {}; | 85 this.failures = {}; |
75 this.lastUpdateDate = new Date(data.date * 1000); | 86 this.lastUpdateDate = new Date(data.date * 1000); |
76 data.range_groups.forEach(function(group) { | 87 // Update |failures| with the appropriate CTFailureGroup's for each
tree. |
77 this._processFailuresForGroup(group, data.alerts, annotations); | 88 data.range_groups.forEach(function(rangeGroup) { |
| 89 this._processFailuresForRangeGroup(rangeGroup, data.alerts, annota
tions); |
78 }.bind(this)); | 90 }.bind(this)); |
| 91 // Sort failure groups so that newer failures are shown at the top o
f the UI. |
79 Object.keys(this.failures, function (tree, failuresByTree) { | 92 Object.keys(this.failures, function (tree, failuresByTree) { |
80 this.failures[tree].sort(this._failureListComparator.bind(this, tr
ee)); | 93 this.failures[tree].sort(this._failureByTreeListComparator.bind(th
is, tree)); |
81 }.bind(this)); | 94 }.bind(this)); |
82 }.bind(this)); | 95 }.bind(this)); |
83 }.bind(this)); | 96 }.bind(this)); |
84 }, | 97 }, |
85 | 98 |
86 _failureComparator: function(a, b) { | 99 _failureComparator: function(a, b) { |
87 if (a.step > b.step) | 100 if (a.step > b.step) |
88 return 1; | 101 return 1; |
89 if (a.step < b.step) | 102 if (a.step < b.step) |
90 return -1 | 103 return -1 |
91 if (a.testName > b.testName) | 104 if (a.testName > b.testName) |
92 return 1; | 105 return 1; |
93 if (a.testName < b.testName) | 106 if (a.testName < b.testName) |
94 return -1 | 107 return -1 |
95 return 0; | 108 return 0; |
96 }, | 109 }, |
97 | 110 |
98 _processFailuresForGroup: function(group, failures, annotations) { | 111 _processFailuresForRangeGroup: function(rangeGroup, alerts, annotations) { |
99 var failuresByReason = {}; | |
100 | |
101 var masterToTree = {}; | 112 var masterToTree = {}; |
102 Object.keys(this._trees, function(tree, masters) { | 113 Object.keys(this._trees, function(tree, masters) { |
103 masters.forEach(function(master) { | 114 masters.forEach(function(master) { |
104 masterToTree[master] = tree; | 115 masterToTree[master] = tree; |
105 }); | 116 }); |
106 }); | 117 }); |
107 | 118 |
108 group.failure_keys.forEach(function(failure_key) { | 119 // A rangeGroup may be related to multiple alerts (via |failure_keys|).
Categorize |
109 var failure = failures.find(function(item) { return item.key == failur
e_key; }); | 120 // these failures by reason (cause of failure), so that they can be grou
ped in the UI |
| 121 // (via a CTFailureGroup). Failures will be grouped in |failuresByReason
|. |
| 122 var failuresByReason = {}; |
| 123 rangeGroup.failure_keys.forEach(function(failure_key) { |
| 124 var failure = alerts.find(function(item) { return item.key == failure_
key; }); |
| 125 // Establish the key to uniquely identify a failure by reason. |
110 var reason, failureType; | 126 var reason, failureType; |
111 if (failure.reason) { | 127 if (failure.reason) { |
112 // FIXME: Store the actual failure type in a different field instead
of smashing it into the reason. | 128 // FIXME: Store the actual failure type in a different field instead
of smashing it into the reason. |
113 var parts = failure.reason.split(':'); | 129 var parts = failure.reason.split(':'); |
114 reason = parts[0]; | 130 reason = parts[0]; |
115 failureType = parts[1] || 'FAIL'; | 131 failureType = parts[1] || 'FAIL'; |
116 } else { | 132 } else { |
117 reason = null; | 133 reason = null; |
118 failureType = 'UNKNOWN'; | 134 failureType = 'UNKNOWN'; |
119 } | 135 } |
120 | 136 |
121 var failureKey = JSON.stringify({ | 137 var failureKey = JSON.stringify({ |
122 step: failure.step_name, | 138 step: failure.step_name, |
123 reason: reason, | 139 reason: reason, |
124 }); | 140 }); |
125 | 141 |
| 142 // FIXME: Figure out what tree masters that aren't in masterToTree |
| 143 // we should have. |
126 var tree = masterToTree[failure.master_url]; | 144 var tree = masterToTree[failure.master_url]; |
127 | 145 |
128 // FIXME: Use a model class instead of a dumb object. | 146 // FIXME: Use a model class instead of a dumb object. |
129 if (!failuresByReason[failureKey]) | 147 if (!failuresByReason[failureKey]) |
130 failuresByReason[failureKey] = {}; | 148 failuresByReason[failureKey] = {}; |
131 if (!failuresByReason[failureKey][tree]) | 149 if (!failuresByReason[failureKey][tree]) |
132 failuresByReason[failureKey][tree] = {}; | 150 failuresByReason[failureKey][tree] = {}; |
133 failuresByReason[failureKey][tree][failure.builder_name] = { | 151 failuresByReason[failureKey][tree][failure.builder_name] = { |
134 // FIXME: Rename to failureType. | 152 // FIXME: Rename to failureType. |
135 actual: failureType, | 153 actual: failureType, |
136 lastFailingBuild: failure.last_failing_build, | 154 lastFailingBuild: failure.last_failing_build, |
137 earliestFailingBuild: failure.failing_build, | 155 earliestFailingBuild: failure.failing_build, |
138 masterUrl: failure.master_url, | 156 masterUrl: failure.master_url, |
139 failingBuildCount: failure.failing_build_count, | 157 failingBuildCount: failure.failing_build_count, |
140 }; | 158 }; |
141 }.bind(this)); | 159 }.bind(this)); |
142 | 160 |
| 161 if (!Object.keys(failuresByReason).length) |
| 162 return; |
| 163 |
143 var groupedFailures = {}; | 164 var groupedFailures = {}; |
144 Object.keys(failuresByReason, function(failureKey, resultsByTree) { | 165 Object.keys(failuresByReason, function(failureKey, resultsByTree) { |
145 var failure = JSON.parse(failureKey); | 166 var failure = JSON.parse(failureKey); |
146 Object.keys(resultsByTree, function(tree, resultsByBuilder) { | 167 Object.keys(resultsByTree, function(tree, resultsByBuilder) { |
147 if (!groupedFailures[tree]) | 168 if (!groupedFailures[tree]) |
148 groupedFailures[tree] = []; | 169 groupedFailures[tree] = []; |
149 groupedFailures[tree].push(new CTFailure(failure.step, failure.reaso
n, resultsByBuilder, group.merged_first_failing, group.merged_last_passing)); | 170 groupedFailures[tree].push( |
| 171 new CTFailure(failure.step, failure.reason, resultsByBuilder)); |
150 }) | 172 }) |
151 }); | 173 }); |
152 | 174 |
153 Object.keys(groupedFailures, function(tree, failures) { | 175 Object.keys(groupedFailures, function(tree, failures) { |
154 failures.sort(this._failureComparator); | 176 failures.sort(this._failureComparator); |
155 | 177 |
156 if (!this.failures[tree]) | 178 if (!this.failures[tree]) |
157 this.failures[tree] = []; | 179 this.failures[tree] = []; |
158 // FIXME: Need a better identifier for a failure group; | 180 // FIXME: Need a better identifier for a failure group; |
159 var key = group.sort_key; | 181 var key = rangeGroup.sort_key; |
160 this.failures[tree].push(new CTFailureGroup(key, failures, annotations
[key])); | 182 var commitList = new CTCommitList(this.commitLog, rangeGroup.likely_re
visions); |
| 183 this.failures[tree].push( |
| 184 new CTFailureGroup(key, failures, commitList, annotations[key])); |
161 }.bind(this)); | 185 }.bind(this)); |
162 }, | 186 }, |
163 }); | 187 }); |
164 </script> | 188 </script> |
165 </polymer-element> | 189 </polymer-element> |
OLD | NEW |