Skip to content

Commit

Permalink
Merge pull request #181 from rochoa/master
Browse files Browse the repository at this point in the history
Minimal changes to get tests running in Mac OS X plus other cleanups
  • Loading branch information
strk committed Apr 7, 2014
2 parents f63b4c3 + 8c09f30 commit afd8158
Show file tree
Hide file tree
Showing 6 changed files with 81 additions and 83 deletions.
8 changes: 7 additions & 1 deletion README.md
Expand Up @@ -95,7 +95,7 @@ var config = {
grainstore: {
datasource: {
user:'postgres', host: '127.0.0.1',
port: 5432
port: 5432
}
}, //see grainstore npm for other options
renderCache: {
Expand Down Expand Up @@ -162,6 +162,12 @@ try `redis-cli flushall`. Windshaft caches MML files in Redis than can contain S
and may not expire them when you change your Windshaft config, but manually flushing
redis should do the trick.

### Uncaught Error: Command failed running tests
You need [ImageMagick](http://www.imagemagick.org/) to run some tests. In Mac OS X
there are some issues running with latest versions of ImageMagick. If you use
[Homebrew](http://brew.sh/) you can try with a
[modified Formula to install ImageMagick version 6.7.7](https://gist.github.com/rochoa/10017167).

--
Thanks to the Mapnik and Mapbox team for making such flexible tools

Expand Down
1 change: 0 additions & 1 deletion lib/windshaft/server.js
Expand Up @@ -8,7 +8,6 @@ var express = require('express')
, mapnik = require('mapnik')
, Step = require('step')
, semver = require('semver')
, LRU = require('lru-cache')
, Profiler = require('step-profiler')
, PSQL = require('./psql')
, StatsD = require('node-statsd').StatsD
Expand Down
7 changes: 3 additions & 4 deletions package.json
Expand Up @@ -6,14 +6,14 @@
"keywords": [
"cartodb"
],
"url": "https://github.com/Vizzuality/Windshaft",
"url": "https://github.com/CartoDB/Windshaft",
"licenses": [{
"type": "BSD",
"url": "https://github.com/Vizzuality/Windshaft/blob/master/LICENSE"
"url": "https://github.com/CartoDB/Windshaft/blob/master/LICENSE"
}],
"repository": {
"type": "git",
"url": "git://github.com/Vizzuality/Windshaft.git"
"url": "git://github.com/CartoDB/Windshaft.git"
},
"author": "Vizzuality <contact@vizzuality.com> (http://vizzuality.com)",
"contributors": [
Expand All @@ -32,7 +32,6 @@
"mapnik": "~0.7.17",
"semver": "~1.1.0",
"redis-mpool": "~0.0.2",
"lru-cache": "~2.3.0",
"carto": "http://github.com/CartoDB/carto/tarball/0.9.5-cdb3",
"step-profiler": "git://github.com/CartoDB/node-step-profiler.git#0.0.1",
"underscore.string": "~1.1.6",
Expand Down
26 changes: 10 additions & 16 deletions test/acceptance/multilayer.js
Expand Up @@ -29,6 +29,8 @@ suite('multilayer', function() {
mapnik.register_system_fonts();
var available_system_fonts = _.keys(mapnik.fontFiles());

var IMAGE_EQUALS_TOLERANCE_PER_MIL = 20;

checkCORSHeaders = function(res) {
var h = res.headers['access-control-allow-headers'];
assert.ok(h);
Expand Down Expand Up @@ -227,8 +229,7 @@ suite('multilayer', function() {
assert.equal(res.statusCode, 200, res.body);
assert.equal(res.headers['content-type'], "image/png");
checkCORSHeaders(res);
assert.imageEqualsFile(res.body, './test/fixtures/test_bigpoint_red.png', 2,
function(err, similarity) {
assert.imageEqualsFile(res.body, './test/fixtures/test_bigpoint_red.png', IMAGE_EQUALS_TOLERANCE_PER_MIL, function(err) {
next(err);
});
});
Expand Down Expand Up @@ -301,8 +302,7 @@ suite('multilayer', function() {
}, {}, function(res) {
assert.equal(res.statusCode, 200, res.body);
assert.equal(res.headers['content-type'], "image/png");
assert.imageEqualsFile(res.body, './test/fixtures/test_table_0_0_0_multilayer1.png', 2,
function(err, similarity) {
assert.imageEqualsFile(res.body, './test/fixtures/test_table_0_0_0_multilayer1.png', IMAGE_EQUALS_TOLERANCE_PER_MIL, function(err) {
next(err);
});
});
Expand Down Expand Up @@ -412,8 +412,7 @@ suite('multilayer', function() {
}, {}, function(res) {
assert.equal(res.statusCode, 200, res.body);
assert.equal(res.headers['content-type'], "image/png");
assert.imageEqualsFile(res.body, './test/fixtures/test_table_0_0_0_multilayer1.png', 2,
function(err, similarity) {
assert.imageEqualsFile(res.body, './test/fixtures/test_table_0_0_0_multilayer1.png', IMAGE_EQUALS_TOLERANCE_PER_MIL, function(err) {
next(err);
});
});
Expand Down Expand Up @@ -521,8 +520,7 @@ suite('multilayer', function() {
}, {}, function(res) {
assert.equal(res.statusCode, 200, res.body);
assert.equal(res.headers['content-type'], "image/png");
assert.imageEqualsFile(res.body, './test/fixtures/test_table_0_0_0_multilayer1.png', 2,
function(err, similarity) {
assert.imageEqualsFile(res.body, './test/fixtures/test_table_0_0_0_multilayer1.png', IMAGE_EQUALS_TOLERANCE_PER_MIL, function(err) {
next(err);
});
});
Expand Down Expand Up @@ -635,8 +633,7 @@ suite('multilayer', function() {
}, {}, function(res) {
assert.equal(res.statusCode, 200, res.body);
assert.equal(res.headers['content-type'], "image/png");
assert.imageEqualsFile(res.body, './test/fixtures/test_table_0_0_0_multilayer1.png', 2,
function(err, similarity) {
assert.imageEqualsFile(res.body, './test/fixtures/test_table_0_0_0_multilayer1.png', IMAGE_EQUALS_TOLERANCE_PER_MIL, function(err) {
next(err);
});
});
Expand Down Expand Up @@ -884,8 +881,7 @@ suite('multilayer', function() {
}, {}, function(res) {
assert.equal(res.statusCode, 200, res.body);
assert.equal(res.headers['content-type'], "image/png");
assert.imageEqualsFile(res.body, './test/fixtures/test_table_0_0_0_multilayer2.png', 2,
function(err, similarity) {
assert.imageEqualsFile(res.body, './test/fixtures/test_table_0_0_0_multilayer2.png', IMAGE_EQUALS_TOLERANCE_PER_MIL, function(err) {
next(err);
});
});
Expand Down Expand Up @@ -918,8 +914,7 @@ suite('multilayer', function() {
}, {}, function(res) {
assert.equal(res.statusCode, 200, res.body);
assert.equal(res.headers['content-type'], "image/png");
assert.imageEqualsFile(res.body, './test/fixtures/test_table_0_0_0_multilayer3.png', 2,
function(err, similarity) {
assert.imageEqualsFile(res.body, './test/fixtures/test_table_0_0_0_multilayer3.png', IMAGE_EQUALS_TOLERANCE_PER_MIL, function(err) {
next(err);
});
});
Expand Down Expand Up @@ -1014,8 +1009,7 @@ suite('multilayer', function() {
}, {}, function(res) {
assert.equal(res.statusCode, 200, res.body);
assert.equal(res.headers['content-type'], "image/png");
assert.imageEqualsFile(res.body, './test/fixtures/test_table_0_0_0_multilayer4.png', 2,
function(err, similarity) {
assert.imageEqualsFile(res.body, './test/fixtures/test_table_0_0_0_multilayer4.png', IMAGE_EQUALS_TOLERANCE_PER_MIL, function(err) {
next(err);
});
});
Expand Down
59 changes: 23 additions & 36 deletions test/acceptance/server_gettile.js
Expand Up @@ -44,6 +44,8 @@ suite('server_gettile', function() {

var mapnik_version = global.environment.mapnik_version || mapnik.versions.mapnik;

var IMAGE_EQUALS_TOLERANCE_PER_MIL = 25;

var default_style;
if ( semver.satisfies(mapnik_version, '<2.1.0') ) {
// 2.0.0 default
Expand Down Expand Up @@ -107,7 +109,7 @@ suite('server_gettile', function() {
status: 200,
headers: { 'Content-Type': 'image/png' }
}, function(res){
assert.imageEqualsFile(res.body, './test/fixtures/test_table_13_4011_3088.png', 2, function(err, similarity) {
assert.imageEqualsFile(res.body, './test/fixtures/test_table_13_4011_3088.png', IMAGE_EQUALS_TOLERANCE_PER_MIL, function(err) {
if (err) throw err;
assert.deepEqual(res.headers['content-type'], "image/png");
done();
Expand Down Expand Up @@ -196,7 +198,7 @@ suite('server_gettile', function() {
status: 200,
headers: { 'Content-Type': 'image/png' }
}, function(res){
assert.imageEqualsFile(res.body, './test/fixtures/test_table_13_4011_3088_limit_2.png', 2, function(err, similarity) {
assert.imageEqualsFile(res.body, './test/fixtures/test_table_13_4011_3088_limit_2.png', IMAGE_EQUALS_TOLERANCE_PER_MIL, function(err) {
if (err) throw err;
assert.deepEqual(res.headers['content-type'], "image/png");
done();
Expand Down Expand Up @@ -293,8 +295,7 @@ suite('server_gettile', function() {
status: 200,
headers: { 'Content-Type': 'image/png' }
}, function(res){
assert.imageEqualsFile(res.body, './test/fixtures/test_table_13_4011_3088_styled.png', 2,
function(err, similarity) {
assert.imageEqualsFile(res.body, './test/fixtures/test_table_13_4011_3088_styled.png', IMAGE_EQUALS_TOLERANCE_PER_MIL, function(err) {
if (err) throw err;
done();
});
Expand All @@ -311,8 +312,7 @@ suite('server_gettile', function() {
},{}, function(res){
assert.ok(!res.headers.hasOwnProperty('x-windshaft-cache'),
"Did hit renderer cache on first time");
assert.imageEqualsFile(res.body, './test/fixtures/test_table_13_4011_3088_styled.png', 2,
function(err, similarity) {
assert.imageEqualsFile(res.body, './test/fixtures/test_table_13_4011_3088_styled.png', IMAGE_EQUALS_TOLERANCE_PER_MIL, function(err) {
if (err) { done(err); return; }
assert.response(server, {
url: '/database/windshaft_test/table/test_table/13/4011/3087.png?cache_buster=5&' + style,
Expand Down Expand Up @@ -341,8 +341,7 @@ suite('server_gettile', function() {
},{}, function(res){
assert.equal(res.statusCode, 200, res.statusCode + ': ' + res.body);
assert.equal(res.headers['content-type'], "image/png");
assert.imageEqualsFile(res.body, './test/fixtures/test_table_13_4011_3088_styled_black.png', 2,
function(err, similarity) {
assert.imageEqualsFile(res.body, './test/fixtures/test_table_13_4011_3088_styled_black.png', IMAGE_EQUALS_TOLERANCE_PER_MIL, function(err, similarity) {
if (err) throw err;
done();
});
Expand All @@ -358,8 +357,7 @@ suite('server_gettile', function() {
},{}, function(res){
assert.equal(res.statusCode, 200, res.statusCode + ': ' + res.body);
assert.equal(res.headers['content-type'], "image/png");
assert.imageEqualsFile(res.body, './test/fixtures/test_table_13_4011_3088_styled_black.png', 2,
function(err, similarity) {
assert.imageEqualsFile(res.body, './test/fixtures/test_table_13_4011_3088_styled_black.png', IMAGE_EQUALS_TOLERANCE_PER_MIL, function(err) {
if (err) throw err;
done();
});
Expand All @@ -376,8 +374,7 @@ suite('server_gettile', function() {
status: 200,
headers: { 'Content-Type': 'image/png' }
}, function(res){
assert.imageEqualsFile(res.body, './test/fixtures/test_table_13_4011_3088_styled_black.png', 2,
function(err, similarity) {
assert.imageEqualsFile(res.body, './test/fixtures/test_table_13_4011_3088_styled_black.png', IMAGE_EQUALS_TOLERANCE_PER_MIL, function(err) {
if (err) throw err;
done();
});
Expand Down Expand Up @@ -406,7 +403,7 @@ suite('server_gettile', function() {
status: 200,
headers: { 'Content-Type': 'image/png' }
}, function(res){
assert.imageEqualsFile(res.body, './test/fixtures/test_table_13_4011_3088_styled_black.png', 2, function(err, similarity) {
assert.imageEqualsFile(res.body, './test/fixtures/test_table_13_4011_3088_styled_black.png', IMAGE_EQUALS_TOLERANCE_PER_MIL, function(err) {
if (err) throw err;
assert.deepEqual(res.headers['content-type'], "image/png");

Expand All @@ -420,7 +417,7 @@ suite('server_gettile', function() {
status: 200,
headers: { 'Content-Type': 'image/png' }
}, function(res){
assert.imageEqualsFile(res.body, './test/fixtures/test_table_13_4011_3088_styled_black.png', 2, function(err, similarity) {
assert.imageEqualsFile(res.body, './test/fixtures/test_table_13_4011_3088_styled_black.png', IMAGE_EQUALS_TOLERANCE_PER_MIL, function(err) {
if (err) throw err;
assert.deepEqual(res.headers['content-type'], "image/png");

Expand All @@ -433,12 +430,12 @@ suite('server_gettile', function() {
status: 200,
headers: { 'Content-Type': 'image/png' }
}, function(res){
assert.imageEqualsFile(res.body, './test/fixtures/test_table_13_4011_3088.png', 2, function(err, similarity) {
assert.imageEqualsFile(res.body, './test/fixtures/test_table_13_4011_3088.png', IMAGE_EQUALS_TOLERANCE_PER_MIL, function(err) {
if (err) throw err;
assert.deepEqual(res.headers['content-type'], "image/png");
done();
});
});
});
});
});
});
Expand Down Expand Up @@ -471,8 +468,7 @@ suite('server_gettile', function() {
},{}, function(res){
assert.equal(res.statusCode, 200, res.statusCode + ': ' + res.body);
assert.equal(res.headers['content-type'], "image/png");
assert.imageEqualsFile(res.body, './test/fixtures/test_default_mapnik_point.png', 2,
function(err, similarity) {
assert.imageEqualsFile(res.body, './test/fixtures/test_default_mapnik_point.png', IMAGE_EQUALS_TOLERANCE_PER_MIL, function(err) {
if (err) throw err;
done();
});
Expand Down Expand Up @@ -545,8 +541,7 @@ suite('server_gettile', function() {
status: 200,
headers: { 'Content-Type': 'image/png' }
}, function(res){
assert.imageEqualsFile(res.body, './test/fixtures/test_table_13_4011_3088_styled.png', 2,
function(err, similarity) {
assert.imageEqualsFile(res.body, './test/fixtures/test_table_13_4011_3088_styled.png', IMAGE_EQUALS_TOLERANCE_PER_MIL, function(err) {
err = err ? null : new Error("Tile starts with unexpected style!");
next(err);
});
Expand Down Expand Up @@ -583,8 +578,7 @@ suite('server_gettile', function() {
status: 200,
headers: { 'Content-Type': 'image/png' }
}, function(res){
assert.imageEqualsFile(res.body, './test/fixtures/test_table_13_4011_3088_styled.png', 2,
function(err, similarity) {
assert.imageEqualsFile(res.body, './test/fixtures/test_table_13_4011_3088_styled.png', IMAGE_EQUALS_TOLERANCE_PER_MIL, function(err) {
if (err) { next(err); return; }
next(null);
});
Expand Down Expand Up @@ -614,8 +608,7 @@ suite('server_gettile', function() {
status: 200,
headers: { 'Content-Type': 'image/png' }
}, function(res){
assert.imageEqualsFile(res.body, './test/fixtures/test_table_13_4011_3088_svg1.png', 2,
function(err, similarity) {
assert.imageEqualsFile(res.body, './test/fixtures/test_table_13_4011_3088_svg1.png', IMAGE_EQUALS_TOLERANCE_PER_MIL, function(err) {
next(err);
});
});
Expand Down Expand Up @@ -650,8 +643,7 @@ suite('server_gettile', function() {
},{}, function(res){
assert.equal(res.statusCode, 200, res.statusCode + ': ' + res.body);
assert.equal(res.headers['content-type'], "image/png");
assert.imageEqualsFile(res.body, './test/fixtures/test_table_13_4011_3088_svg2.png', 2,
function(err, similarity) {
assert.imageEqualsFile(res.body, './test/fixtures/test_table_13_4011_3088_svg2.png', IMAGE_EQUALS_TOLERANCE_PER_MIL, function(err) {
if (err) { next(err); return; }
next(null);
});
Expand All @@ -668,8 +660,7 @@ suite('server_gettile', function() {
},{ }, function(res){
assert.equal(res.statusCode, 200, res.statusCode + ': ' + res.body);
assert.equal(res.headers['content-type'], "image/png");
assert.imageEqualsFile(res.body, './test/fixtures/test_table_13_4011_3088_svg1.png', 2,
function(err, similarity) {
assert.imageEqualsFile(res.body, './test/fixtures/test_table_13_4011_3088_svg1.png', IMAGE_EQUALS_TOLERANCE_PER_MIL, function(err) {
next(err);
});
});
Expand All @@ -685,8 +676,7 @@ suite('server_gettile', function() {
},{ }, function(res){
assert.equal(res.statusCode, 200, res.statusCode + ': ' + res.body);
assert.equal(res.headers['content-type'], "image/png");
assert.imageEqualsFile(res.body, './test/fixtures/test_table_13_4011_3088_svg2.png', 2,
function(err, similarity) {
assert.imageEqualsFile(res.body, './test/fixtures/test_table_13_4011_3088_svg2.png', IMAGE_EQUALS_TOLERANCE_PER_MIL, function(err) {
if (err) { next(err); return; }
next(null);
});
Expand Down Expand Up @@ -718,8 +708,7 @@ suite('server_gettile', function() {
headers: { 'Content-Type': 'image/png' }
}, function(res){
numrequests = res_serv_status.numrequests;
assert.imageEqualsFile(res.body, './test/fixtures/test_table_13_4011_3088_svg2.png', 2,
function(err, similarity) {
assert.imageEqualsFile(res.body, './test/fixtures/test_table_13_4011_3088_svg2.png', IMAGE_EQUALS_TOLERANCE_PER_MIL, function(err) {
next(err);
});
});
Expand All @@ -745,8 +734,7 @@ suite('server_gettile', function() {
assert.equal(res.statusCode, 200, res.statusCode + ': ' + res.body);
assert.equal(res_serv_status.numrequests, numrequests+1);
assert.equal(res.headers['content-type'], "image/png");
assert.imageEqualsFile(res.body, './test/fixtures/test_table_13_4011_3088_svg2.png', 2,
function(err, similarity) {
assert.imageEqualsFile(res.body, './test/fixtures/test_table_13_4011_3088_svg2.png', IMAGE_EQUALS_TOLERANCE_PER_MIL, function(err) {
next(err);
});
});
Expand All @@ -765,8 +753,7 @@ suite('server_gettile', function() {
// millstone should not make another request
assert.equal(res_serv_status.numrequests, numrequests+1);
assert.equal(res.headers['content-type'], "image/png");
assert.imageEqualsFile(res.body, './test/fixtures/test_table_13_4011_3088_svg2.png', 2,
function(err, similarity) {
assert.imageEqualsFile(res.body, './test/fixtures/test_table_13_4011_3088_svg2.png', IMAGE_EQUALS_TOLERANCE_PER_MIL, function(err) {
next(err);
});
});
Expand Down

0 comments on commit afd8158

Please sign in to comment.