Create analysis task should use build time as fallback when commit time is not available.
authordewei_zhu@apple.com <dewei_zhu@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 10 Mar 2018 04:44:56 +0000 (04:44 +0000)
committerdewei_zhu@apple.com <dewei_zhu@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 10 Mar 2018 04:44:56 +0000 (04:44 +0000)
https://bugs.webkit.org/show_bug.cgi?id=183309

Reviewed by Ryosuke Niwa.

Added the ability to schedule analysis task for the range without commit time.

* public/privileged-api/create-analysis-task.php: Use build time as fallback.
* server-tests/privileged-api-create-analysis-task-tests.js: Added a unit test for this change.

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

Websites/perf.webkit.org/ChangeLog
Websites/perf.webkit.org/public/privileged-api/create-analysis-task.php
Websites/perf.webkit.org/server-tests/privileged-api-create-analysis-task-tests.js

index 45d7248..ad69f1b 100644 (file)
@@ -1,3 +1,15 @@
+2018-03-04  Dewei Zhu  <dewei_zhu@apple.com>
+
+        Create analysis task should use build time as fallback when commit time is not available.
+        https://bugs.webkit.org/show_bug.cgi?id=183309
+
+        Reviewed by Ryosuke Niwa.
+
+        Added the ability to schedule analysis task for the range without commit time.
+
+        * public/privileged-api/create-analysis-task.php: Use build time as fallback.
+        * server-tests/privileged-api-create-analysis-task-tests.js: Added a unit test for this change.
+
 2018-03-04  Aakash Jain  <aakash_jain@apple.com>
 
         BuildbotBuildEntry for buildbot 0.9 uses incorrect buildrequestid
 2018-03-04  Aakash Jain  <aakash_jain@apple.com>
 
         BuildbotBuildEntry for buildbot 0.9 uses incorrect buildrequestid
index 5c0a75b..408507a 100644 (file)
@@ -88,12 +88,14 @@ function ensure_config_from_runs($db, $start_run, $end_run) {
 }
 
 function time_for_run($db, $run_id) {
 }
 
 function time_for_run($db, $run_id) {
-    $result = $db->query_and_fetch_all('SELECT max(commit_time) as time
+    $result = $db->query_and_fetch_all('SELECT max(commit_time) as time, max(build_time) as build_time
         FROM test_runs JOIN builds ON run_build = build_id
             JOIN build_commits ON commit_build = build_id
             JOIN commits ON build_commit = commit_id
         WHERE run_id = $1', array($run_id));
         FROM test_runs JOIN builds ON run_build = build_id
             JOIN build_commits ON commit_build = build_id
             JOIN commits ON build_commit = commit_id
         WHERE run_id = $1', array($run_id));
-    return $result ? $result[0]['time'] : null;
+
+    $first_result = array_get($result, 0, array());
+    return $first_result['time'] ? $first_result['time'] : $first_result['build_time'];
 }
 
 main();
 }
 
 main();
index 8775c55..eb60d7b 100644 (file)
@@ -32,6 +32,30 @@ const reportWithRevision = [{
         },
     }}];
 
         },
     }}];
 
+const reportWithRevisionNoTimestamp = [{
+    "buildNumber": "124",
+    "buildTime": "2015-10-27T15:34:51",
+    "revisions": {
+        "WebKit": {
+            "revision": "191622",
+        },
+    },
+    "builderName": "someBuilder",
+    "builderPassword": "somePassword",
+    "platform": "some platform",
+    "tests": {
+        "Suite": {
+            "metrics": {
+                "Time": ["Arithmetic"],
+            },
+            "tests": {
+                "test1": {
+                    "metrics": {"Time": { "current": [11] }},
+                }
+            }
+        },
+    }}];
+
 const anotherReportWithRevision = [{
     "buildNumber": "125",
     "buildTime": "2015-10-27T17:27:41",
 const anotherReportWithRevision = [{
     "buildNumber": "125",
     "buildTime": "2015-10-27T17:27:41",
@@ -57,6 +81,30 @@ const anotherReportWithRevision = [{
         },
     }}];
 
         },
     }}];
 
+const anotherReportWithRevisionNoTimestamp = [{
+    "buildNumber": "125",
+    "buildTime": "2015-10-27T17:27:41",
+    "revisions": {
+        "WebKit": {
+            "revision": "191623",
+        },
+    },
+    "builderName": "someBuilder",
+    "builderPassword": "somePassword",
+    "platform": "some platform",
+    "tests": {
+        "Suite": {
+            "metrics": {
+                "Time": ["Arithmetic"],
+            },
+            "tests": {
+                "test1": {
+                    "metrics": {"Time": { "current": [12] }},
+                }
+            }
+        },
+    }}];
+
 describe('/privileged-api/create-analysis-task', function () {
     prepareServerTest(this);
 
 describe('/privileged-api/create-analysis-task', function () {
     prepareServerTest(this);
 
@@ -180,6 +228,40 @@ describe('/privileged-api/create-analysis-task', function () {
         });
     });
 
         });
     });
 
+    it('should create an analysis task and use build time as fallback when commit time is not available', () => {
+        const db = TestServer.database();
+        return addBuilderForReport(reportWithRevisionNoTimestamp[0]).then(() => {
+            return TestServer.remoteAPI().postJSON('/api/report/', reportWithRevisionNoTimestamp);
+        }).then(() => {
+            return TestServer.remoteAPI().postJSON('/api/report/', anotherReportWithRevisionNoTimestamp);
+        }).then(() => {
+            return Manifest.fetch();
+        }).then(() => {
+            const test1 = Test.findByPath(['Suite', 'test1']);
+            const platform = Platform.findByName('some platform');
+            return db.selectFirstRow('test_configurations', {metric: test1.metrics()[0].id(), platform: platform.id()});
+        }).then((configRow) => {
+            return db.selectRows('test_runs', {config: configRow['id']});
+        }).then((testRuns) => {
+            assert.equal(testRuns.length, 2);
+            return PrivilegedAPI.sendRequest('create-analysis-task', {name: 'hi', startRun: testRuns[0]['id'], endRun: testRuns[1]['id']});
+        }).then((content) => {
+            return AnalysisTask.fetchById(content['taskId']);
+        }).then((task) => {
+            assert.equal(task.name(), 'hi');
+            assert(!task.hasResults());
+            assert(!task.hasPendingRequests());
+            assert.deepEqual(task.bugs(), []);
+            assert.deepEqual(task.causes(), []);
+            assert.deepEqual(task.fixes(), []);
+            assert.equal(task.changeType(), null);
+            assert.equal(task.platform().label(), 'some platform');
+            assert.equal(task.metric().test().label(), 'test1');
+            assert.equal(task.startTime(), 1445960091000);
+            assert.equal(task.endTime(), 1445966861000);
+        });
+    });
+
     it('should return "DuplicateAnalysisTask" when there is already an analysis task for the specified range', () => {
         const db = TestServer.database();
         let startId;
     it('should return "DuplicateAnalysisTask" when there is already an analysis task for the specified range', () => {
         const db = TestServer.database();
         let startId;