Cache realm setup for host acceptance/integration tests#4034
Cache realm setup for host acceptance/integration tests#4034
Conversation
# Conflicts: # packages/host/tests/helpers/index.gts
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 480ef88244
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| return setup(); | ||
| } | ||
| let result = await setup(); | ||
| await dbAdapter.exportSnapshot(snapshotName); |
There was a problem hiding this comment.
Detach snapshots after export to avoid attach-limit failures
withCachedRealmSetup() now writes a new snapshot for every cache miss, but each snapshot stays attached until module teardown, so distinct setup variants accumulate throughout the module. SQLite permits only 10 attached databases; modules with many setupIntegrationTestRealm variants (for example packages/host/tests/integration/realm-test.gts, which calls it many times) can hit too many attached databases before moduleDone cleanup runs. This turns the cache into a hard test failure path once enough unique keys are seen in one module.
Useful? React with 👍 / 👎.
Preview deployments |
Host Test Results 1 files ±0 1 suites ±0 1h 16m 35s ⏱️ - 29m 47s For more details on these errors, see this check. Results for commit 4677c09. ± Comparison against base commit e7401f2. |
Summary
This PR centralizes SQLite snapshot caching for host test realm setup so we get speedups across the whole host suite without requiring per-test wrapper plumbing.
What changed
SQLiteAdapter(packages/host/app/lib/sqlite-adapter.ts):exportSnapshot(snapshotName?)importSnapshot(snapshotName)hasSnapshot(snapshotName)deleteSnapshot(snapshotName)deleteSnapshotsByPrefix(prefix)SQLiteAdapter:close()packages/host/tests/helpers/index.gts:withCachedRealmSetup(...)simpleHashsetupRealmCacheTeardown(...)QUnit.moduleDone(...)so snapshots are cleaned per module and don’t grow unbounded during long runssetupAcceptanceTestRealm(...)now goes throughwithCachedRealmSetup(...)setupIntegrationTestRealm(...)now goes throughwithCachedRealmSetup(...)contents,realmURL,permissions,startMatrix) using stable serialization + hashWhy this approach
setupAcceptanceTestRealm/setupIntegrationTestRealmguarantees coverage for all current callers.Behavior impact
Notes
packages/host/tests/acceptance/host-mode-test.gts.