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

Side by Side Diff: Tools/GardeningServer/model/test/ct-sheriff-failure-group-tests.html

Issue 728023004: Remove GardeningServer. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 1 month 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 | Annotate | Revision Log
OLDNEW
(Empty)
1 <!--
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
4 found in the LICENSE file.
5 -->
6
7 <link rel="import" href="../ct-failure-group.html">
8
9 <script>
10 (function () {
11
12 var assert = chai.assert;
13
14 describe('ct-sheriff-failure-group', function() {
15
16 beforeEach(function() {
17 localStorage.removeItem('CTFailureGroupAnnotations');
18 });
19
20 var key = 0;
21 function newFailureWithAnnotation(annotation, isTreeCloser) {
22 return new CTStepFailure('step', 'reason', [
23 {key: String(key++), annotation: annotation, isTreeCloser: isTreeCloser}
24 ]);
25 }
26
27 describe('category', function() {
28 it('should be "default" by default', function() {
29 var group = new CTFailureGroup('', new CTStepFailureGroupData([]));
30 assert.equal(group.category, 'default');
31 });
32
33 it('should be "snoozed" when snoozed', function() {
34 var group = new CTFailureGroup('', new CTStepFailureGroupData(
35 [newFailureWithAnnotation({snoozeTime: Date.now() + 1000 * 1000})]));
36 assert.equal(group.category, 'snoozed');
37 });
38
39 it('should be "failedOnce" when there is only one failure', function() {
40 var failure = newFailureWithAnnotation();
41 failure.resultNodesByBuilder = {some_key: {failingBuildCount: 1}}
42 var group = new CTFailureGroup('', new CTStepFailureGroupData(
43 [failure]));
44 assert.equal(group.category, 'failedOnce');
45 });
46
47 it('should be "failedOnce" when each failure only failed once', function() {
48 var failure = newFailureWithAnnotation();
49 failure.resultNodesByBuilder = {some_key: {failingBuildCount: 1}}
50 var failure2 = newFailureWithAnnotation();
51 failure2.resultNodesByBuilder = {some_key: {failingBuildCount: 1}}
52 var group = new CTFailureGroup('', new CTStepFailureGroupData(
53 [failure, failure2]));
54 assert.equal(group.category, 'failedOnce');
55 });
56
57 it('should not be "failedOnce" when there is more than one failure', functio n() {
58 var failure = newFailureWithAnnotation();
59 failure.resultNodesByBuilder = {some_key: {failingBuildCount: 1},
60 other_key: {failingBuildCount: 1}}
61 var group = new CTFailureGroup('', new CTStepFailureGroupData(
62 [failure]));
63 assert.equal(group.category, 'default');
64 });
65
66 it('treeCloser should win over failedOnce', function() {
67 var failure = newFailureWithAnnotation();
68 failure.resultNodesByBuilder = {some_key: {failingBuildCount: 1, isTreeClo ser: true}}
69 var group = new CTFailureGroup('', new CTStepFailureGroupData(
70 [failure]));
71 assert.equal(group.category, 'treeCloser');
72 });
73
74 it('snoozed should win over treeCloser', function() {
75 var failure = newFailureWithAnnotation({snoozeTime: Date.now() + 1000 * 10 00}, true);
76 var group = new CTFailureGroup('', new CTStepFailureGroupData(
77 [failure]));
78 assert.equal(group.category, 'snoozed');
79 });
80 });
81
82 describe('snooze', function() {
83 it('should set isSnoozed', function(done) {
84 var group = new CTFailureGroup('', new CTStepFailureGroupData([newFailureW ithAnnotation()]));
85 group.snoozeUntil(Date.now() + 1000 * 1000).then(function() {
86 assert.isTrue(group.isSnoozed);
87 done();
88 });
89 });
90 });
91
92 describe('unsnooze', function() {
93 it('should clear isSnoozed', function(done) {
94 var group = new CTFailureGroup('', new CTStepFailureGroupData([newFailureW ithAnnotation()]));
95 group.snoozeUntil(Date.now() + 1000 * 1000).then(function() {
96 group.unsnooze().then(function() {
97 assert.isFalse(group.isSnoozed);
98 done();
99 });
100 });
101 });
102 });
103
104 describe('setBug', function() {
105 it('should store the bug', function(done) {
106 var group = new CTFailureGroup('', new CTStepFailureGroupData([newFailureW ithAnnotation()]));
107 group.setBug('123').then(function() {
108 assert.equal(group.bug, 'https://crbug.com/123');
109 assert.equal(group._annotation.bug, 'https://crbug.com/123');
110 assert.equal(group.bugLabel, 'Bug 123');
111 done();
112 });
113 });
114
115 it('should support URLs', function(done) {
116 var group = new CTFailureGroup('', new CTStepFailureGroupData([newFailureW ithAnnotation()]));
117 group.setBug('https://foobar.com/?id=876&x=y').then(function() {
118 assert.equal(group.bug, 'https://foobar.com/?id=876&x=y');
119 assert.equal(group._annotation.bug, 'https://foobar.com/?id=876&x=y');
120 assert.equal(group.bugLabel, 'Bug 876');
121 done();
122 });
123 });
124 });
125
126 describe('clearBug', function() {
127 it('should work', function(done) {
128 var group = new CTFailureGroup('', new CTStepFailureGroupData([]));
129 group.setBug('123').then(function() {
130 group.clearBug().then(function() {
131 assert.isUndefined(group.bug);
132 assert.isUndefined(group.bugLabel);
133 assert.notProperty(group._annotation, 'bug');
134 done();
135 });
136 });
137 });
138 });
139
140 describe('annotations', function() {
141 it('should have sensible defaults', function() {
142 var group = new CTFailureGroup('', new CTStepFailureGroupData([]));
143 assert.deepEqual(group._annotation, {});
144 assert.isFalse(group.isSnoozed);
145 assert.isUndefined(group.bug);
146 assert.isUndefined(group.bugLabel);
147 });
148
149 it('should compute properties', function() {
150 var group = new CTFailureGroup('', new CTStepFailureGroupData([newFailureW ithAnnotation(
151 {snoozeTime: Date.now() + 1000 * 1000, bug: 'https://crbug.com/123'})] ));
152 assert.isTrue(group.isSnoozed);
153 assert.equal(group.bug, 'https://crbug.com/123');
154 });
155
156 it('should ignore snoozeTime unless it is present on all alerts', function() {
157 var notSnoozedMultipleAlerts = new CTFailureGroup('', new CTStepFailureGro upData([
158 new CTStepFailure('step', 'reason', [
159 {key: 'a', annotation: {snoozeTime: Date.now() + 1000 * 1000}},
160 {key: 'b',},
161 ])
162 ]));
163 var notSnoozedMultipleFailures = new CTFailureGroup('', new CTStepFailureG roupData([
164 new CTStepFailure('step', 'reason', [
165 {key: 'a', annotation: {snoozeTime: Date.now() + 1000 * 1000}},
166 ]),
167 new CTStepFailure('step', 'reason', [
168 {key: 'b'},
169 ]),
170 ]));
171 var snoozedMultipleAlerts = new CTFailureGroup('', new CTStepFailureGroupD ata([
172 new CTStepFailure('step', 'reason', [
173 {key: 'a', annotation: {snoozeTime: Date.now() + 1000 * 1000}},
174 {key: 'b', annotation: {snoozeTime: Date.now() + 1000 * 1000}},
175 ])
176 ]));
177 var snoozedMultipleFailures = new CTFailureGroup('', new CTStepFailureGrou pData([
178 new CTStepFailure('step', 'reason', [
179 {key: 'a', annotation: {snoozeTime: Date.now() + 1000 * 1000}},
180 ]),
181 new CTStepFailure('step', 'reason', [
182 {key: 'b', annotation: {snoozeTime: Date.now() + 1000 * 1000}},
183 ]),
184 ]));
185 assert.isFalse(notSnoozedMultipleAlerts.isSnoozed);
186 assert.isFalse(notSnoozedMultipleFailures.isSnoozed);
187 assert.isTrue(snoozedMultipleAlerts.isSnoozed);
188 assert.isTrue(snoozedMultipleFailures.isSnoozed);
189 });
190
191 it('should use the earliest snoozeTime of all alerts', function() {
192 var timeFuture = Date.now() + 1000 * 1000;
193 var timePast = Date.now() - 1000 * 1000;
194
195 var notSnoozed = new CTFailureGroup('', new CTStepFailureGroupData([
196 new CTStepFailure('step', 'reason', [
197 {key: 'a', annotation: {snoozeTime: timeFuture}},
198 {key: 'b', annotation: {snoozeTime: timePast}},
199 ])
200 ]));
201
202 assert.isFalse(notSnoozed.isSnoozed);
203 });
204
205 it('should be persisted', function(done) {
206 var group = new CTFailureGroup('', new CTStepFailureGroupData(
207 [newFailureWithAnnotation(), newFailureWithAnnotation()]));
208 group.snoozeUntil(123).then(function() {
209 group.setBug('456').then(function() {
210 CTFailureGroup.fetchAnnotations().then(function(annotations) {
211 assert.deepEqual(annotations[group.data.failures[0].keys()[0]], {sno ozeTime: 123, bug: 'https://crbug.com/456'});
212 assert.deepEqual(annotations[group.data.failures[1].keys()[0]], {sno ozeTime: 123, bug: 'https://crbug.com/456'});
213 done();
214 });
215 });
216 });
217 });
218 });
219 });
220
221 })()
222 </script>
OLDNEW
« no previous file with comments | « Tools/GardeningServer/model/test/ct-failures-tests.html ('k') | Tools/GardeningServer/model/test/ct-step-failure-tests.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698