Speed up the card-source-endpoints realm-server suite (per-module boots + template dedupe) - #6086
Open
lukemelia wants to merge 1 commit into
Open
Conversation
The card-source-endpoints suite paid a full-stack realm boot per test (clone template DB, build a Worker, boot the Realm, log in to Matrix, start a supertest server, tear down) across all 55 tests, and rebuilt a distinct template for two size-limit modules that differed only by request-time limits. Boot the three read-only modules once per module instead of once per test via `mode: 'before'`: - card source GET > public readable realm (12 tests) - card source GET > permissioned realm (4 tests) - card source HEAD > public readable realm (3 tests) Each either reads fixture files no test mutates or writes to a path unique to that test, so a shared boot stays order-independent. The harness already pairs before/after and clones the template DB once for `mode: 'before'`, so this removes ~16 per-test boots for a mechanical change. Give the .gts size-limit module the same file/audio/video limits as the binary size-limit module so both hash to one cached template (the template cache key includes the limits, which are request-time config and do not affect indexed content). The extra limits are inert for the .gts test and collapse two identical template builds into one. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_014GsYGsuCqHJz9GAti4jheG
Contributor
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
No unresolved blocking issues were identified.
Pull request overview
This pull request speeds up card-source endpoint tests by sharing read-only realm boots and deduplicating equivalent templates.
Changes:
- Uses
mode: 'before'for three read-only modules. - Reuses cached templates with aligned size limits.
File summaries
| File | Summary |
|---|---|
packages/realm-server/tests/card-source-endpoints-test.ts |
Updates test setup and size-limit template reuse. |
Review details
- Files reviewed: 1/1 changed files
- Comments generated: 0
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
tests/card-source-endpoints-test.ts(55 tests) paid a full-stack realm boot per test — clone the template Postgres DB → tmp dir + fixture copy → construct aWorker→ boot theRealm→logInToMatrix()→ build aRealmServer→ start a supertest server → tear down — because the harness default ismode: 'beforeEach'. It also built two distinct templates for size-limit modules that differ only by request-time limits.This lands the two lowest-risk, highest-impact items from CS-12935.
1.
mode: 'before'for the read-only modulesBoot once per module instead of once per test for the three modules that don't mutate shared realm state:
card source GET request › public readable realm(12 tests)card source GET request › permissioned realm(4 tests)card source HEAD request › public readable realm(3 tests)Each test either reads fixture files that no test mutates or writes to a path unique to that test, so a shared boot stays order-independent. The harness (
setupDB) already pairsbefore/afterand clones the template DB once undermode: 'before', so this is a mechanical change that removes ~16 per-test boots.2. Consolidate the two size-limit templates
public writable realm with size limitnow carries the same{file: 512, audio: 2048, video: 8192}limits aspublic writable realm with size limit for binary, so both hash to one cached template. The template cache key includes the limits, but limits are request-time config and don't affect indexed content, so the extra two are inert for the.gtstest and collapse two identical builds into one.Deferred (follow-ups from the ticket)
simplefixture lacksperson-with-error.gtsandhello.test.gtsthat the module reads, and adding them would perturb the sharedsimplefixture for other modules. Oncemode: 'before'collapses that module to a single boot, the realistic-vs-simple boot differential is paid only once, so the remaining value is small.Verification
Changes are lint-clean. End-to-end timing was intended via
scripts/measure-test-file.shper the ticket's method note, but local runs are currently blocked by an unrelated stale local dev stack; CI runs this suite against a built host and is the authoritative source for the green run and before/after shard timings. Themode: 'before'path is already exercised by existing suites, and the size-limit consolidation preserves each module's own runtime limits (only the shared template is deduped).🤖 Generated with Claude Code