'buildbot-syncer.js' should be able to determine force build argument from a list...
authordewei_zhu@apple.com <dewei_zhu@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 19 Jan 2017 03:19:37 +0000 (03:19 +0000)
committerdewei_zhu@apple.com <dewei_zhu@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 19 Jan 2017 03:19:37 +0000 (03:19 +0000)
https://bugs.webkit.org/show_bug.cgi?id=167152

Reviewed by Ryosuke Niwa.

Add 'rootOptions' key which maps to a list of possible repositories.
For a build request, only one of the repositories in the list is valid.

* tools/js/buildbot-syncer.js:
(BuildbotSyncer.prototype._propertiesForBuildRequest):
(BuildbotSyncer._validateAndMergeProperties):
(BuildbotSyncer):
* unit-tests/buildbot-syncer-tests.js:
(sampleiOSConfig):
(sampleiOSConfigWithExpansions):
(createSampleBuildRequest):
(Promise.resolve.then):
* unit-tests/resources/mock-v3-models.js:
(MockModels.inject):

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

Websites/perf.webkit.org/ChangeLog
Websites/perf.webkit.org/tools/js/buildbot-syncer.js
Websites/perf.webkit.org/unit-tests/buildbot-syncer-tests.js
Websites/perf.webkit.org/unit-tests/resources/mock-v3-models.js

index 4ca0c09a80b6500213a7a764acc469ff16a2600e..489fff610a50611ecf7ed6510701a5dafa66f18d 100644 (file)
@@ -1,3 +1,25 @@
+2017-01-18  Dewei Zhu  <dewei_zhu@apple.com>
+
+        'buildbot-syncer.js' should be able to determine force build argument from a list of possible repositories.
+        https://bugs.webkit.org/show_bug.cgi?id=167152
+
+        Reviewed by Ryosuke Niwa.
+
+        Add 'rootOptions' key which maps to a list of possible repositories.
+        For a build request, only one of the repositories in the list is valid.
+
+        * tools/js/buildbot-syncer.js:
+        (BuildbotSyncer.prototype._propertiesForBuildRequest):
+        (BuildbotSyncer._validateAndMergeProperties):
+        (BuildbotSyncer):
+        * unit-tests/buildbot-syncer-tests.js:
+        (sampleiOSConfig):
+        (sampleiOSConfigWithExpansions):
+        (createSampleBuildRequest):
+        (Promise.resolve.then):
+        * unit-tests/resources/mock-v3-models.js:
+        (MockModels.inject):
+
 2017-01-17  Ryosuke Niwa  <rniwa@webkit.org>
 
         Make calls to render() functions async
index af60dea214663c0c05b5bfea8d8ce7c3c67da6ea..88aed05ab885a11a987a97c42e1de6fa6dbb0da3 100644 (file)
@@ -222,9 +222,14 @@ class BuildbotSyncer {
             else if ('root' in value) {
                 let repositoryName = value['root'];
                 let repository = repositoryByName[repositoryName];
-                assert(repository, '"${repositoryName}" must be specified');
+                assert(repository, `"${repositoryName}" must be specified`);
                 properties[key] = rootSet.revisionForRepository(repository);
-            } else if ('rootsExcluding' in value) {
+            } else if ('rootOptions' in value) {
+                const filteredOptions = value['rootOptions'].filter((option) => option in repositoryByName);
+                assert.equal(filteredOptions.length, 1, `There should be exactly one valid root among "${value['rootOptions']}".`);
+                properties[key] = rootSet.revisionForRepository(repositoryByName[filteredOptions[0]]);
+            }
+            else if ('rootsExcluding' in value) {
                 let revisionSet = this._revisionSetFromRootSetWithExclusionList(rootSet, value['rootsExcluding']);
                 properties[key] = JSON.stringify(revisionSet);
             }
@@ -334,25 +339,25 @@ class BuildbotSyncer {
                 continue;
 
             switch (name) {
-            case 'properties': // fallthrough
+            case 'properties': // Fallthrough
             case 'arguments':
                 assert.equal(typeof(value), 'object', 'arguments should be a dictionary');
                 if (!config['properties'])
                     config['properties'] = {};
                 this._validateAndMergeProperties(config['properties'], value);
                 break;
-            case 'test': // fallthrough
-            case 'slaveList': // fallthrough
+            case 'test': // Fallthrough
+            case 'slaveList': // Fallthrough
             case 'platforms':
             case 'types':
                 assert(value instanceof Array, `${name} should be an array`);
                 assert(value.every(function (part) { return typeof part == 'string'; }), `${name} should be an array of strings`);
                 config[name] = value.slice();
                 break;
-            case 'type': // fallthrough
-            case 'builder': // fallthrough
-            case 'platform': // fallthrough
-            case 'slaveArgument': // fallthrough
+            case 'type': // Fallthrough
+            case 'builder': // Fallthrough
+            case 'platform': // Fallthrough
+            case 'slaveArgument': // Fallthrough
             case 'buildRequestArgument':
                 assert.equal(typeof(value), 'string', `${name} should be of string type`);
                 config[name] = value;
@@ -373,7 +378,7 @@ class BuildbotSyncer {
                 continue;
             }
             assert.equal(typeof(value), 'object', 'A argument value must be either a string or a dictionary');
-                
+
             let keys = Object.keys(value);
             assert.equal(keys.length, 1, 'arguments value cannot contain more than one key');
             let namedValue = value[keys[0]];
@@ -381,10 +386,11 @@ class BuildbotSyncer {
             case 'root':
                 assert.equal(typeof(namedValue), 'string', 'root name must be a string');
                 break;
+            case 'rootOptions': // Fallthrough
             case 'rootsExcluding':
-                assert(namedValue instanceof Array, 'rootsExcluding must specify an array');
+                assert(namedValue instanceof Array, `${keys[0]} must specify an array`);
                 for (let excludedRootName of namedValue)
-                    assert.equal(typeof(excludedRootName), 'string', 'rootsExcluding must specify an array of strings');
+                    assert.equal(typeof(excludedRootName), 'string', `${keys[0]} must specify an array of strings`);
                 namedValue = namedValue.slice();
                 break;
             default:
index b45a5b7833f847bbb90a4340e012dc4a42835186..bcf7dc4ad73c2632198bee6a710fa53ae4bad68f 100644 (file)
@@ -16,6 +16,7 @@ function sampleiOSConfig()
             {
                 'arguments': {
                     'desired_image': {'root': 'iOS'},
+                    'opensource': {'rootOptions': ['WebKit-SVN', 'WebKit-Git']},
                     'roots_dict': {'rootsExcluding': ['iOS']}
                 },
                 'slaveArgument': 'slavename',
@@ -107,7 +108,6 @@ function sampleiOSConfigWithExpansions()
             },
         ]
     }
-    
 }
 
 let sampleRootSetData = {
@@ -122,7 +122,13 @@ let sampleRootSetData = {
         'time': 1456931874000,
         'repository': 'Shared',
         'revision': '80229',
-    }
+    },
+    'WebKit-Git': {
+        "id":"111239",
+        "time":1456931874000,
+        "repository":"WebKit-Git",
+        "revision":"9abcdef",
+    },
 };
 
 function smallConfiguration()
@@ -204,6 +210,7 @@ function createSampleBuildRequest(platform, test)
     let rootSet = RootSet.ensureSingleton('4197', {roots: [
         {'id': '111127', 'time': 1456955807334, 'repository': MockModels.webkit, 'revision': '197463'},
         {'id': '111237', 'time': 1456931874000, 'repository': MockModels.sharedRepository, 'revision': '80229'},
+        {'id': '111239', 'time': 1456931874000, 'repository': MockModels.webkitGit, 'revision': '9abcdef'},
         {'id': '88930', 'time': 0, 'repository': MockModels.ios, 'revision': '13A452'},
     ]});
 
@@ -564,7 +571,7 @@ describe('BuildbotSyncer', function () {
         it('should include all properties specified in a given configuration', function () {
             let syncers = BuildbotSyncer._loadConfig(RemoteAPI, sampleiOSConfig());
             let properties = syncers[0]._propertiesForBuildRequest(createSampleBuildRequest(MockModels.iphone, MockModels.speedometer));
-            assert.deepEqual(Object.keys(properties), ['desired_image', 'roots_dict', 'test_name', 'forcescheduler', 'build_request_id']);
+            assert.deepEqual(Object.keys(properties), ['desired_image', 'opensource', 'roots_dict', 'test_name', 'forcescheduler', 'build_request_id']);
         });
 
         it('should preserve non-parametric property values', function () {
@@ -584,6 +591,12 @@ describe('BuildbotSyncer', function () {
             assert.equal(properties['desired_image'], '13A452');
         });
 
+        it('should resolve "rootOptions"', function () {
+            let syncers = BuildbotSyncer._loadConfig(RemoteAPI, sampleiOSConfig());
+            let properties = syncers[0]._propertiesForBuildRequest(createSampleBuildRequest(MockModels.iphone, MockModels.speedometer));
+            assert.equal(properties['roots_dict'], JSON.stringify(sampleRootSetData));
+        });
+
         it('should resolve "rootsExcluding"', function () {
             let syncers = BuildbotSyncer._loadConfig(RemoteAPI, sampleiOSConfig());
             let properties = syncers[0]._propertiesForBuildRequest(createSampleBuildRequest(MockModels.iphone, MockModels.speedometer));
@@ -892,9 +905,11 @@ describe('BuildbotSyncer', function () {
                 assert.deepEqual(requests[0].data, {
                     'build_request_id': '16733-' + MockModels.iphone.id(),
                     'desired_image': '13A452',
+                    "opensource": "9abcdef",
                     'forcescheduler': 'ABTest-iPhone-RunBenchmark-Tests-ForceScheduler',
                     'roots_dict': '{"WebKit":{"id":"111127","time":1456955807334,"repository":"WebKit","revision":"197463"},'
-                        + '"Shared":{"id":"111237","time":1456931874000,"repository":"Shared","revision":"80229"}}',
+                        + '"Shared":{"id":"111237","time":1456931874000,"repository":"Shared","revision":"80229"},'
+                        + '"WebKit-Git":{"id":"111239","time":1456931874000,"repository":"WebKit-Git","revision":"9abcdef"}}',
                     'slavename': 'some-slave',
                     'test_name': 'speedometer'
                 });
index 795ee1d836c52cddb380c1dfe52dc04a00283fac..c6525a509ee8a2227f4c1f72846a4bb620334703 100644 (file)
@@ -18,6 +18,7 @@ var MockModels = {
             MockModels.ios = Repository.ensureSingleton(22, {name: 'iOS'});
             MockModels.webkit = Repository.ensureSingleton(11, {name: 'WebKit', url: 'http://trac.webkit.org/changeset/$1'});
             MockModels.sharedRepository = Repository.ensureSingleton(16, {name: 'Shared'});
+            MockModels.webkitGit = Repository.ensureSingleton(17, {name: 'WebKit-Git'});
             MockModels.builder = new Builder(176, {name: 'WebKit Perf Builder', buildUrl: 'http://build.webkit.org/builders/$builderName/$buildNumber'});
 
             MockModels.someTest = Test.ensureSingleton(1, {name: 'Some test'});