diff --git a/lib/cartodb/monitoring/health_check.js b/lib/cartodb/monitoring/health_check.js index f59fbfb1..1fca02b8 100644 --- a/lib/cartodb/monitoring/health_check.js +++ b/lib/cartodb/monitoring/health_check.js @@ -1,6 +1,4 @@ -var dot = require('dot'); var fs = require('fs'); -var path = require('path'); var step = require('step'); function HealthCheck(metadataBackend, tilelive) { @@ -11,24 +9,9 @@ function HealthCheck(metadataBackend, tilelive) { module.exports = HealthCheck; -var mapnikOptions = { - query: { - metatile: 1, - poolSize: 4, - bufferSize: 64 - }, - protocol: 'mapnik:', - slashes: true, - xml: null -}; - -var xmlTemplate = dot.template(fs.readFileSync(path.resolve(__dirname, 'map-config.xml'), 'utf-8')); - HealthCheck.prototype.check = function(config, callback) { - var self = this, - startTime, - result = { + var result = { redis: { ok: false }, @@ -39,7 +22,6 @@ HealthCheck.prototype.check = function(config, callback) { ok: false } }; - var mapnikXmlParams = config; step( function getManualDisable() { @@ -56,50 +38,7 @@ HealthCheck.prototype.check = function(config, callback) { throw err; } }, - function getDBParams(err) { - if (err) { - throw err; - } - startTime = Date.now(); - self.metadataBackend.getAllUserDBParams(config.username, this); - }, - function loadMapnik(err, dbParams) { - if (err) { - throw err; - } - result.redis = { - ok: !err, - elapsed: Date.now() - startTime, - size: Object.keys(dbParams).length - }; - mapnikOptions.xml = xmlTemplate(mapnikXmlParams); - - startTime = Date.now(); - self.tilelive.load(mapnikOptions, this); - }, - function getTile(err, source) { - if (err) { - throw err; - } - - result.mapnik = { - ok: !err, - elapsed: Date.now() - startTime - }; - - startTime = Date.now(); - source.getTile(config.z, config.x, config.y, this); - }, - function handleTile(err, tile) { - result.tile = { - ok: !err - }; - - if (tile) { - result.tile.elapsed = Date.now() - startTime; - result.tile.size = tile.length; - } - + function handleResult(err) { callback(err, result); } ); diff --git a/test/acceptance/health_check.js b/test/acceptance/health_check.js index 890b559e..682deedd 100644 --- a/test/acceptance/health_check.js +++ b/test/acceptance/health_check.js @@ -51,31 +51,6 @@ suite('health checks', function () { ); }); - test('fails for invalid user because it is not in redis', function (done) { - resetHealthConfig(); - - global.environment.health.username = 'invalid'; - - assert.response(server, - healthCheckRequest, - { - status: 503 - }, - function (res, err) { - assert.ok(!err); - - var parsed = JSON.parse(res.body); - - assert.equal(parsed.enabled, true); - assert.equal(parsed.ok, false); - - assert.equal(parsed.result.redis.ok, false); - - done(); - } - ); - }); - test('error if disabled file exists', function(done) { var fs = require('fs');