feat(agent): consume explicit deployment events safely
This commit is contained in:
parent
5897eb6850
commit
aabd462f2e
4 changed files with 93 additions and 0 deletions
16
server-tools/lake-lamp-authz/deployment-event-worker.test.js
Normal file
16
server-tools/lake-lamp-authz/deployment-event-worker.test.js
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
"use strict";
|
||||
const test = require("node:test");
|
||||
const assert = require("node:assert/strict");
|
||||
const fs = require("node:fs");
|
||||
const os = require("node:os");
|
||||
const path = require("node:path");
|
||||
const { processOne } = require("./deployment-event-worker");
|
||||
test("resident deployment agent consumes only an explicit immutable event and writes a receipt", async () => {
|
||||
const root = fs.mkdtempSync(path.join(os.tmpdir(), "lake-lamp-deploy-worker-")), queue = path.join(root, "queue"), receipts = path.join(root, "receipts"), sha = "a".repeat(40);
|
||||
fs.mkdirSync(queue); fs.writeFileSync(path.join(queue, "event.json"), JSON.stringify({ schema: "guanghu.deployment-event/v1", event_id: "event-1", state: "queued_for_resident_agent", repo: "bingshuo/guanghu-ice-heart", branch: "main", commit_sha: sha, workorder_id: "order-1", resource: `GLS-0239-DEPLOY@${sha}`, manifest: "deployment/requests/GLS-0239.json" }));
|
||||
try {
|
||||
const result = await processOne({ queueDir: queue, receiptsDir: receipts, registry: { "bingshuo/guanghu-ice-heart": { repo_url: "https://example.invalid/code.git" } }, provisionFn: async request => { assert.equal(request.resource, `GLS-0239-DEPLOY@${sha}`); return { ok: true, unit: "example.service" }; } });
|
||||
assert.equal(result.state, "DEPLOYED_AND_VERIFIED");
|
||||
assert.equal(JSON.parse(fs.readFileSync(path.join(receipts, "event-1.json"))).diagnostic_code, "deployment_succeeded");
|
||||
} finally { fs.rmSync(root, { recursive: true, force: true }); }
|
||||
});
|
||||
Loading…
Reference in a new issue