sync-buildbot.js should update the list of tests and platforms associated with a...
authorrniwa@webkit.org <rniwa@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 6 Jun 2016 18:51:23 +0000 (18:51 +0000)
committerrniwa@webkit.org <rniwa@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 6 Jun 2016 18:51:23 +0000 (18:51 +0000)
https://bugs.webkit.org/show_bug.cgi?id=158406
<rdar://problem/26185737>

Reviewed by Darin Adler.

Added /api/update-triggerable to update the list of configurations (platform and test pairs)
associated with a given triggerable, and make sync-buildbot.js use this JSON API before each
syncing cycle so that the association gets updated automatically by simply updating the JSON.

* server-tests/api-manifest.js: Use const for imported modules.
* server-tests/api-report-commits-tests.js: Removed unnecessary importing of crypto.
* server-tests/resources/mock-data.js:
(MockData.someTestId): Added.
(MockData.somePlatformId): Added.
(MockData.addMockData):
* server-tests/tools-buildbot-triggerable-tests.js: Use const for imported modules. Also added
a test for BuildbotTriggerable's updateTriggerable.
* tools/js/buildbot-triggerable.js:
(BuildbotTriggerable.prototype.updateTriggerable): Added. Find the list of all configurations
associated with this triggeerable and post it to /api/update-triggerable.
* tools/js/database.js: Added triggerable_configurations to the list of tables.
* tools/js/remote.js:
(RemoteAPI.prototype.postJSON): Print the whole response when JSON parsing fails for debugging.
* tools/sync-buildbot.js:
(syncLoop): Call BuildbotTriggerable's updateTriggerable before syncing.

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

Websites/perf.webkit.org/ChangeLog
Websites/perf.webkit.org/server-tests/api-manifest.js
Websites/perf.webkit.org/server-tests/api-report-commits-tests.js
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-triggerable.js
Websites/perf.webkit.org/tools/js/database.js
Websites/perf.webkit.org/tools/js/remote.js
Websites/perf.webkit.org/tools/sync-buildbot.js

index 3bb5b8c..95147af 100644 (file)
@@ -1,3 +1,32 @@
+2016-06-06  Ryosuke Niwa  <rniwa@webkit.org>
+
+        sync-buildbot.js should update the list of tests and platforms associated with a triggerable
+        https://bugs.webkit.org/show_bug.cgi?id=158406
+        <rdar://problem/26185737>
+
+        Reviewed by Darin Adler.
+
+        Added /api/update-triggerable to update the list of configurations (platform and test pairs)
+        associated with a given triggerable, and make sync-buildbot.js use this JSON API before each
+        syncing cycle so that the association gets updated automatically by simply updating the JSON.
+
+        * server-tests/api-manifest.js: Use const for imported modules.
+        * server-tests/api-report-commits-tests.js: Removed unnecessary importing of crypto.
+        * server-tests/resources/mock-data.js:
+        (MockData.someTestId): Added.
+        (MockData.somePlatformId): Added.
+        (MockData.addMockData):
+        * server-tests/tools-buildbot-triggerable-tests.js: Use const for imported modules. Also added
+        a test for BuildbotTriggerable's updateTriggerable.
+        * tools/js/buildbot-triggerable.js:
+        (BuildbotTriggerable.prototype.updateTriggerable): Added. Find the list of all configurations
+        associated with this triggeerable and post it to /api/update-triggerable.
+        * tools/js/database.js: Added triggerable_configurations to the list of tables.
+        * tools/js/remote.js:
+        (RemoteAPI.prototype.postJSON): Print the whole response when JSON parsing fails for debugging.
+        * tools/sync-buildbot.js:
+        (syncLoop): Call BuildbotTriggerable's updateTriggerable before syncing.
+
 2016-06-02  Ryosuke Niwa  <rniwa@webkit.org>
 
         Build fix after r201564.
index 2f1b03a..2587eeb 100644 (file)
@@ -1,10 +1,11 @@
 'use strict';
 
-let assert = require('assert');
+const assert = require('assert');
 
 require('../tools/js/v3-models.js');
 
-let TestServer = require('./resources/test-server.js');
+const MockData = require('./resources/mock-data.js');
+const TestServer = require('./resources/test-server.js');
 
 describe('/api/manifest', function () {
     this.timeout(1000);
index cc10c1a..bc07817 100644 (file)
@@ -1,7 +1,6 @@
 'use strict';
 
 const assert = require('assert');
-const crypto = require('crypto');
 
 const TestServer = require('./resources/test-server.js');
 const addSlaveForReport = require('./resources/common-operations.js').addSlaveForReport;
index 2da3bd2..71152b5 100644 (file)
@@ -16,6 +16,8 @@ MockData = {
         Test.clearStaticMap();
         TestGroup.clearStaticMap();
     },
+    someTestId() { return 200; },
+    somePlatformId() { return 65; },
     addMockData: function (db, statusList)
     {
         if (!statusList)
@@ -28,8 +30,8 @@ MockData = {
             db.insert('commits', {id: 87832, repository: 9, revision: '10.11 15A284'}),
             db.insert('commits', {id: 93116, repository: 11, revision: '191622', time: (new Date(1445945816878)).toISOString()}),
             db.insert('commits', {id: 96336, repository: 11, revision: '192736', time: (new Date(1448225325650)).toISOString()}),
-            db.insert('platforms', {id: 65, name: 'some platform'}),
-            db.insert('tests', {id: 200, name: 'some test'}),
+            db.insert('platforms', {id: MockData.somePlatformId(), name: 'some platform'}),
+            db.insert('tests', {id: MockData.someTestId(), name: 'some test'}),
             db.insert('test_metrics', {id: 300, test: 200, name: 'some metric'}),
             db.insert('test_configurations', {id: 301, metric: 300, platform: 65, type: 'current'}),
             db.insert('root_sets', {id: 401}),
index dfa489d..e84b393 100644 (file)
@@ -1,11 +1,12 @@
 'use strict';
 
-let assert = require('assert');
+const assert = require('assert');
 
-let BuildbotTriggerable = require('../tools/js/buildbot-triggerable.js').BuildbotTriggerable;
-let MockData = require('./resources/mock-data.js');
-let MockRemoteAPI = require('../unit-tests/resources/mock-remote-api.js').MockRemoteAPI;
-let TestServer = require('./resources/test-server.js');
+const BuildbotTriggerable = require('../tools/js/buildbot-triggerable.js').BuildbotTriggerable;
+const MockData = require('./resources/mock-data.js');
+const MockRemoteAPI = require('../unit-tests/resources/mock-remote-api.js').MockRemoteAPI;
+const TestServer = require('./resources/test-server.js');
+const connectToDatabaseInEveryTest = require('./resources/common-operations.js').connectToDatabaseInEveryTest;
 
 class MockLogger {
     constructor()
@@ -902,4 +903,32 @@ describe('BuildbotTriggerable', function () {
             }).catch(done);
         });
     });
+
+    describe('updateTriggerables', function () {
+        connectToDatabaseInEveryTest();
+
+        it('should update available triggerables', function (done) {
+            let db = TestServer.database();
+            MockData.addMockData(db).then(function () {
+                return Manifest.fetch();
+            }).then(function () {
+                return db.selectAll('triggerable_configurations', 'test');
+            }).then(function (configurations) {
+                assert.equal(configurations.length, 0);
+                let config = MockData.mockTestSyncConfigWithSingleBuilder();
+                let logger = new MockLogger;
+                let slaveInfo = {name: 'sync-slave', password: 'password'};
+                let triggerable = new BuildbotTriggerable(config, TestServer.remoteAPI(), MockRemoteAPI, slaveInfo, logger);
+                return triggerable.updateTriggerable();
+            }).then(function () {
+                return db.selectAll('triggerable_configurations', 'test');
+            }).then(function (configurations) {
+                assert.equal(configurations.length, 1);
+                assert.equal(configurations[0].test, MockData.someTestId());
+                assert.equal(configurations[0].platform, MockData.somePlatformId());
+                done();
+            }).catch(done);
+        });
+    });
+
 });
index 8163ec3..aaf5b2a 100644 (file)
@@ -27,6 +27,22 @@ class BuildbotTriggerable {
 
     name() { return this._name; }
 
+    updateTriggerable()
+    {
+        const map = new Map;
+        for (const syncer of this._syncers) {
+            for (const config of syncer.testConfigurations()) {
+                const entry = {test: config.test.id(), platform: config.platform.id()};
+                map.set(entry.test + '-' + entry.platform, entry);
+            }
+        }
+        return this._remote.postJSON(`/api/update-triggerable/`, {
+            'slaveName': this._slaveInfo.name,
+            'slavePassword': this._slaveInfo.password,
+            'triggerable': this._name,
+            'configurations': Array.from(map.values())});
+    }
+
     syncOnce()
     {
         let syncerList = this._syncers;
index 5590552..864f596 100644 (file)
@@ -142,6 +142,7 @@ const tableToPrefixMap = {
     'test_runs': 'run',
     'tests': 'test',
     'tracker_repositories': 'tracrepo',
+    'triggerable_configurations': 'trigconfig',
     'platforms': 'platform',
     'reports': 'report',
     'repositories': 'repository',
index e6de4f1..14605f1 100644 (file)
@@ -71,7 +71,12 @@ class RemoteAPI {
         const contentType = 'application/json';
         const payload = JSON.stringify(data);
         return this.sendHttpRequest(path, 'POST', 'application/json', payload).then(function (result) {
-            return JSON.parse(result.responseText);
+            try {
+                return JSON.parse(result.responseText);
+            } catch (error) {
+                console.error(result.responseText);
+                throw error;
+            }
         });
     }
 
index 4e925e9..f502d9f 100755 (executable)
@@ -41,8 +41,12 @@ function syncLoop(options)
     global.RemoteAPI = new RemoteAPI(serverConfig.server);
 
     console.log(`Fetching the manifest...`);
+
+    let triggerable;
     Manifest.fetch().then(function () {
-        let triggerable = new BuildbotTriggerable(buildbotConfig, global.RemoteAPI, buildbotRemote, serverConfig.slave, console);
+        triggerable = new BuildbotTriggerable(buildbotConfig, global.RemoteAPI, buildbotRemote, serverConfig.slave, console);
+        return triggerable.updateTriggerable();
+    }).then(function () {
         return triggerable.syncOnce();
     }).catch(function (error) {
         console.error(error);