Separate staged command payloads from provisioning state

This commit is contained in:
2026-10-06 14:03:28 -04:00
parent ddb3db9537
commit fbf0629486
4 changed files with 54 additions and 13 deletions
+12
View File
@@ -708,6 +708,18 @@ describe('native instance provisioning', () => {
const { getHostOperation, reportHostOperation } = await import('../../src/lib/server/hosts/index.js');
const stage = getHostOperation(staged.stage_operation_id)!;
expect(stage.kind).toBe('files.stage'); expect(await operationFor(restart.id)).toBeNull();
const routing = db().prepare('SELECT payload FROM ec_host_operations WHERE id=?').get(stage.id) as { payload: string };
expect(JSON.parse(routing.payload)).toEqual({ stageId: restart.id });
const plan = db().prepare('SELECT files_json FROM native_provisioning WHERE deployment_id=?').get(restart.id) as { files_json: string };
expect(JSON.parse(plan.files_json)[0]).not.toHaveProperty('contentBase64');
expect(db().prepare('SELECT payload FROM ec_host_operation_payloads WHERE operation_id=?').get(stage.id))
.toEqual({ payload: JSON.stringify(stage.payload) });
const { closeDb } = await import('../../src/lib/server/db/index.js');
closeDb();
const { pendingHostOperations } = await import('../../src/lib/server/hosts/index.js');
expect(pendingHostOperations(hostId).find(operation => operation.id === stage.id)?.payload).toEqual(stage.payload);
await advance();
expect((db().prepare('SELECT stage_operation_id FROM native_provisioning WHERE deployment_id=?').get(restart.id) as { stage_operation_id: string }).stage_operation_id).toBe(stage.id);
expect(stagedFileChanges('campaign', 'campaign')[0].state).toBe('pending');
reportHostOperation(hostId, stage.id, { state: 'completed', result: { state: 'staged' } });
await advance(); expect(await operationFor(restart.id)).toBeNull();