Sha256: 399956ae52140823c7030de0ebf2672f6a853241d6bf5bc1da29a886ad2c2c48

Contents?: true

Size: 1.49 KB

Versions: 15

Compression:

Stored size: 1.49 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 'rack/test'
require 'fake_collector'
require './testing_app'
require 'multiverse_helpers'

class CrossApplicationTracingTest < MiniTest::Unit::TestCase

  # Important because the hooks are global that we only wire one AgentHooks up
  @@app = TestingApp.new
  @@wrapper_app = NewRelic::Rack::AgentHooks.new(@@app)

  include MultiverseHelpers
  setup_and_teardown_agent(:cross_process_id => "boo",
                           :encoding_key => "\0",
                           :trusted_account_ids => [1]) \
  do |collector|
    collector.stub('connect', {"agent_run_id" => 666 })
  end

  def after_setup
    @@app.reset_headers
    @@app.response = "<html><head><title>W00t!</title></head><body><p>Hello World</p></body></html>"
  end

  include Rack::Test::Methods

  def app
    @@wrapper_app
  end

  def test_cross_app_doesnt_modify_without_header
    get '/'
    assert_nil last_response.headers["X-NewRelic-App-Data"]
  end

  def test_cross_app_doesnt_modify_with_invalid_header
    get '/', nil, {'X-NewRelic-ID' => Base64.encode64('otherjunk')}
    assert_nil last_response.headers["X-NewRelic-App-Data"]
  end

  def test_cross_app_writes_out_information
    get '/', nil, {'X-NewRelic-ID' => Base64.encode64('1#234')}
    refute_nil last_response.headers["X-NewRelic-App-Data"]
    assert_metrics_recorded(['ClientApplication/1#234/all'])
  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
newrelic_rpm-3.7.2.195 test/multiverse/suites/agent_only/cross_application_tracing_test.rb
newrelic_rpm-3.7.2.192 test/multiverse/suites/agent_only/cross_application_tracing_test.rb
newrelic_rpm-3.7.2.190.beta test/multiverse/suites/agent_only/cross_application_tracing_test.rb
newrelic_rpm-3.7.1.188 test/multiverse/suites/agent_only/cross_application_tracing_test.rb
newrelic_rpm-3.7.1.182 test/multiverse/suites/agent_only/cross_application_tracing_test.rb
newrelic_rpm-3.7.1.180 test/multiverse/suites/agent_only/cross_application_tracing_test.rb
newrelic_rpm-3.7.0.177 test/multiverse/suites/agent_only/cross_application_tracing_test.rb
newrelic_rpm-3.7.0.174.beta test/multiverse/suites/agent_only/cross_application_tracing_test.rb
newrelic_rpm-3.6.9.171 test/multiverse/suites/agent_only/cross_application_tracing_test.rb
newrelic_rpm-3.6.8.168 test/multiverse/suites/agent_only/cross_application_tracing_test.rb
newrelic_rpm-3.6.8.164 test/multiverse/suites/agent_only/cross_application_tracing_test.rb
newrelic_rpm-3.6.7.159 test/multiverse/suites/agent_only/cross_application_tracing_test.rb
newrelic_rpm-3.6.7.159.beta test/multiverse/suites/agent_only/cross_application_tracing_test.rb
newrelic_rpm-3.6.7.152 test/multiverse/suites/agent_only/cross_application_tracing_test.rb
newrelic_rpm-3.6.6.147 test/multiverse/suites/agent_only/cross_application_tracing_test.rb