feat: recover interrupted installation preparation safely
This commit is contained in:
@@ -1,10 +1,34 @@
|
||||
import { expect, test } from "vitest";
|
||||
// The shipped operator client is plain ESM, shared by the embedded command and these API-boundary tests.
|
||||
// @ts-expect-error JavaScript operator module has no separate declaration file.
|
||||
import { prepareWorkspace } from "../../tools/tht/internal/installapply/import-bindings.mjs";
|
||||
import { prepareWorkspace, importBinding } from "../../tools/tht/internal/installapply/import-bindings.mjs";
|
||||
|
||||
const revision = "a".repeat(40);
|
||||
|
||||
test("a stranded preprocessing state requests guarded recovery, then verifies fresh readiness", async () => {
|
||||
let state = "running";
|
||||
const request = async (path: string, body?: unknown): Promise<Response> => {
|
||||
if (path === "/catalog/databases") return Response.json([{ id: "database-id", workspaceId: "chinook", version: 2, schemaSyncedVersion: 2,
|
||||
binding: { transport: "postgres_direct" }, workspaceRevision: { commit: revision } }]);
|
||||
if (path.endsWith("/sync-runs")) return Response.json([]);
|
||||
if (path.endsWith("/preprocessing")) {
|
||||
if (body) { expect(body).toEqual({ recoverInterrupted: true }); state = "ready"; }
|
||||
return Response.json({ state });
|
||||
}
|
||||
throw Error("unexpected operation");
|
||||
};
|
||||
expect(await prepareWorkspace(request, "chinook", revision, async () => {})).toEqual({ workspaceId: "chinook", state: "ready" });
|
||||
});
|
||||
|
||||
test("retry reaches a pending human schema review even when its reservation blocks binding import", async () => {
|
||||
const request = async (path: string) => {
|
||||
if (path === "/installation/bindings") return Response.json({ code: "installation_operation_pending" }, { status: 409 });
|
||||
if (path === "/catalog/databases") return Response.json([{ workspaceId: "chinook", activeSyncRun: { id: "run-id", state: "awaiting_confirmation" } }]);
|
||||
throw Error("unexpected operation");
|
||||
};
|
||||
await expect(importBinding(request, { configuration: { workspaceId: "chinook" } }, revision, async () => {})).rejects.toMatchObject({ code: "schema_review_required", runId: "run-id" });
|
||||
});
|
||||
|
||||
test.each(["blocked", "failed"])("configured Evidence/index failure (%s) remains a real stop", async state => {
|
||||
const request = async (path: string, body?: unknown): Promise<Response> => {
|
||||
if (path === "/catalog/databases") return Response.json([{ id: "database-id", workspaceId: "chinook", version: 2, schemaSyncedVersion: 2,
|
||||
|
||||
Reference in New Issue
Block a user