feat(deployment): implement recovery for interrupted rebuilds

This commit is contained in:
KodekaTeam committed 2026-08-22 16:12:58 +07:00
1 parent f6ff607777
commit 0a16bd9b17
4 files changed
+229 -4

No files matched your search

+47
View File
@@ -0,0 +1,47 @@
import assert from "node:assert/strict";
import test from "node:test";
import { classifyInterruptedRebuild } from "../../src/server/services/deployment-recovery.service";
import { isDeploymentLockActive } from "../../src/server/services/deployment-lock.service";
const startedAt = new Date("2026-08-22T10:00:00.000Z");
test("interrupted rebuild is recovered as successful for a new running container", () => {
assert.equal(
classifyInterruptedRebuild({
startedAt,
inspect: {
Created: "2026-08-22T10:00:05.000Z",
State: { Running: true, Status: "running" },
},
}),
"SUCCESS",
);
});
test("interrupted rebuild is not reported as successful for the old runtime", () => {
assert.equal(
classifyInterruptedRebuild({
startedAt,
inspect: {
Created: "2026-08-20T10:00:00.000Z",
State: { Running: true, Status: "running" },
},
}),
"FAILED",
);
});
test("deployment lock becomes inactive when its heartbeat is stale", () => {
const now = new Date("2026-08-22T10:05:00.000Z");
assert.equal(
isDeploymentLockActive(
{
expiresAt: new Date("2026-08-22T10:15:00.000Z"),
updatedAt: new Date("2026-08-22T10:00:00.000Z"),
},
{ now, staleMs: 120_000 },
),
false,
);
});