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

Side by Side Diff: Tools/GardeningServer/scripts/model.js

Issue 402603007: Get sheriff-o-matic data from auto-sheriff.appspot.com. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: update and delete old code Created 6 years, 5 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 | Annotate | Revision Log
OLDNEW
(Empty)
1 /*
2 * Copyright (C) 2011 Google Inc. All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
6 * are met:
7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 *
13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
14 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
15 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
17 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
18 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
19 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
20 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
21 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
22 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
23 * THE POSSIBILITY OF SUCH DAMAGE.
24 */
25
26 var model = model || {};
27
28 (function () {
29
30 var kCommitLogLength = 50;
31
32 model.state = {};
33 model.state.failureAnalysisByTest = {};
34
35 function findAndMarkRevertedRevisions(commitDataList)
36 {
37 var revertedRevisions = {};
38 Object.keys(commitDataList, function(index, commitData) {
39 if (commitData.revertedRevision)
40 revertedRevisions[commitData.revertedRevision] = true;
41 });
42 Object.keys(commitDataList, function(index, commitData) {
43 if (commitData.revision in revertedRevisions)
44 commitData.wasReverted = true;
45 });
46 }
47
48 function fuzzyFind(testName, commitData)
49 {
50 var indexOfLastDot = testName.lastIndexOf('.');
51 var stem = indexOfLastDot == -1 ? testName : testName.substr(0, indexOfLastD ot);
52 return commitData.message.indexOf(stem) != -1;
53 }
54
55 function heuristicallyNarrowRegressionRange(failureAnalysis)
56 {
57 var commitDataList = model.state.recentCommits;
58 var commitDataIndex = commitDataList.length - 1;
59
60 for(var revision = failureAnalysis.newestPassingRevision + 1; revision <= fa ilureAnalysis.oldestFailingRevision; ++revision) {
61 while (commitDataIndex >= 0 && commitDataList[commitDataIndex].revision < revision)
62 --commitDataIndex;
63 var commitData = commitDataList[commitDataIndex];
64 if (commitData.revision != revision)
65 continue;
66 if (fuzzyFind(failureAnalysis.testName, commitData)) {
67 failureAnalysis.oldestFailingRevision = revision;
68 failureAnalysis.newestPassingRevision = revision - 1;
69 return;
70 }
71 }
72 }
73
74 var g_commitIndex = {};
75
76 model.updateRecentCommits = function()
77 {
78 return trac.recentCommitData('trunk', kCommitLogLength).then(function(commit DataList) {
79 model.state.recentCommits = commitDataList;
80 updateCommitIndex();
81 findAndMarkRevertedRevisions(model.state.recentCommits);
82 });
83 };
84
85 function updateCommitIndex()
86 {
87 model.state.recentCommits.forEach(function(commitData) {
88 g_commitIndex[commitData.revision] = commitData;
89 });
90 }
91
92 model.commitDataListForRevisionRange = function(fromRevision, toRevision)
93 {
94 var result = [];
95 for (var revision = fromRevision; revision <= toRevision; ++revision) {
96 var commitData = g_commitIndex[revision];
97 if (commitData)
98 result.push(commitData);
99 }
100 return result;
101 };
102
103 model.buildersInFlightForRevision = function(revision)
104 {
105 var builders = {};
106 Object.keys(model.state.resultsByBuilder).forEach(function(builderName) {
107 var results = model.state.resultsByBuilder[builderName];
108 if (parseInt(results.blink_revision) < revision)
109 builders[builderName] = { actual: 'BUILDING' };
110 });
111 return builders;
112 };
113
114 model.updateResultsByBuilder = function()
115 {
116 return results.fetchResultsByBuilder(Object.keys(config.builders)).then(func tion(resultsByBuilder) {
117 model.state.resultsByBuilder = resultsByBuilder;
118 });
119 };
120
121 // failureCallback is called multiple times: once for each failure
122 model.analyzeUnexpectedFailures = function(failureCallback)
123 {
124 var unexpectedFailures = results.unexpectedFailuresByTest(model.state.result sByBuilder);
125
126 Object.keys(model.state.failureAnalysisByTest, function(testName, failureAna lysis) {
127 if (!(testName in unexpectedFailures))
128 delete model.state.failureAnalysisByTest[testName];
129 });
130
131 var failurePromises = [];
132 Object.keys(unexpectedFailures, function(testName, resultNodesByBuilder) {
133 var builderNameList = Object.keys(resultNodesByBuilder);
134 failurePromises.push(results.unifyRegressionRanges(builderNameList, test Name).then(function(result) {
135 var oldestFailingRevision = result[0];
136 var newestPassingRevision = result[1];
137 var failureAnalysis = {
138 'testName': testName,
139 'resultNodesByBuilder': resultNodesByBuilder,
140 'oldestFailingRevision': oldestFailingRevision,
141 'newestPassingRevision': newestPassingRevision,
142 };
143
144 heuristicallyNarrowRegressionRange(failureAnalysis);
145
146 var previousFailureAnalysis = model.state.failureAnalysisByTest[test Name];
147 if (previousFailureAnalysis
148 && previousFailureAnalysis.oldestFailingRevision <= failureAnaly sis.oldestFailingRevision
149 && previousFailureAnalysis.newestPassingRevision >= failureAnaly sis.newestPassingRevision) {
150 failureAnalysis.oldestFailingRevision = previousFailureAnalysis. oldestFailingRevision;
151 failureAnalysis.newestPassingRevision = previousFailureAnalysis. newestPassingRevision;
152 }
153
154 model.state.failureAnalysisByTest[testName] = failureAnalysis;
155
156 failureCallback(failureAnalysis, failurePromises.length);
157 }));
158 });
159 return Promise.all(failurePromises);
160 };
161
162 })();
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698