fix: finalize durable Pi lifecycle
This commit is contained in:
@@ -152,6 +152,38 @@ test.each(["none", "upstream"] as const)(
|
||||
},
|
||||
);
|
||||
|
||||
test("maintenance endpoints report marker-derived state after post-rename and post-remove fsync failures", async () => {
|
||||
const dir = mkdtempSync(path.join(tmpdir(), "tht-maintenance-endpoint-fsync-"));
|
||||
const marker = path.join(dir, "maintenance.json");
|
||||
let failSync = true;
|
||||
try {
|
||||
const maintenanceBarrier = new MaintenanceBarrier(marker, {
|
||||
syncDirectory() {
|
||||
if (failSync) throw new Error("injected maintenance fsync failure");
|
||||
},
|
||||
});
|
||||
const app = buildApp(loadConfig({
|
||||
AUTH_MODE: "none",
|
||||
THT_HARNESS_DIR: "../harness",
|
||||
THT_MAINTENANCE_FILE: marker,
|
||||
}), { thtRunner: {} as any, maintenanceBarrier });
|
||||
|
||||
const activated = await app.inject({ method: "POST", url: "/internal/maintenance/activate" });
|
||||
expect(activated.statusCode).toBe(500);
|
||||
expect(activated.json()).toMatchObject({ active: true, admissions: 0 });
|
||||
|
||||
failSync = false;
|
||||
expect((await app.inject({ method: "GET", url: "/internal/maintenance/status" })).json())
|
||||
.toEqual({ active: true, admissions: 0 });
|
||||
failSync = true;
|
||||
const deactivated = await app.inject({ method: "POST", url: "/internal/maintenance/deactivate" });
|
||||
expect(deactivated.statusCode).toBe(500);
|
||||
expect(deactivated.json()).toMatchObject({ active: false, admissions: 0 });
|
||||
} finally {
|
||||
rmSync(dir, { recursive: true, force: true });
|
||||
}
|
||||
});
|
||||
|
||||
test("admin all-sessions response matches the authenticated lifecycle wire fixture", async () => {
|
||||
const fixture = JSON.parse(readFileSync(
|
||||
path.join(import.meta.dirname, "fixtures", "sessions-scope-all.json"),
|
||||
|
||||
Reference in New Issue
Block a user