2018-10-24 00:39:02 +08:00
|
|
|
'use strict';
|
|
|
|
|
2019-10-07 16:44:45 +08:00
|
|
|
require('../../support/test-helper');
|
2015-07-08 05:46:58 +08:00
|
|
|
|
|
|
|
var assert = require('../../support/assert');
|
2019-10-07 16:44:45 +08:00
|
|
|
var testClient = require('./support/test-client');
|
|
|
|
var serverOptions = require('./support/ported-server-options');
|
2015-07-08 05:46:58 +08:00
|
|
|
var fs = require('fs');
|
|
|
|
var http = require('http');
|
2019-10-23 00:22:33 +08:00
|
|
|
var path = require('path');
|
2015-07-08 05:46:58 +08:00
|
|
|
|
2019-10-22 01:07:24 +08:00
|
|
|
describe.skip('blend http client timeout', function () {
|
2015-07-08 05:46:58 +08:00
|
|
|
var mapConfig = {
|
|
|
|
version: '1.3.0',
|
|
|
|
layers: [
|
|
|
|
{
|
|
|
|
type: 'http',
|
|
|
|
options: {
|
|
|
|
urlTemplate: 'http://127.0.0.1:8033/{s}/{z}/{x}/{y}.png',
|
|
|
|
subdomains: ['light']
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
|
|
|
type: 'mapnik',
|
|
|
|
options: {
|
|
|
|
sql: 'SELECT * FROM populated_places_simple_reduced',
|
|
|
|
cartocss: '#layer { marker-fill:red; } #layer { marker-width: 2; }',
|
|
|
|
cartocss_version: '2.3.0',
|
|
|
|
geom_column: 'the_geom'
|
|
|
|
}
|
|
|
|
}
|
|
|
|
]
|
|
|
|
};
|
|
|
|
|
|
|
|
var oldHttpRendererTimeout;
|
|
|
|
var httpRendererTimeout = 100;
|
|
|
|
|
|
|
|
var slowHttpRendererResourcesServer;
|
|
|
|
|
2019-10-22 01:07:24 +08:00
|
|
|
before(function (done) {
|
2015-07-08 05:46:58 +08:00
|
|
|
oldHttpRendererTimeout = serverOptions.renderer.http.timeout;
|
|
|
|
serverOptions.renderer.http.timeout = httpRendererTimeout;
|
|
|
|
|
|
|
|
// Start a server to test external resources
|
2019-10-22 01:07:24 +08:00
|
|
|
slowHttpRendererResourcesServer = http.createServer(function (request, response) {
|
|
|
|
setTimeout(function () {
|
2019-10-23 00:22:33 +08:00
|
|
|
var filename = path.join(__dirname, '/../fixtures/http/light_nolabels-1-0-0.png');
|
2019-10-22 01:07:24 +08:00
|
|
|
fs.readFile(filename, { encoding: 'binary' }, function (err, file) {
|
2015-07-08 05:46:58 +08:00
|
|
|
response.writeHead(200);
|
2019-10-22 01:07:24 +08:00
|
|
|
response.write(file, 'binary');
|
2015-07-08 05:46:58 +08:00
|
|
|
response.end();
|
|
|
|
});
|
|
|
|
}, httpRendererTimeout * 2);
|
|
|
|
});
|
|
|
|
slowHttpRendererResourcesServer.listen(8033, done);
|
|
|
|
});
|
|
|
|
|
2019-10-22 01:07:24 +08:00
|
|
|
after(function (done) {
|
2015-07-08 05:46:58 +08:00
|
|
|
serverOptions.renderer.http.timeout = oldHttpRendererTimeout;
|
|
|
|
slowHttpRendererResourcesServer.close(done);
|
|
|
|
});
|
|
|
|
|
2019-10-22 01:07:24 +08:00
|
|
|
it('should fail to render when http layer times out', function (done) {
|
2015-07-08 05:46:58 +08:00
|
|
|
var options = {
|
|
|
|
statusCode: 400,
|
|
|
|
contentType: 'application/json; charset=utf-8',
|
|
|
|
serverOptions: serverOptions
|
|
|
|
};
|
2019-10-22 01:07:24 +08:00
|
|
|
testClient.withLayergroup(mapConfig, options, function (err, requestTile, finish) {
|
2015-07-08 05:46:58 +08:00
|
|
|
var tileUrl = '/all/0/0/0.png';
|
2019-10-22 01:07:24 +08:00
|
|
|
requestTile(tileUrl, options, function (err, res) {
|
2015-07-08 05:46:58 +08:00
|
|
|
assert.ok(!err);
|
|
|
|
var parsedBody = JSON.parse(res.body);
|
|
|
|
assert.ok(parsedBody.errors);
|
|
|
|
assert.ok(parsedBody.errors.length);
|
2019-10-22 01:41:03 +08:00
|
|
|
assert.strictEqual(parsedBody.errors[0], 'Unable to fetch http tile: http://127.0.0.1:8033/light/0/0/0.png');
|
2019-10-22 01:07:24 +08:00
|
|
|
finish(function (finishErr) {
|
2015-07-08 05:46:58 +08:00
|
|
|
done(err || finishErr);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|