test: fix flaky debugModeExpiresBasedOnServerTime test#165
Open
kinyoklion wants to merge 9 commits into
Open
Conversation
Add waitUntilInactive() calls after awaitRequest() in both debugModeExpires tests to ensure the flush worker has fully processed the response (including setting lastKnownPastTime) before proceeding to send the next event. Co-Authored-By: rlamb@launchdarkly.com <4955475+kinyoklion@users.noreply.github.com>
Contributor
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
Co-Authored-By: rlamb@launchdarkly.com <4955475+kinyoklion@users.noreply.github.com>
Co-Authored-By: rlamb@launchdarkly.com <4955475+kinyoklion@users.noreply.github.com>
Co-Authored-By: rlamb@launchdarkly.com <4955475+kinyoklion@users.noreply.github.com>
Co-Authored-By: rlamb@launchdarkly.com <4955475+kinyoklion@users.noreply.github.com>
Co-Authored-By: rlamb@launchdarkly.com <4955475+kinyoklion@users.noreply.github.com>
Co-Authored-By: rlamb@launchdarkly.com <4955475+kinyoklion@users.noreply.github.com>
Co-Authored-By: rlamb@launchdarkly.com <4955475+kinyoklion@users.noreply.github.com>
Co-Authored-By: rlamb@launchdarkly.com <4955475+kinyoklion@users.noreply.github.com>
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.
Requirements
Related issues
Fixes a flaky test in
DefaultEventProcessorOutputTest.Describe the solution you've provided
Added
ep.waitUntilInactive()calls afteres.awaitRequest()in bothdebugModeExpires*tests. This ensures the flush worker has fully completed processing the HTTP response — including callinghandleResponse()which setslastKnownPastTime— before the test proceeds to send the next event.Root cause
flushBlocking()only waits for the FLUSH message to be processed by the dispatcher thread, which puts the payload on the worker queue and returns.awaitRequest()returns as soon asMockEventSender.receive()adds toreceivedParams, which happens beforeSendEventsTask.run()callsresponseListener.handleResponse(result). This meanslastKnownPastTimemay not be set when the test sends the second event, causing the debug mode expiration check to use only client time (which is 19s behinddebugUntil), resulting in an unexpected debug event.Describe alternatives you've considered
Thread.sleep()afterawaitRequest()— fragile and non-deterministic.Additional context
This test has been flaking at ~6% rate across the last 100 CI runs. All observed failures show the same pattern: a
debugevent appears where only asummaryevent was expected.Link to Devin session: https://app.devin.ai/sessions/4b0d94a56a834efb9c0a758755e6653e
Requested by: @kinyoklion
Note
Low Risk
Test-only synchronization changes with no production or API impact.
Overview
Adds
ep.waitUntilInactive()after the initial flush andes.awaitRequest()indebugModeExpiresBasedOnClientTimeIfClientTimeIsLaterThanServerTimeanddebugModeExpiresBasedOnServerTimeIfServerTimeIsLaterThanClientTime.The tests were racing:
awaitRequest()could return before the flush worker ranhandleResponse()and setlastKnownPastTime, so the second feature event sometimes still emitted a debug event instead of only a summary. Waiting until the processor is inactive ties the setup step to that response handling.Reviewed by Cursor Bugbot for commit 3e2086b. Bugbot is set up for automated code reviews on this repo. Configure here.