Skip to content

Commit 73879c0

Browse files
authored
Merge pull request #4362 from DataDog/ivoanjo/fix-profiling-flaky-spec
[NO-TICKET] Fix flaky profiler object counting spec
2 parents 9945a09 + 8f52c60 commit 73879c0

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

spec/datadog/profiling/collectors/cpu_and_wall_time_worker_spec.rb

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1345,6 +1345,10 @@
13451345
end
13461346

13471347
it "returns different numbers of allocations for different threads" do
1348+
# GC disabled for the same reason as "returns the exact number of allocations between two calls of the method"
1349+
# spec above.
1350+
GC.disable
1351+
13481352
# To get the exact expected number of allocations, we run this once before so that Ruby can create and cache all
13491353
# it needs to
13501354
new_object = proc { Object.new }
@@ -1374,8 +1378,10 @@
13741378
# This test checks that even though we observed 100 allocations in a background thread t1, the counters for
13751379
# the current thread were not affected by this change
13761380

1377-
expect(after_t1 - before_t1).to be 100
1381+
expect(after_t1 - before_t1).to be >= 100
13781382
expect(after_allocations - before_allocations).to be < 10
1383+
ensure
1384+
GC.enable
13791385
end
13801386

13811387
context "when allocation profiling is enabled but allocation counting is disabled" do

0 commit comments

Comments
 (0)