gitoria

notes

All repositories: gitoria

ReadmeCodePull requestsReleasesTicketsSettings
Commitdb07aa84db07aa84tests: short-id-switch ports from env (NOTES_SWITCH_IDENT_PORT/_PORT), defaults unchangedmredb07aa84/plugins/http1/tests/ws-event-order-load.mjs

2.8 KB

  1. // ws-event-order-load.mjs — 039_http1_ws_client's events must arrive in the order they
  2. // happened under load, too (2026-10-02). Two orderings were measured broken there only
  3. // when threads get preempted: the client's `open` before the server's `connect` (fixed by
  4. // the loop's stamp order, plugin_api.zig `head_stamp_fn`), and the client's `close`
  5. // before the server's (the server queued its `close` after writing the echo: 18-25 of
  6. // 100 runs, 10 copies on 3 CPUs under HL_GC_STRESS=1). No in-process trick stalls a
  7. // plugin thread between a write and a queue, so this is the loaded repeat: the fixture
  8. // compiled --native, LANES copies at once pinned to 2 CPUs, RUNS rounds (master before the
  9. // close fix: 2-6 of the 192 out of order, 5 tries of 5; ~8 s).
  10. import { spawn, spawnSync } from 'node:child_process';
  11. import { mkdtempSync, readFileSync, rmSync } from 'node:fs';
  12. import { tmpdir } from 'node:os';
  13. import { fileURLToPath } from 'node:url';
  14. import { dirname, join, resolve } from 'node:path';
  15. const ROOT = resolve(dirname(fileURLToPath(import.meta.url)), '../../..');
  16. const BIN = resolve(ROOT, 'native/zig-out/bin/hybriel');
  17. const DIR = resolve(ROOT, 'tests/pass/plugins');
  18. const NAME = '039_http1_ws_client';
  19. const EXP = readFileSync(resolve(ROOT, `tests/expected/pass/plugins/${NAME}.txt`), 'utf8').trimEnd();
  20. const BASE = Number(process.env.HL_TEST_PORT || 14980);
  21. const LANES = Number(process.env.LANES || 16), RUNS = Number(process.env.RUNS || 12), CPUS = process.env.CPUS || '0-1';
  22. const work = mkdtempSync(join(tmpdir(), 'hl-ws-order-'));
  23. const exe = join(work, NAME);
  24. const c = spawnSync(BIN, ['--native', `${NAME}.hl`, '-o', exe, '--quiet'], { cwd: DIR, encoding: 'utf8' });
  25. if (c.status !== 0) { console.log('FAIL compile: ' + (c.stderr || c.stdout)); process.exit(1); }
  26. const once = (port) => new Promise((res) => {
  27. // one pipe for both streams, as the runner reads them: the banner is stderr
  28. const p = spawn('sh', ['-c', 'exec taskset -c "$1" "$0" 2>&1', exe, CPUS], {
  29. cwd: DIR, env: { ...process.env, HL_TEST_PORT: String(port), HL_GC_STRESS: '1', HOME: work },
  30. });
  31. let out = '';
  32. p.stdout.on('data', (d) => { out += d; });
  33. const t = setTimeout(() => p.kill('SIGKILL'), 60000);
  34. p.on('close', (code) => {
  35. clearTimeout(t);
  36. const got = out.replace(/\0/g, '').replace(new RegExp(`:${port}(?!\\d)`, 'g'), ':PORT').trimEnd();
  37. res(code === 0 && got === EXP ? null : `exit ${code}\n${got}`);
  38. });
  39. });
  40. const bad = [];
  41. for (let r = 0; r < RUNS; r++) {
  42. const outs = await Promise.all(Array.from({ length: LANES }, (_, k) => once(BASE + k)));
  43. outs.forEach((o) => { if (o) bad.push(o); });
  44. }
  45. rmSync(work, { recursive: true, force: true });
  46. if (bad.length) {
  47. console.log(`FAIL ${bad.length} of ${LANES * RUNS} runs out of order; first:\n${bad[0]}`);
  48. process.exit(1);
  49. }
  50. console.log(`ok ws-event-order-load: ${LANES * RUNS} loaded runs of ${NAME} in order`);

Branches

Latest commits

  • db07aa84tests: short-id-switch ports from env (NOTES_SWITCH_IDENT_PORT/_PORT), defaults unchangedmre
  • ef9f9feere-vendor Hybriel 6f8a0689 (int 6–11: streaming cursors, #203 index heal + close() fix, fd403 listDir/cursor fds, hl:time browser side, hl:web batches 5+6)mre
  • 5485467cdocker-compose: nofile 65536 (Hybriel int 6+ boot opened >1024 files in the tracker)mre
  • 86ea4a85deploy: backup copies index files first and *.mpack data last (hot-copy skew, hybriel #203)mre
  • edeab20fnotes mission 015: mission, report, LOG, STATUSmre
  • 542a0383notes mission 015: e2e-chrome E2E_HOST (own cookie jar in the shared Chrome)mre
  • 8b30f510notes mission 015: main-menu from layouts 0bcc629, current = true kept (route marks only /), server-HTML marker checksmre
  • 84b574c4notes mission 015: re-vendor plugins from hybriel f9614007 (incl. web, #117)mre
  • 447da53dnotes mission 014: report — remaining gates and lisbeth E2E proofmre
  • fd9f92c3notes mission 014: report (partial), LOG, STATUSmre
  • b2501360notes mission 014: open() sets asking=false before flush(0) (hybriel#196)mre
  • 9414ce59notes mission 014: merge theme 76f99f6, components 3794c59, strict single-press openAsk (fails on old open())mre
  • c08c655anotes 013: theme re-copied from layouts 76f99f6 (menu marks the current page), current = true on the menu item, e2e marker checks, reportmre
  • 21c8f65dnotes mission 012: STATUSmre
  • 0bbb3dd9notes mission 012: delete section of the browser gate de-flaked (openAsk: calm wait, press again when the question closes by itself); report 012mre
  • f431bdf8notes mission 011: notes on the layouts theme (ListFirst shell), styles cut, check-theme gate, E2E extended; reportmre
  • 1a8603d1notes mission 011 WIP: deploy.sh gate summary also matches check-theme, browser.mjs logout via the user menumre
  • dae2e508notes mission 011 WIP: theme dbe3de7, shell on AppHeader/MainMenu/UserMenu/Sidebar + ListFirst, styles cut to the app's own, check-theme gate, e2e auditmre
  • fd36da27notes mission 010: the note editor is the Hybriel MdEditor block (components.hybriel 1442e58, verbatim); md-editor.js, its route, script tag and offlineFiles retired; gate 66/0, realdata-offline 12/0, round-trip and Chrome E2E tests; report 010mre
  • efa92170notes tests/identkit.mjs: refuse a taken ident port, cold-wait deadline, emit, identities; mission 009 reportmre