2017-07-28 00:50:27 +08:00
|
|
|
require('../support/test_helper');
|
|
|
|
|
|
|
|
const assert = require('../support/assert');
|
|
|
|
const TestClient = require('../support/test-client');
|
2018-05-23 01:22:08 +08:00
|
|
|
const serverOptions = require('../../lib/cartodb/server_options');
|
2017-07-28 00:50:27 +08:00
|
|
|
|
2017-08-01 18:53:29 +08:00
|
|
|
const timeoutErrorTilePath = `${process.cwd()}/assets/render-timeout-fallback.png`;
|
|
|
|
|
2017-07-28 00:50:27 +08:00
|
|
|
const pointSleepSql = `
|
|
|
|
SELECT
|
2017-08-01 00:26:45 +08:00
|
|
|
pg_sleep(0.3),
|
2017-07-28 00:50:27 +08:00
|
|
|
'SRID=3857;POINT(0 0)'::geometry the_geom_webmercator,
|
|
|
|
1 cartodb_id,
|
|
|
|
2 val
|
|
|
|
`;
|
|
|
|
|
2017-08-01 16:21:39 +08:00
|
|
|
const validationPointSleepSql = `
|
|
|
|
SELECT
|
|
|
|
pg_sleep(0.3),
|
|
|
|
ST_Transform('SRID=4326;POINT(-180 85.05112877)'::geometry, 3857) the_geom_webmercator,
|
|
|
|
1 cartodb_id,
|
|
|
|
2 val
|
|
|
|
`;
|
|
|
|
|
2017-07-28 00:50:27 +08:00
|
|
|
const createMapConfig = ({
|
|
|
|
version = '1.6.0',
|
|
|
|
type = 'cartodb',
|
|
|
|
sql = pointSleepSql,
|
|
|
|
cartocss = TestClient.CARTOCSS.POINTS,
|
|
|
|
cartocss_version = '2.3.0',
|
2017-08-01 16:21:39 +08:00
|
|
|
interactivity = 'cartodb_id',
|
2017-08-01 00:26:45 +08:00
|
|
|
countBy = 'cartodb_id',
|
|
|
|
attributes
|
2017-07-28 00:50:27 +08:00
|
|
|
} = {}) => ({
|
|
|
|
version,
|
|
|
|
layers: [{
|
|
|
|
type,
|
|
|
|
options: {
|
|
|
|
source: {
|
|
|
|
id: 'a0'
|
|
|
|
},
|
|
|
|
cartocss,
|
2017-08-01 00:26:45 +08:00
|
|
|
cartocss_version,
|
2017-08-01 16:21:39 +08:00
|
|
|
attributes,
|
|
|
|
interactivity
|
2017-07-28 00:50:27 +08:00
|
|
|
}
|
|
|
|
}],
|
|
|
|
analyses: [
|
|
|
|
{
|
|
|
|
id: 'a0',
|
|
|
|
type: 'source',
|
|
|
|
params: {
|
|
|
|
query: sql
|
|
|
|
}
|
|
|
|
}
|
|
|
|
],
|
|
|
|
dataviews: {
|
|
|
|
count: {
|
|
|
|
source: {
|
|
|
|
id: 'a0'
|
|
|
|
},
|
|
|
|
type: 'formula',
|
|
|
|
options: {
|
|
|
|
column: countBy,
|
|
|
|
operation: 'count'
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2018-07-02 19:03:01 +08:00
|
|
|
const db_limit_error_message = 'You are over platform\'s limits: SQL query timeout error.' +
|
|
|
|
' Refactor your query before running again or contact CARTO support for more details.';
|
|
|
|
|
2017-08-01 15:39:37 +08:00
|
|
|
const DATASOURCE_TIMEOUT_ERROR = {
|
2018-07-02 19:03:01 +08:00
|
|
|
errors: [db_limit_error_message],
|
2017-08-01 15:39:37 +08:00
|
|
|
errors_with_context: [{
|
|
|
|
type: 'limit',
|
|
|
|
subtype: 'datasource',
|
2018-07-02 19:03:01 +08:00
|
|
|
message: db_limit_error_message
|
2017-08-01 15:39:37 +08:00
|
|
|
}]
|
|
|
|
};
|
|
|
|
|
2018-07-02 19:03:01 +08:00
|
|
|
describe.only('user database timeout limit', function () {
|
2017-08-01 00:26:45 +08:00
|
|
|
describe('dataview', function () {
|
|
|
|
beforeEach(function (done) {
|
2017-07-28 00:50:27 +08:00
|
|
|
const mapconfig = createMapConfig();
|
|
|
|
this.testClient = new TestClient(mapconfig, 1234);
|
2017-08-10 23:09:05 +08:00
|
|
|
this.testClient.setUserDatabaseTimeoutLimit(200, done);
|
2017-07-28 00:50:27 +08:00
|
|
|
});
|
|
|
|
|
|
|
|
afterEach(function (done) {
|
2017-08-10 23:09:05 +08:00
|
|
|
this.testClient.setUserDatabaseTimeoutLimit(0, (err) => {
|
2017-08-01 00:52:09 +08:00
|
|
|
if (err) {
|
|
|
|
return done(err);
|
|
|
|
}
|
|
|
|
this.testClient.drain(done);
|
|
|
|
});
|
2017-07-28 00:50:27 +08:00
|
|
|
});
|
|
|
|
|
|
|
|
it('layergroup creation works but dataview request fails due to statement timeout', function (done) {
|
|
|
|
const params = {
|
|
|
|
response: {
|
2017-08-01 01:08:29 +08:00
|
|
|
status: 429,
|
2017-07-28 00:50:27 +08:00
|
|
|
headers: {
|
|
|
|
'Content-Type': 'application/json; charset=utf-8'
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2017-08-01 16:21:39 +08:00
|
|
|
this.testClient.getDataview('count', params, (err, timeoutError) => {
|
2017-07-28 00:50:27 +08:00
|
|
|
assert.ifError(err);
|
|
|
|
|
2017-08-01 16:21:39 +08:00
|
|
|
assert.deepEqual(timeoutError, DATASOURCE_TIMEOUT_ERROR);
|
2017-07-28 00:50:27 +08:00
|
|
|
|
|
|
|
done();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2017-08-01 16:21:39 +08:00
|
|
|
describe('raster', function () {
|
|
|
|
describe('while validating in layergroup creation', function () {
|
|
|
|
beforeEach(function (done) {
|
|
|
|
const mapconfig = createMapConfig({ sql: validationPointSleepSql });
|
|
|
|
this.testClient = new TestClient(mapconfig, 1234);
|
2017-08-10 23:09:05 +08:00
|
|
|
this.testClient.setUserDatabaseTimeoutLimit(200, done);
|
2017-08-01 16:21:39 +08:00
|
|
|
});
|
|
|
|
|
|
|
|
afterEach(function (done) {
|
2017-08-10 23:09:05 +08:00
|
|
|
this.testClient.setUserDatabaseTimeoutLimit(0, (err) => {
|
2017-08-01 16:21:39 +08:00
|
|
|
if (err) {
|
|
|
|
return done(err);
|
|
|
|
}
|
|
|
|
this.testClient.drain(done);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
it('fails due to statement timeout', function (done) {
|
|
|
|
const expectedResponse = {
|
|
|
|
status: 429,
|
|
|
|
headers: {
|
|
|
|
'Content-Type': 'application/json; charset=utf-8'
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2017-12-05 19:09:31 +08:00
|
|
|
this.testClient.getLayergroup({ response: expectedResponse }, (err, timeoutError) => {
|
2017-08-01 16:21:39 +08:00
|
|
|
assert.deepEqual(timeoutError, {
|
2018-07-02 19:03:01 +08:00
|
|
|
errors: [db_limit_error_message ],
|
2017-08-01 16:21:39 +08:00
|
|
|
errors_with_context: [{
|
|
|
|
type: 'limit',
|
|
|
|
subtype: 'datasource',
|
2018-07-02 19:03:01 +08:00
|
|
|
message: db_limit_error_message,
|
2017-08-01 16:21:39 +08:00
|
|
|
layer: { id: 'layer0', index: 0, type: 'mapnik' }
|
|
|
|
}]
|
|
|
|
});
|
|
|
|
|
|
|
|
done();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('fetching raster tiles', function () {
|
|
|
|
describe('with user\'s timeout of 200 ms', function () {
|
2017-08-01 18:53:29 +08:00
|
|
|
describe('with onTileErrorStrategy ENABLED', function () {
|
|
|
|
let onTileErrorStrategy;
|
|
|
|
|
|
|
|
beforeEach(function (done) {
|
|
|
|
onTileErrorStrategy = global.environment.enabledFeatures.onTileErrorStrategy;
|
|
|
|
global.environment.enabledFeatures.onTileErrorStrategy = true;
|
|
|
|
|
|
|
|
const mapconfig = createMapConfig();
|
|
|
|
this.testClient = new TestClient(mapconfig, 1234);
|
|
|
|
const expectedResponse = {
|
|
|
|
status: 200,
|
2017-08-01 16:21:39 +08:00
|
|
|
headers: {
|
|
|
|
'Content-Type': 'application/json; charset=utf-8'
|
|
|
|
}
|
2017-08-01 18:53:29 +08:00
|
|
|
};
|
|
|
|
|
2017-08-10 23:09:05 +08:00
|
|
|
this.testClient.setUserDatabaseTimeoutLimit(200, (err) => {
|
2017-08-01 18:53:29 +08:00
|
|
|
if (err) {
|
|
|
|
return done(err);
|
|
|
|
}
|
|
|
|
|
2017-12-05 19:09:31 +08:00
|
|
|
this.testClient.getLayergroup({ response: expectedResponse }, (err, res) => {
|
2017-08-10 23:09:05 +08:00
|
|
|
if (err) {
|
|
|
|
return done(err);
|
|
|
|
}
|
2017-08-01 18:53:29 +08:00
|
|
|
|
2017-08-10 23:09:05 +08:00
|
|
|
this.layergroupid = res.layergroupid;
|
|
|
|
|
|
|
|
done();
|
|
|
|
});
|
2017-08-01 18:53:29 +08:00
|
|
|
});
|
|
|
|
});
|
2017-08-01 16:21:39 +08:00
|
|
|
|
2017-08-01 18:53:29 +08:00
|
|
|
afterEach(function (done) {
|
|
|
|
global.environment.enabledFeatures.onTileErrorStrategy = onTileErrorStrategy;
|
2017-08-10 23:09:05 +08:00
|
|
|
this.testClient.setUserDatabaseTimeoutLimit(0, (err) => {
|
|
|
|
if (err) {
|
|
|
|
return done(err);
|
|
|
|
}
|
|
|
|
this.testClient.drain(done);
|
|
|
|
});
|
2017-08-01 18:53:29 +08:00
|
|
|
});
|
|
|
|
|
|
|
|
it('"png" fails due to statement timeout', function (done) {
|
|
|
|
const params = {
|
|
|
|
layergroupid: this.layergroupid,
|
|
|
|
format: 'png',
|
|
|
|
layers: [ 0 ]
|
|
|
|
};
|
|
|
|
|
|
|
|
this.testClient.getTile(0, 0, 0, params, (err, res, tile) => {
|
|
|
|
assert.ifError(err);
|
|
|
|
|
|
|
|
assert.imageIsSimilarToFile(tile, timeoutErrorTilePath, 0.05, (err) => {
|
|
|
|
assert.ifError(err);
|
|
|
|
done();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
2017-08-01 16:21:39 +08:00
|
|
|
|
2017-08-01 18:53:29 +08:00
|
|
|
it('"static png" fails due to statement timeout', function (done) {
|
|
|
|
const params = {
|
|
|
|
layergroupid: this.layergroupid,
|
|
|
|
zoom: 0,
|
|
|
|
lat: 0,
|
|
|
|
lng: 0,
|
|
|
|
width: 256,
|
|
|
|
height: 256,
|
|
|
|
format: 'png'
|
|
|
|
};
|
|
|
|
|
|
|
|
this.testClient.getStaticCenter(params, function (err, res, tile) {
|
|
|
|
assert.ifError(err);
|
|
|
|
|
|
|
|
assert.imageIsSimilarToFile(tile, timeoutErrorTilePath, 0.05, (err) => {
|
|
|
|
assert.ifError(err);
|
|
|
|
done();
|
|
|
|
});
|
|
|
|
});
|
2017-08-01 16:21:39 +08:00
|
|
|
});
|
|
|
|
});
|
2017-08-01 17:58:43 +08:00
|
|
|
|
2017-08-01 18:53:29 +08:00
|
|
|
describe('with onTileErrorStrategy DISABLED', function () {
|
|
|
|
let onTileErrorStrategy;
|
|
|
|
|
|
|
|
beforeEach(function (done) {
|
|
|
|
onTileErrorStrategy = global.environment.enabledFeatures.onTileErrorStrategy;
|
|
|
|
global.environment.enabledFeatures.onTileErrorStrategy = false;
|
|
|
|
|
|
|
|
const mapconfig = createMapConfig();
|
|
|
|
this.testClient = new TestClient(mapconfig, 1234);
|
|
|
|
const expectedResponse = {
|
|
|
|
status: 200,
|
2017-08-01 17:58:43 +08:00
|
|
|
headers: {
|
|
|
|
'Content-Type': 'application/json; charset=utf-8'
|
|
|
|
}
|
2017-08-01 18:53:29 +08:00
|
|
|
};
|
|
|
|
|
2017-08-10 23:09:05 +08:00
|
|
|
this.testClient.setUserDatabaseTimeoutLimit(200, (err) => {
|
2017-08-01 18:53:29 +08:00
|
|
|
if (err) {
|
|
|
|
return done(err);
|
|
|
|
}
|
|
|
|
|
2017-12-05 19:09:31 +08:00
|
|
|
this.testClient.getLayergroup({ response: expectedResponse }, (err, res) => {
|
2017-08-10 23:09:05 +08:00
|
|
|
if (err) {
|
|
|
|
return done(err);
|
|
|
|
}
|
2017-08-01 18:53:29 +08:00
|
|
|
|
2017-08-10 23:09:05 +08:00
|
|
|
this.layergroupid = res.layergroupid;
|
|
|
|
|
|
|
|
done();
|
|
|
|
});
|
2017-08-01 18:53:29 +08:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
afterEach(function (done) {
|
|
|
|
global.environment.enabledFeatures.onTileErrorStrategy = onTileErrorStrategy;
|
|
|
|
|
2017-08-10 23:09:05 +08:00
|
|
|
this.testClient.setUserDatabaseTimeoutLimit(0, (err) => {
|
|
|
|
if (err) {
|
|
|
|
return done(err);
|
|
|
|
}
|
|
|
|
|
|
|
|
this.testClient.drain(done);
|
|
|
|
});
|
2017-08-01 18:53:29 +08:00
|
|
|
});
|
|
|
|
|
|
|
|
it('"png" fails due to statement timeout', function (done) {
|
|
|
|
const params = {
|
|
|
|
layergroupid: this.layergroupid,
|
|
|
|
format: 'png',
|
|
|
|
layers: [ 0 ],
|
|
|
|
response: {
|
|
|
|
status: 429,
|
|
|
|
headers: {
|
|
|
|
'Content-Type': 'application/json; charset=utf-8'
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
this.testClient.getTile(0, 0, 0, params, (err, res, timeoutError) => {
|
|
|
|
assert.ifError(err);
|
|
|
|
|
|
|
|
assert.deepEqual(timeoutError, DATASOURCE_TIMEOUT_ERROR);
|
|
|
|
|
|
|
|
done();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
it('"static png" fails due to statement timeout', function (done) {
|
|
|
|
const params = {
|
|
|
|
layergroupid: this.layergroupid,
|
|
|
|
zoom: 0,
|
|
|
|
lat: 0,
|
|
|
|
lng: 0,
|
|
|
|
width: 256,
|
|
|
|
height: 256,
|
|
|
|
format: 'png',
|
|
|
|
response: {
|
|
|
|
status: 429,
|
|
|
|
headers: {
|
|
|
|
'Content-Type': 'application/json; charset=utf-8'
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
2017-08-01 17:58:43 +08:00
|
|
|
|
2017-08-01 18:53:29 +08:00
|
|
|
this.testClient.getStaticCenter(params, (err, res, timeoutError) => {
|
|
|
|
assert.ifError(err);
|
2017-08-01 17:58:43 +08:00
|
|
|
|
2017-08-01 18:53:29 +08:00
|
|
|
assert.deepEqual(timeoutError, DATASOURCE_TIMEOUT_ERROR);
|
2017-08-01 17:58:43 +08:00
|
|
|
|
2017-08-01 18:53:29 +08:00
|
|
|
done();
|
|
|
|
});
|
2017-08-01 17:58:43 +08:00
|
|
|
});
|
|
|
|
});
|
2017-08-01 16:21:39 +08:00
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('vector', function () {
|
|
|
|
describe('while validating in layergroup creation', function () {
|
|
|
|
beforeEach(function (done) {
|
|
|
|
const mapconfig = createMapConfig({ sql: validationPointSleepSql });
|
|
|
|
this.testClient = new TestClient(mapconfig, 1234);
|
2017-08-10 23:09:05 +08:00
|
|
|
this.testClient.setUserDatabaseTimeoutLimit(200, done);
|
2017-08-01 16:21:39 +08:00
|
|
|
});
|
|
|
|
|
|
|
|
afterEach(function (done) {
|
2017-08-10 23:09:05 +08:00
|
|
|
this.testClient.setUserDatabaseTimeoutLimit(0, (err) => {
|
2017-08-01 16:21:39 +08:00
|
|
|
if (err) {
|
|
|
|
return done(err);
|
|
|
|
}
|
|
|
|
this.testClient.drain(done);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
it('fails due to statement timeout', function (done) {
|
|
|
|
const expectedResponse = {
|
|
|
|
status: 429,
|
|
|
|
headers: {
|
|
|
|
'Content-Type': 'application/json; charset=utf-8'
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2017-12-05 19:09:31 +08:00
|
|
|
this.testClient.getLayergroup({ response: expectedResponse }, (err, timeoutError) => {
|
2017-08-01 16:21:39 +08:00
|
|
|
assert.deepEqual(timeoutError, {
|
2018-07-02 19:03:01 +08:00
|
|
|
errors: [ db_limit_error_message ],
|
2017-08-01 16:21:39 +08:00
|
|
|
errors_with_context: [{
|
|
|
|
type: 'limit',
|
|
|
|
subtype: 'datasource',
|
2018-07-02 19:03:01 +08:00
|
|
|
message: db_limit_error_message,
|
2017-08-01 16:21:39 +08:00
|
|
|
layer: { id: 'layer0', index: 0, type: 'mapnik' }
|
|
|
|
}]
|
|
|
|
});
|
|
|
|
|
|
|
|
done();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('fetching vector tiles', function () {
|
|
|
|
beforeEach(function (done) {
|
|
|
|
const mapconfig = createMapConfig();
|
|
|
|
this.testClient = new TestClient(mapconfig, 1234);
|
|
|
|
const expectedResponse = {
|
|
|
|
status: 200,
|
|
|
|
headers: {
|
|
|
|
'Content-Type': 'application/json; charset=utf-8'
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2017-12-05 19:09:31 +08:00
|
|
|
this.testClient.getLayergroup({ response: expectedResponse }, (err, res) => {
|
2017-08-01 16:21:39 +08:00
|
|
|
if (err) {
|
|
|
|
return done(err);
|
|
|
|
}
|
|
|
|
|
|
|
|
this.layergroupid = res.layergroupid;
|
|
|
|
|
|
|
|
done();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
afterEach(function (done) {
|
|
|
|
this.testClient.drain(done);
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('with user\'s timeout of 200 ms', function () {
|
|
|
|
beforeEach(function (done) {
|
2017-08-10 23:09:05 +08:00
|
|
|
this.testClient.setUserDatabaseTimeoutLimit(200, done);
|
2017-08-01 16:21:39 +08:00
|
|
|
});
|
|
|
|
|
|
|
|
afterEach(function (done) {
|
2017-08-10 23:09:05 +08:00
|
|
|
this.testClient.setUserDatabaseTimeoutLimit(0, done);
|
2017-08-01 16:21:39 +08:00
|
|
|
});
|
|
|
|
|
2017-11-15 22:07:30 +08:00
|
|
|
it('"mvt" fails due to statement timeout', function (done) {
|
2017-08-01 16:21:39 +08:00
|
|
|
const params = {
|
|
|
|
layergroupid: this.layergroupid,
|
|
|
|
format: 'mvt',
|
|
|
|
layers: [ 0 ],
|
|
|
|
response: {
|
|
|
|
status: 429,
|
|
|
|
headers: {
|
2017-11-07 18:08:01 +08:00
|
|
|
'Content-Type': 'application/x-protobuf'
|
2017-08-01 16:21:39 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2017-11-07 18:08:01 +08:00
|
|
|
this.testClient.getTile(0, 0, 0, params, (err, res, tile) => {
|
2017-08-01 16:21:39 +08:00
|
|
|
assert.ifError(err);
|
2017-12-05 19:09:31 +08:00
|
|
|
|
2017-11-07 18:08:01 +08:00
|
|
|
var tileJSON = tile.toJSON();
|
|
|
|
assert.equal(Array.isArray(tileJSON), true);
|
|
|
|
assert.equal(tileJSON.length, 2);
|
|
|
|
assert.equal(tileJSON[0].name, 'errorTileSquareLayer');
|
|
|
|
assert.equal(tileJSON[1].name, 'errorTileStripesLayer');
|
2017-12-05 19:09:31 +08:00
|
|
|
|
2017-08-01 16:21:39 +08:00
|
|
|
done();
|
|
|
|
});
|
2017-12-05 19:09:31 +08:00
|
|
|
|
2017-08-01 16:21:39 +08:00
|
|
|
});
|
|
|
|
});
|
2018-05-23 01:22:08 +08:00
|
|
|
|
2018-06-11 20:47:39 +08:00
|
|
|
if (process.env.POSTGIS_VERSION >= '20400') {
|
2018-05-23 01:41:20 +08:00
|
|
|
describe('fetching vector tiles via PostGIS renderer', function() {
|
2018-05-23 01:22:08 +08:00
|
|
|
const usePostGIS = true;
|
|
|
|
const originalUsePostGIS = serverOptions.renderer.mvt.usePostGIS;
|
|
|
|
|
|
|
|
beforeEach(function (done) {
|
|
|
|
serverOptions.renderer.mvt.usePostGIS = usePostGIS;
|
|
|
|
|
|
|
|
const mapconfig = createMapConfig();
|
|
|
|
this.testClient = new TestClient(mapconfig, 1234);
|
|
|
|
const expectedResponse = {
|
|
|
|
status: 200,
|
|
|
|
headers: {
|
|
|
|
'Content-Type': 'application/json; charset=utf-8'
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
this.testClient.getLayergroup({ response: expectedResponse }, (err, res) => {
|
|
|
|
if (err) {
|
|
|
|
return done(err);
|
|
|
|
}
|
|
|
|
|
|
|
|
this.layergroupid = res.layergroupid;
|
|
|
|
|
|
|
|
done();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2018-05-23 01:37:46 +08:00
|
|
|
afterEach(function () {
|
2018-05-23 01:22:08 +08:00
|
|
|
serverOptions.renderer.mvt.usePostGIS = originalUsePostGIS;
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('with user\'s timeout of 200 ms', function () {
|
|
|
|
beforeEach(function (done) {
|
|
|
|
this.testClient.setUserDatabaseTimeoutLimit(200, done);
|
|
|
|
});
|
|
|
|
|
|
|
|
afterEach(function (done) {
|
|
|
|
this.testClient.setUserDatabaseTimeoutLimit(0, done);
|
|
|
|
});
|
|
|
|
|
|
|
|
it('"mvt" fails due to statement timeout', function (done) {
|
|
|
|
const params = {
|
|
|
|
layergroupid: this.layergroupid,
|
|
|
|
format: 'mvt',
|
|
|
|
layers: [ 0 ],
|
|
|
|
response: {
|
|
|
|
status: 429,
|
|
|
|
headers: {
|
|
|
|
'Content-Type': 'application/x-protobuf'
|
|
|
|
}
|
|
|
|
},
|
|
|
|
cacheBuster: true
|
|
|
|
};
|
|
|
|
|
|
|
|
this.testClient.getTile(0, 0, 0, params, (err, res, tile) => {
|
|
|
|
assert.ifError(err);
|
|
|
|
|
|
|
|
var tileJSON = tile.toJSON();
|
|
|
|
assert.equal(Array.isArray(tileJSON), true);
|
|
|
|
assert.equal(tileJSON.length, 2);
|
|
|
|
assert.equal(tileJSON[0].name, 'errorTileSquareLayer');
|
|
|
|
assert.equal(tileJSON[1].name, 'errorTileStripesLayer');
|
|
|
|
|
|
|
|
done();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
2017-08-01 16:21:39 +08:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
describe('interactivity', function () {
|
|
|
|
describe('while validating in layergroup creation', function () {
|
|
|
|
beforeEach(function (done) {
|
|
|
|
const mapconfig = createMapConfig({ sql: validationPointSleepSql, interactivity: 'val' });
|
|
|
|
this.testClient = new TestClient(mapconfig, 1234);
|
2017-08-10 23:09:05 +08:00
|
|
|
this.testClient.setUserDatabaseTimeoutLimit(200, done);
|
2017-08-01 16:21:39 +08:00
|
|
|
});
|
|
|
|
|
|
|
|
afterEach(function (done) {
|
2017-08-10 23:09:05 +08:00
|
|
|
this.testClient.setUserDatabaseTimeoutLimit(0, (err) => {
|
2017-08-01 16:21:39 +08:00
|
|
|
if (err) {
|
|
|
|
return done(err);
|
|
|
|
}
|
|
|
|
this.testClient.drain(done);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
it('fails due to statement timeout', function (done) {
|
|
|
|
const expectedResponse = {
|
|
|
|
status: 429,
|
|
|
|
headers: {
|
|
|
|
'Content-Type': 'application/json; charset=utf-8'
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2017-12-05 19:09:31 +08:00
|
|
|
this.testClient.getLayergroup({ response: expectedResponse }, (err, timeoutError) => {
|
2017-08-01 16:21:39 +08:00
|
|
|
assert.deepEqual(timeoutError, {
|
2018-07-02 19:03:01 +08:00
|
|
|
errors: [ db_limit_error_message ],
|
2017-08-01 16:21:39 +08:00
|
|
|
errors_with_context: [{
|
|
|
|
type: 'limit',
|
|
|
|
subtype: 'datasource',
|
2018-07-02 19:03:01 +08:00
|
|
|
message: db_limit_error_message,
|
2017-08-01 16:21:39 +08:00
|
|
|
layer: { id: 'layer0', index: 0, type: 'mapnik' }
|
|
|
|
}]
|
|
|
|
});
|
|
|
|
|
|
|
|
done();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('fetching interactivity tiles', function () {
|
|
|
|
beforeEach(function (done) {
|
|
|
|
const mapconfig = createMapConfig({ interactivity: 'val' });
|
|
|
|
this.testClient = new TestClient(mapconfig, 1234);
|
|
|
|
const expectedResponse = {
|
|
|
|
status: 200,
|
|
|
|
headers: {
|
|
|
|
'Content-Type': 'application/json; charset=utf-8'
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2017-12-05 19:09:31 +08:00
|
|
|
this.testClient.getLayergroup({ response: expectedResponse }, (err, res) => {
|
2017-08-01 16:21:39 +08:00
|
|
|
if (err) {
|
|
|
|
return done(err);
|
|
|
|
}
|
|
|
|
|
|
|
|
this.layergroupid = res.layergroupid;
|
|
|
|
|
|
|
|
done();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
afterEach(function (done) {
|
|
|
|
this.testClient.drain(done);
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('with user\'s timeout of 200 ms', function () {
|
|
|
|
beforeEach(function (done) {
|
2017-08-10 23:09:05 +08:00
|
|
|
this.testClient.setUserDatabaseTimeoutLimit(200, done);
|
2017-08-01 16:21:39 +08:00
|
|
|
});
|
|
|
|
|
|
|
|
afterEach(function (done) {
|
2017-08-10 23:09:05 +08:00
|
|
|
this.testClient.setUserDatabaseTimeoutLimit(0, done);
|
2017-08-01 16:21:39 +08:00
|
|
|
});
|
|
|
|
|
2017-08-01 16:29:46 +08:00
|
|
|
it('"grid.json" fails due to statement timeout', function (done) {
|
2017-08-01 16:21:39 +08:00
|
|
|
const params = {
|
|
|
|
layergroupid: this.layergroupid,
|
|
|
|
format: 'grid.json',
|
2017-08-01 16:29:46 +08:00
|
|
|
layers: 'mapnik',
|
2017-08-01 16:21:39 +08:00
|
|
|
response: {
|
|
|
|
status: 429,
|
|
|
|
headers: {
|
|
|
|
'Content-Type': 'application/json; charset=utf-8'
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
this.testClient.getTile(0, 0, 0, params, (err, res, timeoutError) => {
|
|
|
|
assert.ifError(err);
|
|
|
|
|
|
|
|
assert.deepEqual(timeoutError, DATASOURCE_TIMEOUT_ERROR);
|
|
|
|
|
|
|
|
done();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2017-08-01 15:39:37 +08:00
|
|
|
describe('torque', function () {
|
2017-08-01 00:26:45 +08:00
|
|
|
describe('while validating in layergroup creation', function () {
|
|
|
|
beforeEach(function (done) {
|
|
|
|
const mapconfig = createMapConfig({
|
|
|
|
type: 'torque',
|
|
|
|
cartocss: TestClient.CARTOCSS.TORQUE
|
|
|
|
});
|
|
|
|
this.testClient = new TestClient(mapconfig, 1234);
|
2017-08-10 23:09:05 +08:00
|
|
|
this.testClient.setUserDatabaseTimeoutLimit(200, done);
|
2017-08-01 00:26:45 +08:00
|
|
|
});
|
|
|
|
|
|
|
|
afterEach(function (done) {
|
2017-08-10 23:09:05 +08:00
|
|
|
this.testClient.setUserDatabaseTimeoutLimit(0, (err) => {
|
2017-08-01 00:26:45 +08:00
|
|
|
if (err) {
|
|
|
|
return done(err);
|
|
|
|
}
|
|
|
|
this.testClient.drain(done);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
it('fails due to statement timeout', function (done) {
|
|
|
|
const expectedResponse = {
|
2017-08-01 01:08:29 +08:00
|
|
|
status: 429,
|
2017-08-01 00:26:45 +08:00
|
|
|
headers: {
|
|
|
|
'Content-Type': 'application/json; charset=utf-8'
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2017-12-05 19:09:31 +08:00
|
|
|
this.testClient.getLayergroup({ response: expectedResponse }, (err, timeoutError) => {
|
2017-08-01 00:26:45 +08:00
|
|
|
assert.deepEqual(timeoutError, {
|
2018-07-02 19:03:01 +08:00
|
|
|
errors: [db_limit_error_message],
|
2017-08-01 00:26:45 +08:00
|
|
|
errors_with_context: [{
|
2017-08-01 01:36:07 +08:00
|
|
|
type: 'limit',
|
|
|
|
subtype: 'datasource',
|
2018-07-02 19:03:01 +08:00
|
|
|
message: db_limit_error_message,
|
2017-08-01 00:26:45 +08:00
|
|
|
layer: { id: 'torque-layer0', index: 0, type: 'torque' }
|
|
|
|
}]
|
|
|
|
});
|
|
|
|
|
|
|
|
done();
|
|
|
|
});
|
2017-07-28 00:50:27 +08:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2017-08-01 15:39:37 +08:00
|
|
|
describe('fetching torque tiles', function () {
|
|
|
|
beforeEach(function (done) {
|
2017-08-01 00:26:45 +08:00
|
|
|
const mapconfig = createMapConfig({
|
|
|
|
type: 'torque',
|
|
|
|
cartocss: TestClient.CARTOCSS.TORQUE
|
|
|
|
});
|
|
|
|
this.testClient = new TestClient(mapconfig, 1234);
|
|
|
|
const expectedResponse = {
|
|
|
|
status: 200,
|
|
|
|
headers: {
|
|
|
|
'Content-Type': 'application/json; charset=utf-8'
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2017-12-05 19:09:31 +08:00
|
|
|
this.testClient.getLayergroup({ response: expectedResponse }, (err, res) => {
|
2017-08-01 00:26:45 +08:00
|
|
|
if (err) {
|
|
|
|
return done(err);
|
|
|
|
}
|
|
|
|
|
|
|
|
this.layergroupid = res.layergroupid;
|
|
|
|
|
|
|
|
done();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
afterEach(function (done) {
|
|
|
|
this.testClient.drain(done);
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('with user\'s timeout of 200 ms', function () {
|
|
|
|
beforeEach(function (done) {
|
2017-08-10 23:09:05 +08:00
|
|
|
this.testClient.setUserDatabaseTimeoutLimit(200, done);
|
2017-08-01 00:26:45 +08:00
|
|
|
});
|
|
|
|
|
|
|
|
afterEach(function (done) {
|
2017-08-10 23:09:05 +08:00
|
|
|
this.testClient.setUserDatabaseTimeoutLimit(0, done);
|
2017-08-01 00:26:45 +08:00
|
|
|
});
|
|
|
|
|
2017-08-01 15:39:37 +08:00
|
|
|
it('"torque.json" fails due to statement timeout', function (done) {
|
2017-08-01 00:26:45 +08:00
|
|
|
const params = {
|
|
|
|
layergroupid: this.layergroupid,
|
|
|
|
format: 'torque.json',
|
|
|
|
layers: [ 0 ],
|
|
|
|
response: {
|
2017-08-01 01:08:29 +08:00
|
|
|
status: 429,
|
2017-08-01 00:26:45 +08:00
|
|
|
headers: {
|
|
|
|
'Content-Type': 'application/json; charset=utf-8'
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2017-08-01 16:21:39 +08:00
|
|
|
this.testClient.getTile(0, 0, 0, params, (err, res, timeoutError) => {
|
2017-08-01 00:26:45 +08:00
|
|
|
assert.ifError(err);
|
|
|
|
|
2017-08-01 16:21:39 +08:00
|
|
|
assert.deepEqual(timeoutError, DATASOURCE_TIMEOUT_ERROR);
|
2017-08-01 15:39:37 +08:00
|
|
|
|
|
|
|
done();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
it('".png" fails due to statement timeout', function (done) {
|
|
|
|
const params = {
|
|
|
|
layergroupid: this.layergroupid,
|
|
|
|
format: 'torque.png',
|
|
|
|
layers: [ 0 ],
|
|
|
|
response: {
|
|
|
|
status: 429,
|
|
|
|
headers: {
|
|
|
|
'Content-Type': 'application/json; charset=utf-8'
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
this.testClient.getTile(0, 0, 0, params, (err, res, attributes) => {
|
|
|
|
assert.ifError(err);
|
|
|
|
|
|
|
|
assert.deepEqual(attributes, DATASOURCE_TIMEOUT_ERROR);
|
2017-08-01 00:26:45 +08:00
|
|
|
|
|
|
|
done();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
2017-07-28 00:50:27 +08:00
|
|
|
});
|
2017-08-01 00:26:45 +08:00
|
|
|
});
|
2017-07-28 00:50:27 +08:00
|
|
|
|
2017-08-01 00:26:45 +08:00
|
|
|
describe('attributes:', function () {
|
|
|
|
describe('while validating in map instatiation', function () {
|
|
|
|
beforeEach(function (done) {
|
|
|
|
const mapconfig = createMapConfig({
|
|
|
|
attributes: {
|
|
|
|
id: 'cartodb_id',
|
|
|
|
columns: [ 'val' ]
|
|
|
|
}
|
|
|
|
});
|
|
|
|
this.testClient = new TestClient(mapconfig, 1234);
|
2017-08-10 23:09:05 +08:00
|
|
|
this.testClient.setUserDatabaseTimeoutLimit(200, done);
|
2017-08-01 00:26:45 +08:00
|
|
|
});
|
2017-07-28 00:50:27 +08:00
|
|
|
|
2017-08-01 00:26:45 +08:00
|
|
|
afterEach(function (done) {
|
2017-08-10 23:09:05 +08:00
|
|
|
this.testClient.setUserDatabaseTimeoutLimit(0, (err) => {
|
2017-08-01 00:26:45 +08:00
|
|
|
if (err) {
|
|
|
|
return done(err);
|
|
|
|
}
|
|
|
|
this.testClient.drain(done);
|
2017-07-28 00:50:27 +08:00
|
|
|
});
|
2017-08-01 00:26:45 +08:00
|
|
|
});
|
2017-07-28 00:50:27 +08:00
|
|
|
|
2017-08-01 00:26:45 +08:00
|
|
|
it('layergroup creation fails due to statement timeout', function (done) {
|
|
|
|
const expectedResponse = {
|
2017-08-01 01:08:29 +08:00
|
|
|
status: 429,
|
2017-08-01 00:26:45 +08:00
|
|
|
headers: {
|
|
|
|
'Content-Type': 'application/json; charset=utf-8'
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2017-12-05 19:09:31 +08:00
|
|
|
this.testClient.getLayergroup({ response: expectedResponse }, (err, timeoutError) => {
|
2017-08-01 00:26:45 +08:00
|
|
|
assert.deepEqual(timeoutError, {
|
2018-07-02 19:03:01 +08:00
|
|
|
errors: [db_limit_error_message],
|
2017-08-01 00:26:45 +08:00
|
|
|
errors_with_context: [{
|
2017-08-01 01:36:07 +08:00
|
|
|
type: 'limit',
|
|
|
|
subtype: 'datasource',
|
2018-07-02 19:03:01 +08:00
|
|
|
message: db_limit_error_message,
|
2017-08-01 00:26:45 +08:00
|
|
|
layer: {
|
|
|
|
id: 'layer0',
|
|
|
|
index: 0,
|
|
|
|
type: 'mapnik'
|
|
|
|
}
|
|
|
|
}]
|
|
|
|
});
|
|
|
|
|
|
|
|
done();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('fetching by feature id', function () {
|
|
|
|
beforeEach(function (done) {
|
|
|
|
const mapconfig = createMapConfig({
|
|
|
|
attributes: {
|
|
|
|
id: 'cartodb_id',
|
|
|
|
columns: [ 'val' ]
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
this.testClient = new TestClient(mapconfig, 1234);
|
|
|
|
|
|
|
|
const expectedResponse = {
|
|
|
|
status: 200,
|
|
|
|
headers: {
|
|
|
|
'Content-Type': 'application/json; charset=utf-8'
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2017-12-05 19:09:31 +08:00
|
|
|
this.testClient.getLayergroup({ response: expectedResponse }, (err, res) => {
|
2017-08-01 00:26:45 +08:00
|
|
|
if (err) {
|
|
|
|
return done(err);
|
|
|
|
}
|
|
|
|
|
|
|
|
this.layergroupid = res.layergroupid;
|
|
|
|
|
|
|
|
done();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
afterEach(function (done) {
|
|
|
|
this.testClient.drain(done);
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('with user\'s timeout of 200 ms', function () {
|
|
|
|
beforeEach(function (done) {
|
2017-08-10 23:09:05 +08:00
|
|
|
this.testClient.setUserDatabaseTimeoutLimit(200, done);
|
2017-08-01 00:26:45 +08:00
|
|
|
});
|
|
|
|
|
|
|
|
afterEach(function (done) {
|
2017-08-10 23:09:05 +08:00
|
|
|
this.testClient.setUserDatabaseTimeoutLimit(0, done);
|
2017-08-01 00:26:45 +08:00
|
|
|
});
|
|
|
|
|
|
|
|
it('fails due to statement timeout', function (done) {
|
|
|
|
const params = {
|
|
|
|
layergroupid: this.layergroupid,
|
|
|
|
featureId: 1,
|
|
|
|
layer: 0,
|
|
|
|
response: {
|
2017-08-01 01:08:29 +08:00
|
|
|
status: 429,
|
2017-08-01 00:26:45 +08:00
|
|
|
headers: {
|
|
|
|
'Content-Type': 'application/json; charset=utf-8'
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2017-08-01 16:21:39 +08:00
|
|
|
this.testClient.getAttributes(params, (err, res, timeoutError) => {
|
2017-08-01 00:26:45 +08:00
|
|
|
assert.ifError(err);
|
|
|
|
|
2017-08-01 16:21:39 +08:00
|
|
|
assert.deepEqual(timeoutError, DATASOURCE_TIMEOUT_ERROR);
|
2017-08-01 00:26:45 +08:00
|
|
|
|
|
|
|
done();
|
|
|
|
});
|
|
|
|
});
|
2017-07-28 00:50:27 +08:00
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|