Add support for submitting build request to Buildbot 0.9 server in BuildbotSyncer
authoraakash_jain@apple.com <aakash_jain@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 5 Feb 2018 17:14:13 +0000 (17:14 +0000)
committeraakash_jain@apple.com <aakash_jain@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 5 Feb 2018 17:14:13 +0000 (17:14 +0000)
https://bugs.webkit.org/show_bug.cgi?id=182218

Reviewed by Ryosuke Niwa.

* tools/js/buildbot-syncer.js:
(BuildbotSyncer.prototype.scheduleRequest): Added assert to ensure forcescheduler property is always defined. Builds can not
be scheduled on Buildbot without this property. Updated unit-tests and server-tests accordingly.
(BuildbotSyncer.prototype.scheduleBuildOnBuildbotDeprecated): Method to schedule build request on Buildbot 0.8 server.
(BuildbotSyncer.prototype.scheduleBuildOnBuildbot): Method to schedule build request on Buildbot 0.9 server.
(BuildbotSyncer.prototype.pathForForceBuildDeprecated): Path for scheudling build on Buildbot 0.8 server.
(BuildbotSyncer.prototype.pathForForceBuild): Path for scheudling build on Buildbot 0.9 server.
* unit-tests/buildbot-syncer-tests.js:
(smallConfiguration): Added test-case for scheduleBuildOnBuildbot. Also added forcescheduler property in sample data.
* server-tests/resources/mock-data.js: Added forcescheduler property in sample data.
* server-tests/tools-buildbot-triggerable-tests.js: Updated server-tests to take care of added forcescheduler property.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@228099 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Websites/perf.webkit.org/ChangeLog
Websites/perf.webkit.org/server-tests/resources/mock-data.js
Websites/perf.webkit.org/server-tests/tools-buildbot-triggerable-tests.js
Websites/perf.webkit.org/tools/js/buildbot-syncer.js
Websites/perf.webkit.org/unit-tests/buildbot-syncer-tests.js

index 4d50d60..3c17fb1 100644 (file)
@@ -1,5 +1,24 @@
 2018-02-02  Aakash Jain  <aakash_jain@apple.com>
 
+        Add support for submitting build request to Buildbot 0.9 server in BuildbotSyncer
+        https://bugs.webkit.org/show_bug.cgi?id=182218
+
+        Reviewed by Ryosuke Niwa.
+
+        * tools/js/buildbot-syncer.js:
+        (BuildbotSyncer.prototype.scheduleRequest): Added assert to ensure forcescheduler property is always defined. Builds can not
+        be scheduled on Buildbot without this property. Updated unit-tests and server-tests accordingly.
+        (BuildbotSyncer.prototype.scheduleBuildOnBuildbotDeprecated): Method to schedule build request on Buildbot 0.8 server.
+        (BuildbotSyncer.prototype.scheduleBuildOnBuildbot): Method to schedule build request on Buildbot 0.9 server.
+        (BuildbotSyncer.prototype.pathForForceBuildDeprecated): Path for scheudling build on Buildbot 0.8 server.
+        (BuildbotSyncer.prototype.pathForForceBuild): Path for scheudling build on Buildbot 0.9 server.
+        * unit-tests/buildbot-syncer-tests.js:
+        (smallConfiguration): Added test-case for scheduleBuildOnBuildbot. Also added forcescheduler property in sample data.
+        * server-tests/resources/mock-data.js: Added forcescheduler property in sample data.
+        * server-tests/tools-buildbot-triggerable-tests.js: Updated server-tests to take care of added forcescheduler property.
+
+2018-02-02  Aakash Jain  <aakash_jain@apple.com>
+
         Add support for fetching recent builds in Buildbot 0.9 format in BuildbotSyncer
         https://bugs.webkit.org/show_bug.cgi?id=179743
 
index 11e1d8d..d9950a2 100644 (file)
@@ -196,7 +196,8 @@ MockData = {
                 'some-test': {'test': ['some test']}
             },
             'builders': {
-                'builder-1': {'builder': 'some-builder-1'},
+                'builder-1': {'builder': 'some-builder-1',
+                     properties: {forcescheduler: 'force-some-builder-1'}} 
             },
             'testConfigurations': [
                 {
@@ -226,8 +227,8 @@ MockData = {
                 'some-test': {'test': ['some test']},
             },
             'builders': {
-                'builder-1': {'builder': 'some-builder-1'},
-                'builder-2': {'builder': 'some builder 2'},
+                'builder-1': {'builder': 'some-builder-1', properties: {forcescheduler: 'force-some-builder-1'}},
+                'builder-2': {'builder': 'some builder 2', properties: {forcescheduler: 'force-some-builder-2'}},
             },
             'testConfigurations': [
                 {
index f331fbe..79a3bc1 100644 (file)
@@ -57,7 +57,7 @@ describe('BuildbotTriggerable', function () {
             }).then(() => {
                 assert.equal(MockRemoteAPI.requests[2].method, 'POST');
                 assert.equal(MockRemoteAPI.requests[2].url, '/builders/some-builder-1/force');
-                assert.deepEqual(MockRemoteAPI.requests[2].data, {'wk': '191622', 'os': '10.11 15A284', 'build-request-id': '702'});
+                assert.deepEqual(MockRemoteAPI.requests[2].data, {'wk': '191622', 'os': '10.11 15A284', 'build-request-id': '702', 'forcescheduler': 'force-some-builder-1'});
                 MockRemoteAPI.requests[2].resolve('OK');
                 return MockRemoteAPI.waitForRequest();
             }).then(() => {
@@ -167,7 +167,7 @@ describe('BuildbotTriggerable', function () {
                 assert.equal(MockRemoteAPI.requests.length, 5);
                 assert.equal(MockRemoteAPI.requests[4].method, 'POST');
                 assert.equal(MockRemoteAPI.requests[4].url, '/builders/some%20builder%202/force');
-                assert.deepEqual(MockRemoteAPI.requests[4].data, {'wk': '191622', 'os': '10.11 15A284', 'build-request-id': '700'});
+                assert.deepEqual(MockRemoteAPI.requests[4].data, {'wk': '191622', 'os': '10.11 15A284', 'build-request-id': '700', 'forcescheduler': 'force-some-builder-2'});
                 MockRemoteAPI.requests[4].resolve('OK');
                 return MockRemoteAPI.waitForRequest();
             }).then(() => {
@@ -322,7 +322,7 @@ describe('BuildbotTriggerable', function () {
                 assert.equal(MockRemoteAPI.requests.length, 5);
                 assert.equal(MockRemoteAPI.requests[4].method, 'POST');
                 assert.equal(MockRemoteAPI.requests[4].url, '/builders/some-builder-1/force');
-                assert.deepEqual(MockRemoteAPI.requests[4].data, {'wk': '191622', 'os': '10.11 15A284', 'build-request-id': '702'});
+                assert.deepEqual(MockRemoteAPI.requests[4].data, {'wk': '191622', 'os': '10.11 15A284', 'build-request-id': '702', 'forcescheduler': 'force-some-builder-1'});
                 MockRemoteAPI.requests[4].resolve('OK');
                 return MockRemoteAPI.waitForRequest();
             }).then(() => {
@@ -468,7 +468,7 @@ describe('BuildbotTriggerable', function () {
                 assert.equal(MockRemoteAPI.requests.length, 5);
                 assert.equal(MockRemoteAPI.requests[4].method, 'POST');
                 assert.equal(MockRemoteAPI.requests[4].url, '/builders/some%20builder%202/force');
-                assert.deepEqual(MockRemoteAPI.requests[4].data, {'wk': '191622', 'os': '10.11 15A284', 'build-request-id': '710'});
+                assert.deepEqual(MockRemoteAPI.requests[4].data, {'wk': '191622', 'os': '10.11 15A284', 'build-request-id': '710', 'forcescheduler': 'force-some-builder-2'});
                 MockRemoteAPI.requests[4].resolve('OK');
                 return MockRemoteAPI.waitForRequest();
             }).then(() => {
@@ -568,11 +568,11 @@ describe('BuildbotTriggerable', function () {
                 assert.equal(MockRemoteAPI.requests.length, 6);
                 assert.equal(MockRemoteAPI.requests[4].method, 'POST');
                 assert.equal(MockRemoteAPI.requests[4].url, '/builders/some%20builder%202/force');
-                assert.deepEqual(MockRemoteAPI.requests[4].data, {'wk': '192736', 'os': '10.11 15A284', 'build-request-id': '701'});
+                assert.deepEqual(MockRemoteAPI.requests[4].data, {'wk': '192736', 'os': '10.11 15A284', 'build-request-id': '701', 'forcescheduler': 'force-some-builder-2'});
                 MockRemoteAPI.requests[4].resolve('OK');
                 assert.equal(MockRemoteAPI.requests[5].method, 'POST');
                 assert.equal(MockRemoteAPI.requests[5].url, '/builders/some-builder-1/force');
-                assert.deepEqual(MockRemoteAPI.requests[5].data, {'wk': '192736', 'os': '10.11 15A284', 'build-request-id': '711'});
+                assert.deepEqual(MockRemoteAPI.requests[5].data, {'wk': '192736', 'os': '10.11 15A284', 'build-request-id': '711', 'forcescheduler': 'force-some-builder-1'});
                 MockRemoteAPI.requests[5].resolve('OK');
                 return MockRemoteAPI.waitForRequest();
             }).then(() => {
@@ -665,7 +665,7 @@ describe('BuildbotTriggerable', function () {
                 assert.equal(requests.length, 3);
                 assert.equal(requests[2].method, 'POST');
                 assert.equal(requests[2].url, '/builders/some-builder-1/force');
-                assert.deepEqual(requests[2].data, {'wk': '191622', 'os': '10.11 15A284', 'build-request-id': '700'});
+                assert.deepEqual(requests[2].data, {'wk': '191622', 'os': '10.11 15A284', 'build-request-id': '700', 'forcescheduler': 'force-some-builder-1'});
                 return new Promise((resolve) => setTimeout(resolve, 10));
             }).then(() => {
                 assert.equal(requests.length, 3);
@@ -738,7 +738,7 @@ describe('BuildbotTriggerable', function () {
             }).then(() => {
                 assert.equal(requests.length, 3);
                 assertRequestAndResolve(requests[2], 'POST', '/builders/some-builder-1/force');
-                assert.deepEqual(requests[2].data, {'wk': '192736', 'os': '10.11 15A284', 'build-request-id': '701'});
+                assert.deepEqual(requests[2].data, {'wk': '192736', 'os': '10.11 15A284', 'build-request-id': '701', 'forcescheduler': 'force-some-builder-1'});
                 return MockRemoteAPI.waitForRequest();
             }).then(() => {
                 assert.equal(requests.length, 4);
@@ -805,7 +805,7 @@ describe('BuildbotTriggerable', function () {
                 assert.equal(MockRemoteAPI.requests.length, 3);
                 assert.equal(MockRemoteAPI.requests[2].method, 'POST');
                 assert.equal(MockRemoteAPI.requests[2].url, '/builders/some-builder-1/force');
-                assert.deepEqual(MockRemoteAPI.requests[2].data, {'wk': '192736', 'os': '10.11 15A284', 'build-request-id': '701'});
+                assert.deepEqual(MockRemoteAPI.requests[2].data, {'wk': '192736', 'os': '10.11 15A284', 'build-request-id': '701', 'forcescheduler': 'force-some-builder-1'});
                 MockRemoteAPI.requests[2].resolve('OK');
                 return MockRemoteAPI.waitForRequest();
             }).then(() => {
@@ -931,7 +931,7 @@ describe('BuildbotTriggerable', function () {
                 assert.equal(MockRemoteAPI.requests.length, 3);
                 assert.equal(MockRemoteAPI.requests[2].method, 'POST');
                 assert.equal(MockRemoteAPI.requests[2].url, '/builders/some-builder-1/force');
-                assert.deepEqual(MockRemoteAPI.requests[2].data, {'wk': '191622', 'os': '10.11 15A284', 'build-request-id': '710'});
+                assert.deepEqual(MockRemoteAPI.requests[2].data, {'wk': '191622', 'os': '10.11 15A284', 'build-request-id': '710', 'forcescheduler': 'force-some-builder-1'});
                 MockRemoteAPI.requests[2].resolve('OK');
             });
         });
index bcd8a05..840f0ac 100644 (file)
@@ -140,6 +140,7 @@ class BuildbotSyncer {
         assert(!this._slavesWithNewRequests.has(slaveName));
         let properties = this._propertiesForBuildRequest(newRequest, requestsInGroup);
 
+        assert(properties['forcescheduler'], `forcescheduler was not specified in buildbot properties for build request ${newRequest.id()} on platform "${newRequest.platform().name()}" for builder "${this.builderName()}"`);
         assert.equal(!this._slavePropertyName, !slaveName);
         if (this._slavePropertyName)
             properties[this._slavePropertyName] = slaveName;
@@ -148,7 +149,19 @@ class BuildbotSyncer {
             properties[this._platformPropertyName] = newRequest.platform().name();
 
         this._slavesWithNewRequests.add(slaveName);
-        return this._remote.postFormUrlencodedData(this.pathForForceBuild(), properties);
+        return this.scheduleBuildOnBuildbotDeprecated(properties);
+    }
+
+    scheduleBuildOnBuildbotDeprecated(properties)
+    {
+        return this._remote.postFormUrlencodedData(this.pathForForceBuildDeprecated(), properties);
+    }
+
+    scheduleBuildOnBuildbot(properties)
+    {
+        const data = {jsonrpc: '2.0', method: 'force', id: properties[this._buildRequestPropertyName], params: properties};
+        const path = this.pathForForceBuild(properties['forcescheduler']);
+        return this._remote.postJSON(path, data);
     }
 
     scheduleRequestInGroupIfAvailable(newRequest, requestsInGroup, slaveName)
@@ -258,7 +271,8 @@ class BuildbotSyncer {
         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`; }
+    pathForForceBuildDeprecated() { return `/builders/${escape(this._builderName)}/force`; }
+    pathForForceBuild(schedulerName) { return `/api/v2/forceschedulers/${schedulerName}`; }
 
     url() { return this._remote.url(`/builders/${escape(this._builderName)}/`); }
     urlForBuildNumberDeprecated(number) { return this._remote.url(`/builders/${escape(this._builderName)}/builds/${number}`); }
index 6653271..5a29e39 100644 (file)
@@ -134,6 +134,7 @@ function smallConfiguration()
         'builders': {
             'some-builder': {
                 'builder': 'some builder',
+                'properties': {'forcescheduler': 'some-builder-ForceScheduler'}
             }
         },
         'testConfigurations': [{
@@ -1673,6 +1674,33 @@ describe('BuildbotSyncer', () => {
         });
     });
 
+    describe('scheduleBuildOnBuildbot', () => {
+        it('should schedule a build request on Buildbot', async () => {
+            const syncer = BuildbotSyncer._loadConfig(MockRemoteAPI, sampleiOSConfig(), builderNameToIDMap())[0];
+            const request = createSampleBuildRequest(MockModels.iphone, MockModels.speedometer);
+            const properties = syncer._propertiesForBuildRequest(request, [request]);
+            const promise  = syncer.scheduleBuildOnBuildbot(properties);
+
+            assert.equal(requests.length, 1);
+            assert.equal(requests[0].method, 'POST');
+            assert.equal(requests[0].url, '/api/v2/forceschedulers/ABTest-iPhone-RunBenchmark-Tests-ForceScheduler');
+            requests[0].resolve();
+            await promise;
+            assert.deepEqual(requests[0].data, {
+                'id': '16733-' + MockModels.iphone.id(),
+                'jsonrpc': '2.0',
+                'method': 'force',
+                'params': {
+                    'build_request_id': '16733-' + MockModels.iphone.id(),
+                    'desired_image': '13A452',
+                    'opensource': '197463',
+                    'forcescheduler': 'ABTest-iPhone-RunBenchmark-Tests-ForceScheduler',
+                    'test_name': 'speedometer'
+                }
+            });
+        });
+    });
+
     describe('scheduleRequest', () => {
         it('should schedule a build request on a specified slave', () => {
             let syncer = BuildbotSyncer._loadConfig(MockRemoteAPI, sampleiOSConfig(), builderNameToIDMap())[0];
@@ -1720,7 +1748,7 @@ describe('BuildbotSyncer', () => {
                 assert.equal(requests.length, 1);
                 assert.equal(requests[0].url, '/builders/some%20builder/force');
                 assert.equal(requests[0].method, 'POST');
-                assert.deepEqual(requests[0].data, {id: '16733-' + MockModels.somePlatform.id(), 'os': '13A452', 'wk': '197463'});
+                assert.deepEqual(requests[0].data, {id: '16733-' + MockModels.somePlatform.id(), 'os': '13A452', 'wk': '197463', 'forcescheduler': 'some-builder-ForceScheduler'});
             });
         });
 
@@ -1733,7 +1761,7 @@ describe('BuildbotSyncer', () => {
                 assert.equal(requests.length, 1);
                 assert.equal(requests[0].url, '/builders/some%20builder/force');
                 assert.equal(requests[0].method, 'POST');
-                assert.deepEqual(requests[0].data, {id: '16733-' + MockModels.somePlatform.id(), 'os': '13A452', 'wk': '197463'});
+                assert.deepEqual(requests[0].data, {id: '16733-' + MockModels.somePlatform.id(), 'os': '13A452', 'wk': '197463', 'forcescheduler': 'some-builder-ForceScheduler'});
             });
         });