Reconcile recovered campaign targets (Refs #166)
CI / checks (push) Failing after 8m28s

This commit is contained in:
2026-10-19 20:22:58 -04:00
parent 0f05be3a59
commit b5ed0831ae
13 changed files with 802 additions and 21 deletions
+23 -4
View File
@@ -57,7 +57,7 @@ async function resume(id = campaign) {
}
describe('campaign resume API', () => {
it.each(['held', 'manual'])(
it.each(['held', 'manual', 'failed'])(
'queues %s rollback changes without touching live files',
async (state) => {
await heldRollback(state);
@@ -93,7 +93,7 @@ describe('campaign resume API', () => {
it.each(['cancelled', 'failed', 'interrupted'])(
'releases an old %s operation so the worker creates fresh restart intent',
async (state) => {
await heldRollback();
await heldRollback('failed');
const { requestRestart } =
await import('../../src/lib/server/provisioning/requests.js');
const { db } = await import('../../src/lib/server/db/index.js');
@@ -101,6 +101,11 @@ describe('campaign resume API', () => {
db()
.prepare('UPDATE server_deployments SET state = ?, finished_at = ? WHERE id = ?')
.run(state, new Date().toISOString(), old.id);
db()
.prepare(
'UPDATE deployment_servers SET restarted_at=?,checked_at=?,players=3 WHERE deployment_id=?'
)
.run(new Date().toISOString(), new Date().toISOString(), campaign);
expect((await resume()).status).toBe(202);
expect(
db()
@@ -113,7 +118,14 @@ describe('campaign resume API', () => {
await sweep();
const next = requestRestart(server, { kind: 'campaign', id: campaign });
expect(next.id).not.toBe(old.id);
expect(next).toMatchObject({ state: 'waiting', submitted_at: null });
expect(next).toMatchObject({ state: 'waiting', action: 'rebuild', submitted_at: null });
expect(
db()
.prepare(
'SELECT restarted_at,checked_at,players FROM deployment_servers WHERE deployment_id=?'
)
.get(campaign)
).toEqual({ restarted_at: null, checked_at: null, players: null });
expect(
db().prepare('SELECT state FROM server_deployments WHERE id = ?').get(old.id)
).toEqual({ state });
@@ -174,7 +186,7 @@ describe('campaign resume API', () => {
const response = await resume();
expect(response.status).toBe(409);
expect(await response.json()).toEqual({
error: 'This campaign has no held changes to resume.'
error: 'This campaign has no held or failed activations to retry.'
});
expect(kick).not.toHaveBeenCalled();
expect(db().prepare('SELECT * FROM server_deployments').all()).toEqual([]);
@@ -193,4 +205,11 @@ describe('campaign resume API', () => {
}
}
);
it('does not retry a failed file-staging attempt with no activation work', async () => {
await heldRollback('failed');
const { db } = await import('../../src/lib/server/db/index.js');
db().prepare('UPDATE deployment_servers SET files_changed=0').run();
expect((await resume()).status).toBe(409);
});
});