CI green on a loaded shared machine: browser suites (now also glyph-ligatures and feature-fit, through the shared launch helper) in one dedicated shard started first at concurrency 2; timeouts scaled by load ÷ cores (tests/helpers/load.ts, max(1-, 5-min average), capped at 5x, logged) for browser tests, waits, launch/close, the other shards' default and the desktop boot check; one retry for a browser test that timed out while the factor was above 2, listed as 'retried under load' in the CI summary, never for an assertion failure; the six-type App Privacy walk no longer dumps every step (the --debug-dump check walks two types), wait timeouts print per-line times; play-edit-lock checks reads in flight instead of wall time; tests/load-retry.test.ts

This commit is contained in:
CRTkafa 2026-10-14 05:21:15 +08:00
parent 21fa91afd1
commit 918146d4a6
13 changed files with 261 additions and 96 deletions

View file

@ -27,7 +27,8 @@ const wait = (ms: number) => new Promise(r => setTimeout(r, ms));
function fakePlay(o: { delay?: number; replaceOnce?: string } = {}) {
const open = new Map<string, string>();
let n = 0;
const peak = { total: 0, now: 0 };
/** total / now: edits open at once; reads / reading: requests inside an edit in flight at once. */
const peak = { total: 0, now: 0, reads: 0, reading: 0 };
let replaced = false;
globalThis.fetch = (async (input: string | URL | Request, init?: RequestInit) => {
const url = String(input);
@ -42,7 +43,8 @@ function fakePlay(o: { delay?: number; replaceOnce?: string } = {}) {
return json({ id: e });
}
if (method === 'DELETE') { peak.now--; if (open.get(pkg) === id) open.delete(pkg); return json({}); }
await wait(o.delay ?? 15);
peak.reading++; peak.reads = Math.max(peak.reads, peak.reading);
try { await wait(o.delay ?? 15); } finally { peak.reading--; }
if (o.replaceOnce === pkg && !replaced) { replaced = true; open.set(pkg, `e${++n}`); } // e.g. a Console save
if (open.get(pkg) !== id) return json(DELETED, 400);
return json({ ok: rest ?? '' });
@ -80,11 +82,11 @@ describe('Play edits: one open edit per package', () => {
test('different packages still read in parallel', async () => {
const peak = fakePlay({ delay: 40 });
const pkgs = ['com.example.a', 'com.example.b', 'com.example.c'];
const started = Date.now();
const out = await Promise.all(pkgs.map(async pkg => { const p = await playClient('/nonexistent', pkg); return p.read(id => p.call<{ ok: string }>('GET', `${p.API}/edits/${id}/details`)); }));
expect(out.map(o => o.ok)).toEqual(['/details', '/details', '/details']);
expect(peak.total).toBe(3);
expect(Date.now() - started).toBeLessThan(40 * 3);
// all three reads were in flight at the same time (not the wall time: a loaded machine stretches it)
expect(peak.reads).toBe(3);
});
test('a read whose edit was deleted is redone once with a new edit', async () => {