Tolerate concurrent PM2 profile cleanup

This commit is contained in:
2026-07-25 14:13:24 +00:00
parent 62b6e20c46
commit 43ae163038
2 changed files with 20 additions and 2 deletions
@@ -40,7 +40,8 @@ const createHarness = (
operation: GatewayOperationRecord,
failStart = false,
failStop = false,
processesPresent = true
processesPresent = true,
missingOnDelete = false
) => {
let nextOperation: GatewayOperationRecord | null = operation;
const statuses: string[] = [];
@@ -103,6 +104,9 @@ const createHarness = (
},
delete: async (name) => {
deleted.push(name);
if (missingOnDelete) {
throw new Error('process or namespace not found');
}
if (failStop) {
throw new Error('pm2 delete failed');
}
@@ -168,6 +172,15 @@ describe('GatewayOrchestrator first-class operations', () => {
expect(harness.completions).toEqual(['SUCCEEDED']);
});
it('treats a process removed concurrently as a successful stop', async () => {
const harness = createHarness(buildOperation('STOP'), false, false, true, true);
await harness.orchestrator.runOperationsNow();
expect(harness.deleted).toEqual(['sammo:che:2:game-api', 'sammo:che:2:turn-daemon']);
expect(harness.completions).toEqual(['SUCCEEDED']);
});
it('records a failed start instead of reporting a false success', async () => {
const harness = createHarness(buildOperation('START'), true);