From 3f1aa9955b34b656af36863f32e95d371b8cf46a Mon Sep 17 00:00:00 2001 From: Raul Ochoa Date: Tue, 13 Jan 2015 12:09:02 +0100 Subject: [PATCH] Remove query tables api dependency from health check --- lib/cartodb/cartodb_windshaft.js | 2 +- lib/cartodb/monitoring/health_check.js | 3 +- lib/cartodb/server_options.js | 3 +- test/acceptance/health_check.js | 104 ++++++++++++------------- 4 files changed, 53 insertions(+), 59 deletions(-) diff --git a/lib/cartodb/cartodb_windshaft.js b/lib/cartodb/cartodb_windshaft.js index c5934428..63dc4081 100644 --- a/lib/cartodb/cartodb_windshaft.js +++ b/lib/cartodb/cartodb_windshaft.js @@ -666,7 +666,7 @@ var CartodbWindshaft = function(serverOptions) { // ---- Template maps interface ends @} - var healthCheck = new HealthCheck(cartoData, serverOptions.queryTablesApi, Windshaft.tilelive); + var healthCheck = new HealthCheck(cartoData, Windshaft.tilelive); ws.get('/health', function(req, res) { var healthConfig = global.environment.health || {}; diff --git a/lib/cartodb/monitoring/health_check.js b/lib/cartodb/monitoring/health_check.js index 069a5e81..873cd19d 100644 --- a/lib/cartodb/monitoring/health_check.js +++ b/lib/cartodb/monitoring/health_check.js @@ -4,9 +4,8 @@ var _ = require('underscore'), path = require('path'), Step = require('step'); -function HealthCheck(metadataBackend, queryTablesApi, tilelive) { +function HealthCheck(metadataBackend, tilelive) { this.metadataBackend = metadataBackend; - this.queryTablesApi = queryTablesApi; this.tilelive = tilelive; } diff --git a/lib/cartodb/server_options.js b/lib/cartodb/server_options.js index d67ccd0e..adea9a3c 100644 --- a/lib/cartodb/server_options.js +++ b/lib/cartodb/server_options.js @@ -71,8 +71,7 @@ module.exports = function(redisPool) { varnish_secret: global.environment.varnish.secret, cache_enabled: global.environment.cache_enabled, log_format: global.environment.log_format, - useProfiler: global.environment.useProfiler, - queryTablesApi: queryTablesApi + useProfiler: global.environment.useProfiler }; // Do not send unwatch on release diff --git a/test/acceptance/health_check.js b/test/acceptance/health_check.js index 7044f504..af8c361e 100644 --- a/test/acceptance/health_check.js +++ b/test/acceptance/health_check.js @@ -5,72 +5,68 @@ var CartodbWindshaft = require(__dirname + '/../../lib/cartodb/cartodb_windshaft var serverOptions = require(__dirname + '/../../lib/cartodb/server_options')(); var server = new CartodbWindshaft(serverOptions); -var SQLAPIEmu = require(__dirname + '/../support/SQLAPIEmu.js'); +suite('health checks', function () { - - - suite('health checks', function () { - beforeEach(function (done) { - global.environment.health = { - enabled: true, - username: 'localhost', - z: 0, - x: 0, - y: 0 - }; - done(); - }); - - var healthCheckRequest = { - url: '/health', - method: 'GET', - headers: { - host: 'localhost' - } + beforeEach(function (done) { + global.environment.health = { + enabled: true, + username: 'localhost', + z: 0, + x: 0, + y: 0 }; + done(); + }); - test('returns 200 and ok=true with enabled configuration', function (done) { - assert.response(server, - healthCheckRequest, - { - status: 200 - }, - function (res, err) { - console.log(res.body); - assert.ok(!err); + var healthCheckRequest = { + url: '/health', + method: 'GET', + headers: { + host: 'localhost' + } + }; - var parsed = JSON.parse(res.body); + test('returns 200 and ok=true with enabled configuration', function (done) { + assert.response(server, + healthCheckRequest, + { + status: 200 + }, + function (res, err) { + console.log(res.body); + assert.ok(!err); - assert.ok(parsed.enabled); - assert.ok(parsed.ok); + var parsed = JSON.parse(res.body); - done(); - } - ); - }); + assert.ok(parsed.enabled); + assert.ok(parsed.ok); - test('fails for invalid user because it is not in redis', function (done) { - global.environment.health.username = 'invalid'; + done(); + } + ); + }); - assert.response(server, - healthCheckRequest, - { - status: 503 - }, - function (res, err) { - assert.ok(!err); + test('fails for invalid user because it is not in redis', function (done) { + global.environment.health.username = 'invalid'; - var parsed = JSON.parse(res.body); + assert.response(server, + healthCheckRequest, + { + status: 503 + }, + function (res, err) { + assert.ok(!err); - assert.equal(parsed.enabled, true); - assert.equal(parsed.ok, false); + var parsed = JSON.parse(res.body); - assert.equal(parsed.result.redis.ok, false); + assert.equal(parsed.enabled, true); + assert.equal(parsed.ok, false); - done(); - } - ); - }); + assert.equal(parsed.result.redis.ok, false); + done(); + } + ); + }); });