Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[PROF-9963] Add integration testing for Ruby dir interruption monkey patch #41

Merged
merged 3 commits into from
Jul 2, 2024
Merged
Show file tree
Hide file tree
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
27 changes: 27 additions & 0 deletions scenarios/ruby_dir_interruption_patch/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
FROM ruby:3.3

ENV DD_PROFILING_ENABLED true
ENV DD_PROFILING_DIR_INTERRUPTION_WORKAROUND_ENABLED true

COPY ./scenarios/ruby_dir_interruption_patch/*.rb /app/
RUN chmod 755 /app/*

WORKDIR /app
RUN bundle install

RUN wget https://github.com/ruby/spec/archive/refs/heads/master.zip -O spec-master.zip
RUN wget https://github.com/ruby/mspec/archive/refs/heads/master.zip -O mspec-master.zip
RUN unzip spec-master.zip
RUN unzip mspec-master.zip

# Since we aggressively drop permissions when running, we need to manually create a folder for rubyspec to use
RUN mkdir /app/rubyspec_temp
RUN chmod 777 /app/rubyspec_temp

# Needed by one of the ruby specs (which is testing access to home)
# @ivoanjo: Locally I get uid 1000, and in CI I'm seeing 1001. I am not sure why they differ, or if any other uids
# can show up. But, if we're missing this for an user, it'll cause the tests to fail so we definitely won't miss it.
RUN useradd -u 1000 -ms /bin/bash someuser
RUN useradd -u 1001 -ms /bin/bash someuser2

CMD bundle exec ddprofrb exec ruby mspec-master/bin/mspec-run --config mspec_config.rb spec-master/core/dir/
5 changes: 5 additions & 0 deletions scenarios/ruby_dir_interruption_patch/expected_profile.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"test_name": "ruby_dir_interruption_patch",
"stacks": [],
"note": "This test has no stacks, as it's not expected to emit profiles -- we're only testing that the mspec run is successful even when the profiler monkey patches are available."
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we catch the failure correctly if this does not run ? I think absence of pprof is enough to fail.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes -- you can actually see it failing in https://github.com/DataDog/prof-correctness/actions/runs/9758283260/job/26932502637 and then I added a ugly workaround in af8650b .

}
3 changes: 3 additions & 0 deletions scenarios/ruby_dir_interruption_patch/gems.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
source 'https://rubygems.org'

gem 'datadog', git: 'https://github.com/datadog/dd-trace-rb.git', branch: 'master'
8 changes: 8 additions & 0 deletions scenarios/ruby_dir_interruption_patch/mspec_config.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
Datadog::Profiling.wait_until_running

if Dir.ancestors.first == Datadog::Profiling::Ext::DirInstanceMonkeyPatches &&
Dir.singleton_class.ancestors.first == Datadog::Profiling::Ext::DirClassMonkeyPatches
puts "Dir interruption patch is present!"
else
raise 'Dir interruption patch is not present!'
end
Loading