better retry strategy for query service e2e (#5626)

* better retry API startegy

* better retry API startegy
This commit is contained in:
Eugenio Romano
2020-04-21 12:56:14 +01:00
committed by GitHub
parent 6462bbf35a
commit 53b01ae594
9 changed files with 87 additions and 162 deletions

View File

@@ -1,106 +0,0 @@
function beforeAllRewrite() {
const originalBeforeAll = global.beforeAll;
// tslint:disable-next-line
global.beforeAll = function (beforeAllFunction, timeout) {
const wrapClbk = async (done) => {
try {
await beforeAllFunction(done);
} catch (error) {
console.log('Error Before all second attempt in 10 sec');
sleep(10000);
try {
await beforeAllFunction(done);
} catch (e) {
// tslint:disable-next-line:no-console
console.log('Error Before all second attempt fail all' + JSON.stringify(error));
await expect(true).toBe(false);
}
}
done();
};
originalBeforeAll(wrapClbk, timeout);
};
}
function afterAllRewrite() {
const originalAfterAll = global.afterAll;
// tslint:disable-next-line
global.afterAll = function (afterAllFunction, timeout) {
const wrapClbk = async (done) => {
try {
await afterAllFunction(done);
} catch (error) {
// tslint:disable-next-line:no-console
console.log('Error After all' + JSON.stringify(error));
}
done();
};
originalAfterAll(wrapClbk, timeout);
};
}
function beforeEachAllRewrite() {
const originalBeforeEach = global.beforeEach;
// tslint:disable-next-line
global.beforeEach = function (beforeEachFunction, timeout) {
const wrapClbk = async (done) => {
try {
await beforeEachFunction(done);
} catch (error) {
// tslint:disable-next-line:no-console
console.log('Error before Each' + JSON.stringify(error));
}
done();
};
originalBeforeEach(wrapClbk, timeout);
};
}
function afterEachAllRewrite() {
const originalAfterEach = global.afterEach;
// tslint:disable-next-line
global.afterEach = function (afterEachFunction, timeout) {
const wrapClbk = async (done) => {
try {
await afterEachFunction(done);
} catch (error) {
// tslint:disable-next-line:no-console
console.log('Error After each' + JSON.stringify(error));
}
done();
};
originalAfterEach(wrapClbk, timeout);
};
}
function sleep(delay) {
var start = new Date().getTime();
while (new Date().getTime() < start + delay) ;
}
module.exports = {
beforeAllRewrite: beforeAllRewrite,
afterAllRewrite: afterAllRewrite,
beforeEachAllRewrite: beforeEachAllRewrite,
afterEachAllRewrite: afterEachAllRewrite
};