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

Improve integration testing for dynamic configuration #3012

Merged
merged 2 commits into from
Jul 28, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions spec/datadog/tracing/contrib/suite/integration_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,12 @@
Datadog.configure { |c| c.remote.poll_interval_seconds = 0.001 }
end

after { WebMock.disable! }
after do
# Ensure RC background worker is stopped before we disable webmock
# to avoid failed HTTP requests, trying to make a real remote call.
Datadog.shutdown!
Copy link
Member Author

Choose a reason for hiding this comment

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

This currently generates an error in a background thread, after the test assertions finish, because the RC worker thread tries to make an unmocked RC call after we call WebMock.disable!. This PR ensures the RC worker is closed before WebMock.disable! is called.

WebMock.disable!
end

def new_dynamic_configuration(product = 'TEST-PRODUCT', data = '', config = 'test-config', name = 'test-name')
Struct.new(:product, :data, :config, :name).new(product, data, config, name)
Expand Down Expand Up @@ -230,9 +235,8 @@ def build(*dynamic_configurations)
context 'for log_injection_enabled' do
let(:tracing_sampling_rate) { 0.0 }
let(:io) { StringIO.new }
let(:appender) { SemanticLogger.add_appender(io: io) }
let(:logger) do
appender
SemanticLogger.add_appender(io: io)
SemanticLogger['TestClass']
end

Expand All @@ -242,7 +246,7 @@ def build(*dynamic_configurations)
end
end

after { SemanticLogger.remove_appender(appender) }
after { SemanticLogger.close }

it 'changes disables log injection' do
# Before
Expand Down
Loading