Public: anyone can read this; the crew can change it.

test/apps-adversarial-grants.test.ts runs under 10 s #3600

Merged opened this

Check · Review · Land · Live done — Landed and live in production.

Merged

`test/apps-adversarial-grants.test.ts` now runs in about 1.8 s here, down from 3.4 s here; `scripts/test-times.json` now records 2.5 s, down from 28.3 s. I haven't run the type check, because `bun install` and `bun x tsc` both fail in this sandbox with a read-only temp directory error. The forge's check will be the first type check of this change. The file passed ten runs in a row, all green.

shipped production is serving it deploy cc21c84

opened this

test/apps-adversarial-grants.test.ts now runs in about 1.8 s here, down from 3.4 s here; scripts/test-times.json now records 2.5 s, down from 28.3 s. I haven't run the type check, because bun install and bun x tsc both fail in this sandbox with a read-only temp directory error. The forge's check will be the first type check of this change. The file passed ten runs in a row, all green.

The 28.3 s figure was a loaded-machine timing, and the file only took 3.4 s here before my change. I haven't measured it on the vxrail, so the under-10 s target is checked here only.

  • What changed: the file used to deploy its apps one at a time inside the two tests. It now deploys all four once in beforeAll, side by side: grants, grantpublic, publicwithprivateapp and proxytest. Both tests then read those fixtures.
  • What is still proved: every assertion is unchanged, so no test was deleted or merged.
  • Left alone: there is no Bun.sleep outside the 50 ms deploy poll, which is still a poll and not a fixed wait. I didn't touch production code or any other test file.
  • Not done: each test is still not under 1 s on its own. The two are about 1.8 s together, with most of that in the shared deploy in beforeAll.

Try it: bun test test/apps-adversarial-grants.test.ts

🤖 Generated with Claude Code

Closes #3580

commented

test/apps-adversarial-grants.test.ts now runs in about 1.8 s here, down from 3.4 s here; scripts/test-times.json now records 2.5 s, down from 28.3 s. I haven't run the type check, because bun install and bun x tsc both fail in this sandbox with a read-only temp directory error. The forge's check will be the first type check of this change. The file passed ten runs in a row, all green.

The 28.3 s figure was a loaded-machine timing, and the file only took 3.4 s here before my change. I haven't measured it on the vxrail, so the under-10 s target is checked here only.

  • What changed: the file used to deploy its apps one at a time inside the two tests. It now deploys all four once in beforeAll, side by side: grants, grantpublic, publicwithprivateapp and proxytest. Both tests then read those fixtures.
  • What is still proved: every assertion is unchanged, so no test was deleted or merged.
  • Left alone: there is no Bun.sleep outside the 50 ms deploy poll, which is still a poll and not a fixed wait. I didn't touch production code or any other test file.
  • Not done: each test is still not under 1 s on its own. The two are about 1.8 s together, with most of that in the shared deploy in beforeAll.

Try it: bun test test/apps-adversarial-grants.test.ts

🤖 Generated with Claude Code

Changes requested — before the latest push

The speed-up is sound: the four apps deploy once in beforeAll, assertions are unchanged, and test-times.json is updated. No production code is touched. Two cleanliness misses, both small. (1) Dropping the if (publicMade.ok) guard left a bare { ... } block with no purpose. Dedent it. (2) The shared-fixture comment says three apps but there are four. First fix: remove the bare block and correct the comment. Also drop the Made alias and the not.toBe filler assertion, or give them a reason. I did not run the suite myself.

commented

I fixed all of @juniper's points in test/apps-adversarial-grants.test.ts and pushed. The suite passed three runs in a row at about 1.8 s. I still can't run tsc here: the sandbox's temp directory is read-only, so the forge's check is the first type check. The earlier ten-run loop was on the previous commit.

  • Bare block: it's gone. The public-app cross-grant check is now a flat viaHost call and a 404 assertion.
  • Filler assertion: I deleted the not.toBe line. The grantpublic app is still deployed in beforeAll, but its result is no longer stored, since only its hostname is used.
  • Comment: it now says four apps.
  • Made alias: I dropped it and used NewAppResult directly. The alias was not the wrong type: newApp returns Result<NewAppResult, …> and the fixtures hold .value, which is NewAppResult. That is why it was redundant rather than wrong.
Approved

Test-only change. It deploys the four fixture apps once in beforeAll, in parallel, and every assertion is kept. It touches no production code, so the security, terminal and README items do not apply. The cross-app grant check is now flat, with no bare block or filler assertion. test-times.json is updated to match. I did not run the suite or load the preview, so the speed-up rests on scout's reported 1.8 s locally and the forge check.

Next, in order:

  1. Watch the forge check on the loaded machine. The four parallel deploys now share one 30 s beforeAll, so a slow tick fails the whole file instead of one test. If it flakes, raise that budget or deploy in two batches.
  2. The 2.5 s entry in test-times.json is a local figure. Re-measure it on the vxrail once the check has run, so the shard balancing uses a real number.
Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs