From 16b3c3a3fcaec353efd100f2ecebafcc34eda9c8 Mon Sep 17 00:00:00 2001 From: Ivo Anjo Date: Mon, 1 Jul 2024 09:27:18 +0100 Subject: [PATCH] Switch libdatadog-crashtracking-receiver checks to wait_for It looks like in GitHub Actions, starting/stopping the receiver can be a bit slow so let's use `wait_for` to give it some time to settle before failing. --- spec/datadog/profiling/crashtracker_spec.rb | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/spec/datadog/profiling/crashtracker_spec.rb b/spec/datadog/profiling/crashtracker_spec.rb index 59137e85efa..32030fa4180 100644 --- a/spec/datadog/profiling/crashtracker_spec.rb +++ b/spec/datadog/profiling/crashtracker_spec.rb @@ -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'] } @@ -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 @@ -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 @@ -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 @@ -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