Skip to content

Fix flaky TestSendCustomMessagePendingError#292

Merged
andykellr merged 1 commit into
open-telemetry:mainfrom
tpaschalis:fix-custompendingmessage-flakiness
Aug 20, 2024
Merged

Fix flaky TestSendCustomMessagePendingError#292
andykellr merged 1 commit into
open-telemetry:mainfrom
tpaschalis:fix-custompendingmessage-flakiness

Conversation

@tpaschalis

@tpaschalis tpaschalis commented Jul 4, 2024

Copy link
Copy Markdown
Member

I'm not entirely sure this is the correct way to test this, so any feedback is appreciated cc @andykellr

The flake is easy to reproduce currently with go test -run=TestSendCustomMessagePendingError -count=1000 -race .

After this fix, I've given it >25k runs and didn't manage to get any failures at all.

Background

The flakiness in TestSendCustomMessagePendingError was due to the fact that the second call to SendCustomMessage was often not fast enough to trigger the condition, giving the first call to c.sender.ScheduleSend() enough time for a message to be sent and clearing the previous CustomMessage from the sender's first queued message in the process.

Solution

Without going deeper to add explicit synchronization, I think that delaying the start to the server can guarantee that no messages are sent out at the beginning, and starting it up later is stil valid for the rest of the assertions

Fixes #278

@tpaschalis
tpaschalis requested a review from a team July 4, 2024 13:10
@codecov

codecov Bot commented Jul 4, 2024

Copy link
Copy Markdown

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 76.32%. Comparing base (ed38d5f) to head (6bba093).
Report is 4 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #292   +/-   ##
=======================================
  Coverage   76.32%   76.32%           
=======================================
  Files          25       25           
  Lines        1681     1681           
=======================================
  Hits         1283     1283           
  Misses        291      291           
  Partials      107      107           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@tpaschalis

Copy link
Copy Markdown
Member Author

Any feedback here?

@tigrannajaryan
tigrannajaryan requested a review from andykellr July 22, 2024 15:24
@tpaschalis

Copy link
Copy Markdown
Member Author

cc @andykellr hey there Andy👋 sorry for the ping, but do you have any feedback on this?

@andykellr andykellr left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great, thank you for the fix!

@andykellr
andykellr merged commit 182ce37 into open-telemetry:main Aug 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

TestSendCustomMessagePendingError is unstable

2 participants