gitoria

tracker

All repositories: gitoria

ReadmeCodePull requestsReleasesTicketsSettings
Commitb24cd2d5b24cd2d5log: Anton on hl:fetch, mission 569mreb24cd2d5/tests/tmdbcheck.mjs

3.1 KB

  1. // tests/tmdbcheck.mjs — tools/tmdb-check.hl against a tiny fake TMDB (mission 039, tracker#36): a dropped connection does not end the
  2. // run (asked again at the end, `failed …` line when it still fails), --from N resumes. No real token, no real TMDB.
  3. // COPY=/abs/copy/of/storage/mpackdb TOOL=tools/tmdb-check.hl PORT=8700 node tests/tmdbcheck.mjs (COPY: a copy, never live data)
  4. import http from 'node:http';
  5. import { spawn } from 'node:child_process';
  6. const PORT = Number(process.env.PORT || 8700), COPY = process.env.COPY, TOOL = process.env.TOOL || 'tools/tmdb-check.hl';
  7. if (!COPY) { console.log('set COPY'); process.exit(2); }
  8. let seen = [], dropAlways = null, dropOnce = null, onceDone = false;
  9. const server = http.createServer((req, res) => {
  10. const m = /^\/3\/(movie|tv)\/(\d+)/.exec(req.url); const id = m && m[2];
  11. seen.push(id);
  12. if (id === dropAlways || (id === dropOnce && !onceDone && (onceDone = true))) { req.socket.destroy(); return; }
  13. res.writeHead(200, { 'content-type': 'application/json' });
  14. res.end(JSON.stringify({ id: Number(id), title: 'x', name: 'x', original_title: 'x', original_name: 'x', release_date: '1999-01-01', first_air_date: '1999-01-01' }));
  15. });
  16. await new Promise(r => server.listen(PORT, '127.0.0.1', r));
  17. const run = (args) => new Promise((resolve) => {
  18. seen = []; onceDone = false; let out = '';
  19. const p = spawn('./bin/hybriel', [TOOL, ...args], { env: { ...process.env, TMDB_READ_TOKEN: 'fake-token', TMDB_BASE_URL: `http://127.0.0.1:${PORT}/3`, TRACKER_STORAGE: COPY } });
  20. p.stdout.on('data', d => out += d); p.stderr.on('data', d => out += d);
  21. p.on('close', code => resolve({ code, out, seen: [...seen] }));
  22. });
  23. let pass = 0, fail = 0;
  24. const check = (name, ok, extra = '') => { ok ? pass++ : fail++; console.log((ok ? 'PASS ' : 'FAIL ') + name + (ok ? '' : ' — ' + extra)); };
  25. const base = await run(['--limit', '6', '--all']);
  26. const ids = base.seen;
  27. check('baseline: 6 asked, exit 0', ids.length == 6 && base.code == 0, base.out.slice(-300));
  28. dropAlways = ids[1]; dropOnce = ids[2];
  29. const r1 = await run(['--limit', '6', '--all']);
  30. const cnt = (id) => r1.seen.filter(x => x === id).length;
  31. check('run goes on after dropped connections (exit 0, done line)', r1.code == 0 && /tmdb check done: asked=6/.test(r1.out), r1.out.slice(-400));
  32. check('dropped-once title asked again, then ok', cnt(ids[2]) == 2 && cnt(ids[1]) == 2 && ids.slice(3).every(i => cnt(i) == 1), JSON.stringify(r1.seen));
  33. const failedLines = r1.out.split('\n').filter(l => l.startsWith('failed '));
  34. check('exactly one `failed` line, with the reason, for the title that kept failing', failedLines.length == 1 && failedLines[0].includes('tmdb ' + ids[1] + ':') && /no answer/.test(failedLines[0]), r1.out);
  35. check('totals: clear=5 failed=1 retried=2', /clear=5 errors=0 failed=1 retried=2/.test(r1.out), r1.out.slice(-300));
  36. dropAlways = null;
  37. const r2 = await run(['--from', '4', '--limit', '2']);
  38. check('--from 4 --limit 2 asks exactly titles 5 and 6 of the same order', JSON.stringify(r2.seen) == JSON.stringify(ids.slice(4, 6)), JSON.stringify(r2.seen));
  39. server.close(); console.log(`tmdbcheck: ${pass} pass, ${fail} fail`); process.exit(fail ? 1 : 0);

Branches

Latest commits

  • b24cd2d5log: Anton on hl:fetch, mission 569mre
  • 7d42cac1log+status: SL1 measured, fetch stalls remainmre
  • 8e5f2ceflog: SL1 deployedmre
  • 29f34212log: SL1 deploy startedmre
  • 529dd741Merge sl1-slices: slice details repair and person fill (SL1)mre
  • 8a83316blog: SL1 result, session drain slowermre
  • 35e93e8dSL1: slice the details repair and person fill: catalog lists changed in place, 40 ms fill steps, people created in steps, writes one table per tickmre
  • 72c9119flog+status: SL1 startedmre
  • d74620fcmission SL1: slice repair and person fillmre
  • 5d542d73log+status: ST1 resultmre
  • 3945eb81ST1: stall diagnosis reportmre
  • 404733aclog: ST1 startedmre
  • 3e3d5a55mission ST1: stall diagnosismre
  • 9c3180eblog+status: RV28d measured after deploymre
  • fdf10b1alog: RV28d deployed on day38bmre
  • 320005e9log: RV28d merged, deploy runningmre
  • a8fef27dRV28d: reportmre
  • 2bae8373RV28d: re-vendor Hybriel set day38b (source 1e554d75, bin 5ff2a46d)mre
  • 16b3354aMerge branch 'main' into rv28cmre
  • 6f4f27d8log: RV28d started (day38b)mre