mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-09-17 14:21:29 +00:00
better retry strategy for query service e2e (#5626)
* better retry API startegy * better retry API startegy
This commit is contained in:
@@ -71,7 +71,6 @@ describe('Form Field Component - Dropdown Widget', () => {
|
|||||||
runningProcessInstance = await processInstancesService.createProcessInstance(processDefinition.entry.key, simpleApp);
|
runningProcessInstance = await processInstancesService.createProcessInstance(processDefinition.entry.key, simpleApp);
|
||||||
queryService = new QueryService(apiService);
|
queryService = new QueryService(apiService);
|
||||||
|
|
||||||
await browser.sleep(4000); // eventual consistency query
|
|
||||||
tasklist = await queryService.getProcessInstanceTasks(runningProcessInstance.entry.id, simpleApp);
|
tasklist = await queryService.getProcessInstanceTasks(runningProcessInstance.entry.id, simpleApp);
|
||||||
task = await tasklist.list.entries[0];
|
task = await tasklist.list.entries[0];
|
||||||
tasksService = new TasksService(apiService);
|
tasksService = new TasksService(apiService);
|
||||||
|
@@ -93,7 +93,6 @@ describe('Process list cloud', () => {
|
|||||||
});
|
});
|
||||||
queryService = new QueryService(apiService);
|
queryService = new QueryService(apiService);
|
||||||
|
|
||||||
await browser.sleep(4000); // eventual consistency query
|
|
||||||
const task = await queryService.getProcessInstanceTasks(completedProcess.entry.id, candidateBaseApp);
|
const task = await queryService.getProcessInstanceTasks(completedProcess.entry.id, candidateBaseApp);
|
||||||
tasksService = new TasksService(apiService);
|
tasksService = new TasksService(apiService);
|
||||||
const claimedTask = await tasksService.claimTask(task.list.entries[0].entry.id, candidateBaseApp);
|
const claimedTask = await tasksService.claimTask(task.list.entries[0].entry.id, candidateBaseApp);
|
||||||
|
@@ -123,7 +123,6 @@ describe('Process filters cloud', () => {
|
|||||||
});
|
});
|
||||||
queryService = new QueryService(apiService);
|
queryService = new QueryService(apiService);
|
||||||
|
|
||||||
await browser.sleep(4000); // eventual consistency query
|
|
||||||
const task = await queryService.getProcessInstanceTasks(completedProcess.entry.id, candidateBaseApp);
|
const task = await queryService.getProcessInstanceTasks(completedProcess.entry.id, candidateBaseApp);
|
||||||
tasksService = new TasksService(apiService);
|
tasksService = new TasksService(apiService);
|
||||||
const claimedTask = await tasksService.claimTask(task.list.entries[0].entry.id, candidateBaseApp);
|
const claimedTask = await tasksService.claimTask(task.list.entries[0].entry.id, candidateBaseApp);
|
||||||
|
@@ -83,7 +83,6 @@ describe('Process filters cloud', () => {
|
|||||||
});
|
});
|
||||||
queryService = new QueryService(apiService);
|
queryService = new QueryService(apiService);
|
||||||
|
|
||||||
await browser.sleep(4000); // eventual consistency query
|
|
||||||
const task = await queryService.getProcessInstanceTasks(completedProcess.entry.id, candidateBaseApp);
|
const task = await queryService.getProcessInstanceTasks(completedProcess.entry.id, candidateBaseApp);
|
||||||
tasksService = new TasksService(apiService);
|
tasksService = new TasksService(apiService);
|
||||||
const claimedTask = await tasksService.claimTask(task.list.entries[0].entry.id, candidateBaseApp);
|
const claimedTask = await tasksService.claimTask(task.list.entries[0].entry.id, candidateBaseApp);
|
||||||
|
@@ -92,7 +92,6 @@ describe('Task filters cloud', () => {
|
|||||||
|
|
||||||
queryService = new QueryService(apiService);
|
queryService = new QueryService(apiService);
|
||||||
|
|
||||||
await browser.sleep(4000); // eventual consistency query
|
|
||||||
await queryService.getProcessInstanceTasks(secondProcessInstance.entry.id, simpleApp);
|
await queryService.getProcessInstanceTasks(secondProcessInstance.entry.id, simpleApp);
|
||||||
await processInstancesService.suspendProcessInstance(processInstance.entry.id, simpleApp);
|
await processInstancesService.suspendProcessInstance(processInstance.entry.id, simpleApp);
|
||||||
await processInstancesService.deleteProcessInstance(secondProcessInstance.entry.id, simpleApp);
|
await processInstancesService.deleteProcessInstance(secondProcessInstance.entry.id, simpleApp);
|
||||||
|
@@ -4,3 +4,4 @@
|
|||||||
"C311290": "https://issues.alfresco.com/jira/browse/ADF-5118",
|
"C311290": "https://issues.alfresco.com/jira/browse/ADF-5118",
|
||||||
"C317658": "https://issues.alfresco.com/jira/browse/ADF-5118"
|
"C317658": "https://issues.alfresco.com/jira/browse/ADF-5118"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -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
|
|
||||||
};
|
|
@@ -17,6 +17,7 @@
|
|||||||
|
|
||||||
import { ApiService } from '../api.service';
|
import { ApiService } from '../api.service';
|
||||||
import { Logger } from '../../utils/logger';
|
import { Logger } from '../../utils/logger';
|
||||||
|
import { ApiUtil } from '../../structure/api.util';
|
||||||
|
|
||||||
export class QueryService {
|
export class QueryService {
|
||||||
|
|
||||||
@@ -27,6 +28,11 @@ export class QueryService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async getProcessInstanceTasks(processInstanceId, appName): Promise<any> {
|
async getProcessInstanceTasks(processInstanceId, appName): Promise<any> {
|
||||||
|
const predicate = (result: any) => {
|
||||||
|
return result.list && result.list.entries.length > 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
const apiCall = async () => {
|
||||||
try {
|
try {
|
||||||
const path = '/' + appName + '/query/v1/process-instances/' + processInstanceId + '/tasks';
|
const path = '/' + appName + '/query/v1/process-instances/' + processInstanceId + '/tasks';
|
||||||
const method = 'GET';
|
const method = 'GET';
|
||||||
@@ -35,11 +41,19 @@ export class QueryService {
|
|||||||
|
|
||||||
return this.api.performBpmOperation(path, method, queryParams, postBody);
|
return this.api.performBpmOperation(path, method, queryParams, postBody);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
Logger.error('get process-instances Service error');
|
Logger.error('get process-instances tasks Service error');
|
||||||
}
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
return ApiUtil.waitForApi(apiCall, predicate);
|
||||||
}
|
}
|
||||||
|
|
||||||
async getProcessInstance(processInstanceId, appName): Promise<any> {
|
async getProcessInstance(processInstanceId, appName): Promise<any> {
|
||||||
|
const predicate = (result: any) => {
|
||||||
|
return !!result;
|
||||||
|
};
|
||||||
|
|
||||||
|
const apiCall = async () => {
|
||||||
try {
|
try {
|
||||||
const path = '/' + appName + '/query/v1/process-instances/' + processInstanceId;
|
const path = '/' + appName + '/query/v1/process-instances/' + processInstanceId;
|
||||||
const method = 'GET';
|
const method = 'GET';
|
||||||
@@ -48,24 +62,40 @@ export class QueryService {
|
|||||||
|
|
||||||
return this.api.performBpmOperation(path, method, queryParams, postBody);
|
return this.api.performBpmOperation(path, method, queryParams, postBody);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
Logger.error('get process-instance Service error');
|
Logger.error('get process-instances Service error');
|
||||||
}
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
return ApiUtil.waitForApi(apiCall, predicate);
|
||||||
}
|
}
|
||||||
|
|
||||||
async getProcessInstanceSubProcesses(processInstanceId, appName): Promise<any> {
|
async getProcessInstanceSubProcesses(processInstanceId, appName): Promise<any> {
|
||||||
|
const predicate = (result: any) => {
|
||||||
|
return result.list && result.list.entries.length > 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
const apiCall = async () => {
|
||||||
try {
|
try {
|
||||||
const path = '/' + appName + '/query/v1/process-instances/' + processInstanceId + '/subprocesses';
|
const path = '/' + appName + '/query/v1/process-instances/' + processInstanceId + '/subprocesses';
|
||||||
const method = 'GET';
|
const method = 'GET';
|
||||||
|
|
||||||
const queryParams = {};
|
const queryParams = {}, postBody = {};
|
||||||
|
|
||||||
return this.api.performBpmOperation(path, method, queryParams, {});
|
return this.api.performBpmOperation(path, method, queryParams, postBody);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
Logger.error('get subprocesses process-instances Service error');
|
Logger.error('get subprocesses process-instances Service error');
|
||||||
}
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
return ApiUtil.waitForApi(apiCall, predicate);
|
||||||
}
|
}
|
||||||
|
|
||||||
async getTaskByName(taskName, processInstanceId, appName): Promise<any> {
|
async getTaskByName(taskName, processInstanceId, appName): Promise<any> {
|
||||||
|
const predicate = (result: any) => {
|
||||||
|
return !!result;
|
||||||
|
};
|
||||||
|
|
||||||
|
const apiCall = async () => {
|
||||||
try {
|
try {
|
||||||
const path = '/' + appName + '/query/v1/process-instances/' + processInstanceId + '/tasks';
|
const path = '/' + appName + '/query/v1/process-instances/' + processInstanceId + '/tasks';
|
||||||
const method = 'GET';
|
const method = 'GET';
|
||||||
@@ -78,12 +108,21 @@ export class QueryService {
|
|||||||
return data.list.entries[i];
|
return data.list.entries[i];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
Logger.error('Get Task By Name - Service error');
|
Logger.error('Get Task By Name - Service error');
|
||||||
}
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
return ApiUtil.waitForApi(apiCall, predicate);
|
||||||
}
|
}
|
||||||
|
|
||||||
async getProcessInstanceId(processName: string, appName: string): Promise<any> {
|
async getProcessInstanceId(processName: string, appName: string): Promise<any> {
|
||||||
|
const predicate = (result: any) => {
|
||||||
|
return !!result;
|
||||||
|
};
|
||||||
|
|
||||||
|
const apiCall = async () => {
|
||||||
try {
|
try {
|
||||||
const path = '/' + appName + '/query/v1/process-instances';
|
const path = '/' + appName + '/query/v1/process-instances';
|
||||||
const method = 'GET';
|
const method = 'GET';
|
||||||
@@ -95,6 +134,8 @@ export class QueryService {
|
|||||||
} catch (error) {
|
} catch (error) {
|
||||||
Logger.error('Get Process Instance Id - Service error, Response: ', JSON.parse(JSON.stringify(error)).response.text);
|
Logger.error('Get Process Instance Id - Service error, Response: ', JSON.parse(JSON.stringify(error)).response.text);
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
|
||||||
|
return ApiUtil.waitForApi(apiCall, predicate);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -12,7 +12,6 @@ require('ts-node').register({
|
|||||||
});
|
});
|
||||||
const ACTIVITI_CLOUD_APPS = require('./lib/testing').ACTIVITI_CLOUD_APPS;
|
const ACTIVITI_CLOUD_APPS = require('./lib/testing').ACTIVITI_CLOUD_APPS;
|
||||||
|
|
||||||
const { beforeAllRewrite, afterAllRewrite, beforeEachAllRewrite, afterEachAllRewrite } = require('./e2e/protractor/override-jasmine');
|
|
||||||
const { uploadScreenshot, cleanReportFolder } = require('./e2e/protractor/save-remote');
|
const { uploadScreenshot, cleanReportFolder } = require('./e2e/protractor/save-remote');
|
||||||
const argv = require('yargs').argv;
|
const argv = require('yargs').argv;
|
||||||
|
|
||||||
@@ -160,11 +159,6 @@ exports.config = {
|
|||||||
},
|
},
|
||||||
|
|
||||||
onPrepare() {
|
onPrepare() {
|
||||||
afterEachAllRewrite();
|
|
||||||
beforeEachAllRewrite();
|
|
||||||
afterAllRewrite();
|
|
||||||
beforeAllRewrite();
|
|
||||||
|
|
||||||
retry.onPrepare();
|
retry.onPrepare();
|
||||||
|
|
||||||
jasmine.DEFAULT_TIMEOUT_INTERVAL = TIMEOUT;
|
jasmine.DEFAULT_TIMEOUT_INTERVAL = TIMEOUT;
|
||||||
|
Reference in New Issue
Block a user