fix(pi): converge worker failures and thinking state
This commit is contained in:
@@ -269,6 +269,49 @@ describe('managed Pi extension bridge', () => {
|
||||
expect(currentWorker.status).toBe(200);
|
||||
});
|
||||
|
||||
it('releases a crashed worker write lease so only its same-project waiter advances', async () => {
|
||||
const root = await mkdtemp(path.join(tmpdir(), 'makelore-pi-extension-crash-lease-'));
|
||||
roots.push(root);
|
||||
const leases = new PiProjectWriteLeaseCoordinator();
|
||||
const host = new PiManagedExtensionHost(leases);
|
||||
hosts.push(host);
|
||||
const crashed = await host.registerWorker({
|
||||
conversationId: 'conversation-crashed', generation: 1, projectId: 'project-a', extensionsDir: root,
|
||||
});
|
||||
const waiter = await host.registerWorker({
|
||||
conversationId: 'conversation-waiter', generation: 1, projectId: 'project-a', extensionsDir: root,
|
||||
});
|
||||
const other = await host.registerWorker({
|
||||
conversationId: 'conversation-other', generation: 1, projectId: 'project-b', extensionsDir: root,
|
||||
});
|
||||
await Promise.all([
|
||||
host.bindRun('conversation-crashed', 1, 'run-crashed'),
|
||||
host.bindRun('conversation-waiter', 1, 'run-waiter'),
|
||||
host.bindRun('conversation-other', 1, 'run-other'),
|
||||
]);
|
||||
expect((await post(crashed, {
|
||||
action: 'lease.acquire', conversationId: 'conversation-crashed', workerGeneration: 1,
|
||||
runId: 'run-crashed', resourceId: 'crashed-write',
|
||||
})).status).toBe(200);
|
||||
const waiting = post(waiter, {
|
||||
action: 'lease.acquire', conversationId: 'conversation-waiter', workerGeneration: 1,
|
||||
runId: 'run-waiter', resourceId: 'waiting-write',
|
||||
});
|
||||
expect((await post(other, {
|
||||
action: 'lease.acquire', conversationId: 'conversation-other', workerGeneration: 1,
|
||||
runId: 'run-other', resourceId: 'other-write',
|
||||
})).status).toBe(200);
|
||||
await expect.poll(() => leases.waitingCount('project-a')).toBe(1);
|
||||
|
||||
await crashed.dispose();
|
||||
|
||||
await expect(waiting).resolves.toMatchObject({ status: 200 });
|
||||
expect(leases.waitingCount()).toBe(0);
|
||||
expect(leases.activeCount).toBe(2);
|
||||
await Promise.all([waiter.dispose(), other.dispose()]);
|
||||
expect(leases.activeCount).toBe(0);
|
||||
});
|
||||
|
||||
it('joins a coding child to the same project write lease as its parent', async () => {
|
||||
const root = await mkdtemp(path.join(tmpdir(), 'makelore-pi-extension-child-lease-'));
|
||||
roots.push(root);
|
||||
|
||||
Reference in New Issue
Block a user