1 // Copyright (C) 2012 Google Inc. All rights reserved.
3 // Redistribution and use in source and binary forms, with or without
4 // modification, are permitted provided that the following conditions are
7 // * Redistributions of source code must retain the above copyright
8 // notice, this list of conditions and the following disclaimer.
9 // * Redistributions in binary form must reproduce the above
10 // copyright notice, this list of conditions and the following disclaimer
11 // in the documentation and/or other materials provided with the
13 // * Neither the name of Google Inc. nor the names of its
14 // contributors may be used to endorse or promote products derived from
15 // this software without specific prior written permission.
17 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
18 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
19 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
20 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
21 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
22 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
23 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
27 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 function LOAD_BUILDBOT_DATA(builderData)
31 builders.masters = {};
32 builders.urlNameToMasterName = {};
35 var testTypesThatDoNotUpload = {};
36 builders.noUploadTestTypes = builderData['no_upload_test_types']
37 builderData['masters'].forEach(function(master) {
38 builders.urlNameToMasterName[master.url_name] = master.name;
39 builders.masters[master.name] = new builders.BuilderMaster(master);
41 master.groups.forEach(function(group) { groups[group] = true; });
43 Object.keys(master.tests).forEach(function(testType) {
44 if (builders.testTypeUploadsToFlakinessDashboardServer(testType))
45 testTypes[testType] = true;
47 testTypesThatDoNotUpload[testType] = true;
50 builders.groups = Object.keys(groups);
51 builders.groups.sort();
52 builders.testTypes = Object.keys(testTypes);
53 builders.testTypes.sort();
54 // FIXME: Expose this in the flakiness dashboard UI and give a clear error message
55 // pointing to a bug about getting the test type in question uploading results.
56 builders.testTypesThatDoNotUpload = Object.keys(testTypesThatDoNotUpload);
57 builders.testTypesThatDoNotUpload.sort();
60 var builders = builders || {};
64 builders.testTypeUploadsToFlakinessDashboardServer = function(testType)
66 for (var i = 0; i < builders.noUploadTestTypes.length; i++) {
67 if (string.contains(testType, builders.noUploadTestTypes[i]))
73 var currentBuilderGroup = {};
74 var testTypesThatRunToTBlinkBots = ['layout-tests', 'webkit_unit_tests'];
76 builders.getBuilderGroup = function(groupName, testType)
78 if (!builders in currentBuilderGroup) {
79 currentBuilderGroup = builders.loadBuildersList(groupName, testType);
81 return currentBuilderGroup;
84 function isChromiumWebkitTipOfTreeTestRunner(builder)
86 return !isChromiumWebkitDepsTestRunner(builder);
89 function isChromiumWebkitDepsTestRunner(builder)
91 return builder.indexOf('(deps)') != -1;
94 builders._builderFilter = function(groupName, masterName, testType)
96 if (testTypesThatRunToTBlinkBots.indexOf(testType) == -1) {
97 if (masterName == 'ChromiumWebkit' && groupName != '@ToT Blink')
98 return function() { return false };
102 if (groupName == '@ToT Blink')
103 return isChromiumWebkitTipOfTreeTestRunner;
105 if (groupName == '@ToT Chromium')
106 return isChromiumWebkitDepsTestRunner;
111 // FIXME: When we change to show multiple groups at once, this will need to
112 // change to key off groupName and builderName.
113 builders.master = function(builderName)
115 return builders.builderToMaster[builderName];
118 builders.loadBuildersList = function(groupName, testType)
120 if (!groupName || !testType) {
121 console.warn("Group name and/or test type were empty.");
122 return new builders.BuilderGroup(false);
124 var builderGroup = new builders.BuilderGroup(groupName == '@ToT Blink');
125 builders.builderToMaster = {};
127 for (masterName in builders.masters) {
128 if (!builders.masters[masterName])
131 var master = builders.masters[masterName];
132 var hasTest = testType in master.tests;
133 var isInGroup = master.groups.indexOf(groupName) != -1;
135 if (hasTest && isInGroup) {
136 var builderList = master.tests[testType].builders;
137 var builderFilter = builders._builderFilter(groupName, masterName, testType);
139 builderList = builderList.filter(builderFilter);
140 builderGroup.append(builderList);
142 builderList.forEach(function (builderName) {
143 builders.builderToMaster[builderName] = master;
148 currentBuilderGroup = builderGroup;
149 return currentBuilderGroup;
152 builders.getAllGroupNames = function()
154 return builders.groups;
157 builders.BuilderMaster = function(master_data)
159 this.name = master_data.name;
160 this.basePath = 'http://build.chromium.org/p/' + master_data.url_name;
161 this.tests = master_data.tests;
162 this.groups = master_data.groups;
165 builders.BuilderMaster.prototype = {
166 logPath: function(builder, buildNumber)
168 return this.builderPath(builder) + '/builds/' + buildNumber;
170 builderPath: function(builder)
172 return this.basePath + '/builders/' + builder;
174 builderJsonPath: function()
176 return this.basePath + '/json/builders';
180 builders.BuilderGroup = function(isToTBlink)
182 this.isToTBlink = isToTBlink;
183 // Map of builderName (the name shown in the waterfall) to builderPath (the
184 // path used in the builder's URL)
188 builders.BuilderGroup.prototype = {
189 append: function(builders) {
190 builders.forEach(function(builderName) {
191 this.builders[builderName] = builderName.replace(/[ .()]/g, '_');
194 defaultBuilder: function()
196 for (var builder in this.builders)
198 console.error('There are no builders in this builder group.');
202 return builders.master(this.defaultBuilder());
206 builders.groupNamesForTestType = function(testType)
209 for (masterName in builders.masters) {
210 var master = builders.masters[masterName];
211 if (testType in master.tests) {
212 groupNames = groupNames.concat(master.groups);
216 if (groupNames.length == 0) {
217 console.error("The current test type wasn't present in any groups:", testType);
221 var groupNames = groupNames.reduce(function(prev, curr) {
222 if (prev.indexOf(curr) == -1) {