Skip to content

Commit

Permalink
Removing problematic crashtracker specs
Browse files Browse the repository at this point in the history
These specs are problematic in two ways:

- `pgrep` results in false positive
- the above masked the fact that `at_fork` appears to be unreliable
- some of these leak threads
  • Loading branch information
lloeki committed Oct 9, 2024
1 parent c8a2165 commit 8bc0e5e
Showing 1 changed file with 0 additions and 110 deletions.
110 changes: 0 additions & 110 deletions spec/datadog/core/crashtracking/component_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -97,13 +97,6 @@
end

context 'instance methods' do
# No crash tracker process should still be running at the start of each testcase
around do |example|
wait_for { `pgrep -f libdatadog-crashtracking-receiver` }.to be_empty
example.run
wait_for { `pgrep -f libdatadog-crashtracking-receiver` }.to be_empty
end

describe '#start' do
context 'when _native_start_or_update_on_fork raises an exception' do
it 'logs the exception' do
Expand All @@ -116,56 +109,6 @@
crashtracker.start
end
end

it 'starts the crash tracker' do
crashtracker = build_crashtracker

crashtracker.start

wait_for { `pgrep -f libdatadog-crashtracking-receiver` }.to_not be_empty

tear_down!
end

context 'when calling start multiple times in a row' do
it 'only starts the crash tracker once' do
crashtracker = build_crashtracker

3.times { crashtracker.start }

wait_for { `pgrep -f libdatadog-crashtracking-receiver`.lines.size }.to be 1

tear_down!
end
end

context 'when multiple instances' do
it 'only starts the crash tracker once' do
crashtracker = build_crashtracker
crashtracker.start

another_crashtracker = build_crashtracker
another_crashtracker.start

wait_for { `pgrep -f libdatadog-crashtracking-receiver`.lines.size }.to be 1

tear_down!
end
end

context 'when forked' do
it 'starts a second crash tracker for the fork' do
crashtracker = build_crashtracker

crashtracker.start

expect_in_fork do
wait_for { `pgrep -f libdatadog-crashtracking-receiver`.lines.size }.to be 2
end

tear_down!
end
end
end

describe '#stop' do
Expand All @@ -180,18 +123,6 @@
crashtracker.stop
end
end

it 'stops the crash tracker' do
crashtracker = build_crashtracker

crashtracker.start

wait_for { `pgrep -f libdatadog-crashtracking-receiver`.lines.size }.to eq 1

crashtracker.stop

wait_for { `pgrep -f libdatadog-crashtracking-receiver` }.to be_empty
end
end

describe '#update_on_fork' do
Expand All @@ -216,17 +147,6 @@

crashtracker.update_on_fork
end

it 'updates existing crash tracking process after started' do
crashtracker = build_crashtracker

crashtracker.start
crashtracker.update_on_fork

wait_for { `pgrep -f libdatadog-crashtracking-receiver`.lines.size }.to be 1

tear_down!
end
end

context 'integration testing' do
Expand Down Expand Up @@ -360,36 +280,6 @@
expect(crash_report_message[:os_info]).to_not be_empty
end
end

context 'when forked' do
# This integration test coverages the case that
# the callback registered with `Utils::AtForkMonkeyPatch.at_fork`
# does not contain a stale instance of the crashtracker component.
it 'ensures the latest configuration applied' do
allow(described_class).to receive(:_native_start_or_update_on_fork)

# `Datadog.configure` to trigger crashtracking component reinstantiation,
# a callback is first registered with `Utils::AtForkMonkeyPatch.at_fork`,
# but not with the second `Datadog.configure` invokation.
Datadog.configure do |c|
c.agent.host = 'example.com'
end

Datadog.configure do |c|
c.agent.host = 'google.com'
c.agent.port = 12345
end

expect_in_fork do
expect(described_class).to have_received(:_native_start_or_update_on_fork).with(
hash_including(
action: :update_on_fork,
agent_base_url: 'http://google.com:12345/',
)
)
end
end
end
end
end

Expand Down

0 comments on commit 8bc0e5e

Please sign in to comment.