diff --git a/config/environments/development.js.example b/config/environments/development.js.example index 9627c905..73c3fd6a 100644 --- a/config/environments/development.js.example +++ b/config/environments/development.js.example @@ -154,9 +154,6 @@ var config = { ,health: { enabled: false, username: 'localhost', - query: "SELECT 1::int as interactivity_id, '0101000020110F0000EE866678CE876D41466F35C2EC1150C1'::geometry as geom, 'Lorem ipsum dolor sit amet' as label", - srid: 3857, - geometry_field: 'geom', z: 0, x: 0, y: 0 diff --git a/config/environments/production.js.example b/config/environments/production.js.example index 2fc6b0bd..7e472c8f 100644 --- a/config/environments/production.js.example +++ b/config/environments/production.js.example @@ -163,9 +163,6 @@ var config = { ,health: { enabled: true, username: 'localhost', - query: "SELECT 1::int as interactivity_id, '0101000020110F0000EE866678CE876D41466F35C2EC1150C1'::geometry as geom, 'Lorem ipsum dolor sit amet' as label", - srid: 3857, - geometry_field: 'geom', z: 0, x: 0, y: 0 diff --git a/config/environments/staging.js.example b/config/environments/staging.js.example index dd2a5bb3..e1e04717 100644 --- a/config/environments/staging.js.example +++ b/config/environments/staging.js.example @@ -163,9 +163,6 @@ var config = { ,health: { enabled: false, username: 'localhost', - query: "SELECT 1::int as interactivity_id, '0101000020110F0000EE866678CE876D41466F35C2EC1150C1'::geometry as geom, 'Lorem ipsum dolor sit amet' as label", - srid: 3857, - geometry_field: 'geom', z: 0, x: 0, y: 0 diff --git a/config/environments/test.js.example b/config/environments/test.js.example index 1af3c978..d38e0e6e 100644 --- a/config/environments/test.js.example +++ b/config/environments/test.js.example @@ -150,9 +150,6 @@ var config = { ,health: { enabled: false, username: 'localhost', - query: "SELECT 1::int as interactivity_id, '0101000020110F0000EE866678CE876D41466F35C2EC1150C1'::geometry as geom, 'Lorem ipsum dolor sit amet' as label", - srid: 3857, - geometry_field: 'geom', z: 0, x: 0, y: 0 diff --git a/lib/cartodb/monitoring/health_check.js b/lib/cartodb/monitoring/health_check.js index 3845122c..069a5e81 100644 --- a/lib/cartodb/monitoring/health_check.js +++ b/lib/cartodb/monitoring/health_check.js @@ -34,67 +34,29 @@ HealthCheck.prototype.check = function(config, callback) { redis: { ok: false }, - postgresql: { - ok: false - }, mapnik: { ok: false }, tile: { ok: false } - }, - mapnikXmlParams = _.extend({ - dbport: global.environment.postgres.port - }, config); + }; + mapnikXmlParams = config; Step( function getDBParams() { startTime = Date.now(); self.metadataBackend.getAllUserDBParams(config.username, this); }, - function runQuery(err, dbParams) { + function loadMapnik(err, dbParams) { if (err) { throw err; } - result.redis = { ok: !err, elapsed: Date.now() - startTime, size: Object.keys(dbParams).length }; - - dbParams.dbuser = _.template(global.environment.postgres_auth_user, {user_id: dbParams.dbuser}); - - mapnikXmlParams = _.extend(mapnikXmlParams, dbParams); - - startTime = Date.now(); - self.queryTablesApi.getAffectedTablesInQuery(config.username, { - user: dbParams.dbuser, - pass: dbParams.dbpass, - host: dbParams.dbhost, - port: global.environment.postgres.port, - dbname: dbParams.dbname, - api_key: dbParams.apikey - }, config.query, this); - }, - function handleAffectedTablesQuery(err, affectedTables) { - if (err) { - throw err; - } - - result.postgresql = { - ok: !err, - elapsed: Date.now() - startTime, - size: affectedTables.length - }; - - this(); - }, - function loadMapnik(err) { - if (err) { - throw err; - } mapnikOptions.xml = xmlTemplate(mapnikXmlParams); startTime = Date.now(); @@ -126,4 +88,4 @@ HealthCheck.prototype.check = function(config, callback) { callback(err, result); } ); -}; \ No newline at end of file +}; diff --git a/lib/cartodb/monitoring/map-config.xml b/lib/cartodb/monitoring/map-config.xml index e81cb17a..91a271e1 100644 --- a/lib/cartodb/monitoring/map-config.xml +++ b/lib/cartodb/monitoring/map-config.xml @@ -1,45 +1,4 @@ - - - - - - png8:m=h - layer0 - interactivity_id - - - - - - - layer0 - layer0-labels - - - - - - - - - - - - - - - - - - - + diff --git a/test/acceptance/health_check.js b/test/acceptance/health_check.js index b5cc44e6..7044f504 100644 --- a/test/acceptance/health_check.js +++ b/test/acceptance/health_check.js @@ -8,19 +8,12 @@ var server = new CartodbWindshaft(serverOptions); var SQLAPIEmu = require(__dirname + '/../support/SQLAPIEmu.js'); -[true, false].forEach(function(cdbQueryTablesFromPostgresEnabledValue) { - - global.environment.enabledFeatures = {cdbQueryTablesFromPostgres: cdbQueryTablesFromPostgresEnabledValue}; - - suite('health checks - postgres=' + cdbQueryTablesFromPostgresEnabledValue, function () { + suite('health checks', function () { beforeEach(function (done) { global.environment.health = { enabled: true, username: 'localhost', - query: "SELECT 1::int as interactivity_id, '0101000020110F0000EE866678CE876D41466F35C2EC1150C1'::geometry as geom, 'Lorem ipsum dolor sit amet' as label", - srid: 3857, - geometry_field: 'geom', z: 0, x: 0, y: 0 @@ -28,18 +21,6 @@ var SQLAPIEmu = require(__dirname + '/../support/SQLAPIEmu.js'); done(); }); - if (!cdbQueryTablesFromPostgresEnabledValue) { - var sqlApiServer; - - before(function (done) { - sqlApiServer = new SQLAPIEmu(global.environment.sqlapi.port, done); - }); - - after(function (done) { - sqlApiServer.close(done); - }); - } - var healthCheckRequest = { url: '/health', method: 'GET', @@ -48,27 +29,6 @@ var SQLAPIEmu = require(__dirname + '/../support/SQLAPIEmu.js'); } }; - test('returns 200 and ok=true with disabled configuration', function (done) { - global.environment.health.enabled = false; - - assert.response(server, - healthCheckRequest, - { - status: 200 - }, - function (res, err) { - assert.ok(!err); - - var parsed = JSON.parse(res.body); - - assert.equal(parsed.enabled, false); - assert.ok(parsed.ok); - - done(); - } - ); - }); - test('returns 200 and ok=true with enabled configuration', function (done) { assert.response(server, healthCheckRequest, @@ -76,6 +36,7 @@ var SQLAPIEmu = require(__dirname + '/../support/SQLAPIEmu.js'); status: 200 }, function (res, err) { + console.log(res.body); assert.ok(!err); var parsed = JSON.parse(res.body); @@ -111,31 +72,5 @@ var SQLAPIEmu = require(__dirname + '/../support/SQLAPIEmu.js'); ); }); - test.skip('fails for wrong query', function (done) { - global.environment.health.query = 'select wadus query'; - 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.ok(parsed.result.redis.ok); - - assert.equal(parsed.result.postgresql.ok, false); - - done(); - } - ); - }); - - }); - -}); \ No newline at end of file +});