newrelic_rpm 3.7.1.188 → 3.7.2.190.beta
Sign up to get free protection for your applications and to get access to all the features.
- data.tar.gz.sig +3 -2
- data/CHANGELOG +1 -1
- data/Guardfile +3 -3
- data/README.md +1 -1
- data/Rakefile +0 -2
- data/init.rb +2 -5
- data/lib/new_relic/agent.rb +3 -0
- data/lib/new_relic/agent/agent.rb +2 -0
- data/lib/new_relic/agent/configuration/default_source.rb +32 -14
- data/lib/new_relic/agent/configuration/environment_source.rb +1 -0
- data/lib/new_relic/agent/cross_app_monitor.rb +2 -2
- data/lib/new_relic/agent/cross_app_tracing.rb +2 -2
- data/lib/new_relic/agent/error_collector.rb +1 -1
- data/lib/new_relic/agent/http_clients/typhoeus_wrappers.rb +4 -1
- data/lib/new_relic/agent/instrumentation/action_controller_subscriber.rb +10 -8
- data/lib/new_relic/agent/instrumentation/action_view_subscriber.rb +11 -6
- data/lib/new_relic/agent/javascript_instrumentor.rb +27 -36
- data/lib/new_relic/agent/method_tracer.rb +20 -2
- data/lib/new_relic/agent/new_relic_service.rb +35 -27
- data/lib/new_relic/agent/request_sampler.rb +20 -13
- data/lib/new_relic/agent/sampler_collection.rb +4 -0
- data/lib/new_relic/agent/stats_engine/stats_hash.rb +4 -4
- data/lib/new_relic/agent/system_info.rb +25 -15
- data/lib/new_relic/agent/transaction.rb +23 -4
- data/lib/new_relic/agent/transaction_sampler.rb +1 -1
- data/lib/new_relic/cli/install.rb +1 -1
- data/lib/new_relic/control.rb +1 -0
- data/lib/new_relic/helper.rb +1 -29
- data/lib/new_relic/json_wrapper.rb +92 -0
- data/lib/new_relic/language_support.rb +4 -0
- data/lib/new_relic/rack/agent_hooks.rb +4 -0
- data/lib/new_relic/rack/browser_monitoring.rb +4 -0
- data/lib/new_relic/rack/developer_mode.rb +4 -1
- data/lib/new_relic/rack/error_collector.rb +5 -0
- data/lib/new_relic/rack/transaction_reset.rb +20 -0
- data/lib/new_relic/version.rb +1 -1
- data/lib/tasks/install.rake +0 -1
- data/newrelic_rpm.gemspec +1 -1
- data/test/agent_helper.rb +7 -8
- data/test/environments/norails/Gemfile +2 -1
- data/test/environments/rails21/Gemfile +2 -2
- data/test/environments/rails21/config/environment.rb +1 -3
- data/test/environments/rails21/config/environments/development.rb +0 -6
- data/test/environments/rails22/Gemfile +2 -2
- data/test/environments/rails22/config/environment.rb +0 -2
- data/test/environments/rails22/config/environments/development.rb +0 -6
- data/test/environments/rails23/Gemfile +2 -3
- data/test/environments/rails23/config/environment.rb +0 -9
- data/test/environments/rails23/config/environments/development.rb +0 -5
- data/test/environments/rails30/Gemfile +2 -2
- data/test/environments/rails31/Gemfile +2 -2
- data/test/environments/rails32/Gemfile +2 -1
- data/test/environments/rails40/Gemfile +2 -1
- data/test/intentional_fail.rb +1 -2
- data/test/multiverse/lib/multiverse/envfile.rb +1 -5
- data/test/multiverse/lib/multiverse/suite.rb +10 -27
- data/test/multiverse/suites/active_record/ar_method_aliasing.rb +49 -67
- data/test/multiverse/suites/agent_only/encoding_handling_test.rb +128 -0
- data/test/multiverse/suites/agent_only/marshaling_test.rb +7 -9
- data/test/multiverse/suites/agent_only/script/loading.rb +20 -0
- data/test/multiverse/suites/agent_only/start_up_test.rb +7 -0
- data/test/multiverse/suites/bare/Envfile +3 -0
- data/test/multiverse/suites/bare/standalone_instrumentation_test.rb +43 -0
- data/test/multiverse/suites/rails/Envfile +0 -2
- data/test/multiverse/suites/rails/app/views/views/_a_partial.html.erb +1 -0
- data/test/multiverse/suites/rails/app/views/views/index.html.erb +1 -1
- data/test/multiverse/suites/rails/error_tracing_test.rb +1 -1
- data/test/multiverse/suites/rails/request_statistics_test.rb +9 -4
- data/test/multiverse/suites/rails/view_instrumentation_test.rb +111 -106
- data/test/multiverse/suites/typhoeus/Envfile +1 -1
- data/test/multiverse/suites/typhoeus/typhoeus_test.rb +16 -2
- data/test/multiverse/test/multiverse_test.rb +2 -2
- data/test/new_relic/agent/agent/connect_test.rb +1 -1
- data/test/new_relic/agent/agent/start_test.rb +1 -1
- data/test/new_relic/agent/agent/start_worker_thread_test.rb +1 -1
- data/test/new_relic/agent/agent_logger_test.rb +3 -7
- data/test/new_relic/agent/agent_test.rb +33 -57
- data/test/new_relic/agent/apdex_from_server_test.rb +1 -1
- data/test/new_relic/agent/audit_logger_test.rb +5 -8
- data/test/new_relic/agent/autostart_test.rb +1 -1
- data/test/new_relic/agent/browser_token_test.rb +1 -1
- data/test/new_relic/agent/busy_calculator_test.rb +2 -4
- data/test/new_relic/agent/commands/agent_command_router_test.rb +5 -5
- data/test/new_relic/agent/commands/agent_command_test.rb +1 -1
- data/test/new_relic/agent/commands/thread_profiler_session_test.rb +6 -6
- data/test/new_relic/agent/commands/xray_session_collection_test.rb +10 -10
- data/test/new_relic/agent/commands/xray_session_test.rb +1 -1
- data/test/new_relic/agent/configuration/default_source_test.rb +4 -4
- data/test/new_relic/agent/configuration/environment_source_test.rb +14 -2
- data/test/new_relic/agent/configuration/manager_test.rb +3 -3
- data/test/new_relic/agent/configuration/orphan_configuration_test.rb +1 -1
- data/test/new_relic/agent/configuration/server_source_test.rb +1 -1
- data/test/new_relic/agent/configuration/yaml_source_test.rb +2 -2
- data/test/new_relic/agent/cpu_sampler_test.rb +1 -1
- data/test/new_relic/agent/cross_app_monitor_test.rb +3 -3
- data/test/new_relic/agent/cross_app_tracing_test.rb +5 -4
- data/test/new_relic/agent/database_test.rb +1 -1
- data/test/new_relic/agent/datastores/mongo/metric_generator_test.rb +1 -1
- data/test/new_relic/agent/datastores/mongo/metric_translator_test.rb +1 -1
- data/test/new_relic/agent/datastores/mongo/obfuscator_test.rb +1 -1
- data/test/new_relic/agent/datastores/mongo/statement_formatter_test.rb +2 -2
- data/test/new_relic/agent/error_collector/notice_error_test.rb +1 -1
- data/test/new_relic/agent/error_collector_test.rb +5 -3
- data/test/new_relic/agent/event_listener_test.rb +1 -1
- data/test/new_relic/agent/harvester_test.rb +1 -1
- data/test/new_relic/agent/http_clients/uri_util_test.rb +1 -1
- data/test/new_relic/agent/instrumentation/action_controller_subscriber_test.rb +1 -1
- data/test/new_relic/agent/instrumentation/action_view_subscriber_test.rb +1 -1
- data/test/new_relic/agent/instrumentation/active_record_helper_test.rb +1 -1
- data/test/new_relic/agent/instrumentation/active_record_instrumentation_test.rb +495 -495
- data/test/new_relic/agent/instrumentation/active_record_subscriber_test.rb +2 -2
- data/test/new_relic/agent/instrumentation/controller_instrumentation_test.rb +1 -1
- data/test/new_relic/agent/instrumentation/instrumentation_test.rb +1 -1
- data/test/new_relic/agent/instrumentation/metric_frame_test.rb +1 -1
- data/test/new_relic/agent/instrumentation/net_instrumentation_test.rb +4 -6
- data/test/new_relic/agent/instrumentation/queue_time_test.rb +1 -1
- data/test/new_relic/agent/instrumentation/rack_test.rb +1 -1
- data/test/new_relic/agent/instrumentation/sinatra/transaction_namer_test.rb +1 -1
- data/test/new_relic/agent/instrumentation/sinatra_test.rb +1 -1
- data/test/new_relic/agent/instrumentation/task_instrumentation_test.rb +7 -7
- data/test/new_relic/agent/javascript_instrumentor_test.rb +47 -55
- data/test/new_relic/agent/memcache_instrumentation_test.rb +1 -1
- data/test/new_relic/agent/memory_logger_test.rb +1 -1
- data/test/new_relic/agent/method_interrobang_test.rb +2 -3
- data/test/new_relic/agent/method_tracer/class_methods/add_method_tracer_test.rb +4 -4
- data/test/new_relic/agent/method_tracer/instance_methods/trace_execution_scoped_test.rb +1 -1
- data/test/new_relic/agent/method_tracer_test.rb +6 -7
- data/test/new_relic/agent/method_visibility_test.rb +1 -1
- data/test/new_relic/agent/new_relic_service_test.rb +129 -19
- data/test/new_relic/agent/obfuscator_test.rb +1 -1
- data/test/new_relic/agent/pipe_channel_manager_test.rb +143 -145
- data/test/new_relic/agent/pipe_service_test.rb +2 -4
- data/test/new_relic/agent/request_sampler_test.rb +23 -19
- data/test/new_relic/agent/rpm_agent_test.rb +3 -3
- data/test/new_relic/agent/rules_engine_test.rb +1 -1
- data/test/new_relic/agent/sampled_buffer_test.rb +1 -1
- data/test/new_relic/agent/sampler_collection_test.rb +3 -3
- data/test/new_relic/agent/sampler_test.rb +1 -1
- data/test/new_relic/agent/shim_agent_test.rb +1 -1
- data/test/new_relic/agent/sql_sampler_test.rb +4 -6
- data/test/new_relic/agent/stats_engine/gc_profiler_test.rb +1 -1
- data/test/new_relic/agent/stats_engine/metric_stats_test.rb +5 -5
- data/test/new_relic/agent/stats_engine/samplers_test.rb +2 -2
- data/test/new_relic/agent/stats_engine_test.rb +3 -3
- data/test/new_relic/agent/stats_hash_test.rb +2 -2
- data/test/new_relic/agent/stats_test.rb +1 -1
- data/test/new_relic/agent/threading/agent_thread_test.rb +2 -4
- data/test/new_relic/agent/threading/backtrace_node_test.rb +1 -1
- data/test/new_relic/agent/threading/backtrace_service_test.rb +5 -5
- data/test/new_relic/agent/threading/thread_profile_test.rb +1 -1
- data/test/new_relic/agent/transaction/developer_mode_sample_buffer_test.rb +1 -1
- data/test/new_relic/agent/transaction/force_persist_sample_buffer_test.rb +1 -1
- data/test/new_relic/agent/transaction/pop_test.rb +1 -1
- data/test/new_relic/agent/transaction/slowest_sample_buffer_test.rb +1 -1
- data/test/new_relic/agent/transaction/xray_sample_buffer_test.rb +1 -1
- data/test/new_relic/agent/transaction_interrobang_test.rb +2 -3
- data/test/new_relic/agent/transaction_sample_builder_test.rb +16 -14
- data/test/new_relic/agent/transaction_sampler_test.rb +16 -21
- data/test/new_relic/agent/transaction_state_test.rb +1 -1
- data/test/new_relic/agent/transaction_test.rb +61 -1
- data/test/new_relic/agent/transaction_timings_test.rb +1 -1
- data/test/new_relic/agent/worker_loop_test.rb +1 -1
- data/test/new_relic/agent_test.rb +2 -3
- data/test/new_relic/cli/deployments_test.rb +3 -3
- data/test/new_relic/coerce_test.rb +1 -1
- data/test/new_relic/collection_helper_test.rb +1 -1
- data/test/new_relic/control/class_methods_test.rb +2 -2
- data/test/new_relic/control/frameworks/rails_test.rb +1 -1
- data/test/new_relic/control_test.rb +9 -4
- data/test/new_relic/dependency_detection_test.rb +1 -1
- data/test/new_relic/dispatcher_test.rb +1 -1
- data/test/new_relic/environment_report_test.rb +4 -6
- data/test/new_relic/fake_collector.rb +1 -158
- data/test/new_relic/framework_test.rb +2 -1
- data/test/new_relic/http_client_test_cases.rb +2 -3
- data/test/new_relic/json_wrapper_test.rb +77 -0
- data/test/new_relic/language_support_test.rb +1 -1
- data/test/new_relic/license_test.rb +2 -2
- data/test/new_relic/load_test.rb +2 -8
- data/test/new_relic/local_environment_test.rb +1 -1
- data/test/new_relic/metric_data_test.rb +1 -1
- data/test/new_relic/metric_parser/metric_parser_test.rb +1 -1
- data/test/new_relic/metric_spec_test.rb +1 -1
- data/test/new_relic/multiverse_helpers.rb +26 -30
- data/test/new_relic/noticed_error_test.rb +1 -1
- data/test/new_relic/rack/agent_hooks_test.rb +1 -1
- data/test/new_relic/rack/all_test.rb +1 -1
- data/test/new_relic/rack/browser_monitoring_test.rb +4 -2
- data/test/new_relic/rack/deferred_instrumentation_test.rb +3 -5
- data/test/new_relic/rack/developer_mode_helper_test.rb +1 -1
- data/test/new_relic/rack/developer_mode_test.rb +1 -1
- data/test/new_relic/rack/error_collector_test.rb +8 -8
- data/test/new_relic/rack/transaction_reset_test.rb +35 -0
- data/test/new_relic/transaction_analysis/segment_summary_test.rb +2 -2
- data/test/new_relic/transaction_analysis_test.rb +1 -1
- data/test/new_relic/transaction_sample/composite_segment_test.rb +1 -1
- data/test/new_relic/transaction_sample/fake_segment_test.rb +2 -4
- data/test/new_relic/transaction_sample/segment_test.rb +3 -7
- data/test/new_relic/transaction_sample/summary_segment_test.rb +1 -1
- data/test/new_relic/transaction_sample_subtest_test.rb +1 -1
- data/test/new_relic/transaction_sample_test.rb +4 -6
- data/test/new_relic/version_number_test.rb +1 -1
- data/test/performance/lib/performance/instrumentation/gc_stats.rb +1 -1
- data/test/performance/lib/performance/json_reporter.rb +1 -1
- data/test/performance/suites/marshalling.rb +76 -0
- data/test/test_helper.rb +6 -39
- metadata +19 -12
- metadata.gz.sig +0 -0
- data/test/new_relic/helper_test.rb +0 -32
@@ -5,7 +5,7 @@
|
|
5
5
|
require File.expand_path(File.join(File.dirname(__FILE__),'..', 'test_helper'))
|
6
6
|
|
7
7
|
# Test logic around detecting or configuring dispatcher
|
8
|
-
class DispatcherTest <
|
8
|
+
class DispatcherTest < MiniTest::Unit::TestCase
|
9
9
|
|
10
10
|
def setup
|
11
11
|
NewRelic::Agent.shutdown
|
@@ -6,7 +6,7 @@ require File.expand_path(File.join(File.dirname(__FILE__),'..','test_helper'))
|
|
6
6
|
|
7
7
|
require 'new_relic/environment_report'
|
8
8
|
|
9
|
-
class EnvironmentReportTest <
|
9
|
+
class EnvironmentReportTest < MiniTest::Unit::TestCase
|
10
10
|
def setup
|
11
11
|
@old_logic = ::NewRelic::EnvironmentReport.registered_reporters.dup
|
12
12
|
@report = ::NewRelic::EnvironmentReport.new
|
@@ -31,12 +31,10 @@ class EnvironmentReportTest < Test::Unit::TestCase
|
|
31
31
|
end
|
32
32
|
|
33
33
|
def test_report_on_handles_errors_gracefully
|
34
|
-
|
35
|
-
|
36
|
-
raise ArgumentError, "woah! something blew up"
|
37
|
-
end
|
38
|
-
assert_nil ::NewRelic::EnvironmentReport.new["What time is it?"]
|
34
|
+
::NewRelic::EnvironmentReport.report_on("What time is it?") do
|
35
|
+
raise ArgumentError, "woah! something blew up"
|
39
36
|
end
|
37
|
+
assert_nil ::NewRelic::EnvironmentReport.new["What time is it?"]
|
40
38
|
end
|
41
39
|
|
42
40
|
def test_it_does_not_set_keys_for_nil_values
|
@@ -270,7 +270,6 @@ module NewRelic
|
|
270
270
|
class SubmittedTransactionTraceTree
|
271
271
|
def initialize(body, format)
|
272
272
|
@body = body
|
273
|
-
@body = AgentPost.unblob(@body) if format == :json
|
274
273
|
end
|
275
274
|
|
276
275
|
def request_params
|
@@ -295,7 +294,7 @@ module NewRelic
|
|
295
294
|
|
296
295
|
def initialize(opts={})
|
297
296
|
super
|
298
|
-
@body[4] = unblob(@body[4]) if @format == :json
|
297
|
+
@body[1][0][4] = unblob(@body[1][0][4]) if @format == :json
|
299
298
|
end
|
300
299
|
|
301
300
|
def samples
|
@@ -318,159 +317,3 @@ module NewRelic
|
|
318
317
|
end
|
319
318
|
|
320
319
|
end
|
321
|
-
|
322
|
-
if $0 == __FILE__
|
323
|
-
require 'test/unit'
|
324
|
-
require 'net/http'
|
325
|
-
|
326
|
-
class FakeCollectorTest < Test::Unit::TestCase
|
327
|
-
def setup
|
328
|
-
@collector = NewRelic::FakeCollector.new
|
329
|
-
@collector.run
|
330
|
-
end
|
331
|
-
|
332
|
-
def teardown
|
333
|
-
@collector.stop
|
334
|
-
end
|
335
|
-
|
336
|
-
def test_get_redirect
|
337
|
-
@collector.mock['get_redirect_host'].evaluate = [200, 'test.example.com']
|
338
|
-
response = invoke('get_redirect_host')
|
339
|
-
|
340
|
-
assert_equal 'test.example.com', response
|
341
|
-
assert_equal 'get_redirect_host', @collector.agent_data[0].action
|
342
|
-
end
|
343
|
-
|
344
|
-
def test_connect
|
345
|
-
response = invoke('connect')
|
346
|
-
|
347
|
-
assert_equal 1, response['agent_run_id']
|
348
|
-
assert_equal 'connect', @collector.agent_data[0].action
|
349
|
-
end
|
350
|
-
|
351
|
-
def test_metric_data
|
352
|
-
response = invoke('metric_data?run_id=1',
|
353
|
-
{'Foo/Bar' => [1,2,3], 'Baz/Cux' => [4,5,6]})
|
354
|
-
|
355
|
-
assert_equal 1, response['Some/Metric/Spec']
|
356
|
-
post = @collector.agent_data[0]
|
357
|
-
assert_equal 'metric_data', post.action
|
358
|
-
assert_equal({'Foo/Bar' => [1,2,3], 'Baz/Cux' => [4,5,6]}, post.body)
|
359
|
-
assert_equal 1, post.run_id.to_i
|
360
|
-
end
|
361
|
-
|
362
|
-
def test_sql_trace_data
|
363
|
-
response = invoke('sql_trace_data?run_id=2',
|
364
|
-
['trace', 'trace', 'trace'])
|
365
|
-
|
366
|
-
assert_nil response
|
367
|
-
post = @collector.agent_data[0]
|
368
|
-
assert_equal 'sql_trace_data', post.action
|
369
|
-
assert_equal ['trace', 'trace', 'trace'], post.body
|
370
|
-
assert_equal 2, post.run_id.to_i
|
371
|
-
end
|
372
|
-
|
373
|
-
def test_transaction_sample_data
|
374
|
-
response = invoke('transaction_sample_data?run_id=3',
|
375
|
-
['node', ['node', 'node'], 'node'])
|
376
|
-
|
377
|
-
assert_nil response
|
378
|
-
post = @collector.agent_data[0]
|
379
|
-
assert_equal 'transaction_sample_data', post.action
|
380
|
-
assert_equal ['node', ['node', 'node'], 'node'], post.body
|
381
|
-
assert_equal 3, post.run_id.to_i
|
382
|
-
end
|
383
|
-
|
384
|
-
def test_transaction_sample_data_json
|
385
|
-
response = invoke('transaction_sample_data?run_id=3&marshal_format=json',
|
386
|
-
'["node",["node","node"],"node"]')
|
387
|
-
|
388
|
-
assert_equal '', response
|
389
|
-
post = @collector.agent_data[0]
|
390
|
-
assert_equal 'transaction_sample_data', post.action
|
391
|
-
assert_equal '["node",["node","node"],"node"]', post.body
|
392
|
-
assert_equal 3, post.run_id.to_i
|
393
|
-
end
|
394
|
-
|
395
|
-
def test_error_data
|
396
|
-
response = invoke('error_data?run_id=4', ['error'])
|
397
|
-
|
398
|
-
assert_nil response
|
399
|
-
post = @collector.agent_data[0]
|
400
|
-
assert_equal 'error_data', post.action
|
401
|
-
assert_equal ['error'], post.body
|
402
|
-
end
|
403
|
-
|
404
|
-
def test_analytic_event_data
|
405
|
-
events = [
|
406
|
-
{
|
407
|
-
'type' => 'Transaction',
|
408
|
-
'name' => 'Controller/foo/bar',
|
409
|
-
'duration' => '718',
|
410
|
-
'timestamp' => 1368489547.888435
|
411
|
-
}
|
412
|
-
]
|
413
|
-
response = invoke('analytic_event_data', [33, events])
|
414
|
-
|
415
|
-
assert_nil response['return_value']
|
416
|
-
post = @collector.agent_data[0]
|
417
|
-
assert_equal 'analytic_event_data', post.action
|
418
|
-
assert_equal events, post.body
|
419
|
-
assert_equal 33, post.run_id.to_i
|
420
|
-
end
|
421
|
-
|
422
|
-
def test_shutdown
|
423
|
-
response = invoke('shutdown?run_id=1')
|
424
|
-
|
425
|
-
assert_nil response
|
426
|
-
assert_equal 'shutdown', @collector.agent_data[0].action
|
427
|
-
end
|
428
|
-
|
429
|
-
def test_multiple_invokations
|
430
|
-
pid = Process.fork do
|
431
|
-
invoke('get_redirect_host')
|
432
|
-
invoke('connect')
|
433
|
-
invoke('metric_data?run_id=1')
|
434
|
-
invoke('transaction_sample_data?run_id=1')
|
435
|
-
invoke('shutdown?run_id=1')
|
436
|
-
end
|
437
|
-
invoke('get_redirect_host')
|
438
|
-
invoke('connect')
|
439
|
-
invoke('metric_data?run_id=2')
|
440
|
-
invoke('transaction_sample_data?run_id=2')
|
441
|
-
invoke('shutdown?run_id=2')
|
442
|
-
|
443
|
-
Process.wait(pid)
|
444
|
-
|
445
|
-
expected = ['get_redirect_host', 'connect', 'metric_data',
|
446
|
-
'transaction_sample_data', 'shutdown',
|
447
|
-
'get_redirect_host', 'connect', 'metric_data',
|
448
|
-
'transaction_sample_data', 'shutdown']
|
449
|
-
assert_equal expected.sort, @collector.agent_data.map(&:action).sort
|
450
|
-
end
|
451
|
-
|
452
|
-
def test_reset
|
453
|
-
@collector.mock['get_redirect_host'].evaluate = [200, 'never!']
|
454
|
-
@collector.reset
|
455
|
-
assert_equal [200, 'localhost'], @collector.mock['get_redirect_host'].evaluate
|
456
|
-
end
|
457
|
-
|
458
|
-
def invoke(method, post={}, code=200)
|
459
|
-
uri = URI.parse("http://127.0.0.1:#{@collector.determine_port}/agent_listener/8/12345/#{method}")
|
460
|
-
request = Net::HTTP::Post.new("#{uri.path}?#{uri.query}")
|
461
|
-
if uri.query && uri.query.include?('marshal_format=json')
|
462
|
-
request.body = JSON.dump(post)
|
463
|
-
else
|
464
|
-
request.body = Marshal.dump(post)
|
465
|
-
end
|
466
|
-
response = Net::HTTP.start(uri.host, uri.port) do |http|
|
467
|
-
http.request(request)
|
468
|
-
end
|
469
|
-
if uri.query && uri.query.include?('marshal_format=json')
|
470
|
-
JSON.load(response.body)
|
471
|
-
else
|
472
|
-
Marshal.load(response.body)
|
473
|
-
end
|
474
|
-
end
|
475
|
-
end
|
476
|
-
end
|
@@ -5,7 +5,7 @@
|
|
5
5
|
require File.expand_path(File.join(File.dirname(__FILE__),'..', 'test_helper'))
|
6
6
|
|
7
7
|
# Test logic around detecting or configuring framework
|
8
|
-
class FrameworkTest <
|
8
|
+
class FrameworkTest < MiniTest::Unit::TestCase
|
9
9
|
|
10
10
|
def setup
|
11
11
|
|
@@ -25,6 +25,7 @@ class FrameworkTest < Test::Unit::TestCase
|
|
25
25
|
def teardown
|
26
26
|
# Put things back how we found them
|
27
27
|
::NewRelic.send(:const_set, :TEST, @old_newrelic_test_const)
|
28
|
+
NewRelic::Agent.reset_config
|
28
29
|
end
|
29
30
|
|
30
31
|
def test_detects_framework_via_loaded_libraries
|
@@ -5,7 +5,6 @@
|
|
5
5
|
require "newrelic_rpm"
|
6
6
|
require "fake_external_server"
|
7
7
|
require "evil_server"
|
8
|
-
require 'mocha'
|
9
8
|
require 'multiverse_helpers'
|
10
9
|
|
11
10
|
module HttpClientTestCases
|
@@ -413,7 +412,7 @@ module HttpClientTestCases
|
|
413
412
|
# https://newrelic.atlassian.net/browse/RUBY-1244
|
414
413
|
def test_failure_in_our_start_code_still_records_externals
|
415
414
|
# Fake a failure in our start-up code...
|
416
|
-
NewRelic.stubs(:
|
415
|
+
NewRelic::JSONWrapper.stubs(:dump).raises("Boom!")
|
417
416
|
|
418
417
|
with_config(:"cross_application_tracer.enabled" => true) do
|
419
418
|
get_response
|
@@ -425,7 +424,7 @@ module HttpClientTestCases
|
|
425
424
|
# https://newrelic.atlassian.net/browse/RUBY-1244
|
426
425
|
def test_failure_to_add_tt_node_doesnt_append_params_to_wrong_segment
|
427
426
|
# Fake a failure in our start-up code...
|
428
|
-
NewRelic.stubs(:
|
427
|
+
NewRelic::JSONWrapper.stubs(:dump).raises("Boom!")
|
429
428
|
|
430
429
|
in_transaction do
|
431
430
|
with_config(:"cross_application_tracer.enabled" => true) do
|
@@ -0,0 +1,77 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
# This file is distributed under New Relic's license terms.
|
3
|
+
# See https://github.com/newrelic/rpm/blob/master/LICENSE for complete details.
|
4
|
+
|
5
|
+
require File.expand_path(File.join(File.dirname(__FILE__),'..','test_helper'))
|
6
|
+
require 'test/unit'
|
7
|
+
require 'newrelic_rpm'
|
8
|
+
|
9
|
+
class JSONWrapperTest < Test::Unit::TestCase
|
10
|
+
def test_json_roundtrip
|
11
|
+
obj = [
|
12
|
+
99, 'luftballons',
|
13
|
+
{
|
14
|
+
'Hast du etwas' => 'Zeit für mich',
|
15
|
+
'Dann singe ich' => {
|
16
|
+
'ein lied' => 'für dich'
|
17
|
+
}
|
18
|
+
}
|
19
|
+
]
|
20
|
+
copy = NewRelic::JSONWrapper.load(NewRelic::JSONWrapper.dump(obj))
|
21
|
+
assert(obj == copy)
|
22
|
+
end
|
23
|
+
|
24
|
+
if NewRelic::LanguageSupport.supports_string_encodings?
|
25
|
+
def test_normalize_string_returns_input_if_correctly_encoded_utf8
|
26
|
+
string = "i want a pony"
|
27
|
+
result = NewRelic::JSONWrapper.normalize_string(string)
|
28
|
+
assert_same(string, result)
|
29
|
+
assert_equal(Encoding.find('UTF-8'), result.encoding)
|
30
|
+
end
|
31
|
+
|
32
|
+
def test_normalize_string_returns_munged_copy_if_ascii_8bit
|
33
|
+
string = (0..255).to_a.pack("C*")
|
34
|
+
result = NewRelic::JSONWrapper.normalize_string(string)
|
35
|
+
assert_not_same(string, result)
|
36
|
+
assert_equal(Encoding.find('ISO-8859-1'), result.encoding)
|
37
|
+
assert_equal(string, result.dup.force_encoding('ASCII-8BIT'))
|
38
|
+
end
|
39
|
+
|
40
|
+
def test_normalize_string_returns_munged_copy_if_invalid_utf8
|
41
|
+
string = (0..255).to_a.pack("C*").force_encoding('UTF-8')
|
42
|
+
result = NewRelic::JSONWrapper.normalize_string(string)
|
43
|
+
assert_not_same(result, string)
|
44
|
+
assert_equal(Encoding.find('ISO-8859-1'), result.encoding)
|
45
|
+
assert_equal(string, result.dup.force_encoding('UTF-8'))
|
46
|
+
end
|
47
|
+
|
48
|
+
def test_normalize_string_returns_munged_copy_if_other_convertible_encoding
|
49
|
+
string = "i want a pony".encode('UTF-16LE')
|
50
|
+
result = NewRelic::JSONWrapper.normalize_string(string)
|
51
|
+
assert_not_same(result, string)
|
52
|
+
assert_equal(Encoding.find('UTF-8'), result.encoding)
|
53
|
+
assert_equal(string, result.encode('UTF-16LE'))
|
54
|
+
end
|
55
|
+
|
56
|
+
def test_normalize_string_returns_munged_copy_if_other_non_convertible_enocding
|
57
|
+
# Attempting to convert from UTF-7 to UTF-8 in Ruby will raise an
|
58
|
+
# Encoding::ConverterNotFoundError, which is what we're trying to
|
59
|
+
# replicate for this test case.
|
60
|
+
# The following UTF-7 string decodes to 'Jyväskylä', a city in Finland
|
61
|
+
string = "Jyv+AOQ-skyl+AOQ-".force_encoding("UTF-7")
|
62
|
+
assert string.valid_encoding?
|
63
|
+
result = NewRelic::JSONWrapper.normalize_string(string)
|
64
|
+
assert_not_same(result, string)
|
65
|
+
assert_equal(Encoding.find('ISO-8859-1'), result.encoding)
|
66
|
+
assert_equal('Jyv+AOQ-skyl+AOQ-'.force_encoding('ISO-8859-1'), result)
|
67
|
+
end
|
68
|
+
|
69
|
+
def test_normalizes_string_encodings_if_asked
|
70
|
+
string = (0..255).to_a.pack("C*")
|
71
|
+
encoded = NewRelic::JSONWrapper.dump([string], :normalize => true)
|
72
|
+
decoded = NewRelic::JSONWrapper.load(encoded)
|
73
|
+
expected = [string.dup.force_encoding('ISO-8859-1').encode('UTF-8')]
|
74
|
+
assert_equal(expected, decoded)
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
@@ -4,7 +4,7 @@
|
|
4
4
|
|
5
5
|
require File.expand_path(File.join(File.dirname(__FILE__),'..','test_helper'))
|
6
6
|
|
7
|
-
class NewRelic::LanguageSupportTest <
|
7
|
+
class NewRelic::LanguageSupportTest < MiniTest::Unit::TestCase
|
8
8
|
include ::NewRelic::TestHelpers::RuntimeDetection
|
9
9
|
|
10
10
|
def test_object_space_usable_on_jruby_with_object_space_enabled
|
@@ -6,7 +6,7 @@ require File.expand_path(File.join(File.dirname(__FILE__),'..','test_helper'))
|
|
6
6
|
|
7
7
|
# look through the source code to enforce some simple rules that help us keep
|
8
8
|
# our license data up to date.
|
9
|
-
class LicenseTest <
|
9
|
+
class LicenseTest < MiniTest::Unit::TestCase
|
10
10
|
include NewRelic::TestHelpers::FileSearching
|
11
11
|
|
12
12
|
# A list of regexs that will likely match license info
|
@@ -80,7 +80,7 @@ class LicenseTest < Test::Unit::TestCase
|
|
80
80
|
next if should_skip?(filename)
|
81
81
|
|
82
82
|
first_thousand_bytes = File.read(filename, 1000)
|
83
|
-
|
83
|
+
refute_nil first_thousand_bytes, "#{filename} is shorter than 1000 bytes."
|
84
84
|
|
85
85
|
first_four_lines = first_thousand_bytes.split("\n")[0...4]
|
86
86
|
|
data/test/new_relic/load_test.rb
CHANGED
@@ -2,16 +2,10 @@
|
|
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__),'..','test_helper'))
|
6
|
-
require 'test/unit'
|
7
5
|
require 'resolv'
|
8
|
-
|
9
|
-
require 'mocha/setup'
|
10
|
-
rescue LoadError
|
11
|
-
require 'mocha'
|
12
|
-
end
|
6
|
+
require 'mocha/setup'
|
13
7
|
|
14
|
-
class LoadTest <
|
8
|
+
class LoadTest < MiniTest::Unit::TestCase
|
15
9
|
def test_loading_agent_when_disabled_does_not_resolv_addresses
|
16
10
|
::Resolv.expects(:getaddress).never
|
17
11
|
::IPSocket.expects(:getaddress).never
|
@@ -3,7 +3,7 @@
|
|
3
3
|
# See https://github.com/newrelic/rpm/blob/master/LICENSE for complete details.
|
4
4
|
|
5
5
|
require File.expand_path(File.join(File.dirname(__FILE__),'..', 'test_helper'))
|
6
|
-
class NewRelic::LocalEnvironmentTest <
|
6
|
+
class NewRelic::LocalEnvironmentTest < MiniTest::Unit::TestCase
|
7
7
|
|
8
8
|
def self.teardown
|
9
9
|
# To remove mock server instances from ObjectSpace
|
@@ -4,7 +4,7 @@
|
|
4
4
|
|
5
5
|
require File.expand_path(File.join(File.dirname(__FILE__),'..', 'test_helper'))
|
6
6
|
require 'new_relic/metric_data'
|
7
|
-
class NewRelic::MetricDataTest <
|
7
|
+
class NewRelic::MetricDataTest < MiniTest::Unit::TestCase
|
8
8
|
def test_initialize_basic
|
9
9
|
spec = mock('metric_spec')
|
10
10
|
stats = mock('stats')
|
@@ -3,7 +3,7 @@
|
|
3
3
|
# See https://github.com/newrelic/rpm/blob/master/LICENSE for complete details.
|
4
4
|
|
5
5
|
require File.expand_path(File.join(File.dirname(__FILE__),'..', '..', 'test_helper'))
|
6
|
-
class NewRelic::MetricParser::MetricParserTest <
|
6
|
+
class NewRelic::MetricParser::MetricParserTest < MiniTest::Unit::TestCase
|
7
7
|
class ::AnApplicationClass
|
8
8
|
end
|
9
9
|
|
@@ -3,7 +3,7 @@
|
|
3
3
|
# See https://github.com/newrelic/rpm/blob/master/LICENSE for complete details.
|
4
4
|
|
5
5
|
require File.expand_path(File.join(File.dirname(__FILE__),'..', 'test_helper'))
|
6
|
-
class NewRelic::MetricSpecTest <
|
6
|
+
class NewRelic::MetricSpecTest < MiniTest::Unit::TestCase
|
7
7
|
|
8
8
|
def test_equal
|
9
9
|
spec1 = NewRelic::MetricSpec.new('Controller')
|
@@ -21,15 +21,11 @@ module MultiverseHelpers
|
|
21
21
|
|
22
22
|
def setup_and_teardown_agent(opts = {}, &block)
|
23
23
|
define_method(:setup) do
|
24
|
-
before_setup if respond_to?(:before_setup)
|
25
24
|
setup_agent(opts, &block)
|
26
|
-
after_setup if respond_to?(:after_setup)
|
27
25
|
end
|
28
26
|
|
29
27
|
define_method(:teardown) do
|
30
|
-
before_teardown if respond_to?(:before_teardown)
|
31
28
|
teardown_agent
|
32
|
-
after_teardown if respond_to?(:after_teardown)
|
33
29
|
end
|
34
30
|
end
|
35
31
|
|
@@ -134,29 +130,29 @@ module MultiverseHelpers
|
|
134
130
|
extend self
|
135
131
|
end
|
136
132
|
|
137
|
-
if RUBY_VERSION < "1.8.7"
|
138
|
-
# No instance_exec in 1.8.6... sigh
|
139
|
-
#
|
140
|
-
# Cribbed from https://www.ruby-forum.com/topic/72172#101957, most straight
|
141
|
-
# forward implementation I could find without using ActiveSupport
|
142
|
-
class Object
|
143
|
-
unless defined? instance_exec # 1.9
|
144
|
-
def instance_exec(*arguments, &block)
|
145
|
-
block.bind(self)[*arguments]
|
146
|
-
end
|
147
|
-
end
|
148
|
-
end
|
149
|
-
|
150
|
-
class Proc
|
151
|
-
def bind(object)
|
152
|
-
block, time = self, Time.now
|
153
|
-
(class << object; self end).class_eval do
|
154
|
-
method_name = "__bind_#{time.to_i}_#{time.usec}"
|
155
|
-
define_method(method_name, &block)
|
156
|
-
method = instance_method(method_name)
|
157
|
-
remove_method(method_name)
|
158
|
-
method
|
159
|
-
end.bind(object)
|
160
|
-
end
|
161
|
-
end
|
162
|
-
end
|
133
|
+
#if RUBY_VERSION < "1.8.7"
|
134
|
+
# # No instance_exec in 1.8.6... sigh
|
135
|
+
# #
|
136
|
+
# # Cribbed from https://www.ruby-forum.com/topic/72172#101957, most straight
|
137
|
+
# # forward implementation I could find without using ActiveSupport
|
138
|
+
# class Object
|
139
|
+
# unless defined? instance_exec # 1.9
|
140
|
+
# def instance_exec(*arguments, &block)
|
141
|
+
# block.bind(self)[*arguments]
|
142
|
+
# end
|
143
|
+
# end
|
144
|
+
# end
|
145
|
+
#
|
146
|
+
# class Proc
|
147
|
+
# def bind(object)
|
148
|
+
# block, time = self, Time.now
|
149
|
+
# (class << object; self end).class_eval do
|
150
|
+
# method_name = "__bind_#{time.to_i}_#{time.usec}"
|
151
|
+
# define_method(method_name, &block)
|
152
|
+
# method = instance_method(method_name)
|
153
|
+
# remove_method(method_name)
|
154
|
+
# method
|
155
|
+
# end.bind(object)
|
156
|
+
# end
|
157
|
+
# end
|
158
|
+
#end
|