wd_newrelic_rpm 3.5.5 → 3.5.6
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +2 -0
- data/CHANGELOG +60 -0
- data/Rakefile +14 -18
- data/gem-public_cert.pem +20 -0
- data/lib/new_relic/agent.rb +3 -0
- data/lib/new_relic/agent/agent.rb +86 -97
- data/lib/new_relic/agent/agent_logger.rb +9 -1
- data/lib/new_relic/agent/busy_calculator.rb +5 -0
- data/lib/new_relic/agent/configuration/defaults.rb +3 -3
- data/lib/new_relic/agent/configuration/manager.rb +12 -0
- data/lib/new_relic/agent/configuration/mask_defaults.rb +1 -0
- data/lib/new_relic/agent/configuration/yaml_source.rb +5 -1
- data/lib/new_relic/agent/cross_process_monitoring.rb +164 -20
- data/lib/new_relic/agent/error_collector.rb +13 -2
- data/lib/new_relic/agent/event_listener.rb +39 -0
- data/lib/new_relic/agent/instrumentation/browser_monitoring_timings.rb +18 -8
- data/lib/new_relic/agent/instrumentation/rails3/action_controller.rb +1 -1
- data/lib/new_relic/agent/instrumentation/sinatra.rb +8 -1
- data/lib/new_relic/agent/new_relic_service.rb +90 -10
- data/lib/new_relic/agent/pipe_service.rb +9 -0
- data/lib/new_relic/agent/sql_sampler.rb +10 -3
- data/lib/new_relic/agent/stats_engine/transactions.rb +1 -0
- data/lib/new_relic/agent/thread_profiler.rb +20 -7
- data/lib/new_relic/agent/worker_loop.rb +2 -1
- data/lib/new_relic/coerce.rb +37 -0
- data/lib/new_relic/commands/deployments.rb +1 -1
- data/lib/new_relic/control/frameworks/rails.rb +29 -5
- data/lib/new_relic/control/frameworks/rails3.rb +2 -11
- data/lib/new_relic/control/instance_methods.rb +11 -7
- data/lib/new_relic/control/server_methods.rb +5 -37
- data/lib/new_relic/latest_changes.rb +31 -0
- data/lib/new_relic/local_environment.rb +1 -1
- data/lib/new_relic/metric_data.rb +13 -2
- data/lib/new_relic/noticed_error.rb +8 -1
- data/lib/new_relic/rack/agent_hooks.rb +20 -0
- data/lib/new_relic/rack/error_collector.rb +11 -1
- data/lib/new_relic/recipes.rb +32 -10
- data/lib/new_relic/transaction_sample.rb +12 -3
- data/lib/new_relic/transaction_sample/segment.rb +6 -3
- data/lib/new_relic/version.rb +10 -15
- data/newrelic.yml +12 -19
- data/newrelic_rpm.gemspec +22 -464
- data/test/multiverse/.gitignore +1 -0
- data/test/multiverse/lib/multiverse/environment.rb +1 -1
- data/test/multiverse/lib/multiverse/suite.rb +2 -0
- data/test/multiverse/suites/active_record/Envfile +3 -3
- data/test/multiverse/suites/active_record/ar_method_aliasing.rb +1 -1
- data/test/multiverse/suites/active_record/config/newrelic.yml +2 -2
- data/test/multiverse/suites/agent_only/Envfile +2 -1
- data/test/multiverse/suites/agent_only/config/newrelic.yml +3 -1
- data/test/multiverse/suites/agent_only/cross_process_test.rb +56 -0
- data/test/multiverse/suites/{logging → agent_only}/logging_test.rb +42 -22
- data/test/multiverse/suites/agent_only/no_dns_resolv.rb +17 -0
- data/test/multiverse/suites/{rum_auto_instrumentation/sanity_test.rb → agent_only/rum_instrumentation_test.rb} +25 -46
- data/test/multiverse/suites/agent_only/service_timeout_test.rb +6 -3
- data/test/multiverse/suites/agent_only/ssl_test.rb +22 -0
- data/test/multiverse/suites/{no_load → agent_only}/start_up_test.rb +9 -2
- data/test/multiverse/suites/agent_only/testing_app.rb +17 -0
- data/test/multiverse/suites/agent_only/thread_profiling_test.rb +6 -5
- data/test/multiverse/suites/datamapper/config/newrelic.yml +1 -1
- data/test/multiverse/suites/{rails_3_queue_time → rails}/Envfile +3 -0
- data/test/multiverse/suites/rails/app.rb +49 -0
- data/test/multiverse/suites/{rails_3_views → rails}/app/views/foos/_foo.html.haml +0 -0
- data/test/multiverse/suites/{rails_3_views/app/views/test → rails/app/views/views}/_a_partial.html.erb +0 -0
- data/test/multiverse/suites/{rails_3_views/app/views/test → rails/app/views/views}/_mid_partial.html.erb +0 -0
- data/test/multiverse/suites/{rails_3_views/app/views/test → rails/app/views/views}/_top_partial.html.erb +0 -0
- data/test/multiverse/suites/{rails_3_views/app/views/test → rails/app/views/views}/deep_partial.html.erb +0 -0
- data/test/multiverse/suites/{rails_3_views/app/views/test → rails/app/views/views}/haml_view.html.haml +0 -0
- data/test/multiverse/suites/{rails_3_views/app/views/test → rails/app/views/views}/index.html.erb +0 -0
- data/test/multiverse/suites/rails/config/newrelic.yml +32 -0
- data/test/multiverse/suites/{rails_3_error_tracing → rails}/error_tracing_test.rb +51 -88
- data/test/multiverse/suites/rails/gc_instrumentation_test.rb +79 -0
- data/test/multiverse/suites/{rails_3_queue_time → rails}/queue_time_test.rb +3 -23
- data/test/multiverse/suites/{rails_3_views → rails}/view_instrumentation_test.rb +21 -61
- data/test/multiverse/suites/resque/Envfile +7 -4
- data/test/multiverse/suites/resque/Rakefile +8 -0
- data/test/multiverse/suites/resque/config/newrelic.yml +1 -1
- data/test/multiverse/suites/resque/instrumentation_test.rb +118 -41
- data/test/multiverse/suites/resque/resque_setup.rb +15 -0
- data/test/multiverse/suites/sinatra/config/newrelic.yml +1 -2
- data/test/multiverse/suites/sinatra/sinatra_error_tracing_test.rb +38 -0
- data/test/multiverse/suites/sinatra/sinatra_test.rb +17 -0
- data/test/multiverse/test/suite_examples/one/a/config/newrelic.yml +1 -1
- data/test/multiverse/test/suite_examples/one/b/config/newrelic.yml +1 -1
- data/test/new_relic/agent/agent/connect_test.rb +24 -100
- data/test/new_relic/agent/agent/start_worker_thread_test.rb +3 -3
- data/test/new_relic/agent/agent_test.rb +126 -31
- data/test/new_relic/agent/browser_monitoring_test.rb +1 -1
- data/test/new_relic/agent/busy_calculator_test.rb +8 -0
- data/test/new_relic/agent/configuration/manager_test.rb +28 -0
- data/test/new_relic/agent/configuration/yaml_source_test.rb +12 -2
- data/test/new_relic/agent/cross_process_monitoring_test.rb +144 -31
- data/test/new_relic/agent/error_collector_test.rb +16 -0
- data/test/new_relic/agent/event_listener_test.rb +46 -0
- data/test/new_relic/agent/instrumentation/browser_monitoring_timings_test.rb +57 -30
- data/test/new_relic/agent/instrumentation/task_instrumentation_test.rb +1 -0
- data/test/new_relic/agent/new_relic_service_test.rb +95 -2
- data/test/new_relic/agent/pipe_channel_manager_test.rb +3 -3
- data/test/new_relic/agent/pipe_service_test.rb +21 -1
- data/test/new_relic/agent/rpm_agent_test.rb +1 -1
- data/test/new_relic/agent/sql_sampler_test.rb +20 -0
- data/test/new_relic/agent/thread_profiler_test.rb +53 -8
- data/test/new_relic/agent/worker_loop_test.rb +19 -16
- data/test/new_relic/agent_test.rb +1 -2
- data/test/new_relic/coerce_test.rb +65 -0
- data/test/new_relic/command/deployments_test.rb +1 -1
- data/test/new_relic/control_test.rb +23 -44
- data/test/new_relic/fake_collector.rb +34 -6
- data/test/new_relic/local_environment_test.rb +1 -1
- data/test/new_relic/metric_data_test.rb +29 -0
- data/test/new_relic/noticed_error_test.rb +8 -0
- data/test/new_relic/rack/agent_hooks_test.rb +30 -0
- data/test/new_relic/rack/error_collector_test.rb +16 -0
- data/test/new_relic/transaction_sample/segment_test.rb +7 -0
- data/test/new_relic/transaction_sample_test.rb +36 -8
- data/test/new_relic/version_number_test.rb +6 -30
- data/test/script/ci.sh +6 -5
- data/test/test_contexts.rb +2 -1
- data/test/test_helper.rb +23 -6
- data/ui/helpers/google_pie_chart.rb +1 -0
- metadata +68 -67
- data/newrelic_rpm.gemspec.erb +0 -54
- data/test/fixtures/gemspec_no_build.rb +0 -442
- data/test/fixtures/gemspec_with_build.rb +0 -442
- data/test/fixtures/gemspec_with_build_and_stage.rb +0 -442
- data/test/multiverse/suites/logging/Envfile +0 -4
- data/test/multiverse/suites/logging/config/newrelic.yml +0 -22
- data/test/multiverse/suites/monitor_mode_false/Envfile +0 -2
- data/test/multiverse/suites/monitor_mode_false/config/newrelic.yml +0 -25
- data/test/multiverse/suites/monitor_mode_false/no_dns_resolv.rb +0 -29
- data/test/multiverse/suites/no_load/Envfile +0 -2
- data/test/multiverse/suites/no_load/config/newrelic.yml +0 -22
- data/test/multiverse/suites/rails_3_error_tracing/Envfile +0 -15
- data/test/multiverse/suites/rails_3_error_tracing/config/newrelic.yml +0 -165
- data/test/multiverse/suites/rails_3_gc/Envfile +0 -8
- data/test/multiverse/suites/rails_3_gc/config/newrelic.yml +0 -167
- data/test/multiverse/suites/rails_3_gc/instrumentation_test.rb +0 -92
- data/test/multiverse/suites/rails_3_queue_time/config/newrelic.yml +0 -165
- data/test/multiverse/suites/rails_3_views/.gitignore +0 -3
- data/test/multiverse/suites/rails_3_views/Envfile +0 -16
- data/test/multiverse/suites/rails_3_views/config/newrelic.yml +0 -164
- data/test/multiverse/suites/resque/dump.rdb +0 -0
- data/test/multiverse/suites/rum_auto_instrumentation/Envfile +0 -4
- data/test/multiverse/suites/rum_auto_instrumentation/config/newrelic.yml +0 -24
- data/test/multiverse/suites/rum_auto_instrumentation/responses/worst_case_small.html +0 -5000
- data/test/new_relic/fake_service.rb +0 -53
data/test/multiverse/.gitignore
CHANGED
@@ -4,7 +4,7 @@ module Multiverse
|
|
4
4
|
ROOT = File.expand_path(File.join(File.dirname(__FILE__), '..', '..'))
|
5
5
|
$: << File.expand_path(File.join(ROOT, 'lib'))
|
6
6
|
|
7
|
-
# Include from our unit testing path to share fake_collector
|
7
|
+
# Include from our unit testing path to share fake_collector
|
8
8
|
$: << File.expand_path(File.join(ROOT, '..', 'new_relic'))
|
9
9
|
|
10
10
|
SUITES_DIRECTORY = ENV['SUITES_DIRECTORY'] || File.join(ROOT, '/suites')
|
@@ -56,6 +56,8 @@ module Multiverse
|
|
56
56
|
if RUBY_VERSION > '1.8.7'
|
57
57
|
f.puts " gem 'test-unit', :require => 'test/unit'"
|
58
58
|
f.puts " gem 'debugger'" if include_debugger
|
59
|
+
else
|
60
|
+
f.puts " gem 'ruby-debug'" if include_debugger
|
59
61
|
end
|
60
62
|
end
|
61
63
|
puts yellow("Gemfile set to:") if verbose?
|
@@ -2,12 +2,12 @@ gemfile <<-RB
|
|
2
2
|
if RUBY_VERSION == '1.8.6'
|
3
3
|
gem 'activerecord', '2.3.14'
|
4
4
|
elsif RUBY_PLATFORM == 'java'
|
5
|
-
gem '
|
6
|
-
gem '
|
5
|
+
gem 'activerecord-jdbcsqlite3-adapter', '1.2.2.1'
|
6
|
+
gem 'jdbc-sqlite3', '3.7.2'
|
7
7
|
gem 'activerecord'
|
8
8
|
else
|
9
9
|
gem 'activerecord'
|
10
|
-
gem 'sqlite3'
|
10
|
+
gem 'sqlite3', '~> 1.3.5'
|
11
11
|
end
|
12
12
|
|
13
13
|
RB
|
@@ -11,7 +11,7 @@ development:
|
|
11
11
|
app_name: test
|
12
12
|
host: 127.0.0.1
|
13
13
|
api_host: 127.0.0.1
|
14
|
-
port:
|
14
|
+
port: <%= 30_000 + ($$ % 10_000) %>
|
15
15
|
transaction_tracer:
|
16
16
|
record_sql: obfuscated
|
17
17
|
enabled: true
|
@@ -20,3 +20,5 @@ development:
|
|
20
20
|
capture_params: false
|
21
21
|
log_level: debug
|
22
22
|
log_file_path: agent.log
|
23
|
+
browser_monitoring:
|
24
|
+
auto_instrument: true
|
@@ -0,0 +1,56 @@
|
|
1
|
+
require 'rack/test'
|
2
|
+
require 'fake_collector'
|
3
|
+
require './testing_app'
|
4
|
+
|
5
|
+
class CrossProcessTest < Test::Unit::TestCase
|
6
|
+
|
7
|
+
# Important because the hooks are global that we only wire one AgentHooks up
|
8
|
+
@@app = TestingApp.new
|
9
|
+
@@wrapper_app = NewRelic::Rack::AgentHooks.new(@@app)
|
10
|
+
|
11
|
+
def setup
|
12
|
+
$collector ||= NewRelic::FakeCollector.new
|
13
|
+
$collector.reset
|
14
|
+
$collector.mock['connect'] = [200, {'return_value' => {"agent_run_id" => 666 }}]
|
15
|
+
$collector.run
|
16
|
+
|
17
|
+
NewRelic::Agent.manual_start(
|
18
|
+
:cross_process_id => "boo",
|
19
|
+
:encoding_key => "\0",
|
20
|
+
:trusted_account_ids => [1])
|
21
|
+
|
22
|
+
NewRelic::Agent.instance.events.notify(:finished_configuring)
|
23
|
+
|
24
|
+
@@app.reset_headers
|
25
|
+
@@app.response = "<html><head><title>W00t!</title></head><body><p>Hello World</p></body></html>"
|
26
|
+
end
|
27
|
+
|
28
|
+
def teardown
|
29
|
+
NewRelic::Agent.shutdown
|
30
|
+
end
|
31
|
+
|
32
|
+
include Rack::Test::Methods
|
33
|
+
|
34
|
+
def app
|
35
|
+
@@wrapper_app
|
36
|
+
end
|
37
|
+
|
38
|
+
def test_cross_process_doesnt_modify_without_header
|
39
|
+
get '/'
|
40
|
+
assert_nil last_response.headers["X-NewRelic-App-Data"]
|
41
|
+
end
|
42
|
+
|
43
|
+
def test_cross_process_doesnt_modify_with_invalid_header
|
44
|
+
get '/', nil, {'X-NewRelic-ID' => Base64.encode64('otherjunk')}
|
45
|
+
assert_nil last_response.headers["X-NewRelic-App-Data"]
|
46
|
+
end
|
47
|
+
|
48
|
+
def test_cross_process_writes_out_information
|
49
|
+
get '/', nil, {'X-NewRelic-ID' => Base64.encode64('1#234')}
|
50
|
+
assert_not_nil last_response.headers["X-NewRelic-App-Data"]
|
51
|
+
|
52
|
+
metric = NewRelic::Agent.instance.stats_engine.lookup_stats('ClientApplication/1#234/all')
|
53
|
+
assert_equal 1, metric.call_count
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
@@ -36,27 +36,50 @@ class LoggingTest < Test::Unit::TestCase
|
|
36
36
|
end
|
37
37
|
|
38
38
|
def test_logs_raw_sql_warning
|
39
|
-
NewRelic::Agent.config.apply_config(:'transaction_tracer.record_sql' => 'obfuscated')
|
40
|
-
|
41
39
|
running_agent_writes_to_log(
|
42
|
-
{:'transaction_tracer.record_sql' => '
|
43
|
-
"Agent is configured to send raw SQL to the service")
|
40
|
+
{:'transaction_tracer.record_sql' => 'obfuscated'},
|
41
|
+
"Agent is configured to send raw SQL to the service") do
|
42
|
+
|
43
|
+
NewRelic::Agent.config.apply_config(:'transaction_tracer.record_sql' => 'raw')
|
44
|
+
end
|
45
|
+
|
44
46
|
end
|
45
47
|
|
46
|
-
def
|
47
|
-
|
48
|
+
def test_logs_ssl_warning
|
49
|
+
running_agent_writes_to_log(
|
50
|
+
{:ssl => false},
|
51
|
+
"Agent is configured not to use SSL when communicating with New Relic's servers") do
|
52
|
+
|
53
|
+
NewRelic::Agent.config.apply_config(:ssl => false)
|
54
|
+
end
|
55
|
+
end
|
48
56
|
|
57
|
+
def test_logs_ssl_verify_cert_warning
|
49
58
|
running_agent_writes_to_log(
|
50
|
-
{:
|
51
|
-
"
|
59
|
+
{:ssl => false, :verify_certificate => false},
|
60
|
+
"Agent is configured to use SSL but to skip certificate validation when communicating with New Relic's servers") do
|
61
|
+
|
62
|
+
NewRelic::Agent.config.apply_config(:ssl => true, :verify_certificate => false)
|
63
|
+
end
|
52
64
|
end
|
53
65
|
|
54
|
-
def test_logs_if_not_sending_errors_on_change
|
55
|
-
NewRelic::Agent.config.apply_config(:'error_collector.enabled' => true)
|
56
66
|
|
67
|
+
def test_logs_if_sending_errors_on_change
|
57
68
|
running_agent_writes_to_log(
|
58
69
|
{:'error_collector.enabled' => false},
|
59
|
-
"Errors will
|
70
|
+
"Errors will be sent") do
|
71
|
+
|
72
|
+
NewRelic::Agent.config.apply_config(:'error_collector.enabled' => true)
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
def test_logs_if_not_sending_errors_on_change
|
77
|
+
running_agent_writes_to_log(
|
78
|
+
{:'error_collector.enabled' => true},
|
79
|
+
"Errors will not be sent") do
|
80
|
+
|
81
|
+
NewRelic::Agent.config.apply_config(:'error_collector.enabled' => false)
|
82
|
+
end
|
60
83
|
end
|
61
84
|
|
62
85
|
def test_logs_transaction_tracing_disabled
|
@@ -103,8 +126,7 @@ class LoggingTest < Test::Unit::TestCase
|
|
103
126
|
$collector.run
|
104
127
|
|
105
128
|
NewRelic::Agent.reset_config
|
106
|
-
NewRelic::Agent
|
107
|
-
NewRelic::Control.instance(true)
|
129
|
+
NewRelic::Agent::Agent.instance_variable_set(:@instance, nil)
|
108
130
|
|
109
131
|
@logger = NewRelic::Agent::MemoryLogger.new
|
110
132
|
NewRelic::Agent.logger = @logger
|
@@ -113,25 +135,23 @@ class LoggingTest < Test::Unit::TestCase
|
|
113
135
|
|
114
136
|
def teardown
|
115
137
|
$collector.reset
|
138
|
+
|
139
|
+
# Really clear out our agent instance since we set bad license keys
|
140
|
+
NewRelic::Agent::Agent.instance_variable_set(:@instance, nil)
|
116
141
|
end
|
117
142
|
|
118
143
|
# Helpers
|
119
144
|
def running_agent_writes_to_log(options, msg)
|
120
|
-
|
121
|
-
|
122
|
-
|
145
|
+
NewRelic::Agent.manual_start(options)
|
146
|
+
yield if block_given?
|
147
|
+
NewRelic::Agent.shutdown
|
148
|
+
saw?(msg)
|
123
149
|
end
|
124
150
|
|
125
151
|
def with_connect_response(status=200, response={})
|
126
152
|
$collector.mock['connect'] = [status, response]
|
127
153
|
end
|
128
154
|
|
129
|
-
def run_agent_with(options = {})
|
130
|
-
NewRelic::Agent.manual_start(options)
|
131
|
-
NewRelic::Agent.shutdown
|
132
|
-
yield
|
133
|
-
end
|
134
|
-
|
135
155
|
def saw?(*expected_messages)
|
136
156
|
flattened = @logger.messages.flatten
|
137
157
|
expected_messages.each do |expected|
|
@@ -0,0 +1,17 @@
|
|
1
|
+
|
2
|
+
class NoDnsResolv < Test::Unit::TestCase
|
3
|
+
def test_should_no_resolve_hostname_when_agent_is_disabled
|
4
|
+
Resolv.expects(:getaddress).never
|
5
|
+
NewRelic::Agent.manual_start(:monitor_mode => false)
|
6
|
+
end
|
7
|
+
|
8
|
+
def setup
|
9
|
+
NewRelic::Agent::Agent.instance_variable_set(:@instance, NewRelic::Agent::Agent.new)
|
10
|
+
end
|
11
|
+
|
12
|
+
def teardown
|
13
|
+
$collector.reset
|
14
|
+
NewRelic::Agent.shutdown
|
15
|
+
NewRelic::Agent::Agent.instance_variable_set(:@instance, nil)
|
16
|
+
end
|
17
|
+
end
|
@@ -1,68 +1,47 @@
|
|
1
|
-
require 'test
|
2
|
-
require "rack/test"
|
1
|
+
require 'rack/test'
|
3
2
|
require 'new_relic/rack/browser_monitoring'
|
4
|
-
require '
|
5
|
-
|
6
|
-
class MyApp
|
7
|
-
# allow tests to set up the response they want.
|
8
|
-
class << self
|
9
|
-
def reset_headers
|
10
|
-
@headers = {'Content-Type' => 'text/html'}
|
11
|
-
end
|
12
|
-
attr_accessor :response
|
13
|
-
attr_accessor :headers
|
14
|
-
def add_header(key, value)
|
15
|
-
@headers[key] = value
|
16
|
-
@headers
|
17
|
-
end
|
18
|
-
end
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
def call(env)
|
23
|
-
[200, self.class.headers, [self.class.response]]
|
24
|
-
end
|
25
|
-
end
|
26
|
-
|
27
|
-
NewRelic::Agent.manual_start(:browser_key => 'browserKey', :application_id => 'appId',
|
28
|
-
:beacon => 'beacon', :episodes_file => 'this_is_my_file')
|
29
|
-
NewRelic::Agent.instance.instance_eval do
|
30
|
-
@beacon_configuration = NewRelic::Agent::BeaconConfiguration.new
|
31
|
-
end
|
3
|
+
require './testing_app'
|
32
4
|
|
33
5
|
class RumAutoTest < Test::Unit::TestCase
|
34
|
-
def setup
|
35
|
-
MyApp.reset_headers
|
36
|
-
end
|
37
6
|
|
7
|
+
attr_reader :app
|
38
8
|
include Rack::Test::Methods
|
39
9
|
|
40
|
-
def
|
41
|
-
|
10
|
+
def setup
|
11
|
+
@inner_app = TestingApp.new
|
12
|
+
@app = NewRelic::Rack::BrowserMonitoring.new(@inner_app)
|
13
|
+
|
14
|
+
NewRelic::Agent.manual_start(:browser_key => 'browserKey', :application_id => 'appId',
|
15
|
+
:beacon => 'beacon', :episodes_file => 'this_is_my_file')
|
16
|
+
NewRelic::Agent.instance.instance_variable_set(
|
17
|
+
:@beacon_configuration, NewRelic::Agent::BeaconConfiguration.new)
|
42
18
|
end
|
43
19
|
|
20
|
+
def teardown
|
21
|
+
NewRelic::Agent.shutdown
|
22
|
+
end
|
44
23
|
|
45
24
|
def test_autoinstrumenation_is_active
|
46
|
-
|
25
|
+
@inner_app.response = "<html><head><title>W00t!</title></head><body><p>Hello World</p></body></html>"
|
47
26
|
get '/'
|
48
27
|
assert(last_response.body =~ %r|<script|, "response body should include RUM auto instrumentation js:\n #{last_response.body}")
|
49
28
|
assert(last_response.body =~ %r|NREUMQ|, "response body should include RUM auto instrumentation js:\n #{last_response.body}")
|
50
29
|
end
|
51
30
|
|
52
31
|
def test_autoinstrumenation_with_basic_page_puts_header_at_beggining_of_head
|
53
|
-
|
32
|
+
@inner_app.response = "<html><head><title>foo</title></head><body><p>Hello World</p></body></html>"
|
54
33
|
get '/'
|
55
34
|
assert(last_response.body.include?('<html><head><script type="text/javascript">var NREUMQ=NREUMQ||[];NREUMQ.push(["mark","firstbyte",new Date().getTime()]);</script><title>foo</title></head><body>'))
|
56
35
|
end
|
57
36
|
|
58
37
|
def test_autoinstrumenation_with_body_only_puts_header_before_body
|
59
|
-
|
38
|
+
@inner_app.response = "<html><body><p>Hello World</p></body></html>"
|
60
39
|
get '/'
|
61
40
|
assert(last_response.body.include?('<html><script type="text/javascript">var NREUMQ=NREUMQ||[];NREUMQ.push(["mark","firstbyte",new Date().getTime()]);</script><body>'))
|
62
41
|
end
|
63
42
|
|
64
43
|
def test_autoinstrumenation_with_X_UA_Compatible_puts_header_at_end_of_head
|
65
|
-
|
44
|
+
@inner_app.response = '<html><head><meta http-equiv="X-UA-Compatible" content="IE=8;FF=3;OtherUA=4" /></head><body><p>Hello World</p></body></html>'
|
66
45
|
get '/'
|
67
46
|
assert(last_response.body.include?(
|
68
47
|
'<html><head><meta http-equiv="X-UA-Compatible" content="IE=8;FF=3;OtherUA=4" /><script type="text/javascript">var NREUMQ=NREUMQ||[];NREUMQ.push(["mark","firstbyte",new Date().getTime()]);</script></head><body>'
|
@@ -71,21 +50,21 @@ class RumAutoTest < Test::Unit::TestCase
|
|
71
50
|
|
72
51
|
# regression
|
73
52
|
def test_autoinstrumenation_fails_gracefully_with_X_UA_Compatible_and_no_close_head_tag_puts_header_before_body_tag
|
74
|
-
|
53
|
+
@inner_app.response = '<html><head><meta http-equiv="X-UA-Compatible" content="IE=8;FF=3;OtherUA=4" /><body><p>Hello World</p></body></html>'
|
75
54
|
get '/'
|
76
55
|
assert(!last_response.body.include?(%'NREUMQ'))
|
77
56
|
end
|
78
57
|
|
79
58
|
def test_autoinstrumenation_doesnt_run_for_crazy_shit_like_this
|
80
|
-
|
59
|
+
@inner_app.response = '<html><head <body </body>'
|
81
60
|
get '/'
|
82
61
|
assert_equal('<html><head <body </body>', last_response.body)
|
83
62
|
end
|
84
63
|
|
85
64
|
def test_content_length_is_correctly_set_if_present
|
86
|
-
|
87
|
-
content_length =
|
88
|
-
|
65
|
+
@inner_app.response = "<html><head><title>W00t!</title></head><body><p>Hello World</p></body></html>"
|
66
|
+
content_length = @inner_app.response.length
|
67
|
+
@inner_app.headers["Content-Length"] = content_length
|
89
68
|
get '/'
|
90
69
|
assert(last_response.headers['Content-Length'].to_i > content_length)
|
91
70
|
assert_equal(last_response.body.length.to_s, last_response.headers['Content-Length'])
|
@@ -93,8 +72,8 @@ class RumAutoTest < Test::Unit::TestCase
|
|
93
72
|
|
94
73
|
def test_xml_responses_arent_instrumented
|
95
74
|
body = "<html><head><title>W00t!</title></head><body><p>Hello World</p></body></html>"
|
96
|
-
|
97
|
-
|
75
|
+
@inner_app.response = body
|
76
|
+
@inner_app.headers["Content-Type"] = "text/xml"
|
98
77
|
get '/'
|
99
78
|
assert_equal(last_response.body, body)
|
100
79
|
end
|
@@ -1,8 +1,11 @@
|
|
1
1
|
require 'socket'
|
2
2
|
|
3
3
|
class ServiceTimeoutTest < Test::Unit::TestCase
|
4
|
+
|
5
|
+
PORT = 10_000 + ($$ % 10_000)
|
6
|
+
|
4
7
|
def setup
|
5
|
-
hk = TCPServer.new('127.0.0.1',
|
8
|
+
hk = TCPServer.new('127.0.0.1',PORT)
|
6
9
|
|
7
10
|
Thread.new {
|
8
11
|
client = hk.accept
|
@@ -14,8 +17,8 @@ class ServiceTimeoutTest < Test::Unit::TestCase
|
|
14
17
|
end
|
15
18
|
|
16
19
|
def test_service_timeout
|
17
|
-
server = NewRelic::Control::Server.new('localhost',
|
18
|
-
NewRelic::Agent.config.apply_config(:timeout =>
|
20
|
+
server = NewRelic::Control::Server.new('localhost',PORT,'127.0.0.1')
|
21
|
+
NewRelic::Agent.config.apply_config(:timeout => 0.1)
|
19
22
|
|
20
23
|
service = NewRelic::Agent::NewRelicService.new('deadbeef', server)
|
21
24
|
|
@@ -0,0 +1,22 @@
|
|
1
|
+
class SSLTest < Test::Unit::TestCase
|
2
|
+
|
3
|
+
def setup
|
4
|
+
# This is similar to how jruby 1.6.8 behaves when jruby-openssl isn't
|
5
|
+
# installed
|
6
|
+
@original_ssl_config = NewRelic::Agent.config[:ssl]
|
7
|
+
NewRelic::Agent.config.apply_config(:ssl => true)
|
8
|
+
NewRelic::Agent.agent = NewRelic::Agent::Agent.new
|
9
|
+
Net::HTTPSession.any_instance.stubs('use_ssl=').raises(LoadError)
|
10
|
+
end
|
11
|
+
|
12
|
+
def teardown
|
13
|
+
NewRelic::Agent.config.apply_config(:ssl => @original_ssl_config)
|
14
|
+
end
|
15
|
+
|
16
|
+
def test_agent_shuts_down_when_ssl_is_on_but_unavailable
|
17
|
+
::NewRelic::Agent.agent.expects(:shutdown)
|
18
|
+
::NewRelic::Agent.expects(:finish_setup).never
|
19
|
+
::NewRelic::Agent.agent.connect_in_foreground
|
20
|
+
ensure
|
21
|
+
end
|
22
|
+
end
|
@@ -7,8 +7,15 @@ class StartUpTest < Test::Unit::TestCase
|
|
7
7
|
cmd = "bundle exec ruby -e '#{ruby}'"
|
8
8
|
|
9
9
|
sin, sout, serr = Open3.popen3(cmd)
|
10
|
+
output = sout.read + serr.read
|
10
11
|
|
11
|
-
jruby_noise =
|
12
|
-
|
12
|
+
jruby_noise = [
|
13
|
+
"JRuby limited openssl loaded. http://jruby.org/openssl\n",
|
14
|
+
"gem install jruby-openssl for full support.\n",
|
15
|
+
/Exception\: java\.lang.*\n/]
|
16
|
+
|
17
|
+
jruby_noise.each {|noise| output.gsub!(noise, "")}
|
18
|
+
|
19
|
+
assert_equal '', output
|
13
20
|
end
|
14
21
|
end
|