Sha256: bdc314b4a2564c1970575c82d5bac0813c2247b1ecc76da126e6c55db9e0116b

Contents?: true

Size: 1.76 KB

Versions: 27

Compression:

Stored size: 1.76 KB

Contents

# https://newrelic.atlassian.net/browse/RUBY-765
require 'fake_collector'

class HttpResponseCodeTest < Test::Unit::TestCase
  def setup
    $collector ||= NewRelic::FakeCollector.new
    $collector.reset
    $collector.run
    NewRelic::Agent.manual_start(:send_data_on_exit => false)
    @agent = NewRelic::Agent.instance
  end

  def teardown
    $collector.reset
    NewRelic::Agent.shutdown
  end

  def test_request_entity_too_large
    $collector.mock['metric_data'] = [413, {'exception' => {'error_type' => 'RuntimeError', 'message' => 'too much'}}]

    @agent.stats_engine.get_stats_no_scope('Custom/too_big') \
      .record_data_point(1)
    assert_equal 1, @agent.stats_engine \
      .get_stats_no_scope('Custom/too_big').call_count

    @agent.send(:harvest_and_send_timeslice_data)

    # make sure the data gets thrown away without crashing
    assert_equal 0, @agent.stats_engine \
      .get_stats_no_scope('Custom/too_big').call_count

    # make sure we actually talked to the collector
    assert_equal(1, $collector.agent_data.select{|x| x.action == 'metric_data'}.size)
  end

  def test_unsupported_media_type
    $collector.mock['metric_data'] = [415, {'exception' => {'error_type' => 'RuntimeError', 'message' => 'looks bad'}}]

    @agent.stats_engine.get_stats_no_scope('Custom/too_big') \
      .record_data_point(1)
    assert_equal 1, @agent.stats_engine \
      .get_stats_no_scope('Custom/too_big').call_count

    @agent.send(:harvest_and_send_timeslice_data)

    # make sure the data gets thrown away without crashing
    assert_equal 0, @agent.stats_engine \
      .get_stats_no_scope('Custom/too_big').call_count

    # make sure we actually talked to the collector
    assert_equal(1, $collector.agent_data.select{|x| x.action == 'metric_data'}.size)
  end
end

Version data entries

27 entries across 27 versions & 4 rubygems

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