Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1195,6 +1195,58 @@ def skip_if_signal_handler_sampling_not_supported
end
end

context "GC stress enabled integration test", :memcheck_valgrind_skip do
before do
unless ENV["DATADOG_GEM_CI"] == "true"
Comment thread
ivoanjo marked this conversation as resolved.
Comment thread
ivoanjo marked this conversation as resolved.
skip "Test is slow so we only run it with DATADOG_GEM_CI=true"
end
end

# Make sure the profiler doesn't skip samples during GC.stress
let(:options) { {dynamic_sampling_rate_enabled: false} }
let(:allocation_profiling_enabled) { true }
let(:allocation_counting_enabled) { true }
let(:heap_profiling_enabled) { RubyVersion.is?(">= 3.1") }
let(:gvl_profiling_enabled) { RubyVersion.is?(">= 3.2") }
let(:sighandler_sampling_enabled) do
!(RubyVersion.is?("< 3.2.5") || RubyVersion.is?(">= 3.3", "< 3.3.4"))
end

it "runs the profiler successfully" do
on_failure_proc_called = false
cpu_and_wall_time_worker # pre-create instances before enabling stress

GC.stress = true
begin
cpu_and_wall_time_worker.start(on_failure_proc: proc { on_failure_proc_called = true })
cpu_and_wall_time_worker.wait_until_running(timeout_seconds: 30)

10.times { |i| i.to_s }
recorder.serialize!
10.times { |i| i.to_s }

cpu_and_wall_time_worker.stop
profile = recorder.serialize!
ensure
GC.stress = false
end

expect(on_failure_proc_called).to(
be(false),
-> {
failure_exception = cpu_and_wall_time_worker.send(:failure_exception)
"Profiler failed to run cleanly, failure_exception: #{failure_exception.inspect}\n" \
"#{failure_exception&.backtrace&.join("\n")}"
}
)

samples = samples_from_pprof(profile).select do |sample|
sample.locations.any? { |location| location.path == __FILE__ }
end
expect(samples.map(&:values)).to include(include("alloc-samples": be > 0))
end
end

context "when the _native_sampling_loop terminates with an exception" do
it "calls the on_failure_proc" do
expect(described_class).to receive(:_native_sampling_loop).and_raise(StandardError.new("Simulated error"))
Expand Down
Loading