Make server tests return a promise instead of manually calling done
authorrniwa@webkit.org <rniwa@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 15 Mar 2017 03:19:02 +0000 (03:19 +0000)
committerrniwa@webkit.org <rniwa@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 15 Mar 2017 03:19:02 +0000 (03:19 +0000)
https://bugs.webkit.org/show_bug.cgi?id=169648

Rubber-stamped by Chris Dumez.

Make the existing server tests always reutrn a promise instead of manually calling "done" callback.
The promise tests are a lot more stable and less error prone.

Also use arrow functions everywhere and use prepareServerTest, renamed from connectToDatabaseInEveryTest,
in more tests instead of manually connecting to database in every test, and reset v3 models.

* server-tests/admin-platforms-tests.js:
* server-tests/admin-reprocess-report-tests.js:
* server-tests/api-build-requests-tests.js:
* server-tests/api-manifest.js:
* server-tests/api-measurement-set-tests.js:
(.postReports): Deleted. Not used in any test.
* server-tests/api-report-commits-tests.js:
* server-tests/api-report-tests.js:
* server-tests/api-update-triggerable.js:
* server-tests/privileged-api-upate-run-status.js:
* server-tests/resources/common-operations.js:
(prepareServerTest): Renamed from connectToDatabaseInEveryTest. Increase the timeout and reset v3 models.
* server-tests/tools-buildbot-triggerable-tests.js:

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

13 files changed:
Websites/perf.webkit.org/ChangeLog
Websites/perf.webkit.org/server-tests/admin-platforms-tests.js
Websites/perf.webkit.org/server-tests/admin-reprocess-report-tests.js
Websites/perf.webkit.org/server-tests/api-build-requests-tests.js
Websites/perf.webkit.org/server-tests/api-commits.js
Websites/perf.webkit.org/server-tests/api-manifest.js
Websites/perf.webkit.org/server-tests/api-measurement-set-tests.js
Websites/perf.webkit.org/server-tests/api-report-commits-tests.js
Websites/perf.webkit.org/server-tests/api-report-tests.js
Websites/perf.webkit.org/server-tests/api-update-triggerable.js
Websites/perf.webkit.org/server-tests/privileged-api-upate-run-status.js
Websites/perf.webkit.org/server-tests/resources/common-operations.js
Websites/perf.webkit.org/server-tests/tools-buildbot-triggerable-tests.js

index 71146bab0ec445bfdcd3d68b2b8dd96f8b2020f0..ee98d6b05d73428f1625a7f9243b6bca3f85c593 100644 (file)
@@ -1,3 +1,30 @@
+2017-03-14  Ryosuke Niwa  <rniwa@webkit.org>
+
+        Make server tests return a promise instead of manually calling done
+        https://bugs.webkit.org/show_bug.cgi?id=169648
+
+        Rubber-stamped by Chris Dumez.
+
+        Make the existing server tests always reutrn a promise instead of manually calling "done" callback.
+        The promise tests are a lot more stable and less error prone.
+
+        Also use arrow functions everywhere and use prepareServerTest, renamed from connectToDatabaseInEveryTest,
+        in more tests instead of manually connecting to database in every test, and reset v3 models.
+
+        * server-tests/admin-platforms-tests.js:
+        * server-tests/admin-reprocess-report-tests.js:
+        * server-tests/api-build-requests-tests.js:
+        * server-tests/api-manifest.js:
+        * server-tests/api-measurement-set-tests.js:
+        (.postReports): Deleted. Not used in any test.
+        * server-tests/api-report-commits-tests.js:
+        * server-tests/api-report-tests.js:
+        * server-tests/api-update-triggerable.js:
+        * server-tests/privileged-api-upate-run-status.js:
+        * server-tests/resources/common-operations.js:
+        (prepareServerTest): Renamed from connectToDatabaseInEveryTest. Increase the timeout and reset v3 models.
+        * server-tests/tools-buildbot-triggerable-tests.js:
+
 2017-03-12  Ryosuke Niwa  <rniwa@webkit.org>
 
         Rename RootSet to CommitSet
index e75ad9a31e709a96393cfd73a1aed9259707094d..6872a932b02bbf5935c060a757c257d0e4a8fcca 100644 (file)
@@ -3,13 +3,11 @@
 const assert = require('assert');
 
 const TestServer = require('./resources/test-server.js');
-const connectToDatabaseInEveryTest = require('./resources/common-operations.js').connectToDatabaseInEveryTest;
+const prepareServerTest = require('./resources/common-operations.js').prepareServerTest;
 const submitReport = require('./resources/common-operations.js').submitReport;
 
 describe("/admin/platforms", function () {
-    this.timeout(1000);
-    TestServer.inject();
-    connectToDatabaseInEveryTest();
+    prepareServerTest(this);
 
     function reportsForDifferentPlatforms()
     {
@@ -40,37 +38,36 @@ describe("/admin/platforms", function () {
             }];
     } 
 
-    it("should delete the platform that got merged into another one", function (done) {
+    it("should delete the platform that got merged into another one", () => {
         const db = TestServer.database();
-        let oldPlatforms;        
-        submitReport(reportsForDifferentPlatforms()).then(function () {
+        let oldPlatforms;
+        return submitReport(reportsForDifferentPlatforms()).then(() => {
             return db.selectAll('platforms', 'name');
-        }).then(function (platforms) {
+        }).then((platforms) => {
             oldPlatforms = platforms;
             assert.equal(oldPlatforms.length, 3);
             assert.equal(oldPlatforms[0]['name'], 'Mavericks');
             assert.equal(oldPlatforms[1]['name'], 'Mountain Lion');
             assert.equal(oldPlatforms[2]['name'], 'Trunk Mountain Lion');
-        }).then(function () {
+        }).then(() => {
             return TestServer.remoteAPI().postFormUrlencodedData('/admin/platforms.php',
                 {'action': 'merge', 'id': oldPlatforms[1]['id'], 'destination': oldPlatforms[2]['id']});
-        }).then(function () {
+        }).then(() => {
             return db.selectAll('platforms');
-        }).then(function (newPlatforms) {
+        }).then((newPlatforms) => {
             assert.equal(newPlatforms.length, 2);
             assert.deepEqual(newPlatforms[0], oldPlatforms[0]);
             assert.deepEqual(newPlatforms[1], oldPlatforms[2]);
-            done();
-        }).catch(done);
+        });
     });
 
-    it("should move test runs from the merged platform to the destination platform", function (done) {
+    it("should move test runs from the merged platform to the destination platform", () => {
         let oldTestRuns;
         const queryForRuns = 'SELECT * FROM test_runs, test_configurations, platforms WHERE run_config = config_id AND config_platform = platform_id ORDER by run_mean_cache';
         const db = TestServer.database();
-        submitReport(reportsForDifferentPlatforms()).then(function () {
+        return submitReport(reportsForDifferentPlatforms()).then(() => {
             return db.query(queryForRuns);
-        }).then(function (result) {
+        }).then((result) => {
             oldTestRuns = result.rows;
             assert.equal(oldTestRuns.length, 4);
             assert.equal(oldTestRuns[0]['platform_name'], 'Mavericks');
@@ -81,12 +78,12 @@ describe("/admin/platforms", function () {
             assert.equal(oldTestRuns[2]['run_sum_cache'], 18);
             assert.equal(oldTestRuns[3]['platform_name'], 'Trunk Mountain Lion');
             assert.equal(oldTestRuns[3]['run_sum_cache'], 24);
-        }).then(function () {
+        }).then(() => {
             return TestServer.remoteAPI().postFormUrlencodedData('/admin/platforms.php',
                 {'action': 'merge', 'id': oldTestRuns[1]['platform_id'], 'destination': oldTestRuns[3]['platform_id']});
-        }).then(function () {
+        }).then(() => {
             return db.query(queryForRuns);
-        }).then(function (result) {
+        }).then((result) => {
             const newTestRuns = result.rows;
             assert.equal(newTestRuns.length, 4);
             assert.equal(newTestRuns[0]['run_id'], oldTestRuns[0]['run_id']);
@@ -102,20 +99,20 @@ describe("/admin/platforms", function () {
             assert.equal(newTestRuns[3]['platform_name'], 'Trunk Mountain Lion');
             assert.equal(newTestRuns[3]['run_sum_cache'], 24);
             assert.equal(newTestRuns[1]['run_config'], newTestRuns[3]['run_config']);
-            done();
-        }).catch(done);
+        });
     });
 
-    it("should move test configurations from the merged platform to the destination platform", function (done) {
+    it("should move test configurations from the merged platform to the destination platform", () => {
         let oldConfigs;
         const reports = reportsForDifferentPlatforms();
         reports[0]['tests'] = {"test": { "metrics": {"FrameRate": { "baseline": [[1, 1, 1], [1, 1, 1]] } } } };
         const queryForConfig = 'SELECT * from test_configurations, platforms, test_metrics'
             + ' where config_platform = platform_id and config_metric = metric_id and platform_name in ($1, $2) order by config_id';
         const db = TestServer.database();
-        submitReport(reports).then(function () {
+
+        return submitReport(reports).then(() => {
             return db.query(queryForConfig, [reports[0]['platform'], reports[2]['platform']]);
-        }).then(function (result) {
+        }).then((result) => {
             oldConfigs = result.rows;
             assert.equal(oldConfigs.length, 2);
             assert.equal(oldConfigs[0]['platform_name'], reports[0]['platform']);
@@ -124,12 +121,12 @@ describe("/admin/platforms", function () {
             assert.equal(oldConfigs[1]['platform_name'], reports[2]['platform']);
             assert.equal(oldConfigs[1]['metric_name'], 'FrameRate');
             assert.equal(oldConfigs[1]['config_type'], 'current');
-        }).then(function () {
+        }).then(() => {
             return TestServer.remoteAPI().postFormUrlencodedData('/admin/platforms.php',
                 {'action': 'merge', 'id': oldConfigs[0]['platform_id'], 'destination': oldConfigs[1]['platform_id']});
-        }).then(function () {
+        }).then(() => {
             return db.query(queryForConfig, [reports[0]['platform'], reports[2]['platform']]);
-        }).then(function (result) {
+        }).then((result) => {
             const newConfigs = result.rows;
             assert.equal(newConfigs.length, 2);
             assert.equal(newConfigs[0]['platform_name'], reports[2]['platform']);
@@ -138,8 +135,7 @@ describe("/admin/platforms", function () {
             assert.equal(newConfigs[1]['platform_name'], reports[2]['platform']);
             assert.equal(newConfigs[1]['metric_name'], 'FrameRate');
             assert.equal(newConfigs[1]['config_type'], 'current');
-            done();
-        }).catch(done);
+        });
     });
 
 });
index 47ce1b0a304caa7fe168dee411811f3e98ccc34d..c90ebeed89f26cdc07926884c9f7f3658b5905ff 100644 (file)
@@ -4,12 +4,10 @@ const assert = require('assert');
 
 const TestServer = require('./resources/test-server.js');
 const addBuilderForReport = require('./resources/common-operations.js').addBuilderForReport;
-const connectToDatabaseInEveryTest = require('./resources/common-operations.js').connectToDatabaseInEveryTest;
+const prepareServerTest = require('./resources/common-operations.js').prepareServerTest;
 
 describe("/admin/reprocess-report", function () {
-    this.timeout(1000);
-    TestServer.inject();
-    connectToDatabaseInEveryTest();
+    prepareServerTest(this);
 
     const simpleReport = [{
         "buildNumber": "1986",
@@ -43,34 +41,33 @@ describe("/admin/reprocess-report", function () {
             }
         }];
 
-    it("should still create new repository when repository ownerships are different", function (done) {
+    it("should still create new repository when repository ownerships are different", () => {
         let db = TestServer.database();
-        addBuilderForReport(simpleReportWithRevisions[0]).then(function () {
+        return addBuilderForReport(simpleReportWithRevisions[0]).then(() => {
             return db.insert('repositories', {'name': 'WebKit', 'owner': 1});
-        }).then(function () {
+        }).then(() => {
             return TestServer.remoteAPI().postJSON('/api/report/', simpleReportWithRevisions);
-        }).then(function (response) {
+        }).then((response) => {
             assert.equal(response['status'], 'OK');
             return db.selectRows('repositories', {'name': 'WebKit'});
-        }).then(function (repositories) {
+        }).then((repositories) => {
             assert.equal(repositories.length, 2);
             const webkitRepsitoryId = repositories[0].owner == 1 ? repositories[1].id : repositories[0].id;
             return db.selectRows('commits', {'revision': '213214', 'repository': webkitRepsitoryId});
-        }).then(function (result) {
+        }).then((result) => {
             assert(result.length, 1);
-            done();
-        }).catch(done);
+        });
     });
 
-    it("should add build", function (done) {
+    it("should add build", () => {
         let db = TestServer.database();
         let reportId;
-        addBuilderForReport(simpleReport[0]).then(function () {
+        return addBuilderForReport(simpleReport[0]).then(() => {
             return TestServer.remoteAPI().postJSON('/api/report/', simpleReport);
-        }).then(function (response) {
+        }).then((response) => {
             assert.equal(response['status'], 'OK');
             return Promise.all([db.selectAll('builds'), db.selectAll('reports')]);
-        }).then(function (result) {
+        }).then((result) => {
             const builds = result[0];
             const reports = result[1];
             assert.equal(builds.length, 1);
@@ -79,37 +76,36 @@ describe("/admin/reprocess-report", function () {
             reportId = reports[0]['id'];
             assert.equal(reports[0]['build_number'], 1986);
             return db.query('UPDATE reports SET report_build = NULL; DELETE FROM builds');
-        }).then(function () {
+        }).then(() => {
             return db.selectAll('builds');
-        }).then(function (builds) {
+        }).then((builds) => {
             assert.equal(builds.length, 0);
             return TestServer.remoteAPI().getJSONWithStatus(`/admin/reprocess-report?report=${reportId}`);
-        }).then(function () {
+        }).then(() => {
             return db.selectAll('builds');
-        }).then(function (builds) {
+        }).then((builds) => {
             assert.equal(builds.length, 1);
             assert.equal(builds[0]['number'], 1986);
-            done();
-        }).catch(done);
+        });
     });
 
-    it("should not duplicate the reprocessed report", function (done) {
+    it("should not duplicate the reprocessed report", () => {
         let db = TestServer.database();
         let originalReprot;
-        addBuilderForReport(simpleReport[0]).then(function () {
+        return addBuilderForReport(simpleReport[0]).then(() => {
             return TestServer.remoteAPI().postJSON('/api/report/', simpleReport);
-        }).then(function (response) {
+        }).then((response) => {
             assert.equal(response['status'], 'OK');
             return db.selectAll('reports');
-        }).then(function (reports) {
+        }).then((reports) => {
             assert.equal(reports.length, 1);
             originalReprot = reports[0];
             return db.query('UPDATE reports SET report_build = NULL; DELETE FROM builds');
-        }).then(function () {
+        }).then(() => {
             return TestServer.remoteAPI().getJSONWithStatus(`/admin/reprocess-report?report=${originalReprot['id']}`);
-        }).then(function () {
+        }).then(() => {
             return db.selectAll('reports');
-        }).then(function (reports) {
+        }).then((reports) => {
             assert.equal(reports.length, 1);
             const newPort = reports[0];
             originalReprot['committed_at'] = null;
@@ -118,7 +114,6 @@ describe("/admin/reprocess-report", function () {
             originalReprot['build'] = null;
             newPort['build'] = null;
             assert.deepEqual(originalReprot, newPort);
-            done();
-        }).catch(done);
+        });
     });
 });
index 6bb7f1e9a06e35be20810a27de879cd923a2a2aa..fdf0c87f78acd782601d02261bc7956c0b597b48 100644 (file)
@@ -4,44 +4,33 @@ let assert = require('assert');
 
 let MockData = require('./resources/mock-data.js');
 let TestServer = require('./resources/test-server.js');
+const prepareServerTest = require('./resources/common-operations.js').prepareServerTest;
 
 describe('/api/build-requests', function () {
-    this.timeout(1000);
-    TestServer.inject();
+    prepareServerTest(this);
 
-    beforeEach(function () {
-        MockData.resetV3Models();
-    });
-
-    it('should return "TriggerableNotFound" when the database is empty', function (done) {
-        TestServer.remoteAPI().getJSON('/api/build-requests/build-webkit').then(function (content) {
+    it('should return "TriggerableNotFound" when the database is empty', () => {
+        return TestServer.remoteAPI().getJSON('/api/build-requests/build-webkit').then((content) => {
             assert.equal(content['status'], 'TriggerableNotFound');
-            done();
-        }).catch(done);
+        });
     });
 
-    it('should return an empty list when there are no build requests', function (done) {
-        TestServer.database().connect().then(function () {
-            return TestServer.database().insert('build_triggerables', {name: 'build-webkit'});
-        }).then(function () {
+    it('should return an empty list when there are no build requests', () => {
+        return TestServer.database().insert('build_triggerables', {name: 'build-webkit'}).then(() => {
             return TestServer.remoteAPI().getJSON('/api/build-requests/build-webkit');
-        }).then(function (content) {
+        }).then((content) => {
             assert.equal(content['status'], 'OK');
             assert.deepEqual(content['buildRequests'], []);
             assert.deepEqual(content['commitSets'], []);
             assert.deepEqual(content['commits'], []);
             assert.deepEqual(Object.keys(content).sort(), ['buildRequests', 'commitSets', 'commits', 'status']);
-            done();
-        }).catch(done);
+        });
     });
 
-    it('should return build requets associated with a given triggerable with appropriate commits and commitSets', function (done) {
-        let db = TestServer.database();
-        db.connect().then(function () {
-            return MockData.addMockData(db);
-        }).then(function () {
+    it('should return build requets associated with a given triggerable with appropriate commits and commitSets', () => {
+        return MockData.addMockData(TestServer.database()).then(() => {
             return TestServer.remoteAPI().getJSONWithStatus('/api/build-requests/build-webkit');
-        }).then(function (content) {
+        }).then((content) => {
             assert.deepEqual(Object.keys(content).sort(), ['buildRequests', 'commitSets', 'commits', 'status']);
 
             assert.equal(content['commitSets'].length, 2);
@@ -89,17 +78,13 @@ describe('/api/build-requests', function () {
             assert.deepEqual(content['buildRequests'][3].commitSet, 402);
             assert.deepEqual(content['buildRequests'][3].status, 'pending');
             assert.deepEqual(content['buildRequests'][3].test, '200');
-            done();
-        }).catch(done);
+        });
     });
 
-    it('should support useLegacyIdResolution option', function (done) {
-        let db = TestServer.database();
-        db.connect().then(function () {
-            return MockData.addMockData(db);
-        }).then(function () {
+    it('should support useLegacyIdResolution option', () => {
+        return MockData.addMockData(TestServer.database()).then(() => {
             return TestServer.remoteAPI().getJSONWithStatus('/api/build-requests/build-webkit?useLegacyIdResolution=true');
-        }).then(function (content) {
+        }).then((content) => {
             assert.deepEqual(Object.keys(content).sort(), ['buildRequests', 'commitSets', 'commits', 'status']);
 
             assert.equal(content['commitSets'].length, 2);
@@ -147,19 +132,15 @@ describe('/api/build-requests', function () {
             assert.deepEqual(content['buildRequests'][3].commitSet, 402);
             assert.deepEqual(content['buildRequests'][3].status, 'pending');
             assert.deepEqual(content['buildRequests'][3].test, ['some test']);
-            done();
-        }).catch(done);
+        });
     });
 
-    it('should be fetchable by BuildRequest.fetchForTriggerable', function (done) {
-        let db = TestServer.database();
-        db.connect().then(function () {
-            return MockData.addMockData(db);
-        }).then(function () {
+    it('should be fetchable by BuildRequest.fetchForTriggerable', () => {
+        return MockData.addMockData(TestServer.database()).then(() => {
             return Manifest.fetch();
-        }).then(function () {
+        }).then(() => {
             return BuildRequest.fetchForTriggerable('build-webkit');
-        }).then(function (buildRequests) {
+        }).then((buildRequests) => {
             assert.equal(buildRequests.length, 4);
 
             let test = Test.findById(200);
@@ -241,48 +222,35 @@ describe('/api/build-requests', function () {
             let secondWebKitCommit = secondCommitSet.commitForRepository(webkit);
             assert.equal(secondWebKitCommit.revision(), '192736');
             assert.equal(+secondWebKitCommit.time(), 1448225325650);
-
-            done();
-        }).catch(done);
+        });
     });
 
-    it('should not include a build request if all requests in the same group had been completed', function (done) {
-        let db = TestServer.database();
-        db.connect().then(function () {
-            return MockData.addMockData(db, ['completed', 'completed', 'completed', 'completed']);
-        }).then(function () {
+    it('should not include a build request if all requests in the same group had been completed', () => {
+        return MockData.addMockData(TestServer.database(), ['completed', 'completed', 'completed', 'completed']).then(() => {
             return Manifest.fetch();
-        }).then(function () {
+        }).then(() => {
             return BuildRequest.fetchForTriggerable('build-webkit');
-        }).then(function (buildRequests) {
+        }).then((buildRequests) => {
             assert.equal(buildRequests.length, 0);
-            done();
-        }).catch(done);
+        });
     });
 
-    it('should not include a build request if all requests in the same group had been failed or cancled', function (done) {
-        let db = TestServer.database();
-        db.connect().then(function () {
-            return MockData.addMockData(db, ['failed', 'failed', 'canceled', 'canceled']);
-        }).then(function () {
+    it('should not include a build request if all requests in the same group had been failed or cancled', () => {
+        return MockData.addMockData(TestServer.database(), ['failed', 'failed', 'canceled', 'canceled']).then(() => {
             return Manifest.fetch();
-        }).then(function () {
+        }).then(() => {
             return BuildRequest.fetchForTriggerable('build-webkit');
-        }).then(function (buildRequests) {
+        }).then((buildRequests) => {
             assert.equal(buildRequests.length, 0);
-            done();
-        }).catch(done);
+        });
     });
 
-    it('should include all build requests of a test group if one of the reqeusts in the group had not been finished', function (done) {
-        let db = TestServer.database();
-        db.connect().then(function () {
-            return MockData.addMockData(db, ['completed', 'completed', 'scheduled', 'pending']);
-        }).then(function () {
+    it('should include all build requests of a test group if one of the reqeusts in the group had not been finished', () => {
+        return MockData.addMockData(TestServer.database(), ['completed', 'completed', 'scheduled', 'pending']).then(() => {
             return Manifest.fetch();
-        }).then(function () {
+        }).then(() => {
             return BuildRequest.fetchForTriggerable('build-webkit');
-        }).then(function (buildRequests) {
+        }).then((buildRequests) => {
             assert.equal(buildRequests.length, 4);
             assert.ok(buildRequests[0].hasFinished());
             assert.ok(buildRequests[0].hasStarted());
@@ -296,19 +264,15 @@ describe('/api/build-requests', function () {
             assert.ok(!buildRequests[3].hasFinished());
             assert.ok(!buildRequests[3].hasStarted());
             assert.ok(buildRequests[3].isPending());
-            done();
-        }).catch(done);
+        });
     });
 
-    it('should include all build requests of a test group if one of the reqeusts in the group is still running', function (done) {
-        let db = TestServer.database();
-        db.connect().then(function () {
-            return MockData.addMockData(db, ['completed', 'completed', 'completed', 'running']);
-        }).then(function () {
+    it('should include all build requests of a test group if one of the reqeusts in the group is still running', () => {
+        return MockData.addMockData(TestServer.database(), ['completed', 'completed', 'completed', 'running']).then(() => {
             return Manifest.fetch();
-        }).then(function () {
+        }).then(() => {
             return BuildRequest.fetchForTriggerable('build-webkit');
-        }).then(function (buildRequests) {
+        }).then((buildRequests) => {
             assert.equal(buildRequests.length, 4);
             assert.ok(buildRequests[0].hasFinished());
             assert.ok(buildRequests[0].hasStarted());
@@ -322,19 +286,16 @@ describe('/api/build-requests', function () {
             assert.ok(!buildRequests[3].hasFinished());
             assert.ok(buildRequests[3].hasStarted());
             assert.ok(!buildRequests[3].isPending());
-            done();
-        }).catch(done);
+        });
     });
 
-    it('should order build requests based on test group creation time and order', function (done) {
+    it('should order build requests based on test group creation time and order', () => {
         let db = TestServer.database();
-        db.connect().then(function () {
-            return Promise.all([MockData.addMockData(db), MockData.addAnotherMockTestGroup(db)]);
-        }).then(function () {
+        return Promise.all([MockData.addMockData(db), MockData.addAnotherMockTestGroup(db)]).then(() => {
             return Manifest.fetch();
-        }).then(function () {
+        }).then(() => {
             return BuildRequest.fetchForTriggerable('build-webkit');
-        }).then(function (buildRequests) {
+        }).then((buildRequests) => {
             assert.equal(buildRequests.length, 8);
             assert.equal(buildRequests[0].id(), 700);
             assert.equal(buildRequests[0].testGroupId(), 600);
@@ -361,19 +322,16 @@ describe('/api/build-requests', function () {
             assert.equal(buildRequests[7].id(), 713);
             assert.equal(buildRequests[7].testGroupId(), 601);
             assert.strictEqual(buildRequests[7].order(), 3);
-            done();
-        }).catch(done);
+        });
     });
 
-    it('should place build requests created by user before automatically created ones', function (done) {
+    it('should place build requests created by user before automatically created ones', () => {
         let db = TestServer.database();
-        db.connect().then(function () {
-            return Promise.all([MockData.addMockData(db), MockData.addAnotherMockTestGroup(db, null, 'rniwa')]);
-        }).then(function () {
+        return Promise.all([MockData.addMockData(db), MockData.addAnotherMockTestGroup(db, null, 'rniwa')]).then(() => {
             return Manifest.fetch();
-        }).then(function () {
+        }).then(() => {
             return BuildRequest.fetchForTriggerable('build-webkit');
-        }).then(function (buildRequests) {
+        }).then((buildRequests) => {
             assert.equal(buildRequests.length, 8);
             assert.equal(buildRequests[0].id(), 710);
             assert.equal(buildRequests[0].testGroupId(), 601);
@@ -400,7 +358,6 @@ describe('/api/build-requests', function () {
             assert.equal(buildRequests[7].id(), 703);
             assert.equal(buildRequests[7].testGroupId(), 600);
             assert.strictEqual(buildRequests[7].order(), 3);
-            done();
-        }).catch(done);
+        });
     });
 });
index 4c7c0066d5872e567f495aac98a592584c54443a..0ea94811777bde0f620d92e4465ad8a3f1cd1f80 100644 (file)
@@ -4,11 +4,10 @@ const assert = require('assert');
 
 const TestServer = require('./resources/test-server.js');
 const addSlaveForReport = require('./resources/common-operations.js').addSlaveForReport;
-const connectToDatabaseInEveryTest = require('./resources/common-operations.js').connectToDatabaseInEveryTest;
+const prepareServerTest = require('./resources/common-operations.js').prepareServerTest;
 
-describe("/api/commits/", () => {
-    TestServer.inject();
-    connectToDatabaseInEveryTest();
+describe("/api/commits/", function () {
+    prepareServerTest(this);
 
     const subversionCommits = {
         "slaveName": "someSlave",
index 7bd3ecc3ebac73953beaccea9b0198170a518100..6dfca5601e2acaff088eaa18c713602ea4a768ee 100644 (file)
@@ -6,19 +6,15 @@ require('../tools/js/v3-models.js');
 
 const MockData = require('./resources/mock-data.js');
 const TestServer = require('./resources/test-server.js');
+const prepareServerTest = require('./resources/common-operations.js').prepareServerTest;
 
 describe('/api/manifest', function () {
-    this.timeout(1000);
-    TestServer.inject();
+    prepareServerTest(this);
 
-    beforeEach(function () {
-        MockData.resetV3Models();
-    });
-
-    it("should generate an empty manifest when database is empty", function (done) {
-        TestServer.remoteAPI().getJSON('/api/manifest').then(function (manifest) {
+    it("should generate an empty manifest when database is empty", () => {
+        return TestServer.remoteAPI().getJSON('/api/manifest').then((manifest) => {
             assert.deepEqual(Object.keys(manifest).sort(), ['all', 'bugTrackers', 'builders', 'dashboard', 'dashboards',
-                'elapsedTime', 'metrics', 'repositories', 'siteTitle', 'status', 'summaryPages', 'tests', 'triggerables']);
+                'elapsedTime', 'fileUploadSizeLimit', 'metrics', 'repositories', 'siteTitle', 'status', 'summaryPages', 'tests', 'triggerables']);
 
             assert.equal(typeof(manifest.elapsedTime), 'number');
             delete manifest.elapsedTime;
@@ -35,20 +31,19 @@ describe('/api/manifest', function () {
                 tests: {},
                 triggerables: {},
                 summaryPages: [],
+                fileUploadSizeLimit: 0,
                 status: 'OK'
             });
-            done();
-        }).catch(done);
+        });
     });
 
     const bugzillaData = {id: 1, name: 'Bugzilla', bug_url: 'https://webkit.org/b/$number', new_bug_url: 'https://bugs.webkit.org/'};
     const radarData = {id: 2, name: 'Radar'};
 
-    it("should generate manifest with bug trackers without repositories", function (done) {
-        TestServer.database().connect();
-        TestServer.database().insert('bug_trackers', bugzillaData).then(function () {
+    it("should generate manifest with bug trackers without repositories", () => {
+        return TestServer.database().insert('bug_trackers', bugzillaData).then(() => {
             return TestServer.remoteAPI().getJSON('/api/manifest');
-        }).then(function (content) {
+        }).then((content) => {
             assert.deepEqual(content.bugTrackers, {1: {name: 'Bugzilla', bugUrl: 'https://webkit.org/b/$number',
                 newBugUrl: 'https://bugs.webkit.org/', repositories: null}});
 
@@ -58,15 +53,12 @@ describe('/api/manifest', function () {
             assert.equal(tracker.name(), 'Bugzilla');
             assert.equal(tracker.bugUrl(123), 'https://webkit.org/b/123');
             assert.equal(tracker.newBugUrl(), 'https://bugs.webkit.org/');
-
-            done();
-        }).catch(done);
+        });
     });
 
-    it("should generate manifest with bug trackers and repositories", function (done) {
+    it("should generate manifest with bug trackers and repositories", () => {
         let db = TestServer.database();
-        db.connect();
-        Promise.all([
+        return Promise.all([
             db.insert('bug_trackers', bugzillaData),
             db.insert('bug_trackers', radarData),
             db.insert('repositories', {id: 11, name: 'WebKit', url: 'https://trac.webkit.org/$1'}),
@@ -75,9 +67,9 @@ describe('/api/manifest', function () {
             db.insert('tracker_repositories', {tracker: bugzillaData.id, repository: 11}),
             db.insert('tracker_repositories', {tracker: radarData.id, repository: 9}),
             db.insert('tracker_repositories', {tracker: radarData.id, repository: 22}),
-        ]).then(function () {
+        ]).then(() => {
             return TestServer.remoteAPI().getJSON('/api/manifest');
-        }).then(function (content) {
+        }).then((content) => {
             let manifest = Manifest._didFetchManifest(content);
 
             let webkit = Repository.findById(11);
@@ -104,21 +96,18 @@ describe('/api/manifest', function () {
             assert(tracker);
             assert.equal(tracker.name(), 'Radar');
             assert.deepEqual(Repository.sortByName(tracker.repositories()), [osx, ios]);
-
-            done();
-        }).catch(done);
+        });
     });
 
-    it("should generate manifest with builders", function (done) {
+    it("should generate manifest with builders", () => {
         let db = TestServer.database();
-        db.connect();
-        Promise.all([
+        return Promise.all([
             db.insert('builders', {id: 1, name: 'SomeBuilder', password_hash: 'a',
                 build_url: 'https://build.webkit.org/builders/$builderName/build/$buildNumber'}),
             db.insert('builders', {id: 2, name: 'SomeOtherBuilder', password_hash: 'b'})
-        ]).then(function () {
+        ]).then(() => {
             return TestServer.remoteAPI().getJSON('/api/manifest');
-        }).then(function (content) {
+        }).then((content) => {
             assert.deepEqual(content.builders, {
                 '1': {name: 'SomeBuilder', buildUrl: 'https://build.webkit.org/builders/$builderName/build/$buildNumber'},
                 '2': {name: 'SomeOtherBuilder', buildUrl: null}
@@ -135,15 +124,12 @@ describe('/api/manifest', function () {
             assert(builder);
             assert.equal(builder.name(), 'SomeOtherBuilder');
             assert.equal(builder.urlForBuild(123), null);
-
-            done();
-        }).catch(done);
+        });
     });
 
-    it("should generate manifest with tests, metrics, and platforms", function (done) {
+    it("should generate manifest with tests, metrics, and platforms", () => {
         let db = TestServer.database();
-        db.connect();
-        Promise.all([
+        return Promise.all([
             db.insert('tests', {id: 1, name: 'SomeTest'}),
             db.insert('tests', {id: 2, name: 'SomeOtherTest'}),
             db.insert('tests', {id: 3, name: 'ChildTest', parent: 1}),
@@ -163,9 +149,9 @@ describe('/api/manifest', function () {
             db.insert('test_configurations', {id: 105, metric: 9, platform: 46, type: 'current'}),
             db.insert('test_configurations', {id: 106, metric: 5, platform: 23, type: 'current'}),
             db.insert('test_configurations', {id: 107, metric: 5, platform: 23, type: 'baseline'}),
-        ]).then(function () {
+        ]).then(() => {
             return TestServer.remoteAPI().getJSON('/api/manifest');
-        }).then(function (content) {
+        }).then((content) => {
             assert.deepEqual(content.tests, {
                 "1": {"name": "SomeTest", "parentId": null, "url": null},
                 "2": {"name": "SomeOtherTest", "parentId": null, "url": null},
@@ -271,15 +257,12 @@ describe('/api/manifest', function () {
             assert.equal(grandChildTest.metrics().length, 1);
             assert.equal(grandChildTest.metrics()[0].label(), 'Time');
             assert.equal(grandChildTest.metrics()[0].fullName(), 'SomeTest \u220B ChildTest \u220B GrandChild : Time');
-
-            done();
-        }).catch(done);
+        });
     });
 
-    it("should generate manifest with triggerables", function (done) {
+    it("should generate manifest with triggerables", () => {
         let db = TestServer.database();
-        db.connect();
-        Promise.all([
+        return Promise.all([
             db.insert('repositories', {id: 11, name: 'WebKit', url: 'https://trac.webkit.org/$1'}),
             db.insert('repositories', {id: 9, name: 'OS X'}),
             db.insert('repositories', {id: 101, name: 'WebKit', owner: 9, url: 'https://trac.webkit.org/$1'}),
@@ -305,9 +288,9 @@ describe('/api/manifest', function () {
             db.insert('triggerable_configurations', {triggerable: 200, test: 2, platform: 46}),
             db.insert('triggerable_configurations', {triggerable: 201, test: 1, platform: 23}),
             db.insert('triggerable_configurations', {triggerable: 201, test: 2, platform: 23}),
-        ]).then(function () {
+        ]).then(() => {
             return Manifest.fetch();
-        }).then(function () {
+        }).then(() => {
             let webkit = Repository.findById(11);
             assert.equal(webkit.name(), 'WebKit');
             assert.equal(webkit.urlForRevision(123), 'https://trac.webkit.org/123');
@@ -351,9 +334,7 @@ describe('/api/manifest', function () {
 
             assert.equal(Triggerable.findByTestConfiguration(someOtherTest, ios9iphone5s), iosTriggerable);
             assert.equal(Triggerable.findByTestConfiguration(childTest, ios9iphone5s), iosTriggerable);
-
-            done();
-        }).catch(done);
+        });
     });
 
 });
index 9e5a364493f180093c4b45ae8f099d87d290586a..588c472f2572f94b3ea59948150524d0f99826f4 100644 (file)
@@ -7,16 +7,10 @@ require('../tools/js/v3-models.js');
 const MockData = require('./resources/mock-data.js');
 const TestServer = require('./resources/test-server.js');
 const addBuilderForReport = require('./resources/common-operations.js').addBuilderForReport;
-const connectToDatabaseInEveryTest = require('./resources/common-operations.js').connectToDatabaseInEveryTest;
+const prepareServerTest = require('./resources/common-operations.js').prepareServerTest;
 
 describe("/api/measurement-set", function () {
-    this.timeout(1000);
-    TestServer.inject();
-    connectToDatabaseInEveryTest();
-
-    beforeEach(function () {
-        MockData.resetV3Models();
-    });
+    prepareServerTest(this);
 
     function queryPlatformAndMetric(platformName, metricName)
     {
@@ -135,65 +129,61 @@ describe("/api/measurement-set", function () {
             },
         }}];
 
-    it("should reject when platform ID is missing", function (done) {
-        addBuilderForReport(reportWithBuildTime[0]).then(function () {
+    it("should reject when platform ID is missing", () => {
+        return addBuilderForReport(reportWithBuildTime[0]).then(() => {
             return TestServer.remoteAPI().postJSON('/api/report/', reportWithBuildTime);
-        }).then(function (response) {
+        }).then((response) => {
             assert.equal(response['status'], 'OK');
             return queryPlatformAndMetric('Mountain Lion', 'Time');
-        }).then(function (result) {
+        }).then((result) => {
             return TestServer.remoteAPI().getJSON(`/api/measurement-set/?metric=${result.metricId}`);
-        }).then(function (response) {
+        }).then((response) => {
             assert.equal(response['status'], 'AmbiguousRequest');
-            done();
-        }).catch(done);
+        });
     });
 
-    it("should reject when metric ID is missing", function (done) {
-        addBuilderForReport(reportWithBuildTime[0]).then(function () {
+    it("should reject when metric ID is missing", () => {
+        return addBuilderForReport(reportWithBuildTime[0]).then(() => {
             return TestServer.remoteAPI().postJSON('/api/report/', reportWithBuildTime);
-        }).then(function (response) {
+        }).then((response) => {
             assert.equal(response['status'], 'OK');
             return queryPlatformAndMetric('Mountain Lion', 'Time');
-        }).then(function (result) {
+        }).then((result) => {
             return TestServer.remoteAPI().getJSON(`/api/measurement-set/?platform=${result.platformId}`);
-        }).then(function (response) {
+        }).then((response) => {
             assert.equal(response['status'], 'AmbiguousRequest');
-            done();
-        }).catch(done);
+        });
     });
 
-    it("should reject an invalid platform name", function (done) {
-        addBuilderForReport(reportWithBuildTime[0]).then(function () {
+    it("should reject an invalid platform name", () => {
+        return addBuilderForReport(reportWithBuildTime[0]).then(() => {
             return TestServer.remoteAPI().postJSON('/api/report/', reportWithBuildTime);
-        }).then(function (response) {
+        }).then((response) => {
             assert.equal(response['status'], 'OK');
             return queryPlatformAndMetric('Mountain Lion', 'Time');
-        }).then(function (result) {
+        }).then((result) => {
             return TestServer.remoteAPI().getJSON(`/api/measurement-set/?platform=${result.platformId}a&metric=${result.metricId}`);
-        }).then(function (response) {
+        }).then((response) => {
             assert.equal(response['status'], 'InvalidPlatform');
-            done();
-        }).catch(done);
+        });
     });
 
-    it("should reject an invalid metric name", function (done) {
-        addBuilderForReport(reportWithBuildTime[0]).then(function () {
+    it("should reject an invalid metric name", () => {
+        return addBuilderForReport(reportWithBuildTime[0]).then(() => {
             return TestServer.remoteAPI().postJSON('/api/report/', reportWithBuildTime);
-        }).then(function (response) {
+        }).then((response) => {
             assert.equal(response['status'], 'OK');
             return queryPlatformAndMetric('Mountain Lion', 'Time');
-        }).then(function (result) {
+        }).then((result) => {
             return TestServer.remoteAPI().getJSON(`/api/measurement-set/?platform=${result.platformId}&metric=${result.metricId}b`);
-        }).then(function (response) {
+        }).then((response) => {
             assert.equal(response['status'], 'InvalidMetric');
-            done();
-        }).catch(done);
+        });
     });
 
-    it("should be able to return an empty report", function (done) {
+    it("should return 404 when the report is empty", () => {
         const db = TestServer.database();
-        Promise.all([
+        return Promise.all([
             db.insert('tests', {id: 1, name: 'SomeTest'}),
             db.insert('tests', {id: 2, name: 'SomeOtherTest'}),
             db.insert('tests', {id: 3, name: 'ChildTest', parent: 1}),
@@ -213,25 +203,24 @@ describe("/api/measurement-set", function () {
             db.insert('test_configurations', {id: 105, metric: 9, platform: 46, type: 'current'}),
             db.insert('test_configurations', {id: 106, metric: 5, platform: 23, type: 'current'}),
             db.insert('test_configurations', {id: 107, metric: 5, platform: 23, type: 'baseline'}),
-        ]).then(function () {
-            return TestServer.remoteAPI().getJSONWithStatus(`/api/measurement-set/?platform=46&metric=5`).then(function (response) {
-                assert.equal(response.statusCode, 404);
-            }, function (error) {
+        ]).then(() => {
+            return TestServer.remoteAPI().getJSONWithStatus(`/api/measurement-set/?platform=46&metric=5`).then((response) => {
+                assert(false);
+            }, (error) => {
                 assert.equal(error, 404);
-                done();
             });
-        }).catch(done);
+        });
     });
 
-    it("should be able to retrieve a reported value", function (done) {
-        addBuilderForReport(reportWithBuildTime[0]).then(function () {
+    it("should be able to retrieve a reported value", () => {
+        return addBuilderForReport(reportWithBuildTime[0]).then(() => {
             return TestServer.remoteAPI().postJSON('/api/report/', reportWithBuildTime);
-        }).then(function (response) {
+        }).then((response) => {
             assert.equal(response['status'], 'OK');
             return queryPlatformAndMetric('Mountain Lion', 'Time');
-        }).then(function (result) {
+        }).then((result) => {
             return TestServer.remoteAPI().getJSONWithStatus(`/api/measurement-set/?platform=${result.platformId}&metric=${result.metricId}`);
-        }).then(function (response) {
+        }).then((response) => {
             const buildTime = +(new Date(reportWithBuildTime[0]['buildTime']));
 
             assert.deepEqual(Object.keys(response).sort(),
@@ -248,7 +237,7 @@ describe("/api/measurement-set", function () {
 
             assert.deepEqual(Object.keys(response['configurations']), ['current']);
 
-            var currentRows = response['configurations']['current'];
+            const currentRows = response['configurations']['current'];
             assert.equal(currentRows.length, 1);
             assert.equal(currentRows[0].length, response['formatMap'].length);
             assert.deepEqual(format(response['formatMap'], currentRows[0]), {
@@ -261,17 +250,16 @@ describe("/api/measurement-set", function () {
                 commitTime: buildTime,
                 buildTime: buildTime,
                 buildNumber: '123'});
-            done();
-        }).catch(done);
+        });
     });
 
-    it("should return return the right IDs for measurement, build, and builder", function (done) {
-        addBuilderForReport(reportWithBuildTime[0]).then(function () {
+    it("should return return the right IDs for measurement, build, and builder", () => {
+        return addBuilderForReport(reportWithBuildTime[0]).then(() => {
             return TestServer.remoteAPI().postJSON('/api/report/', reportWithBuildTime);
-        }).then(function (response) {
+        }).then((response) => {
             assert.equal(response['status'], 'OK');
             return queryPlatformAndMetric('Mountain Lion', 'Time');
-        }).then(function (result) {
+        }).then((result) => {
             const db = TestServer.database();
             return Promise.all([
                 db.selectAll('test_runs'),
@@ -279,7 +267,7 @@ describe("/api/measurement-set", function () {
                 db.selectAll('builders'),
                 TestServer.remoteAPI().getJSONWithStatus(`/api/measurement-set/?platform=${result.platformId}&metric=${result.metricId}`),
             ]);
-        }).then(function (result) {
+        }).then((result) => {
             const runs = result[0];
             const builds = result[1];
             const builders = result[2];
@@ -299,23 +287,8 @@ describe("/api/measurement-set", function () {
             assert.equal(measurement[response['formatMap'].indexOf('id')], measurementId);
             assert.equal(measurement[response['formatMap'].indexOf('build')], buildId);
             assert.equal(measurement[response['formatMap'].indexOf('builder')], builderId);
-
-            done();
-        }).catch(done);
-    });
-
-    function postReports(reports, callback)
-    {
-        if (!reports.length)
-            return callback();
-
-        postJSON('/api/report/', reports[0], function (response) {
-            assert.equal(response.statusCode, 200);
-            assert.equal(JSON.parse(response.responseText)['status'], 'OK');
-
-            postReports(reports.slice(1), callback);
         });
-    }
+    });
 
     function queryPlatformAndMetricWithRepository(platformName, metricName, repositoryName)
     {
@@ -324,24 +297,22 @@ describe("/api/measurement-set", function () {
             db.selectFirstRow('platforms', {name: platformName}),
             db.selectFirstRow('test_metrics', {name: metricName}),
             db.selectFirstRow('repositories', {name: repositoryName}),
-        ]).then(function (result) {
-            return {platformId: result[0]['id'], metricId: result[1]['id'], repositoryId: result[2]['id']};
-        });
+        ]).then((result) => ({platformId: result[0]['id'], metricId: result[1]['id'], repositoryId: result[2]['id']}));
     }
 
-    it("should order results by commit time", function (done) {
+    it("should order results by commit time", () => {
         const remote = TestServer.remoteAPI();
         let repositoryId;
-        addBuilderForReport(reportWithBuildTime[0]).then(function () {
+        return addBuilderForReport(reportWithBuildTime[0]).then(() => {
             return remote.postJSON('/api/report/', reportWithBuildTime);
-        }).then(function () {
+        }).then(() => {
             return remote.postJSON('/api/report/', reportWithRevision);
-        }).then(function () {
+        }).then(() => {
             return queryPlatformAndMetricWithRepository('Mountain Lion', 'Time', 'WebKit');
-        }).then(function (result) {
+        }).then((result) => {
             repositoryId = result.repositoryId;
             return remote.getJSONWithStatus(`/api/measurement-set/?platform=${result.platformId}&metric=${result.metricId}`);
-        }).then(function (response) {
+        }).then((response) => {
             const currentRows = response['configurations']['current'];
             const buildTime = +(new Date(reportWithBuildTime[0]['buildTime']));
             const revisionTime = +(new Date(reportWithRevision[0]['revisions']['WebKit']['timestamp']));
@@ -368,14 +339,13 @@ describe("/api/measurement-set", function () {
                 commitTime: buildTime,
                 buildTime: buildTime,
                 buildNumber: '123' });
-            done();
-        }).catch(done);
+        });
     });
 
-    it("should order results by build time when commit times are missing", function (done) {
+    it("should order results by build time when commit times are missing", () => {
         const remote = TestServer.remoteAPI();
         let repositoryId;
-        addBuilderForReport(reportWithBuildTime[0]).then(() => {
+        return addBuilderForReport(reportWithBuildTime[0]).then(() => {
             const db = TestServer.database();
             return Promise.all([
                 db.insert('repositories', {'id': 1, 'name': 'macOS'}),
@@ -396,7 +366,7 @@ describe("/api/measurement-set", function () {
                 "platform": "Sierra",
                 "tests": { "Test": {"metrics": {"Time": { "baseline": [1, 2, 3, 4, 5] } } } },
             }]);
-        }).then(function () {
+        }).then(() => {
             return remote.postJSON('/api/report/', [{
                 "buildNumber": "1002",
                 "buildTime": '2017-01-19 19:46:37',
@@ -410,11 +380,11 @@ describe("/api/measurement-set", function () {
                 "platform": "Sierra",
                 "tests": { "Test": {"metrics": {"Time": { "baseline": [5, 6, 7, 8, 9] } } } },
             }]);
-        }).then(function () {
+        }).then(() => {
             return queryPlatformAndMetricWithRepository('Sierra', 'Time', 'macOS');
-        }).then(function (result) {
+        }).then((result) => {
             return remote.getJSONWithStatus(`/api/measurement-set/?platform=${result.platformId}&metric=${result.metricId}`);
-        }).then(function (response) {
+        }).then((response) => {
             const currentRows = response['configurations']['baseline'];
             assert.equal(currentRows.length, 2);
             assert.deepEqual(format(response['formatMap'], currentRows[0]), {
@@ -437,105 +407,97 @@ describe("/api/measurement-set", function () {
                 commitTime: +Date.UTC(2017, 0, 19, 19, 46, 37),
                 buildTime: +Date.UTC(2017, 0, 19, 19, 46, 37),
                 buildNumber: '1002' });
-            done();
-        }).catch(done);
+        });
     });
 
     function buildNumbers(parsedResult, config)
     {
-        return parsedResult['configurations'][config].map(function (row) {
-            return format(parsedResult['formatMap'], row)['buildNumber'];
-        });
+        return parsedResult['configurations'][config].map((row) => format(parsedResult['formatMap'], row)['buildNumber']);
     }
 
-    it("should include one data point after the current time range", function (done) {
+    it("should include one data point after the current time range", () => {
         const remote = TestServer.remoteAPI();
-        addBuilderForReport(reportWithBuildTime[0]).then(function () {
+        return addBuilderForReport(reportWithBuildTime[0]).then(() => {
             return remote.postJSON('/api/report/', reportWithAncentRevision);
-        }).then(function () {
+        }).then(() => {
             return remote.postJSON('/api/report/', reportWithNewRevision);
-        }).then(function () {
+        }).then(() => {
             return queryPlatformAndMetric('Mountain Lion', 'Time');
-        }).then(function (result) {
+        }).then((result) => {
             return remote.getJSONWithStatus(`/api/measurement-set/?platform=${result.platformId}&metric=${result.metricId}`);
-        }).then(function (response) {
+        }).then((response) => {
             assert.equal(response['status'], 'OK');
             assert.equal(response['clusterCount'], 2, 'should have two clusters');
             assert.deepEqual(buildNumbers(response, 'current'),
                 [reportWithAncentRevision[0]['buildNumber'], reportWithNewRevision[0]['buildNumber']]);
-            done();
-        }).catch(done);
+        });
     });
 
-    it("should always include one old data point before the current time range", function (done) {
+    it("should always include one old data point before the current time range", () => {
         const remote = TestServer.remoteAPI();
-        addBuilderForReport(reportWithBuildTime[0]).then(function () {
+        return addBuilderForReport(reportWithBuildTime[0]).then(() => {
             return remote.postJSON('/api/report/', reportWithBuildTime);
-        }).then(function () {
+        }).then(() => {
             return remote.postJSON('/api/report/', reportWithAncentRevision);
-        }).then(function () {
+        }).then(() => {
             return queryPlatformAndMetric('Mountain Lion', 'Time');
-        }).then(function (result) {
+        }).then((result) => {
             return remote.getJSONWithStatus(`/api/measurement-set/?platform=${result.platformId}&metric=${result.metricId}`);
-        }).then(function (response) {
+        }).then((response) => {
             assert.equal(response['clusterCount'], 2, 'should have two clusters');
             let currentRows = response['configurations']['current'];
             assert.equal(currentRows.length, 2, 'should contain two data points');
             assert.deepEqual(buildNumbers(response, 'current'), [reportWithAncentRevision[0]['buildNumber'], reportWithBuildTime[0]['buildNumber']]);
-            done();
-        }).catch(done);
+        });
     });
 
-    it("should create cached results", function (done) {
+    it("should create cached results", () => {
         const remote = TestServer.remoteAPI();
         let cachePrefix;
-        addBuilderForReport(reportWithBuildTime[0]).then(function () {
+        return addBuilderForReport(reportWithBuildTime[0]).then(() => {
             return remote.postJSON('/api/report/', reportWithAncentRevision);
-        }).then(function () {
+        }).then(() => {
             return remote.postJSON('/api/report/', reportWithRevision);
-        }).then(function () {
+        }).then(() => {
             return remote.postJSON('/api/report/', reportWithNewRevision);
-        }).then(function () {
+        }).then(() => {
             return queryPlatformAndMetric('Mountain Lion', 'Time');
-        }).then(function (result) {
+        }).then((result) => {
             cachePrefix = '/data/measurement-set-' + result.platformId + '-' + result.metricId;
             return remote.getJSONWithStatus(`/api/measurement-set/?platform=${result.platformId}&metric=${result.metricId}`);
-        }).then(function (newResult) {
-            return remote.getJSONWithStatus(`${cachePrefix}.json`).then(function (cachedResult) {
+        }).then((newResult) => {
+            return remote.getJSONWithStatus(`${cachePrefix}.json`).then((cachedResult) => {
                 assert.deepEqual(newResult, cachedResult);
                 return remote.getJSONWithStatus(`${cachePrefix}-${cachedResult['startTime']}.json`);
-            }).then(function (oldResult) {
-                var oldBuildNumbers = buildNumbers(oldResult, 'current');
-                var newBuildNumbers = buildNumbers(newResult, 'current');
+            }).then((oldResult) => {
+                const oldBuildNumbers = buildNumbers(oldResult, 'current');
+                const newBuildNumbers = buildNumbers(newResult, 'current');
                 assert(oldBuildNumbers.length >= 2, 'The old cluster should contain at least two data points');
                 assert(newBuildNumbers.length >= 2, 'The new cluster should contain at least two data points');
                 assert.deepEqual(oldBuildNumbers.slice(oldBuildNumbers.length - 2), newBuildNumbers.slice(0, 2),
                     'Two conseqcutive clusters should share two data points');
-                done();
             });
-        }).catch(done);
+        });
     });
 
-    it("should use lastModified timestamp identical to that in the manifest file", function (done) {
+    it("should use lastModified timestamp identical to that in the manifest file", () => {
         const remote = TestServer.remoteAPI();
-        addBuilderForReport(reportWithBuildTime[0]).then(function () {
+        return addBuilderForReport(reportWithBuildTime[0]).then(() => {
             return remote.postJSON('/api/report/', reportWithRevision);
-        }).then(function () {
+        }).then(() => {
             return queryPlatformAndMetric('Mountain Lion', 'Time');
-        }).then(function (result) {
+        }).then((result) => {
             return remote.getJSONWithStatus(`/api/measurement-set/?platform=${result.platformId}&metric=${result.metricId}`);
-        }).then(function (primaryCluster) {
-            return remote.getJSONWithStatus('/api/manifest').then(function (content) {
+        }).then((primaryCluster) => {
+            return remote.getJSONWithStatus('/api/manifest').then((content) => {
                 const manifest = Manifest._didFetchManifest(content);
 
                 const platform = Platform.findByName('Mountain Lion');
                 assert.equal(Metric.all().length, 1);
                 const metric = Metric.all()[0];
                 assert.equal(platform.lastModified(metric), primaryCluster['lastModified']);
-
-                done();
             });
-        }).catch(done);
+        });
     });
 
 });
index cfd39a2dfaf6c4850d1a5e747cd8aa9f61a91ee4..f1ad761b6059f81435bf583448609e79d176e5ed 100644 (file)
@@ -4,12 +4,10 @@ const assert = require('assert');
 
 const TestServer = require('./resources/test-server.js');
 const addSlaveForReport = require('./resources/common-operations.js').addSlaveForReport;
-const connectToDatabaseInEveryTest = require('./resources/common-operations.js').connectToDatabaseInEveryTest;
+const prepareServerTest = require('./resources/common-operations.js').prepareServerTest;
 
 describe("/api/report-commits/", function () {
-    this.timeout(1000);
-    TestServer.inject();
-    connectToDatabaseInEveryTest();
+    prepareServerTest(this);
 
     const emptyReport = {
         "slaveName": "someSlave",
@@ -78,54 +76,49 @@ describe("/api/report-commits/", function () {
         ]
     }
 
-    it("should reject error when slave name is missing", function (done) {
-        TestServer.remoteAPI().postJSON('/api/report-commits/', {}).then(function (response) {
+    it("should reject error when slave name is missing", () => {
+        return TestServer.remoteAPI().postJSON('/api/report-commits/', {}).then((response) => {
             assert.equal(response['status'], 'MissingSlaveName');
-            done();
-        }).catch(done);
+        });
     });
 
-    it("should reject when there are no slaves", function (done) {
-        TestServer.remoteAPI().postJSON('/api/report-commits/', emptyReport).then(function (response) {
+    it("should reject when there are no slaves", () => {
+        return TestServer.remoteAPI().postJSON('/api/report-commits/', emptyReport).then((response) => {
             assert.equal(response['status'], 'SlaveNotFound');
             return TestServer.database().selectAll('commits');
-        }).then(function (rows) {
+        }).then((rows) => {
             assert.equal(rows.length, 0);
-            done();
-        }).catch(done);
+        });
     });
 
-    it("should accept an empty report", function (done) {
-        addSlaveForReport(emptyReport).then(function () {
+    it("should accept an empty report", () => {
+        return addSlaveForReport(emptyReport).then(() => {
             return TestServer.remoteAPI().postJSON('/api/report-commits/', emptyReport);
-        }).then(function (response) {
+        }).then((response) => {
             assert.equal(response['status'], 'OK');
-            done();
-        }).catch(done);
+        });
     });
 
-    it("should add a missing repository", function (done) {
-        const db = TestServer.database();
-        addSlaveForReport(subversionCommit).then(function () {
+    it("should add a missing repository", () => {
+        return addSlaveForReport(subversionCommit).then(() => {
             return TestServer.remoteAPI().postJSON('/api/report-commits/', subversionCommit);
-        }).then(function (response) {
+        }).then((response) => {
             assert.equal(response['status'], 'OK');
-            return db.selectAll('repositories');
-        }).then(function (rows) {
+            return TestServer.database().selectAll('repositories');
+        }).then((rows) => {
             assert.equal(rows.length, 1);
             assert.equal(rows[0]['name'], subversionCommit.commits[0]['repository']);
-            done();
-        }).catch(done);
+        });
     });
 
-    it("should store a commit from a valid slave", function (done) {
-        const db = TestServer.database();
-        addSlaveForReport(subversionCommit).then(function () {
+    it("should store a commit from a valid slave", () => {
+        return addSlaveForReport(subversionCommit).then(() => {
             return TestServer.remoteAPI().postJSON('/api/report-commits/', subversionCommit);
-        }).then(function (response) {
+        }).then((response) => {
             assert.equal(response['status'], 'OK');
+            const db = TestServer.database();
             return Promise.all([db.selectAll('commits'), db.selectAll('committers')]);
-        }).then(function (result) {
+        }).then((result) => {
             let commits = result[0];
             let committers = result[1];
             let reportedData = subversionCommit.commits[0];
@@ -138,31 +131,28 @@ describe("/api/report-commits/", function () {
             assert.equal(commits[0]['committer'], committers[0]['id']);
             assert.equal(committers[0]['name'], reportedData['author']['name']);
             assert.equal(committers[0]['account'], reportedData['author']['account']);
-
-            done();
-        }).catch(done);
+        });
     });
 
-    it("should reject an invalid revision number", function (done) {
-        addSlaveForReport(subversionCommit).then(function () {
+    it("should reject an invalid revision number", () => {
+        return addSlaveForReport(subversionCommit).then(() => {
             return TestServer.remoteAPI().postJSON('/api/report-commits/', subversionInvalidCommit);
-        }).then(function (response) {
+        }).then((response) => {
             assert.equal(response['status'], 'InvalidRevision');
             return TestServer.database().selectAll('commits');
-        }).then(function (rows) {
+        }).then((rows) => {
             assert.equal(rows.length, 0);
-            done();
-        }).catch(done);
+        });
     });
 
-    it("should store two commits from a valid slave", function (done) {
-        const db = TestServer.database();
-        addSlaveForReport(subversionTwoCommits).then(function () {
+    it("should store two commits from a valid slave", () => {
+        return addSlaveForReport(subversionTwoCommits).then(() => {
             return TestServer.remoteAPI().postJSON('/api/report-commits/', subversionTwoCommits);
-        }).then(function (response) {
+        }).then((response) => {
             assert.equal(response['status'], 'OK');
+            const db = TestServer.database();
             return Promise.all([db.selectAll('commits'), db.selectAll('committers')]);
-        }).then(function (result) {
+        }).then((result) => {
             const commits = result[0];
             const committers = result[1];
             assert.equal(commits.length, 2);
@@ -185,38 +175,34 @@ describe("/api/report-commits/", function () {
             assert.equal(commits[1]['previous_commit'], commits[0]['id']);
             assert.equal(committers[1]['name'], reportedData['author']['name']);
             assert.equal(committers[1]['account'], reportedData['author']['account']);
-
-            done();
-        }).catch(done);
+        });
     });
 
-    it("should fail if previous commit is invalid", function (done) {
-        const db = TestServer.database();
-        addSlaveForReport(subversionInvalidPreviousCommit).then(function () {
+    it("should fail if previous commit is invalid", () => {
+        return addSlaveForReport(subversionInvalidPreviousCommit).then(() => {
             return TestServer.remoteAPI().postJSON('/api/report-commits/', subversionInvalidPreviousCommit);
-        }).then(function (response) {
+        }).then((response) => {
             assert.equal(response['status'], 'FailedToFindPreviousCommit');
-            return db.selectAll('commits');
-        }).then(function (result) {
+            return TestServer.database().selectAll('commits');
+        }).then((result) => {
             assert.equal(result.length, 0);
-            done();
-        }).catch(done);
+        });
     });
 
-    it("should update an existing commit if there is one", function (done) {
+    it("should update an existing commit if there is one", () => {
         const db = TestServer.database();
         const reportedData = subversionCommit.commits[0];
-        addSlaveForReport(subversionCommit).then(function () {
+        return addSlaveForReport(subversionCommit).then(() => {
             return Promise.all([
                 db.insert('repositories', {'id': 1, 'name': 'WebKit'}),
                 db.insert('commits', {'repository': 1, 'revision': reportedData['revision'], 'time': reportedData['time']})
             ]);
-        }).then(function () {
+        }).then(() => {
             return TestServer.remoteAPI().postJSON('/api/report-commits/', subversionCommit);
-        }).then(function (response) {
+        }).then((response) => {
             assert.equal(response['status'], 'OK');
             return Promise.all([db.selectAll('commits'), db.selectAll('committers')]);
-        }).then(function (result) {
+        }).then((result) => {
             const commits = result[0];
             const committers = result[1];
 
@@ -226,27 +212,25 @@ describe("/api/report-commits/", function () {
             assert.equal(commits[0]['committer'], committers[0]['id']);
             assert.equal(committers[0]['name'], reportedData['author']['name']);
             assert.equal(committers[0]['account'], reportedData['author']['account']);
-
-            done();
-        }).catch(done);
+        });
     });
 
-    it("should not update an unrelated commit", function (done) {
+    it("should not update an unrelated commit", () => {
         const db = TestServer.database();
         const firstData = subversionTwoCommits.commits[0];
         const secondData = subversionTwoCommits.commits[1];
-        addSlaveForReport(subversionCommit).then(function () {
+        return addSlaveForReport(subversionCommit).then(() => {
             return Promise.all([
                 db.insert('repositories', {'id': 1, 'name': 'WebKit'}),
                 db.insert('commits', {'id': 2, 'repository': 1, 'revision': firstData['revision'], 'time': firstData['time']}),
                 db.insert('commits', {'id': 3, 'repository': 1, 'revision': secondData['revision'], 'time': secondData['time']})
             ]);
-        }).then(function () {
+        }).then(() => {
             return TestServer.remoteAPI().postJSON('/api/report-commits/', subversionCommit);
-        }).then(function (response) {
+        }).then((response) => {
             assert.equal(response['status'], 'OK');
             return Promise.all([db.selectAll('commits'), db.selectAll('committers')]);
-        }).then(function (result) {
+        }).then((result) => {
             const commits = result[0];
             const committers = result[1];
 
@@ -261,30 +245,27 @@ describe("/api/report-commits/", function () {
             assert.equal(commits[1]['id'], 3);
             assert.equal(commits[1]['message'], null);
             assert.equal(commits[1]['committer'], null);
-
-            done();
-        }).catch(done);
+        });
     });
 
-    it("should update an existing committer if there is one", function (done) {
+    it("should update an existing committer if there is one", () => {
         const db = TestServer.database();
         const author = subversionCommit.commits[0]['author'];
-        addSlaveForReport(subversionCommit).then(function () {
+        return addSlaveForReport(subversionCommit).then(() => {
             return Promise.all([
                 db.insert('repositories', {'id': 1, 'name': 'WebKit'}),
                 db.insert('committers', {'repository': 1, 'account': author['account']}),
             ]);
-        }).then(function () {
+        }).then(() => {
             return TestServer.remoteAPI().postJSON('/api/report-commits/', subversionCommit);
-        }).then(function (response) {
+        }).then((response) => {
             assert.equal(response['status'], 'OK');
             return db.selectAll('committers');
-        }).then(function (committers) {
+        }).then((committers) => {
             assert.equal(committers.length, 1);
             assert.equal(committers[0]['name'], author['name']);
             assert.equal(committers[0]['account'], author['account']);
-            done();
-        }).catch(done);
+        });
     });
 
     const sameRepositoryNameInSubCommitAndMajorCommit = {
@@ -317,22 +298,20 @@ describe("/api/report-commits/", function () {
         ]
     }
 
-    it("should distinguish between repositories with the asme name but with a different owner.", function (done) {
-        const db = TestServer.database();
-        addSlaveForReport(sameRepositoryNameInSubCommitAndMajorCommit).then(function () {
+    it("should distinguish between repositories with the asme name but with a different owner.", () => {
+        return addSlaveForReport(sameRepositoryNameInSubCommitAndMajorCommit).then(() => {
             return TestServer.remoteAPI().postJSON('/api/report-commits/', sameRepositoryNameInSubCommitAndMajorCommit);
-        }).then(function (response) {
+        }).then((response) => {
             assert.equal(response['status'], 'OK');
-            return db.selectRows('repositories', {'name': 'WebKit'});
-        }).then(function (result) {
+            return TestServer.database().selectRows('repositories', {'name': 'WebKit'});
+        }).then((result) => {
             assert.equal(result.length, 2);
             let osWebKit = result[0];
             let webkitRepository = result[1];
             assert.notEqual(osWebKit.id, webkitRepository.id);
             assert.equal(osWebKit.name, webkitRepository.name);
             assert.equal(webkitRepository.owner, null);
-            done();
-        })
+        });
     });
 
     const systemVersionCommitWithSubcommits = {
@@ -359,11 +338,11 @@ describe("/api/report-commits/", function () {
         ]
     }
 
-    it("should accept inserting one commit with some sub commits", function (done) {
+    it("should accept inserting one commit with some sub commits", () => {
         const db = TestServer.database();
-        addSlaveForReport(systemVersionCommitWithSubcommits).then(function () {
+        return addSlaveForReport(systemVersionCommitWithSubcommits).then(() => {
             return TestServer.remoteAPI().postJSON('/api/report-commits/', systemVersionCommitWithSubcommits);
-        }).then(function (response) {
+        }).then((response) => {
             assert.equal(response['status'], 'OK');
             return Promise.all([db.selectRows('commits', {'revision': 'Sierra16D32'}),
                 db.selectRows('commits', {'message': 'WebKit Commit'}),
@@ -371,7 +350,7 @@ describe("/api/report-commits/", function () {
                 db.selectRows('repositories', {'name': 'OSX'}),
                 db.selectRows('repositories', {'name': "WebKit"}),
                 db.selectRows('repositories', {'name': 'JavaScriptCore'})])
-        }).then(function (result) {
+        }).then((result) => {
             assert.equal(result.length, 6);
 
             assert.equal(result[0].length, 1);
@@ -408,7 +387,7 @@ describe("/api/report-commits/", function () {
             return Promise.all([db.selectRows('commit_ownerships', {'owner': osxCommit.id, 'owned': webkitCommit.id}, {'sortBy': 'owner'}),
                 db.selectRows('commit_ownerships', {'owner': osxCommit.id, 'owned': jscCommit.id}, {'sortBy': 'owner'}),
                 db.selectRows('commits', {'repository': webkitRepository.id})]);
-        }).then(function (result) {
+        }).then((result) => {
             assert.equal(result.length, 3);
 
             assert.equal(result[0].length, 1);
@@ -420,8 +399,7 @@ describe("/api/report-commits/", function () {
             assert.notEqual(ownerCommitForJSCCommit, null);
 
             assert.equal(result[2].length, 1);
-            done();
-        }).catch(done);
+        });
     })
 
     const multipleSystemVersionCommitsWithSubcommits = {
@@ -465,11 +443,11 @@ describe("/api/report-commits/", function () {
         ]
     };
 
-    it("should accept inserting multiple commits with multiple sub-commits", function (done) {
+    it("should accept inserting multiple commits with multiple sub-commits", () => {
         const db = TestServer.database();
-        addSlaveForReport(multipleSystemVersionCommitsWithSubcommits).then(function () {
+        return addSlaveForReport(multipleSystemVersionCommitsWithSubcommits).then(() => {
             return TestServer.remoteAPI().postJSON('/api/report-commits/', multipleSystemVersionCommitsWithSubcommits);
-        }).then(function (response) {
+        }).then((response) => {
             assert.equal(response['status'], 'OK');
             return Promise.all([db.selectRows('commits', {'revision': 'Sierra16D32'}),
                 db.selectRows('commits', {'revision': 'Sierra16C67'}),
@@ -479,7 +457,7 @@ describe("/api/report-commits/", function () {
                 db.selectRows('repositories', {'name': 'OSX'}),
                 db.selectRows('repositories', {'name': "WebKit"}),
                 db.selectRows('repositories', {'name': 'JavaScriptCore'})])
-        }).then(function (result) {
+        }).then((result) => {
             assert.equal(result.length, 8);
 
             assert.equal(result[0].length, 1);
@@ -529,7 +507,7 @@ describe("/api/report-commits/", function () {
                 db.selectRows('commit_ownerships', {'owner': osxCommit0.id, 'owned': jscCommit0.id}, {'sortBy': 'owner'}),
                 db.selectRows('commit_ownerships', {'owner': osxCommit1.id, 'owned': jscCommit1.id}, {'sortBy': 'owner'}),
                 db.selectRows('commits', {'repository': webkitRepository.id})]);
-        }).then(function (result) {
+        }).then((result) => {
             assert.equal(result.length, 5);
 
             assert.equal(result[0].length, 1);
@@ -549,9 +527,7 @@ describe("/api/report-commits/", function () {
             assert.notEqual(ownerCommitForJSCCommit1, null);
 
             assert.equal(result[4].length, 1);
-
-            done();
-        }).catch(done);
+        });
     });
 
     const systemVersionCommitWithEmptySubcommits = {
@@ -568,14 +544,14 @@ describe("/api/report-commits/", function () {
         ]
     }
 
-    it("should accept inserting one commit with no sub commits", function (done) {
-        const db = TestServer.database();
-        addSlaveForReport(systemVersionCommitWithEmptySubcommits).then(function () {
+    it("should accept inserting one commit with no sub commits", () => {
+        return addSlaveForReport(systemVersionCommitWithEmptySubcommits).then(() => {
             return TestServer.remoteAPI().postJSON('/api/report-commits/', systemVersionCommitWithEmptySubcommits);
-        }).then(function (response) {
+        }).then((response) => {
             assert.equal(response['status'], 'OK');
+            const db = TestServer.database();
             return Promise.all([db.selectAll('commits'), db.selectAll('repositories'), db.selectAll('commit_ownerships', 'owner')]);
-        }).then(function (result) {
+        }).then((result) => {
             let commits = result[0];
             let repositories = result[1];
             let commit_ownerships = result[2];
@@ -584,8 +560,7 @@ describe("/api/report-commits/", function () {
             assert.equal(commits[0].repository, repositories[0].id);
             assert.equal(repositories[0].name, 'OSX');
             assert.equal(commit_ownerships.length, 0);
-            done();
-        }).catch(done);
+        });
     });
 
     const systemVersionCommitAndSubcommitWithTimestamp = {
@@ -608,13 +583,11 @@ describe("/api/report-commits/", function () {
         ]
     }
 
-    it("should reject inserting one commit with sub commits that contains timestamp", function (done) {
-        const db = TestServer.database();
-        addSlaveForReport(systemVersionCommitAndSubcommitWithTimestamp).then(function () {
+    it("should reject inserting one commit with sub commits that contains timestamp", () => {
+        return addSlaveForReport(systemVersionCommitAndSubcommitWithTimestamp).then(() => {
             return TestServer.remoteAPI().postJSON('/api/report-commits/', systemVersionCommitAndSubcommitWithTimestamp);
-        }).then(function (response) {
+        }).then((response) => {
             assert.equal(response['status'], 'SubCommitShouldNotContainTimestamp');
-            done();
-        }).catch(done);
+        });
     });
 });
index 0568c48c8aa959cdfc1f927823ba85d2411963c4..41740047538e08bbc8b0b58e24c75d7fdbd13927 100644 (file)
@@ -5,12 +5,10 @@ const assert = require('assert');
 const TestServer = require('./resources/test-server.js');
 const addBuilderForReport = require('./resources/common-operations.js').addBuilderForReport;
 const addSlaveForReport = require('./resources/common-operations.js').addSlaveForReport;
-const connectToDatabaseInEveryTest = require('./resources/common-operations.js').connectToDatabaseInEveryTest;
+const prepareServerTest = require('./resources/common-operations.js').prepareServerTest;
 
 describe("/api/report", function () {
-    this.timeout(1000);
-    TestServer.inject();
-    connectToDatabaseInEveryTest();
+    prepareServerTest(this);
 
     function emptyReport()
     {
@@ -56,36 +54,33 @@ describe("/api/report", function () {
         };
     }
 
-    it("should reject error when builder name is missing", function (done) {
-        TestServer.remoteAPI().postJSON('/api/report/', [{"buildTime": "2013-02-28T10:12:03.388304"}]).then(function (response) {
+    it("should reject error when builder name is missing", () => {
+        return TestServer.remoteAPI().postJSON('/api/report/', [{"buildTime": "2013-02-28T10:12:03.388304"}]).then((response) => {
             assert.equal(response['status'], 'MissingBuilderName');
-            done();
-        }).catch(done);
+        });
     });
 
-    it("should reject error when build time is missing", function (done) {
-        addBuilderForReport(emptyReport()).then(function () {
+    it("should reject error when build time is missing", () => {
+        return addBuilderForReport(emptyReport()).then(() => {
             return TestServer.remoteAPI().postJSON('/api/report/', [{"builderName": "someBuilder", "builderPassword": "somePassword"}]);
-        }).then(function (response) {
+        }).then((response) => {
             assert.equal(response['status'], 'MissingBuildTime');
-            done();
         });
     });
 
-    it("should reject when there are no builders", function (done) {
-        TestServer.remoteAPI().postJSON('/api/report/', [emptyReport()]).then(function (response) {
+    it("should reject when there are no builders", () => {
+        return TestServer.remoteAPI().postJSON('/api/report/', [emptyReport()]).then((response) => {
             assert.equal(response['status'], 'BuilderNotFound');
             assert.equal(response['failureStored'], false);
             assert.equal(response['processedRuns'], 0);
             return TestServer.database().selectAll('reports');
-        }).then(function (reports) {
+        }).then((reports) => {
             assert.equal(reports.length, 0);
-            done();
-        }).catch(done);
+        });
     });
 
-    it("should reject a report without a builder password", function (done) {
-        addBuilderForReport(emptyReport()).then(function () {
+    it("should reject a report without a builder password", () => {
+        return addBuilderForReport(emptyReport()).then(() => {
             var report = [{
                 "buildNumber": "123",
                 "buildTime": "2013-02-28T10:12:03.388304",
@@ -93,26 +88,25 @@ describe("/api/report", function () {
                 "tests": {},
                 "revisions": {}}];
             return TestServer.remoteAPI().postJSON('/api/report/', report);
-        }).then(function (response) {
+        }).then((response) => {
             assert.equal(response['status'], 'BuilderNotFound');
             assert.equal(response['failureStored'], false);
             assert.equal(response['processedRuns'], 0);
             return TestServer.database().selectAll('reports');
-        }).then(function (reports) {
+        }).then((reports) => {
             assert.equal(reports.length, 0);
-            done();
-        }).catch(done);
+        });
     });
 
-    it("should store a report from a valid builder", function (done) {
-        addBuilderForReport(emptyReport()).then(function () {
+    it("should store a report from a valid builder", () => {
+        return addBuilderForReport(emptyReport()).then(() => {
             return TestServer.remoteAPI().postJSON('/api/report/', [emptyReport()]);
-        }).then(function (response) {
+        }).then((response) => {
             assert.equal(response['status'], 'OK');
             assert.equal(response['failureStored'], false);
             assert.equal(response['processedRuns'], 1);
             return TestServer.database().selectAll('reports');
-        }).then(function (reports) {
+        }).then((reports) => {
             assert.equal(reports.length, 1);
             const submittedContent = emptyReport();
             const storedContent = JSON.parse(reports[0]['content']);
@@ -121,24 +115,22 @@ describe("/api/report", function () {
             delete submittedContent['tests'];
             delete storedContent['tests'];
             assert.deepEqual(storedContent, submittedContent);
-
-            done();
-        }).catch(done);
+        });
     });
 
-    it("should treat the slave password as the builder password if there is no matching slave", function (done) {
+    it("should treat the slave password as the builder password if there is no matching slave", () => {
         let report = emptyReport();
         report['slavePassword'] = report['builderPassword'];
         delete report['builderPassword'];
 
-        addSlaveForReport(report).then(function () {
+        return addSlaveForReport(report).then(() => {
             return TestServer.remoteAPI().postJSON('/api/report/', [report]);
-        }).then(function (response) {
+        }).then((response) => {
             assert.equal(response['status'], 'OK');
             assert.equal(response['failureStored'], false);
             assert.equal(response['processedRuns'], 1);
             return TestServer.database().selectAll('reports');
-        }).then(function (reports) {
+        }).then((reports) => {
             assert.equal(reports.length, 1);
             const storedContent = JSON.parse(reports[0]['content']);
 
@@ -146,20 +138,18 @@ describe("/api/report", function () {
             delete report['tests'];
             delete storedContent['tests'];
             assert.deepEqual(storedContent, report);
-
-            done();
-        }).catch(done);
+        });
     });
 
-    it("should store a report from a valid slave", function (done) {
-        addSlaveForReport(emptySlaveReport()).then(function () {
+    it("should store a report from a valid slave", () => {
+        return addSlaveForReport(emptySlaveReport()).then(() => {
             return TestServer.remoteAPI().postJSON('/api/report/', [emptySlaveReport()]);
-        }).then(function (response) {
+        }).then((response) => {
             assert.equal(response['status'], 'OK');
             assert.equal(response['failureStored'], false);
             assert.equal(response['processedRuns'], 1);
             return TestServer.database().selectAll('reports');
-        }).then(function (reports) {
+        }).then((reports) => {
             assert.equal(reports.length, 1);
             const submittedContent = emptySlaveReport();
             const storedContent = JSON.parse(reports[0]['content']);
@@ -168,88 +158,81 @@ describe("/api/report", function () {
             delete submittedContent['tests'];
             delete storedContent['tests'];
             assert.deepEqual(storedContent, submittedContent);
-
-            done();
-        }).catch(done);
+        });
     });
 
-    it("should store the builder name but not the builder password", function (done) {
-        addBuilderForReport(emptyReport()).then(function () {
+    it("should store the builder name but not the builder password", () => {
+        return addBuilderForReport(emptyReport()).then(() => {
             return TestServer.remoteAPI().postJSON('/api/report/', [emptyReport()]);
-        }).then(function (response) {
+        }).then((response) => {
             return TestServer.database().selectAll('reports');
-        }).then(function (reports) {
+        }).then((reports) => {
             assert.equal(reports.length, 1);
             const storedContent = JSON.parse(reports[0]['content']);
             assert.equal(storedContent['builderName'], emptyReport()['builderName']);
             assert(!('builderPassword' in storedContent));
-            done();
-        }).catch(done);
+        });
     });
 
-    it("should add a slave if there isn't one and the report was authenticated by a builder", function (done) {
-        addBuilderForReport(emptyReport()).then(function () {
+    it("should add a slave if there isn't one and the report was authenticated by a builder", () => {
+        return addBuilderForReport(emptyReport()).then(() => {
             return TestServer.remoteAPI().postJSON('/api/report/', [emptyReport()]);
-        }).then(function (response) {
+        }).then((response) => {
             return TestServer.database().selectAll('build_slaves');
-        }).then(function (slaves) {
+        }).then((slaves) => {
             assert.equal(slaves.length, 1);
             assert.equal(slaves[0]['name'], emptyReport()['slaveName']);
-            done();
-        }).catch(done);
+        });
     });
 
-    it("should add a builder if there isn't one and the report was authenticated by a slave", function (done) {
-        addSlaveForReport(emptySlaveReport()).then(function () {
+    it("should add a builder if there isn't one and the report was authenticated by a slave", () => {
+        return addSlaveForReport(emptySlaveReport()).then(() => {
             return TestServer.remoteAPI().postJSON('/api/report/', [emptySlaveReport()]);
-        }).then(function (response) {
+        }).then((response) => {
             return TestServer.database().selectAll('builders');
-        }).then(function (builders) {
+        }).then((builders) => {
             assert.equal(builders.length, 1);
             assert.equal(builders[0]['name'], emptyReport()['builderName']);
-            done();
-        }).catch(done);
+        });
     });
 
-    it("should add a build", function (done) {
-        addBuilderForReport(emptyReport()).then(function () {
+    it("should add a build", () => {
+        return addBuilderForReport(emptyReport()).then(() => {
             return TestServer.remoteAPI().postJSON('/api/report/', [emptyReport()]);
-        }).then(function () {
+        }).then(() => {
             return TestServer.database().selectAll('builds');
-        }).then(function (builds) {
+        }).then((builds) => {
             assert.strictEqual(builds[0]['number'], 123);
-            done();
-        }).catch(done);
+        });
     });
 
-    it("should add the platform", function (done) {
-        addBuilderForReport(emptyReport()).then(function () {
+    it("should add the platform", () => {
+        return addBuilderForReport(emptyReport()).then(() => {
             return TestServer.remoteAPI().postJSON('/api/report/', [emptyReport()]);
-        }).then(function () {
+        }).then(() => {
             return TestServer.database().selectAll('platforms');
-        }).then(function (platforms) {
+        }).then((platforms) => {
             assert.equal(platforms.length, 1);
             assert.equal(platforms[0]['name'], 'Mountain Lion');
-            done();
-        }).catch(done);
+        });
     });
 
-    it("should add repositories and build revisions", function (done) {
-        addBuilderForReport(emptyReport()).then(function () {
+    it("should add repositories and build revisions", () => {
+        return addBuilderForReport(emptyReport()).then(() => {
             return TestServer.remoteAPI().postJSON('/api/report/', [emptyReport()]);
-        }).then(function (response) {
+        }).then((response) => {
             const db = TestServer.database();
             return Promise.all([
                 db.selectAll('repositories'),
                 db.selectAll('commits'),
                 db.selectAll('build_commits', 'build_commit'),
             ]);
-        }).then(function (result) {
+        }).then((result) => {
             const repositories = result[0];
             const commits = result[1];
             const buildCommitsRelations = result[2];
             assert.equal(repositories.length, 2);
-            assert.deepEqual(repositories.map(function (row) { return row['name']; }).sort(), ['OS X', 'WebKit']);
+            assert.deepEqual(repositories.map((row) => { return row['name']; }).sort(), ['OS X', 'WebKit']);
 
             assert.equal(commits.length, 2);
             assert.equal(buildCommitsRelations.length, 2);
@@ -269,58 +252,55 @@ describe("/api/report", function () {
             assert.equal(repositoryNameToRevisionRow['WebKit']['revision'], '141977');
             assert.equal(repositoryNameToRevisionRow['WebKit']['time'].toString(),
                 new Date('2013-02-06 08:55:20.9').toString());
-            done();
-        }).catch(done);
+        });
     });
 
-    it("should not create a duplicate build for the same build number if build times are close", function (done) {
-        let firstReport = emptyReport();
+    it("should not create a duplicate build for the same build number if build times are close", () => {
+        const firstReport = emptyReport();
         firstReport['buildTime'] = '2013-02-28T10:12:04';
-        let secondReport = emptyReport();
+        const secondReport = emptyReport();
         secondReport['buildTime'] = '2013-02-28T10:22:03';
 
-        addBuilderForReport(emptyReport()).then(function () {
+        return addBuilderForReport(emptyReport()).then(() => {
             return TestServer.remoteAPI().postJSON('/api/report/', [firstReport]);
-        }).then(function (response) {
+        }).then((response) => {
             assert.equal(response['status'], 'OK');
             return TestServer.database().selectAll('builds');
-        }).then(function (builds) {
+        }).then((builds) => {
             assert.equal(builds.length, 1);
             return TestServer.remoteAPI().postJSON('/api/report/', [secondReport]);
-        }).then(function (response) {
+        }).then((response) => {
             assert.equal(response['status'], 'OK');
             return TestServer.database().selectAll('builds');
-        }).then(function (builds) {
+        }).then((builds) => {
             assert.equal(builds.length, 1);
-            done();
-        }).catch(done);
+        });
     });
 
-    it("should create distinct builds for the same build number if build times are far apart", function (done) {
-        let firstReport = emptyReport();
+    it("should create distinct builds for the same build number if build times are far apart", () => {
+        const firstReport = emptyReport();
         firstReport['buildTime'] = '2013-02-28T10:12:03';
-        let secondReport = emptyReport();
+        const secondReport = emptyReport();
         secondReport['buildTime'] = '2014-01-20T22:23:34';
 
-        addBuilderForReport(emptyReport()).then(function () {
+        return addBuilderForReport(emptyReport()).then(() => {
             return TestServer.remoteAPI().postJSON('/api/report/', [firstReport]);
-        }).then(function (response) {
+        }).then((response) => {
             assert.equal(response['status'], 'OK');
             return TestServer.database().selectAll('builds');
-        }).then(function (builds) {
+        }).then((builds) => {
             assert.equal(builds.length, 1);
             return TestServer.remoteAPI().postJSON('/api/report/', [secondReport]);
-        }).then(function (response) {
+        }).then((response) => {
             assert.equal(response['status'], 'OK');
             return TestServer.database().selectAll('builds');
-        }).then(function (builds) {
+        }).then((builds) => {
             assert.equal(builds.length, 2);
-            done();
-        }).catch(done);
+        });
     });
 
-    it("should reject a report with mismatching revision info", function (done) {
-        let firstReport = emptyReport();
+    it("should reject a report with mismatching revision info", () => {
+        const firstReport = emptyReport();
         firstReport['revisions'] = {
             "WebKit": {
                 "revision": "141977",
@@ -328,7 +308,7 @@ describe("/api/report", function () {
             }
         };
 
-        let secondReport = emptyReport();
+        const secondReport = emptyReport();
         secondReport['revisions'] = {
             "WebKit": {
                 "revision": "150000",
@@ -336,22 +316,21 @@ describe("/api/report", function () {
             }
         };
 
-        addBuilderForReport(firstReport).then(function () {
+        return addBuilderForReport(firstReport).then(() => {
             return TestServer.remoteAPI().postJSON('/api/report/', [firstReport]);
-        }).then(function (response) {
+        }).then((response) => {
             assert.equal(response['status'], 'OK');
             return TestServer.database().selectAll('builds');
-        }).then(function (builds) {
+        }).then((builds) => {
             assert.equal(builds.length, 1);
             return TestServer.remoteAPI().postJSON('/api/report/', [secondReport]);
-        }).then(function (response) {
+        }).then((response) => {
             assert.equal(response['status'], 'MismatchingCommitRevision');
             assert(JSON.stringify(response).indexOf('141977') >= 0);
             assert(JSON.stringify(response).indexOf('150000') >= 0);
             assert.equal(response['failureStored'], true);
             assert.equal(response['processedRuns'], 0);
-            done();
-        }).catch(done);
+        });
     });
 
     const reportWithTwoLevelsOfAggregations = {
@@ -400,15 +379,15 @@ describe("/api/report", function () {
 
     function reportAfterAddingBuilderAndAggregators(report)
     {
-        return addBuilderForReport(report).then(function () {
+        return addBuilderForReport(report).then(() => {
             const db = TestServer.database();
             return Promise.all([
                 db.insert('aggregators', {name: 'Arithmetic'}),
                 db.insert('aggregators', {name: 'Geometric'}),
             ]);
-        }).then(function () {
+        }).then(() => {
             return TestServer.remoteAPI().postJSON('/api/report/', [report]);
-        }).then(function (response) {
+        }).then((response) => {
             assert.equal(response['status'], 'OK');
             assert.equal(response['failureStored'], false);
             return response;
@@ -419,34 +398,31 @@ describe("/api/report", function () {
         queryAndFetchAll('SELECT * FROM test_runs WHERE run_config IN'
             + '(SELECT config_id FROM test_configurations, test_metrics, tests WHERE config_metric = metric_id AND metric_test = test_id AND'
             + 'test_name = $1 AND metric_name = $2)',
-            ['Arithmetic', 'values.reduce(function (a, b) { return a + b; }) / values.length'], function () {
+            ['Arithmetic', 'values.reduce(function (a, b) { return a + b; }) / values.length'], () => {
             queryAndFetchAll('INSERT INTO aggregators (aggregator_name, aggregator_definition) values ($1, $2)',
                 ['Geometric', 'Math.pow(values.reduce(function (a, b) { return a * b; }), 1 / values.length)'], callback);
         });
     }
 
-    it("should accept a report with aggregators", function (done) {
-        reportAfterAddingBuilderAndAggregators(reportWithTwoLevelsOfAggregations).then(function () {
-            done();
-        }).catch(done);
+    it("should accept a report with aggregators", () => {
+        return reportAfterAddingBuilderAndAggregators(reportWithTwoLevelsOfAggregations);
     });
 
-    it("should add tests", function (done) {
-        reportAfterAddingBuilderAndAggregators(reportWithTwoLevelsOfAggregations).then(function () {
+    it("should add tests", () => {
+        return reportAfterAddingBuilderAndAggregators(reportWithTwoLevelsOfAggregations).then(() => {
             return TestServer.database().selectAll('tests');
-        }).then(function (tests) {
-            assert.deepEqual(tests.map(function (row) { return row['name']; }).sort(),
+        }).then((tests) => {
+            assert.deepEqual(tests.map((row) => { return row['name']; }).sort(),
                 ['CSS', 'DOM', 'DummyBenchmark', 'DummyPageLoading', 'ModifyNodes', 'TraverseNodes', 'apple.com', 'webkit.org']);
-            done();
-        }).catch(done);
+        });
     });
 
-    it("should add metrics", function (done) {
-        reportAfterAddingBuilderAndAggregators(reportWithTwoLevelsOfAggregations).then(function () {
+    it("should add metrics", () => {
+        return reportAfterAddingBuilderAndAggregators(reportWithTwoLevelsOfAggregations).then(() => {
             return TestServer.database().query('SELECT * FROM tests, test_metrics LEFT JOIN aggregators ON metric_aggregator = aggregator_id WHERE metric_test = test_id');
-        }).then(function (result) {
-            let testNameToMetrics = {};
-            result.rows.forEach(function (row) {
+        }).then((result) => {
+            const testNameToMetrics = {};
+            result.rows.forEach((row) => {
                 if (!(row['test_name'] in testNameToMetrics))
                     testNameToMetrics[row['test_name']] = new Array;
                 testNameToMetrics[row['test_name']].push([row['metric_name'], row['aggregator_name']]);
@@ -459,15 +435,14 @@ describe("/api/report", function () {
             assert.deepEqual(testNameToMetrics['TraverseNodes'], [['Time', null]]);
             assert.deepEqual(testNameToMetrics['apple.com'], [['Time', null]]);
             assert.deepEqual(testNameToMetrics['webkit.org'], [['Time', null]]);
-            done();
-        }).catch(done);
+        });
     });
 
     function fetchTestConfig(testName, metricName)
     {
         return TestServer.database().query(`SELECT * FROM tests, test_metrics, test_configurations
             WHERE test_id = metric_test AND metric_id = config_metric
-            AND test_name = $1 AND metric_name = $2`, [testName, metricName]).then(function (result) {
+            AND test_name = $1 AND metric_name = $2`, [testName, metricName]).then((result) => {
                 assert.equal(result.rows.length, 1);
                 return result.rows[0];
             });
@@ -476,19 +451,19 @@ describe("/api/report", function () {
     function fetchTestRunIterationsForMetric(testName, metricName)
     {
         const db = TestServer.database();
-        return fetchTestConfig(testName, metricName).then(function (config) {
+        return fetchTestConfig(testName, metricName).then((config) => {
             return db.selectFirstRow('test_runs', {config: config['config_id']});
-        }).then(function (run) {
-            return db.selectRows('run_iterations', {run: run['id']}, {sortBy: 'order'}).then(function (iterations) {
+        }).then((run) => {
+            return db.selectRows('run_iterations', {run: run['id']}, {sortBy: 'order'}).then((iterations) => {
                 return {run: run, iterations: iterations};
             });
         });
     }
 
-    it("should store run values", function (done) {
-        reportAfterAddingBuilderAndAggregators(reportWithTwoLevelsOfAggregations).then(function () {
+    it("should store run values", () => {
+        return reportAfterAddingBuilderAndAggregators(reportWithTwoLevelsOfAggregations).then(() => {
             return fetchTestRunIterationsForMetric('apple.com', 'Time');
-        }).then(function (result) {
+        }).then((result) => {
             const run = result.run;
             const runId = run['id'];
             assert.deepEqual(result.iterations, [
@@ -496,12 +471,12 @@ describe("/api/report", function () {
                 {run: runId, order: 1, group: null, value: 510, relative_time: null},
                 {run: runId, order: 2, group: null, value: 520, relative_time: null},
                 {run: runId, order: 3, group: null, value: 530, relative_time: null}]);
-            var sum = 500 + 510 + 520 + 530;
+            const sum = 500 + 510 + 520 + 530;
             assert.equal(run['mean_cache'], sum / result.iterations.length);
             assert.equal(run['sum_cache'], sum);
             assert.equal(run['square_sum_cache'], 500 * 500 + 510 * 510 + 520 * 520 + 530 * 530);
             return fetchTestRunIterationsForMetric('CSS', 'Time');
-        }).then(function (result) {
+        }).then((result) => {
             const run = result.run;
             const runId = run['id'];
             assert.deepEqual(result.iterations, [
@@ -529,14 +504,13 @@ describe("/api/report", function () {
             assert.equal(run['mean_cache'], sum / result.iterations.length);
             assert.equal(run['sum_cache'], sum);
             assert.equal(run['square_sum_cache'], squareSum);
-            done();
-        }).catch(done);
+        });
     });
 
-    it("should store aggregated run values", function (done) {
-        reportAfterAddingBuilderAndAggregators(reportWithTwoLevelsOfAggregations).then(function () {
+    it("should store aggregated run values", () => {
+        return reportAfterAddingBuilderAndAggregators(reportWithTwoLevelsOfAggregations).then(() => {
             return fetchTestRunIterationsForMetric('DummyPageLoading', 'Time');
-        }).then(function (result) {
+        }).then((result) => {
             const run = result.run;
             const runId = result.run['id'];
             const expectedValues = [(500 + 100) / 2, (510 + 110) / 2, (520 + 120) / 2, (530 + 130) / 2];
@@ -549,14 +523,13 @@ describe("/api/report", function () {
             assert.equal(run['mean_cache'], sum / result.iterations.length);
             assert.equal(run['sum_cache'], sum);
             assert.equal(run['square_sum_cache'], expectedValues.reduce(function (sum, value) { return sum + value * value; }, 0));
-            done();
-        }).catch(done);
+        });
     });
 
-    it("should be able to compute the aggregation of aggregated values", function (done) {
-        reportAfterAddingBuilderAndAggregators(reportWithTwoLevelsOfAggregations).then(function () {
+    it("should be able to compute the aggregation of aggregated values", () => {
+        return reportAfterAddingBuilderAndAggregators(reportWithTwoLevelsOfAggregations).then(() => {
             return fetchTestRunIterationsForMetric('DummyBenchmark', 'Time');
-        }).then(function (result) {
+        }).then((result) => {
             const run = result.run;
             const runId = run['id'];
             const expectedIterations = [];
@@ -574,8 +547,7 @@ describe("/api/report", function () {
             assert.equal(run['mean_cache'], sum / result.iterations.length);
             assert.equal(run['sum_cache'], sum);
             assert.equal(run['square_sum_cache'], squareSum);
-            done();
-        }).catch(done);
+        });
     });
 
     function reportWithSameSubtestName()
@@ -611,28 +583,25 @@ describe("/api/report", function () {
         };
     }
 
-    it("should be able to add a report with same subtest name", function (done) {
-        reportAfterAddingBuilderAndAggregators(reportWithSameSubtestName()).then(function () {
-            done();
-        }).catch(done);
+    it("should be able to add a report with same subtest name", () => {
+        return reportAfterAddingBuilderAndAggregators(reportWithSameSubtestName());
     });
 
-    it("should be able to reuse the same test rows", function (done) {
-        reportAfterAddingBuilderAndAggregators(reportWithSameSubtestName()).then(function () {
+    it("should be able to reuse the same test rows", () => {
+        return reportAfterAddingBuilderAndAggregators(reportWithSameSubtestName()).then(() => {
             return TestServer.database().selectAll('tests');
-        }).then(function (tests) {
+        }).then((tests) => {
             assert.equal(tests.length, 6);
             let newReport = reportWithSameSubtestName();
             newReport.buildNumber = "125";
             newReport.buildTime = "2013-02-28T12:17:24.1";
             return TestServer.remoteAPI().postJSON('/api/report/', [newReport]);
-        }).then(function (response) {
+        }).then((response) => {
             assert.equal(response['status'], 'OK');
             return TestServer.database().selectAll('tests');
-        }).then(function (tests) {
+        }).then((tests) => {
             assert.equal(tests.length, 6);
-            done();
-        }).catch(done);
+        });
     });
 
     const reportWithSameSingleValue = {
@@ -655,24 +624,23 @@ describe("/api/report", function () {
             },
         }};
 
-    it("should be able to add a report with single value results", function (done) {
-        reportAfterAddingBuilderAndAggregators(reportWithSameSingleValue).then(function () {
+    it("should be able to add a report with single value results", () => {
+        return reportAfterAddingBuilderAndAggregators(reportWithSameSingleValue).then(() => {
             return fetchTestRunIterationsForMetric('test1', 'Combined');
-        }).then(function (result) {
+        }).then((result) => {
             const run = result.run;
             assert.equal(run['iteration_count_cache'], 1);
             assert.equal(run['mean_cache'], 3);
             assert.equal(run['sum_cache'], 3);
             assert.equal(run['square_sum_cache'], 9);
             return fetchTestRunIterationsForMetric('suite', 'Combined');
-        }).then(function (result) {
+        }).then((result) => {
             const run = result.run;
             assert.equal(run['iteration_count_cache'], 1);
             assert.equal(run['mean_cache'], 5);
             assert.equal(run['sum_cache'], 5);
             assert.equal(run['square_sum_cache'], 25);
-            done();
-        }).catch(done);
+        });
     });
 
     const reportWithSameValuePairs = {
@@ -688,10 +656,10 @@ describe("/api/report", function () {
             },
         };
 
-    it("should be able to add a report with (relative time, value) pairs", function (done) {
-        reportAfterAddingBuilderAndAggregators(reportWithSameValuePairs).then(function () {
+    it("should be able to add a report with (relative time, value) pairs", () => {
+        return reportAfterAddingBuilderAndAggregators(reportWithSameValuePairs).then(() => {
             return fetchTestRunIterationsForMetric('test', 'FrameRate');
-        }).then(function (result) {
+        }).then((result) => {
             const run = result.run;
             assert.equal(run['iteration_count_cache'], 3);
             assert.equal(run['mean_cache'], 4);
@@ -703,8 +671,7 @@ describe("/api/report", function () {
                 {run: runId, order: 0, group: null, value: 4, relative_time: 0},
                 {run: runId, order: 1, group: null, value: 5, relative_time: 100},
                 {run: runId, order: 2, group: null, value: 3, relative_time: 205}]);
-            done();
-        }).catch(done);
+        });
     });
 
     const reportsUpdatingDifferentTests = [
@@ -734,40 +701,38 @@ describe("/api/report", function () {
         },
     ];
 
-    it("should update the last modified date of test configurations with new runs", function (done) {
-        addBuilderForReport(reportsUpdatingDifferentTests[0]).then(function () {
+    it("should update the last modified date of test configurations with new runs", () => {
+        return addBuilderForReport(reportsUpdatingDifferentTests[0]).then(() => {
             return TestServer.remoteAPI().postJSON('/api/report/', [reportsUpdatingDifferentTests[0]]);
-        }).then(function (response) {
+        }).then((response) => {
             assert.equal(response['status'], 'OK');
             return fetchTestConfig('test1', 'Time');
-        }).then(function (originalConfig) {
-            return TestServer.remoteAPI().postJSON('/api/report/', [reportsUpdatingDifferentTests[2]]).then(function () {
+        }).then((originalConfig) => {
+            return TestServer.remoteAPI().postJSON('/api/report/', [reportsUpdatingDifferentTests[2]]).then(() => {
                 return fetchTestConfig('test1', 'Time');
-            }).then(function (config) {
+            }).then((config) => {
                 assert(originalConfig['config_runs_last_modified'] instanceof Date);
                 assert(config['config_runs_last_modified'] instanceof Date);
                 assert(+originalConfig['config_runs_last_modified'] < +config['config_runs_last_modified']);
-                done();
             });
-        }).catch(done);
+        });
     });
 
-    it("should not update the last modified date of unrelated test configurations", function (done) {
-        addBuilderForReport(reportsUpdatingDifferentTests[0]).then(function () {
+    it("should not update the last modified date of unrelated test configurations", () => {
+        return addBuilderForReport(reportsUpdatingDifferentTests[0]).then(() => {
             return TestServer.remoteAPI().postJSON('/api/report/', [reportsUpdatingDifferentTests[0]]);
-        }).then(function (response) {
+        }).then((response) => {
             assert.equal(response['status'], 'OK');
             return fetchTestConfig('test1', 'Time');
-        }).then(function (originalConfig) {
-            return TestServer.remoteAPI().postJSON('/api/report/', [reportsUpdatingDifferentTests[1]]).then(function (response) {
+        }).then((originalConfig) => {
+            return TestServer.remoteAPI().postJSON('/api/report/', [reportsUpdatingDifferentTests[1]]).then((response) => {
                 assert.equal(response['status'], 'OK');
                 return fetchTestConfig('test1', 'Time');
-            }).then(function (config) {
+            }).then((config) => {
                 assert(originalConfig['config_runs_last_modified'] instanceof Date);
                 assert(config['config_runs_last_modified'] instanceof Date);
                 assert.equal(+originalConfig['config_runs_last_modified'], +config['config_runs_last_modified']);
-                done();
             });
-        }).catch(done);
+        });
     });
 });
index 8c13bea1783e83eab1634f616e964b3449a757e1..5f209f1c175c0043f99cad76690d96d06c00c14a 100644 (file)
@@ -7,12 +7,10 @@ require('../tools/js/v3-models.js');
 const TestServer = require('./resources/test-server.js');
 const MockData = require('./resources/mock-data.js');
 const addSlaveForReport = require('./resources/common-operations.js').addSlaveForReport;
-const connectToDatabaseInEveryTest = require('./resources/common-operations.js').connectToDatabaseInEveryTest;
+const prepareServerTest = require('./resources/common-operations.js').prepareServerTest;
 
 describe('/api/update-triggerable/', function () {
-    this.timeout(1000);
-    TestServer.inject();
-    connectToDatabaseInEveryTest();
+    prepareServerTest(this);
 
     const emptyUpdate = {
         'slaveName': 'someSlave',
@@ -30,85 +28,78 @@ describe('/api/update-triggerable/', function () {
         ],
     };
 
-    it('should reject when slave name is missing', function (done) {
-        TestServer.remoteAPI().postJSON('/api/update-triggerable/', {}).then(function (response) {
+    it('should reject when slave name is missing', () => {
+        return TestServer.remoteAPI().postJSON('/api/update-triggerable/', {}).then((response) => {
             assert.equal(response['status'], 'MissingSlaveName');
-            done();
-        }).catch(done);
+        });
     });
 
-    it('should reject when there are no slaves', function (done) {
+    it('should reject when there are no slaves', () => {
         const update = {slaveName: emptyUpdate.slaveName, slavePassword: emptyUpdate.slavePassword};
-        TestServer.remoteAPI().postJSON('/api/update-triggerable/', update).then(function (response) {
+        return TestServer.remoteAPI().postJSON('/api/update-triggerable/', update).then((response) => {
             assert.equal(response['status'], 'SlaveNotFound');
-            done();
-        }).catch(done);
+        });
     });
 
-    it('should reject when the slave password doesn\'t match', function (done) {
-        MockData.addMockData(TestServer.database()).then(function () {
+    it('should reject when the slave password doesn\'t match', () => {
+        return MockData.addMockData(TestServer.database()).then(() => {
             return addSlaveForReport(emptyUpdate);
-        }).then(function () {
+        }).then(() => {
             const report = {slaveName: emptyUpdate.slaveName, slavePassword: 'badPassword'};
             return TestServer.remoteAPI().postJSON('/api/update-triggerable/', emptyUpdate);
-        }).then(function (response) {
+        }).then((response) => {
             assert.equal(response['status'], 'OK');
-            done();
-        }).catch(done);
+        });
     });
 
-    it('should accept an empty report', function (done) {
-        MockData.addMockData(TestServer.database()).then(function () {
+    it('should accept an empty report', () => {
+        return MockData.addMockData(TestServer.database()).then(() => {
             return addSlaveForReport(emptyUpdate);
-        }).then(function () {
+        }).then(() => {
             return TestServer.remoteAPI().postJSON('/api/update-triggerable/', emptyUpdate);
-        }).then(function (response) {
+        }).then((response) => {
             assert.equal(response['status'], 'OK');
-            done();
-        }).catch(done);
+        });
     });
 
-    it('delete existing configurations when accepting an empty report', function (done) {
+    it('delete existing configurations when accepting an empty report', () => {
         const db = TestServer.database();
-        MockData.addMockData(db).then(function () {
+        return MockData.addMockData(db).then(() => {
             return Promise.all([
                 addSlaveForReport(emptyUpdate),
                 db.insert('triggerable_configurations',
                     {'triggerable': 1 /* build-webkit */, 'test': MockData.someTestId(), 'platform': MockData.somePlatformId()})
             ]);
-        }).then(function () {
+        }).then(() => {
             return TestServer.remoteAPI().postJSON('/api/update-triggerable/', emptyUpdate);
-        }).then(function (response) {
+        }).then((response) => {
             assert.equal(response['status'], 'OK');
             return db.selectAll('triggerable_configurations', 'test');
-        }).then(function (rows) {
+        }).then((rows) => {
             assert.equal(rows.length, 0);
-            done();
-        }).catch(done);
+        });
     });
 
-    it('should add configurations in the update', function (done) {
+    it('should add configurations in the update', () => {
         const db = TestServer.database();
-        MockData.addMockData(db).then(function () {
+        return MockData.addMockData(db).then(() => {
             return addSlaveForReport(smallUpdate);
-        }).then(function () {
+        }).then(() => {
             return TestServer.remoteAPI().postJSON('/api/update-triggerable/', smallUpdate);
-        }).then(function (response) {
+        }).then((response) => {
             assert.equal(response['status'], 'OK');
             return db.selectAll('triggerable_configurations', 'test');
-        }).then(function (rows) {
+        }).then((rows) => {
             assert.equal(rows.length, 1);
             assert.equal(rows[0]['test'], smallUpdate.configurations[0]['test']);
             assert.equal(rows[0]['platform'], smallUpdate.configurations[0]['platform']);
-            done();
-        }).catch(done);
+        });
     });
 
-    it('should reject when a configuration is malformed', function (done) {
-        const db = TestServer.database();
-        MockData.addMockData(db).then(function () {
+    it('should reject when a configuration is malformed', () => {
+        return MockData.addMockData(TestServer.database()).then(() => {
             return addSlaveForReport(smallUpdate);
-        }).then(function () {
+        }).then(() => {
             const update = {
                 'slaveName': 'someSlave',
                 'slavePassword': 'somePassword',
@@ -116,10 +107,9 @@ describe('/api/update-triggerable/', function () {
                 'configurations': [{}],
             };
             return TestServer.remoteAPI().postJSON('/api/update-triggerable/', update);
-        }).then(function (response) {
+        }).then((response) => {
             assert.equal(response['status'], 'InvalidConfigurationEntry');
-            done();
-        }).catch(done);
+        });
     });
 
 });
index ba6c6660df8b68fb301c008dd5a962574cc9660e..e2f6b761089637957ae593c5e7bd8969ace12041 100644 (file)
@@ -6,12 +6,10 @@ const assert = require('assert');
 
 const TestServer = require('./resources/test-server.js');
 const addBuilderForReport = require('./resources/common-operations.js').addBuilderForReport;
-const connectToDatabaseInEveryTest = require('./resources/common-operations.js').connectToDatabaseInEveryTest;
+const prepareServerTest = require('./resources/common-operations.js').prepareServerTest;
 
 describe("/privileged-api/update-run-status", function () {
-    this.timeout(1000);
-    TestServer.inject();
-    connectToDatabaseInEveryTest();
+    prepareServerTest(this);
 
     const reportWithRevision = [{
         "buildNumber": "124",
@@ -35,100 +33,95 @@ describe("/privileged-api/update-run-status", function () {
             },
         }}];
 
-    it("should be able to mark a run as an outlier", function (done) {
+    it("should be able to mark a run as an outlier", () => {
         const db = TestServer.database();
         let id;
-        addBuilderForReport(reportWithRevision[0]).then(function () {
+        return addBuilderForReport(reportWithRevision[0]).then(() => {
             return TestServer.remoteAPI().postJSON('/api/report/', reportWithRevision);
-        }).then(function (response) {
+        }).then((response) => {
             assert.equal(response['status'], 'OK');
             return db.selectAll('test_runs');
-        }).then(function (runRows) {
+        }).then((runRows) => {
             assert.equal(runRows.length, 1);
             assert.equal(runRows[0]['mean_cache'], 11);
             assert.equal(runRows[0]['iteration_count_cache'], 1);
             assert.equal(runRows[0]['marked_outlier'], false);
             id = runRows[0]['id'];
             return PrivilegedAPI.requestCSRFToken();
-        }).then(function () {
+        }).then(() => {
             return PrivilegedAPI.sendRequest('update-run-status', {'run': id, 'markedOutlier': true, 'token': PrivilegedAPI._token});
-        }).then(function () {
+        }).then(() => {
             return db.selectAll('test_runs');
-        }).then(function (runRows) {
+        }).then((runRows) => {
             assert.equal(runRows.length, 1);
             assert.equal(runRows[0]['mean_cache'], 11);
             assert.equal(runRows[0]['iteration_count_cache'], 1);
             assert.equal(runRows[0]['marked_outlier'], true);
-            done();
-        }).catch(done);
+        });
     });
 
-    it("should reject when the token is not set in cookie", function (done) {
+    it("should reject when the token is not set in cookie", () => {
         const db = TestServer.database();
-        addBuilderForReport(reportWithRevision[0]).then(function () {
+        return addBuilderForReport(reportWithRevision[0]).then(() => {
             return TestServer.remoteAPI().postJSON('/api/report/', reportWithRevision);
-        }).then(function (response) {
+        }).then((response) => {
             assert.equal(response['status'], 'OK');
             return db.selectAll('test_runs');
-        }).then(function (runRows) {
+        }).then((runRows) => {
             assert.equal(runRows.length, 1);
             assert.equal(runRows[0]['marked_outlier'], false);
             return PrivilegedAPI.requestCSRFToken();
-        }).then(function () {
+        }).then(() => {
             RemoteAPI.clearCookies();
             return RemoteAPI.postJSONWithStatus('/privileged-api/update-run-status', {token: PrivilegedAPI._token});
-        }).then(function () {
+        }).then(() => {
             assert(false, 'PrivilegedAPI.sendRequest should reject');
-        }, function (response) {
+        }, (response) => {
             assert.equal(response['status'], 'InvalidToken');
-            done();
-        }).catch(done);
+        });
     });
 
-    it("should reject when the token in the request content is bad", function (done) {
-        const db = TestServer.database();
-        addBuilderForReport(reportWithRevision[0]).then(function () {
+    it("should reject when the token in the request content is bad", () => {
+        return addBuilderForReport(reportWithRevision[0]).then(() => {
             return TestServer.remoteAPI().postJSON('/api/report/', reportWithRevision);
-        }).then(function (response) {
+        }).then((response) => {
             assert.equal(response['status'], 'OK');
-            return db.selectAll('test_runs');
-        }).then(function (runRows) {
+            return TestServer.database().selectAll('test_runs');
+        }).then((runRows) => {
             assert.equal(runRows.length, 1);
             assert.equal(runRows[0]['marked_outlier'], false);
             return PrivilegedAPI.requestCSRFToken();
-        }).then(function () {
+        }).then(() => {
             return RemoteAPI.postJSONWithStatus('/privileged-api/update-run-status', {token: 'bad'});
-        }).then(function () {
+        }).then(() => {
             assert(false, 'PrivilegedAPI.sendRequest should reject');
-        }, function (response) {
+        }, (response) => {
             assert.equal(response['status'], 'InvalidToken');
-            done();
-        }).catch(done);
+        });
     });
 
-    it("should be able to unmark a run as an outlier", function (done) {
+    it("should be able to unmark a run as an outlier", () => {
         const db = TestServer.database();
-        addBuilderForReport(reportWithRevision[0]).then(function () {
+        return addBuilderForReport(reportWithRevision[0]).then(() => {
             return TestServer.remoteAPI().postJSON('/api/report/', reportWithRevision);
-        }).then(function (response) {
+        }).then((response) => {
             assert.equal(response['status'], 'OK');
             return db.selectAll('test_runs');
-        }).then(function (runRows) {
+        }).then((runRows) => {
             assert.equal(runRows.length, 1);
             assert.equal(runRows[0]['marked_outlier'], false);
             return PrivilegedAPI.sendRequest('update-run-status', {'run': runRows[0]['id'], 'markedOutlier': true});
-        }).then(function () {
+        }).then(() => {
             return db.selectAll('test_runs');
-        }).then(function (runRows) {
+        }).then((runRows) => {
             assert.equal(runRows.length, 1);
             assert.equal(runRows[0]['marked_outlier'], true);
             return PrivilegedAPI.sendRequest('update-run-status', {'run': runRows[0]['id'], 'markedOutlier': false});
-        }).then(function () {
+        }).then(() => {
             return db.selectAll('test_runs');
-        }).then(function (runRows) {
+        }).then((runRows) => {
             assert.equal(runRows.length, 1);
             assert.equal(runRows[0]['marked_outlier'], false);
-            done();
-        }).catch(done);
+        });
     });
 });
index 1c440652b7ef2961dcfdc6c4f0b02224f10b37c6..41c579e6b59362b020419e0c6a1415b8db9578ed 100644 (file)
@@ -17,9 +17,14 @@ function addSlaveForReport(report)
     });
 }
 
-function connectToDatabaseInEveryTest()
+function prepareServerTest(test)
 {
+    test.timeout(1000);
+    TestServer.inject();
+
     beforeEach(function () {
+        if (typeof(MockData) != 'undefined')
+            MockData.resetV3Models();
         TestServer.database().connect({keepAlive: true});
     });
 
@@ -41,6 +46,6 @@ function submitReport(report)
 if (typeof module != 'undefined') {
     module.exports.addBuilderForReport = addBuilderForReport;
     module.exports.addSlaveForReport = addSlaveForReport;
-    module.exports.connectToDatabaseInEveryTest = connectToDatabaseInEveryTest;
+    module.exports.prepareServerTest = prepareServerTest;
     module.exports.submitReport = submitReport;
 }
index 4e63dc481f8de2d0d7bbd0f5b66dc14b6c19138b..f4307d051b4159d55fe0ce4899acea78c8ca9da8 100644 (file)
@@ -6,7 +6,7 @@ const BuildbotTriggerable = require('../tools/js/buildbot-triggerable.js').Build
 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;
+const prepareServerTest = require('./resources/common-operations.js').prepareServerTest;
 
 class MockLogger {
     constructor()
@@ -19,31 +19,27 @@ class MockLogger {
 }
 
 describe('BuildbotTriggerable', function () {
-    this.timeout(1000);
-    TestServer.inject();
+    prepareServerTest(this);
 
     beforeEach(function () {
         MockData.resetV3Models();
         MockRemoteAPI.reset('http://build.webkit.org');
     });
 
-    describe('syncOnce', function () {
-        it('should schedule the next build request when there are no pending builds', function (done) {
-            let db = TestServer.database();
+    describe('syncOnce', () => {
+        it('should schedule the next build request when there are no pending builds', () => {
+            const db = TestServer.database();
             let syncPromise;
-            db.connect().then(function () {
-                return MockData.addMockData(db, ['completed', 'running', 'pending', 'pending']);
-            }).then(function () {
+            return MockData.addMockData(db, ['completed', 'running', 'pending', 'pending']).then(() => {
                 return Manifest.fetch();
-            }).then(function () {
-                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);
+            }).then(() => {
+                const config = MockData.mockTestSyncConfigWithSingleBuilder();
+                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.catch(done);
                 return MockRemoteAPI.waitForRequest();
-            }).then(function () {
+            }).then(() => {
                 assert.equal(BuildRequest.all().length, 4);
                 assert.equal(BuildRequest.findById(700).status(), 'completed');
                 assert.equal(BuildRequest.findById(701).status(), 'running');
@@ -53,107 +49,99 @@ describe('BuildbotTriggerable', function () {
                 assert.equal(MockRemoteAPI.requests[0].url, '/json/builders/some-builder-1/pendingBuilds');
                 MockRemoteAPI.requests[0].resolve([]);
                 return MockRemoteAPI.waitForRequest();
-            }).then(function () {
+            }).then(() => {
                 assert.equal(MockRemoteAPI.requests[1].method, 'GET');
                 assert.equal(MockRemoteAPI.requests[1].url, '/json/builders/some-builder-1/builds/?select=-1&select=-2');
                 MockRemoteAPI.requests[1].resolve({[-1]: MockData.runningBuild(), [-2]: MockData.finishedBuild()});
                 return MockRemoteAPI.waitForRequest();
-            }).then(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'});
                 MockRemoteAPI.requests[2].resolve('OK');
                 return MockRemoteAPI.waitForRequest();
-            }).then(function () {
+            }).then(() => {
                 assert.equal(MockRemoteAPI.requests[3].method, 'GET');
                 assert.equal(MockRemoteAPI.requests[3].url, '/json/builders/some-builder-1/pendingBuilds');
                 MockRemoteAPI.requests[3].resolve([MockData.pendingBuild()])
                 return MockRemoteAPI.waitForRequest();
-            }).then(function () {
+            }).then(() => {
                 assert.equal(MockRemoteAPI.requests[4].method, 'GET');
                 assert.equal(MockRemoteAPI.requests[4].url, '/json/builders/some-builder-1/builds/?select=-1&select=-2');
                 MockRemoteAPI.requests[4].resolve({[-1]: MockData.runningBuild(), [-2]: MockData.finishedBuild()});
                 return syncPromise;
-            }).then(function () {
+            }).then(() => {
                 return BuildRequest.fetchForTriggerable(MockData.mockTestSyncConfigWithSingleBuilder().triggerableName);
-            }).then(function () {
+            }).then(() => {
                 assert.equal(BuildRequest.all().length, 4);
                 assert.equal(BuildRequest.findById(700).status(), 'completed');
                 assert.equal(BuildRequest.findById(701).status(), 'running');
                 assert.equal(BuildRequest.findById(702).status(), 'scheduled');
                 assert.equal(BuildRequest.findById(703).status(), 'pending');
-                done();
-            }).catch(done);
+            });
         });
 
-        it('should not schedule the next build request when there is a pending build', function (done) {
-            let db = TestServer.database();
+        it('should not schedule the next build request when there is a pending build', () => {
+            const db = TestServer.database();
             let syncPromise;
-            db.connect().then(function () {
-                return MockData.addMockData(db, ['completed', 'running', 'pending', 'pending']);
-            }).then(function () {
+            return MockData.addMockData(db, ['completed', 'running', 'pending', 'pending']).then(() => {
                 return Manifest.fetch();
-            }).then(function () {
+            }).then(() => {
                 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);
                 syncPromise = triggerable.syncOnce();
-                syncPromise.catch(done);
                 return MockRemoteAPI.waitForRequest();
-            }).then(function () {
+            }).then(() => {
                 assert.equal(MockRemoteAPI.requests[0].method, 'GET');
                 assert.equal(MockRemoteAPI.requests[0].url, '/json/builders/some-builder-1/pendingBuilds');
                 MockRemoteAPI.requests[0].resolve([MockData.pendingBuild()]);
                 return MockRemoteAPI.waitForRequest();
-            }).then(function () {
+            }).then(() => {
                 assert.equal(MockRemoteAPI.requests[1].method, 'GET');
                 assert.equal(MockRemoteAPI.requests[1].url, '/json/builders/some-builder-1/builds/?select=-1&select=-2');
                 MockRemoteAPI.requests[1].resolve({[-1]: MockData.runningBuild(), [-2]: MockData.finishedBuild()});
                 return MockRemoteAPI.waitForRequest();
-            }).then(function () {
+            }).then(() => {
                 assert.equal(MockRemoteAPI.requests[2].method, 'GET');
                 assert.equal(MockRemoteAPI.requests[2].url, '/json/builders/some-builder-1/pendingBuilds');
                 MockRemoteAPI.requests[2].resolve([MockData.pendingBuild()])
                 return MockRemoteAPI.waitForRequest();
-            }).then(function () {
+            }).then(() => {
                 assert.equal(MockRemoteAPI.requests[3].method, 'GET');
                 assert.equal(MockRemoteAPI.requests[3].url, '/json/builders/some-builder-1/builds/?select=-1&select=-2');
                 MockRemoteAPI.requests[3].resolve({[-1]: MockData.runningBuild(), [-2]: MockData.finishedBuild()});
                 return syncPromise;
-            }).then(function () {
+            }).then(() => {
                 assert.equal(BuildRequest.all().length, 4);
                 assert.equal(BuildRequest.findById(700).status(), 'completed');
                 assert.equal(BuildRequest.findById(701).status(), 'running');
                 assert.equal(BuildRequest.findById(702).status(), 'pending');
                 assert.equal(BuildRequest.findById(703).status(), 'pending');
                 return BuildRequest.fetchForTriggerable(MockData.mockTestSyncConfigWithSingleBuilder().triggerableName);
-            }).then(function () {
+            }).then(() => {
                 assert.equal(BuildRequest.all().length, 4);
                 assert.equal(BuildRequest.findById(700).status(), 'completed');
                 assert.equal(BuildRequest.findById(701).status(), 'running');
                 assert.equal(BuildRequest.findById(702).status(), 'scheduled');
                 assert.equal(BuildRequest.findById(703).status(), 'pending');
-                done();
-            }).catch(done);
+            });
         });
 
-        it('should schedule the build request on a builder without a pending build if it\'s the first request in the group', function (done) {
-            let db = TestServer.database();
+        it('should schedule the build request on a builder without a pending build if it\'s the first request in the group', () => {
+            const db = TestServer.database();
             let syncPromise;
-            db.connect().then(function () {
-                return MockData.addMockData(db, ['pending', 'pending', 'pending', 'pending']);
-            }).then(function () {
+            return MockData.addMockData(db, ['pending', 'pending', 'pending', 'pending']).then(() => {
                 return Manifest.fetch();
-            }).then(function () {
-                let config = MockData.mockTestSyncConfigWithTwoBuilders();
-                let logger = new MockLogger;
-                let slaveInfo = {name: 'sync-slave', password: 'password'};
-                let triggerable = new BuildbotTriggerable(config, TestServer.remoteAPI(), MockRemoteAPI, slaveInfo, logger);
+            }).then(() => {
+                const config = MockData.mockTestSyncConfigWithTwoBuilders();
+                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.catch(done);
                 return MockRemoteAPI.waitForRequest();
-            }).then(function () {
+            }).then(() => {
                 assert.equal(MockRemoteAPI.requests.length, 2);
                 assert.equal(MockRemoteAPI.requests[0].method, 'GET');
                 assert.equal(MockRemoteAPI.requests[0].url, '/json/builders/some-builder-1/pendingBuilds');
@@ -162,7 +150,7 @@ describe('BuildbotTriggerable', function () {
                 assert.equal(MockRemoteAPI.requests[1].url, '/json/builders/some%20builder%202/pendingBuilds');
                 MockRemoteAPI.requests[1].resolve([]);
                 return MockRemoteAPI.waitForRequest();
-            }).then(function () {
+            }).then(() => {
                 assert.equal(MockRemoteAPI.requests.length, 4);
                 assert.equal(MockRemoteAPI.requests[2].method, 'GET');
                 assert.equal(MockRemoteAPI.requests[2].url, '/json/builders/some-builder-1/builds/?select=-1&select=-2');
@@ -171,14 +159,14 @@ describe('BuildbotTriggerable', function () {
                 assert.equal(MockRemoteAPI.requests[3].url, '/json/builders/some%20builder%202/builds/?select=-1&select=-2');
                 MockRemoteAPI.requests[3].resolve({});
                 return MockRemoteAPI.waitForRequest();
-            }).then(function () {
+            }).then(() => {
                 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'});
                 MockRemoteAPI.requests[4].resolve('OK');
                 return MockRemoteAPI.waitForRequest();
-            }).then(function () {
+            }).then(() => {
                 assert.equal(MockRemoteAPI.requests.length, 7);
                 assert.equal(MockRemoteAPI.requests[5].method, 'GET');
                 assert.equal(MockRemoteAPI.requests[5].url, '/json/builders/some-builder-1/pendingBuilds');
@@ -187,7 +175,7 @@ describe('BuildbotTriggerable', function () {
                 assert.equal(MockRemoteAPI.requests[6].url, '/json/builders/some%20builder%202/pendingBuilds');
                 MockRemoteAPI.requests[6].resolve([MockData.pendingBuild({builder: 'some builder 2', buildRequestId: 700})]);
                 return MockRemoteAPI.waitForRequest();
-            }).then(function () {
+            }).then(() => {
                 assert.equal(MockRemoteAPI.requests.length, 9);
                 assert.equal(MockRemoteAPI.requests[7].method, 'GET');
                 assert.equal(MockRemoteAPI.requests[7].url, '/json/builders/some-builder-1/builds/?select=-1&select=-2');
@@ -196,7 +184,7 @@ describe('BuildbotTriggerable', function () {
                 assert.equal(MockRemoteAPI.requests[8].url, '/json/builders/some%20builder%202/builds/?select=-1&select=-2');
                 MockRemoteAPI.requests[8].resolve({});
                 return syncPromise;
-            }).then(function () {
+            }).then(() => {
                 assert.equal(BuildRequest.all().length, 4);
                 assert.equal(BuildRequest.findById(700).status(), 'pending');
                 assert.equal(BuildRequest.findById(700).statusUrl(), null);
@@ -207,7 +195,7 @@ describe('BuildbotTriggerable', function () {
                 assert.equal(BuildRequest.findById(703).status(), 'pending');
                 assert.equal(BuildRequest.findById(703).statusUrl(), null);
                 return BuildRequest.fetchForTriggerable(MockData.mockTestSyncConfigWithTwoBuilders().triggerableName);
-            }).then(function () {
+            }).then(() => {
                 assert.equal(BuildRequest.all().length, 4);
                 assert.equal(BuildRequest.findById(700).status(), 'scheduled');
                 assert.equal(BuildRequest.findById(700).statusUrl(), 'http://build.webkit.org/builders/some%20builder%202/');
@@ -217,26 +205,22 @@ describe('BuildbotTriggerable', function () {
                 assert.equal(BuildRequest.findById(702).statusUrl(), null);
                 assert.equal(BuildRequest.findById(703).status(), 'pending');
                 assert.equal(BuildRequest.findById(703).statusUrl(), null);
-                done();
-            }).catch(done);
+            });
         });
 
-        it('should not schedule a build request on a different builder than the one the first build request is pending', function (done) {
-            let db = TestServer.database();
+        it('should not schedule a build request on a different builder than the one the first build request is pending', () => {
+            const db = TestServer.database();
             let syncPromise;
-            db.connect().then(function () {
-                return MockData.addMockData(db, ['pending', 'pending', 'pending', 'pending']);
-            }).then(function () {
+            return MockData.addMockData(db, ['pending', 'pending', 'pending', 'pending']).then(() => {
                 return Manifest.fetch();
-            }).then(function () {
+            }).then(() => {
                 let config = MockData.mockTestSyncConfigWithTwoBuilders();
                 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.catch(done);
                 return MockRemoteAPI.waitForRequest();
-            }).then(function () {
+            }).then(() => {
                 assert.equal(MockRemoteAPI.requests.length, 2);
                 assert.equal(MockRemoteAPI.requests[0].method, 'GET');
                 assert.equal(MockRemoteAPI.requests[0].url, '/json/builders/some-builder-1/pendingBuilds');
@@ -245,7 +229,7 @@ describe('BuildbotTriggerable', function () {
                 assert.equal(MockRemoteAPI.requests[1].url, '/json/builders/some%20builder%202/pendingBuilds');
                 MockRemoteAPI.requests[1].resolve([]);
                 return MockRemoteAPI.waitForRequest();
-            }).then(function () {
+            }).then(() => {
                 assert.equal(MockRemoteAPI.requests.length, 4);
                 assert.equal(MockRemoteAPI.requests[2].method, 'GET');
                 assert.equal(MockRemoteAPI.requests[2].url, '/json/builders/some-builder-1/builds/?select=-1&select=-2');
@@ -254,7 +238,7 @@ describe('BuildbotTriggerable', function () {
                 assert.equal(MockRemoteAPI.requests[3].url, '/json/builders/some%20builder%202/builds/?select=-1&select=-2');
                 MockRemoteAPI.requests[3].resolve({});
                 return MockRemoteAPI.waitForRequest();
-            }).then(function () {
+            }).then(() => {
                 assert.equal(MockRemoteAPI.requests.length, 6);
                 assert.equal(MockRemoteAPI.requests[4].method, 'GET');
                 assert.equal(MockRemoteAPI.requests[4].url, '/json/builders/some-builder-1/pendingBuilds');
@@ -263,7 +247,7 @@ describe('BuildbotTriggerable', function () {
                 assert.equal(MockRemoteAPI.requests[5].url, '/json/builders/some%20builder%202/pendingBuilds');
                 MockRemoteAPI.requests[5].resolve([]);
                 return MockRemoteAPI.waitForRequest();
-            }).then(function () {
+            }).then(() => {
                 assert.equal(MockRemoteAPI.requests.length, 8);
                 assert.equal(MockRemoteAPI.requests[6].method, 'GET');
                 assert.equal(MockRemoteAPI.requests[6].url, '/json/builders/some-builder-1/builds/?select=-1&select=-2');
@@ -272,7 +256,7 @@ describe('BuildbotTriggerable', function () {
                 assert.equal(MockRemoteAPI.requests[7].url, '/json/builders/some%20builder%202/builds/?select=-1&select=-2');
                 MockRemoteAPI.requests[7].resolve({});
                 return syncPromise;
-            }).then(function () {
+            }).then(() => {
                 assert.equal(BuildRequest.all().length, 4);
                 assert.equal(BuildRequest.findById(700).status(), 'pending');
                 assert.equal(BuildRequest.findById(700).statusUrl(), null);
@@ -283,7 +267,7 @@ describe('BuildbotTriggerable', function () {
                 assert.equal(BuildRequest.findById(703).status(), 'pending');
                 assert.equal(BuildRequest.findById(703).statusUrl(), null);
                 return BuildRequest.fetchForTriggerable(MockData.mockTestSyncConfigWithTwoBuilders().triggerableName);
-            }).then(function () {
+            }).then(() => {
                 assert.equal(BuildRequest.all().length, 4);
                 assert.equal(BuildRequest.findById(700).status(), 'scheduled');
                 assert.equal(BuildRequest.findById(700).statusUrl(), 'http://build.webkit.org/builders/some-builder-1/');
@@ -293,26 +277,22 @@ describe('BuildbotTriggerable', function () {
                 assert.equal(BuildRequest.findById(702).statusUrl(), null);
                 assert.equal(BuildRequest.findById(703).status(), 'pending');
                 assert.equal(BuildRequest.findById(703).statusUrl(), null);
-                done();
-            }).catch(done);
+            });
         });
 
-        it('should update the status of a pending build and schedule a new build if the pending build had started running', function (done) {
-            let db = TestServer.database();
+        it('should update the status of a pending build and schedule a new build if the pending build had started running', () => {
+            const db = TestServer.database();
             let syncPromise;
-            db.connect().then(function () {
-                return MockData.addMockData(db, ['pending', 'pending', 'pending', 'pending']);
-            }).then(function () {
+            return MockData.addMockData(db, ['pending', 'pending', 'pending', 'pending']).then(() => {
                 return Manifest.fetch();
-            }).then(function () {
-                let config = MockData.mockTestSyncConfigWithTwoBuilders();
-                let logger = new MockLogger;
-                let slaveInfo = {name: 'sync-slave', password: 'password'};
-                let triggerable = new BuildbotTriggerable(config, TestServer.remoteAPI(), MockRemoteAPI, slaveInfo, logger);
+            }).then(() => {
+                const config = MockData.mockTestSyncConfigWithTwoBuilders();
+                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.catch(done);
                 return MockRemoteAPI.waitForRequest();
-            }).then(function () {
+            }).then(() => {
                 assert.equal(MockRemoteAPI.requests.length, 2);
                 assert.equal(MockRemoteAPI.requests[0].method, 'GET');
                 assert.equal(MockRemoteAPI.requests[0].url, '/json/builders/some-builder-1/pendingBuilds');
@@ -321,7 +301,7 @@ describe('BuildbotTriggerable', function () {
                 assert.equal(MockRemoteAPI.requests[1].url, '/json/builders/some%20builder%202/pendingBuilds');
                 MockRemoteAPI.requests[1].resolve([]);
                 return MockRemoteAPI.waitForRequest();
-            }).then(function () {
+            }).then(() => {
                 assert.equal(MockRemoteAPI.requests.length, 4);
                 assert.equal(MockRemoteAPI.requests[2].method, 'GET');
                 assert.equal(MockRemoteAPI.requests[2].url, '/json/builders/some-builder-1/builds/?select=-1&select=-2');
@@ -330,14 +310,14 @@ describe('BuildbotTriggerable', function () {
                 assert.equal(MockRemoteAPI.requests[3].url, '/json/builders/some%20builder%202/builds/?select=-1&select=-2');
                 MockRemoteAPI.requests[3].resolve({});
                 return MockRemoteAPI.waitForRequest();
-            }).then(function () {
+            }).then(() => {
                 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'});
                 MockRemoteAPI.requests[4].resolve('OK');
                 return MockRemoteAPI.waitForRequest();
-            }).then(function () {
+            }).then(() => {
                 assert.equal(MockRemoteAPI.requests.length, 7);
                 assert.equal(MockRemoteAPI.requests[5].method, 'GET');
                 assert.equal(MockRemoteAPI.requests[5].url, '/json/builders/some-builder-1/pendingBuilds');
@@ -346,7 +326,7 @@ describe('BuildbotTriggerable', function () {
                 assert.equal(MockRemoteAPI.requests[6].url, '/json/builders/some%20builder%202/pendingBuilds');
                 MockRemoteAPI.requests[6].resolve([]);
                 return MockRemoteAPI.waitForRequest();
-            }).then(function () {
+            }).then(() => {
                 assert.equal(MockRemoteAPI.requests.length, 9);
                 assert.equal(MockRemoteAPI.requests[7].method, 'GET');
                 assert.equal(MockRemoteAPI.requests[7].url, '/json/builders/some-builder-1/builds/?select=-1&select=-2');
@@ -355,7 +335,7 @@ describe('BuildbotTriggerable', function () {
                 assert.equal(MockRemoteAPI.requests[8].url, '/json/builders/some%20builder%202/builds/?select=-1&select=-2');
                 MockRemoteAPI.requests[8].resolve({});
                 return syncPromise;
-            }).then(function () {
+            }).then(() => {
                 assert.equal(BuildRequest.all().length, 4);
                 assert.equal(BuildRequest.findById(700).status(), 'pending');
                 assert.equal(BuildRequest.findById(700).statusUrl(), null);
@@ -366,7 +346,7 @@ describe('BuildbotTriggerable', function () {
                 assert.equal(BuildRequest.findById(703).status(), 'pending');
                 assert.equal(BuildRequest.findById(703).statusUrl(), null);
                 return BuildRequest.fetchForTriggerable(MockData.mockTestSyncConfigWithTwoBuilders().triggerableName);
-            }).then(function () {
+            }).then(() => {
                 assert.equal(BuildRequest.all().length, 4);
                 assert.equal(BuildRequest.findById(700).status(), 'failed');
                 assert.equal(BuildRequest.findById(700).statusUrl(), 'http://build.webkit.org/builders/some-builder-1/builds/123');
@@ -376,50 +356,46 @@ describe('BuildbotTriggerable', function () {
                 assert.equal(BuildRequest.findById(702).statusUrl(), 'http://build.webkit.org/builders/some-builder-1/');
                 assert.equal(BuildRequest.findById(703).status(), 'pending');
                 assert.equal(BuildRequest.findById(703).statusUrl(), null);
-                done();
-            }).catch(done);
+            });
         });
 
-        it('should update the status of a scheduled build if the pending build had started running', function (done) {
-            let db = TestServer.database();
+        it('should update the status of a scheduled build if the pending build had started running', () => {
+            const db = TestServer.database();
             let syncPromise;
-            db.connect().then(function () {
-                return MockData.addMockData(db, ['scheduled', 'pending', 'pending', 'pending']);
-            }).then(function () {
+            return MockData.addMockData(db, ['scheduled', 'pending', 'pending', 'pending']).then(() => {
                 return Manifest.fetch();
-            }).then(function () {
+            }).then(() => {
                 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);
                 syncPromise = triggerable.syncOnce();
-                syncPromise.catch(done);
                 return MockRemoteAPI.waitForRequest();
-            }).then(function () {
+            }).then(() => {
                 assert.equal(MockRemoteAPI.requests.length, 1);
                 assert.equal(MockRemoteAPI.requests[0].method, 'GET');
                 assert.equal(MockRemoteAPI.requests[0].url, '/json/builders/some-builder-1/pendingBuilds');
                 MockRemoteAPI.requests[0].resolve([MockData.pendingBuild({buildRequestId: 700})]);
                 return MockRemoteAPI.waitForRequest();
-            }).then(function () {
+            }).then(() => {
                 assert.equal(MockRemoteAPI.requests.length, 2);
                 assert.equal(MockRemoteAPI.requests[1].method, 'GET');
                 assert.equal(MockRemoteAPI.requests[1].url, '/json/builders/some-builder-1/builds/?select=-1&select=-2');
                 MockRemoteAPI.requests[1].resolve({});
                 return MockRemoteAPI.waitForRequest();
-            }).then(function () {
+            }).then(() => {
                 assert.equal(MockRemoteAPI.requests.length, 3);
                 assert.equal(MockRemoteAPI.requests[2].method, 'GET');
                 assert.equal(MockRemoteAPI.requests[2].url, '/json/builders/some-builder-1/pendingBuilds');
                 MockRemoteAPI.requests[2].resolve([]);
                 return MockRemoteAPI.waitForRequest();
-            }).then(function () {
+            }).then(() => {
                 assert.equal(MockRemoteAPI.requests.length, 4);
                 assert.equal(MockRemoteAPI.requests[3].method, 'GET');
                 assert.equal(MockRemoteAPI.requests[3].url, '/json/builders/some-builder-1/builds/?select=-1&select=-2');
                 MockRemoteAPI.requests[3].resolve({[-1]: MockData.runningBuild({buildRequestId: 700})});
                 return syncPromise;
-            }).then(function () {
+            }).then(() => {
                 assert.equal(BuildRequest.all().length, 4);
                 assert.equal(BuildRequest.findById(700).status(), 'scheduled');
                 assert.equal(BuildRequest.findById(700).statusUrl(), null);
@@ -430,7 +406,7 @@ describe('BuildbotTriggerable', function () {
                 assert.equal(BuildRequest.findById(703).status(), 'pending');
                 assert.equal(BuildRequest.findById(703).statusUrl(), null);
                 return BuildRequest.fetchForTriggerable(MockData.mockTestSyncConfigWithTwoBuilders().triggerableName);
-            }).then(function () {
+            }).then(() => {
                 assert.equal(BuildRequest.all().length, 4);
                 assert.equal(BuildRequest.findById(700).status(), 'running');
                 assert.equal(BuildRequest.findById(700).statusUrl(), 'http://build.webkit.org/builders/some-builder-1/builds/124');
@@ -440,29 +416,25 @@ describe('BuildbotTriggerable', function () {
                 assert.equal(BuildRequest.findById(702).statusUrl(), null);
                 assert.equal(BuildRequest.findById(703).status(), 'pending');
                 assert.equal(BuildRequest.findById(703).statusUrl(), null);
-                done();
-            }).catch(done);
+            });
         });
 
-        it('should schedule a build request on a builder without pending builds if the request belongs to a new test group', function (done) {
-            let db = TestServer.database();
+        it('should schedule a build request on a builder without pending builds if the request belongs to a new test group', () => {
+            const db = TestServer.database();
             let syncPromise;
-            db.connect().then(function () {
-                return Promise.all([
-                    MockData.addMockData(db, ['completed', 'pending', 'pending', 'pending']),
-                    MockData.addAnotherMockTestGroup(db, ['pending', 'pending', 'pending', 'pending'])
-                ]);
-            }).then(function () {
+            return Promise.all([
+                MockData.addMockData(db, ['completed', 'pending', 'pending', 'pending']),
+                MockData.addAnotherMockTestGroup(db, ['pending', 'pending', 'pending', 'pending'])
+            ]).then(() => {
                 return Manifest.fetch();
-            }).then(function () {
-                let config = MockData.mockTestSyncConfigWithTwoBuilders();
-                let logger = new MockLogger;
-                let slaveInfo = {name: 'sync-slave', password: 'password'};
-                let triggerable = new BuildbotTriggerable(config, TestServer.remoteAPI(), MockRemoteAPI, slaveInfo, logger);
+            }).then(() => {
+                const config = MockData.mockTestSyncConfigWithTwoBuilders();
+                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.catch(done);
                 return MockRemoteAPI.waitForRequest();
-            }).then(function () {
+            }).then(() => {
                 assert.equal(MockRemoteAPI.requests.length, 2);
                 assert.equal(MockRemoteAPI.requests[0].method, 'GET');
                 assert.equal(MockRemoteAPI.requests[0].url, '/json/builders/some-builder-1/pendingBuilds');
@@ -471,7 +443,7 @@ describe('BuildbotTriggerable', function () {
                 assert.equal(MockRemoteAPI.requests[1].url, '/json/builders/some%20builder%202/pendingBuilds');
                 MockRemoteAPI.requests[1].resolve([]);
                 return MockRemoteAPI.waitForRequest();
-            }).then(function () {
+            }).then(() => {
                 assert.equal(MockRemoteAPI.requests.length, 4);
                 assert.equal(MockRemoteAPI.requests[2].method, 'GET');
                 assert.equal(MockRemoteAPI.requests[2].url, '/json/builders/some-builder-1/builds/?select=-1&select=-2');
@@ -480,14 +452,14 @@ describe('BuildbotTriggerable', function () {
                 assert.equal(MockRemoteAPI.requests[3].url, '/json/builders/some%20builder%202/builds/?select=-1&select=-2');
                 MockRemoteAPI.requests[3].resolve({});
                 return MockRemoteAPI.waitForRequest();
-            }).then(function () {
+            }).then(() => {
                 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'});
                 MockRemoteAPI.requests[4].resolve('OK');
                 return MockRemoteAPI.waitForRequest();
-            }).then(function () {
+            }).then(() => {
                 assert.equal(MockRemoteAPI.requests.length, 7);
                 assert.equal(MockRemoteAPI.requests[5].method, 'GET');
                 assert.equal(MockRemoteAPI.requests[5].url, '/json/builders/some-builder-1/pendingBuilds');
@@ -496,7 +468,7 @@ describe('BuildbotTriggerable', function () {
                 assert.equal(MockRemoteAPI.requests[6].url, '/json/builders/some%20builder%202/pendingBuilds');
                 MockRemoteAPI.requests[6].resolve([MockData.pendingBuild({builder: 'some builder 2', buildRequestId: 710})]);
                 return MockRemoteAPI.waitForRequest();
-            }).then(function () {
+            }).then(() => {
                 assert.equal(MockRemoteAPI.requests.length, 9);
                 assert.equal(MockRemoteAPI.requests[7].method, 'GET');
                 assert.equal(MockRemoteAPI.requests[7].url, '/json/builders/some-builder-1/builds/?select=-1&select=-2');
@@ -505,7 +477,7 @@ describe('BuildbotTriggerable', function () {
                 assert.equal(MockRemoteAPI.requests[8].url, '/json/builders/some%20builder%202/builds/?select=-1&select=-2');
                 MockRemoteAPI.requests[8].resolve({});
                 return syncPromise;
-            }).then(function () {
+            }).then(() => {
                 assert.equal(BuildRequest.all().length, 8);
                 assert.equal(BuildRequest.findById(700).status(), 'completed');
                 assert.equal(BuildRequest.findById(700).statusUrl(), null);
@@ -524,7 +496,7 @@ describe('BuildbotTriggerable', function () {
                 assert.equal(BuildRequest.findById(713).status(), 'pending');
                 assert.equal(BuildRequest.findById(713).statusUrl(), null);
                 return BuildRequest.fetchForTriggerable(MockData.mockTestSyncConfigWithTwoBuilders().triggerableName);
-            }).then(function () {
+            }).then(() => {
                 assert.equal(BuildRequest.all().length, 8);
                 assert.equal(BuildRequest.findById(700).status(), 'completed');
                 assert.equal(BuildRequest.findById(700).statusUrl(), 'http://build.webkit.org/builders/some-builder-1/builds/123');
@@ -542,29 +514,25 @@ describe('BuildbotTriggerable', function () {
                 assert.equal(BuildRequest.findById(712).statusUrl(), null);
                 assert.equal(BuildRequest.findById(713).status(), 'pending');
                 assert.equal(BuildRequest.findById(713).statusUrl(), null);
-                done();
-            }).catch(done);
+            });
         });
 
-        it('should schedule a build request on the same scheduler the first request had ran', function (done) {
-            let db = TestServer.database();
+        it('should schedule a build request on the same scheduler the first request had ran', () => {
+            const db = TestServer.database();
             let syncPromise;
-            db.connect().then(function () {
-                return Promise.all([
-                    MockData.addMockData(db, ['running', 'pending', 'pending', 'pending']),
-                    MockData.addAnotherMockTestGroup(db, ['running', 'pending', 'pending', 'pending'])
-                ]);
-            }).then(function () {
+            return Promise.all([
+                MockData.addMockData(db, ['running', 'pending', 'pending', 'pending']),
+                MockData.addAnotherMockTestGroup(db, ['running', 'pending', 'pending', 'pending'])
+            ]).then(() => {
                 return Manifest.fetch();
-            }).then(function () {
-                let config = MockData.mockTestSyncConfigWithTwoBuilders();
-                let logger = new MockLogger;
-                let slaveInfo = {name: 'sync-slave', password: 'password'};
-                let triggerable = new BuildbotTriggerable(config, TestServer.remoteAPI(), MockRemoteAPI, slaveInfo, logger);
+            }).then(() => {
+                const config = MockData.mockTestSyncConfigWithTwoBuilders();
+                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.catch(done);
                 return MockRemoteAPI.waitForRequest();
-            }).then(function () {
+            }).then(() => {
                 assert.equal(MockRemoteAPI.requests.length, 2);
                 assert.equal(MockRemoteAPI.requests[0].method, 'GET');
                 assert.equal(MockRemoteAPI.requests[0].url, '/json/builders/some-builder-1/pendingBuilds');
@@ -573,7 +541,7 @@ describe('BuildbotTriggerable', function () {
                 assert.equal(MockRemoteAPI.requests[1].url, '/json/builders/some%20builder%202/pendingBuilds');
                 MockRemoteAPI.requests[1].resolve([]);
                 return MockRemoteAPI.waitForRequest();
-            }).then(function () {
+            }).then(() => {
                 assert.equal(MockRemoteAPI.requests.length, 4);
                 assert.equal(MockRemoteAPI.requests[2].method, 'GET');
                 assert.equal(MockRemoteAPI.requests[2].url, '/json/builders/some-builder-1/builds/?select=-1&select=-2');
@@ -582,7 +550,7 @@ describe('BuildbotTriggerable', function () {
                 assert.equal(MockRemoteAPI.requests[3].url, '/json/builders/some%20builder%202/builds/?select=-1&select=-2');
                 MockRemoteAPI.requests[3].resolve({[-1]: MockData.runningBuild({builder: 'some builder 2', buildRequestId: 700})});
                 return MockRemoteAPI.waitForRequest();
-            }).then(function () {
+            }).then(() => {
                 assert.equal(MockRemoteAPI.requests.length, 6);
                 assert.equal(MockRemoteAPI.requests[4].method, 'POST');
                 assert.equal(MockRemoteAPI.requests[4].url, '/builders/some%20builder%202/force');
@@ -593,7 +561,7 @@ describe('BuildbotTriggerable', function () {
                 assert.deepEqual(MockRemoteAPI.requests[5].data, {'wk': '192736', 'os': '10.11 15A284', 'build-request-id': '711'});
                 MockRemoteAPI.requests[5].resolve('OK');
                 return MockRemoteAPI.waitForRequest();
-            }).then(function () {
+            }).then(() => {
                 assert.equal(MockRemoteAPI.requests.length, 8);
                 assert.equal(MockRemoteAPI.requests[6].method, 'GET');
                 assert.equal(MockRemoteAPI.requests[6].url, '/json/builders/some-builder-1/pendingBuilds');
@@ -602,7 +570,7 @@ describe('BuildbotTriggerable', function () {
                 assert.equal(MockRemoteAPI.requests[7].url, '/json/builders/some%20builder%202/pendingBuilds');
                 MockRemoteAPI.requests[7].resolve([MockData.pendingBuild({builder: 'some builder 2',buildRequestId: 701})]);
                 return MockRemoteAPI.waitForRequest();
-            }).then(function () {
+            }).then(() => {
                 assert.equal(MockRemoteAPI.requests.length, 10);
                 assert.equal(MockRemoteAPI.requests[8].method, 'GET');
                 assert.equal(MockRemoteAPI.requests[8].url, '/json/builders/some-builder-1/builds/?select=-1&select=-2');
@@ -611,7 +579,7 @@ describe('BuildbotTriggerable', function () {
                 assert.equal(MockRemoteAPI.requests[9].url, '/json/builders/some%20builder%202/builds/?select=-1&select=-2');
                 MockRemoteAPI.requests[9].resolve({[-1]: MockData.runningBuild({builder: 'some builder 2', buildRequestId: 700})});
                 return syncPromise;
-            }).then(function () {
+            }).then(() => {
                 assert.equal(BuildRequest.all().length, 8);
                 assert.equal(BuildRequest.findById(700).status(), 'running');
                 assert.equal(BuildRequest.findById(700).statusUrl(), null);
@@ -630,7 +598,7 @@ describe('BuildbotTriggerable', function () {
                 assert.equal(BuildRequest.findById(713).status(), 'pending');
                 assert.equal(BuildRequest.findById(713).statusUrl(), null);
                 return BuildRequest.fetchForTriggerable(MockData.mockTestSyncConfigWithTwoBuilders().triggerableName);
-            }).then(function () {
+            }).then(() => {
                 assert.equal(BuildRequest.all().length, 8);
                 assert.equal(BuildRequest.findById(700).status(), 'running');
                 assert.equal(BuildRequest.findById(700).statusUrl(), 'http://build.webkit.org/builders/some%20builder%202/builds/124');
@@ -648,53 +616,49 @@ describe('BuildbotTriggerable', function () {
                 assert.equal(BuildRequest.findById(712).statusUrl(), null);
                 assert.equal(BuildRequest.findById(713).status(), 'pending');
                 assert.equal(BuildRequest.findById(713).statusUrl(), null);
-                done();
-            }).catch(done);
+            });
         });
 
-        it('should recover from multiple test groups running simultenously', function (done) {
-            let db = TestServer.database();
+        it('should recover from multiple test groups running simultenously', () => {
+            const db = TestServer.database();
             let syncPromise;
-            db.connect().then(function () {
-                return Promise.all([
-                    MockData.addMockData(db, ['completed', 'pending', 'pending', 'pending']),
-                    MockData.addAnotherMockTestGroup(db, ['completed', 'pending', 'pending', 'pending'])
-                ]);
-            }).then(function () {
+            return Promise.all([
+                MockData.addMockData(db, ['completed', 'pending', 'pending', 'pending']),
+                MockData.addAnotherMockTestGroup(db, ['completed', 'pending', 'pending', 'pending'])
+            ]).then(() => {
                 return Manifest.fetch();
-            }).then(function () {
-                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);
+            }).then(() => {
+                const config = MockData.mockTestSyncConfigWithSingleBuilder();
+                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.catch(done);
                 return MockRemoteAPI.waitForRequest();
-            }).then(function () {
+            }).then(() => {
                 assert.equal(MockRemoteAPI.requests.length, 1);
                 assert.equal(MockRemoteAPI.requests[0].method, 'GET');
                 assert.equal(MockRemoteAPI.requests[0].url, '/json/builders/some-builder-1/pendingBuilds');
                 MockRemoteAPI.requests[0].resolve([MockData.pendingBuild({buildRequestId: 711})]);
                 return MockRemoteAPI.waitForRequest();
-            }).then(function () {
+            }).then(() => {
                 assert.equal(MockRemoteAPI.requests.length, 2);
                 assert.equal(MockRemoteAPI.requests[1].method, 'GET');
                 assert.equal(MockRemoteAPI.requests[1].url, '/json/builders/some-builder-1/builds/?select=-1&select=-2');
                 MockRemoteAPI.requests[1].resolve({[-1]: MockData.runningBuild({buildRequestId: 700}), [-2]: MockData.finishedBuild({buildRequestId: 710})});
                 return MockRemoteAPI.waitForRequest();
-            }).then(function () {
+            }).then(() => {
                 assert.equal(MockRemoteAPI.requests.length, 3);
                 assert.equal(MockRemoteAPI.requests[2].method, 'GET');
                 assert.equal(MockRemoteAPI.requests[2].url, '/json/builders/some-builder-1/pendingBuilds');
                 MockRemoteAPI.requests[2].resolve([MockData.pendingBuild({buildRequestId: 701})]);
                 return MockRemoteAPI.waitForRequest();
-            }).then(function () {
+            }).then(() => {
                 assert.equal(MockRemoteAPI.requests.length, 4);
                 assert.equal(MockRemoteAPI.requests[3].method, 'GET');
                 assert.equal(MockRemoteAPI.requests[3].url, '/json/builders/some-builder-1/builds/?select=-1&select=-2');
                 MockRemoteAPI.requests[3].resolve({[-1]: MockData.runningBuild({buildRequestId: 700}), [-2]: MockData.finishedBuild({buildRequestId: 710})});
                 return syncPromise;
-            }).then(function () {
+            }).then(() => {
                 assert.equal(BuildRequest.all().length, 8);
                 assert.equal(BuildRequest.findById(700).status(), 'completed');
                 assert.equal(BuildRequest.findById(700).statusUrl(), null);
@@ -713,7 +677,7 @@ describe('BuildbotTriggerable', function () {
                 assert.equal(BuildRequest.findById(713).status(), 'pending');
                 assert.equal(BuildRequest.findById(713).statusUrl(), null);
                 return BuildRequest.fetchForTriggerable(MockData.mockTestSyncConfigWithTwoBuilders().triggerableName);
-            }).then(function () {
+            }).then(() => {
                 assert.equal(BuildRequest.all().length, 8);
                 assert.equal(BuildRequest.findById(700).status(), 'completed');
                 assert.equal(BuildRequest.findById(700).statusUrl(), 'http://build.webkit.org/builders/some-builder-1/builds/124');
@@ -731,59 +695,53 @@ describe('BuildbotTriggerable', function () {
                 assert.equal(BuildRequest.findById(712).statusUrl(), null);
                 assert.equal(BuildRequest.findById(713).status(), 'pending');
                 assert.equal(BuildRequest.findById(713).statusUrl(), null);
-                done();
-            }).catch(done);
+            });
         });
 
-        it('should recover from missing failed build request', function (done) {
-            let db = TestServer.database();
+        it('should recover from missing failed build request', () => {
+            const db = TestServer.database();
             let syncPromise;
-            db.connect().then(function () {
-                return Promise.all([
-                    MockData.addMockData(db, ['failed', 'pending', 'pending', 'pending']),
-                ]);
-            }).then(function () {
+            return MockData.addMockData(db, ['failed', 'pending', 'pending', 'pending']).then(() => {
                 return Manifest.fetch();
-            }).then(function () {
-                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);
+            }).then(() => {
+                const config = MockData.mockTestSyncConfigWithSingleBuilder();
+                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.catch(done);
                 return MockRemoteAPI.waitForRequest();
-            }).then(function () {
+            }).then(() => {
                 assert.equal(MockRemoteAPI.requests.length, 1);
                 assert.equal(MockRemoteAPI.requests[0].method, 'GET');
                 assert.equal(MockRemoteAPI.requests[0].url, '/json/builders/some-builder-1/pendingBuilds');
                 MockRemoteAPI.requests[0].resolve([]);
                 return MockRemoteAPI.waitForRequest();
-            }).then(function () {
+            }).then(() => {
                 assert.equal(MockRemoteAPI.requests.length, 2);
                 assert.equal(MockRemoteAPI.requests[1].method, 'GET');
                 assert.equal(MockRemoteAPI.requests[1].url, '/json/builders/some-builder-1/builds/?select=-1&select=-2');
                 MockRemoteAPI.requests[1].resolve({});
                 return MockRemoteAPI.waitForRequest();
-            }).then(function () {
+            }).then(() => {
                 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'});
                 MockRemoteAPI.requests[2].resolve('OK');
                 return MockRemoteAPI.waitForRequest();
-            }).then(function () {
+            }).then(() => {
                 assert.equal(MockRemoteAPI.requests.length, 4);
                 assert.equal(MockRemoteAPI.requests[3].method, 'GET');
                 assert.equal(MockRemoteAPI.requests[3].url, '/json/builders/some-builder-1/pendingBuilds');
                 MockRemoteAPI.requests[3].resolve([MockData.pendingBuild({buildRequestId: 701})]);
                 return MockRemoteAPI.waitForRequest();
-            }).then(function () {
+            }).then(() => {
                 assert.equal(MockRemoteAPI.requests.length, 5);
                 assert.equal(MockRemoteAPI.requests[4].method, 'GET');
                 assert.equal(MockRemoteAPI.requests[4].url, '/json/builders/some-builder-1/builds/?select=-1&select=-2');
                 MockRemoteAPI.requests[4].resolve({});
                 return syncPromise;
-            }).then(function () {
+            }).then(() => {
                 assert.equal(BuildRequest.all().length, 4);
                 assert.equal(BuildRequest.findById(700).status(), 'failed');
                 assert.equal(BuildRequest.findById(700).statusUrl(), null);
@@ -794,7 +752,7 @@ describe('BuildbotTriggerable', function () {
                 assert.equal(BuildRequest.findById(703).status(), 'pending');
                 assert.equal(BuildRequest.findById(703).statusUrl(), null);
                 return BuildRequest.fetchForTriggerable(MockData.mockTestSyncConfigWithTwoBuilders().triggerableName);
-            }).then(function () {
+            }).then(() => {
                 assert.equal(BuildRequest.all().length, 4);
                 assert.equal(BuildRequest.findById(700).status(), 'failed');
                 assert.equal(BuildRequest.findById(700).statusUrl(), null);
@@ -804,113 +762,102 @@ describe('BuildbotTriggerable', function () {
                 assert.equal(BuildRequest.findById(702).statusUrl(), null);
                 assert.equal(BuildRequest.findById(703).status(), 'pending');
                 assert.equal(BuildRequest.findById(703).statusUrl(), null);
-                done();
-            }).catch(done);
+            });
         });
 
-        it('should update the status of a supposedly scheduled build that went missing', function (done) {
-            let db = TestServer.database();
+        it('should update the status of a supposedly scheduled build that went missing', () => {
+            const db = TestServer.database();
             let syncPromise;
-            db.connect().then(function () {
-                return MockData.addMockData(db, ['scheduled', 'pending', 'pending', 'pending']);
-            }).then(function () {
+            return MockData.addMockData(db, ['scheduled', 'pending', 'pending', 'pending']).then(() => {
                 return Manifest.fetch();
-            }).then(function () {
-                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);
+            }).then(() => {
+                const config = MockData.mockTestSyncConfigWithSingleBuilder();
+                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.catch(done);
                 return MockRemoteAPI.waitForRequest();
-            }).then(function () {
+            }).then(() => {
                 assert.equal(MockRemoteAPI.requests.length, 1);
                 assert.equal(MockRemoteAPI.requests[0].method, 'GET');
                 assert.equal(MockRemoteAPI.requests[0].url, '/json/builders/some-builder-1/pendingBuilds');
                 MockRemoteAPI.requests[0].resolve([]);
                 return MockRemoteAPI.waitForRequest();
-            }).then(function () {
+            }).then(() => {
                 assert.equal(MockRemoteAPI.requests.length, 2);
                 assert.equal(MockRemoteAPI.requests[1].method, 'GET');
                 assert.equal(MockRemoteAPI.requests[1].url, '/json/builders/some-builder-1/builds/?select=-1&select=-2');
                 MockRemoteAPI.requests[1].resolve({});
                 return MockRemoteAPI.waitForRequest();
-            }).then(function () {
+            }).then(() => {
                 assert.equal(MockRemoteAPI.requests.length, 3);
                 assert.equal(MockRemoteAPI.requests[2].method, 'GET');
                 assert.equal(MockRemoteAPI.requests[2].url, '/json/builders/some-builder-1/pendingBuilds');
                 MockRemoteAPI.requests[2].resolve([]);
                 return MockRemoteAPI.waitForRequest();
-            }).then(function () {
+            }).then(() => {
                 assert.equal(MockRemoteAPI.requests.length, 4);
                 assert.equal(MockRemoteAPI.requests[3].method, 'GET');
                 assert.equal(MockRemoteAPI.requests[3].url, '/json/builders/some-builder-1/builds/?select=-1&select=-2');
                 MockRemoteAPI.requests[3].resolve({});
                 return syncPromise;
-            }).then(function () {
+            }).then(() => {
                 assert.equal(BuildRequest.all().length, 4);
                 assert.equal(BuildRequest.findById(700).status(), 'scheduled');
                 assert.equal(BuildRequest.findById(701).status(), 'pending');
                 assert.equal(BuildRequest.findById(702).status(), 'pending');
                 assert.equal(BuildRequest.findById(703).status(), 'pending');
                 return BuildRequest.fetchForTriggerable(MockData.mockTestSyncConfigWithTwoBuilders().triggerableName);
-            }).then(function () {
+            }).then(() => {
                 assert.equal(BuildRequest.all().length, 4);
                 assert.equal(BuildRequest.findById(700).status(), 'failed');
                 assert.equal(BuildRequest.findById(701).status(), 'pending');
                 assert.equal(BuildRequest.findById(702).status(), 'pending');
                 assert.equal(BuildRequest.findById(703).status(), 'pending');
-                done();
-            }).catch(done);
+            });
         });
 
-        it('should schedule a build request of an user created test group before ones created by automatic change detection', function (done) {
-            let db = TestServer.database();
+        it('should schedule a build request of an user created test group before ones created by automatic change detection', () => {
+            const db = TestServer.database();
             let syncPromise;
-            db.connect().then(function () {
-                return Promise.all([
-                    MockData.addMockData(db, ['pending', 'pending', 'pending', 'pending']),
-                    MockData.addAnotherMockTestGroup(db, ['pending', 'pending', 'pending', 'pending'], 'rniwa'),
-                ]);
-            }).then(function () {
+            return Promise.all([
+                MockData.addMockData(db, ['pending', 'pending', 'pending', 'pending']),
+                MockData.addAnotherMockTestGroup(db, ['pending', 'pending', 'pending', 'pending'], 'rniwa'),
+            ]).then(() => {
                 return Manifest.fetch();
-            }).then(function () {
-                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);
+            }).then(() => {
+                const config = MockData.mockTestSyncConfigWithSingleBuilder();
+                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.catch(done);
                 return MockRemoteAPI.waitForRequest();
-            }).then(function () {
+            }).then(() => {
                 assert.equal(MockRemoteAPI.requests.length, 1);
                 assert.equal(MockRemoteAPI.requests[0].method, 'GET');
                 assert.equal(MockRemoteAPI.requests[0].url, '/json/builders/some-builder-1/pendingBuilds');
                 MockRemoteAPI.requests[0].resolve([]);
                 return MockRemoteAPI.waitForRequest();
-            }).then(function () {
+            }).then(() => {
                 assert.equal(MockRemoteAPI.requests.length, 2);
                 assert.equal(MockRemoteAPI.requests[1].method, 'GET');
                 assert.equal(MockRemoteAPI.requests[1].url, '/json/builders/some-builder-1/builds/?select=-1&select=-2');
                 MockRemoteAPI.requests[1].resolve({});
                 return MockRemoteAPI.waitForRequest();
-            }).then(function () {
+            }).then(() => {
                 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'});
                 MockRemoteAPI.requests[2].resolve('OK');
-                done();
-            }).catch(done);
+            });
         });
     });
 
-    describe('updateTriggerables', function () {
-        connectToDatabaseInEveryTest();
-
-        it('should update available triggerables', function (done) {
-            let db = TestServer.database();
-            MockData.addMockData(db).then(() => {
+    describe('updateTriggerables', () => {
+        it('should update available triggerables', () => {
+            const db = TestServer.database();
+            return MockData.addMockData(db).then(() => {
                 return Manifest.fetch();
             }).then(() => {
                 return db.selectAll('triggerable_configurations', 'test');
@@ -949,9 +896,7 @@ describe('BuildbotTriggerable', function () {
                 let platform = Platform.findById(MockData.somePlatformId());
                 let triggerable = Triggerable.findByTestConfiguration(test, platform);
                 assert.equal(triggerable.name(), 'build-webkit');
-
-                done();
-            }).catch(done);
+            });
         });
     });