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

Ensure Datadog::Statsd is loaded during test #929

Merged
merged 2 commits into from
Jan 22, 2020

Conversation

marcotc
Copy link
Member

@marcotc marcotc commented Jan 21, 2020

This PR fixes this flaky metrics_spec.rb test: https://app.circleci.com/jobs/github/DataDog/dd-trace-rb/52268

The failure happens because a few tests reference Datadog::Statsd in their before steps without ensuring that it has been loaded:

let(:custom_statsd) { instance_double(Datadog::Statsd) }

More often then not, Datadog::Statsd gets dynamically loaded by metrics.rb

require 'datadog/statsd' unless defined?(::Datadog::Statsd)

and tests run fine, but we shouldn't depend on the side-effects of other tests for a correct test run.

Because I explicitly require 'datadog/statsd' in the test file, I've added a new test to ensure that our code that dynamically loads Datadog::Statsd still works.

@marcotc marcotc added the dev/testing Involves testing processes (e.g. RSpec) label Jan 21, 2020
@marcotc marcotc requested a review from a team January 21, 2020 23:26
@marcotc marcotc self-assigned this Jan 21, 2020
@marcotc marcotc added this to the 0.32.0 milestone Jan 22, 2020
@marcotc marcotc merged commit 96e8157 into master Jan 22, 2020
@marcotc marcotc deleted the test/fix-flaky-metrics-statsd-test branch January 22, 2020 18:54
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