tracker
All repositories: gitoria
6.3 KB
// tests/warmstart.mjs — THE GATE of the progressive start (mission T17, boot time): the server listens BEFORE the start-up scan// (lib/bootscan.hl) is done. TRACKER_WARM_SYNC_MS=0 + TRACKER_WARM_HOLD_MS=4000 make the window deterministic on the fixture storage:// for 4 s after "listening" nothing is scanned. Proves, with real HTTP requests to the running server:// - during the window: `/` and `/movies` and `/search/x` answer 200 with the "starting up" note (no list), the personal pages and// /settings answer 200 without it, a short id answers 503 (Retry-After), the search face finds nothing and imports nothing// - after the log line "boot scan: done": no note anywhere, `/` lists the fixture titles, a short id answers 301, the search finds// the fixture show, the jobs started (the short-id backfill ran: "short ids done")// On the OLD code (no note, no 503) the first block fails — `TRACKER_APP_DIR=<old tree> node tests/warmstart.mjs` shows it.//// node tests/warmstart.mjs (TRACKER_GATE_PORT, default 8748)import { spawn, execFileSync } from 'node:child_process';import { mkdirSync, rmSync, writeFileSync } from 'node:fs';import { dirname, join, resolve } from 'node:path';import { fileURLToPath } from 'node:url';const HERE = dirname(fileURLToPath(import.meta.url));const APP = process.env.TRACKER_APP_DIR ? resolve(process.env.TRACKER_APP_DIR) : resolve(HERE, '..');const PORT = Number(process.env.TRACKER_GATE_PORT || 8748);const BASE = `http://127.0.0.1:${PORT}`;const SCRATCH = join(resolve(HERE, '..'), '.scratch', 'warmstart');const STORE = join(SCRATCH, 'store'), MPACKDB = join(STORE, 'mpackdb'), SESSIONS = join(SCRATCH, 'sessions');rmSync(SCRATCH, { recursive: true, force: true });mkdirSync(MPACKDB, { recursive: true }); mkdirSync(SESSIONS, { recursive: true });let failures = 0, passes = 0;const check = (label, ok, detail = '') => { console.log(`${ok ? 'ok ' : 'FAIL'} ${label}${ok ? '' : ' — ' + detail}`); if (ok) passes++; else failures++; };const sleep = (ms) => new Promise(r => setTimeout(r, ms));const get = async (path) => { const r = await fetch(BASE + path, { redirect: 'manual' }); return { status: r.status, retry: r.headers.get('retry-after'), body: await r.text() }; };const NOTE = /id="warming"/;let server, log = '';try {const seedOut = execFileSync(join(APP, 'bin/hybriel'), ['tests/seed-show.hl'], { cwd: APP, env: { ...process.env, TRACKER_STORAGE: MPACKDB } }).toString();check('seed: the fixture titles were written', seedOut.includes('gate-test-show'), seedOut);writeFileSync(join(STORE, 'old-short-ids.json'), JSON.stringify({ sh1: '100jh' }));server = spawn(join(APP, 'bin/hybriel'), ['project.hl'], { cwd: APP, env: { ...process.env, TRACKER_PORT: String(PORT), TRACKER_SESSIONS: SESSIONS + '/', TRACKER_STORAGE: MPACKDB, TRACKER_WATCH: '0',TRACKER_URL: BASE, TRACKER_SYNC: '0', TRACKER_ART: '0', TRACKER_PHOTOS: '0', TRACKER_BACKFILL: '0', TRACKER_KINDS: '0', TRACKER_COLLECTIONS: '0', TRACKER_FRANCHISE_SEED: '0', TRACKER_REPAIR: '0', TRACKER_CREDITS: '0',TRACKER_OLD_SHORT_IDS: join(STORE, 'old-short-ids.json'), TRACKER_WARM_SYNC_MS: '0', TRACKER_WARM_HOLD_MS: '4000' }, stdio: ['ignore', 'pipe', 'pipe'] });server.stdout.on('data', d => log += d); server.stderr.on('data', d => log += d);let up = false;for (let i = 0; i < 600 && !up; i++) { try { up = (await fetch(BASE + '/')).ok; } catch { await sleep(250); } }check('the server answers (a cold start compiles first)', up, log);const t0 = Date.now();// ---- the window: the server listens, the scan has not started ----const home = await get('/'), movies = await get('/movies'), search = await get('/search/gate'), show = await get('/series/gate-test-show');check('window: / answers 200 with the "starting up" note', home.status === 200 && NOTE.test(home.body) && /starting up/.test(home.body), `${home.status} ${home.body.slice(0, 200)}`);check('window: /movies, /search/<text> and a title page answer 200 with the note', [movies, search, show].every(r => r.status === 200 && NOTE.test(r.body)), JSON.stringify([movies, search, show].map(r => r.status + String(NOTE.test(r.body)))));const settings = await get('/settings'), myUnwatched = await get('/my/unwatched'), myMovies = await get('/my/movies');check('window: /settings and the personal pages answer 200 WITHOUT the note (they need none of the scan)', [settings, myUnwatched, myMovies].every(r => r.status === 200 && !NOTE.test(r.body)), JSON.stringify([settings, myUnwatched, myMovies].map(r => r.status + String(NOTE.test(r.body)))));const sid = await get('/abcde');check('window: a short id answers 503 + Retry-After (it may be one the scan has not read yet), not 404', sid.status === 503 && sid.retry === '30', `${sid.status} ${sid.retry}`);check('window: the log says the scan goes on after the server listens, no scan line yet', /boot scan: listening first/.test(log) && !/boot scan: \d+ titles/.test(log), log);// ---- after the hold: the clock scans, then everything is there ----for (let i = 0; i < 400 && !/short ids done|short ids: nothing/.test(log); i++) await sleep(100);check('the scan finished by itself, then the jobs started (log: boot scan: done … short ids done)', /boot scan: done in \d+ ms/.test(log) && /short ids done/.test(log) && Date.now() - t0 >= 3000, log);const home2 = await get('/'), movies2 = await get('/movies'), series2 = await get('/series'), found = await get('/search/gate%20test');check('after: no note on / /movies /search', [home2, movies2, found].every(r => r.status === 200 && !NOTE.test(r.body)), JSON.stringify([home2, movies2, found].map(r => r.status + String(NOTE.test(r.body)))));check('after: /series lists the fixture series, the search finds it', /Gate Test Show/.test(series2.body) && /gate-test-show/.test(found.body), JSON.stringify([/Gate Test Show/.test(series2.body), /gate-test-show/.test(found.body)]));const known = await get('/100jh');check('after: the OLD short id of the fixture show is kept and answers 301 to its page', known.status === 301, `${known.status}`);check('after: an unknown short id is a 404 again', (await get('/abcde')).status === 404);} catch (e) {check('no exception', false, String(e && e.stack || e));} finally {if (server) { server.kill('SIGTERM'); await sleep(500); }rmSync(SCRATCH, { recursive: true, force: true });}console.log(`\n${passes} passed, ${failures} failed`);process.exit(failures ? 1 : 0);
Branches
Latest commits
- e195d372Tracker: token pathsmre
- 7f541d11Tracker conductor: CONDUCTOR.md, short STATUS.md, old status + decisions archive to archive/2026-10-31mre
- 8dd423f7README: login.js stays by caramboleyo's explicit rulemre
- d8df1493tracker: standby service on port 45018 and a gap-free hand-over in deploy.sh step 4mre
- 36dd1686ident#31: the selector's sign-in returns to the page the user started on (return attribute = the login callback with next), gate checkmre
- ff9b838etracker: the Ended status pill uses the same red as layouts (pill danger); gate updatedmre
- 40d9719eTP2: LOG line and report for the tracker pillsmre
- ab3f2ba5tracker: status, genres, TMDB/IMDb/TVDB/TVmaze links and list kinds use the theme's pill; dense season list with the season check centred on its title line; gates for bothmre
- 521061d6tracker header on phones: signed in, the brand fits whole at 360 and 390 px (tighter gaps and side paddings, slightly smaller brand, narrow screens and signed in only); mobile gate checks itmre
- 18114a53tracker: franchises gate waits for the signed-out selector instead of the removed Log in buttonmre
- 08561d73ident selector back in the header (creator 2026-10-24): selector top right signed in and out on phone and desktop, no second Log in button, new gate checks (WIP: gates not re-run after the last edits)mre
- 59ef1e4atests/browser: repair 'done' check counts the 404 titles the first run already finished (race: failed=1 when Bulk Film 79 ran before the restart)mre
- 5925fc4dreports/MK-mobile.md: rebase update, gate countsmre
- 6adbc7f0extlink badges: background-clip after the background shorthand (it reset the clip: the pills were 44 px tall); gates check the lookmre
- 8d3b0f20widget: the franchise link's 44 px tap area no longer overlaps the Prequel/Sequel rowmre
- 1d98dcfdbrowser gate: the badges' size check reads the padding box (the 44 px tap area is transparent border)mre
- 2f9e29ffreports/MK-mobile.md, deploy.sh GATES: tests/mobile.mjs, theme check markermre
- 7cfc8ab5a season of more than 150 episodes starts closed on its title page; the phone gate checks itmre
- 59095c59tests/mobile.mjs: the phone gate (390 px touch, tap targets, /franchises paging)mre
- 105309detap targets: every row link, the TMDB/IMDb badges, the widget links, the franchise names and the login-failed link are 44 px high on a phonemre