Skip to content

Commit

Permalink
[NO-TICKET] Switch libdatadog-crashtracking-receiver checks to wait_for
Browse files Browse the repository at this point in the history
**What does this PR do?**

This PR changes the crashtracking specs to use `wait_for` when asserting
on the `libdatadog-crashtracking-receiver` process still being alive or
not.

**Motivation:**

While experimenting with moving our test suite to GitHub Actions, this
seemed to trigger a lot.

Also, we saw it trigger at least once for CircleCI as well:
https://app.circleci.com/pipelines/github/DataDog/dd-trace-rb/15402/workflows/d3d6f9ad-7d9f-4845-9f6b-bc92eaf88b74/jobs/563014

**Additional Notes:**

Fixes DataDog/ruby-guild#176 .

I'll see if there's something we can improve on the libdatadog side
to avoid this flakiness, but let's not live with the flaky specs until
we do so.

**How to test the change?**

Validate that CI is still green.
  • Loading branch information
ivoanjo committed Jul 9, 2024
1 parent d1e5618 commit c3b70d2
Showing 1 changed file with 14 additions and 7 deletions.
21 changes: 14 additions & 7 deletions spec/datadog/profiling/crashtracker_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,13 @@
before do
skip_if_profiling_not_supported(self)

crash_tracker_pids = `pgrep -f libdatadog-crashtracking-receiver`
expect(crash_tracker_pids).to be_empty, "No crash tracker process should be running, found #{crash_tracker_pids}"
# No crash tracker process should still be running at the start of each testcase
wait_for { `pgrep -f libdatadog-crashtracking-receiver` }.to be_empty
end

after do
# No crash tracker process should still be running at the end of each testcase
wait_for { `pgrep -f libdatadog-crashtracking-receiver` }.to be_empty
end

let(:exporter_configuration) { [:agent, 'http://localhost:6006'] }
Expand Down Expand Up @@ -59,7 +64,7 @@
it 'starts the crash tracker' do
start

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

crashtracker.stop
end
Expand All @@ -68,7 +73,7 @@
it 'only starts the crash tracker once' do
3.times { crashtracker.start }

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

crashtracker.stop
end
Expand All @@ -95,13 +100,15 @@

it 'starts a second crash tracker for the fork' do
expect_in_fork do
wait_for { `pgrep -f libdatadog-crashtracking-receiver`.lines.size }.to be 1

crashtracker.reset_after_fork

expect(`pgrep -f libdatadog-crashtracking-receiver`.lines.size).to be 2
wait_for { `pgrep -f libdatadog-crashtracking-receiver`.lines.size }.to be 2

crashtracker.stop

expect(`pgrep -f libdatadog-crashtracking-receiver`.lines.size).to be 1
wait_for { `pgrep -f libdatadog-crashtracking-receiver`.lines.size }.to be 1
end
end
end
Expand All @@ -124,7 +131,7 @@

stop

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

Expand Down

0 comments on commit c3b70d2

Please sign in to comment.