Updating commit in OSBuildFetcher should respect revision range in config.
authordewei_zhu@apple.com <dewei_zhu@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 19 Jan 2019 09:08:11 +0000 (09:08 +0000)
committerdewei_zhu@apple.com <dewei_zhu@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 19 Jan 2019 09:08:11 +0000 (09:08 +0000)
https://bugs.webkit.org/show_bug.cgi?id=193558

Reviewed by Ryosuke Niwa.

OSBuildFetcher._fetchAvailableBuilds should filter out commits those are not in
revision range specified by cofnig.

* server-tests/tools-os-build-fetcher-tests.js: Added a unit test for this change.
* tools/js/os-build-fetcher.js:
(prototype.async._fetchAvailableBuilds): Filter out commits from update list if commit
revision is out of range.

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

Websites/perf.webkit.org/ChangeLog
Websites/perf.webkit.org/server-tests/tools-os-build-fetcher-tests.js
Websites/perf.webkit.org/tools/js/os-build-fetcher.js

index 1b41349..5cefdca 100644 (file)
@@ -1,3 +1,18 @@
+2019-01-17  Dewei Zhu  <dewei_zhu@apple.com>
+
+        Updating commit in OSBuildFetcher should respect revision range in config.
+        https://bugs.webkit.org/show_bug.cgi?id=193558
+
+        Reviewed by Ryosuke Niwa.
+
+        OSBuildFetcher._fetchAvailableBuilds should filter out commits those are not in
+        revision range specified by cofnig.
+
+        * server-tests/tools-os-build-fetcher-tests.js: Added a unit test for this change.
+        * tools/js/os-build-fetcher.js:
+        (prototype.async._fetchAvailableBuilds): Filter out commits from update list if commit
+        revision is out of range.
+
 2018-12-31  Dewei Zhu  <dewei_zhu@apple.com>
 
         Test group results notification should not say a build request to build had failed even when it had successfully completed.
index f7a1eb6..7b2e517 100644 (file)
@@ -534,7 +534,7 @@ describe('OSBuildFetcher', function() {
             });
         });
 
-        it('should update testability warning for commits', async () => {
+        it('should update testability message for commits', async () => {
             const logger = new MockLogger;
             const fetcher = new OSBuildFetcher(config, TestServer.remoteAPI(), slaveAuth, MockSubprocess, logger);
             const db = TestServer.database();
@@ -799,6 +799,49 @@ describe('OSBuildFetcher', function() {
             assert.equal(result['commits'][0]['order'], 1604003400);
         });
 
+        it('should update commits within specified revision range', async () => {
+            const logger = new MockLogger;
+            const fetcher = new OSBuildFetcher(configWithoutOwnedCommitCommand, TestServer.remoteAPI(), slaveAuth, MockSubprocess, logger);
+            const db = TestServer.database();
+            const resultsForSierraD = {allRevisions: ["Sierra16D68", "Sierra16D69"], commitsWithTestability: {"Sierra16D10000": "Panic"}};
+            const resultsForSierraE = {allRevisions: ["Sierra16E32", "Sierra16E33", "Sierra16E33h", "Sierra16E34", "Sierra16E10000"], commitsWithTestability: {}};
+
+            await addSlaveForReport(emptyReport);
+            await Promise.all([
+                db.insert('repositories', {'id': 10, 'name': 'OSX'}),
+                db.insert('commits', {'repository': 10, 'revision': 'Sierra16D67', 'order': 1603006700, 'reported': true}),
+                db.insert('commits', {'repository': 10, 'revision': 'Sierra16D68', 'order': 1603006800, 'reported': true}),
+                db.insert('commits', {'repository': 10, 'revision': 'Sierra16D69', 'order': 1603006900, 'reported': false}),
+                db.insert('commits', {'repository': 10, 'revision': 'Sierra16E32', 'order': 1604003200, 'reported': true}),
+                db.insert('commits', {'repository': 10, 'revision': 'Sierra16E33', 'order': 1604003300, 'reported': true}),
+                db.insert('commits', {'repository': 10, 'revision': 'Sierra16E33g', 'order': 1604003307, 'reported': true})]);
+
+            let result = await TestServer.remoteAPI().getJSON('/api/commits/OSX/last-reported?from=1603000000&to=1603099900');
+            assert.equal(result['commits'].length, 1);
+            assert.equal(result['commits'][0]['revision'], 'Sierra16D68');
+            assert.equal(result['commits'][0]['order'], 1603006800);
+
+            result = await TestServer.remoteAPI().getJSON('/api/commits/OSX/last-reported?from=1604000000&to=1604099900');
+            assert.equal(result['commits'].length, 1);
+            assert.equal(result['commits'][0]['revision'], 'Sierra16E33g');
+            assert.equal(result['commits'][0]['order'], 1604003307);
+            const waitForInvocationPromise = MockSubprocess.waitForInvocation();
+            const fetchAvailableBuildsPromise = fetcher._fetchAvailableBuilds();
+
+            await waitForInvocationPromise;
+            assert.equal(invocations.length, 1);
+            assert.deepEqual(invocations[0].command, ['list', 'all osx 16Dxx builds']);
+            invocations[0].resolve(JSON.stringify(resultsForSierraD));
+
+            await MockSubprocess.resetAndWaitForInvocation();
+            assert.equal(invocations.length, 1);
+            assert.deepEqual(invocations[0].command, ['list', 'all osx 16Exx builds']);
+            invocations[0].resolve(JSON.stringify(resultsForSierraE));
+
+            result = await fetchAvailableBuildsPromise;
+            assert.equal(result.commitsToUpdate.length, 0);
+        });
+
         it('should use "last-reported" order + 1 as "minOrder"', async () => {
             const logger = new MockLogger;
             const fetcher = new OSBuildFetcher(configTrackingOneOS, TestServer.remoteAPI(), slaveAuth, MockSubprocess, logger);
index 0806325..9934079 100644 (file)
@@ -68,8 +68,12 @@ class OSBuildFetcher {
             }
             newCommitsToReport.push(...commits);
 
-            for (const [revision, testability] of Object.entries(commitInfo.commitsWithTestability))
+            for (const [revision, testability] of Object.entries(commitInfo.commitsWithTestability)) {
+                const order = this._computeOrder(revision);
+                if (order > maxRevisionOrder || order < minRevisionOrder)
+                    continue;
                 commitsToUpdate.push({repository: repositoryName, revision, testability});
+            }
         }
         return {newCommitsToReport, commitsToUpdate};
     }