test(server): replace flaky fs-watch burst e2e with FsWatcherService unit test#944
Open
tomsen-ai wants to merge 2 commits into
Open
test(server): replace flaky fs-watch burst e2e with FsWatcherService unit test#944tomsen-ai wants to merge 2 commits into
tomsen-ai wants to merge 2 commits into
Conversation
The test assumed port+1 stays free between allocation and startServer binding. Under vitest concurrency another worker can grab it, causing startServer to bind to port+2 or higher. Relax the integration assertion to check the bound port is >= port+1 and that the lock file reflects the actual bound port. The exact +1/+2 retry sequence is already covered by unit tests for listenWithPortRetry. Closes MoonshotAI#937
…unit test The e2e AC MoonshotAI#2 test created 600 files with writeFileSync and asserted that chokidar delivered >500 change events inside one 200ms debounce window. On slow or contended runners the 600 writes spanned multiple windows, so truncated:true was never emitted and the test failed. Move the truncated-burst coverage to a FsWatcherService unit test that drives a fake FSWatcher, removing the dependency on real file IO timing. Remove the flaky e2e case and renumber the remaining ACs. Closes MoonshotAI#943
|
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.
Related Issue
Resolve #943
Problem
packages/server/test/fs-watch.e2e.test.tsAC #2 ("burst > 500 changes inside 200ms window → truncated:true") was flaky under concurrent test runs.The test created 600 files with
writeFileSyncin a loop and expected chokidar to deliver more than 500 change events inside one 200ms debounce window. On slow machines or when vitest workers competed for disk IO, the 600 writes spanned multiple debounce windows, sotruncated: truewas never emitted and the assertion failed.What changed
fs-watch.e2e.test.tsand renumbered the remaining ACs.FsWatcherServiceunit test inservices.test.tsthat drives a fakeFSWatcherand asserts the truncated path:maxChangesPerWindowsynthetic events set the internal truncated flagevent.fs.changedframe withtruncated: trueand the correctcountFakeWatcherhelper withEventEmitterso it can emit chokidar events for the unit test.This preserves coverage of the truncated-burst logic while removing the dependency on real file IO timing.
Tests
pnpm --filter @moonshot-ai/server exec vitest run test/services.test.ts test/fs-watch.e2e.test.tsChecklist