Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix flaky TestSendCustomMessagePendingError #292

Merged

Conversation

tpaschalis
Copy link
Member

@tpaschalis tpaschalis commented Jul 4, 2024

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

Signed-off-by: Paschalis Tsilias <paschalis.tsilias@grafana.com>
@tpaschalis tpaschalis requested a review from a team July 4, 2024 13:10
Copy link

codecov bot commented Jul 4, 2024

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
Member Author

Any feedback here?

@tigrannajaryan tigrannajaryan requested a review from andykellr July 22, 2024 15:24
@tpaschalis
Copy link
Member Author

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

Copy link
Contributor

@andykellr andykellr left a comment

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
7 checks passed
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