Syncing script's configuration duplicates a lot of boilerplate
[WebKit-https.git] / Websites / perf.webkit.org / unit-tests / buildbot-syncer-tests.js
index 5bb8ccf..b45a5b7 100644 (file)
@@ -58,6 +58,58 @@ function sampleiOSConfig()
     };
 }
 
+function sampleiOSConfigWithExpansions()
+{
+    return {
+        "triggerableName": "build-webkit-ios",
+        "shared":
+            {
+                "arguments": {
+                    "webkit-revision": {"root": "WebKit"},
+                    "os-version": {"root": "iOS"}
+                },
+                "buildRequestArgument": "build-request-id"
+            },
+        "types": {
+            "iphone-plt": {
+                "test": ["PLT-iPhone"],
+                "arguments": {"test_name": "plt"}
+            },
+            "ipad-plt": {
+                "test": ["PLT-iPad"],
+                "arguments": {"test_name": "plt"}
+            },
+            "speedometer": {
+                "test": ["Speedometer"],
+                "arguments": {"tests": "speedometer"}
+            },
+        },
+        "builders": {
+            "iphone": {
+                "builder": "iPhone AB Tests",
+                "arguments": {"forcescheduler": "force-iphone-ab-tests"}
+            },
+            "ipad": {
+                "builder": "iPad AB Tests",
+                "arguments": {"forcescheduler": "force-ipad-ab-tests"}
+            },
+        },
+        "configurations": [
+            {
+                "builder": "iphone",
+                "platforms": ["iPhone", "iOS 10 iPhone"],
+                "types": ["iphone-plt", "speedometer"],
+            },
+            {
+                "builder": "ipad",
+                "platforms": ["iPad"],
+                "types": ["ipad-plt", "speedometer"],
+            },
+        ]
+    }
+    
+}
+
 let sampleRootSetData = {
     'WebKit': {
         'id': '111127',
@@ -482,6 +534,30 @@ describe('BuildbotSyncer', function () {
             assert.equal(configurations[1].platform, MockModels.ipad);
             assert.equal(configurations[1].test, MockModels.jetstream);
         });
+
+        it('should parse test configurations with types and platforms expansions correctly', function () {
+            let syncers = BuildbotSyncer._loadConfig(RemoteAPI, sampleiOSConfigWithExpansions());
+
+            assert.equal(syncers.length, 2);
+
+            let configurations = syncers[0].testConfigurations();
+            assert.equal(configurations.length, 4);
+            assert.equal(configurations[0].platform, MockModels.iphone);
+            assert.equal(configurations[0].test, MockModels.iPhonePLT);
+            assert.equal(configurations[1].platform, MockModels.iOS10iPhone);
+            assert.equal(configurations[1].test, MockModels.iPhonePLT);
+            assert.equal(configurations[2].platform, MockModels.iphone);
+            assert.equal(configurations[2].test, MockModels.speedometer);
+            assert.equal(configurations[3].platform, MockModels.iOS10iPhone);
+            assert.equal(configurations[3].test, MockModels.speedometer);
+
+            configurations = syncers[1].testConfigurations();
+            assert.equal(configurations.length, 2);
+            assert.equal(configurations[0].platform, MockModels.ipad);
+            assert.equal(configurations[0].test, MockModels.iPadPLT);
+            assert.equal(configurations[1].platform, MockModels.ipad);
+            assert.equal(configurations[1].test, MockModels.speedometer);
+        });
     });
 
     describe('_propertiesForBuildRequest', function () {
@@ -827,7 +903,7 @@ describe('BuildbotSyncer', function () {
         });
     });
 
-    describe('scheduleFirstRequestInGroupIfAvailable', function () {
+    describe('scheduleRequestInGroupIfAvailable', function () {
 
         function pullBuildbotWithAssertion(syncer, pendingBuilds, inProgressAndFinishedBuilds)
         {
@@ -847,10 +923,10 @@ describe('BuildbotSyncer', function () {
             let syncer = BuildbotSyncer._loadConfig(MockRemoteAPI, {'configurations': [smallConfiguration()]})[0];
 
             pullBuildbotWithAssertion(syncer, [], {}).then(function () {
-                syncer.scheduleFirstRequestInGroupIfAvailable(createSampleBuildRequest(MockModels.somePlatform, MockModels.someTest));
+                syncer.scheduleRequestInGroupIfAvailable(createSampleBuildRequest(MockModels.somePlatform, MockModels.someTest));
             }).then(function () {
                 assert.equal(requests.length, 1);
-                assert.equal(requests[0].url, '/builders/some builder/force');
+                assert.equal(requests[0].url, '/builders/some%20builder/force');
                 assert.equal(requests[0].method, 'POST');
                 assert.deepEqual(requests[0].data, {id: '16733-' + MockModels.somePlatform.id()});
                 done();
@@ -861,10 +937,10 @@ describe('BuildbotSyncer', function () {
             let syncer = BuildbotSyncer._loadConfig(MockRemoteAPI, {'configurations': [smallConfiguration()]})[0];
 
             pullBuildbotWithAssertion(syncer, [], {[-1]: smallFinishedBuild()}).then(function () {
-                syncer.scheduleFirstRequestInGroupIfAvailable(createSampleBuildRequest(MockModels.somePlatform, MockModels.someTest));
+                syncer.scheduleRequestInGroupIfAvailable(createSampleBuildRequest(MockModels.somePlatform, MockModels.someTest));
             }).then(function () {
                 assert.equal(requests.length, 1);
-                assert.equal(requests[0].url, '/builders/some builder/force');
+                assert.equal(requests[0].url, '/builders/some%20builder/force');
                 assert.equal(requests[0].method, 'POST');
                 assert.deepEqual(requests[0].data, {id: '16733-' + MockModels.somePlatform.id()});
                 done();
@@ -875,7 +951,7 @@ describe('BuildbotSyncer', function () {
             let syncer = BuildbotSyncer._loadConfig(MockRemoteAPI, {'configurations': [smallConfiguration()]})[0];
 
             pullBuildbotWithAssertion(syncer, [smallPendingBuild()], {}).then(function () {
-                syncer.scheduleFirstRequestInGroupIfAvailable(createSampleBuildRequest(MockModels.somePlatform, MockModels.someTest));
+                syncer.scheduleRequestInGroupIfAvailable(createSampleBuildRequest(MockModels.somePlatform, MockModels.someTest));
             }).then(function () {
                 assert.equal(requests.length, 0);
                 done();
@@ -886,7 +962,7 @@ describe('BuildbotSyncer', function () {
             let syncer = BuildbotSyncer._loadConfig(MockRemoteAPI, sampleiOSConfig())[0];
 
             pullBuildbotWithAssertion(syncer, [], {}).then(function () {
-                syncer.scheduleFirstRequestInGroupIfAvailable(createSampleBuildRequest(MockModels.iphone, MockModels.speedometer));
+                syncer.scheduleRequestInGroupIfAvailable(createSampleBuildRequest(MockModels.iphone, MockModels.speedometer));
             }).then(function () {
                 assert.equal(requests.length, 1);
                 assert.equal(requests[0].url, '/builders/ABTest-iPhone-RunBenchmark-Tests/force');
@@ -899,7 +975,7 @@ describe('BuildbotSyncer', function () {
             let syncer = BuildbotSyncer._loadConfig(MockRemoteAPI, sampleiOSConfig())[1];
 
             pullBuildbotWithAssertion(syncer, [], {[-1]: sampleFinishedBuild()}).then(function () {
-                syncer.scheduleFirstRequestInGroupIfAvailable(createSampleBuildRequest(MockModels.ipad, MockModels.speedometer));
+                syncer.scheduleRequestInGroupIfAvailable(createSampleBuildRequest(MockModels.ipad, MockModels.speedometer));
             }).then(function () {
                 assert.equal(requests.length, 1);
                 assert.equal(requests[0].url, '/builders/ABTest-iPad-RunBenchmark-Tests/force');
@@ -912,7 +988,7 @@ describe('BuildbotSyncer', function () {
             let syncer = BuildbotSyncer._loadConfig(MockRemoteAPI, sampleiOSConfig())[1];
 
             pullBuildbotWithAssertion(syncer, [samplePendingBuild()], {}).then(function () {
-                syncer.scheduleFirstRequestInGroupIfAvailable(createSampleBuildRequest(MockModels.ipad, MockModels.speedometer));
+                syncer.scheduleRequestInGroupIfAvailable(createSampleBuildRequest(MockModels.ipad, MockModels.speedometer));
             }).then(function () {
                 assert.equal(requests.length, 0);
                 done();
@@ -923,7 +999,7 @@ describe('BuildbotSyncer', function () {
             let syncer = BuildbotSyncer._loadConfig(MockRemoteAPI, sampleiOSConfig())[1];
 
             pullBuildbotWithAssertion(syncer, [samplePendingBuild(1, 1, 'another-slave')], {}).then(function () {
-                syncer.scheduleFirstRequestInGroupIfAvailable(createSampleBuildRequest(MockModels.ipad, MockModels.speedometer));
+                syncer.scheduleRequestInGroupIfAvailable(createSampleBuildRequest(MockModels.ipad, MockModels.speedometer));
             }).then(function () {
                 assert.equal(requests.length, 1);
                 done();
@@ -934,7 +1010,7 @@ describe('BuildbotSyncer', function () {
             let syncer = BuildbotSyncer._loadConfig(MockRemoteAPI, sampleiOSConfig())[1];
 
             pullBuildbotWithAssertion(syncer, [], {[-1]: sampleInProgressBuild()}).then(function () {
-                syncer.scheduleFirstRequestInGroupIfAvailable(createSampleBuildRequest(MockModels.ipad, MockModels.speedometer));
+                syncer.scheduleRequestInGroupIfAvailable(createSampleBuildRequest(MockModels.ipad, MockModels.speedometer));
             }).then(function () {
                 assert.equal(requests.length, 1);
                 done();
@@ -945,7 +1021,7 @@ describe('BuildbotSyncer', function () {
             let syncer = BuildbotSyncer._loadConfig(MockRemoteAPI, sampleiOSConfig())[1];
 
             pullBuildbotWithAssertion(syncer, [], {[-1]: sampleInProgressBuild('other-slave')}).then(function () {
-                syncer.scheduleFirstRequestInGroupIfAvailable(createSampleBuildRequest(MockModels.ipad, MockModels.speedometer));
+                syncer.scheduleRequestInGroupIfAvailable(createSampleBuildRequest(MockModels.ipad, MockModels.speedometer));
             }).then(function () {
                 assert.equal(requests.length, 1);
                 done();
@@ -956,7 +1032,7 @@ describe('BuildbotSyncer', function () {
             let syncer = BuildbotSyncer._loadConfig(MockRemoteAPI, sampleiOSConfig())[0];
 
             pullBuildbotWithAssertion(syncer, [], {}).then(function () {
-                syncer.scheduleFirstRequestInGroupIfAvailable(createSampleBuildRequest(MockModels.ipad, MockModels.speedometer));
+                syncer.scheduleRequestInGroupIfAvailable(createSampleBuildRequest(MockModels.ipad, MockModels.speedometer));
             }).then(function () {
                 assert.equal(requests.length, 0);
                 done();
@@ -971,7 +1047,7 @@ describe('BuildbotSyncer', function () {
                 syncer.scheduleRequest(createSampleBuildRequest(MockModels.ipad, MockModels.speedometer), 'ABTest-iPad-1');
             }).then(function () {
                 assert.equal(requests.length, 2);
-                syncer.scheduleFirstRequestInGroupIfAvailable(createSampleBuildRequest(MockModels.ipad, MockModels.speedometer));
+                syncer.scheduleRequestInGroupIfAvailable(createSampleBuildRequest(MockModels.ipad, MockModels.speedometer));
             }).then(function () {
                 assert.equal(requests.length, 2);
                 done();
@@ -985,7 +1061,7 @@ describe('BuildbotSyncer', function () {
                 syncer.scheduleRequest(createSampleBuildRequest(MockModels.ipad, MockModels.speedometer), 'ABTest-iPad-0');
             }).then(function () {
                 assert.equal(requests.length, 1);
-                syncer.scheduleFirstRequestInGroupIfAvailable(createSampleBuildRequest(MockModels.ipad, MockModels.speedometer), 'ABTest-iPad-1');
+                syncer.scheduleRequestInGroupIfAvailable(createSampleBuildRequest(MockModels.ipad, MockModels.speedometer), 'ABTest-iPad-1');
             }).then(function () {
                 assert.equal(requests.length, 2);
                 done();
@@ -999,7 +1075,7 @@ describe('BuildbotSyncer', function () {
                 syncer.scheduleRequest(createSampleBuildRequest(MockModels.somePlatform, MockModels.someTest), null);
             }).then(function () {
                 assert.equal(requests.length, 1);
-                syncer.scheduleFirstRequestInGroupIfAvailable(createSampleBuildRequest(MockModels.somePlatform, MockModels.someTest));
+                syncer.scheduleRequestInGroupIfAvailable(createSampleBuildRequest(MockModels.somePlatform, MockModels.someTest));
             }).then(function () {
                 assert.equal(requests.length, 1);
                 done();