Medlar/docs/tests/S048-server-farms.md
2026-11-26 17:36:34 -06:00

4.4 KiB

S048 — Servers behind a load balancer with different validators: test file

Written by the worker that built it, run in the same session (Phase: test). Results say what was seen.

Built

  • crates/core/src/http/mod.rs · Validators::maybe_same: equal known sizes, nginx tags W/"<size hex>-<mtime hex>" agree on the size part; Source::web (HTTP only).
  • crates/core/src/http/fetch.rs · Farm per link: versions proven to have the same bytes, one known 64 KiB sample; send_range sends no If-Range on a farm, 200 on a farm is RangeIgnored; sure_range and prove compare bytes before anything of an unsure reply is written.
  • crates/core/src/http/download.rs · probe and resume accept a same-size reply (HTTP only), seed the sample from disk, store task.farm once proven.
  • crates/core/src/store/007.sql · tasks.farm column; crates/core/src/model.rs Task::farm.
  • crates/testserver · farm=N (N nodes in turn, own Last-Modified and nginx ETag) and liar=1 (odd nodes other bytes, same size).
  • Tests: crates/core/tests/farm.rs, unit farm_versions in http/mod.rs.

Checks

# Risk Do this Expect How Result
1 HIGH Download 8 MB from farm=3, throttle 1 MB/s per connection Right SHA-256, at least 3 parts at different starts, task.farm true integration (a_farm_downloads_in_parts) pass (3 starts seen in most runs, 4 in some)
2 HIGH Stop a farm download when every part has bytes, resume with the farm flag stored Right hash, first ETag/Last-Modified kept, no If-Range sent integration (a_farm_goes_on_after_a_stop) fixed (proof flake: prove now ends when another part proved the version), then 15/15
3 HIGH Same as 2 with the flag cleared before resuming Right hash; farm found again by bytes or not needed integration fixed, then pass
4 HIGH Fresh download from farm=2&liar=1 Changed with task.farm false, or a file wholly of one version; never mixed integration (a_liar_of_the_same_size_is_another_file) pass
5 HIGH Half an honest farm download, then switch to liar mode and resume Changed; finished bytes untouched and equal to the right content integration (a_liar_on_the_way_keeps_what_is_there) pass
6 HIGH Tags differing after the size part; other size; other size in tag; opaque tags; unknown size maybe same / no / no / maybe / no unit (farm_versions) pass
7 HIGH FTP file with a new mtime, same size, resumed Still Changed (farm rule is HTTP only) integration (ftp_resumes) fixed (rule had leaked to FTP)
8 HIGH Old store opened Migration 007 adds farm = 0 integration (store tests in suite) pass
9 MED Full workspace suite, absolute TMPDIR All green cargo test --no-fail-fast 35 targets ok; relink pause/resume race passed on rerun; control::connector_flood_15 fails (40 ok, 0 busy): connector untouched by S048, KNOWN BUG, timing of the rate gate
10 MED Release build, hidden run (spare port 17998, testserver 18431, throwaway home), POST a 64 MB farm=3 link Done, hash equal to the plain file, tasks.farm = 1 by hand (tools/hidden.sh) pass: hash 0095b3fa…, farm 1, list shows Done
11 LOW Same hidden run: CPU 1 s after done 0 % when idle by hand not run cleanly: 160 % measured 1 s after done (graph still moving or finishing); idle not measured later
12 MED tools/package.sh 0.1.1 AppImage, tar.gz, Arch package, SHA256SUMS; checksums verify by hand pass (PKGBUILD tar.gz hash updated); the packaged builds were not launched

Needs

crates/testserver on 127.0.0.1 only. Spare ports 17998/18431 and a throwaway home for hidden runs. Never romsgames.net or any real site; never the user's Medlar on 17616 or ~/.local/share/medlar.

Doubts

  • A sticky load balancer that never again shows the probe's node at a fresh start: parts are accepted only for proven versions, which needs one sure reply to compare against; PROOF_TRIES (12) may be too few on a big farm.
  • Proof compares 64 KiB at one place. A same-size different file that matches there would be taken as the same; the plan accepts this.
  • Without the stored flag a resumed task may finish without re-proving the farm (the flag then stays false).
  • connector_flood_15 and the 160 % CPU right after done were not investigated (outside the plan).
  • Never tried against a real farm.