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

Side by Side Diff: Tools/GardeningServer/model/test/ct-failures-tests.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: Simplify and document updateLeft() using the fact that it returns the resulting object. 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="../ct-failures.html"> 7 <link rel="import" href="../ct-failures.html">
8 8
9 <link rel="import" href="../../lib/network-simulator.html">
10 <link rel="import" href="../ct-commit-list.html">
11 <link rel="import" href="../ct-commit-log-mock.html">
12 <link rel="import" href="../ct-failure-group.html">
13 <link rel="import" href="../ct-failure.html">
14
9 <script> 15 <script>
10 (function () { 16 (function () {
11 17
12 var assert = chai.assert; 18 var assert = chai.assert;
13 19
14 describe('ct-failures', function() { 20 describe('ct-failures', function() {
15 describe('failureComparator', function() { 21 describe('failureComparator', function() {
16 it('should sort failures', function() { 22 it('should sort failures', function() {
17 var analyzer = new CTFailures(new CTCommitList(undefined, [])); 23 var analyzer = new CTFailures(new CTCommitList(undefined, []));
18 24
(...skipping 10 matching lines...) Expand all
29 }); 35 });
30 36
31 describe('failureByTreeListComparator', function() { 37 describe('failureByTreeListComparator', function() {
32 it('should compare failures correctly', function() { 38 it('should compare failures correctly', function() {
33 var analyzer = new CTFailures(new CTCommitList(undefined, [])); 39 var analyzer = new CTFailures(new CTCommitList(undefined, []));
34 40
35 var cl1 = new CTCommitList(undefined, ['chromium:1', 'blink:2']); 41 var cl1 = new CTCommitList(undefined, ['chromium:1', 'blink:2']);
36 var cl2 = new CTCommitList(undefined, ['chromium:2', 'blink:1']); 42 var cl2 = new CTCommitList(undefined, ['chromium:2', 'blink:1']);
37 var cl3 = new CTCommitList(undefined, ['chromium:2', 'blink:2']); 43 var cl3 = new CTCommitList(undefined, ['chromium:2', 'blink:2']);
38 var cl4 = new CTCommitList(undefined, []); 44 var cl4 = new CTCommitList(undefined, []);
39 var group1 = new CTFailureGroup([], cl1); 45 var group1 = new CTFailureGroup('', [], cl1);
40 var group2 = new CTFailureGroup([], cl2); 46 var group2 = new CTFailureGroup('', [], cl2);
41 var group3 = new CTFailureGroup([], cl3); 47 var group3 = new CTFailureGroup('', [], cl3);
42 var group4 = new CTFailureGroup([], cl4); 48 var group4 = new CTFailureGroup('', [], cl4);
43 49
44 // Sort by last revision first. 50 // Sort by last revision first.
45 assert(analyzer._failureByTreeListComparator('chromium', group1, group2) > 0); 51 assert(analyzer._failureByTreeListComparator('chromium', group1, group2) > 0);
46 assert(analyzer._failureByTreeListComparator('chromium', group2, group1) < 0); 52 assert(analyzer._failureByTreeListComparator('chromium', group2, group1) < 0);
47 assert(analyzer._failureByTreeListComparator('chromium', group1, group1) = = 0); 53 assert(analyzer._failureByTreeListComparator('chromium', group1, group1) = = 0);
48 54
49 // If the tree revisions are equal, take others. 55 // If the tree revisions are equal, take others.
50 assert(analyzer._failureByTreeListComparator('chromium', group2, group3) > 0); 56 assert(analyzer._failureByTreeListComparator('chromium', group2, group3) > 0);
51 57
52 // Prioritize the given tree. 58 // Prioritize the given tree.
53 assert(analyzer._failureByTreeListComparator('chromium', group1, group2) > 0); 59 assert(analyzer._failureByTreeListComparator('chromium', group1, group2) > 0);
54 assert(analyzer._failureByTreeListComparator('blink', group1, group2) < 0) ; 60 assert(analyzer._failureByTreeListComparator('blink', group1, group2) < 0) ;
55 61
56 // Default to 'chromium'. 62 // Default to 'chromium'.
57 assert(analyzer._failureByTreeListComparator(undefined, group1, group2) > 0); 63 assert(analyzer._failureByTreeListComparator(undefined, group1, group2) > 0);
58 64
59 // Failures without a revision go to the end. 65 // Failures without a revision go to the end.
60 assert(analyzer._failureByTreeListComparator('chromium', group4, group1) > 0); 66 assert(analyzer._failureByTreeListComparator('chromium', group4, group1) > 0);
61 }); 67 });
62 }); 68 });
69
70 describe('.update', function() {
71 it('should update everything', function(done) {
72 var simulator = new NetworkSimulator(assert, done);
73 var netData = {
74 alerts: {
75 latest_builder_info: {
76 'chromium.webkit': {
77 'Linux Tests': {
78 state: "building",
79 lastUpdateTime: 1409697816.726562,
80 revisions: {
81 v8: 50,
82 chromium: 293001,
83 nacl: 50,
84 blink: 181262
85 },
86 },
87 },
88 'chromium.linux': {
89 "Linux Tests (dbg)(1)": {
90 state: "building",
91 lastUpdateTime: 1409696812.7248161,
92 revisions: {
93 v8: 50,
94 chromium: 292984,
95 nacl: 50,
96 blink: 181241
97 }
98 },
99 }
100 },
101 range_groups: [
102 {
103 sort_key: 'linux: Linux Tests (dbg)(1)',
104 failure_keys: [ 'f1', ],
105 likely_revisions: [
106 'chromium: 100',
107 'chromium: 101',
108 ],
109 merged_first_failing: {
110 blink: 50,
111 nacl: 50,
112 v8: 50,
113 chromium: 101,
114 },
115 merged_last_passing: {
116 blink: 50,
117 nacl: 50,
118 v8: 50,
119 chromium: 99,
120 },
121 },
122 ],
123 alerts: [
124 {
125 last_result_time: 1409697347.089103,
126 failing_build_count: 4,
127 passing_build: 2485,
128 last_failing_build: 2489,
129 failing_build: 2486,
130 latest_revisions: {
131 v8: 50,
132 chromium: 103,
133 nacl: 50,
134 blink: 51
135 },
136 master_url: "https://build.chromium.org/p/chromium.linux",
137 reason: null,
138 failing_revisions: {
139 v8: 50,
140 chromium: 101,
141 nacl: 50,
142 blink: 50
143 },
144 builder_name: "Linux Tests (dbg)(1)",
145 key: "f1",
146 step_name: "compile",
147 tree_name: null,
148 passing_revisions: {
149 v8: 50,
150 chromium: 99,
151 nacl: 50,
152 blink: 50
153 },
154 would_close_tree: true
155 },
156 ],
157 }
158 }
159 simulator.json = function(url) {
160 var matched = Object.find(netData, function(key) {
161 return url.indexOf(key) != -1;
162 });
163 if (matched) {
164 return Promise.resolve(netData[matched]);
165 } else {
166 return Promise.reject('Unexpected url: ' + url);
167 }
168 };
169 simulator.runTest(function() {
170 var analyzer = new CTFailures(CTCommitLogMock());
171 return analyzer.update().then(function() {
172 assert.property(analyzer.failures, 'chromium');
173 assert.lengthOf(analyzer.failures.chromium, 1);
174 var group = analyzer.failures.chromium[0];
175 assert.equal(group.constructor, CTFailureGroup);
176 assert.equal(group.key, 'linux: Linux Tests (dbg)(1)');
177 assert.lengthOf(group.failures, 1);
178 var failure = group.failures[0];
179 assert.equal(failure.constructor, CTFailure);
180 assert.equal(failure.key, 'compile::null');
181 assert.equal(failure.step, 'compile');
182 assert.equal(failure.testName, null);
183 var resultNodesByBuilder = failure.resultNodesByBuilder;
184 assert.property(resultNodesByBuilder, 'Linux Tests (dbg)(1)');
185 var dbgBuilder = resultNodesByBuilder['Linux Tests (dbg)(1)'];
186 assert.propertyVal(dbgBuilder, 'actual', 'UNKNOWN');
187 assert.propertyVal(dbgBuilder, 'lastFailingBuild', 2489);
188 assert.propertyVal(dbgBuilder, 'earliestFailingBuild', 2486);
189 assert.propertyVal(dbgBuilder, 'masterUrl', 'https://build.chromium.or g/p/chromium.linux');
190 assert.propertyVal(dbgBuilder, 'failingBuildCount', 4);
191
192 var commitList = group.commitList;
193 assert.equal(commitList.constructor, CTCommitList);
194 assert.lengthOf(commitList.repositories, 1);
195 var repositoryCommitList = commitList.repositories[0];
196 assert.propertyVal(repositoryCommitList, 'range', '100 : 101');
197 assert.propertyVal(repositoryCommitList, 'expanded', false);
198
199 // Flip |expanded| to true to check that it's preserved across updates .
200 repositoryCommitList.expanded = true;
201
202 // Update |netData| to make sure it's propagated into the updated valu es.
203 netData.alerts.alerts[0].last_failing_build = 2490;
204
205 return analyzer.update().then(function() {
206 assert.strictEqual(analyzer.failures.chromium[0], group)
207 assert.strictEqual(group.failures[0], failure)
208 assert.strictEqual(failure.resultNodesByBuilder, resultNodesByBuilde r);
209 assert.strictEqual(resultNodesByBuilder['Linux Tests (dbg)(1)'], dbg Builder);
210 assert.propertyVal(dbgBuilder, 'lastFailingBuild', 2490);
211
212 assert.strictEqual(group.commitList, commitList);
213 assert.strictEqual(commitList.repositories[0], repositoryCommitList) ;
214 assert.propertyVal(repositoryCommitList, 'expanded', true);
215 });
216 });
217 });
218 });
219 });
220
63 }); 221 });
64 222
65 })() 223 })()
66 </script> 224 </script>
OLDNEW
« no previous file with comments | « Tools/GardeningServer/model/test/ct-failure-tests.html ('k') | Tools/GardeningServer/ui/ct-sheriff-o-matic.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698