Add initSyncers method in BuildbotTriggerable
authoraakash_jain@apple.com <aakash_jain@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 7 Sep 2017 04:23:35 +0000 (04:23 +0000)
committeraakash_jain@apple.com <aakash_jain@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 7 Sep 2017 04:23:35 +0000 (04:23 +0000)
https://bugs.webkit.org/show_bug.cgi?id=176125

Reviewed by Ryosuke Niwa.

* tools/sync-buildbot.js:
(syncLoop): Use initSyncers() which returns a promise. Modified to handle the promise.
* tools/js/buildbot-triggerable.js:
(BuildbotTriggerable): Invokes initSyncers() appropriately.
(BuildbotTriggerable.prototype.initSyncers): Returns a promise which initialize all the syncers.
* server-tests/tools-buildbot-triggerable-tests.js: Updated tests to handle initSyncers().
* server-tests/tools-sync-buildbot-integration-tests.js: Ditto.

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

Websites/perf.webkit.org/ChangeLog
Websites/perf.webkit.org/server-tests/tools-buildbot-triggerable-tests.js
Websites/perf.webkit.org/server-tests/tools-sync-buildbot-integration-tests.js
Websites/perf.webkit.org/tools/js/buildbot-triggerable.js
Websites/perf.webkit.org/tools/sync-buildbot.js

index ffc7621..72fc058 100644 (file)
@@ -1,3 +1,18 @@
+2017-09-06  Aakash Jain  <aakash_jain@apple.com>
+
+        Add initSyncers method in BuildbotTriggerable
+        https://bugs.webkit.org/show_bug.cgi?id=176125
+
+        Reviewed by Ryosuke Niwa.
+
+        * tools/sync-buildbot.js:
+        (syncLoop): Use initSyncers() which returns a promise. Modified to handle the promise.
+        * tools/js/buildbot-triggerable.js:
+        (BuildbotTriggerable): Invokes initSyncers() appropriately.
+        (BuildbotTriggerable.prototype.initSyncers): Returns a promise which initialize all the syncers.
+        * server-tests/tools-buildbot-triggerable-tests.js: Updated tests to handle initSyncers().
+        * server-tests/tools-sync-buildbot-integration-tests.js: Ditto.
+
 2017-09-05  Ryosuke Niwa  <rniwa@webkit.org>
 
         Add a button to show two weeks of data to perf dashboard
index d32eec7..df42bea 100644 (file)
@@ -35,7 +35,7 @@ describe('BuildbotTriggerable', function () {
                 const logger = new MockLogger;
                 const slaveInfo = {name: 'sync-slave', password: 'password'};
                 const triggerable = new BuildbotTriggerable(config, TestServer.remoteAPI(), MockRemoteAPI, slaveInfo, logger);
-                syncPromise = triggerable.syncOnce();
+                syncPromise = triggerable.initSyncers().then(() => triggerable.syncOnce());
                 return MockRemoteAPI.waitForRequest();
             }).then(() => {
                 assert.equal(BuildRequest.all().length, 4);
@@ -89,7 +89,7 @@ describe('BuildbotTriggerable', function () {
                 let logger = new MockLogger;
                 let slaveInfo = {name: 'sync-slave', password: 'password'};
                 let triggerable = new BuildbotTriggerable(config, TestServer.remoteAPI(), MockRemoteAPI, slaveInfo, logger);
-                syncPromise = triggerable.syncOnce();
+                syncPromise = triggerable.initSyncers().then(() => triggerable.syncOnce());
                 return MockRemoteAPI.waitForRequest();
             }).then(() => {
                 assert.equal(MockRemoteAPI.requests[0].method, 'GET');
@@ -137,7 +137,7 @@ describe('BuildbotTriggerable', function () {
                 const logger = new MockLogger;
                 const slaveInfo = {name: 'sync-slave', password: 'password'};
                 const triggerable = new BuildbotTriggerable(config, TestServer.remoteAPI(), MockRemoteAPI, slaveInfo, logger);
-                syncPromise = triggerable.syncOnce();
+                syncPromise = triggerable.initSyncers().then(() => triggerable.syncOnce());
                 return MockRemoteAPI.waitForRequest();
             }).then(() => {
                 assert.equal(MockRemoteAPI.requests.length, 2);
@@ -216,7 +216,7 @@ describe('BuildbotTriggerable', function () {
                 let logger = new MockLogger;
                 let slaveInfo = {name: 'sync-slave', password: 'password'};
                 let triggerable = new BuildbotTriggerable(config, TestServer.remoteAPI(), MockRemoteAPI, slaveInfo, logger);
-                syncPromise = triggerable.syncOnce();
+                syncPromise = triggerable.initSyncers().then(() => triggerable.syncOnce());
                 return MockRemoteAPI.waitForRequest();
             }).then(() => {
                 assert.equal(MockRemoteAPI.requests.length, 2);
@@ -288,7 +288,7 @@ describe('BuildbotTriggerable', function () {
                 const logger = new MockLogger;
                 const slaveInfo = {name: 'sync-slave', password: 'password'};
                 const triggerable = new BuildbotTriggerable(config, TestServer.remoteAPI(), MockRemoteAPI, slaveInfo, logger);
-                syncPromise = triggerable.syncOnce();
+                syncPromise = triggerable.initSyncers().then(() => triggerable.syncOnce());
                 return MockRemoteAPI.waitForRequest();
             }).then(() => {
                 assert.equal(MockRemoteAPI.requests.length, 2);
@@ -367,7 +367,7 @@ describe('BuildbotTriggerable', function () {
                 let logger = new MockLogger;
                 let slaveInfo = {name: 'sync-slave', password: 'password'};
                 let triggerable = new BuildbotTriggerable(config, TestServer.remoteAPI(), MockRemoteAPI, slaveInfo, logger);
-                syncPromise = triggerable.syncOnce();
+                syncPromise = triggerable.initSyncers().then(() => triggerable.syncOnce());
                 return MockRemoteAPI.waitForRequest();
             }).then(() => {
                 assert.equal(MockRemoteAPI.requests.length, 1);
@@ -430,7 +430,7 @@ describe('BuildbotTriggerable', function () {
                 const logger = new MockLogger;
                 const slaveInfo = {name: 'sync-slave', password: 'password'};
                 const triggerable = new BuildbotTriggerable(config, TestServer.remoteAPI(), MockRemoteAPI, slaveInfo, logger);
-                syncPromise = triggerable.syncOnce();
+                syncPromise = triggerable.initSyncers().then(() => triggerable.syncOnce());
                 return MockRemoteAPI.waitForRequest();
             }).then(() => {
                 assert.equal(MockRemoteAPI.requests.length, 2);
@@ -528,7 +528,7 @@ describe('BuildbotTriggerable', function () {
                 const logger = new MockLogger;
                 const slaveInfo = {name: 'sync-slave', password: 'password'};
                 const triggerable = new BuildbotTriggerable(config, TestServer.remoteAPI(), MockRemoteAPI, slaveInfo, logger);
-                syncPromise = triggerable.syncOnce();
+                syncPromise = triggerable.initSyncers().then(() => triggerable.syncOnce());
                 return MockRemoteAPI.waitForRequest();
             }).then(() => {
                 assert.equal(MockRemoteAPI.requests.length, 2);
@@ -629,7 +629,7 @@ describe('BuildbotTriggerable', function () {
                 const logger = new MockLogger;
                 const slaveInfo = {name: 'sync-slave', password: 'password'};
                 const triggerable = new BuildbotTriggerable(config, TestServer.remoteAPI(), MockRemoteAPI, slaveInfo, logger);
-                syncPromise = triggerable.syncOnce();
+                syncPromise = triggerable.initSyncers().then(() => triggerable.syncOnce());
                 return MockRemoteAPI.waitForRequest();
             }).then(() => {
                 assert.equal(requests.length, 1);
@@ -704,7 +704,7 @@ describe('BuildbotTriggerable', function () {
                 const logger = new MockLogger;
                 const slaveInfo = {name: 'sync-slave', password: 'password'};
                 triggerable = new BuildbotTriggerable(config, TestServer.remoteAPI(), MockRemoteAPI, slaveInfo, logger);
-                syncPromise = triggerable.syncOnce();
+                syncPromise = triggerable.initSyncers().then(() => triggerable.syncOnce());
                 return MockRemoteAPI.waitForRequest();
             }).then(() => {
                 assert.equal(requests.length, 1);
@@ -731,7 +731,7 @@ describe('BuildbotTriggerable', function () {
                     {[-1]: MockData.runningBuild({buildRequestId: 700}), [-2]: MockData.finishedBuild({buildRequestId: 710})});
                 return syncPromise;
             }).then(() => {
-                syncPromise = triggerable.syncOnce();
+                syncPromise = triggerable.initSyncers().then(() => triggerable.syncOnce());
                 return MockRemoteAPI.waitForRequest();
             }).then(() => {
                 assert.equal(requests.length, 6);
@@ -764,7 +764,7 @@ describe('BuildbotTriggerable', function () {
                 const logger = new MockLogger;
                 const slaveInfo = {name: 'sync-slave', password: 'password'};
                 const triggerable = new BuildbotTriggerable(config, TestServer.remoteAPI(), MockRemoteAPI, slaveInfo, logger);
-                syncPromise = triggerable.syncOnce();
+                syncPromise = triggerable.initSyncers().then(() => triggerable.syncOnce());
                 return MockRemoteAPI.waitForRequest();
             }).then(() => {
                 assert.equal(MockRemoteAPI.requests.length, 1);
@@ -831,7 +831,7 @@ describe('BuildbotTriggerable', function () {
                 const logger = new MockLogger;
                 const slaveInfo = {name: 'sync-slave', password: 'password'};
                 const triggerable = new BuildbotTriggerable(config, TestServer.remoteAPI(), MockRemoteAPI, slaveInfo, logger);
-                syncPromise = triggerable.syncOnce();
+                syncPromise = triggerable.initSyncers().then(() => triggerable.syncOnce());
                 return MockRemoteAPI.waitForRequest();
             }).then(() => {
                 assert.equal(MockRemoteAPI.requests.length, 1);
@@ -886,7 +886,7 @@ describe('BuildbotTriggerable', function () {
                 const logger = new MockLogger;
                 const slaveInfo = {name: 'sync-slave', password: 'password'};
                 const triggerable = new BuildbotTriggerable(config, TestServer.remoteAPI(), MockRemoteAPI, slaveInfo, logger);
-                syncPromise = triggerable.syncOnce();
+                syncPromise = triggerable.initSyncers().then(() => triggerable.syncOnce());
                 return MockRemoteAPI.waitForRequest();
             }).then(() => {
                 assert.equal(MockRemoteAPI.requests.length, 1);
@@ -972,7 +972,7 @@ describe('BuildbotTriggerable', function () {
                 const logger = new MockLogger;
                 const slaveInfo = {name: 'sync-slave', password: 'password'};
                 const buildbotTriggerable = new BuildbotTriggerable(config, TestServer.remoteAPI(), MockRemoteAPI, slaveInfo, logger);
-                return buildbotTriggerable.updateTriggerable();
+                return buildbotTriggerable.initSyncers().then(() => buildbotTriggerable.updateTriggerable());
             }).then(() => refetchManifest()).then(() => {
                 assert.equal(Triggerable.all().length, 1);
 
@@ -997,7 +997,7 @@ describe('BuildbotTriggerable', function () {
                 const logger = new MockLogger;
                 const slaveInfo = {name: 'sync-slave', password: 'password'};
                 const buildbotTriggerable = new BuildbotTriggerable(config, TestServer.remoteAPI(), MockRemoteAPI, slaveInfo, logger);
-                return buildbotTriggerable.updateTriggerable();
+                return buildbotTriggerable.initSyncers().then(() => buildbotTriggerable.updateTriggerable());
             }).then(() => refetchManifest()).then(() => {
                 assert.equal(Triggerable.all().length, 1);
                 const groups = TriggerableRepositoryGroup.sortByName(Triggerable.all()[0].repositoryGroups());
index dbe2d80..bada57a 100644 (file)
@@ -61,7 +61,7 @@ function createTriggerable()
         return Manifest.fetch();
     }).then(() => {
         triggerable = new BuildbotTriggerable(config, TestServer.remoteAPI(), MockRemoteAPI, {name: 'sync-slave', password: 'password'}, new MockLogger);
-        return triggerable.updateTriggerable();
+        return triggerable.initSyncers().then(() => triggerable.updateTriggerable());
     }).then(() => Manifest.fetch()).then(() => {
         return new BuildbotTriggerable(config, TestServer.remoteAPI(), MockRemoteAPI, {name: 'sync-slave', password: 'password'}, new MockLogger);
     });
@@ -156,7 +156,7 @@ describe('sync-buildbot', function () {
             assert.equal(otherCommitSet.rootForRepository(webkit), null);
             assert.deepEqual(otherCommitSet.allRootFiles(), []);
 
-            syncPromise = triggerable.syncOnce();
+            syncPromise = triggerable.initSyncers().then(() => triggerable.syncOnce());
             return MockRemoteAPI.waitForRequest();
         }).then(() => {
             assert.equal(requests.length, 3);
@@ -267,7 +267,7 @@ describe('sync-buildbot', function () {
             assert.deepEqual(otherCommitSet.allRootFiles(), []);
 
             MockRemoteAPI.reset();
-            syncPromise = triggerable.syncOnce();
+            syncPromise = triggerable.initSyncers().then(() => triggerable.syncOnce());
             return MockRemoteAPI.waitForRequest();
         }).then(() => {
             assert.equal(requests.length, 3);
@@ -441,7 +441,7 @@ describe('sync-buildbot', function () {
             const otherRoots = otherBuildRequest.commitSet().allRootFiles();
             assert.equal(otherRoots.length, 1);
             assert.deepEqual(otherRoots[0].filename(), 'root46.dat');
-            syncPromise = triggerable.syncOnce();
+            syncPromise = triggerable.initSyncers().then(() => triggerable.syncOnce());
             return MockRemoteAPI.waitForRequest();
         }).then(() => {
             assert.equal(requests.length, 3);
@@ -512,7 +512,7 @@ describe('sync-buildbot', function () {
             assert.equal(otherBuildRequest.statusUrl(), null);
             assert.equal(otherBuildRequest.buildId(), null);
 
-            syncPromise = triggerable.syncOnce();
+            syncPromise = triggerable.initSyncers().then(() => triggerable.syncOnce());
             return Promise.all([MockRemoteAPI.waitForRequest(), uploadRoot(1, 123)]);
         }).then(() => {
             assert.equal(requests.length, 3);
@@ -596,7 +596,7 @@ describe('sync-buildbot', function () {
             assert.equal(otherBuildRequest.statusUrl(), null);
             assert.equal(otherBuildRequest.buildId(), null);
 
-            syncPromise = triggerable.syncOnce();
+            syncPromise = triggerable.initSyncers().then(() => triggerable.syncOnce());
             return MockRemoteAPI.waitForRequest();
         }).then(() => {
             assert.equal(requests.length, 3);
index 99f4360..1bf191d 100644 (file)
@@ -16,15 +16,25 @@ class BuildbotTriggerable {
         assert(typeof(this._lookbackCount) == 'number' && this._lookbackCount > 0, 'lookbackCount must be a number greater than 0');
 
         this._remote = remote;
+        this._config = config;
+        this._buildbotRemote = buildbotRemote;
 
         this._slaveInfo = slaveInfo;
         assert(typeof(slaveInfo.name) == 'string', 'slave name must be specified');
         assert(typeof(slaveInfo.password) == 'string', 'slave password must be specified');
 
-        this._syncers = BuildbotSyncer._loadConfig(buildbotRemote, config);
+        this._syncers = null;
         this._logger = logger || {log: () => { }, error: () => { }};
     }
 
+    initSyncers()
+    {
+        return new Promise((resolve, reject) => {
+            this._syncers = BuildbotSyncer._loadConfig(this._buildbotRemote, this._config);
+            setTimeout(resolve, 0);
+        });
+    }
+
     name() { return this._name; }
 
     updateTriggerable()
index 34aa6ea..70740f3 100755 (executable)
@@ -35,11 +35,13 @@ function syncLoop(options)
     };
 
     Manifest.fetch().then(() => {
-        return makeTriggerable().updateTriggerable();
+        const triggerable = makeTriggerable();
+        return triggerable.initSyncers().then(() => triggerable.updateTriggerable());
     }).then(() => {
         return Manifest.fetch();
     }).then(() => {
-        return makeTriggerable().syncOnce();
+        const triggerable = makeTriggerable();
+        return triggerable.initSyncers().then(() => triggerable.syncOnce());
     }).catch((error) => {
         console.error(error);
         if (typeof(error.stack) == 'string') {