Sha256: f782cd9d9867568708ba116d961108935679eeebbc6b91d3cdd501ff50431e5e

Contents?: true

Size: 1.03 KB

Versions: 21

Compression:

Stored size: 1.03 KB

Contents

class ThreadedTest < Test::Unit::TestCase
  def setup
    @original_thread_class = NewRelic::Agent::AgentThread
    swap_thread_class(FakeThread)
  end

  def teardown
    swap_thread_class(@original_thread_class)
    @original_thread_class = nil

    FakeThread.list.clear
  end

  def default_test
    # no-op to keep quiet....
  end

  private

  def swap_thread_class(klass)
    NewRelic::Agent.send(:remove_const, "AgentThread") if NewRelic::Agent.const_defined?("AgentThread")
    NewRelic::Agent.const_set("AgentThread", klass)
  end
end

class FakeThread
  @@list = []

  def initialize(locals={}, &block)
    @locals = locals
    yield if block_given?
  end

  def self.current
    {}
  end

  def self.list
    @@list
  end

  def self.bucket_thread(thread, _)
    thread[:bucket] 
  end

  def self.scrub_backtrace(thread, _)
    thread[:scrubbed_backtrace] || thread.backtrace
  end

  def key?(key)
    @locals.key?(key)
  end

  def [](key)
    @locals[key]
  end

  def backtrace
    @locals[:backtrace] || []
  end

  def join
  end
end

Version data entries

21 entries across 21 versions & 3 rubygems

Version Path
wd_newrelic_rpm-3.5.8 test/new_relic/agent/threaded_test.rb
sundawg_newrelic_rpm-3.5.8.2 test/new_relic/agent/threaded_test.rb
sundawg_newrelic_rpm-3.5.8.1 test/new_relic/agent/threaded_test.rb
newrelic_rpm-3.5.8.72 test/new_relic/agent/threaded_test.rb
newrelic_rpm-3.5.8.70 test/new_relic/agent/threaded_test.rb
newrelic_rpm-3.5.8.64.beta test/new_relic/agent/threaded_test.rb
newrelic_rpm-3.5.7.59 test/new_relic/agent/threaded_test.rb
newrelic_rpm-3.5.7.59.beta test/new_relic/agent/threaded_test.rb
newrelic_rpm-3.5.7.58.beta test/new_relic/agent/threaded_test.rb
wd_newrelic_rpm-3.5.6 test/new_relic/agent/threaded_test.rb
newrelic_rpm-3.5.7.57.beta test/new_relic/agent/threaded_test.rb
newrelic_rpm-3.5.6.55 test/new_relic/agent/threaded_test.rb
newrelic_rpm-3.5.6.48.beta test/new_relic/agent/threaded_test.rb
newrelic_rpm-3.5.6.46.beta test/new_relic/agent/threaded_test.rb
newrelic_rpm-3.5.6.42.beta test/new_relic/agent/threaded_test.rb
newrelic_rpm-3.5.5.39.beta test/new_relic/agent/threaded_test.rb
wd_newrelic_rpm-3.5.5 test/new_relic/agent/threaded_test.rb
newrelic_rpm-3.5.5.38 test/new_relic/agent/threaded_test.rb
newrelic_rpm-3.5.5.540.dev test/new_relic/agent/threaded_test.rb
newrelic_rpm-3.5.4.35.beta test/new_relic/agent/threaded_test.rb