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="../ct-failures.html"> | 7 <link rel="import" href="../ct-failures.html"> |
8 | 8 |
9 <link rel="import" href="../../lib/network-simulator.html"> | 9 <link rel="import" href="../../lib/network-simulator.html"> |
10 <link rel="import" href="../ct-commit-list.html"> | 10 <link rel="import" href="../ct-commit-list.html"> |
11 <link rel="import" href="../ct-commit-log-mock.html"> | 11 <link rel="import" href="../ct-commit-log-mock.html"> |
12 <link rel="import" href="../ct-failure-group.html"> | 12 <link rel="import" href="../ct-failure-group.html"> |
13 <link rel="import" href="../ct-failure.html"> | 13 <link rel="import" href="../ct-failure.html"> |
14 | 14 |
15 <script> | 15 <script> |
16 (function () { | 16 (function () { |
| 17 'use strict'; |
17 | 18 |
18 var assert = chai.assert; | 19 var assert = chai.assert; |
19 | 20 |
20 describe('ct-failures', function() { | 21 describe('ct-failures', function() { |
21 describe('failureComparator', function() { | 22 describe('failureComparator', function() { |
22 it('should sort failures', function() { | 23 it('should sort failures', function() { |
23 var analyzer = new CTFailures(new CTCommitList(undefined, [])); | 24 var analyzer = new CTFailures(new CTCommitList(undefined, [])); |
24 | 25 |
25 var resultsByBuilder = {}; | 26 var resultsByBuilder = {}; |
26 var failure1 = new CTFailure("step1", "reason1", resultsByBuilder, 123, 12
3); | 27 var failure1 = new CTFailure("step1", "reason1", resultsByBuilder, 123, 12
3); |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
60 assert(analyzer._failureByTreeListComparator('blink', group1, group2) < 0)
; | 61 assert(analyzer._failureByTreeListComparator('blink', group1, group2) < 0)
; |
61 | 62 |
62 // Default to 'chromium'. | 63 // Default to 'chromium'. |
63 assert(analyzer._failureByTreeListComparator(undefined, group1, group2) >
0); | 64 assert(analyzer._failureByTreeListComparator(undefined, group1, group2) >
0); |
64 | 65 |
65 // Failures without a revision go to the end. | 66 // Failures without a revision go to the end. |
66 assert(analyzer._failureByTreeListComparator('chromium', group4, group1) >
0); | 67 assert(analyzer._failureByTreeListComparator('chromium', group4, group1) >
0); |
67 }); | 68 }); |
68 }); | 69 }); |
69 | 70 |
| 71 describe('._mungeAlerts', function() { |
| 72 it('puts alerts into a standard format', function() { |
| 73 var analyzer = new CTFailures(new CTCommitList(undefined, [])); |
| 74 var alerts = [ |
| 75 { |
| 76 reason: 'reason', |
| 77 master_url: 'https://build.chromium.org/p/chromium.webkit', |
| 78 }, |
| 79 { |
| 80 reason: 'reason:type', |
| 81 master_url: 'https://build.chromium.org/p/chromium.chrome', |
| 82 }, |
| 83 { |
| 84 master_url: 'https://build.chromium.org/p/chromium.gpu', |
| 85 }, |
| 86 { |
| 87 reason: 'reason:type', |
| 88 failureType: 'actual_type', |
| 89 }, |
| 90 ]; |
| 91 analyzer._mungeAlerts(alerts); |
| 92 assert.lengthOf(alerts, 4); |
| 93 assert.deepEqual(alerts[0], { |
| 94 reason: 'reason', |
| 95 failureType: 'FAIL', |
| 96 master_url: 'https://build.chromium.org/p/chromium.webkit', |
| 97 tree: 'blink', |
| 98 }); |
| 99 assert.deepEqual(alerts[1], { |
| 100 reason: 'reason', |
| 101 failureType: 'type', |
| 102 master_url: 'https://build.chromium.org/p/chromium.chrome', |
| 103 tree: 'chromium', |
| 104 }); |
| 105 assert.deepEqual(alerts[2], { |
| 106 failureType: 'UNKNOWN', |
| 107 master_url: 'https://build.chromium.org/p/chromium.gpu', |
| 108 tree: 'chromium', |
| 109 }); |
| 110 assert.deepEqual(alerts[3], { |
| 111 reason: 'reason:type', |
| 112 failureType: 'actual_type', |
| 113 tree: undefined, |
| 114 }); |
| 115 }); |
| 116 }); |
| 117 |
| 118 describe('.groupFailuresByTreeAndReason', function() { |
| 119 it('groups failures', function() { |
| 120 var analyzer = new CTFailures(new CTCommitList(undefined, [])); |
| 121 var linuxAnnotation = [1]; |
| 122 var winAnnotation = [2]; |
| 123 var blinkAnnotation = [3]; |
| 124 var annotations = { |
| 125 'https_//build.chromium.org/p/chromium::Linux::1::unit_tests::MyTest': l
inuxAnnotation, |
| 126 'https_//build.chromium.org/p/chromium::Win::3::unit_tests::MyTest': win
Annotation, |
| 127 'https_//build.chromium.org/p/chromium.webkit::Linux::1::LayoutTests::My
Test': blinkAnnotation, |
| 128 }; |
| 129 var failuresByTree = analyzer._groupFailuresByTreeAndReason([{ |
| 130 tree: 'chromium', |
| 131 step_name: 'unit_tests', |
| 132 reason: 'MyTest', |
| 133 builder_name: 'Linux', |
| 134 failureType: 'a_type', |
| 135 failing_build: 1, |
| 136 last_failing_build: 2, |
| 137 failing_build_count: 2, |
| 138 master_url: 'https://build.chromium.org/p/chromium', |
| 139 }, { |
| 140 tree: 'chromium', |
| 141 step_name: 'unit_tests', |
| 142 reason: 'MyTest', |
| 143 builder_name: 'Win', |
| 144 failureType: 'another_type', |
| 145 failing_build: 3, |
| 146 last_failing_build: 5, |
| 147 failing_build_count: 42, |
| 148 master_url: 'https://build.chromium.org/p/chromium', |
| 149 }, { |
| 150 tree: 'blink', |
| 151 step_name: 'LayoutTests', |
| 152 reason: 'MyTest', |
| 153 builder_name: 'Linux', |
| 154 failureType: 'a_type', |
| 155 failing_build: 1, |
| 156 last_failing_build: 2, |
| 157 failing_build_count: 2, |
| 158 master_url: 'https://build.chromium.org/p/chromium.webkit', |
| 159 }], annotations); |
| 160 assert.equal(Object.size(failuresByTree), 2); |
| 161 assert.equal(Object.size(failuresByTree.chromium), 1); |
| 162 assert.property(failuresByTree.chromium, '{"step":"unit_tests","reason":"M
yTest"}'); |
| 163 var chromiumBuilders = failuresByTree.chromium['{"step":"unit_tests","reas
on":"MyTest"}']; |
| 164 assert.equal(Object.size(chromiumBuilders), 2); |
| 165 assert.equal(Object.size(chromiumBuilders.Linux), 7); |
| 166 assert.propertyVal(chromiumBuilders.Linux, 'key', 'https_//build.chromium.
org/p/chromium::Linux::1::unit_tests::MyTest'); |
| 167 assert.propertyVal(chromiumBuilders.Linux, 'actual', 'a_type'); |
| 168 assert.propertyVal(chromiumBuilders.Linux, 'lastFailingBuild', 2); |
| 169 assert.propertyVal(chromiumBuilders.Linux, 'earliestFailingBuild', 1); |
| 170 assert.propertyVal(chromiumBuilders.Linux, 'masterUrl', 'https://build.chr
omium.org/p/chromium'); |
| 171 assert.propertyVal(chromiumBuilders.Linux, 'failingBuildCount', 2); |
| 172 assert.propertyVal(chromiumBuilders.Linux, 'annotation', linuxAnnotation); |
| 173 |
| 174 assert.equal(Object.size(chromiumBuilders.Win), 7); |
| 175 assert.propertyVal(chromiumBuilders.Win, 'key', 'https_//build.chromium.or
g/p/chromium::Win::3::unit_tests::MyTest'); |
| 176 assert.propertyVal(chromiumBuilders.Win, 'actual', 'another_type'); |
| 177 assert.propertyVal(chromiumBuilders.Win, 'lastFailingBuild', 5); |
| 178 assert.propertyVal(chromiumBuilders.Win, 'earliestFailingBuild', 3); |
| 179 assert.propertyVal(chromiumBuilders.Win, 'masterUrl', 'https://build.chrom
ium.org/p/chromium'); |
| 180 assert.propertyVal(chromiumBuilders.Win, 'failingBuildCount', 42); |
| 181 assert.propertyVal(chromiumBuilders.Win, 'annotation', winAnnotation); |
| 182 |
| 183 assert.equal(Object.size(failuresByTree.blink), 1); |
| 184 assert.property(failuresByTree.blink, '{"step":"LayoutTests","reason":"MyT
est"}'); |
| 185 var blinkBuilders = failuresByTree.blink['{"step":"LayoutTests","reason":"
MyTest"}']; |
| 186 assert.equal(Object.size(blinkBuilders), 1); |
| 187 assert.equal(Object.size(blinkBuilders.Linux), 7); |
| 188 assert.propertyVal(blinkBuilders.Linux, 'key', 'https_//build.chromium.org
/p/chromium.webkit::Linux::1::LayoutTests::MyTest'); |
| 189 assert.propertyVal(blinkBuilders.Linux, 'actual', 'a_type'); |
| 190 assert.propertyVal(blinkBuilders.Linux, 'lastFailingBuild', 2); |
| 191 assert.propertyVal(blinkBuilders.Linux, 'earliestFailingBuild', 1); |
| 192 assert.propertyVal(blinkBuilders.Linux, 'masterUrl', 'https://build.chromi
um.org/p/chromium.webkit'); |
| 193 assert.propertyVal(blinkBuilders.Linux, 'failingBuildCount', 2); |
| 194 assert.propertyVal(blinkBuilders.Linux, 'annotation', blinkAnnotation); |
| 195 }); |
| 196 }); |
| 197 |
70 describe('.update', function() { | 198 describe('.update', function() { |
71 it('should update everything', function(done) { | 199 it('should update everything', function(done) { |
72 var simulator = new NetworkSimulator(assert, done); | 200 var simulator = new NetworkSimulator(assert, done); |
73 var netData = { | 201 var netData = { |
74 alerts: { | 202 alerts: { |
75 latest_builder_info: { | 203 latest_builder_info: { |
76 'chromium.webkit': { | 204 'chromium.webkit': { |
77 'Linux Tests': { | 205 'Linux Tests': { |
78 state: "building", | 206 state: "building", |
79 lastUpdateTime: 1409697816.726562, | 207 lastUpdateTime: 1409697816.726562, |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
196 assert.propertyVal(repositoryCommitList, 'range', '100 : 101'); | 324 assert.propertyVal(repositoryCommitList, 'range', '100 : 101'); |
197 assert.propertyVal(repositoryCommitList, 'expanded', false); | 325 assert.propertyVal(repositoryCommitList, 'expanded', false); |
198 | 326 |
199 // Flip |expanded| to true to check that it's preserved across updates
. | 327 // Flip |expanded| to true to check that it's preserved across updates
. |
200 repositoryCommitList.expanded = true; | 328 repositoryCommitList.expanded = true; |
201 | 329 |
202 // Update |netData| to make sure it's propagated into the updated valu
es. | 330 // Update |netData| to make sure it's propagated into the updated valu
es. |
203 netData.alerts.alerts[0].last_failing_build = 2490; | 331 netData.alerts.alerts[0].last_failing_build = 2490; |
204 | 332 |
205 return analyzer.update().then(function() { | 333 return analyzer.update().then(function() { |
206 console.log(analyzer.failures.chromium[0].data.failures[0].resultNod
esByBuilder["Linux Tests (dbg)(1)"].lastFailingBuild); | |
207 console.log(group.data.failures[0].resultNodesByBuilder["Linux Tests
(dbg)(1)"].lastFailingBuild); | |
208 assert.strictEqual(analyzer.failures.chromium[0], group) | 334 assert.strictEqual(analyzer.failures.chromium[0], group) |
209 assert.strictEqual(group.data.failures[0], failure) | 335 assert.strictEqual(group.data.failures[0], failure) |
210 assert.strictEqual(failure.resultNodesByBuilder, resultNodesByBuilde
r); | 336 assert.strictEqual(failure.resultNodesByBuilder, resultNodesByBuilde
r); |
211 assert.strictEqual(resultNodesByBuilder['Linux Tests (dbg)(1)'], dbg
Builder); | 337 assert.strictEqual(resultNodesByBuilder['Linux Tests (dbg)(1)'], dbg
Builder); |
212 assert.propertyVal(dbgBuilder, 'lastFailingBuild', 2490); | 338 assert.propertyVal(dbgBuilder, 'lastFailingBuild', 2490); |
213 | 339 |
214 assert.strictEqual(group.data.commitList, commitList); | 340 assert.strictEqual(group.data.commitList, commitList); |
215 assert.strictEqual(commitList.repositories[0], repositoryCommitList)
; | 341 assert.strictEqual(commitList.repositories[0], repositoryCommitList)
; |
216 assert.propertyVal(repositoryCommitList, 'expanded', true); | 342 assert.propertyVal(repositoryCommitList, 'expanded', true); |
217 }); | 343 }); |
(...skipping 14 matching lines...) Expand all Loading... |
232 assert(failure.data.data.should_appear); | 358 assert(failure.data.data.should_appear); |
233 }); | 359 }); |
234 assert(analyzer.failures['trooper'].length == 2); | 360 assert(analyzer.failures['trooper'].length == 2); |
235 }); | 361 }); |
236 }); | 362 }); |
237 | 363 |
238 }); | 364 }); |
239 | 365 |
240 })() | 366 })() |
241 </script> | 367 </script> |
OLD | NEW |