diff --git a/scenarios/ruby_dir_interruption_patch/Dockerfile b/scenarios/ruby_dir_interruption_patch/Dockerfile new file mode 100644 index 0000000..bbceae6 --- /dev/null +++ b/scenarios/ruby_dir_interruption_patch/Dockerfile @@ -0,0 +1,24 @@ +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) +RUN useradd -u 1000 -ms /bin/bash someuser + +CMD bundle exec ddprofrb exec ruby mspec-master/bin/mspec-run --config mspec_config.rb spec-master/core/dir/ diff --git a/scenarios/ruby_dir_interruption_patch/expected_profile.json b/scenarios/ruby_dir_interruption_patch/expected_profile.json new file mode 100644 index 0000000..48ea741 --- /dev/null +++ b/scenarios/ruby_dir_interruption_patch/expected_profile.json @@ -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." +} diff --git a/scenarios/ruby_dir_interruption_patch/gems.rb b/scenarios/ruby_dir_interruption_patch/gems.rb new file mode 100644 index 0000000..d20718e --- /dev/null +++ b/scenarios/ruby_dir_interruption_patch/gems.rb @@ -0,0 +1,3 @@ +source 'https://rubygems.org' + +gem 'datadog', git: 'https://github.com/datadog/dd-trace-rb.git', branch: 'master' diff --git a/scenarios/ruby_dir_interruption_patch/mspec_config.rb b/scenarios/ruby_dir_interruption_patch/mspec_config.rb new file mode 100644 index 0000000..a437d53 --- /dev/null +++ b/scenarios/ruby_dir_interruption_patch/mspec_config.rb @@ -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