improve locking naming
parent
5ea758fc9e
commit
937de0f338
|
@ -49,7 +49,7 @@ jobs:
|
|||
- 'cloud-runner-hooks'
|
||||
- 'cloud-runner-local-persistence'
|
||||
- 'cloud-runner-locking'
|
||||
- 'cloud-runner-locking-upsert'
|
||||
- 'cloud-runner-locking-get-locked'
|
||||
providerStrategy:
|
||||
# - aws
|
||||
- local-docker
|
||||
|
@ -107,7 +107,7 @@ jobs:
|
|||
- 'cloud-runner-s3-steps'
|
||||
#- 'cloud-runner-local-persistence'
|
||||
# - 'cloud-runner-locking'
|
||||
#- 'cloud-runner-locking-upsert'
|
||||
#- 'cloud-runner-locking-get-locked'
|
||||
providerStrategy:
|
||||
- aws
|
||||
- local-docker
|
||||
|
|
|
@ -1052,7 +1052,7 @@ class CloudRunner {
|
|||
try {
|
||||
if (__1.BuildParameters.useRetainedWorkspaceMode(buildParameters)) {
|
||||
CloudRunner.lockedWorkspace = shared_workspace_locking_1.default.NewWorkspaceName();
|
||||
const result = await shared_workspace_locking_1.default.GetOrCreateLockedWorkspace(CloudRunner.lockedWorkspace, CloudRunner.buildParameters.buildGuid, CloudRunner.buildParameters);
|
||||
const result = await shared_workspace_locking_1.default.GetLockedWorkspace(CloudRunner.lockedWorkspace, CloudRunner.buildParameters.buildGuid, CloudRunner.buildParameters);
|
||||
if (result) {
|
||||
cloud_runner_logger_1.default.logLine(`Using retained workspace ${CloudRunner.lockedWorkspace}`);
|
||||
CloudRunner.cloudRunnerEnvironmentVariables = [
|
||||
|
@ -5325,7 +5325,7 @@ class SharedWorkspaceLocking {
|
|||
.map((x) => x.replace(`/`, ``))
|
||||
.filter((x) => x.includes(workspace) && x.endsWith(`_lock`));
|
||||
}
|
||||
static async GetOrCreateLockedWorkspace(workspace, runId, buildParametersContext) {
|
||||
static async GetLockedWorkspace(workspace, runId, buildParametersContext) {
|
||||
if (!build_parameters_1.default.useRetainedWorkspaceMode(buildParametersContext)) {
|
||||
return false;
|
||||
}
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -94,7 +94,7 @@ class CloudRunner {
|
|||
if (BuildParameters.useRetainedWorkspaceMode(buildParameters)) {
|
||||
CloudRunner.lockedWorkspace = SharedWorkspaceLocking.NewWorkspaceName();
|
||||
|
||||
const result = await SharedWorkspaceLocking.GetOrCreateLockedWorkspace(
|
||||
const result = await SharedWorkspaceLocking.GetLockedWorkspace(
|
||||
CloudRunner.lockedWorkspace,
|
||||
CloudRunner.buildParameters.buildGuid,
|
||||
CloudRunner.buildParameters,
|
||||
|
|
|
@ -62,11 +62,7 @@ export class SharedWorkspaceLocking {
|
|||
.map((x) => x.replace(`/`, ``))
|
||||
.filter((x) => x.includes(workspace) && x.endsWith(`_lock`));
|
||||
}
|
||||
public static async GetOrCreateLockedWorkspace(
|
||||
workspace: string,
|
||||
runId: string,
|
||||
buildParametersContext: BuildParameters,
|
||||
) {
|
||||
public static async GetLockedWorkspace(workspace: string, runId: string, buildParametersContext: BuildParameters) {
|
||||
if (!BuildParameters.useRetainedWorkspaceMode(buildParametersContext)) {
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -12,7 +12,7 @@ describe('Cloud Runner Local Docker Workflows', () => {
|
|||
it('Responds', () => {});
|
||||
|
||||
if (CloudRunnerOptions.providerStrategy === `local-docker`) {
|
||||
it('inspect stateful folder of Workflows', async () => {
|
||||
it('inspect stateful folder of workflows', async () => {
|
||||
const testValue = `the state in a job exits in the expected local-docker folder`;
|
||||
|
||||
// Setup parameters
|
||||
|
|
|
@ -15,11 +15,11 @@ async function CreateParameters(overrides: any) {
|
|||
return await BuildParameters.create();
|
||||
}
|
||||
|
||||
describe('Cloud Runner Locking Upsert', () => {
|
||||
describe('Cloud Runner Locking Get Locked Workspace', () => {
|
||||
setups();
|
||||
it('Responds', () => {});
|
||||
if (CloudRunnerOptions.cloudRunnerDebug) {
|
||||
it(`Get Or Create From No Workspace`, async () => {
|
||||
it(`Get locked workspace From No Workspace`, async () => {
|
||||
const overrides: any = {
|
||||
versioning: 'None',
|
||||
projectPath: 'test-project',
|
||||
|
@ -33,11 +33,9 @@ describe('Cloud Runner Locking Upsert', () => {
|
|||
const newWorkspaceName = `test-workspace-${uuidv4()}`;
|
||||
const runId = uuidv4();
|
||||
CloudRunner.buildParameters = buildParameters;
|
||||
expect(
|
||||
await SharedWorkspaceLocking.GetOrCreateLockedWorkspace(newWorkspaceName, runId, buildParameters),
|
||||
).toBeTruthy();
|
||||
expect(await SharedWorkspaceLocking.GetLockedWorkspace(newWorkspaceName, runId, buildParameters)).toBeTruthy();
|
||||
}, 150000);
|
||||
it(`Get Or Create From Unlocked`, async () => {
|
||||
it(`Get locked workspace from unlocked`, async () => {
|
||||
const overrides: any = {
|
||||
versioning: 'None',
|
||||
projectPath: 'test-project',
|
||||
|
@ -52,12 +50,10 @@ describe('Cloud Runner Locking Upsert', () => {
|
|||
const runId = uuidv4();
|
||||
CloudRunner.buildParameters = buildParameters;
|
||||
expect(await SharedWorkspaceLocking.CreateWorkspace(newWorkspaceName, buildParameters)).toBeTruthy();
|
||||
expect(
|
||||
await SharedWorkspaceLocking.GetOrCreateLockedWorkspace(newWorkspaceName, runId, buildParameters),
|
||||
).toBeTruthy();
|
||||
expect(await SharedWorkspaceLocking.GetLockedWorkspace(newWorkspaceName, runId, buildParameters)).toBeTruthy();
|
||||
expect(CloudRunner.lockedWorkspace).toMatch(newWorkspaceName);
|
||||
}, 300000);
|
||||
it(`Get Or Create From Locked`, async () => {
|
||||
it(`Get locked workspace from locked`, async () => {
|
||||
const overrides: any = {
|
||||
versioning: 'None',
|
||||
projectPath: 'test-project',
|
||||
|
@ -78,12 +74,10 @@ describe('Cloud Runner Locking Upsert', () => {
|
|||
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(await SharedWorkspaceLocking.GetLockedWorkspace(newWorkspaceName, runId2, buildParameters)).toBeTruthy();
|
||||
expect(CloudRunner.lockedWorkspace).not.toMatch(newWorkspaceName);
|
||||
}, 300000);
|
||||
it(`Get Or Create After Double Lock And One Unlock`, async () => {
|
||||
it(`Get locked workspace after double lock and one unlock`, async () => {
|
||||
const overrides: any = {
|
||||
versioning: 'None',
|
||||
projectPath: 'test-project',
|
||||
|
@ -107,12 +101,10 @@ describe('Cloud Runner Locking Upsert', () => {
|
|||
expect(await SharedWorkspaceLocking.HasWorkspaceLock(newWorkspaceName, runId, buildParameters)).toBeTruthy();
|
||||
expect(await SharedWorkspaceLocking.IsWorkspaceLocked(newWorkspaceName, buildParameters)).toBeTruthy();
|
||||
expect(await SharedWorkspaceLocking.DoesWorkspaceExist(newWorkspaceName, buildParameters)).toBeTruthy();
|
||||
expect(
|
||||
await SharedWorkspaceLocking.GetOrCreateLockedWorkspace(newWorkspaceName, runId2, buildParameters),
|
||||
).toBeTruthy();
|
||||
expect(await SharedWorkspaceLocking.GetLockedWorkspace(newWorkspaceName, runId2, buildParameters)).toBeTruthy();
|
||||
expect(CloudRunner.lockedWorkspace).not.toContain(newWorkspaceName);
|
||||
}, 300000);
|
||||
it(`Get Or Create After Double Lock And Unlock`, async () => {
|
||||
it(`Get locked workspace after double lock and unlock`, async () => {
|
||||
const overrides: any = {
|
||||
versioning: 'None',
|
||||
projectPath: 'test-project',
|
||||
|
@ -137,12 +129,10 @@ describe('Cloud Runner Locking Upsert', () => {
|
|||
expect(await SharedWorkspaceLocking.ReleaseWorkspace(newWorkspaceName, runId, buildParameters)).toBeTruthy();
|
||||
expect(await SharedWorkspaceLocking.IsWorkspaceLocked(newWorkspaceName, buildParameters)).toBeFalsy();
|
||||
expect(await SharedWorkspaceLocking.DoesWorkspaceExist(newWorkspaceName, buildParameters)).toBeTruthy();
|
||||
expect(
|
||||
await SharedWorkspaceLocking.GetOrCreateLockedWorkspace(newWorkspaceName, runId2, buildParameters),
|
||||
).toBeTruthy();
|
||||
expect(await SharedWorkspaceLocking.GetLockedWorkspace(newWorkspaceName, runId2, buildParameters)).toBeTruthy();
|
||||
expect(CloudRunner.lockedWorkspace).toContain(newWorkspaceName);
|
||||
}, 300000);
|
||||
it(`Get Or Create From Unlocked Was Locked`, async () => {
|
||||
it(`Get locked workspace from unlocked was locked`, async () => {
|
||||
const overrides: any = {
|
||||
versioning: 'None',
|
||||
projectPath: 'test-project',
|
||||
|
@ -159,9 +149,7 @@ describe('Cloud Runner Locking Upsert', () => {
|
|||
expect(await SharedWorkspaceLocking.CreateWorkspace(newWorkspaceName, buildParameters)).toBeTruthy();
|
||||
expect(await SharedWorkspaceLocking.LockWorkspace(newWorkspaceName, runId, buildParameters)).toBeTruthy();
|
||||
expect(await SharedWorkspaceLocking.ReleaseWorkspace(newWorkspaceName, runId, buildParameters)).toBeTruthy();
|
||||
expect(
|
||||
await SharedWorkspaceLocking.GetOrCreateLockedWorkspace(newWorkspaceName, runId, buildParameters),
|
||||
).toBeTruthy();
|
||||
expect(await SharedWorkspaceLocking.GetLockedWorkspace(newWorkspaceName, runId, buildParameters)).toBeTruthy();
|
||||
expect(CloudRunner.lockedWorkspace).toMatch(newWorkspaceName);
|
||||
}, 300000);
|
||||
}
|
|
@ -86,9 +86,7 @@ describe('Cloud Runner Locking', () => {
|
|||
).toBeTruthy();
|
||||
await SharedWorkspaceLocking.CleanupWorkspace(newWorkspaceName, buildParameters);
|
||||
CloudRunnerLogger.log(`Starting get or create`);
|
||||
expect(
|
||||
await SharedWorkspaceLocking.GetOrCreateLockedWorkspace(newWorkspaceName, runId, buildParameters),
|
||||
).toBeTruthy();
|
||||
expect(await SharedWorkspaceLocking.GetLockedWorkspace(newWorkspaceName, runId, buildParameters)).toBeTruthy();
|
||||
}, 350000);
|
||||
}
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue