Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions scripts/accord-proof-fixture.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,9 @@ export async function accordFixture() {
mkdirSync(home);
initialize(data, { fixtures: true });
install({ home, data, clients: [] });
const h = { dir, home, data, profile: join(home, '.config/accord/connection.json'), children: [] };
// Use Accord's production leadership window: a 500ms test-only lease can expire
// while a shared CI runner is busy, correctly terminating the coordinator.
const h = { dir, home, data, profile: join(home, '.config/accord/connection.json'), children: [], leaderMs: 5000 };
const launch = async (command, args) => {
const p = fork(
fileURLToPath(new URL('../vendor/accord/src/cli.mjs', import.meta.url)),
Expand All @@ -58,7 +60,14 @@ export async function accordFixture() {
h.driver = d.p;
h.driverUrl = d.url;
h.start = async (port = 0) => {
const s = await launch('serve', ['--port', String(port), '--driver-url', h.driverUrl, '--leader-ms', '500']);
const s = await launch('serve', [
'--port',
String(port),
'--driver-url',
h.driverUrl,
'--leader-ms',
String(h.leaderMs)
]);
h.server = s.p;
h.url = s.url;
};
Expand Down
21 changes: 20 additions & 1 deletion test/accord-install.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import test from 'node:test';
import assert from 'node:assert/strict';
import fs from 'node:fs/promises';
import path from 'node:path';
import { accordFixture } from './accord-fixture.mjs';
import { accordFixture, delay } from './accord-fixture.mjs';
import { ensureLloomAccord } from '../src/accord-install.mjs';
test('LLooM reuses an installed authority and retires its duplicate skill without losing edits', async (t) => {
const h = await accordFixture();
Expand All @@ -28,3 +28,22 @@ test('LLooM reuses an installed authority and retires its duplicate skill withou
await ensureLloomAccord({ home: h.home, profilePath: h.profile });
assert.equal((await fs.readdir(archive)).length, 1);
});

test(
'authority reuse tolerates a scheduling pause within the production leadership window',
{ skip: process.platform === 'win32' },
async (t) => {
const h = await accordFixture();
t.after(() => h.close());
h.server.kill('SIGSTOP');
try {
await delay(800);
} finally {
h.server.kill('SIGCONT');
}
await delay(200);
const result = await ensureLloomAccord({ home: h.home, profilePath: h.profile });
assert(result.reused);
assert.equal(h.server.exitCode, null);
}
);
2 changes: 1 addition & 1 deletion test/schedule-integration.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ for (const crash of ['coordinator', 'gateway'])
if (crash === 'coordinator') {
await stop(h.server, 'SIGKILL');
await assert.rejects(readHostMemory(), 'unavailable telemetry must fail admission closed');
await delay(650);
await delay(h.leaderMs + 150);
await h.start(accordPort);
} else {
await stop(gateway, 'SIGKILL');
Expand Down
Loading