Sha256: 35d8b243339390ad116deb427870c5b6151936090e36a939b54d0c3642d0faf8

Contents?: true

Size: 1.18 KB

Versions: 17

Compression:

Stored size: 1.18 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.

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

17 entries across 17 versions & 1 rubygems

Version Path
newrelic_rpm-3.6.5.130 test/new_relic/agent/threaded_test.rb
newrelic_rpm-3.6.4.122 test/new_relic/agent/threaded_test.rb
newrelic_rpm-3.6.4.113.beta test/new_relic/agent/threaded_test.rb
newrelic_rpm-3.6.3.111 test/new_relic/agent/threaded_test.rb
newrelic_rpm-3.6.3.106 test/new_relic/agent/threaded_test.rb
newrelic_rpm-3.6.3.105.beta test/new_relic/agent/threaded_test.rb
newrelic_rpm-3.6.3.104 test/new_relic/agent/threaded_test.rb
newrelic_rpm-3.6.3.103.beta test/new_relic/agent/threaded_test.rb
newrelic_rpm-3.6.2.96 test/new_relic/agent/threaded_test.rb
newrelic_rpm-3.6.2.90.beta test/new_relic/agent/threaded_test.rb
newrelic_rpm-3.6.1.88 test/new_relic/agent/threaded_test.rb
newrelic_rpm-3.6.1.87 test/new_relic/agent/threaded_test.rb
newrelic_rpm-3.6.1.86.beta test/new_relic/agent/threaded_test.rb
newrelic_rpm-3.6.1.85.beta test/new_relic/agent/threaded_test.rb
newrelic_rpm-3.6.0.83 test/new_relic/agent/threaded_test.rb
newrelic_rpm-3.6.0.78 test/new_relic/agent/threaded_test.rb
newrelic_rpm-3.6.0.74.beta test/new_relic/agent/threaded_test.rb