Sha256: 03e24d1147302a74c1b2e83b3b0d2ae2e9cd583752e2fdcc75a38a0105508b6a

Contents?: true

Size: 1.16 KB

Versions: 3

Compression:

Stored size: 1.16 KB

Contents

# encoding: utf-8
# This file is distributed under New Relic's license terms.
# See https://github.com/newrelic/rpm/blob/master/LICENSE for complete details.

require 'multiverse_helpers'
require 'new_relic/rack/browser_monitoring'
require 'new_relic/rack/agent_hooks'
require 'new_relic/rack/error_collector'

if NewRelic::Agent::Instrumentation::RackHelpers.rack_version_supported?

class RackEnvMutationTest < Minitest::Test
  attr_accessor :inner_app

  include MultiverseHelpers
  include Rack::Test::Methods

  setup_and_teardown_agent

  class BadApp
    def call(env)
      Thread.new do
        100.times do
          env.each do |k, v|
            # allow main thread to run while we're still in the middle of
            # iterating
            Thread.pass
          end
        end
      end

      # Give the thread we just spawned a chance to start up
      Thread.pass

      [200, {}, ['cool story']]
    end
  end

  def app
    inner_app = BadApp.new
    Rack::Builder.app do
      use NewRelic::Rack::AgentHooks
      run inner_app
    end
  end

  def test_safe_from_iterations_over_rack_env_from_background_threads
    100.times do
      get '/'
    end
  end
end

end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
newrelic_rpm-3.10.0.279 test/multiverse/suites/rack/rack_env_mutation_test.rb
newrelic_rpm-3.9.9.275 test/multiverse/suites/rack/rack_env_mutation_test.rb
newrelic_rpm-3.9.8.273 test/multiverse/suites/rack/rack_env_mutation_test.rb