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

Avoid *_any_instance_of when running tests with parallelism #1179

Merged

Conversation

marcotc
Copy link
Member

@marcotc marcotc commented Sep 18, 2020

Depends on #1177, for support for clean tracer shutdown/restart (merged)

Fixes flaky tests when running our tracer with JRuby, like this one.

This happens because, during testing, we collect spans from our tracer by executing allow_any_instance_of(Datadog::Tracer).to receive(:write).
This setup works fine on CRuby, but JRuby encounters a scenario where two calls to tracer.write(trace) try to be executed at the same time, but only one makes it through.

This PR changes the setup to use single object mocks, which reliability works now.

I've searched our test suite, and this is the only use of *_any_instance_of that can be affected by this issue, as it's the only one that mocks a method that can be called from multiple threads.

All our uses of *_any_instance_of in single tests do not involve concurrency, and are thus safe.

@marcotc marcotc requested a review from a team September 18, 2020 18:45
@marcotc marcotc self-assigned this Sep 18, 2020
@marcotc marcotc added the dev/testing Involves testing processes (e.g. RSpec) label Sep 18, 2020
Base automatically changed from test/fix-parallelism-with-_any_instance_of to master September 18, 2020 21:16
Copy link
Contributor

@ericmustin ericmustin left a comment

Choose a reason for hiding this comment

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

👍

@marcotc marcotc merged commit 9a5f7fa into master Sep 23, 2020
@marcotc marcotc deleted the test/fix-parallelism-with-_any_instance_of-2-the-test-part branch September 23, 2020 18:04
@marcotc marcotc added this to the 0.41.0 milestone Sep 30, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dev/testing Involves testing processes (e.g. RSpec)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants