ci: Fix CI timeout issues (no-changelog) (#5250)
This commit is contained in:
committed by
GitHub
parent
54333398ce
commit
c8a146ba31
@@ -18,7 +18,11 @@ let credentialOwnerRole: Role;
|
||||
let saveCredential: SaveCredentialFunction;
|
||||
|
||||
beforeAll(async () => {
|
||||
app = await utils.initTestServer({ endpointGroups: ['publicApi'], applyAuth: false });
|
||||
app = await utils.initTestServer({
|
||||
endpointGroups: ['publicApi'],
|
||||
applyAuth: false,
|
||||
enablePublicAPI: true,
|
||||
});
|
||||
await testDb.init();
|
||||
|
||||
utils.initConfigFile();
|
||||
|
||||
@@ -13,7 +13,11 @@ let globalOwnerRole: Role;
|
||||
let workflowRunner: ActiveWorkflowRunner;
|
||||
|
||||
beforeAll(async () => {
|
||||
app = await utils.initTestServer({ endpointGroups: ['publicApi'], applyAuth: false });
|
||||
app = await utils.initTestServer({
|
||||
endpointGroups: ['publicApi'],
|
||||
applyAuth: false,
|
||||
enablePublicAPI: true,
|
||||
});
|
||||
await testDb.init();
|
||||
|
||||
globalOwnerRole = await testDb.getGlobalOwnerRole();
|
||||
@@ -43,7 +47,7 @@ beforeEach(async () => {
|
||||
});
|
||||
|
||||
afterEach(async () => {
|
||||
await workflowRunner.removeAll();
|
||||
await workflowRunner?.removeAll();
|
||||
});
|
||||
|
||||
afterAll(async () => {
|
||||
|
||||
@@ -17,7 +17,11 @@ let workflowOwnerRole: Role;
|
||||
let workflowRunner: ActiveWorkflowRunner;
|
||||
|
||||
beforeAll(async () => {
|
||||
app = await utils.initTestServer({ endpointGroups: ['publicApi'], applyAuth: false });
|
||||
app = await utils.initTestServer({
|
||||
endpointGroups: ['publicApi'],
|
||||
applyAuth: false,
|
||||
enablePublicAPI: true,
|
||||
});
|
||||
await testDb.init();
|
||||
|
||||
const [fetchedGlobalOwnerRole, fetchedGlobalMemberRole, fetchedWorkflowOwnerRole] =
|
||||
@@ -49,7 +53,7 @@ beforeEach(async () => {
|
||||
});
|
||||
|
||||
afterEach(async () => {
|
||||
await workflowRunner.removeAll();
|
||||
await workflowRunner?.removeAll();
|
||||
});
|
||||
|
||||
afterAll(async () => {
|
||||
|
||||
@@ -95,7 +95,8 @@ export async function init() {
|
||||
* Drop test DB, closing bootstrap connection if existing.
|
||||
*/
|
||||
export async function terminate() {
|
||||
await Db.getConnection().destroy();
|
||||
const connection = Db.getConnection();
|
||||
if (connection.isInitialized) await connection.destroy();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -82,16 +82,15 @@ CredentialTypes(loadNodesAndCredentials);
|
||||
|
||||
/**
|
||||
* Initialize a test server.
|
||||
*
|
||||
* @param applyAuth Whether to apply auth middleware to test server.
|
||||
* @param endpointGroups Groups of endpoints to apply to test server.
|
||||
*/
|
||||
export async function initTestServer({
|
||||
applyAuth,
|
||||
endpointGroups,
|
||||
enablePublicAPI = false,
|
||||
}: {
|
||||
applyAuth: boolean;
|
||||
endpointGroups?: EndpointGroup[];
|
||||
enablePublicAPI?: boolean;
|
||||
}) {
|
||||
const testServer = {
|
||||
app: express(),
|
||||
@@ -124,17 +123,20 @@ export async function initTestServer({
|
||||
const [routerEndpoints, functionEndpoints] = classifyEndpointGroups(endpointGroups);
|
||||
|
||||
if (routerEndpoints.length) {
|
||||
const { apiRouters } = await loadPublicApiVersions(testServer.publicApiEndpoint);
|
||||
const map: Record<string, express.Router | express.Router[] | any> = {
|
||||
credentials: { controller: credentialsController, path: 'credentials' },
|
||||
workflows: { controller: workflowsController, path: 'workflows' },
|
||||
nodes: { controller: nodesController, path: 'nodes' },
|
||||
license: { controller: licenseController, path: 'license' },
|
||||
eventBus: { controller: eventBusRouter, path: 'eventbus' },
|
||||
publicApi: apiRouters,
|
||||
ldap: { controller: ldapController, path: 'ldap' },
|
||||
};
|
||||
|
||||
if (enablePublicAPI) {
|
||||
const { apiRouters } = await loadPublicApiVersions(testServer.publicApiEndpoint);
|
||||
map.publicApi = apiRouters;
|
||||
}
|
||||
|
||||
for (const group of routerEndpoints) {
|
||||
if (group === 'publicApi') {
|
||||
testServer.app.use(...(map[group] as express.Router[]));
|
||||
|
||||
Reference in New Issue
Block a user