Modified: trunk/Websites/perf.webkit.org/public/api/measurement-set.php (203485 => 203486)
--- trunk/Websites/perf.webkit.org/public/api/measurement-set.php 2016-07-21 02:09:51 UTC (rev 203485)
+++ trunk/Websites/perf.webkit.org/public/api/measurement-set.php 2016-07-21 03:25:59 UTC (rev 203486)
@@ -31,6 +31,11 @@
array('platform' => $platform_id, 'metric' => $metric_id));
}
+ if ($fetcher->at_end()) {
+ header($_SERVER['SERVER_PROTOCOL'] . ' 404 Not Found');
+ exit(404);
+ }
+
$cluster_count = 0;
while (!$fetcher->at_end()) {
$content = $fetcher->fetch_next_cluster();
@@ -164,9 +169,9 @@
function execute_query($config_id) {
return $this->db->query('
- SELECT test_runs.*, builds.*,
- array_agg((commit_id, commit_repository, commit_revision, commit_time)) AS revisions,
- max(commit_time) AS revision_time, max(commit_order) AS revision_order
+ SELECT test_runs.*, build_id, build_number, build_builder, build_time,
+ array_agg((commit_id, commit_repository, commit_revision, extract(epoch from commit_time) * 1000)) AS revisions,
+ extract(epoch from max(commit_time)) * 1000 AS revision_time, max(commit_order) AS revision_order
FROM builds
LEFT OUTER JOIN build_commits ON commit_build = build_id
LEFT OUTER JOIN commits ON build_commit = commit_id, test_runs
@@ -181,7 +186,7 @@
}
private static function format_run(&$run, &$commit_time) {
- $commit_time = Database::to_js_time($run['revision_time']);
+ $commit_time = intval($run['revision_time']);
$build_time = Database::to_js_time($run['build_time']);
if (!$commit_time)
$commit_time = $build_time;
@@ -211,7 +216,7 @@
$commit_id = intval(trim($name_and_revision[0], '"'));
$repository_id = intval(trim($name_and_revision[1], '"'));
$revision = trim($name_and_revision[2], '"');
- $time = Database::to_js_time(trim($name_and_revision[3], '"'));
+ $time = intval(trim($name_and_revision[3], '"'));
array_push($revisions, array($commit_id, $repository_id, $revision, $time));
}
return $revisions;
Modified: trunk/Websites/perf.webkit.org/server-tests/api-measurement-set-tests.js (203485 => 203486)
--- trunk/Websites/perf.webkit.org/server-tests/api-measurement-set-tests.js 2016-07-21 02:09:51 UTC (rev 203485)
+++ trunk/Websites/perf.webkit.org/server-tests/api-measurement-set-tests.js 2016-07-21 03:25:59 UTC (rev 203486)
@@ -2,6 +2,9 @@
const assert = require('assert');
+require('../tools/js/v3-models.js');
+
+const MockData = require('./resources/mock-data.js');
const TestServer = require('./resources/test-server.js');
const addBuilderForReport = require('./resources/common-operations.js').addBuilderForReport;
const connectToDatabaseInEveryTest = require('./resources/common-operations.js').connectToDatabaseInEveryTest;
@@ -11,6 +14,10 @@
TestServer.inject();
connectToDatabaseInEveryTest();
+ beforeEach(function () {
+ MockData.resetV3Models();
+ });
+
function queryPlatformAndMetric(platformName, metricName)
{
const db = TestServer.database();
@@ -68,7 +75,7 @@
"revisions": {
"WebKit": {
"revision": "144000",
- "timestamp": clusterTime(10.3).toISOString(),
+ "timestamp": clusterTime(10.35645364537).toISOString(),
},
},
"builderName": "someBuilder",
@@ -184,6 +191,38 @@
}).catch(done);
});
+ it("should be able to return an empty report", function (done) {
+ const db = TestServer.database();
+ Promise.all([
+ db.insert('tests', {id: 1, name: 'SomeTest'}),
+ db.insert('tests', {id: 2, name: 'SomeOtherTest'}),
+ db.insert('tests', {id: 3, name: 'ChildTest', parent: 1}),
+ db.insert('tests', {id: 4, name: 'GrandChild', parent: 3}),
+ db.insert('aggregators', {id: 200, name: 'Total'}),
+ db.insert('test_metrics', {id: 5, test: 1, name: 'Time'}),
+ db.insert('test_metrics', {id: 6, test: 2, name: 'Time', aggregator: 200}),
+ db.insert('test_metrics', {id: 7, test: 2, name: 'Malloc', aggregator: 200}),
+ db.insert('test_metrics', {id: 8, test: 3, name: 'Time'}),
+ db.insert('test_metrics', {id: 9, test: 4, name: 'Time'}),
+ db.insert('platforms', {id: 23, name: 'iOS 9 iPhone 5s'}),
+ db.insert('platforms', {id: 46, name: 'Trunk Mavericks'}),
+ db.insert('test_configurations', {id: 101, metric: 5, platform: 46, type: 'current'}),
+ db.insert('test_configurations', {id: 102, metric: 6, platform: 46, type: 'current'}),
+ db.insert('test_configurations', {id: 103, metric: 7, platform: 46, type: 'current'}),
+ db.insert('test_configurations', {id: 104, metric: 8, platform: 46, type: 'current'}),
+ db.insert('test_configurations', {id: 105, metric: 9, platform: 46, type: 'current'}),
+ db.insert('test_configurations', {id: 106, metric: 5, platform: 23, type: 'current'}),
+ db.insert('test_configurations', {id: 107, metric: 5, platform: 23, type: 'baseline'}),
+ ]).then(function () {
+ return TestServer.remoteAPI().getJSONWithStatus(`/api/measurement-set/?platform=46&metric=5`).then(function (response) {
+ assert.equal(response.statusCode, 404);
+ }, function (error) {
+ assert.equal(error, 404);
+ done();
+ });
+ }).catch(done);
+ });
+
it("should be able to retrieve a reported value", function (done) {
addBuilderForReport(reportWithBuildTime[0]).then(function () {
return TestServer.remoteAPI().postJSON('/api/report/', reportWithBuildTime);
@@ -379,7 +418,7 @@
});
- it("should create cache results", function (done) {
+ it("should create cached results", function (done) {
const remote = TestServer.remoteAPI();
let cachePrefix;
addBuilderForReport(reportWithBuildTime[0]).then(function () {
@@ -409,4 +448,26 @@
}).catch(done);
});
+ it("should use lastModified timestamp identical to that in the manifest file", function (done) {
+ const remote = TestServer.remoteAPI();
+ addBuilderForReport(reportWithBuildTime[0]).then(function () {
+ return remote.postJSON('/api/report/', reportWithRevision);
+ }).then(function () {
+ return queryPlatformAndMetric('Mountain Lion', 'Time');
+ }).then(function (result) {
+ return remote.getJSONWithStatus(`/api/measurement-set/?platform=${result.platformId}&metric=${result.metricId}`);
+ }).then(function (primaryCluster) {
+ return remote.getJSONWithStatus('/api/manifest').then(function (content) {
+ const manifest = Manifest._didFetchManifest(content);
+
+ const platform = Platform.findByName('Mountain Lion');
+ assert.equal(Metric.all().length, 1);
+ const metric = Metric.all()[0];
+ assert.equal(platform.lastModified(metric), primaryCluster['lastModified']);
+
+ done();
+ });
+ }).catch(done);
+ });
+
});