Sha256: 9197d57c19af8ad92f4a07c03647e642ce341ea6fadddace891c9a94a04363f6

Contents?: true

Size: 1.81 KB

Versions: 36

Compression:

Stored size: 1.81 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 File.expand_path(File.join(File.dirname(__FILE__),'..', 'test_helper'))

# Test logic around detecting or configuring dispatcher
class DispatcherTest < Minitest::Test

  def setup
    NewRelic::Agent.shutdown
    NewRelic::Agent.reset_config
  end

  def teardown
    NewRelic::Agent.reset_config
    NewRelic::Control.reset
  end

  def assert_dispatcher_reported_to_environment_report(dispatcher)
    assert_equal dispatcher.to_s, NewRelic::EnvironmentReport.new["Dispatcher"]
  end

  def test_detects_dispatcher_via_loaded_libraries
    class << self
      module ::PhusionPassenger
      end
    end
    assert_equal :passenger, NewRelic::Agent.config[:dispatcher]
    assert_dispatcher_reported_to_environment_report :passenger
  ensure
    Object.send(:remove_const, :PhusionPassenger)
  end

  def test_detects_dispatcher_via_ENV_NEW_RELIC_DISPATCHER
    ENV['NEW_RELIC_DISPATCHER'] = "foobared"
    NewRelic::Agent.reset_config
    assert_equal :foobared, NewRelic::Agent.config[:dispatcher]
    assert_dispatcher_reported_to_environment_report :foobared
  ensure
    ENV['NEW_RELIC_DISPATCHER'] = nil
  end

  def test_detects_dispatcher_via_ENV_NEWRELIC_DISPATCHER
    ENV['NEWRELIC_DISPATCHER'] = "bazbang"
    NewRelic::Agent.reset_config
    assert_equal :bazbang, NewRelic::Agent.config[:dispatcher]
    assert_dispatcher_reported_to_environment_report :bazbang
  ensure
    ENV['NEWRELIC_DISPATCHER'] = nil
  end

  def test_detects_dispatcher_based_on_arguments_to_manual_start
    NewRelic::Agent.manual_start(:dispatcher   => :resque)
    assert_equal :resque, NewRelic::Agent.config[:dispatcher]
    assert_dispatcher_reported_to_environment_report :resque
  end

end

Version data entries

36 entries across 36 versions & 2 rubygems

Version Path
newrelic_rpm-3.17.2.327 test/new_relic/dispatcher_test.rb
newrelic_rpm-3.17.1.326 test/new_relic/dispatcher_test.rb
newrelic_rpm-3.17.0.325 test/new_relic/dispatcher_test.rb
newrelic_rpm-3.16.3.323 test/new_relic/dispatcher_test.rb
newrelic_rpm-3.16.2.321 test/new_relic/dispatcher_test.rb
newrelic_rpm-3.16.1.320 test/new_relic/dispatcher_test.rb
newrelic_rpm-3.16.0.318 test/new_relic/dispatcher_test.rb
ish_lib_manager-0.0.1 test/dummy/vendor/bundle/ruby/2.3.0/gems/newrelic_rpm-3.15.2.317/test/new_relic/dispatcher_test.rb
newrelic_rpm-3.15.2.317 test/new_relic/dispatcher_test.rb
newrelic_rpm-3.15.1.316 test/new_relic/dispatcher_test.rb
newrelic_rpm-3.15.0.314 test/new_relic/dispatcher_test.rb
newrelic_rpm-3.14.3.313 test/new_relic/dispatcher_test.rb
newrelic_rpm-3.14.2.312 test/new_relic/dispatcher_test.rb
newrelic_rpm-3.14.1.311 test/new_relic/dispatcher_test.rb
newrelic_rpm-3.14.0.305 test/new_relic/dispatcher_test.rb
newrelic_rpm-3.13.2.302 test/new_relic/dispatcher_test.rb
newrelic_rpm-3.13.1.300 test/new_relic/dispatcher_test.rb
newrelic_rpm-3.13.0.299 test/new_relic/dispatcher_test.rb
newrelic_rpm-3.12.1.298 test/new_relic/dispatcher_test.rb
newrelic_rpm-3.12.0.288 test/new_relic/dispatcher_test.rb