|
|
@ -23,11 +23,13 @@ const loginRootUser = async () => { |
|
|
|
const projectTitleByType = { |
|
|
|
const projectTitleByType = { |
|
|
|
sqlite: 'sampleREST', |
|
|
|
sqlite: 'sampleREST', |
|
|
|
mysql: 'externalREST', |
|
|
|
mysql: 'externalREST', |
|
|
|
pg: 'pgExtREST', |
|
|
|
pg: 'pgExtREST' |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
export class TestResetService { |
|
|
|
export class TestResetService { |
|
|
|
private readonly parallelId; |
|
|
|
private readonly parallelId; |
|
|
|
|
|
|
|
// todo: Hack to resolve issue with pg resetting
|
|
|
|
|
|
|
|
private readonly workerId; |
|
|
|
private readonly dbType; |
|
|
|
private readonly dbType; |
|
|
|
private readonly isEmptyProject: boolean; |
|
|
|
private readonly isEmptyProject: boolean; |
|
|
|
|
|
|
|
|
|
|
@ -35,14 +37,17 @@ export class TestResetService { |
|
|
|
parallelId, |
|
|
|
parallelId, |
|
|
|
dbType, |
|
|
|
dbType, |
|
|
|
isEmptyProject, |
|
|
|
isEmptyProject, |
|
|
|
|
|
|
|
workerId |
|
|
|
}: { |
|
|
|
}: { |
|
|
|
parallelId: string; |
|
|
|
parallelId: string; |
|
|
|
dbType: string; |
|
|
|
dbType: string; |
|
|
|
isEmptyProject: boolean; |
|
|
|
isEmptyProject: boolean; |
|
|
|
|
|
|
|
workerId: string; |
|
|
|
}) { |
|
|
|
}) { |
|
|
|
this.parallelId = parallelId; |
|
|
|
this.parallelId = parallelId; |
|
|
|
this.dbType = dbType; |
|
|
|
this.dbType = dbType; |
|
|
|
this.isEmptyProject = isEmptyProject; |
|
|
|
this.isEmptyProject = isEmptyProject; |
|
|
|
|
|
|
|
this.workerId = workerId; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
async process() { |
|
|
|
async process() { |
|
|
@ -68,6 +73,7 @@ export class TestResetService { |
|
|
|
token, |
|
|
|
token, |
|
|
|
dbType: this.dbType, |
|
|
|
dbType: this.dbType, |
|
|
|
parallelId: this.parallelId, |
|
|
|
parallelId: this.parallelId, |
|
|
|
|
|
|
|
workerId: this.workerId |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
try { |
|
|
|
try { |
|
|
@ -90,10 +96,12 @@ export class TestResetService { |
|
|
|
token, |
|
|
|
token, |
|
|
|
dbType, |
|
|
|
dbType, |
|
|
|
parallelId, |
|
|
|
parallelId, |
|
|
|
|
|
|
|
workerId |
|
|
|
}: { |
|
|
|
}: { |
|
|
|
token: string; |
|
|
|
token: string; |
|
|
|
dbType: string; |
|
|
|
dbType: string; |
|
|
|
parallelId: string; |
|
|
|
parallelId: string; |
|
|
|
|
|
|
|
workerId: string; |
|
|
|
}) { |
|
|
|
}) { |
|
|
|
const title = `${projectTitleByType[dbType]}${parallelId}`; |
|
|
|
const title = `${projectTitleByType[dbType]}${parallelId}`; |
|
|
|
const project: Project | undefined = await Project.getByTitle(title); |
|
|
|
const project: Project | undefined = await Project.getByTitle(title); |
|
|
@ -115,7 +123,7 @@ export class TestResetService { |
|
|
|
token, |
|
|
|
token, |
|
|
|
title, |
|
|
|
title, |
|
|
|
parallelId, |
|
|
|
parallelId, |
|
|
|
isEmptyProject: this.isEmptyProject, |
|
|
|
isEmptyProject: this.isEmptyProject |
|
|
|
}); |
|
|
|
}); |
|
|
|
} else if (dbType == 'mysql') { |
|
|
|
} else if (dbType == 'mysql') { |
|
|
|
await resetMysqlSakilaProject({ |
|
|
|
await resetMysqlSakilaProject({ |
|
|
@ -123,20 +131,20 @@ export class TestResetService { |
|
|
|
title, |
|
|
|
title, |
|
|
|
parallelId, |
|
|
|
parallelId, |
|
|
|
oldProject: project, |
|
|
|
oldProject: project, |
|
|
|
isEmptyProject: this.isEmptyProject, |
|
|
|
isEmptyProject: this.isEmptyProject |
|
|
|
}); |
|
|
|
}); |
|
|
|
} else if (dbType == 'pg') { |
|
|
|
} else if (dbType == 'pg') { |
|
|
|
await resetPgSakilaProject({ |
|
|
|
await resetPgSakilaProject({ |
|
|
|
token, |
|
|
|
token, |
|
|
|
title, |
|
|
|
title, |
|
|
|
parallelId, |
|
|
|
parallelId: workerId, |
|
|
|
oldProject: project, |
|
|
|
oldProject: project, |
|
|
|
isEmptyProject: this.isEmptyProject, |
|
|
|
isEmptyProject: this.isEmptyProject |
|
|
|
}); |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return { |
|
|
|
return { |
|
|
|
project: await Project.getByTitle(title), |
|
|
|
project: await Project.getByTitle(title) |
|
|
|
}; |
|
|
|
}; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@ -169,7 +177,7 @@ const removeProjectUsersFromCache = async (project: Project) => { |
|
|
|
const projectUsers: ProjectUser[] = await ProjectUser.getUsersList({ |
|
|
|
const projectUsers: ProjectUser[] = await ProjectUser.getUsersList({ |
|
|
|
project_id: project.id, |
|
|
|
project_id: project.id, |
|
|
|
limit: 1000, |
|
|
|
limit: 1000, |
|
|
|
offset: 0, |
|
|
|
offset: 0 |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
for (const projectUser of projectUsers) { |
|
|
|
for (const projectUser of projectUsers) { |
|
|
|