Repository navigation
test(campaign-enrollment): give every world()-seeding case an explicit budget sized from measured runs - #2358
Merged
Conversation
…t budget sized from measured runs Each enrolment run enrols every eligible person the marketer can see, so the file's runs grow from 7 to 51 members and the last #2241 leads case ran past vitest's 5 s default on main CI twice. Measured 0.5-2.5 s alone and 0.8-4.9 s in a full local test:coverage run. Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01J8VVAjZErQs1eFzRrtWuDe
Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01J8VVAjZErQs1eFzRrtWuDe
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
Contributor
Author
席位核对Verdict: ACCEPT ·
Generated by Claude Code |
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.
Requested by Irene · project thread
Fixes #2357
Clause-②: no
Metadata-protocol: none
维护者速读
test/flow-campaign-enrollment.test.ts里 17 个会建world()的用例,每个都显式带 30 秒预算(WORLD_BUDGET_MS),不再吃 vitest 默认的 5 秒。只改测试,不发布任何东西。world()多加 2 个线索、2 个联系人,所以文件越往后入组人数越多(7 → 51)。最后那个线索用例本机全量跑要 4.9 秒,main CI 上两次超过 5 秒变红。test/flow-campaign-enrollment.test.ts第 46–58 行(预算常量和测量说明)。npx vitest run test/flow-campaign-enrollment.test.ts,预期 30 个用例全过,最慢的约 2.5 秒。What changes
test/flow-campaign-enrollment.test.ts: one constant,WORLD_BUDGET_MS = 30_000, with the measurement and the reason beside it, passed as the per-case timeout (the trailing argument, this repo's per-case convention) to every case that seeds aworld(): 13itand 4it.eachcall sites, 17 in all. The cases that seed nothing (the structural reads and the two "names no campaign" runs) keep the default..changeset/2357-campaign-enrollment-test-budget.md: an empty-frontmatter changeset, since nothing ships.skip, no globaltestTimeout. The size matchesENROLL_BUDGET_MSintest/campaign-enrollment-doors.test.ts, which is 30 s for the same growth.Why the late cases are slower than the early ones. The mechanism assumption holds: this is a slow case under load, not a hang. The cases are not equal, though. An Enroll Members run enrols every eligible person the marketer can see, not only its own world's people. Each
world()adds two eligible leads (status: 'new') and two eligible contacts (department: 'engineering'), all owned by the marketer, and every member is inserted through a per-person subflow. So the run's work grows with each case before it in the file. A probe that counted each run's member rows (a scratch copy of the file, not committed) read 7, 9, 11, 15, 17 members for the leads cases, 16 to 24 for the contacts cases, and then 46 (the #2241 contacts case) and 51 (the #2241 leads case at:438, the last enrolling run in the file). Duration tracks that count. The file's own header already says the filter "rightly enrols the eligible ones among them too", so the growth is how the fixture works, not a defect. It is bounded by the number of cases in this file, because every file boots its own stack.Tests
Per-case durations, in ms, on base
f660fd8(the change only adds timeouts, so the durations are the same on this head). "Full" is one full localvitest run --coverage(CI'spnpm run test:coverage) on a 4-core container: 239 files, 4592 passed, 1 skipped, 0 failed, about 17 minutes.world()-seeding only)The local full run passed, but the two #2241 submit cases finished 53 ms and 94 ms under the 5 s default. On main CI the leads case went past 5000 ms on
0f17c6cand on173b488(job 122642586187: "Test timed out in 5000ms",test/flow-campaign-enrollment.test.ts:424:3on that tree). 30 s is about 6× the slowest full-run reading and 12× the slowest alone.Acceptance notes
Verification
pnpm verify(validate, typecheck,lint --strict, hygiene, token ratchet, build,vitest run) on this branch, exit 0: Test Files 239 passed (239), Tests 4592 passed, 1 skipped (4593), 824 s. The changeset gained its two claim lines during that run, sopnpm hygieneandpnpm hygiene:tokenswere re-run on headcb2c9c3: "source hygiene clean", "source token ratchet clean", both exit 0.npx vitest run test/flow-campaign-enrollment.test.ts, 30 passed.Generated by Claude Code
🤖 Generated with Claude Code
https://claude.ai/code/session_01J8VVAjZErQs1eFzRrtWuDe