Skip to content

Commit

Permalink
More test fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Bill Kayser committed Feb 13, 2010
1 parent 23ef4cc commit 5a7fc36
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 4 deletions.
26 changes: 23 additions & 3 deletions test/new_relic/agent/agent_controller_test.rb
Expand Up @@ -28,8 +28,31 @@ def teardown
Thread.current[:newrelic_ignore_controller] = nil
super
NewRelic::Agent.shutdown
NewRelic::Agent::AgentTestController.clear_headers
end

def test_mongrel_queue
engine.clear_stats
NewRelic::Control.instance.local_env.stubs(:mongrel).returns( stub('mongrel', :workers => stub('workers', :list => stub('list', :length => '10'))))

get :index
assert_equal 1, stats('HttpDispatcher').call_count
assert_equal 1, engine.get_stats_no_scope('Mongrel/Queue Length').call_count
assert_equal 9, engine.get_stats_no_scope('Mongrel/Queue Length').total_call_time
assert_equal 0, engine.get_stats_no_scope('WebFrontend/Mongrel/Average Queue Time').call_count
end

def test_heroku_queue
engine.clear_stats
NewRelic::Control.instance.local_env.stubs(:mongrel).returns( stub('mongrel', :workers => stub('workers', :list => stub('list', :length => '10'))))
NewRelic::Agent::AgentTestController.set_some_headers 'HTTP_X_HEROKU_QUEUE_DEPTH'=>'15'
get :index
assert_equal 1, stats('HttpDispatcher').call_count
assert_equal 1, engine.get_stats_no_scope('Mongrel/Queue Length').call_count
assert_equal 15, engine.get_stats_no_scope('Mongrel/Queue Length').total_call_time
assert_equal 0, engine.get_stats_no_scope('WebFrontend/Mongrel/Average Queue Time').call_count

end
def test_metric__ignore
engine.clear_stats
compare_metrics [], engine.metrics
Expand All @@ -45,7 +68,6 @@ def test_controller_rescued_error
metrics = ['Apdex',
'Apdex/new_relic/agent/agent_test/action_with_error',
'HttpDispatcher',
'Controller',
'Controller/new_relic/agent/agent_test/action_with_error',
'Errors/all']

Expand All @@ -67,7 +89,6 @@ def test_controller_error
metrics = ['Apdex',
'Apdex/new_relic/agent/agent_test/action_with_error',
'HttpDispatcher',
'Controller',
'Controller/new_relic/agent/agent_test/action_with_error',
'Errors/all']

Expand All @@ -89,7 +110,6 @@ def test_filter_error
metrics = ['Apdex',
'Apdex/new_relic/agent/agent_test/action_with_before_filter_error',
'HttpDispatcher',
'Controller',
'Controller/new_relic/agent/agent_test/action_with_before_filter_error',
'Errors/all']

Expand Down
14 changes: 14 additions & 0 deletions test/new_relic/agent/net_instrumentation_test.rb
Expand Up @@ -16,6 +16,20 @@ def test_get
assert_equal %w[External/www.google.com/Net::HTTP/GET External/allOther External/www.google.com/all].sort,
@engine.metrics.sort
end

def test_background
perform_action_with_newrelic_trace("task", :category => :task) do
url = URI.parse('http://www.google.com/index.html')
res = Net::HTTP.start(url.host, url.port) {|http|
http.get('/index.html')
}
assert_match /<head>/, res.body
end
assert_equal @engine.metrics.select{|m| m =~ /^External/}.sort,
%w[External/www.google.com/Net::HTTP/GET External/allOther External/www.google.com/all
External/www.google.com/Net::HTTP/GET:OtherTransaction/Background/NewRelic::Agent::NetInstrumentationTest/task].sort
end

def test_transactional
perform_action_with_newrelic_trace("task") do
url = URI.parse('http://www.google.com/index.html')
Expand Down
2 changes: 1 addition & 1 deletion test/new_relic/agent/rpm_agent_test.rb
Expand Up @@ -35,7 +35,7 @@ def test_public_apis
ignore_called = true
nil
end
NewRelic::Agent.notice_error(ActionController::RoutingError.new("message"), :x => "y")
NewRelic::Agent.notice_error(ActionController::RoutingError.new("message"), :request_params => {:x => "y"})
assert ignore_called
NewRelic::Agent.ignore_error_filter

Expand Down

0 comments on commit 5a7fc36

Please sign in to comment.