fixes
parent
7ef6c52a43
commit
2bd3ea14b4
|
@ -5756,7 +5756,7 @@ class SharedWorkspaceLocking {
|
||||||
}
|
}
|
||||||
return (yield SharedWorkspaceLocking.ReadLines(`aws s3 ls ${SharedWorkspaceLocking.workspaceRoot}${buildParametersContext.cacheKey}/`))
|
return (yield SharedWorkspaceLocking.ReadLines(`aws s3 ls ${SharedWorkspaceLocking.workspaceRoot}${buildParametersContext.cacheKey}/`))
|
||||||
.map((x) => x.replace(`/`, ``))
|
.map((x) => x.replace(`/`, ``))
|
||||||
.filter((x) => x.endsWith(`${workspace}_workspace_lock`));
|
.filter((x) => x.includes(workspace) && x.endsWith(`_lock`));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
static GetOrCreateLockedWorkspace(workspace, runId, buildParametersContext) {
|
static GetOrCreateLockedWorkspace(workspace, runId, buildParametersContext) {
|
||||||
|
@ -5911,7 +5911,7 @@ class SharedWorkspaceLocking {
|
||||||
static ReleaseWorkspace(workspace, runId, buildParametersContext) {
|
static ReleaseWorkspace(workspace, runId, buildParametersContext) {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
const files = yield SharedWorkspaceLocking.GetAllLocksForWorkspace(workspace, buildParametersContext);
|
const files = yield SharedWorkspaceLocking.GetAllLocksForWorkspace(workspace, buildParametersContext);
|
||||||
const file = files.find((x) => x.includes(`${workspace}`) && x.endsWith(`_workspace_lock`) && x.includes(runId));
|
const file = files.find((x) => x.includes(workspace) && x.endsWith(`_lock`) && x.includes(runId));
|
||||||
cloud_runner_logger_1.default.log(`All Locks ${files} ${workspace} ${runId}`);
|
cloud_runner_logger_1.default.log(`All Locks ${files} ${workspace} ${runId}`);
|
||||||
cloud_runner_logger_1.default.log(`Deleting lock ${workspace}/${file}`);
|
cloud_runner_logger_1.default.log(`Deleting lock ${workspace}/${file}`);
|
||||||
cloud_runner_logger_1.default.log(`rm ${SharedWorkspaceLocking.workspaceRoot}${buildParametersContext.cacheKey}/${file}`);
|
cloud_runner_logger_1.default.log(`rm ${SharedWorkspaceLocking.workspaceRoot}${buildParametersContext.cacheKey}/${file}`);
|
||||||
|
|
File diff suppressed because one or more lines are too long
|
@ -43,7 +43,7 @@ export class SharedWorkspaceLocking {
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
.map((x) => x.replace(`/`, ``))
|
.map((x) => x.replace(`/`, ``))
|
||||||
.filter((x) => x.endsWith(`${workspace}_workspace_lock`));
|
.filter((x) => x.includes(workspace) && x.endsWith(`_lock`));
|
||||||
}
|
}
|
||||||
public static async GetOrCreateLockedWorkspace(
|
public static async GetOrCreateLockedWorkspace(
|
||||||
workspace: string,
|
workspace: string,
|
||||||
|
@ -262,7 +262,7 @@ export class SharedWorkspaceLocking {
|
||||||
buildParametersContext: BuildParameters,
|
buildParametersContext: BuildParameters,
|
||||||
): Promise<boolean> {
|
): Promise<boolean> {
|
||||||
const files = await SharedWorkspaceLocking.GetAllLocksForWorkspace(workspace, buildParametersContext);
|
const files = await SharedWorkspaceLocking.GetAllLocksForWorkspace(workspace, buildParametersContext);
|
||||||
const file = files.find((x) => x.includes(`${workspace}`) && x.endsWith(`_workspace_lock`) && x.includes(runId));
|
const file = files.find((x) => x.includes(workspace) && x.endsWith(`_lock`) && x.includes(runId));
|
||||||
CloudRunnerLogger.log(`All Locks ${files} ${workspace} ${runId}`);
|
CloudRunnerLogger.log(`All Locks ${files} ${workspace} ${runId}`);
|
||||||
CloudRunnerLogger.log(`Deleting lock ${workspace}/${file}`);
|
CloudRunnerLogger.log(`Deleting lock ${workspace}/${file}`);
|
||||||
CloudRunnerLogger.log(`rm ${SharedWorkspaceLocking.workspaceRoot}${buildParametersContext.cacheKey}/${file}`);
|
CloudRunnerLogger.log(`rm ${SharedWorkspaceLocking.workspaceRoot}${buildParametersContext.cacheKey}/${file}`);
|
||||||
|
|
|
@ -158,6 +158,38 @@ describe('Cloud Runner Locking', () => {
|
||||||
).toBeTruthy();
|
).toBeTruthy();
|
||||||
expect(CloudRunner.lockedWorkspace).not.toMatch(newWorkspaceName);
|
expect(CloudRunner.lockedWorkspace).not.toMatch(newWorkspaceName);
|
||||||
}, 150000);
|
}, 150000);
|
||||||
|
it(`Get Or Create After Double Lock And Unlock`, async () => {
|
||||||
|
Cli.options.retainWorkspaces = true;
|
||||||
|
const overrides: any = {
|
||||||
|
versioning: 'None',
|
||||||
|
projectPath: 'test-project',
|
||||||
|
unityVersion: UnityVersioning.determineUnityVersion('test-project', UnityVersioning.read('test-project')),
|
||||||
|
targetPlatform: 'StandaloneLinux64',
|
||||||
|
cacheKey: `test-case-${uuidv4()}`,
|
||||||
|
retainWorkspaces: true,
|
||||||
|
};
|
||||||
|
const buildParameters = await CreateParameters(overrides);
|
||||||
|
|
||||||
|
const newWorkspaceName = `test-workspace-${uuidv4()}`;
|
||||||
|
const runId = uuidv4();
|
||||||
|
const runId2 = uuidv4();
|
||||||
|
CloudRunner.buildParameters = buildParameters;
|
||||||
|
expect(await SharedWorkspaceLocking.CreateWorkspace(newWorkspaceName, buildParameters)).toBeTruthy();
|
||||||
|
expect(await SharedWorkspaceLocking.LockWorkspace(newWorkspaceName, runId, buildParameters)).toBeTruthy();
|
||||||
|
expect(await SharedWorkspaceLocking.IsWorkspaceLocked(newWorkspaceName, buildParameters)).toBeTruthy();
|
||||||
|
expect(await SharedWorkspaceLocking.ReleaseWorkspace(newWorkspaceName, runId, buildParameters)).toBeTruthy();
|
||||||
|
expect(await SharedWorkspaceLocking.IsWorkspaceLocked(newWorkspaceName, buildParameters)).toBeFalsy();
|
||||||
|
expect(await SharedWorkspaceLocking.LockWorkspace(newWorkspaceName, runId, buildParameters)).toBeTruthy();
|
||||||
|
expect(await SharedWorkspaceLocking.ReleaseWorkspace(newWorkspaceName, runId, buildParameters)).toBeTruthy();
|
||||||
|
expect(await SharedWorkspaceLocking.HasWorkspaceLock(newWorkspaceName, runId, buildParameters)).toBeTruthy();
|
||||||
|
expect(await SharedWorkspaceLocking.IsWorkspaceLocked(newWorkspaceName, buildParameters)).toBeTruthy();
|
||||||
|
expect(await SharedWorkspaceLocking.IsWorkspaceBelowMax(newWorkspaceName, buildParameters)).toBeTruthy();
|
||||||
|
expect(await SharedWorkspaceLocking.DoesWorkspaceExist(newWorkspaceName, buildParameters)).toBeTruthy();
|
||||||
|
expect(
|
||||||
|
await SharedWorkspaceLocking.GetOrCreateLockedWorkspace(newWorkspaceName, runId2, buildParameters),
|
||||||
|
).toBeTruthy();
|
||||||
|
expect(CloudRunner.lockedWorkspace).not.toMatch(newWorkspaceName);
|
||||||
|
}, 150000);
|
||||||
it(`0 free workspaces after locking`, async () => {
|
it(`0 free workspaces after locking`, async () => {
|
||||||
Cli.options.retainWorkspaces = true;
|
Cli.options.retainWorkspaces = true;
|
||||||
const overrides: any = {
|
const overrides: any = {
|
||||||
|
|
Loading…
Reference in New Issue