Title: [228098] trunk/Websites/perf.webkit.org
Revision
228098
Author
aakash_j...@apple.com
Date
2018-02-05 08:53:22 -0800 (Mon, 05 Feb 2018)

Log Message

Add support for fetching recent builds in Buildbot 0.9 format in BuildbotSyncer
https://bugs.webkit.org/show_bug.cgi?id=179743

Reviewed by Ryosuke Niwa.

* tools/js/buildbot-syncer.js:
(BuildbotSyncer.prototype._pullRecentBuildsDeprecated): Renamed from _pullRecentBuilds. This method fetch
from Buildbot 0.8 server.
(BuildbotSyncer.prototype._pullRecentBuilds): Method to fetch recent builds from Buildbot 0.9 server.
(BuildbotSyncer.prototype.pathForRecentBuilds): URL for fetching recent builds from Buildbot 0.9 server.
(BuildbotSyncer.prototype.pathForBuildJSONDeprecated): Renamed from pathForBuildJSON.
* unit-tests/buildbot-syncer-tests.js:
(_pullRecentBuilds.it): unit-test - should not fetch recent builds when count is zero.
(_pullRecentBuilds.it): unit-test - should pull the right number of recent builds.
(_pullRecentBuilds.it): unit-test - should handle unexpected error while fetching recent builds.
(_pullRecentBuilds.it): unit-test - should create BuildbotBuildEntry after fetching recent builds.

Modified Paths

Diff

Modified: trunk/Websites/perf.webkit.org/ChangeLog (228097 => 228098)


--- trunk/Websites/perf.webkit.org/ChangeLog	2018-02-05 16:33:33 UTC (rev 228097)
+++ trunk/Websites/perf.webkit.org/ChangeLog	2018-02-05 16:53:22 UTC (rev 228098)
@@ -1,3 +1,22 @@
+2018-02-02  Aakash Jain  <aakash_j...@apple.com>
+
+        Add support for fetching recent builds in Buildbot 0.9 format in BuildbotSyncer
+        https://bugs.webkit.org/show_bug.cgi?id=179743
+
+        Reviewed by Ryosuke Niwa.
+
+        * tools/js/buildbot-syncer.js:
+        (BuildbotSyncer.prototype._pullRecentBuildsDeprecated): Renamed from _pullRecentBuilds. This method fetch
+        from Buildbot 0.8 server.
+        (BuildbotSyncer.prototype._pullRecentBuilds): Method to fetch recent builds from Buildbot 0.9 server.
+        (BuildbotSyncer.prototype.pathForRecentBuilds): URL for fetching recent builds from Buildbot 0.9 server.
+        (BuildbotSyncer.prototype.pathForBuildJSONDeprecated): Renamed from pathForBuildJSON.
+        * unit-tests/buildbot-syncer-tests.js:
+        (_pullRecentBuilds.it): unit-test - should not fetch recent builds when count is zero.
+        (_pullRecentBuilds.it): unit-test - should pull the right number of recent builds.
+        (_pullRecentBuilds.it): unit-test - should handle unexpected error while fetching recent builds.
+        (_pullRecentBuilds.it): unit-test - should create BuildbotBuildEntry after fetching recent builds.
+
 2018-02-01  Aakash Jain  <aakash_j...@apple.com>
 
         Create BuildbotBuildEntry in Buildbot syncer in Buildbot 0.9 format

Modified: trunk/Websites/perf.webkit.org/tools/js/buildbot-syncer.js (228097 => 228098)


--- trunk/Websites/perf.webkit.org/tools/js/buildbot-syncer.js	2018-02-05 16:33:33 UTC (rev 228097)
+++ trunk/Websites/perf.webkit.org/tools/js/buildbot-syncer.js	2018-02-05 16:53:22 UTC (rev 228098)
@@ -198,7 +198,7 @@
     {
         return this._remote.getJSON(this.pathForPendingBuildsJSONDeprecated()).then((content) => {
             let pendingEntries = content.map((entry) => new BuildbotBuildEntryDeprecated(this, entry));
-            return this._pullRecentBuilds(count).then((entries) => {
+            return this._pullRecentBuildsDeprecated(count).then((entries) => {
                 let entryByRequest = {};
 
                 for (let entry of pendingEntries)
@@ -219,7 +219,7 @@
         });
     }
 
-    _pullRecentBuilds(count)
+    _pullRecentBuildsDeprecated(count)
     {
         if (!count)
             return Promise.resolve([]);
@@ -228,7 +228,7 @@
         for (let i = 0; i < count; i++)
             selectedBuilds[i] = -i - 1;
 
-        return this._remote.getJSON(this.pathForBuildJSON(selectedBuilds)).then((content) => {
+        return this._remote.getJSON(this.pathForBuildJSONDeprecated(selectedBuilds)).then((content) => {
             const entries = [];
             for (let index of selectedBuilds) {
                 const entry = content[index];
@@ -239,12 +239,25 @@
         });
     }
 
+    _pullRecentBuilds(count)
+    {
+        if (!count)
+            return Promise.resolve([]);
+
+        return this._remote.getJSON(this.pathForRecentBuilds(count)).then((content) => {
+            if (!('builds' in content))
+                return [];
+            return content.builds.map((build) => new BuildbotBuildEntry(this, build));
+        });
+    }
+
     pathForPendingBuildsJSONDeprecated() { return `/json/builders/${escape(this._builderName)}/pendingBuilds`; }
     pathForPendingBuilds() { return `/api/v2/builders/${this._builderID}/buildrequests?complete=false&claimed=false`; }
-    pathForBuildJSON(selectedBuilds)
+    pathForBuildJSONDeprecated(selectedBuilds)
     {
         return `/json/builders/${escape(this._builderName)}/builds/?` + selectedBuilds.map((number) => 'select=' + number).join('&');
     }
+    pathForRecentBuilds(count) { return `/api/v2/builders/${this._builderID}/builds?limit=${count}&order=-number&property=*`; }
     pathForForceBuild() { return `/builders/${escape(this._builderName)}/force`; }
 
     url() { return this._remote.url(`/builders/${escape(this._builderName)}/`); }

Modified: trunk/Websites/perf.webkit.org/unit-tests/buildbot-syncer-tests.js (228097 => 228098)


--- trunk/Websites/perf.webkit.org/unit-tests/buildbot-syncer-tests.js	2018-02-05 16:33:33 UTC (rev 228097)
+++ trunk/Websites/perf.webkit.org/unit-tests/buildbot-syncer-tests.js	2018-02-05 16:53:22 UTC (rev 228098)
@@ -1352,6 +1352,64 @@
         });
     });
 
+    describe('_pullRecentBuilds()', () => {
+        it('should not fetch recent builds when count is zero', async () => {
+            const syncer = BuildbotSyncer._loadConfig(MockRemoteAPI, sampleiOSConfig(), builderNameToIDMap())[1];
+            const promise = syncer._pullRecentBuilds(0);
+            assert.equal(requests.length, 0);
+            const content = await promise;
+            assert.deepEqual(content, []);
+        });
+
+        it('should pull the right number of recent builds', () => {
+            const syncer = BuildbotSyncer._loadConfig(MockRemoteAPI, sampleiOSConfig(), builderNameToIDMap())[1];
+            syncer._pullRecentBuilds(12);
+            assert.equal(requests.length, 1);
+            assert.equal(requests[0].url, '/api/v2/builders/102/builds?limit=12&order=-number&property=*');
+        });
+
+        it('should handle unexpected error while fetching recent builds', async () => {
+            const syncer = BuildbotSyncer._loadConfig(MockRemoteAPI, sampleiOSConfig(), builderNameToIDMap())[1];
+            const promise = syncer._pullRecentBuilds(2);
+            assert.equal(requests.length, 1);
+            assert.equal(requests[0].url, '/api/v2/builders/102/builds?limit=2&order=-number&property=*');
+            requests[0].resolve({'error': 'Unexpected error'});
+            const content = await promise;
+            assert.deepEqual(content, []);
+        });
+
+        it('should create BuildbotBuildEntry after fetching recent builds', async () => {
+            const syncer = BuildbotSyncer._loadConfig(MockRemoteAPI, sampleiOSConfig(), builderNameToIDMap())[1];
+            const promise = syncer._pullRecentBuilds(2);
+            assert.equal(requests.length, 1);
+            assert.equal(requests[0].url, '/api/v2/builders/102/builds?limit=2&order=-number&property=*');
+            requests[0].resolve({'builds': [sampleFinishedBuildData(), sampleInProgressBuildData()]});
+
+            const entries = await promise;
+            assert.deepEqual(entries.length, 2);
+
+            let entry = entries[0];
+            assert.ok(entry instanceof BuildbotBuildEntry);
+            assert.equal(entry.buildNumber(), 1755);
+            assert.equal(entry.workerName(), 'ABTest-iPad-0');
+            assert.equal(entry.buildRequestId(), 18935);
+            assert.ok(!entry.isPending());
+            assert.ok(!entry.isInProgress());
+            assert.ok(entry.hasFinished());
+            assert.equal(entry.url(), 'http://build.webkit.org/#/builders/102/builds/1755');
+
+            entry = entries[1];
+            assert.ok(entry instanceof BuildbotBuildEntry);
+            assert.equal(entry.buildNumber(), 614);
+            assert.equal(entry.slaveName(), 'ABTest-iPad-0');
+            assert.equal(entry.buildRequestId(), 16733);
+            assert.ok(!entry.isPending());
+            assert.ok(entry.isInProgress());
+            assert.ok(!entry.hasFinished());
+            assert.equal(entry.url(), 'http://build.webkit.org/#/builders/102/builds/614');
+        });
+    });
+
     describe('pullBuildbot', () => {
         it('should fetch pending builds from the right URL', () => {
             let syncer = BuildbotSyncer._loadConfig(MockRemoteAPI, sampleiOSConfig(), builderNameToIDMap())[1];
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to