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

DEBUG-3316 verify code tracking works in forked processes #4284

Merged
merged 3 commits into from
Jan 14, 2025
Merged
Show file tree
Hide file tree
Changes from 2 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
32 changes: 32 additions & 0 deletions spec/datadog/di/code_tracker_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,38 @@
expect(tracker.send(:registry)).to be_empty
end
end

context 'when process forks' do
it 'continues tracking in the fork' do
# Load rspec assertion code
expect(1).to eq(1)
expect(1).to equal(1)

expect(tracker.send(:registry)).to be_empty
tracker.start

require_relative 'code_tracker_test_class_4'
expect(tracker.send(:registry).length).to eq(1)
path = tracker.send(:registry).to_a.dig(0, 0)
expect(File.basename(path)).to eq("code_tracker_test_class_4.rb")

expect_in_fork do
expect(tracker.send(:registry).length).to eq(1)
path = tracker.send(:registry).to_a.dig(0, 0)
expect(File.basename(path)).to eq("code_tracker_test_class_4.rb")
end

begin
Process.waitpid
rescue Errno::ECHILD
p-datadog marked this conversation as resolved.
Show resolved Hide resolved
end

# Verify parent did not change
expect(tracker.send(:registry).length).to eq(1)
path = tracker.send(:registry).to_a.dig(0, 0)
expect(File.basename(path)).to eq("code_tracker_test_class_4.rb")
end
end
end

describe "#active?" do
Expand Down
2 changes: 2 additions & 0 deletions spec/datadog/di/code_tracker_test_class_4.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
class CodeTrackerTestClass4
end
2 changes: 2 additions & 0 deletions spec/datadog/di/code_tracker_test_class_5.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
class CodeTrackerTestClass5
end
Loading