Skip to content

Commit

Permalink
[NO-TICKET] Fix flaky spec in profiler due to race
Browse files Browse the repository at this point in the history
**What does this PR do?**

This PR fixes a flaky spec introduced by #3929: a spec to check that
an error was raised in a background thread implicitly depended on a race
(that the background thread ran before the rspec thread did) and thus
started failing when the race was lost.

By actually synchronizing with the background thread using the
`on_failure_proc`, we now guarantee that the background thread has
the chance to run as expected.

**Motivation:**

Our goal is to always have zero flaky specs in the profiler!

**Additional Notes:**

Fixes DataDog/ruby-guild#179

**How to test the change?**

Validate that CI is still green.
  • Loading branch information
ivoanjo committed Sep 20, 2024
1 parent 3ff7052 commit c8d5351
Showing 1 changed file with 4 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -155,8 +155,11 @@

it do
expect(Datadog.logger).to receive(:warn).with(/GVL profiling is not supported/)
proc_called = Queue.new

cpu_and_wall_time_worker.start
cpu_and_wall_time_worker.start(on_failure_proc: proc { proc_called << true })

proc_called.pop
end
end

Expand Down

0 comments on commit c8d5351

Please sign in to comment.