6725f801fff39718011ea2afdb69c462b01defe2
[WebKit-https.git] / Tools / BuildSlaveSupport / build.webkit.org-config / public_html / dashboard / Scripts / BubbleQueueServer.js
1 /*
2  * Copyright (C) 2013, 2014 Apple 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 BubbleQueueServer = function()
27 {
28     const queueInfo = {
29         "commit-queue": {platform: Dashboard.Platform.macOSHighSierra, shortName: "commit", title: "Commit Queue"},
30         "style-queue": {shortName: "style", title: "Style Checker Queue"},
31         "gtk-wk2-ews": {platform: Dashboard.Platform.LinuxGTK, shortName: "gtk-wk2", title: "WebKit2\xa0Release\xa0Build\xa0EWS"},
32         "ios-ews": {platform: Dashboard.Platform.iOS12Device, shortName: "ios", title: "Release\xa0Build\xa0EWS"},
33         "ios-sim-ews": {platform: Dashboard.Platform.iOS12Simulator, shortName: "ios-sim", title: "WebKit2\xa0Release\xa0Tests\xa0EWS"},
34         "jsc-armv7-ews": {platform: Dashboard.Platform.LinuxJSCOnly, shortName: "jsc-armv7", title: "ARMv7\xa0Release\xa0Build\xa0EWS"},
35         "jsc-ews": {platform: Dashboard.Platform.macOSMojave, shortName: "jsc", title: "Release\xa0JSC\xa0Tests\xa0EWS"},
36         "jsc-mips-ews": {platform: Dashboard.Platform.LinuxJSCOnly, shortName: "jsc-mips-ews", title: "MIPS\xa0Release\xa0Build\xa0EWS"},
37         "mac-32bit-ews": {platform: Dashboard.Platform.macOSHighSierra, shortName: "mac-32bit", title: "Release\xa032\u2011bit\xa0Build\xa0EWS"},
38         "mac-ews": {platform: Dashboard.Platform.macOSHighSierra, shortName: "mac", title: "WebKit1\xa0Release\xa0Tests\xa0EWS"},
39         "mac-wk2-ews": {platform: Dashboard.Platform.macOSHighSierra, shortName: "mac-wk2", title: "WebKit2\xa0Release\xa0Tests\xa0EWS"},
40         "mac-debug-ews": {platform: Dashboard.Platform.macOSHighSierra, shortName: "mac-debug", title: "WebKit1\xa0Debug\xa0Tests\xa0EWS"},
41         "bindings-ews": {platform: Dashboard.Platform.macOSHighSierra, shortName: "bindings", title: "Bindings\xa0EWS"},
42         "webkitpy-ews": {platform: Dashboard.Platform.macOSHighSierra, shortName: "webkitpy", title: "Webkitpy\xa0EWS"},
43         "win-ews": {platform: Dashboard.Platform.Windows7, shortName: "win", title: "WebKit1\xa0Release\xa0Build\xa0EWS"},
44         "wincairo-ews": {platform: Dashboard.Platform.WinCairo, shortName: "wincairo", title: "WebKit1\xa0Release\xa0Build\xa0EWS"},
45         "wpe-ews": {platform: Dashboard.Platform.LinuxWPE, shortName: "wpe", title: "WebKit2\xa0Release\xa0Build\xa0EWS"},
46     };
47
48     BaseObject.call(this);
49
50     this.baseURL = "https://webkit-queues.webkit.org/";
51     this.queues = {};
52
53     for (var id in queueInfo)
54         this.queues[id] = new BubbleQueue(this, id, queueInfo[id]);
55 };
56
57 BaseObject.addConstructorFunctions(BubbleQueueServer);
58
59 BubbleQueueServer.prototype = {
60     constructor: BubbleQueueServer,
61     __proto__: BaseObject.prototype,
62
63     jsonQueueLengthURL: function(queueID)
64     {
65         return this.baseURL + "queue-length-json/" + encodeURIComponent(queueID);
66     },
67
68     jsonQueueStatusURL: function(queueID)
69     {
70         return this.baseURL + "queue-status-json/" + encodeURIComponent(queueID);
71     },
72
73     jsonProcessingTimesURL: function(fromTime, toTime)
74     {
75         return this.baseURL + "processing-times-json/" + [fromTime.getUTCFullYear(), fromTime.getUTCMonth() + 1, fromTime.getUTCDate(), fromTime.getUTCHours(), fromTime.getUTCMinutes(), fromTime.getUTCSeconds()].join("-")
76             + "-" + [toTime.getUTCFullYear(), toTime.getUTCMonth() + 1, toTime.getUTCDate(), toTime.getUTCHours(), toTime.getUTCMinutes(), toTime.getUTCSeconds()].join("-");
77     },
78
79     queueStatusURL: function(queueID)
80     {
81         return this.baseURL + "queue-status/" + encodeURIComponent(queueID);
82     },
83
84     // Retrieves information about all patches that were submitted in the time range:
85     // {
86     //     patch_id_1: {
87     //         queue_name_1: {
88     //             date: <date/time when the patch was submitted to the queue>,
89     //             retry_count: <number of times a bot had to bail out and drop the lock, for another bot to start from scratch>,
90     //             wait_duration: <how long it took before a bot first locked the patch for processing>,
91     //             process_duration: <how long it took from end of wait to finish, only valid for finished patches. Includes wait time between retries>
92     //             final_message: <(pass|fail|not processed|could not apply|internal error|in progress)>
93     //         },
94     //         ...
95     //     },
96     //     ...
97     // }
98     loadProcessingTimes: function(fromTime, toTime, callback)
99     {
100         JSON.load(this.jsonProcessingTimesURL(fromTime, toTime), function(data) {
101             for (patch in data) {
102                 for (queue in patch)
103                     queue.date = new Date(queue.date);
104             }
105             callback(data, fromTime, toTime);
106         }.bind(this));
107     },
108 };