Skip to content

Commit 4c5a873

Browse files
committed
integration test
1 parent 0cdef09 commit 4c5a873

File tree

1 file changed

+49
-8
lines changed

1 file changed

+49
-8
lines changed

spec/datadog/di/integration/everything_from_remote_config_spec.rb

+49-8
Original file line numberDiff line numberDiff line change
@@ -230,10 +230,10 @@ def target_method
230230

231231
let(:payloads) { [] }
232232

233-
def do_rc(expect_hook: true)
233+
def do_rc(expect_hook: :hook_method)
234234
expect(probe_manager).to receive(:add_probe).and_call_original
235235
if expect_hook
236-
expect(instrumenter).to receive(:hook_method).and_call_original
236+
expect(instrumenter).to receive(expect_hook).and_call_original
237237
end
238238
# Events can be batched, meaning +post+ could be called once or twice
239239
# depending on how threads are scheduled by the VM.
@@ -370,13 +370,22 @@ def assert_received_and_errored
370370
context 'line probe' do
371371
with_code_tracking
372372

373-
context 'line probe received targeting loaded code not in code tracker' do
374-
let(:probe_spec) do
375-
{id: '11', name: 'bar', type: 'LOG_PROBE', where: {
376-
sourceFile: 'instrumentation_integration_test_class.rb', lines: [22]
377-
}}
373+
shared_context 'targeting integration test class via load' do
374+
before do
375+
begin
376+
Object.send(:remove_const, :InstrumentationIntegrationTestClass)
377+
rescue
378+
nil
379+
end
380+
load File.join(File.dirname(__FILE__), 'instrumentation_integration_test_class.rb')
381+
382+
# We want the probe status to be reported, therefore need to
383+
# disable exception propagation.
384+
settings.dynamic_instrumentation.internal.propagate_all_exceptions = false
378385
end
386+
end
379387

388+
shared_context 'targeting integration test class via require' do
380389
before do
381390
begin
382391
Object.send(:remove_const, :InstrumentationIntegrationTestClass)
@@ -391,14 +400,46 @@ def assert_received_and_errored
391400
expect($LOADED_FEATURES.detect do |path|
392401
File.basename(path) == 'instrumentation_integration_test_class.rb'
393402
end).to be_truthy
394-
component.code_tracker.clear
395403

396404
# We want the probe status to be reported, therefore need to
397405
# disable exception propagation.
398406
settings.dynamic_instrumentation.internal.propagate_all_exceptions = false
399407
end
408+
end
409+
410+
context 'line probe with path containing extra prefix directories' do
411+
let(:probe_spec) do
412+
{id: '11', name: 'bar', type: 'LOG_PROBE', where: {
413+
sourceFile: 'junk/prefix/instrumentation_integration_test_class.rb', lines: [22]
414+
}}
415+
end
416+
417+
include_context 'targeting integration test class via load'
400418

401419
it 'instruments code and adds probe to installed list' do
420+
expect_lazy_log(logger, :debug, /received probe from RC:/)
421+
422+
do_rc(expect_hook: :hook_line)
423+
assert_received_and_installed
424+
425+
expect(probe_manager.installed_probes.length).to eq 1
426+
end
427+
end
428+
429+
context 'line probe received targeting loaded code not in code tracker' do
430+
let(:probe_spec) do
431+
{id: '11', name: 'bar', type: 'LOG_PROBE', where: {
432+
sourceFile: 'instrumentation_integration_test_class.rb', lines: [22]
433+
}}
434+
end
435+
436+
include_context 'targeting integration test class via require'
437+
438+
before do
439+
component.code_tracker.clear
440+
end
441+
442+
it 'marks RC payload as errored' do
402443
expect_lazy_log_many(logger, :debug,
403444
/received probe from RC:/,
404445
/error processing probe configuration:.*File matching probe path.*was loaded and is not in code tracker registry/,)

0 commit comments

Comments
 (0)