Merge branch 'master' into upgrade-windshaft-4.11.3

This commit is contained in:
Daniel García Aubert
2018-10-19 13:08:34 +02:00
18 changed files with 389 additions and 184 deletions
+4 -4
View File
@@ -4,7 +4,7 @@ jobs:
services:
- docker
language: generic
before_install: docker pull carto/nodejs6-xenial-pg101
before_install: docker pull carto/nodejs6-xenial-pg101:postgis-2.4.4.5
script: npm run docker-test
- dist: precise
addons:
@@ -28,7 +28,7 @@ jobs:
- sudo add-apt-repository -y ppa:cartodb/gis-testing
- sudo apt-get update
# Force instalation of libgeos-3.5.0 (presumably needed because of existing version of postgis)
- sudo apt-get -y install libgeos-3.5.0=3.5.0-1cdb2
@@ -59,9 +59,9 @@ jobs:
- createdb template_postgis
- createuser publicuser
- psql -c "CREATE EXTENSION postgis" template_postgis
# install yarn 0.27.5
- curl -o- -L https://yarnpkg.com/install.sh | bash -s -- --version 0.27.5
- curl -o- -L https://yarnpkg.com/install.sh | bash -s -- --version 0.27.5
- export PATH="$HOME/.yarn/bin:$PATH"
# instal redis 4
+1
View File
@@ -5,6 +5,7 @@ Released 2018-mm-dd
New features
- Aggregation time dimensions
- Update sample configurations to use PostGIS to generate MVT's by default (as in production)
- Upgrades Windshaft to [4.11.3](https://github.com/CartoDB/Windshaft/blob/4.11.3/NEWS.md#version-4113)
- `pg-mvt`: Use `query-rewriter` to compose the query to render a MVT tile. If not defined, it will use a Default Query Rewriter.
- `pg-mvt`: Fix bug while building query and there is no columns defined for the layer.
+1 -1
View File
@@ -130,7 +130,7 @@ var config = {
//If enabled, MVTs will be generated with PostGIS directly, instead of using Mapnik,
//PostGIS 2.4 is required for this to work
//If disabled it will use Mapnik MVT generation
usePostGIS: false
usePostGIS: true
},
mapnik: {
// The size of the pool of internal mapnik backend
+1 -1
View File
@@ -130,7 +130,7 @@ var config = {
//If enabled, MVTs will be generated with PostGIS directly, instead of using Mapnik,
//PostGIS 2.4 is required for this to work
//If disabled it will use Mapnik MVT generation
usePostGIS: false
usePostGIS: true
},
mapnik: {
// The size of the pool of internal mapnik backend
+1 -1
View File
@@ -130,7 +130,7 @@ var config = {
//If enabled, MVTs will be generated with PostGIS directly, instead of using Mapnik,
//PostGIS 2.4 is required for this to work
//If disabled it will use Mapnik MVT generation
usePostGIS: false
usePostGIS: true
},
mapnik: {
// The size of the pool of internal mapnik backend
+1 -1
View File
@@ -130,7 +130,7 @@ var config = {
//If enabled, MVTs will be generated with PostGIS directly, instead of using Mapnik,
//PostGIS 2.4 is required for this to work
//If disabled it will use Mapnik MVT generation
usePostGIS: false
usePostGIS: true
},
mapnik: {
// The size of the pool of internal mapnik backend
@@ -0,0 +1,89 @@
FROM ubuntu:xenial
# Use UTF8 to avoid encoding problems with pgsql
ENV LANG C.UTF-8
ENV NPROCS 1
ENV JOBS 1
ENV CXX g++-4.9
ENV PGUSER postgres
# Add external repos
RUN set -ex \
&& apt-get update \
&& apt-get install -y \
curl \
software-properties-common \
locales \
&& add-apt-repository -y ppa:ubuntu-toolchain-r/test \
&& add-apt-repository -y ppa:cartodb/postgresql-10 \
&& add-apt-repository -y ppa:cartodb/gis \
&& curl -sL https://deb.nodesource.com/setup_6.x | bash \
&& locale-gen en_US.UTF-8 \
&& update-locale LANG=en_US.UTF-8
# Install dependencies and PostGIS 2.4 from sources
RUN set -ex \
&& apt-get update \
&& apt-get install -y \
g++-4.9 \
gcc-4.9 \
git \
libcairo2-dev \
libgdal-dev \
libgdal1i \
libgdal20 \
libgeos-dev \
libgif-dev \
libjpeg8-dev \
libjson-c-dev \
libpango1.0-dev \
libpixman-1-dev \
libproj-dev \
libprotobuf-c-dev \
libxml2-dev \
gdal-bin \
make \
nodejs \
protobuf-c-compiler \
pkg-config \
wget \
zip \
postgresql-10 \
postgresql-10-plproxy \
postgresql-10-postgis-2.4 \
postgresql-10-postgis-2.4-scripts \
postgresql-10-postgis-scripts \
postgresql-client-10 \
postgresql-client-common \
postgresql-common \
postgresql-contrib \
postgresql-plpython-10 \
postgresql-server-dev-10 \
postgis \
&& wget http://download.redis.io/releases/redis-4.0.8.tar.gz \
&& tar xvzf redis-4.0.8.tar.gz \
&& cd redis-4.0.8 \
&& make \
&& make install \
&& cd .. \
&& rm redis-4.0.8.tar.gz \
&& rm -R redis-4.0.8 \
&& apt-get purge -y wget protobuf-c-compiler \
&& apt-get autoremove -y
# Configure PostgreSQL
RUN set -ex \
&& echo "listen_addresses='*'" >> /etc/postgresql/10/main/postgresql.conf \
&& echo "local all all trust" > /etc/postgresql/10/main/pg_hba.conf \
&& echo "host all all 0.0.0.0/0 trust" >> /etc/postgresql/10/main/pg_hba.conf \
&& echo "host all all ::1/128 trust" >> /etc/postgresql/10/main/pg_hba.conf \
&& /etc/init.d/postgresql start \
&& createdb template_postgis \
&& createuser publicuser \
&& psql -c "CREATE EXTENSION postgis" template_postgis \
&& /etc/init.d/postgresql stop
WORKDIR /srv
EXPOSE 5858
CMD /etc/init.d/postgresql start
@@ -0,0 +1,88 @@
FROM ubuntu:xenial
# Use UTF8 to avoid encoding problems with pgsql
ENV LANG C.UTF-8
ENV NPROCS 1
ENV JOBS 1
ENV CXX g++-4.9
ENV PGUSER postgres
# Add external repos
RUN set -ex \
&& apt-get update \
&& apt-get install -y \
curl \
software-properties-common \
locales \
&& add-apt-repository -y ppa:ubuntu-toolchain-r/test \
&& add-apt-repository -y ppa:cartodb/postgresql-10 \
&& add-apt-repository -y ppa:cartodb/gis \
&& curl -sL https://deb.nodesource.com/setup_6.x | bash \
&& locale-gen en_US.UTF-8 \
&& update-locale LANG=en_US.UTF-8
RUN set -ex \
&& apt-get update \
&& apt-get install -y \
g++-4.9 \
gcc-4.9 \
git \
libcairo2-dev \
libgdal-dev \
libgdal1i \
libgdal20 \
libgeos-dev \
libgif-dev \
libjpeg8-dev \
libjson-c-dev \
libpango1.0-dev \
libpixman-1-dev \
libproj-dev \
libprotobuf-c-dev \
libxml2-dev \
gdal-bin \
make \
nodejs \
protobuf-c-compiler \
pkg-config \
wget \
zip \
postgresql-10 \
postgresql-10-plproxy \
postgis=2.4.4.5+carto-1 \
postgresql-10-postgis-2.4=2.4.4.5+carto-1 \
postgresql-10-postgis-2.4-scripts=2.4.4.5+carto-1 \
postgresql-10-postgis-scripts=2.4.4.5+carto-1 \
postgresql-client-10 \
postgresql-client-common \
postgresql-common \
postgresql-contrib \
postgresql-plpython-10 \
postgresql-server-dev-10 \
&& wget http://download.redis.io/releases/redis-4.0.8.tar.gz \
&& tar xvzf redis-4.0.8.tar.gz \
&& cd redis-4.0.8 \
&& make \
&& make install \
&& cd .. \
&& rm redis-4.0.8.tar.gz \
&& rm -R redis-4.0.8 \
&& apt-get purge -y wget protobuf-c-compiler \
&& apt-get autoremove -y
# Configure PostgreSQL
RUN set -ex \
&& echo "listen_addresses='*'" >> /etc/postgresql/10/main/postgresql.conf \
&& echo "local all all trust" > /etc/postgresql/10/main/pg_hba.conf \
&& echo "host all all 0.0.0.0/0 trust" >> /etc/postgresql/10/main/pg_hba.conf \
&& echo "host all all ::1/128 trust" >> /etc/postgresql/10/main/pg_hba.conf \
&& /etc/init.d/postgresql start \
&& createdb template_postgis \
&& createuser publicuser \
&& psql -c "CREATE EXTENSION postgis" template_postgis \
&& /etc/init.d/postgresql stop
WORKDIR /srv
EXPOSE 5858
CMD /etc/init.d/postgresql start
@@ -72,14 +72,8 @@ module.exports = class MapStoreMapConfigProvider extends BaseMapConfigProvider {
}
createKey (base) {
const tplValues = Object.assign({
dbname: '',
token: '',
dbuser: '',
format: '',
layer: '',
scale_factor: 1
}, this.params);
const { dbname = '', token = '', dbuser = '', format = '', layer = '', scale_factor = 1 } = this.params;
const tplValues = { dbname, token, dbuser, format, layer, scale_factor };
return (base) ? baseKeyTpl(tplValues) : rendererKeyTpl(tplValues);
}
@@ -232,15 +232,16 @@ module.exports = class NamedMapMapConfigProvider extends BaseMapConfigProvider {
}
createKey (base) {
const tplValues = Object.assign({
dbname: '',
user: this.user,
templateName: this.templateName,
authToken: this.authToken || '',
configHash: configHash(this.config),
layer: '',
scale_factor: 1
}, this.params);
const {
dbname = '',
user = this.user,
templateName = this.templateName,
authToken = this.authToken || '',
configHash = createConfigHash(this.config),
layer = '',
scale_factor = 1
} = this.params;
const tplValues = { dbname, user, templateName, authToken, configHash, layer, scale_factor };
return (base) ? baseKeyTpl(tplValues) : rendererKeyTpl(tplValues);
}
@@ -268,7 +269,7 @@ module.exports = class NamedMapMapConfigProvider extends BaseMapConfigProvider {
}
};
function configHash(config) {
function createConfigHash(config) {
if (!config) {
return '';
}
@@ -276,4 +277,4 @@ function configHash(config) {
return crypto.createHash('md5').update(JSON.stringify(config)).digest('hex').substring(0,8);
}
module.exports.configHash = configHash;
module.exports.configHash = createConfigHash;
+1 -1
View File
@@ -66,7 +66,7 @@
"preinstall": "make pre-install",
"test": "make test-all",
"update-internal-deps": "rm -rf node_modules && rm -f yarn.lock && yarn",
"docker-test": "docker run -v `pwd`:/srv carto/nodejs6-xenial-pg101 bash run_tests_docker.sh && docker ps --filter status=dead --filter status=exited -aq | xargs -r docker rm -v",
"docker-test": "docker run -v `pwd`:/srv carto/nodejs6-xenial-pg101:postgis-2.4.4.5 bash run_tests_docker.sh && docker ps --filter status=dead --filter status=exited -aq | xargs -r docker rm -v",
"docker-bash": "docker run -it -v `pwd`:/srv carto/nodejs6-xenial-pg101 bash"
},
"engines": {
+95 -53
View File
@@ -54,6 +54,8 @@ function createMapConfig (bufferSize, cartocss) {
}
describe('buffer size per format', function () {
let testClient;
var testCases = [
{
desc: 'should get png tile using buffer-size 0',
@@ -126,36 +128,55 @@ describe('buffer size per format', function () {
];
afterEach(function(done) {
if (this.testClient) {
return this.testClient.drain(done);
if (testClient) {
return testClient.drain(done);
}
return done();
});
const originalUsePostGIS = serverOptions.renderer.mvt.usePostGIS;
testCases.forEach(function (test) {
var testFn = (usePostGIS) => {
it(test.desc, function (done) {
serverOptions.renderer.mvt.usePostGIS = usePostGIS;
this.testClient = new TestClient(test.mapConfig, 1234);
serverOptions.renderer.mvt.usePostGIS = originalUsePostGIS;
var coords = test.coords;
var options = {
format: test.format,
layers: test.layers
};
this.testClient.getTile(coords.z, coords.x, coords.y, options, function (err, res, tile) {
assert.ifError(err);
// To generate images use:
// tile.save(test.fixturePath);
test.assert(tile, done);
});
after(function () {
serverOptions.renderer.mvt.usePostGIS = originalUsePostGIS;
});
var testFn = (test) => {
it(test.desc, function (done) {
testClient = new TestClient(test.mapConfig, 1234);
var coords = test.coords;
var options = {
format: test.format,
layers: test.layers
};
testClient.getTile(coords.z, coords.x, coords.y, options, function (err, res, tile) {
assert.ifError(err);
// To generate images use:
// tile.save(test.fixturePath);
test.assert(tile, done);
});
};
if (process.env.POSTGIS_VERSION >= '20400' && test.format === 'mvt'){
testFn(true);
}
testFn(false);
});
};
testCases.filter(test => test.format !== 'mvt').forEach(function (test) {
testFn(test);
});
describe('using mapnik mvt renderer', function() {
before(function () {
serverOptions.renderer.mvt.usePostGIS = false;
});
testCases.filter(test => test.format === 'mvt').forEach(function (test) {
testFn(test);
});
});
const describe_pg = process.env.POSTGIS_VERSION >= '20400' ? describe : describe.skip;
describe_pg('using postgis mvt renderer', function() {
before(function () {
serverOptions.renderer.mvt.usePostGIS = true;
});
testCases.filter(test => test.format === 'mvt').forEach(function (test) {
testFn(test);
});
});
});
@@ -302,6 +323,8 @@ describe('buffer size per format for named maps', function () {
describe('buffer size per format for named maps w/o placeholders', function () {
let testClient;
var testCases = [
{
desc: 'should get png tile using buffer-size 0 overriden by template params',
@@ -435,39 +458,58 @@ describe('buffer size per format for named maps w/o placeholders', function () {
];
afterEach(function(done) {
if (this.testClient) {
return this.testClient.drain(done);
if (testClient) {
return testClient.drain(done);
}
return done();
});
const originalUsePostGIS = serverOptions.renderer.mvt.usePostGIS;
testCases.forEach(function (test) {
var testFn = (usePostGIS) => {
it(test.desc + `(${usePostGIS? 'PostGIS':'mapnik'})`, function (done) {
serverOptions.renderer.mvt.usePostGIS = usePostGIS;
test.template.name += '_1';
this.testClient = new TestClient(test.template, 1234);
serverOptions.renderer.mvt.usePostGIS = originalUsePostGIS;
var coords = test.coords;
var options = {
format: test.format,
placeholders: test.placeholders,
layers: test.layers
};
this.testClient.getTile(coords.z, coords.x, coords.y, options, function (err, res, tile) {
assert.ifError(err);
// To generate images use:
//tile.save(test.fixturePath);
// require('fs').writeFileSync(test.fixturePath, JSON.stringify(tile));
// require('fs').writeFileSync(test.fixturePath, tile.getDataSync());
test.assert(tile, done);
});
});
};
if (process.env.POSTGIS_VERSION >= '20400' && test.format === 'mvt'){
testFn(true);
}
testFn(false);
after(function () {
serverOptions.renderer.mvt.usePostGIS = originalUsePostGIS;
});
var testFn = (test) => {
it(test.desc, function (done) {
test.template.name += '_1';
testClient = new TestClient(test.template, 1234);
var coords = test.coords;
var options = {
format: test.format,
placeholders: test.placeholders,
layers: test.layers
};
testClient.getTile(coords.z, coords.x, coords.y, options, function (err, res, tile) {
assert.ifError(err);
// To generate images use:
//tile.save(test.fixturePath);
// require('fs').writeFileSync(test.fixturePath, JSON.stringify(tile));
// require('fs').writeFileSync(test.fixturePath, tile.getDataSync());
test.assert(tile, done);
});
});
};
testCases.filter(test => test.format !== 'mvt').forEach(function (test) {
testFn(test);
});
describe('using mapnik mvt renderer', function() {
before(function () {
serverOptions.renderer.mvt.usePostGIS = false;
});
testCases.filter(test => test.format === 'mvt').forEach(function (test) {
testFn(test);
});
});
const describe_pg = process.env.POSTGIS_VERSION >= '20400' ? describe : describe.skip;
describe_pg('using postgis mvt renderer', function() {
before(function () {
serverOptions.renderer.mvt.usePostGIS = true;
});
testCases.filter(test => test.format === 'mvt').forEach(function (test) {
testFn(test);
});
});
});
+26 -22
View File
@@ -2,8 +2,13 @@
const assert = require('assert');
const TestClient = require('../support/test-client');
const mapConfigFactory = require('../fixtures/test_mapconfigFactory');
const serverOptions = require('../../lib/cartodb/server_options');
describe('date-wrapping', () => {
const usePgMvtRenderer = serverOptions.renderer.mvt.usePostGIS;
const postgisVersion = process.env.POSTGIS_VERSION;
const describe_mvt = postgisVersion >= '20400' || !usePgMvtRenderer ? describe : describe.skip;
describe_mvt('date-wrapping', () => {
let testClient;
describe('when a map instantiation has one single layer', () => {
@@ -21,13 +26,13 @@ describe('date-wrapping', () => {
const expected = [
{
type: 'Feature',
id: 1,
id: 0,
geometry: { type: 'Point', coordinates: [0, 0] },
properties: { _cdb_feature_count: 1, cartodb_id: 0, date: 1527810000 }
},
{
type: 'Feature',
id: 2,
id: 1,
geometry: { type: 'Point', coordinates: [0, 0] },
properties: { _cdb_feature_count: 1, cartodb_id: 1, date: 1527900000 }
}
@@ -65,13 +70,13 @@ describe('date-wrapping', () => {
const expected = [
{
type: 'Feature',
id: 1,
id: 0,
geometry: { type: 'Point', coordinates: [0, 0] },
properties: { _cdb_feature_count: 1, cartodb_id: 0 }
},
{
type: 'Feature',
id: 2,
id: 1,
geometry: { type: 'Point', coordinates: [0, 0] },
properties: { _cdb_feature_count: 1, cartodb_id: 1 }
}
@@ -111,13 +116,13 @@ describe('date-wrapping', () => {
const expected0 = [
{
type: 'Feature',
id: 1,
id: 0,
geometry: { type: 'Point', coordinates: [0, 0] },
properties: { _cdb_feature_count: 1, cartodb_id: 0, date: 1527810000 }
},
{
type: 'Feature',
id: 2,
id: 1,
geometry: { type: 'Point', coordinates: [0, 0] },
properties: { _cdb_feature_count: 1, cartodb_id: 1, date: 1527900000 }
}
@@ -125,13 +130,13 @@ describe('date-wrapping', () => {
const expected1 = [
{
type: 'Feature',
id: 1,
id: 0,
geometry: { type: 'Point', coordinates: [0, 0] },
properties: { _cdb_feature_count: 1, cartodb_id: 0, date: 1527810000 }
},
{
type: 'Feature',
id: 2,
id: 1,
geometry: { type: 'Point', coordinates: [0, 0] },
properties: { _cdb_feature_count: 1, cartodb_id: 1, date: 1527900000 }
}
@@ -169,13 +174,13 @@ describe('date-wrapping', () => {
const expected0 = [
{
type: 'Feature',
id: 1,
id: 0,
geometry: { type: 'Point', coordinates: [0, 0] },
properties: { _cdb_feature_count: 1, cartodb_id: 0 }
},
{
type: 'Feature',
id: 2,
id: 1,
geometry: { type: 'Point', coordinates: [0, 0] },
properties: { _cdb_feature_count: 1, cartodb_id: 1 }
}
@@ -183,13 +188,13 @@ describe('date-wrapping', () => {
const expected1 = [
{
type: 'Feature',
id: 1,
id: 0,
geometry: { type: 'Point', coordinates: [0, 0] },
properties: { _cdb_feature_count: 1, cartodb_id: 0, date: 1527810000 }
},
{
type: 'Feature',
id: 2,
id: 1,
geometry: { type: 'Point', coordinates: [0, 0] },
properties: { _cdb_feature_count: 1, cartodb_id: 1, date: 1527900000 }
}
@@ -227,13 +232,13 @@ describe('date-wrapping', () => {
const expected0 = [
{
type: 'Feature',
id: 1,
id: 0,
geometry: { type: 'Point', coordinates: [0, 0] },
properties: { _cdb_feature_count: 1, cartodb_id: 0 }
},
{
type: 'Feature',
id: 2,
id: 1,
geometry: { type: 'Point', coordinates: [0, 0] },
properties: { _cdb_feature_count: 1, cartodb_id: 1 }
}
@@ -241,13 +246,13 @@ describe('date-wrapping', () => {
const expected1 = [
{
type: 'Feature',
id: 1,
id: 0,
geometry: { type: 'Point', coordinates: [0, 0] },
properties: { _cdb_feature_count: 1, cartodb_id: 0 }
},
{
type: 'Feature',
id: 2,
id: 1,
geometry: { type: 'Point', coordinates: [0, 0] },
properties: { _cdb_feature_count: 1, cartodb_id: 1 }
}
@@ -292,19 +297,18 @@ describe('date-wrapping', () => {
const expected = [
{
type: 'Feature',
id: 1,
id: 0,
geometry: { type: 'Point', coordinates: [0, 0] },
properties: { cartodb_id: 0, date: 1527810000, sc: 559082000 }
properties: { cartodb_id: 0, date: 1527810000, sc: 559082264.0287178839788058162356 }
},
{
type: 'Feature',
id: 2,
id: 1,
geometry: { type: 'Point', coordinates: [0, 0] },
properties: { cartodb_id: 1, date: 1527900000, sc: 559082000 }
properties: { cartodb_id: 1, date: 1527900000, sc: 559082264.0287178839788058162356 }
}
];
const actual = JSON.parse(mvt.toGeoJSONSync(0)).features;
assert.deepEqual(actual, expected);
done();
});
+13
View File
@@ -2,8 +2,21 @@ require('../support/test_helper');
const assert = require('../support/assert');
const TestClient = require('../support/test-client');
const serverOptions = require('../../lib/cartodb/server_options');
describe('layergroup metadata', function () {
const usePgMvtRenderer = process.env.POSTGIS_VERSION >= '20400';
const originalUsePostGIS = serverOptions.renderer.mvt.usePostGIS;
before(function () {
serverOptions.renderer.mvt.usePostGIS = usePgMvtRenderer;
});
after(function () {
serverOptions.renderer.mvt.usePostGIS = originalUsePostGIS;
});
[1234, 'default_public', false].forEach(api_key => {
it(`tiles base urls ${api_key ? `with api key: ${api_key}` : 'without api key'}`, function (done) {
const mapConfig = {
+20 -5
View File
@@ -7,6 +7,7 @@ const cartodbRedis = require('cartodb-redis');
const TestClient = require('../support/test-client');
const UserLimitsBackend = require('../../lib/cartodb/backends/user-limits');
const rateLimitMiddleware = require('../../lib/cartodb/api/middlewares/rate-limit');
const serverOptions = require('../../lib/cartodb/server_options');
const { RATE_LIMIT_ENDPOINTS_GROUPS } = rateLimitMiddleware;
let userLimitsApi;
@@ -19,7 +20,7 @@ let layergroupid;
const query = `
SELECT
ST_Transform('SRID=4326;POINT(-180 85.05112877)'::geometry, 3857) the_geom_webmercator,
ST_Transform('SRID=4326;POINT(-70 42)'::geometry, 3857) the_geom_webmercator,
1 cartodb_id,
2 val
`;
@@ -273,7 +274,21 @@ describe('rate limit middleware', function () {
});
});
describe('rate limit and vector tiles', function () {
const describe_pg = process.env.POSTGIS_VERSION >= '20400' ? describe : describe.skip;
const originalUsePostGIS = serverOptions.renderer.mvt.usePostGIS;
describe('rate limit and vector tiles (mapnik)', () => { rateLimitAndVectorTilesTest(false); });
describe_pg('rate limit and vector tiles (postgis)', () => { rateLimitAndVectorTilesTest(true); });
function rateLimitAndVectorTilesTest(usePostGIS) {
before(function() {
serverOptions.renderer.mvt.usePostGIS = usePostGIS;
});
after(function () {
serverOptions.renderer.mvt.usePostGIS = originalUsePostGIS;
});
before(function(done) {
global.environment.enabledFeatures.rateLimitsEnabled = true;
@@ -310,7 +325,7 @@ describe('rate limit and vector tiles', function () {
redisClient.SELECT(5, () => {
redisClient.del('user:localhost:mapviews:global');
done();
setTimeout(done, 1000);
});
});
});
@@ -335,7 +350,7 @@ describe('rate limit and vector tiles', function () {
};
};
testClient.getTile(0, 0, 0, tileParams(204, '1', '0', '1'), (err) => {
testClient.getTile(0, 0, 0, tileParams(200, '1', '0', '1'), (err) => {
assert.ifError(err);
testClient.getTile(
@@ -358,4 +373,4 @@ describe('rate limit and vector tiles', function () {
});
});
});
}
+17 -3
View File
@@ -2,8 +2,23 @@ require('../support/test_helper');
const assert = require('../support/assert');
const TestClient = require('../support/test-client');
const serverOptions = require('../../lib/cartodb/server_options');
describe('tilejson', function() {
const describe_pg = process.env.POSTGIS_VERSION >= '20400' ? describe : describe.skip;
const originalUsePostGIS = serverOptions.renderer.mvt.usePostGIS;
describe('tilejson via mapnik renderer', () => { tileJsonSuite(false); });
describe_pg('tilejson via postgis renderer', () => { tileJsonSuite(true); });
function tileJsonSuite(usePostGIS) {
before(function() {
serverOptions.renderer.mvt.usePostGIS = usePostGIS;
});
after(function () {
serverOptions.renderer.mvt.usePostGIS = originalUsePostGIS;
});
function tilejsonValidation(tilejson, shouldHaveGrid = false) {
assert.equal(tilejson.tilejson, '2.2.0');
@@ -215,5 +230,4 @@ describe('tilejson', function() {
});
});
});
}
+17 -73
View File
@@ -380,7 +380,22 @@ describe('user database timeout limit', function () {
});
});
describe('fetching vector tiles', function () {
const describe_pg = process.env.POSTGIS_VERSION >= '20400' ? describe : describe.skip;
describe('fetching vector tiles via mapnik renderer', () => { testFetchingVectorTiles(false); });
describe_pg('fetching vector tiles via postgis renderer', () => { testFetchingVectorTiles(true); });
function testFetchingVectorTiles(usePostGIS) {
const originalUsePostGIS = serverOptions.renderer.mvt.usePostGIS;
before(function () {
serverOptions.renderer.mvt.usePostGIS = usePostGIS;
});
after(function () {
serverOptions.renderer.mvt.usePostGIS = originalUsePostGIS;
});
beforeEach(function (done) {
const mapconfig = createMapConfig();
this.testClient = new TestClient(mapconfig, 1234);
@@ -442,78 +457,7 @@ describe('user database timeout limit', function () {
});
});
if (process.env.POSTGIS_VERSION >= '20400') {
describe('fetching vector tiles via PostGIS renderer', function() {
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();
});
});
afterEach(function () {
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();
});
});
});
});
}
});
}
});