gitoria

tracker

All repositories: gitoria

ReadmeCodePull requestsReleasesTicketsSettings
Commit593a6350593a6350boot: resumable start-up scan, the server listens first (T17)mre593a6350/tests/realdata-search.mjs

6.6 KB

  1. // tests/realdata-search.mjs — tracker.worldapi.org#14 REAL-DATA check of the search (NOT part of the gate): a dev server
  2. // (TRACKER_REAL_BASE, default http://127.0.0.1:8770) over a COPY of Byrodin's storage/ with the REAL TMDB (the dev .env),
  3. // a session file for the creator (az5b2) whose id is in .scratch/real-sid (STATUS.md "ticket #14" has the procedure).
  4. // Times: the page load, every keystroke → its results, "Fetch from web", an import (it WRITES — a copy only!) and the
  5. // imported show's page; screenshots 390 + 1280 into TRACKER_REAL_SHOTS (default /tmp/w052-t14/real). Run: node tests/realdata-search.mjs
  6. import { writeFileSync, readFileSync, mkdirSync } from 'node:fs';
  7. import { launchBrowser } from './cdp.mjs';
  8. process.env.HL_CHROME ||= '/opt/google/chrome/chrome';
  9. const BASE = process.env.TRACKER_REAL_BASE || 'http://127.0.0.1:8770';
  10. const OUT = process.env.TRACKER_REAL_SHOTS || '/tmp/w052-t14/real';
  11. const SID = readFileSync('.scratch/real-sid', 'utf8').trim();
  12. const [CH_FROM, CH_TO] = (process.env.TRACKER_REAL_CHROME || '8771-8772').split('-').map(Number);
  13. // a title the real data has, and one it does not (the import); override with env
  14. const HAVE = process.env.TRACKER_REAL_HAVE || 'doctor who';
  15. const WEB = process.env.TRACKER_REAL_WEB || 'severance';
  16. mkdirSync(OUT, { recursive: true });
  17. const browser = await launchBrowser({ debugPortRange: [CH_FROM, CH_TO] });
  18. const page = await browser.newPage();
  19. const ev = (e) => page.evaluate(e);
  20. await page.send('Network.enable', {});
  21. await page.send('Network.setCookie', { name: 'trackersid', value: SID, url: BASE });
  22. const hydrated = () => page.waitFor('!!window.__hl && window.__hl.socket && window.__hl.socket.readyState === 1 && document.readyState === "complete"', { timeout: 30000, label: 'hydrated' });
  23. const shot = async (n) => writeFileSync(`${OUT}/${n}.png`, Buffer.from((await page.send('Page.captureScreenshot', { format: 'png' })).data, 'base64'));
  24. const titles = () => ev(`JSON.stringify(Array.from(document.querySelectorAll('#titles .search-title')).map(a => a.textContent))`);
  25. const res = [];
  26. for (const [w, h, mobile] of [[390, 844, true], [1280, 900, false]]) {
  27. await page.send('Emulation.setDeviceMetricsOverride', { width: w, height: h, deviceScaleFactor: mobile ? 2 : 1, mobile });
  28. let t = Date.now();
  29. await page.goto(BASE + '/search');
  30. await hydrated();
  31. res.push(`${w} /search load ${Date.now() - t} ms, signed in: ${await ev(`!!document.querySelector('#logout')`)}, focused: ${await ev(`document.activeElement && document.activeElement.id`)}`);
  32. // type HAVE letter by letter, timing each keystroke until the address and the list follow it
  33. let typed = '';
  34. const per = [];
  35. for (const ch of HAVE) {
  36. typed += ch;
  37. t = Date.now();
  38. await page.type('#searchinput', ch);
  39. await page.waitFor(`location.pathname === ${JSON.stringify(typed.trim() ? '/search/' + encodeURIComponent(typed.trim()) : '/search')} && document.querySelector('search-page').getAttribute('data-for') === ${JSON.stringify(typed)}`, { timeout: 10000 });
  40. per.push(Date.now() - t);
  41. }
  42. res.push(`${w} typing "${HAVE}": per keystroke ms ${per.join(',')}; first titles ${(JSON.parse(await titles())).slice(0, 4).join(' | ')}; ${await ev(`document.querySelectorAll('search-row').length`)} rows; scrollW ${await ev('document.documentElement.scrollWidth')}`);
  43. await shot(`search-typed-${w}`);
  44. // a reload of the address opens the same results (server render)
  45. t = Date.now();
  46. await page.goto(BASE + '/search/' + encodeURIComponent(HAVE));
  47. await hydrated();
  48. res.push(`${w} reload /search/${encodeURIComponent(HAVE)} ${Date.now() - t} ms, input "${await ev(`document.querySelector('#searchinput').value`)}", ${(JSON.parse(await titles())).length} titles`);
  49. }
  50. // the web + the import, once (1280)
  51. await page.goto(BASE + '/search/' + encodeURIComponent(WEB));
  52. await hydrated();
  53. res.push(`db for "${WEB}": ${await titles()}`);
  54. let t = Date.now();
  55. await page.click('#fetchweb');
  56. await page.waitFor(`document.querySelectorAll('web-row').length > 0 || !!document.querySelector('#webnote')`, { timeout: 30000, label: 'web results' });
  57. res.push(`fetch from web "${WEB}" ${Date.now() - t} ms: ${await ev(`JSON.stringify(Array.from(document.querySelectorAll('web-row')).map(r => r.querySelector('web-title').textContent + ' [' + r.querySelector('button.add').value + ']'))`)} ${await ev(`document.querySelector('#webnote') ? document.querySelector('#webnote').textContent : ''`)}`);
  58. await page.waitFor(`Array.from(document.querySelectorAll('web-row img')).every(i => i.complete)`, { timeout: 15000 }).catch(() => {});
  59. await shot('search-web-1280');
  60. await page.send('Emulation.setDeviceMetricsOverride', { width: 390, height: 844, deviceScaleFactor: 2, mobile: true });
  61. await shot('search-web-390');
  62. await page.send('Emulation.setDeviceMetricsOverride', { width: 1280, height: 900, deviceScaleFactor: 1, mobile: false });
  63. if (process.env.TRACKER_REAL_IMPORT !== '0' && await ev(`document.querySelectorAll('web-row').length`) > 0) {
  64. const key = await ev(`document.querySelector('web-row button.add').value`);
  65. t = Date.now();
  66. await page.click(`web-row button.add[value="${key}"]`);
  67. await page.waitFor(`location.pathname.startsWith('/shows/') && !!document.querySelector('show-header h1')`, { timeout: 60000, label: 'imported show page' });
  68. res.push(`import ${key} → ${await ev('location.pathname')} in ${Date.now() - t} ms: ${await ev(`JSON.stringify({ h1: document.querySelector('show-header h1').textContent, seasons: Array.from(document.querySelectorAll('season-row')).map(r => r.querySelector('season-label').textContent + ': ' + r.querySelector('season-count').textContent).slice(0, 6), poster: document.querySelector('show-poster img') ? document.querySelector('show-poster img').getAttribute('src') : null, links: Array.from(document.querySelectorAll('a.extlink')).map(a => a.textContent) })`)}`);
  69. await page.waitFor(`!document.querySelector('show-poster img') || document.querySelector('show-poster img').complete`, { timeout: 15000 }).catch(() => {});
  70. await shot('imported-show-1280');
  71. // searched again: now in our database, and no longer in the web list
  72. await page.goto(BASE + '/search/' + encodeURIComponent(WEB));
  73. await hydrated();
  74. res.push(`after import, db for "${WEB}": ${await titles()}`);
  75. await page.click('#fetchweb');
  76. await page.waitFor(`document.querySelectorAll('web-row').length > 0 || !!document.querySelector('#webnote')`, { timeout: 30000 });
  77. res.push(`after import, web keys: ${await ev(`JSON.stringify(Array.from(document.querySelectorAll('web-row button.add')).map(b => b.value))`)} (${key} must be gone)`);
  78. }
  79. console.log(res.join('\n'));
  80. console.log('problems', JSON.stringify(page.problems()));
  81. await browser.close();

Branches

Latest commits

  • 593a6350boot: resumable start-up scan, the server listens first (T17)mre
  • be4890a0reports: H2 hydration audit (no test change needed)mre
  • 1f9c8bf4re-vendor Hybriel 5406d146 (hl:web batches 9+10: #72 emits while the socket is closed delivered after reconnect, browser boot linear, faster list appends; contains int 6–14 + m406)mre
  • c1df88eddocker-compose: HL_GC_TABLE_LOAD=62 (tracker mission 048, T16 real-data numbers)mre
  • d0a82867mission 048: report, LOG (HL_GC_TABLE_LOAD=62 measured)mre
  • 2d4be66fre-vendor Hybriel 5df4eb7e (GC: HL_GC_TABLE_LOAD knob, mission 406)mre
  • 99e7c8b9tests: realdata-m035-radii, repro-t38, realdata-060-backfill ports from env (REAL_PORT, REAL_CHROME, REPRO_CHROME), defaults unchangedmre
  • 4625aa22re-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
  • a6dfd6ecdeploy: person-lookup gate (tracker#46)mre
  • 33ad4bd5Merge commit 'f57f64f'mre
  • 7d38cec4docker-compose: nofile 65536 (default soft 1024 refused boot: errno 24 in fs.listDir, Hybriel 528bc89f)mre
  • f57f64f0mission 046: report, LOGmre
  • 5965963adeploy: backup copies index files first and *.mpack data last (hot-copy skew, hybriel #203)mre
  • efe1b485mission 046: re-vendor Hybriel master 60b2817b (integration 8, #203): plugins mpackdb + web (bin/ git-ignored: hybriel, libhlrt.a, hlc.o, hlrt/ from native/zig-out)mre
  • 53099ffbmission 046: person page reads a slim per-title credit row cache (no whole-record fetch per credit); gate tests/person-lookup.mjsmre
  • 9b3828aemission 046a: report, LOGmre
  • 4b37356emission 046: franchise seed supersedeCollections reads the curated timelines once (10 s one-tick block at the end of boot)mre
  • ac6268e3mission 046a: re-vendor Hybriel 528bc89f (integration 6): plugins mpackdb/time/web (bin/ git-ignored)mre
  • 322b3293mission 046: photoQueue guard for non-row fetch results (damaged persons index)mre
  • e5b99aecmission 046: photoQueue in slices (people.hl photoQueueStart/Step, jobs.hl photoTick), tests/photoqueue.hlmre