Skip to content

Commit

Permalink
Merge pull request #712 from DataDog/ci/fix_flaky_analytics_tag_specs
Browse files Browse the repository at this point in the history
Fix analytics tag specs breaking when global state lingers
  • Loading branch information
delner authored Mar 8, 2019
2 parents 1527003 + e00665a commit f01083a
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 7 deletions.
7 changes: 6 additions & 1 deletion spec/ddtrace/contrib/delayed_job/plugin_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,12 @@ def job_data
Delayed::Worker.delay_jobs = false
end

after(:each) { Datadog.registry[:delayed_job].reset_configuration! }
around do |example|
# Reset before and after each example; don't allow global state to linger.
Datadog.registry[:delayed_job].reset_configuration!
example.run
Datadog.registry[:delayed_job].reset_configuration!
end

describe 'instrumenting worker execution' do
let(:worker) { double(:worker, name: 'worker') }
Expand Down
7 changes: 6 additions & 1 deletion spec/ddtrace/contrib/racecar/patcher_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,12 @@ def all_spans
end
end

after(:each) { Datadog.registry[:racecar].reset_configuration! }
around do |example|
# Reset before and after each example; don't allow global state to linger.
Datadog.registry[:racecar].reset_configuration!
example.run
Datadog.registry[:racecar].reset_configuration!
end

describe 'for single message processing' do
let(:topic) { 'dd_trace_test_dummy' }
Expand Down
7 changes: 6 additions & 1 deletion spec/ddtrace/contrib/rack/configuration_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,12 @@
end
end

after(:each) { Datadog.registry[:rack].reset_configuration! }
around do |example|
# Reset before and after each example; don't allow global state to linger.
Datadog.registry[:rack].reset_configuration!
example.run
Datadog.registry[:rack].reset_configuration!
end

shared_context 'an incoming HTTP request' do
subject(:response) { get '/' }
Expand Down
6 changes: 4 additions & 2 deletions spec/ddtrace/contrib/rake/instrumentation_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,10 @@
end
end

after(:each) do
# Reset configuration to defaults
around do |example|
# Reset before and after each example; don't allow global state to linger.
Datadog.registry[:rake].reset_configuration!
example.run
Datadog.registry[:rake].reset_configuration!

# We don't want instrumentation enabled during the rest of the test suite...
Expand Down
7 changes: 6 additions & 1 deletion spec/ddtrace/contrib/resque/instrumentation_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,12 @@
end
end

after(:each) { Datadog.registry[:resque].reset_configuration! }
around do |example|
# Reset before and after each example; don't allow global state to linger.
Datadog.registry[:resque].reset_configuration!
example.run
Datadog.registry[:resque].reset_configuration!
end

shared_examples 'job execution tracing' do
context 'that succeeds' do
Expand Down
7 changes: 6 additions & 1 deletion spec/ddtrace/contrib/shoryuken/tracer_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,12 @@
end
end

after { Datadog.registry[:shoryuken].reset_configuration! }
around do |example|
# Reset before and after each example; don't allow global state to linger.
Datadog.registry[:shoryuken].reset_configuration!
example.run
Datadog.registry[:shoryuken].reset_configuration!
end

shared_context 'Shoryuken::Worker' do
let(:worker_class) do
Expand Down

0 comments on commit f01083a

Please sign in to comment.