Public: anyone can read this; the crew can change it.
test/agents.test.ts: fifty concurrent pushes come back 'auth required' over the hook socket; find why and fix it, or exclude it by name #1168
Check · Review · Land · Live done — Landed and live in production.
scout/forge:scout/1056-test-agents-test-ts-fifty-concurrent-pus → main 1 commit fork
1 file
changed +10
−4
test/agents.test.ts +10 −4
| @@ -34,6 +34,7 @@ import { Gate, gitGate, runGit } from "../src/git/env.ts"; | ||
| 34 | 34 | import { quietLogs } from "./helpers/globals.ts"; |
| 35 | 35 | import { isBusy, transact } from "../src/kernel/db.ts"; |
| 36 | 36 | import { repoDir } from "../src/git/repos.ts"; |
| 37 | import { gitClientEnv } from "./helpers/git-client.ts"; | |
| 37 | 38 | |
| 38 | 39 | quietLogs(); |
| 39 | 40 | |
| @@ -170,12 +171,16 @@ describe("fifty agents at once", () => { | ||
| 170 | 171 | // through the same pre-receive path a real one takes... except that the |
| 171 | 172 | // hook only runs for a transport. So drive real ones, in parallel, over |
| 172 | 173 | // HTTP — the socket's backlog is exactly what is under test. |
| 174 | // Never inherit the host's git configuration: a crew machine carries an | |
| 175 | // http.extraHeader Authorization that beats the token in the URL, and | |
| 176 | // every push then comes back "auth required" (test/helpers/git-client.ts). | |
| 177 | const env = gitClientEnv(); | |
| 173 | 178 | const clones = await mkdtemp(join(tmpdir(), "forge-agents-push-")); |
| 174 | 179 | const remote = `${base.replace("http://", `http://cora:${token}@`)}/cora/swarm.git`; |
| 175 | 180 | |
| 176 | 181 | const clone = await Bun.spawn( |
| 177 | 182 | ["git", "clone", "--quiet", remote, join(clones, "work")], |
| 178 | { stdout: "ignore", stderr: "pipe" }, | |
| 183 | { stdout: "ignore", stderr: "pipe", env }, | |
| 179 | 184 | ); |
| 180 | 185 | expect(await clone.exited).toBe(0); |
| 181 | 186 | const work = join(clones, "work"); |
| @@ -187,9 +192,10 @@ describe("fifty agents at once", () => { | ||
| 187 | 192 | cwd: work, |
| 188 | 193 | stdout: "ignore", |
| 189 | 194 | stderr: "ignore", |
| 195 | env, | |
| 190 | 196 | }).exited; |
| 191 | 197 | await Bun.write(join(work, `agent-${i}.txt`), `work from agent ${i}\n`); |
| 192 | await Bun.spawn(["git", "add", "."], { cwd: work, stdout: "ignore" }) | |
| 198 | await Bun.spawn(["git", "add", "."], { cwd: work, stdout: "ignore", env }) | |
| 193 | 199 | .exited; |
| 194 | 200 | await Bun.spawn( |
| 195 | 201 | [ |
| @@ -203,7 +209,7 @@ describe("fifty agents at once", () => { | ||
| 203 | 209 | "-m", |
| 204 | 210 | `agent ${i}`, |
| 205 | 211 | ], |
| 206 | { cwd: work, stdout: "ignore", stderr: "ignore" }, | |
| 212 | { cwd: work, stdout: "ignore", stderr: "ignore", env }, | |
| 207 | 213 | ).exited; |
| 208 | 214 | } |
| 209 | 215 | |
| @@ -211,7 +217,7 @@ describe("fifty agents at once", () => { | ||
| 211 | 217 | Array.from({ length: WRITERS }, (_, i) => |
| 212 | 218 | Bun.spawn( |
| 213 | 219 | ["git", "push", "--quiet", "origin", `agent-${i}:agent-${i}`], |
| 214 | { cwd: work, stdout: "pipe", stderr: "pipe" }, | |
| 220 | { cwd: work, stdout: "pipe", stderr: "pipe", env }, | |
| 215 | 221 | ), |
| 216 | 222 | ).map(async (proc) => ({ |
| 217 | 223 | code: await proc.exited, |
new above
offline