newrelic_rpm 3.6.6.147 → 3.6.7.152
Sign up to get free protection for your applications and to get access to all the features.
- data.tar.gz.sig +0 -0
- data/.gitignore +0 -1
- data/CHANGELOG +55 -17
- data/Guardfile +7 -0
- data/Rakefile +6 -0
- data/bin/mongrel_rpm +33 -0
- data/bin/newrelic +13 -0
- data/bin/newrelic_cmd +5 -0
- data/bin/nrdebug +273 -0
- data/install.rb +3 -3
- data/lib/new_relic/agent.rb +4 -6
- data/lib/new_relic/agent/agent.rb +76 -72
- data/lib/new_relic/agent/autostart.rb +18 -5
- data/lib/new_relic/agent/browser_monitoring.rb +41 -35
- data/lib/new_relic/agent/browser_token.rb +38 -0
- data/lib/new_relic/agent/busy_calculator.rb +7 -5
- data/lib/new_relic/agent/commands/agent_command.rb +19 -0
- data/lib/new_relic/agent/commands/agent_command_router.rb +88 -0
- data/lib/new_relic/agent/commands/thread_profiler.rb +80 -0
- data/lib/new_relic/agent/configuration/default_source.rb +700 -0
- data/lib/new_relic/agent/configuration/environment_source.rb +83 -30
- data/lib/new_relic/agent/configuration/manager.rb +8 -8
- data/lib/new_relic/agent/configuration/mask_defaults.rb +2 -2
- data/lib/new_relic/agent/cross_app_monitor.rb +10 -21
- data/lib/new_relic/agent/cross_app_tracing.rb +3 -3
- data/lib/new_relic/agent/error_collector.rb +7 -10
- data/lib/new_relic/agent/http_clients/curb_wrappers.rb +1 -1
- data/lib/new_relic/agent/http_clients/excon_wrappers.rb +5 -1
- data/lib/new_relic/agent/http_clients/httpclient_wrappers.rb +5 -1
- data/lib/new_relic/agent/http_clients/net_http_wrappers.rb +5 -1
- data/lib/new_relic/agent/http_clients/typhoeus_wrappers.rb +1 -1
- data/lib/new_relic/agent/instrumentation/action_controller_subscriber.rb +5 -12
- data/lib/new_relic/agent/instrumentation/action_view_subscriber.rb +4 -0
- data/lib/new_relic/agent/instrumentation/{rails4/active_record.rb → active_record_4.rb} +1 -1
- data/lib/new_relic/agent/instrumentation/active_record_subscriber.rb +11 -11
- data/lib/new_relic/agent/instrumentation/authlogic.rb +8 -6
- data/lib/new_relic/agent/instrumentation/controller_instrumentation.rb +12 -6
- data/lib/new_relic/agent/instrumentation/curb.rb +11 -2
- data/lib/new_relic/agent/instrumentation/delayed_job_instrumentation.rb +1 -3
- data/lib/new_relic/agent/instrumentation/evented_subscriber.rb +11 -2
- data/lib/new_relic/agent/instrumentation/excon/middleware.rb +13 -4
- data/lib/new_relic/agent/instrumentation/puma.rb +2 -1
- data/lib/new_relic/agent/instrumentation/rack.rb +15 -17
- data/lib/new_relic/agent/method_tracer.rb +181 -191
- data/lib/new_relic/agent/new_relic_service.rb +16 -14
- data/lib/new_relic/agent/pipe_channel_manager.rb +1 -1
- data/lib/new_relic/agent/request_sampler.rb +32 -165
- data/lib/new_relic/agent/sampled_buffer.rb +79 -0
- data/lib/new_relic/agent/samplers/delayed_job_sampler.rb +1 -8
- data/lib/new_relic/agent/sql_sampler.rb +3 -3
- data/lib/new_relic/agent/stats_engine.rb +1 -1
- data/lib/new_relic/agent/stats_engine/gc_profiler.rb +1 -1
- data/lib/new_relic/agent/stats_engine/metric_stats.rb +2 -3
- data/lib/new_relic/agent/stats_engine/transactions.rb +2 -22
- data/lib/new_relic/agent/threading/agent_thread.rb +41 -0
- data/lib/new_relic/agent/threading/backtrace_node.rb +71 -0
- data/lib/new_relic/agent/threading/thread_profile.rb +172 -0
- data/lib/new_relic/agent/transaction.rb +16 -4
- data/lib/new_relic/agent/transaction_sample_builder.rb +13 -3
- data/lib/new_relic/agent/transaction_sampler.rb +5 -8
- data/lib/new_relic/agent/transaction_state.rb +166 -0
- data/lib/new_relic/agent/transaction_timings.rb +53 -0
- data/lib/new_relic/cli/command.rb +91 -0
- data/lib/new_relic/{commands → cli}/deployments.rb +13 -9
- data/lib/new_relic/{commands → cli}/install.rb +2 -2
- data/lib/new_relic/control/frameworks/rails.rb +1 -8
- data/lib/new_relic/control/instance_methods.rb +1 -2
- data/lib/new_relic/helper.rb +9 -0
- data/lib/new_relic/local_environment.rb +16 -63
- data/lib/new_relic/rack/browser_monitoring.rb +8 -5
- data/lib/new_relic/recipes.rb +44 -31
- data/lib/new_relic/transaction_sample.rb +6 -2
- data/lib/new_relic/version.rb +1 -1
- data/lib/tasks/install.rake +21 -1
- data/newrelic_rpm.gemspec +5 -1
- data/test/agent_helper.rb +4 -9
- data/test/environments/.gitignore +16 -0
- data/test/environments/lib/environments/runner.rb +104 -0
- data/test/environments/norails/Gemfile +11 -0
- data/test/environments/norails/Rakefile +9 -0
- data/test/environments/rails21/Gemfile +24 -0
- data/test/environments/rails21/Rakefile +12 -0
- data/test/environments/rails21/app/controllers/application.rb +20 -0
- data/test/environments/rails21/config/boot.rb +113 -0
- data/test/environments/rails21/config/database.yml +31 -0
- data/test/environments/rails21/config/environment.rb +28 -0
- data/test/environments/rails21/config/environments/development.rb +16 -0
- data/test/environments/rails21/config/environments/production.rb +8 -0
- data/test/environments/rails21/config/environments/test.rb +10 -0
- data/test/environments/rails21/config/routes.rb +5 -0
- data/test/environments/rails21/db/schema.rb +5 -0
- data/test/environments/rails22/Gemfile +29 -0
- data/test/environments/rails22/Rakefile +12 -0
- data/test/environments/rails22/app/controllers/application.rb +20 -0
- data/test/environments/rails22/config/boot.rb +113 -0
- data/test/environments/rails22/config/database.yml +31 -0
- data/test/environments/rails22/config/environment.rb +27 -0
- data/test/environments/rails22/config/environments/development.rb +16 -0
- data/test/environments/rails22/config/environments/production.rb +8 -0
- data/test/environments/rails22/config/environments/test.rb +10 -0
- data/test/environments/rails22/config/routes.rb +5 -0
- data/test/environments/rails22/db/schema.rb +5 -0
- data/test/environments/rails23/Gemfile +22 -0
- data/test/environments/rails23/Rakefile +12 -0
- data/test/environments/rails23/app/controllers/application.rb +20 -0
- data/test/environments/rails23/config/boot.rb +127 -0
- data/test/environments/rails23/config/database.yml +31 -0
- data/test/environments/rails23/config/environment.rb +25 -0
- data/test/environments/rails23/config/environments/development.rb +16 -0
- data/test/environments/rails23/config/environments/production.rb +8 -0
- data/test/environments/rails23/config/environments/test.rb +10 -0
- data/test/environments/rails23/config/preinitializer.rb +25 -0
- data/test/environments/rails23/config/routes.rb +5 -0
- data/test/environments/rails23/db/schema.rb +5 -0
- data/test/environments/rails30/Gemfile +19 -0
- data/test/environments/rails30/Rakefile +9 -0
- data/test/environments/rails30/config/application.rb +17 -0
- data/test/environments/rails30/config/boot.rb +10 -0
- data/test/environments/rails30/config/database.yml +31 -0
- data/test/environments/rails30/config/environment.rb +6 -0
- data/test/environments/rails30/config/initializers/new_rails_defaults.rb +11 -0
- data/test/environments/rails30/db/schema.rb +5 -0
- data/test/environments/rails31/Gemfile +19 -0
- data/test/environments/rails31/Rakefile +9 -0
- data/test/environments/rails31/config/application.rb +18 -0
- data/test/environments/rails31/config/boot.rb +10 -0
- data/test/environments/rails31/config/database.yml +31 -0
- data/test/environments/rails31/config/environment.rb +6 -0
- data/test/environments/rails31/config/initializers/new_rails_defaults.rb +21 -0
- data/test/environments/rails31/db/schema.rb +5 -0
- data/test/environments/rails32/Gemfile +25 -0
- data/test/environments/rails32/Rakefile +9 -0
- data/test/environments/rails32/config/application.rb +19 -0
- data/test/environments/rails32/config/boot.rb +10 -0
- data/test/environments/rails32/config/database.yml +31 -0
- data/test/environments/rails32/config/environment.rb +6 -0
- data/test/environments/rails32/db/schema.rb +5 -0
- data/test/environments/rails40/Gemfile +25 -0
- data/test/environments/rails40/Rakefile +9 -0
- data/test/environments/rails40/config/application.rb +18 -0
- data/test/environments/rails40/config/boot.rb +10 -0
- data/test/environments/rails40/config/database.yml +31 -0
- data/test/environments/rails40/config/environment.rb +6 -0
- data/test/environments/rails40/db/schema.rb +5 -0
- data/test/multiverse/lib/multiverse/suite.rb +24 -12
- data/test/multiverse/suites/agent_only/logging_test.rb +18 -1
- data/test/multiverse/suites/agent_only/rum_instrumentation_test.rb +1 -8
- data/test/multiverse/suites/agent_only/thread_profiling_test.rb +10 -7
- data/test/multiverse/suites/curb/curb_test.rb +17 -3
- data/test/multiverse/suites/excon/Envfile +1 -1
- data/test/multiverse/suites/excon/excon_test.rb +18 -2
- data/test/multiverse/suites/httpclient/httpclient_test.rb +2 -2
- data/test/multiverse/suites/net_http/net_http_test.rb +2 -2
- data/test/multiverse/suites/rails/error_tracing_test.rb +35 -8
- data/test/multiverse/suites/rails/ignore_test.rb +48 -0
- data/test/multiverse/suites/rails/mongrel_queue_depth_test.rb +44 -0
- data/test/multiverse/suites/sequel/sequel_test.rb +11 -0
- data/test/multiverse/suites/sinatra/ignoring_test.rb +2 -2
- data/test/multiverse/suites/typhoeus/Envfile +9 -2
- data/test/multiverse/suites/typhoeus/typhoeus_test.rb +3 -2
- data/test/new_relic/agent/agent/start_test.rb +3 -22
- data/test/new_relic/agent/agent_test.rb +6 -5
- data/test/new_relic/agent/autostart_test.rb +39 -1
- data/test/new_relic/agent/browser_monitoring_test.rb +43 -88
- data/test/new_relic/agent/browser_token_test.rb +52 -0
- data/test/new_relic/agent/busy_calculator_test.rb +1 -1
- data/test/new_relic/agent/commands/agent_command_router_test.rb +98 -0
- data/test/new_relic/agent/commands/agent_command_test.rb +37 -0
- data/test/new_relic/agent/commands/thread_profiler_test.rb +177 -0
- data/test/new_relic/agent/configuration/default_source_test.rb +81 -0
- data/test/new_relic/agent/configuration/environment_source_test.rb +81 -7
- data/test/new_relic/agent/configuration/manager_test.rb +16 -1
- data/test/new_relic/agent/cross_app_monitor_test.rb +3 -5
- data/test/new_relic/agent/error_collector_test.rb +14 -0
- data/test/new_relic/agent/instrumentation/action_controller_subscriber_test.rb +1 -1
- data/test/new_relic/agent/instrumentation/active_record_instrumentation_test.rb +2 -3
- data/test/new_relic/agent/instrumentation/active_record_subscriber_test.rb +29 -31
- data/test/new_relic/agent/instrumentation/controller_instrumentation_test.rb +22 -0
- data/test/new_relic/agent/method_tracer/instance_methods/trace_execution_scoped_test.rb +2 -2
- data/test/new_relic/agent/method_tracer_test.rb +2 -2
- data/test/new_relic/agent/new_relic_service_test.rb +5 -49
- data/test/new_relic/agent/pipe_channel_manager_test.rb +1 -0
- data/test/new_relic/agent/request_sampler_test.rb +32 -95
- data/test/new_relic/agent/rpm_agent_test.rb +7 -5
- data/test/new_relic/agent/sampled_buffer_test.rb +178 -0
- data/test/new_relic/agent/stats_engine/metric_stats_test.rb +0 -1
- data/test/new_relic/agent/stats_engine_test.rb +10 -17
- data/test/new_relic/agent/threading/agent_thread_test.rb +107 -0
- data/test/new_relic/agent/threading/backtrace_node_test.rb +96 -0
- data/test/new_relic/agent/{threaded_test.rb → threading/fake_thread.rb} +0 -25
- data/test/new_relic/agent/threading/thread_profile_test.rb +308 -0
- data/test/new_relic/agent/threading/threaded_test_case.rb +33 -0
- data/test/new_relic/agent/transaction/pop_test.rb +0 -16
- data/test/new_relic/agent/transaction_sample_builder_test.rb +23 -4
- data/test/new_relic/agent/transaction_sampler_test.rb +14 -15
- data/test/new_relic/agent/transaction_state_test.rb +75 -0
- data/test/new_relic/agent/transaction_test.rb +15 -0
- data/test/new_relic/agent/transaction_timings_test.rb +81 -0
- data/test/new_relic/agent_test.rb +12 -14
- data/test/new_relic/{command → cli}/deployments_test.rb +41 -13
- data/test/new_relic/control/frameworks/rails_test.rb +1 -2
- data/test/new_relic/control_test.rb +1 -2
- data/test/new_relic/dependency_detection_test.rb +14 -0
- data/test/new_relic/fake_collector.rb +1 -0
- data/test/new_relic/helper_test.rb +7 -2
- data/test/new_relic/http_client_test_cases.rb +33 -1
- data/test/new_relic/local_environment_test.rb +0 -23
- data/test/new_relic/metric_data_test.rb +4 -0
- data/test/new_relic/rack/browser_monitoring_test.rb +31 -30
- data/test/performance/lib/performance/result.rb +15 -4
- data/test/performance/lib/performance/timer.rb +7 -1
- data/test/performance/script/baselines +102 -0
- data/test/performance/suites/rum_autoinsertion.rb +57 -0
- data/test/rum/basic.result.html +10 -0
- data/test/rum/basic.source.html +10 -0
- data/test/rum/comments1.result.html +24 -0
- data/test/rum/comments1.source.html +24 -0
- data/test/rum/comments2.result.html +24 -0
- data/test/rum/comments2.source.html +24 -0
- data/test/rum/gt_in_quotes1.result.html +27 -0
- data/test/rum/gt_in_quotes1.source.html +27 -0
- data/test/rum/gt_in_quotes2.result.html +24 -0
- data/test/rum/gt_in_quotes2.source.html +24 -0
- data/test/rum/gt_in_quotes_mismatch.result.html +24 -0
- data/test/rum/gt_in_quotes_mismatch.source.html +24 -0
- data/test/rum/gt_in_single_quotes1.result.html +25 -0
- data/test/rum/gt_in_single_quotes1.source.html +25 -0
- data/test/rum/gt_in_single_quotes_mismatch.result.html +25 -0
- data/test/rum/gt_in_single_quotes_mismatch.source.html +25 -0
- data/test/rum/incomplete_non_meta_tags.result.html +10 -0
- data/test/rum/incomplete_non_meta_tags.source.html +10 -0
- data/test/rum/no_body.result.html +21 -0
- data/test/rum/no_body.source.html +21 -0
- data/test/rum/no_header.result.html +7 -0
- data/test/rum/no_header.source.html +7 -0
- data/test/rum/no_start_header.result.html +9 -0
- data/test/rum/no_start_header.source.html +9 -0
- data/test/rum/script1.result.html +19 -0
- data/test/rum/script1.source.html +19 -0
- data/test/rum/script2.result.html +17 -0
- data/test/rum/script2.source.html +17 -0
- data/test/rum/x_ua_meta_tag.result.html +10 -0
- data/test/rum/x_ua_meta_tag.source.html +10 -0
- data/test/rum/x_ua_meta_tag_multiline.result.html +11 -0
- data/test/rum/x_ua_meta_tag_multiline.source.html +11 -0
- data/test/rum/x_ua_meta_tag_with_others.result.html +11 -0
- data/test/rum/x_ua_meta_tag_with_others.source.html +11 -0
- data/test/rum/x_ua_meta_tag_with_spaces.result.html +10 -0
- data/test/rum/x_ua_meta_tag_with_spaces.source.html +10 -0
- data/test/script/ci.sh +1 -12
- data/test/test_helper.rb +1 -0
- data/vendor/gems/dependency_detection-0.0.1.build/lib/dependency_detection.rb +11 -0
- metadata +225 -32
- metadata.gz.sig +0 -0
- data/lib/new_relic/agent/configuration/defaults.rb +0 -157
- data/lib/new_relic/agent/instrumentation/browser_monitoring_timings.rb +0 -56
- data/lib/new_relic/agent/thread.rb +0 -37
- data/lib/new_relic/agent/thread_profiler.rb +0 -323
- data/lib/new_relic/agent/transaction_info.rb +0 -114
- data/lib/new_relic/command.rb +0 -89
- data/test/new_relic/agent/agent_test_controller_test.rb +0 -348
- data/test/new_relic/agent/instrumentation/browser_monitoring_timings_test.rb +0 -70
- data/test/new_relic/agent/thread_profiler_test.rb +0 -586
- data/test/new_relic/agent/thread_test.rb +0 -93
- data/test/new_relic/agent/transaction_info_test.rb +0 -99
@@ -2,14 +2,15 @@
|
|
2
2
|
# This file is distributed under New Relic's license terms.
|
3
3
|
# See https://github.com/newrelic/rpm/blob/master/LICENSE for complete details.
|
4
4
|
|
5
|
-
require File.expand_path(File.join(File.dirname(__FILE__),'
|
6
|
-
require
|
5
|
+
require File.expand_path(File.join(File.dirname(__FILE__),'..','..','test_helper'))
|
6
|
+
require 'new_relic/cli/command'
|
7
|
+
require 'new_relic/cli/deployments'
|
7
8
|
|
8
|
-
class NewRelic::
|
9
|
+
class NewRelic::Cli::DeploymentsTest < Test::Unit::TestCase
|
9
10
|
|
10
11
|
def setup
|
11
|
-
NewRelic::
|
12
|
-
attr_accessor :messages, :exit_status, :errors, :revision
|
12
|
+
NewRelic::Cli::Deployments.class_eval do
|
13
|
+
attr_accessor :messages, :exit_status, :errors, :revision, :license_key
|
13
14
|
def err(message); @errors = @errors ? @errors + message : message; end
|
14
15
|
def info(message); @messages = @messages ? @messages + message : message; end
|
15
16
|
def just_exit(status=0); @exit_status ||= status; end
|
@@ -27,20 +28,20 @@ class NewRelic::Command::DeploymentsTest < Test::Unit::TestCase
|
|
27
28
|
end
|
28
29
|
def test_help
|
29
30
|
begin
|
30
|
-
NewRelic::
|
31
|
+
NewRelic::Cli::Deployments.new "-h"
|
31
32
|
fail "should have thrown"
|
32
|
-
rescue NewRelic::Command::CommandFailure => c
|
33
|
+
rescue NewRelic::Cli::Command::CommandFailure => c
|
33
34
|
assert_match /^Usage/, c.message
|
34
35
|
end
|
35
36
|
end
|
36
37
|
def test_bad_command
|
37
|
-
assert_raise NewRelic::Command::CommandFailure do
|
38
|
-
NewRelic::
|
38
|
+
assert_raise NewRelic::Cli::Command::CommandFailure do
|
39
|
+
NewRelic::Cli::Deployments.new ["-foo", "bar"]
|
39
40
|
end
|
40
41
|
end
|
41
42
|
def test_interactive
|
42
43
|
mock_the_connection
|
43
|
-
@deployment = NewRelic::
|
44
|
+
@deployment = NewRelic::Cli::Deployments.new(:appname => 'APP',
|
44
45
|
:revision => 3838,
|
45
46
|
:user => 'Bill',
|
46
47
|
:description => "Some lengthy description")
|
@@ -54,7 +55,7 @@ class NewRelic::Command::DeploymentsTest < Test::Unit::TestCase
|
|
54
55
|
def test_command_line_run
|
55
56
|
mock_the_connection
|
56
57
|
# @mock_response.expects(:body).returns("<xml>deployment</xml>")
|
57
|
-
@deployment = NewRelic::
|
58
|
+
@deployment = NewRelic::Cli::Deployments.new(%w[-a APP -r 3838 --user=Bill] << "Some lengthy description")
|
58
59
|
assert_nil @deployment.exit_status
|
59
60
|
assert_nil @deployment.errors
|
60
61
|
assert_equal '3838', @deployment.revision
|
@@ -69,13 +70,40 @@ class NewRelic::Command::DeploymentsTest < Test::Unit::TestCase
|
|
69
70
|
|
70
71
|
def test_error_if_no_license_key
|
71
72
|
with_config(:license_key => '') do
|
72
|
-
assert_raise NewRelic::Command::CommandFailure do
|
73
|
-
deployment = NewRelic::
|
73
|
+
assert_raise NewRelic::Cli::Command::CommandFailure do
|
74
|
+
deployment = NewRelic::Cli::Deployments.new(%w[-a APP -r 3838 --user=Bill] << "Some lengthy description")
|
74
75
|
deployment.run
|
75
76
|
end
|
76
77
|
end
|
77
78
|
end
|
78
79
|
|
80
|
+
def test_with_specified_license_key
|
81
|
+
mock_the_connection
|
82
|
+
@deployment = NewRelic::Cli::Deployments.new(:appname => 'APP',
|
83
|
+
:revision => 3838,
|
84
|
+
:user => 'Bill',
|
85
|
+
:description => "Some lengthy description",
|
86
|
+
:license_key => 'b' * 40)
|
87
|
+
assert_nil @deployment.exit_status
|
88
|
+
assert_nil @deployment.errors
|
89
|
+
assert_equal 'b' * 40, @deployment.license_key
|
90
|
+
@deployment.run
|
91
|
+
@deployment = nil
|
92
|
+
end
|
93
|
+
|
94
|
+
def test_with_unspecified_license_key
|
95
|
+
mock_the_connection
|
96
|
+
@deployment = NewRelic::Cli::Deployments.new(:appname => 'APP',
|
97
|
+
:revision => 3838,
|
98
|
+
:user => 'Bill',
|
99
|
+
:description => "Some lengthy description")
|
100
|
+
assert_nil @deployment.exit_status
|
101
|
+
assert_nil @deployment.errors
|
102
|
+
assert_equal 'a' * 40, @deployment.license_key
|
103
|
+
@deployment.run
|
104
|
+
@deployment = nil
|
105
|
+
end
|
106
|
+
|
79
107
|
private
|
80
108
|
|
81
109
|
def mock_the_connection
|
@@ -6,8 +6,7 @@ require File.expand_path(File.join(File.dirname(__FILE__),'/../../../test_helper
|
|
6
6
|
|
7
7
|
class NewRelic::Control::Frameworks::RailsTest < Test::Unit::TestCase
|
8
8
|
def test_install_browser_monitoring
|
9
|
-
require
|
10
|
-
'/../../../../lib/new_relic/rack/browser_monitoring')))
|
9
|
+
require 'new_relic/rack/browser_monitoring'
|
11
10
|
middleware = stub('middleware config')
|
12
11
|
config = stub('rails config', :middleware => middleware)
|
13
12
|
middleware.expects(:use).with(NewRelic::Rack::BrowserMonitoring)
|
@@ -28,7 +28,6 @@ class NewRelic::ControlTest < Test::Unit::TestCase
|
|
28
28
|
assert_equal :test, control.app
|
29
29
|
end
|
30
30
|
assert_equal :test, control.framework
|
31
|
-
assert_match /test/i, control.local_env.dispatcher_instance_id
|
32
31
|
assert("" == NewRelic::Agent.config[:dispatcher].to_s,
|
33
32
|
"Expected dispatcher to be empty, but was #{NewRelic::Agent.config[:dispatcher].to_s}")
|
34
33
|
assert !NewRelic::Agent.config[:monitor_mode]
|
@@ -47,7 +46,7 @@ class NewRelic::ControlTest < Test::Unit::TestCase
|
|
47
46
|
end
|
48
47
|
|
49
48
|
def test_info
|
50
|
-
NewRelic::Agent.manual_start
|
49
|
+
NewRelic::Agent.manual_start
|
51
50
|
if defined?(Rails)
|
52
51
|
assert_match /jdbc|postgres|mysql|sqlite/, NewRelic::EnvironmentReport.new["Database adapter"]
|
53
52
|
end
|
@@ -124,4 +124,18 @@ class DependencyDetectionTest < Test::Unit::TestCase
|
|
124
124
|
assert_falsy( ran_second_block )
|
125
125
|
end
|
126
126
|
|
127
|
+
def test_defer_should_be_idempotent_when_given_same_name
|
128
|
+
run_count = 0
|
129
|
+
|
130
|
+
2.times do
|
131
|
+
DependencyDetection.defer do
|
132
|
+
named :foobar
|
133
|
+
executes { run_count += 1 }
|
134
|
+
end
|
135
|
+
end
|
136
|
+
|
137
|
+
DependencyDetection.detect!
|
138
|
+
|
139
|
+
assert_equal(1, run_count)
|
140
|
+
end
|
127
141
|
end
|
@@ -27,6 +27,7 @@ module NewRelic
|
|
27
27
|
'sql_trace_data' => [200, {'return_value' => nil}],
|
28
28
|
'transaction_sample_data' => [200, {'return_value' => nil}],
|
29
29
|
'error_data' => [200, {'return_value' => nil}],
|
30
|
+
'profile_data' => [200, {'return_value' => nil}],
|
30
31
|
'shutdown' => [200, {'return_value' => nil}],
|
31
32
|
'analytic_event_data' => [200, {'return_value' => nil}]
|
32
33
|
}
|
@@ -2,11 +2,12 @@
|
|
2
2
|
# This file is distributed under New Relic's license terms.
|
3
3
|
# See https://github.com/newrelic/rpm/blob/master/LICENSE for complete details.
|
4
4
|
|
5
|
-
|
6
|
-
#require File.expand_path(File.join(File.dirname(__FILE__),'..','test_helper'))
|
5
|
+
require File.expand_path(File.join(File.dirname(__FILE__),'..','test_helper'))
|
7
6
|
require 'test/unit'
|
8
7
|
require 'newrelic_rpm'
|
9
8
|
|
9
|
+
if RUBY_VERSION > '1.8.6'
|
10
|
+
|
10
11
|
class HelperTest < Test::Unit::TestCase
|
11
12
|
|
12
13
|
def test_json_serializer_method
|
@@ -25,3 +26,7 @@ class HelperTest < Test::Unit::TestCase
|
|
25
26
|
end
|
26
27
|
|
27
28
|
end
|
29
|
+
|
30
|
+
else
|
31
|
+
puts "Skipping tests in #{__FILE__} because 1.8.6 character encoding is, um, less than stellar"
|
32
|
+
end
|
@@ -43,7 +43,7 @@ module HttpClientTestCases
|
|
43
43
|
end
|
44
44
|
|
45
45
|
@engine = NewRelic::Agent.instance.stats_engine
|
46
|
-
NewRelic::Agent::
|
46
|
+
NewRelic::Agent::TransactionState.get.request_guid = TRANSACTION_GUID
|
47
47
|
end
|
48
48
|
|
49
49
|
# Helpers to support shared tests
|
@@ -122,6 +122,38 @@ module HttpClientTestCases
|
|
122
122
|
])
|
123
123
|
end
|
124
124
|
|
125
|
+
# Although rare, some clients do explicitly set the "host" header on their
|
126
|
+
# http requests. Respect that rather than the host IP on the request if so.
|
127
|
+
#
|
128
|
+
# https://github.com/newrelic/rpm/pull/124
|
129
|
+
def test_get_with_host_header
|
130
|
+
uri = default_uri
|
131
|
+
uri.host = '127.0.0.1'
|
132
|
+
res = get_response(uri.to_s, 'Host' => 'test.local')
|
133
|
+
|
134
|
+
assert_match %r/<head>/i, body(res)
|
135
|
+
assert_metrics_recorded([
|
136
|
+
"External/all",
|
137
|
+
"External/test.local/#{client_name}/GET",
|
138
|
+
"External/allOther",
|
139
|
+
"External/test.local/all"
|
140
|
+
])
|
141
|
+
end
|
142
|
+
|
143
|
+
def test_get_with_host_header_lowercase
|
144
|
+
uri = default_uri
|
145
|
+
uri.host = '127.0.0.1'
|
146
|
+
res = get_response(uri.to_s, 'host' => 'test.local')
|
147
|
+
|
148
|
+
assert_match %r/<head>/i, body(res)
|
149
|
+
assert_metrics_recorded([
|
150
|
+
"External/all",
|
151
|
+
"External/test.local/#{client_name}/GET",
|
152
|
+
"External/allOther",
|
153
|
+
"External/test.local/all"
|
154
|
+
])
|
155
|
+
end
|
156
|
+
|
125
157
|
# Only some HTTP clients support explicit connection reuse, so this test
|
126
158
|
# checks whether the host responds to get_response_multi before executing.
|
127
159
|
def test_get_with_reused_connection
|
@@ -17,19 +17,6 @@ class NewRelic::LocalEnvironmentTest < Test::Unit::TestCase
|
|
17
17
|
end
|
18
18
|
MOCK_OPTIONS = MockOptions.new
|
19
19
|
|
20
|
-
# def test_environment
|
21
|
-
# e = NewRelic::LocalEnvironment.new
|
22
|
-
# assert(nil == e.environment) # working around a bug in 1.9.1
|
23
|
-
# assert_match /test/i, e.dispatcher_instance_id
|
24
|
-
# end
|
25
|
-
# def test_no_webrick
|
26
|
-
# Object.const_set :OPTIONS, 'foo'
|
27
|
-
# e = NewRelic::LocalEnvironment.new
|
28
|
-
# assert(nil == e.environment) # working around a bug in 1.9.1
|
29
|
-
# assert_match /test/i, e.dispatcher_instance_id
|
30
|
-
# Object.class_eval { remove_const :OPTIONS }
|
31
|
-
# end
|
32
|
-
|
33
20
|
def test_passenger
|
34
21
|
class << self
|
35
22
|
module ::PhusionPassenger
|
@@ -39,12 +26,10 @@ class NewRelic::LocalEnvironmentTest < Test::Unit::TestCase
|
|
39
26
|
e = NewRelic::LocalEnvironment.new
|
40
27
|
assert_equal :passenger, e.discovered_dispatcher
|
41
28
|
assert_equal :passenger, NewRelic::Agent.config[:dispatcher]
|
42
|
-
assert_nil e.dispatcher_instance_id, "dispatcher instance id should be nil: #{e.dispatcher_instance_id}"
|
43
29
|
|
44
30
|
with_config(:app_name => 'myapp') do
|
45
31
|
e = NewRelic::LocalEnvironment.new
|
46
32
|
assert_equal :passenger, e.discovered_dispatcher
|
47
|
-
assert_nil e.dispatcher_instance_id
|
48
33
|
end
|
49
34
|
|
50
35
|
ensure
|
@@ -88,12 +73,4 @@ class NewRelic::LocalEnvironmentTest < Test::Unit::TestCase
|
|
88
73
|
end
|
89
74
|
end
|
90
75
|
end
|
91
|
-
|
92
|
-
def test_default_port
|
93
|
-
e = NewRelic::LocalEnvironment.new
|
94
|
-
assert_equal 3000, e.send(:default_port)
|
95
|
-
ARGV.push '--port=3121'
|
96
|
-
assert_equal '3121', e.send(:default_port)
|
97
|
-
ARGV.pop
|
98
|
-
end
|
99
76
|
end
|
@@ -104,6 +104,7 @@ class NewRelic::MetricDataTest < Test::Unit::TestCase
|
|
104
104
|
assert((spec.hash ^ stats.hash) == md1.hash, "expected #{spec.hash ^ stats.hash} to equal #{md1.hash}")
|
105
105
|
end
|
106
106
|
|
107
|
+
if {}.respond_to?(:to_json)
|
107
108
|
def test_to_json_no_metric_id
|
108
109
|
md = NewRelic::MetricData.new(NewRelic::MetricSpec.new('Custom/test/method', ''), NewRelic::Agent::Stats.new, nil)
|
109
110
|
json = md.to_json
|
@@ -115,6 +116,9 @@ class NewRelic::MetricDataTest < Test::Unit::TestCase
|
|
115
116
|
md = NewRelic::MetricData.new(NewRelic::MetricSpec.new('Custom/test/method', ''), NewRelic::Agent::Stats.new, 12345)
|
116
117
|
assert_equal('{"metric_spec":null,"stats":{"total_exclusive_time":0.0,"min_call_time":0.0,"call_count":0,"sum_of_squares":0.0,"total_call_time":0.0,"max_call_time":0.0},"metric_id":12345}', md.to_json, "should not include the metric spec and should have a metric_id")
|
117
118
|
end
|
119
|
+
else
|
120
|
+
puts "Skipping tests in #{__FILE__} because Hash#to_json not available"
|
121
|
+
end
|
118
122
|
|
119
123
|
def test_to_s_with_metric_spec
|
120
124
|
md = NewRelic::MetricData.new(NewRelic::MetricSpec.new('Custom/test/method', ''), NewRelic::Agent::Stats.new, 12345)
|
@@ -96,44 +96,45 @@ EOL
|
|
96
96
|
assert !app.should_instrument?({NewRelic::Rack::BrowserMonitoring::ALREADY_INSTRUMENTED_KEY => true}, 200, {'Content-Type' => 'text/html'})
|
97
97
|
end
|
98
98
|
|
99
|
-
def test_insert_timing_header_right_after_open_head_if_no_meta_tags
|
100
|
-
get '/'
|
101
|
-
|
102
|
-
assert(last_response.body.include?("head>#{NewRelic::Agent.browser_timing_header}"),
|
103
|
-
last_response.body)
|
104
|
-
TestApp.doc = nil
|
105
|
-
end
|
106
|
-
|
107
99
|
def test_insert_header_should_mark_environment
|
108
100
|
get '/'
|
109
101
|
assert last_request.env.key?(NewRelic::Rack::BrowserMonitoring::ALREADY_INSTRUMENTED_KEY)
|
110
|
-
TestApp.doc = nil
|
111
102
|
end
|
112
103
|
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
<head>
|
117
|
-
<title>im a title</title>
|
118
|
-
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"/>
|
119
|
-
<script>
|
120
|
-
junk
|
121
|
-
</script>
|
122
|
-
</head>
|
123
|
-
<body>im some body text</body>
|
124
|
-
</html>
|
125
|
-
EOL
|
126
|
-
get '/'
|
104
|
+
# RUM header auto-insertion testing
|
105
|
+
# We read *.source.html files from the test/rum directory, and then
|
106
|
+
# compare the results of them to *.result.html files.
|
127
107
|
|
128
|
-
|
129
|
-
last_response.body)
|
130
|
-
end
|
108
|
+
source_files = Dir[File.join(File.dirname(__FILE__), "..", "..", "rum", "*.source.html")]
|
131
109
|
|
132
|
-
|
133
|
-
|
110
|
+
RUM_HEADER = "|||I AM THE RUM HEADER|||"
|
111
|
+
RUM_FOOTER = "|||I AM THE RUM FOOTER|||"
|
134
112
|
|
135
|
-
|
136
|
-
|
113
|
+
source_files.each do |source_file|
|
114
|
+
source_filename = File.basename(source_file).gsub(".", "_")
|
115
|
+
source_html = File.read(source_file)
|
116
|
+
|
117
|
+
result_file = source_file.gsub(".source.", ".result.")
|
118
|
+
|
119
|
+
define_method("test_#{source_filename}") do
|
120
|
+
TestApp.doc = source_html
|
121
|
+
NewRelic::Agent.instance.stubs(:browser_timing_header).returns(RUM_HEADER)
|
122
|
+
NewRelic::Agent.instance.stubs(:browser_timing_footer).returns(RUM_FOOTER)
|
123
|
+
|
124
|
+
get '/'
|
125
|
+
|
126
|
+
expected_content = File.read(result_file)
|
127
|
+
assert_equal(expected_content, last_response.body)
|
128
|
+
end
|
129
|
+
|
130
|
+
define_method("test_dont_touch_#{source_filename}") do
|
131
|
+
TestApp.doc = source_html
|
132
|
+
NewRelic::Rack::BrowserMonitoring.any_instance.stubs(:should_instrument?).returns(false)
|
133
|
+
|
134
|
+
get '/'
|
135
|
+
|
136
|
+
assert_equal(source_html, last_response.body)
|
137
|
+
end
|
137
138
|
end
|
138
139
|
|
139
140
|
def test_should_not_throw_exception_on_empty_reponse
|
@@ -2,6 +2,8 @@
|
|
2
2
|
# This file is distributed under New Relic's license terms.
|
3
3
|
# See https://github.com/newrelic/rpm/blob/master/LICENSE for complete details.
|
4
4
|
|
5
|
+
require 'time'
|
6
|
+
|
5
7
|
module Performance
|
6
8
|
class Result
|
7
9
|
attr_reader :test_name, :measurements, :tags, :timer, :artifacts
|
@@ -52,15 +54,22 @@ module Performance
|
|
52
54
|
@measurements.merge(:elapsed => elapsed)
|
53
55
|
end
|
54
56
|
|
57
|
+
def format_timestamp(t)
|
58
|
+
t.utc.iso8601
|
59
|
+
end
|
60
|
+
|
55
61
|
def to_h
|
56
|
-
{
|
62
|
+
h = {
|
57
63
|
"suite" => suite_name,
|
58
64
|
"name" => @test_name,
|
59
65
|
"measurements" => measurements_hash,
|
60
|
-
"tags" => @tags
|
61
|
-
"exception" => @exception,
|
62
|
-
"artifacts" => @artifacts
|
66
|
+
"tags" => @tags
|
63
67
|
}
|
68
|
+
h['exception'] = @exception if @exception
|
69
|
+
h['artifacts'] = @artifacts if @artifacts && !@artifacts.empty?
|
70
|
+
h['started_at'] = format_timestamp(@timer.start_timestamp) if @timer.start_timestamp
|
71
|
+
h['finished_at'] = format_timestamp(@timer.stop_timestamp) if @timer.stop_timestamp
|
72
|
+
h
|
64
73
|
end
|
65
74
|
|
66
75
|
def self.from_hash(hash)
|
@@ -70,6 +79,8 @@ module Performance
|
|
70
79
|
result.tags.merge! hash['tags']
|
71
80
|
result.exception = hash['exception']
|
72
81
|
result.elapsed = elapsed
|
82
|
+
result.timer.start_timestamp = Time.iso8601(hash['started_at']) if hash['started_at']
|
83
|
+
result.timer.stop_timestamp = Time.iso8601(hash['finished_at']) if hash['finished_at']
|
73
84
|
result
|
74
85
|
end
|
75
86
|
|
@@ -4,9 +4,11 @@
|
|
4
4
|
|
5
5
|
module Performance
|
6
6
|
class Timer
|
7
|
+
attr_accessor :start_timestamp, :stop_timestamp
|
8
|
+
|
7
9
|
def initialize
|
8
10
|
@start_timestamp = nil
|
9
|
-
@
|
11
|
+
@stop_timestamp = nil
|
10
12
|
end
|
11
13
|
|
12
14
|
def start(t=Time.now)
|
@@ -34,5 +36,9 @@ module Performance
|
|
34
36
|
nil
|
35
37
|
end
|
36
38
|
end
|
39
|
+
|
40
|
+
def inspect
|
41
|
+
"<Performance::Timer @start_timestamp=#{start_timestamp.inspect}, @stop_timestamp=#{stop_timestamp.inspect}, elapsed=#{elapsed}>"
|
42
|
+
end
|
37
43
|
end
|
38
44
|
end
|
@@ -0,0 +1,102 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
# encoding: utf-8
|
4
|
+
# This file is distributed under New Relic's license terms.
|
5
|
+
# See https://github.com/newrelic/rpm/blob/master/LICENSE for complete details.
|
6
|
+
|
7
|
+
require 'optparse'
|
8
|
+
require 'rubygems'
|
9
|
+
require 'httparty'
|
10
|
+
require 'tmpdir'
|
11
|
+
require 'json'
|
12
|
+
|
13
|
+
require File.join(File.dirname(__FILE__), '..', 'lib', 'performance')
|
14
|
+
|
15
|
+
GEM_NAME = 'newrelic_rpm'
|
16
|
+
|
17
|
+
class GemWorkspace
|
18
|
+
attr_reader :path
|
19
|
+
|
20
|
+
def initialize(path=nil)
|
21
|
+
@path = File.expand_path(path || Dir.mktmpdir)
|
22
|
+
FileUtils.mkdir_p(gems_dir)
|
23
|
+
FileUtils.mkdir_p(extracted_gems_dir)
|
24
|
+
end
|
25
|
+
|
26
|
+
def gems_dir
|
27
|
+
File.join(@path, 'gems')
|
28
|
+
end
|
29
|
+
|
30
|
+
def extracted_gems_dir
|
31
|
+
File.join(@path, 'extracted_gems')
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
class FetchedGem
|
36
|
+
attr_reader :name, :version
|
37
|
+
|
38
|
+
def initialize(workspace, name, version)
|
39
|
+
@workspace = workspace
|
40
|
+
@name = name
|
41
|
+
@version = version
|
42
|
+
end
|
43
|
+
|
44
|
+
def gem_filename
|
45
|
+
"#{@name}-#{@version}.gem"
|
46
|
+
end
|
47
|
+
|
48
|
+
def path
|
49
|
+
File.join(@workspace.gems_dir, gem_filename)
|
50
|
+
end
|
51
|
+
|
52
|
+
def extracted_path
|
53
|
+
File.join(@workspace.extracted_gems_dir, gem_filename.gsub(/\.gem$/, ''))
|
54
|
+
end
|
55
|
+
|
56
|
+
def uri
|
57
|
+
"https://rubygems.org/downloads/#{gem_filename}"
|
58
|
+
end
|
59
|
+
|
60
|
+
def fetch!
|
61
|
+
File.open(path, "w") do |f|
|
62
|
+
rsp = HTTParty.get(uri)
|
63
|
+
f.write(rsp.body)
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
def fetched?
|
68
|
+
File.exist?(path)
|
69
|
+
end
|
70
|
+
|
71
|
+
def git_sha
|
72
|
+
`git rev-parse #{@version}`.strip
|
73
|
+
end
|
74
|
+
|
75
|
+
def extract!
|
76
|
+
fetch! unless fetched?
|
77
|
+
cmd = "cd #{@workspace.extracted_gems_dir} && gem unpack '#{path}'"
|
78
|
+
system(cmd)
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
versions_url = "https://rubygems.org/api/v1/versions/#{GEM_NAME}.json"
|
83
|
+
result = Net::HTTP.get(URI.parse(versions_url))
|
84
|
+
|
85
|
+
gem_versions = JSON.parse(result)
|
86
|
+
ga_gem_versions = gem_versions.reject { |v| v['prerelease'] }
|
87
|
+
|
88
|
+
workspace = GemWorkspace.new(ARGV.first)
|
89
|
+
ga_gem_versions.each do |version|
|
90
|
+
gem = FetchedGem.new(workspace, GEM_NAME, version['number'])
|
91
|
+
gem.extract!
|
92
|
+
options = {
|
93
|
+
:agent_path => gem.extracted_path,
|
94
|
+
:reporter_classes => ["ConsoleReporter", "HakoReporter"],
|
95
|
+
:tags => {
|
96
|
+
:series => 'baseline',
|
97
|
+
:newrelic_rpm_git_sha => gem.git_sha
|
98
|
+
}
|
99
|
+
}
|
100
|
+
runner = Performance::Runner.new(options)
|
101
|
+
runner.run_and_report
|
102
|
+
end
|