Remove query tables api dependency from health check

This commit is contained in:
Raul Ochoa 2015-01-13 12:09:02 +01:00
parent aad2a1e098
commit 3f1aa9955b
4 changed files with 53 additions and 59 deletions

View File

@ -666,7 +666,7 @@ var CartodbWindshaft = function(serverOptions) {
// ---- Template maps interface ends @} // ---- 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) { ws.get('/health', function(req, res) {
var healthConfig = global.environment.health || {}; var healthConfig = global.environment.health || {};

View File

@ -4,9 +4,8 @@ var _ = require('underscore'),
path = require('path'), path = require('path'),
Step = require('step'); Step = require('step');
function HealthCheck(metadataBackend, queryTablesApi, tilelive) { function HealthCheck(metadataBackend, tilelive) {
this.metadataBackend = metadataBackend; this.metadataBackend = metadataBackend;
this.queryTablesApi = queryTablesApi;
this.tilelive = tilelive; this.tilelive = tilelive;
} }

View File

@ -71,8 +71,7 @@ module.exports = function(redisPool) {
varnish_secret: global.environment.varnish.secret, varnish_secret: global.environment.varnish.secret,
cache_enabled: global.environment.cache_enabled, cache_enabled: global.environment.cache_enabled,
log_format: global.environment.log_format, log_format: global.environment.log_format,
useProfiler: global.environment.useProfiler, useProfiler: global.environment.useProfiler
queryTablesApi: queryTablesApi
}; };
// Do not send unwatch on release // Do not send unwatch on release

View File

@ -5,72 +5,68 @@ var CartodbWindshaft = require(__dirname + '/../../lib/cartodb/cartodb_windshaft
var serverOptions = require(__dirname + '/../../lib/cartodb/server_options')(); var serverOptions = require(__dirname + '/../../lib/cartodb/server_options')();
var server = new CartodbWindshaft(serverOptions); var server = new CartodbWindshaft(serverOptions);
var SQLAPIEmu = require(__dirname + '/../support/SQLAPIEmu.js'); suite('health checks', function () {
beforeEach(function (done) {
global.environment.health = {
suite('health checks', function () { enabled: true,
beforeEach(function (done) { username: 'localhost',
global.environment.health = { z: 0,
enabled: true, x: 0,
username: 'localhost', y: 0
z: 0,
x: 0,
y: 0
};
done();
});
var healthCheckRequest = {
url: '/health',
method: 'GET',
headers: {
host: 'localhost'
}
}; };
done();
});
test('returns 200 and ok=true with enabled configuration', function (done) { var healthCheckRequest = {
assert.response(server, url: '/health',
healthCheckRequest, method: 'GET',
{ headers: {
status: 200 host: 'localhost'
}, }
function (res, err) { };
console.log(res.body);
assert.ok(!err);
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); var parsed = JSON.parse(res.body);
assert.ok(parsed.ok);
done(); assert.ok(parsed.enabled);
} assert.ok(parsed.ok);
);
});
test('fails for invalid user because it is not in redis', function (done) { done();
global.environment.health.username = 'invalid'; }
);
});
assert.response(server, test('fails for invalid user because it is not in redis', function (done) {
healthCheckRequest, global.environment.health.username = 'invalid';
{
status: 503
},
function (res, err) {
assert.ok(!err);
var parsed = JSON.parse(res.body); assert.response(server,
healthCheckRequest,
{
status: 503
},
function (res, err) {
assert.ok(!err);
assert.equal(parsed.enabled, true); var parsed = JSON.parse(res.body);
assert.equal(parsed.ok, false);
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();
}
);
});
}); });