stubbing inspection api

pull/437/head
Frostebite 2022-10-19 00:06:00 +01:00
parent 11a38deb99
commit ed9c056718
1 changed files with 11 additions and 14 deletions

View File

@ -45,10 +45,8 @@ export class SharedWorkspaceLocking {
return; return;
} }
CloudRunnerLogger.log(`run agent ${runId} is trying to access a workspace`);
if (await SharedWorkspaceLocking.DoesWorkspaceTopLevelExist(buildParametersContext)) {
const workspaces = await SharedWorkspaceLocking.GetFreeWorkspaces(buildParametersContext); const workspaces = await SharedWorkspaceLocking.GetFreeWorkspaces(buildParametersContext);
CloudRunnerLogger.log(`run agent ${runId} is trying to access a workspace, free: ${JSON.stringify(workspaces)}`);
for (const element of workspaces) { for (const element of workspaces) {
const lockResult = await SharedWorkspaceLocking.LockWorkspace(element, runId, buildParametersContext); const lockResult = await SharedWorkspaceLocking.LockWorkspace(element, runId, buildParametersContext);
CloudRunnerLogger.log(`run agent ${runId} try lock workspace: ${element} result: ${lockResult}`); CloudRunnerLogger.log(`run agent ${runId} try lock workspace: ${element} result: ${lockResult}`);
@ -57,7 +55,6 @@ export class SharedWorkspaceLocking {
return true; return true;
} }
} }
}
const createResult = await SharedWorkspaceLocking.CreateWorkspace(workspace, buildParametersContext, runId); const createResult = await SharedWorkspaceLocking.CreateWorkspace(workspace, buildParametersContext, runId);
CloudRunnerLogger.log( CloudRunnerLogger.log(
@ -89,9 +86,9 @@ export class SharedWorkspaceLocking {
const lockMatches = locks.filter((x) => x.name.includes(runId)); const lockMatches = locks.filter((x) => x.name.includes(runId));
const includesRunLock = lockMatches.length > 0 && locks.indexOf(lockMatches[0]) === 0; const includesRunLock = lockMatches.length > 0 && locks.indexOf(lockMatches[0]) === 0;
CloudRunnerLogger.log( CloudRunnerLogger.log(
`Checking has workspace lock, runId: ${runId} workspace: ${workspace} success: ${includesRunLock} \n Num of LockMatches for Run Agent: ${ `Checking has workspace lock, runId: ${runId} workspace: ${workspace} success: ${includesRunLock} \n- Num of LockMatches for Run Agent: ${
lockMatches.length lockMatches.length
} Num of Locks ${locks.length} orderedLockIndex for Run Agent ${locks.indexOf(lockMatches[0])}`, } Num of Locks ${locks.length} orderedLockIndex for Run Agent ${locks.indexOf(lockMatches[0])} \n \n`,
); );
return includesRunLock; return includesRunLock;
@ -132,7 +129,7 @@ export class SharedWorkspaceLocking {
const isWorkspaceBelowMax = const isWorkspaceBelowMax =
matches.length > 0 && ordered.indexOf(matches[0]) < buildParametersContext.maxRetainedWorkspaces; matches.length > 0 && ordered.indexOf(matches[0]) < buildParametersContext.maxRetainedWorkspaces;
CloudRunnerLogger.log( CloudRunnerLogger.log(
`isWorkspaceBelowMax ${isWorkspaceBelowMax} = ${matches} > 0 && ${ordered.indexOf(matches[0])} < ${ `isWorkspaceBelowMax ${isWorkspaceBelowMax} = ${matches.length} > 0 && ${ordered.indexOf(matches[0])} < ${
buildParametersContext.maxRetainedWorkspaces buildParametersContext.maxRetainedWorkspaces
}`, }`,
); );
@ -202,7 +199,7 @@ export class SharedWorkspaceLocking {
); );
CloudRunnerLogger.log(`All workspaces ${workspaces}`); CloudRunnerLogger.log(`All workspaces ${workspaces}`);
if (await SharedWorkspaceLocking.IsWorkspaceBelowMax(workspace, buildParametersContext)) { if (!(await SharedWorkspaceLocking.IsWorkspaceBelowMax(workspace, buildParametersContext))) {
CloudRunnerLogger.log(`Workspace is below max ${workspaces} ${buildParametersContext.maxRetainedWorkspaces}`); CloudRunnerLogger.log(`Workspace is below max ${workspaces} ${buildParametersContext.maxRetainedWorkspaces}`);
await SharedWorkspaceLocking.CleanupWorkspace(workspace, buildParametersContext); await SharedWorkspaceLocking.CleanupWorkspace(workspace, buildParametersContext);