Move setUserDatabaseTimeoutLimit from class method to a instance method

This commit is contained in:
Daniel García Aubert 2017-08-10 17:09:05 +02:00
parent 9524433437
commit 01a22a45bb
2 changed files with 52 additions and 38 deletions

View File

@ -81,11 +81,11 @@ describe('user database timeout limit', function () {
beforeEach(function (done) {
const mapconfig = createMapConfig();
this.testClient = new TestClient(mapconfig, 1234);
TestClient.setUserDatabaseTimeoutLimit(200, done);
this.testClient.setUserDatabaseTimeoutLimit(200, done);
});
afterEach(function (done) {
TestClient.setUserDatabaseTimeoutLimit(0, (err) => {
this.testClient.setUserDatabaseTimeoutLimit(0, (err) => {
if (err) {
return done(err);
}
@ -118,11 +118,11 @@ describe('user database timeout limit', function () {
beforeEach(function (done) {
const mapconfig = createMapConfig({ sql: validationPointSleepSql });
this.testClient = new TestClient(mapconfig, 1234);
TestClient.setUserDatabaseTimeoutLimit(200, done);
this.testClient.setUserDatabaseTimeoutLimit(200, done);
});
afterEach(function (done) {
TestClient.setUserDatabaseTimeoutLimit(0, (err) => {
this.testClient.setUserDatabaseTimeoutLimit(0, (err) => {
if (err) {
return done(err);
}
@ -156,14 +156,6 @@ describe('user database timeout limit', function () {
describe('fetching raster tiles', function () {
describe('with user\'s timeout of 200 ms', function () {
beforeEach(function (done) {
TestClient.setUserDatabaseTimeoutLimit(200, done);
});
afterEach(function (done) {
TestClient.setUserDatabaseTimeoutLimit(0, done);
});
describe('with onTileErrorStrategy ENABLED', function () {
let onTileErrorStrategy;
@ -180,6 +172,11 @@ describe('user database timeout limit', function () {
}
};
this.testClient.setUserDatabaseTimeoutLimit(200, (err) => {
if (err) {
return done(err);
}
this.testClient.getLayergroup(expectedResponse, (err, res) => {
if (err) {
return done(err);
@ -190,12 +187,17 @@ describe('user database timeout limit', function () {
done();
});
});
});
afterEach(function (done) {
global.environment.enabledFeatures.onTileErrorStrategy = onTileErrorStrategy;
this.testClient.setUserDatabaseTimeoutLimit(0, (err) => {
if (err) {
return done(err);
}
this.testClient.drain(done);
});
});
it('"png" fails due to statement timeout', function (done) {
const params = {
@ -252,6 +254,11 @@ describe('user database timeout limit', function () {
}
};
this.testClient.setUserDatabaseTimeoutLimit(200, (err) => {
if (err) {
return done(err);
}
this.testClient.getLayergroup(expectedResponse, (err, res) => {
if (err) {
return done(err);
@ -262,12 +269,19 @@ describe('user database timeout limit', function () {
done();
});
});
});
afterEach(function (done) {
global.environment.enabledFeatures.onTileErrorStrategy = onTileErrorStrategy;
this.testClient.setUserDatabaseTimeoutLimit(0, (err) => {
if (err) {
return done(err);
}
this.testClient.drain(done);
});
});
it('"png" fails due to statement timeout', function (done) {
const params = {
@ -326,11 +340,11 @@ describe('user database timeout limit', function () {
beforeEach(function (done) {
const mapconfig = createMapConfig({ sql: validationPointSleepSql });
this.testClient = new TestClient(mapconfig, 1234);
TestClient.setUserDatabaseTimeoutLimit(200, done);
this.testClient.setUserDatabaseTimeoutLimit(200, done);
});
afterEach(function (done) {
TestClient.setUserDatabaseTimeoutLimit(0, (err) => {
this.testClient.setUserDatabaseTimeoutLimit(0, (err) => {
if (err) {
return done(err);
}
@ -390,11 +404,11 @@ describe('user database timeout limit', function () {
describe('with user\'s timeout of 200 ms', function () {
beforeEach(function (done) {
TestClient.setUserDatabaseTimeoutLimit(200, done);
this.testClient.setUserDatabaseTimeoutLimit(200, done);
});
afterEach(function (done) {
TestClient.setUserDatabaseTimeoutLimit(0, done);
this.testClient.setUserDatabaseTimeoutLimit(0, done);
});
it('"mvt" fails due to statement timeout', function (done) {
@ -428,11 +442,11 @@ describe('user database timeout limit', function () {
beforeEach(function (done) {
const mapconfig = createMapConfig({ sql: validationPointSleepSql, interactivity: 'val' });
this.testClient = new TestClient(mapconfig, 1234);
TestClient.setUserDatabaseTimeoutLimit(200, done);
this.testClient.setUserDatabaseTimeoutLimit(200, done);
});
afterEach(function (done) {
TestClient.setUserDatabaseTimeoutLimit(0, (err) => {
this.testClient.setUserDatabaseTimeoutLimit(0, (err) => {
if (err) {
return done(err);
}
@ -492,11 +506,11 @@ describe('user database timeout limit', function () {
describe('with user\'s timeout of 200 ms', function () {
beforeEach(function (done) {
TestClient.setUserDatabaseTimeoutLimit(200, done);
this.testClient.setUserDatabaseTimeoutLimit(200, done);
});
afterEach(function (done) {
TestClient.setUserDatabaseTimeoutLimit(0, done);
this.testClient.setUserDatabaseTimeoutLimit(0, done);
});
it('"grid.json" fails due to statement timeout', function (done) {
@ -532,11 +546,11 @@ describe('user database timeout limit', function () {
cartocss: TestClient.CARTOCSS.TORQUE
});
this.testClient = new TestClient(mapconfig, 1234);
TestClient.setUserDatabaseTimeoutLimit(200, done);
this.testClient.setUserDatabaseTimeoutLimit(200, done);
});
afterEach(function (done) {
TestClient.setUserDatabaseTimeoutLimit(0, (err) => {
this.testClient.setUserDatabaseTimeoutLimit(0, (err) => {
if (err) {
return done(err);
}
@ -599,11 +613,11 @@ describe('user database timeout limit', function () {
describe('with user\'s timeout of 200 ms', function () {
beforeEach(function (done) {
TestClient.setUserDatabaseTimeoutLimit(200, done);
this.testClient.setUserDatabaseTimeoutLimit(200, done);
});
afterEach(function (done) {
TestClient.setUserDatabaseTimeoutLimit(0, done);
this.testClient.setUserDatabaseTimeoutLimit(0, done);
});
it('"torque.json" fails due to statement timeout', function (done) {
@ -663,11 +677,11 @@ describe('user database timeout limit', function () {
}
});
this.testClient = new TestClient(mapconfig, 1234);
TestClient.setUserDatabaseTimeoutLimit(200, done);
this.testClient.setUserDatabaseTimeoutLimit(200, done);
});
afterEach(function (done) {
TestClient.setUserDatabaseTimeoutLimit(0, (err) => {
this.testClient.setUserDatabaseTimeoutLimit(0, (err) => {
if (err) {
return done(err);
}
@ -738,11 +752,11 @@ describe('user database timeout limit', function () {
describe('with user\'s timeout of 200 ms', function () {
beforeEach(function (done) {
TestClient.setUserDatabaseTimeoutLimit(200, done);
this.testClient.setUserDatabaseTimeoutLimit(200, done);
});
afterEach(function (done) {
TestClient.setUserDatabaseTimeoutLimit(0, done);
this.testClient.setUserDatabaseTimeoutLimit(0, done);
});
it('fails due to statement timeout', function (done) {

View File

@ -1164,7 +1164,7 @@ TestClient.prototype.setUserRenderTimeoutLimit = function (user, userTimeoutLimi
helper.configureMetadata('hmset', params, callback);
};
TestClient.setUserDatabaseTimeoutLimit = function (timeoutLimit, callback) {
TestClient.prototype.setUserDatabaseTimeoutLimit = function (timeoutLimit, callback) {
const dbname = _.template(global.environment.postgres_auth_user, { user_id: 1 }) + '_db';
const dbuser = _.template(global.environment.postgres_auth_user, { user_id: 1 })
const pass = _.template(global.environment.postgres_auth_pass, { user_id: 1 })