Modified: trunk/Websites/perf.webkit.org/public/privileged-api/create-analysis-task.php (229500 => 229501)
--- trunk/Websites/perf.webkit.org/public/privileged-api/create-analysis-task.php 2018-03-10 03:53:41 UTC (rev 229500)
+++ trunk/Websites/perf.webkit.org/public/privileged-api/create-analysis-task.php 2018-03-10 04:44:56 UTC (rev 229501)
@@ -88,12 +88,14 @@
}
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));
- 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();
Modified: trunk/Websites/perf.webkit.org/server-tests/privileged-api-create-analysis-task-tests.js (229500 => 229501)
--- trunk/Websites/perf.webkit.org/server-tests/privileged-api-create-analysis-task-tests.js 2018-03-10 03:53:41 UTC (rev 229500)
+++ trunk/Websites/perf.webkit.org/server-tests/privileged-api-create-analysis-task-tests.js 2018-03-10 04:44:56 UTC (rev 229501)
@@ -32,6 +32,30 @@
},
}}];
+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",
@@ -57,6 +81,30 @@
},
}}];
+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);
@@ -180,6 +228,40 @@
});
});
+ 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;