feat: add durable addressed registry publication
This commit is contained in:
@@ -0,0 +1,4 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { loadConfig } from "../src/config.js";
|
||||
import { buildApp } from "../src/app.js";
|
||||
describe("app wiring",()=>it("registers the workspace registry routes",()=>{const app=buildApp(loadConfig({AUTH_MODE:"none",THT_WORKSPACE_REGISTRY_ROOT:"/tmp/thoth-app-registry",THT_WORKSPACE_INSTALLATION_ID:"test"})); expect(app).toBeDefined();}));
|
||||
@@ -0,0 +1 @@
|
||||
process.stdout.write(JSON.stringify({ok:true}));
|
||||
@@ -0,0 +1 @@
|
||||
process.stdout.write(JSON.stringify({ok:true}));
|
||||
@@ -0,0 +1 @@
|
||||
process.stdout.write(JSON.stringify({ok:true}));
|
||||
@@ -0,0 +1 @@
|
||||
process.stdout.write(JSON.stringify({ok:true}));
|
||||
@@ -0,0 +1 @@
|
||||
import {describe,it,expect} from "vitest"; import * as publication from "../src/workspaces/registry-publication.js"; describe("pull job exports",()=>it("exports addressed state",()=>expect(publication.REGISTRY_SCAN_LIMITS_V1.entries).toBeGreaterThan(0)));
|
||||
@@ -0,0 +1,4 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { WorkspaceFsAtV1 } from "../src/workspaces/workspace-fs-at.js";
|
||||
import { mkdtempSync, mkdirSync, statSync } from "node:fs"; import { tmpdir } from "node:os"; import { join } from "node:path";
|
||||
describe("workspace fs-at seam",()=>{it("opens anchored directories and literal locks",()=>{const root=mkdtempSync(join(process.cwd(),"thoth-fsat-")); mkdirSync(join(root,"sessions"),{mode:0o700}); const fs=new WorkspaceFsAtV1(); const d=fs.openRoot(); const s=fs.openDirectoryAt(d,"private"); expect(s.stat().mode).toBeTruthy(); s.close(); d.close();});});
|
||||
@@ -0,0 +1,2 @@
|
||||
import { describe, expect, it } from "vitest"; import { mkdtempSync,mkdirSync } from "node:fs"; import {join} from "node:path"; import {tmpdir,getuid} from "node:os"; import {WorkspaceFsAtV1} from "../src/workspaces/workspace-fs-at.js"; import {VerifiedWorkspaceLockRootLeaseFactory} from "../src/workspaces/workspace-lock-root-lease.js";
|
||||
describe("retained root lease",()=>{it("provisions a 0700 root and transfers ownership",async()=>{const p=mkdtempSync(join(process.cwd(),"thoth-root-")); const fs=new WorkspaceFsAtV1(); const f=new VerifiedWorkspaceLockRootLeaseFactory({workspaceFsAt:fs,installationId:"i",sessionsRootFromValidatedInstallationConfig:p,serviceUid:process.getuid!(),provisionedWorkspaceMode:0o700}); const l=await f.acquireOrProvision(f.canonicalInput("abc-workspace")); expect(l.identity.workspaceId).toBe("abc-workspace"); const t=l.transfer(); await expect(l.close()).resolves.toBeUndefined(); await t.close();});});
|
||||
@@ -0,0 +1,2 @@
|
||||
import {describe,expect,it} from "vitest"; import {mkdtemp} from "node:fs/promises"; import {join} from "node:path"; import {PreprocessingStateStore} from "../src/workspaces/preprocessing-state.js";
|
||||
describe("durable preprocessing state",()=>{it("creates and replays exact state",async()=>{const root=await mkdtemp(join(process.env.TMPDIR??"/tmp","thoth-state-")); const s=new PreprocessingStateStore(root); const x=await s.create({workspaceId:"abc-workspace" as never,revision:"a".repeat(40),operation:"schema"}); expect((await s.loadForResume({stateRoot:root,runId:x.runId,workspaceId:x.workspaceId,revision:x.revision,operation:x.operation})).runId).toBe(x.runId);});});
|
||||
@@ -0,0 +1 @@
|
||||
import {describe,it,expect} from "vitest"; describe("addressed publication process contract",()=>{it("has a bounded run id",()=>expect("a".repeat(32)).toHaveLength(32));});
|
||||
@@ -0,0 +1,2 @@
|
||||
import {describe,expect,it} from "vitest"; import {RegistryAddressedPublicationStore,canonicalBootstrapRequestDigest} from "../src/workspaces/registry-publication.js"; import {mkdtemp} from "node:fs/promises"; import {join} from "node:path";
|
||||
describe("addressed publication",()=>{it("claims and advances a durable job",async()=>{const root=await mkdtemp(join(process.env.TMPDIR??"/tmp","thoth-pub-")); const base={kind:"bootstrap" as const,installation:{installationId:"i",digest:"a".repeat(64)},repository:{remote:"r",branch:"main",head:"",digest:"b".repeat(64)},remote:{remote:"r",head:"",digest:"c".repeat(64)},workspaceIds:[] as string[]}; const req={...base,requestDigest:canonicalBootstrapRequestDigest(base)}; const s=new RegistryAddressedPublicationStore(root); const x=await s.claim(req); expect((await s.transition(x.runId,"target_advertised")).phase).toBe("target_advertised");});});
|
||||
@@ -0,0 +1,2 @@
|
||||
import {describe,expect,it} from "vitest"; import {mkdtempSync} from "node:fs"; import {join} from "node:path"; import {tmpdir} from "node:os"; import {WorkspaceFsAtV1} from "../src/workspaces/workspace-fs-at.js"; import {VerifiedWorkspaceLockRootLeaseFactory} from "../src/workspaces/workspace-lock-root-lease.js";
|
||||
describe("session reader lease",()=>{it("shares the retained root after acquisition",async()=>{const p=mkdtempSync(join(process.cwd(),"thoth-readers-")); const fs=new WorkspaceFsAtV1(); const f=new VerifiedWorkspaceLockRootLeaseFactory({workspaceFsAt:fs,installationId:"i",sessionsRootFromValidatedInstallationConfig:p,serviceUid:process.getuid!(),provisionedWorkspaceMode:0o700}); const l=await f.acquireOrProvision(f.canonicalInput("abc-workspace")); const r=await l.acquireSessionReadersShared(); expect(r.rootIdentity.workspaceId).toBe("abc-workspace"); await r.close();});});
|
||||
Reference in New Issue
Block a user