The micro-VM for AI agents — light enough to embed on your laptop, elastic enough to power an agentic cloud.
test(ci): control lease expiry in scale-set scheduling tests (#3238)
kekxy71d41271c010
diff --git a/apps/libs/ci-listener/README.md b/apps/libs/ci-listener/README.mdindex ae9685259..d86baf6c0 100644--- a/apps/libs/ci-listener/README.md+++ b/apps/libs/ci-listener/README.md@@ -978,8 +978,11 @@ test database snapshot because the lease can expire during shutdown. To test ownturnover, commit the initial records under a valid lease, then expire it in teststorage before checking renewal, takeover and recovery under the new owner.-The scale-set tests for JIT recovery, stale quota records and worker startup-backoff use the default execution lease. To check the backoff after two startup+The scale-set integration tests run with the default execution lease. When a+scenario restarts the Listener, the fixture waits for shutdown, then expires the+stored lease so the next owner can take over immediately.++To check the backoff after two startupfailures, advance the test clock to 1,999 ms and then 2,000 ms after failure.Use a monotonic clock for test deadlines so a paused wall clock cannot hide a hang.diff --git a/apps/libs/ci-listener/src/scale-set-listener.spec.ts b/apps/libs/ci-listener/src/scale-set-listener.spec.tsindex 352e06c4a..7eb4d9319 100644--- a/apps/libs/ci-listener/src/scale-set-listener.spec.ts+++ b/apps/libs/ci-listener/src/scale-set-listener.spec.ts@@ -500,15 +500,6 @@ for (const storage of ['sqlite', 'postgres'])])}let started = false- // These retries must keep the same execution owner while the GitHub session fails.- const retryWithSameOwner =- scenario === 'retries an offline assignment after a statless cancellation releases the other candidate' ||- scenario === 'requires spare quota to reacquire one of several ambiguous requests'- const useDefaultLease =- retryWithSameOwner ||- checksBackoff ||- checksJitRecovery ||- scenario === 'rejects a charged retry against a stale quota record'const start = (queued = true) => {const controller = new AbortController()listener = new Listener({@@ -521,12 +512,20 @@ for (const storage of ['sqlite', 'postgres'])return { limits: [{ maximum, domain: 'organization' }], checks: policyChecks }},},- timing: useDefaultLease ? { tickMs: 5 } : { tickMs: 5, leaseMs: 450 },+ timing: { tickMs: 5 },})const initial = !startedstarted = trueconst task = (async () => {if (initial && queued && !fixture.discoverCustom) await seedNotice(99999, 'boxlite')+ if (!initial) {+ // The previous listener has stopped. Allow the next owner to take over immediately.+ await database.transaction('test', async (tx) => {+ const lease = (await tx.get('@lease', true))!+ const expired = { ...lease, version: randomUUID(), payload: { until: 0 } }+ expect(await tx.put(expired, lease.version)).toBe(true)+ })+ }await listener.run(controller.signal)})()return async () => {@@ -1966,13 +1965,7 @@ for (const storage of ['sqlite', 'postgres'])expect(fixture.requests).toContain('GET /orgs/owner/actions/runner-groups/5/repositories')}await stop()- if (checksJitRecovery) {- canConfirmJit = true- await database.transaction('test', async (tx) => {- const lease = (await tx.get('@lease', true))!- expect(await tx.put({ ...lease, version: randomUUID(), payload: { until: 0 } }, lease.version)).toBe(true)- })- }+ if (checksJitRecovery) canConfirmJit = truestop = start()await until(() => fixture.sessions.length === 2)fixture.publish(1, 2)