Skip to content

Commit

Permalink
update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
p committed Jan 8, 2025
1 parent 48a8527 commit dbfdefd
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 29 deletions.
2 changes: 1 addition & 1 deletion spec/datadog/di/component_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
end

it 'returns nil' do
expect(logger).to receive(:debug).with(/Dynamic Instrumentation could not be enabled because Remote Configuration Management is not available/)
expect(logger).to receive(:warn).with(/dynamic instrumentation could not be enabled because Remote Configuration Management is not available/)
component = described_class.build(settings, agent_settings, logger)
expect(component).to be nil
end
Expand Down
2 changes: 1 addition & 1 deletion spec/datadog/di/instrumenter_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -784,7 +784,7 @@
# Needed for the cleanup unhook call.
allow(probe).to receive(:method?).and_return(false)
allow(probe).to receive(:line?).and_return(false)
allow(logger).to receive(:warn)
allow(logger).to receive(:debug)
end

it 'raises ArgumentError' do
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ def do_rc
end

it 'adds a probe to pending list' do
expect(logger).to receive(:info).with(/Received probe from RC:/)
expect(logger).to receive(:debug).with(/received probe from RC:/)

do_rc

Expand Down Expand Up @@ -272,7 +272,7 @@ def assert_received_and_installed
end

it 'instruments code and adds probe to installed list' do
expect(logger).to receive(:info).with(/Received probe from RC:/)
expect(logger).to receive(:debug).with(/received probe from RC:/)

do_rc
assert_received_and_installed
Expand All @@ -282,7 +282,7 @@ def assert_received_and_installed

context 'and target method is invoked' do
it 'notifies about execution' do
expect(logger).to receive(:info).with(/Received probe from RC:/)
expect(logger).to receive(:debug).with(/received probe from RC:/)

do_rc
assert_received_and_installed
Expand Down Expand Up @@ -325,8 +325,8 @@ def assert_received_and_installed
end

it 'installs the second, known, probe' do
expect(logger).to receive(:warn).with(/Unrecognized probe type:/)
expect(logger).to receive(:info).with(/Received probe from RC:/)
expect(logger).to receive(:debug).with(/Unrecognized probe type:/)
expect(logger).to receive(:debug).with(/received probe from RC:/)

do_rc
assert_received_and_installed
Expand Down
12 changes: 6 additions & 6 deletions spec/datadog/di/probe_manager_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,8 @@ class ProbeManagerSpecTestClass; end

context 'when there is an exception during instrumentation' do
it 'logs warning, drops probe and reraises the exception' do
expect(logger).to receive(:warn) do |msg|
expect(msg).to match(/Error processing probe configuration.*Instrumentation error/)
expect(logger).to receive(:debug) do |msg|
expect(msg).to match(/error processing probe configuration.*Instrumentation error/)
end

expect(instrumenter).to receive(:hook) do |probe_|
Expand Down Expand Up @@ -180,8 +180,8 @@ class ProbeManagerSpecTestClass; end
it 'logs warning and keeps probe in installed list' do
expect(instrumenter).to receive(:unhook).with(probe).and_raise("Deinstrumentation error")

expect(logger).to receive(:warn) do |msg|
expect(msg).to match(/Error removing probe.*Deinstrumentation error/)
expect(logger).to receive(:debug) do |msg|
expect(msg).to match(/error removing probe.*Deinstrumentation error/)
end

manager.remove_other_probes(['123'])
Expand All @@ -207,8 +207,8 @@ class ProbeManagerSpecTestClass; end
expect(instrumenter).to receive(:unhook).with(probe).and_raise("Deinstrumentation error")
expect(instrumenter).to receive(:unhook).with(probe2)

expect(logger).to receive(:warn) do |msg|
expect(msg).to match(/Error removing probe.*Deinstrumentation error/)
expect(logger).to receive(:debug) do |msg|
expect(msg).to match(/error removing probe.*Deinstrumentation error/)
end

manager.remove_other_probes(['123'])
Expand Down
32 changes: 16 additions & 16 deletions spec/datadog/di/remote_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -147,8 +147,8 @@

it 'calls probe manager to add a probe' do
expect(component).to receive(:logger).and_return(logger)
expect(logger).to receive(:info) do |message|
expect(message).to match(/Received probe/)
expect(logger).to receive(:debug) do |message|
expect(message).to match(/received probe/)
end

expect(probe_manager).to receive(:add_probe) do |probe|
Expand All @@ -165,12 +165,12 @@
it 'logs warning and consumes the exception' do
expect(component).to receive(:telemetry).and_return(telemetry)
expect(component).to receive(:logger).and_return(logger)
expect(logger).to receive(:info) do |message|
expect(message).to match(/Received probe/)
expect(logger).to receive(:debug) do |message|
expect(message).to match(/received probe/)
end

expect(logger).to receive(:warn) do |msg|
expect(msg).to match(/Unhandled exception.*Runtime error from test/)
expect(logger).to receive(:debug) do |msg|
expect(msg).to match(/unhandled exception.*Runtime error from test/)
end
expect(component).to receive(:logger).and_return(logger)
expect(telemetry).to receive(:report)
Expand All @@ -189,12 +189,12 @@
it 'calls probe manager to remove stale probes' do
allow(component).to receive(:telemetry)
expect(component).to receive(:logger).and_return(logger)
expect(logger).to receive(:info) do |message|
expect(message).to match(/Received probe/)
expect(logger).to receive(:debug) do |message|
expect(message).to match(/received probe/)
end

expect(logger).to receive(:warn) do |msg|
expect(msg).to match(/Unhandled exception.*Runtime error from test/)
expect(logger).to receive(:debug) do |msg|
expect(msg).to match(/unhandled exception.*Runtime error from test/)
end

allow(probe_manager).to receive(:add_probe).and_raise("Runtime error from test")
Expand All @@ -212,12 +212,12 @@
it 'logs warning and consumes the exception' do
expect(component).to receive(:telemetry).and_return(telemetry).at_least(:once)
expect(component).to receive(:logger).and_return(logger)
expect(logger).to receive(:info) do |message|
expect(message).to match(/Received probe/)
expect(logger).to receive(:debug) do |message|
expect(message).to match(/received probe/)
end

expect(logger).to receive(:warn) do |msg|
expect(msg).to match(/Unhandled exception.*Runtime error 1 from test/)
expect(logger).to receive(:debug) do |msg|
expect(msg).to match(/unhandled exception.*Runtime error 1 from test/)
end
expect(telemetry).to receive(:report)

Expand All @@ -228,8 +228,8 @@
expect(component).to receive(:probe_notifier_worker).and_return(probe_notifier_worker)
expect(probe_notifier_worker).to receive(:add_status)

expect(logger).to receive(:warn) do |msg|
expect(msg).to match(/Unhandled exception.*Runtime error 2 from test/)
expect(logger).to receive(:debug) do |msg|
expect(msg).to match(/unhandled exception.*Runtime error 2 from test/)
end
expect(component).to receive(:logger).and_return(logger)
expect(telemetry).to receive(:report)
Expand Down

0 comments on commit dbfdefd

Please sign in to comment.