Public: anyone can read this; the crew can change it.
anonymous-deep: whether the loop is behind is said by each test, never read from the process's own lag #17350
Merged 33h 38m ago, live in production
fix/anonymous-deep-lag-pin → main 0 commits
1 file
changed +9
−1
test/anonymous-deep.test.ts +9 −1
| @@ -8,7 +8,7 @@ import { commitToBranch, createRepo } from "../src/actions/repos.ts"; | ||
| 8 | 8 | import { getRepo } from "../src/core/repos.ts"; |
| 9 | 9 | import { createSession } from "../src/core/sessions.ts"; |
| 10 | 10 | import { createUser, type User } from "../src/core/users.ts"; |
| 11 | import { BEHIND_DIVISOR, STRANGER_BUDGET, finishedStrangerDeep, setCrawlClock, takeCrawl } from "../src/http/crawl.ts"; | |
| 11 | import { BEHIND_DIVISOR, STRANGER_BUDGET, finishedStrangerDeep, pinCrawlLag, setCrawlClock, takeCrawl } from "../src/http/crawl.ts"; | |
| 12 | 12 | import { notePeer } from "../src/http/peer.ts"; |
| 13 | 13 | import { serve, type Servers } from "../src/http/server.ts"; |
| 14 | 14 | import { crawlerShare, createPerfRecord } from "../src/perf/record.ts"; |
| @@ -40,6 +40,10 @@ beforeAll(async () => { | ||
| 40 | 40 | if (!c.ok) throw new Error(String(c.error)); |
| 41 | 41 | const head = Bun.spawnSync(["git", "--git-dir", join(dataDir, "repos", "alice", "open.git"), "rev-parse", "HEAD"]); |
| 42 | 42 | sha = head.stdout.toString().trim(); |
| 43 | // Whether the loop is behind is said by each test, never measured: the lag reading is the | |
| 44 | // process's, and a loaded runner's late loop divided the address budget by four in the first | |
| 45 | // test ("Expected: 200, Received: 429" on its eighth page; #17347, #17319, #17339). | |
| 46 | pinCrawlLag(app, false); | |
| 43 | 47 | }); |
| 44 | 48 | |
| 45 | 49 | afterAll(async () => { |
| @@ -74,16 +78,19 @@ test("a quiet address is still served after many noisy ones: there is no bucket | ||
| 74 | 78 | |
| 75 | 79 | test("the budget divides while the loop is behind, and the explorer's folder expansion is not counted", async () => { |
| 76 | 80 | setCrawlClock(app, () => 6_500_000, true); |
| 81 | pinCrawlLag(app, true); | |
| 77 | 82 | const deep = `/alice/open/blob/${sha}/a.txt`; |
| 78 | 83 | const allowed = Math.floor(STRANGER_BUDGET.address / BEHIND_DIVISOR); |
| 79 | 84 | for (let i = 0; i < allowed; i++) expect((await get(deep, from("10.4.0.1"))).status).toBe(200); |
| 80 | 85 | expect((await get(deep, from("10.4.0.1"))).status).toBe(429); |
| 81 | 86 | for (let i = 0; i < 40; i++) expect((await get("/alice/open/tree/main?fragment=explorer", from("10.4.0.2"))).status).toBe(200); |
| 82 | 87 | setCrawlClock(app, () => 6_500_000, false); |
| 88 | pinCrawlLag(app, false); | |
| 83 | 89 | }); |
| 84 | 90 | |
| 85 | 91 | test("while the loop is behind, strangers on many addresses share one ceiling; on time they don't; a person is never counted", async () => { |
| 86 | 92 | setCrawlClock(app, () => 7_000_000, true); |
| 93 | pinCrawlLag(app, true); | |
| 87 | 94 | const deep = `/alice/open/blob/${sha}/a.txt`; |
| 88 | 95 | for (let i = 0; i < STRANGER_BUDGET.behindAll; i++) { |
| 89 | 96 | expect((await get(deep, from(`10.3.${i >> 8}.${(i & 255) + 1}`))).status).toBe(200); |
| @@ -94,6 +101,7 @@ test("while the loop is behind, strangers on many addresses share one ceiling; o | ||
| 94 | 101 | const cookie = `forge_session=${createSession(app.db, alice.id).token}`; |
| 95 | 102 | expect((await get(deep, from("10.4.0.1", { cookie }))).status).toBe(200); |
| 96 | 103 | setCrawlClock(app, () => 7_000_000, false); |
| 104 | pinCrawlLag(app, false); | |
| 97 | 105 | expect((await get(deep, from("10.4.0.1"))).status).toBe(200); |
| 98 | 106 | }); |
| 99 | 107 |
new above
offline