Commit 8f52c60
committed
[NO-TICKET] Fix flaky profiler object counting spec
**What does this PR do?**
This PR fixes the following flaky profiler spec
(seen in
https://app.circleci.com/pipelines/github/DataDog/dd-trace-rb/19126/workflows/00361a70-d216-4fa9-9ce9-0f87e5f033f1/jobs/669239):
```
Failures:
1) Datadog::Profiling::Collectors::CpuAndWallTimeWorker._native_allocation_count when CpuAndWallTimeWorker has been started when allocation profiling and allocation counting is enabled returns different numbers of allocations for different threads
Failure/Error: expect(after_t1 - before_t1).to be 100
expected #<Integer:201> => 100
got #<Integer:217> => 108
Compared using equal?, which compares object identity,
but expected and actual are not the same object. Use
`expect(actual).to eq(expected)` if you don't care about
object identity in this example.
# ./spec/datadog/profiling/collectors/cpu_and_wall_time_worker_spec.rb:1377:in `block (5 levels) in <top (required)>'
# ./spec/spec_helper.rb:238:in `block (2 levels) in <top (required)>'
# ./spec/spec_helper.rb:123:in `block (2 levels) in <top (required)>'
# /usr/local/bundle/gems/webmock-3.23.0/lib/webmock/rspec.rb:39:in `block (2 levels) in <top (required)>'
# /usr/local/bundle/gems/rspec-wait-0.0.9/lib/rspec/wait.rb:46:in `block (2 levels) in <top (required)>'
```
We had previously debugged the same issue on another spec in
#3554 (and left a nice
comment explaining what the issue is).
I just propagated the same fix (disabling GC for the duration
of the test) to this spec as well.
**Motivation:**
Zero known flaky profiler tests!
**Additional Notes:**
In practice what happens is that we're counting how many
Ruby objects get created during the spec, but if GC gets
triggered at the exact wrong time, it may trigger other
Ruby code running, and thus more objects than expected
being allocated.
By disabling GC for this test, hopefully we're able
to keep the Ruby VM from not allocating any incidental
things in the background.
This GC counting feature is also deprecated, so in the
future we'll remove it which is even nicer :)
**How to test the change?**
Validate that CI is still green.1 parent fba70fd commit 8f52c60
File tree
1 file changed
+7
-1
lines changed- spec/datadog/profiling/collectors
1 file changed
+7
-1
lines changedLines changed: 7 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1345 | 1345 | | |
1346 | 1346 | | |
1347 | 1347 | | |
| 1348 | + | |
| 1349 | + | |
| 1350 | + | |
| 1351 | + | |
1348 | 1352 | | |
1349 | 1353 | | |
1350 | 1354 | | |
| |||
1374 | 1378 | | |
1375 | 1379 | | |
1376 | 1380 | | |
1377 | | - | |
| 1381 | + | |
1378 | 1382 | | |
| 1383 | + | |
| 1384 | + | |
1379 | 1385 | | |
1380 | 1386 | | |
1381 | 1387 | | |
| |||
0 commit comments