Better locking
parent
d4c5218b39
commit
7af054a390
|
|
@ -3,49 +3,54 @@ import { Cli } from '../../cli/cli';
|
||||||
import setups from './cloud-runner-suite.test';
|
import setups from './cloud-runner-suite.test';
|
||||||
import CloudRunnerLogger from '../services/cloud-runner-logger';
|
import CloudRunnerLogger from '../services/cloud-runner-logger';
|
||||||
import { v4 as uuidv4 } from 'uuid';
|
import { v4 as uuidv4 } from 'uuid';
|
||||||
|
import CloudRunnerOptions from '../cloud-runner-options';
|
||||||
|
|
||||||
describe('Cloud Runner Locking', () => {
|
describe('Cloud Runner Locking', () => {
|
||||||
setups();
|
setups();
|
||||||
it(`simple locking flow`, async () => {
|
it('Responds', () => {});
|
||||||
Cli.options.retainWorkspaces = true;
|
if (CloudRunnerOptions.cloudRunnerTests) {
|
||||||
const newWorkspaceName = `test-workspace-${uuidv4()}`;
|
it(`simple locking flow`, async () => {
|
||||||
const runId = uuidv4();
|
Cli.options.retainWorkspaces = true;
|
||||||
await SharedWorkspaceLocking.CreateLockableWorkspace(newWorkspaceName);
|
const newWorkspaceName = `test-workspace-${uuidv4()}`;
|
||||||
const isExpectedUnlockedBeforeLocking =
|
const runId = uuidv4();
|
||||||
(await SharedWorkspaceLocking.IsWorkspaceLocked(newWorkspaceName)) === false;
|
await SharedWorkspaceLocking.CreateLockableWorkspace(newWorkspaceName);
|
||||||
expect(isExpectedUnlockedBeforeLocking).toBeTruthy();
|
const isExpectedUnlockedBeforeLocking =
|
||||||
await SharedWorkspaceLocking.LockWorkspace(newWorkspaceName, runId);
|
(await SharedWorkspaceLocking.IsWorkspaceLocked(newWorkspaceName)) === false;
|
||||||
const isExpectedLockedAfterLocking = (await SharedWorkspaceLocking.IsWorkspaceLocked(newWorkspaceName)) === true;
|
expect(isExpectedUnlockedBeforeLocking).toBeTruthy();
|
||||||
expect(isExpectedLockedAfterLocking).toBeTruthy();
|
await SharedWorkspaceLocking.LockWorkspace(newWorkspaceName, runId);
|
||||||
const locksBeforeRelease = await SharedWorkspaceLocking.GetAllLocks(newWorkspaceName);
|
const isExpectedLockedAfterLocking = (await SharedWorkspaceLocking.IsWorkspaceLocked(newWorkspaceName)) === true;
|
||||||
CloudRunnerLogger.log(JSON.stringify(locksBeforeRelease, undefined, 4));
|
expect(isExpectedLockedAfterLocking).toBeTruthy();
|
||||||
expect(locksBeforeRelease.length > 1).toBeTruthy();
|
const locksBeforeRelease = await SharedWorkspaceLocking.GetAllLocks(newWorkspaceName);
|
||||||
await SharedWorkspaceLocking.ReleaseWorkspace(newWorkspaceName, runId);
|
CloudRunnerLogger.log(JSON.stringify(locksBeforeRelease, undefined, 4));
|
||||||
const locks = await SharedWorkspaceLocking.GetAllLocks(newWorkspaceName);
|
expect(locksBeforeRelease.length > 1).toBeTruthy();
|
||||||
expect(locks.length === 1).toBeTruthy();
|
await SharedWorkspaceLocking.ReleaseWorkspace(newWorkspaceName, runId);
|
||||||
const isExpectedLockedAfterReleasing = (await SharedWorkspaceLocking.IsWorkspaceLocked(newWorkspaceName)) === false;
|
const locks = await SharedWorkspaceLocking.GetAllLocks(newWorkspaceName);
|
||||||
expect(isExpectedLockedAfterReleasing).toBeTruthy();
|
expect(locks.length === 1).toBeTruthy();
|
||||||
}, 150000);
|
const isExpectedLockedAfterReleasing =
|
||||||
it('Locking', async () => {
|
(await SharedWorkspaceLocking.IsWorkspaceLocked(newWorkspaceName)) === false;
|
||||||
Cli.options.retainWorkspaces = true;
|
expect(isExpectedLockedAfterReleasing).toBeTruthy();
|
||||||
CloudRunnerLogger.log(`GetAllWorkspaces ${JSON.stringify(await SharedWorkspaceLocking.GetAllWorkspaces())}`);
|
}, 150000);
|
||||||
CloudRunnerLogger.log(`GetFreeWorkspaces ${JSON.stringify(await SharedWorkspaceLocking.GetFreeWorkspaces())}`);
|
it('Locking', async () => {
|
||||||
CloudRunnerLogger.log(
|
Cli.options.retainWorkspaces = true;
|
||||||
`IsWorkspaceLocked ${JSON.stringify(await SharedWorkspaceLocking.IsWorkspaceLocked('test-workspace'))}`,
|
CloudRunnerLogger.log(`GetAllWorkspaces ${JSON.stringify(await SharedWorkspaceLocking.GetAllWorkspaces())}`);
|
||||||
);
|
CloudRunnerLogger.log(`GetFreeWorkspaces ${JSON.stringify(await SharedWorkspaceLocking.GetFreeWorkspaces())}`);
|
||||||
CloudRunnerLogger.log(`GetFreeWorkspaces ${JSON.stringify(await SharedWorkspaceLocking.GetFreeWorkspaces())}`);
|
CloudRunnerLogger.log(
|
||||||
CloudRunnerLogger.log(
|
`IsWorkspaceLocked ${JSON.stringify(await SharedWorkspaceLocking.IsWorkspaceLocked('test-workspace'))}`,
|
||||||
`LockWorkspace ${JSON.stringify(await SharedWorkspaceLocking.LockWorkspace('test-workspace', uuidv4()))}`,
|
);
|
||||||
);
|
CloudRunnerLogger.log(`GetFreeWorkspaces ${JSON.stringify(await SharedWorkspaceLocking.GetFreeWorkspaces())}`);
|
||||||
CloudRunnerLogger.log(
|
CloudRunnerLogger.log(
|
||||||
`CreateLockableWorkspace ${JSON.stringify(
|
`LockWorkspace ${JSON.stringify(await SharedWorkspaceLocking.LockWorkspace('test-workspace', uuidv4()))}`,
|
||||||
await SharedWorkspaceLocking.CreateLockableWorkspace('test-workspace-2'),
|
);
|
||||||
)}`,
|
CloudRunnerLogger.log(
|
||||||
);
|
`CreateLockableWorkspace ${JSON.stringify(
|
||||||
CloudRunnerLogger.log(
|
await SharedWorkspaceLocking.CreateLockableWorkspace('test-workspace-2'),
|
||||||
`GetLockedWorkspace ${JSON.stringify(
|
)}`,
|
||||||
await SharedWorkspaceLocking.GetLockedWorkspace('test-workspace-2', uuidv4()),
|
);
|
||||||
)}`,
|
CloudRunnerLogger.log(
|
||||||
);
|
`GetLockedWorkspace ${JSON.stringify(
|
||||||
}, 3000000);
|
await SharedWorkspaceLocking.GetLockedWorkspace('test-workspace-2', uuidv4()),
|
||||||
|
)}`,
|
||||||
|
);
|
||||||
|
}, 3000000);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue