From db946b93ec6c8b8c9026f66cdc786cbe7050bb0a Mon Sep 17 00:00:00 2001 From: Raul Marin Date: Wed, 6 Jun 2018 13:18:24 +0200 Subject: [PATCH] Test: Use cartodb-psql to reset connections instead of calling node-postgres directly - Avoids an issue with newer npm not finding node-postgres during the tests as it was required directly but not declared in package.json. - Avoids an issue with the torque timeouts tests --- test/support/test-client.js | 6 +++--- test/support/test_helper.js | 9 +-------- 2 files changed, 4 insertions(+), 11 deletions(-) diff --git a/test/support/test-client.js b/test/support/test-client.js index 2a5840f5..db014c9a 100644 --- a/test/support/test-client.js +++ b/test/support/test-client.js @@ -1268,9 +1268,6 @@ TestClient.prototype.setUserDatabaseTimeoutLimit = function (timeoutLimit, callb const dbuser = _.template(global.environment.postgres_auth_user, { user_id: 1 }); const publicuser = global.environment.postgres.user; - // we need to guarantee all new connections have the new settings - helper.cleanPGPoolConnections(); - const psql = new PSQL({ user: 'postgres', dbname: dbname, @@ -1278,6 +1275,9 @@ TestClient.prototype.setUserDatabaseTimeoutLimit = function (timeoutLimit, callb port: global.environment.postgres.port }); + // we need to guarantee all new connections have the new settings + psql.end(); + step( function configureTimeouts () { const timeoutSQLs = [ diff --git a/test/support/test_helper.js b/test/support/test_helper.js index 48c764a4..65569d78 100644 --- a/test/support/test_helper.js +++ b/test/support/test_helper.js @@ -13,7 +13,6 @@ var lzmaWorker = new LZMA(); var redis = require('redis'); var log4js = require('log4js'); -var pg = require('pg'); const setICUEnvVariable = require('../../lib/cartodb/utils/icu_data_env_setter'); // set environment specific variables @@ -148,11 +147,6 @@ afterEach(function(done) { }); }); -function cleanPGPoolConnections () { - // TODO: this method will be replaced by psql.end - pg.end(); -} - function deleteRedisKeys(keysToDelete, callback) { if (Object.keys(keysToDelete).length === 0) { @@ -215,6 +209,5 @@ module.exports = { checkSurrogateKey: checkSurrogateKey, checkCache: checkCache, rmdirRecursiveSync: rmdirRecursiveSync, - configureMetadata, - cleanPGPoolConnections + configureMetadata };