refactor: make provisioning own instance lifecycle operations
This commit is contained in:
@@ -6,7 +6,7 @@ let fixture: Fixture;
|
||||
beforeEach(async () => {
|
||||
vi.resetModules();
|
||||
fixture = await newFixture(['t5_zombie_theater_1', 't5_zombie_cosmodrome_1']);
|
||||
// No integrations → sweep marks rows manual, exercising that branch.
|
||||
// Provisioning must retain queued work while integrations are unset.
|
||||
delete process.env.KOMODO_ADDRESS;
|
||||
delete process.env.RCON_PASSWORD;
|
||||
});
|
||||
@@ -16,14 +16,12 @@ afterEach(async () => {
|
||||
});
|
||||
|
||||
describe('sweep', () => {
|
||||
it('marks all pending rows manual when integrations are unset', async () => {
|
||||
it('queues pending rows in Provisioning even when integrations are unset', async () => {
|
||||
const { sweep } = await import('../../src/lib/server/pipeline/sweep.js');
|
||||
const { seedServerRegistry } = await import('../../src/lib/server/fleet/servers.js');
|
||||
const { db } = await import('../../src/lib/server/db/index.js');
|
||||
await seedServerRegistry();
|
||||
|
||||
// Seed a deployment row directly — the code path being tested is the
|
||||
// "integrations not configured" branch, which just walks deployment_servers.
|
||||
const depId = 'dep-test-001';
|
||||
db().prepare("INSERT INTO deployments (id, action, started_at, triggered_by) VALUES (?, 'test', ?, 'ui')")
|
||||
.run(depId, new Date().toISOString());
|
||||
@@ -39,12 +37,18 @@ describe('sweep', () => {
|
||||
.run(depId, 't5_zombie_cosmodrome_1');
|
||||
|
||||
await sweep();
|
||||
const { processProvisioning } = await import('../../src/lib/server/provisioning/worker.js');
|
||||
await processProvisioning();
|
||||
await sweep();
|
||||
|
||||
const rows = db()
|
||||
.prepare("SELECT restart_state FROM deployment_servers WHERE deployment_id = ?")
|
||||
.all(depId) as Array<{ restart_state: string }>;
|
||||
expect(rows.length).toBe(2);
|
||||
for (const r of rows) expect(r.restart_state).toBe('manual');
|
||||
for (const r of rows) expect(r.restart_state).toBe('pending');
|
||||
const operations = db().prepare('SELECT state, stage FROM server_deployments').all();
|
||||
expect(operations).toHaveLength(2);
|
||||
for (const operation of operations) expect(operation).toEqual({ state: 'waiting', stage: 'Waiting for Komodo and RCON configuration' });
|
||||
});
|
||||
|
||||
it('is a no-op when nothing is pending', async () => {
|
||||
|
||||
Reference in New Issue
Block a user