Fix ported test related to cache_buster from layergroup token
This commit is contained in:
parent
b038763b7b
commit
5cde325d9a
@ -7,7 +7,7 @@ var cartodbServer = require('../../../lib/cartodb/server');
|
||||
var ServerOptions = require('./support/ported_server_options');
|
||||
var testClient = require('./support/test_client');
|
||||
|
||||
describe('server_gettile', function() {
|
||||
describe.only('server_gettile', function() {
|
||||
|
||||
var server = cartodbServer(ServerOptions);
|
||||
server.setMaxListeners(0);
|
||||
@ -42,8 +42,7 @@ describe('server_gettile', function() {
|
||||
);
|
||||
});
|
||||
|
||||
// REVIEW
|
||||
it.skip("response of get tile can be served by renderer cache", function(done) {
|
||||
it("response of get tile can be served by renderer cache", function(done) {
|
||||
var tileUrl = '/13/4011/3088.png';
|
||||
var lastXwc;
|
||||
var mapConfig = testClient.defaultTableMapConfig('test_table');
|
||||
@ -60,7 +59,7 @@ describe('server_gettile', function() {
|
||||
assert.ok(xwc > 0);
|
||||
assert.ok(xwc >= lastXwc);
|
||||
|
||||
requestTile(tileUrl + '?cache_buster=wadus', function (err, res) {
|
||||
requestTile(tileUrl, { cache_buster: 'wadus' }, function (err, res) {
|
||||
var xwc = res.headers['x-windshaft-cache'];
|
||||
assert.ok(!xwc);
|
||||
|
||||
@ -85,8 +84,7 @@ describe('server_gettile', function() {
|
||||
);
|
||||
});
|
||||
|
||||
// REVIEW
|
||||
it.skip("getting two tiles with same configuration uses renderer cache", function(done) {
|
||||
it("getting two tiles with same configuration uses renderer cache", function(done) {
|
||||
|
||||
var imageFixture = './test/fixtures/test_table_13_4011_3088_styled.png';
|
||||
var tileUrl = '/13/4011/3088.png';
|
||||
@ -101,9 +99,15 @@ describe('server_gettile', function() {
|
||||
}
|
||||
|
||||
testClient.withLayergroup(mapConfig, validateLayergroup, function(err, requestTile, finish) {
|
||||
requestTile(tileUrl, function(err, res) {
|
||||
var xwc = res.headers['x-windshaft-cache'];
|
||||
assert.ok(!xwc);
|
||||
|
||||
requestTile(tileUrl, function (err, res) {
|
||||
assert.ok(res.headers.hasOwnProperty('x-windshaft-cache'), "Did not hit renderer cache on second time");
|
||||
assert.ok(
|
||||
res.headers.hasOwnProperty('x-windshaft-cache'),
|
||||
"Did not hit renderer cache on second time"
|
||||
);
|
||||
assert.ok(res.headers['x-windshaft-cache'] >= 0);
|
||||
|
||||
assert.imageBufferIsSimilarToFile(res.body, imageFixture, IMAGE_EQUALS_TOLERANCE_PER_MIL,
|
||||
@ -116,6 +120,7 @@ describe('server_gettile', function() {
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
var test_style_black_200 = "#test_table{marker-fill:black;marker-line-color:black;marker-width:5}";
|
||||
var test_style_black_210 = "#test_table{marker-fill:black;marker-line-color:black;marker-width:10}";
|
||||
|
@ -1,7 +1,6 @@
|
||||
var _ = require('underscore');
|
||||
var serverOptions = require('../../../../lib/cartodb/server_options');
|
||||
var mapnik = require('windshaft').mapnik;
|
||||
var LayergroupToken = require('../../../../lib/cartodb/models/layergroup-token');
|
||||
var OverviewsQueryRewriter = require('../../../../lib/cartodb/utils/overviews_query_rewriter');
|
||||
var overviewsQueryRewriter = new OverviewsQueryRewriter({
|
||||
zoom_level: 'CDB_ZoomFromScale(!scale_denominator!)'
|
||||
|
@ -454,8 +454,21 @@ function withLayergroup(layergroupConfig, options, callback) {
|
||||
};
|
||||
}
|
||||
|
||||
var baseUrlTpl = '/database/windshaft_test/layergroup/<%= layergroupid %>';
|
||||
var finalUrl = _.template(baseUrlTpl, { layergroupid: layergroupid }) + layergroupUrl;
|
||||
const signerTpl = function ({ signer }) {
|
||||
return `${signer ? `:${signer}@` : ''}`;
|
||||
}
|
||||
|
||||
const cacheTpl = function ({ cache_buster, cacheBuster }) {
|
||||
return `${cache_buster ? `:${cache_buster}` : `:${cacheBuster}`}`;
|
||||
}
|
||||
|
||||
const urlTpl = function ({layergroupid, cache_buster = null, tile }) {
|
||||
const { signer, token , cacheBuster } = LayergroupToken.parse(layergroupid);
|
||||
const base = '/database/windshaft_test/layergroup/'
|
||||
return `${base}${signerTpl({signer})}${token}${cacheTpl({cache_buster, cacheBuster})}${tile}`;
|
||||
}
|
||||
|
||||
const finalUrl = urlTpl({ layergroupid, cache_buster: options.cache_buster, tile: layergroupUrl });
|
||||
|
||||
var request = {
|
||||
url: finalUrl,
|
||||
|
Loading…
Reference in New Issue
Block a user