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.
Files changed (209) hide show
  1. data.tar.gz.sig +3 -2
  2. data/CHANGELOG +1 -1
  3. data/Guardfile +3 -3
  4. data/README.md +1 -1
  5. data/Rakefile +0 -2
  6. data/init.rb +2 -5
  7. data/lib/new_relic/agent.rb +3 -0
  8. data/lib/new_relic/agent/agent.rb +2 -0
  9. data/lib/new_relic/agent/configuration/default_source.rb +32 -14
  10. data/lib/new_relic/agent/configuration/environment_source.rb +1 -0
  11. data/lib/new_relic/agent/cross_app_monitor.rb +2 -2
  12. data/lib/new_relic/agent/cross_app_tracing.rb +2 -2
  13. data/lib/new_relic/agent/error_collector.rb +1 -1
  14. data/lib/new_relic/agent/http_clients/typhoeus_wrappers.rb +4 -1
  15. data/lib/new_relic/agent/instrumentation/action_controller_subscriber.rb +10 -8
  16. data/lib/new_relic/agent/instrumentation/action_view_subscriber.rb +11 -6
  17. data/lib/new_relic/agent/javascript_instrumentor.rb +27 -36
  18. data/lib/new_relic/agent/method_tracer.rb +20 -2
  19. data/lib/new_relic/agent/new_relic_service.rb +35 -27
  20. data/lib/new_relic/agent/request_sampler.rb +20 -13
  21. data/lib/new_relic/agent/sampler_collection.rb +4 -0
  22. data/lib/new_relic/agent/stats_engine/stats_hash.rb +4 -4
  23. data/lib/new_relic/agent/system_info.rb +25 -15
  24. data/lib/new_relic/agent/transaction.rb +23 -4
  25. data/lib/new_relic/agent/transaction_sampler.rb +1 -1
  26. data/lib/new_relic/cli/install.rb +1 -1
  27. data/lib/new_relic/control.rb +1 -0
  28. data/lib/new_relic/helper.rb +1 -29
  29. data/lib/new_relic/json_wrapper.rb +92 -0
  30. data/lib/new_relic/language_support.rb +4 -0
  31. data/lib/new_relic/rack/agent_hooks.rb +4 -0
  32. data/lib/new_relic/rack/browser_monitoring.rb +4 -0
  33. data/lib/new_relic/rack/developer_mode.rb +4 -1
  34. data/lib/new_relic/rack/error_collector.rb +5 -0
  35. data/lib/new_relic/rack/transaction_reset.rb +20 -0
  36. data/lib/new_relic/version.rb +1 -1
  37. data/lib/tasks/install.rake +0 -1
  38. data/newrelic_rpm.gemspec +1 -1
  39. data/test/agent_helper.rb +7 -8
  40. data/test/environments/norails/Gemfile +2 -1
  41. data/test/environments/rails21/Gemfile +2 -2
  42. data/test/environments/rails21/config/environment.rb +1 -3
  43. data/test/environments/rails21/config/environments/development.rb +0 -6
  44. data/test/environments/rails22/Gemfile +2 -2
  45. data/test/environments/rails22/config/environment.rb +0 -2
  46. data/test/environments/rails22/config/environments/development.rb +0 -6
  47. data/test/environments/rails23/Gemfile +2 -3
  48. data/test/environments/rails23/config/environment.rb +0 -9
  49. data/test/environments/rails23/config/environments/development.rb +0 -5
  50. data/test/environments/rails30/Gemfile +2 -2
  51. data/test/environments/rails31/Gemfile +2 -2
  52. data/test/environments/rails32/Gemfile +2 -1
  53. data/test/environments/rails40/Gemfile +2 -1
  54. data/test/intentional_fail.rb +1 -2
  55. data/test/multiverse/lib/multiverse/envfile.rb +1 -5
  56. data/test/multiverse/lib/multiverse/suite.rb +10 -27
  57. data/test/multiverse/suites/active_record/ar_method_aliasing.rb +49 -67
  58. data/test/multiverse/suites/agent_only/encoding_handling_test.rb +128 -0
  59. data/test/multiverse/suites/agent_only/marshaling_test.rb +7 -9
  60. data/test/multiverse/suites/agent_only/script/loading.rb +20 -0
  61. data/test/multiverse/suites/agent_only/start_up_test.rb +7 -0
  62. data/test/multiverse/suites/bare/Envfile +3 -0
  63. data/test/multiverse/suites/bare/standalone_instrumentation_test.rb +43 -0
  64. data/test/multiverse/suites/rails/Envfile +0 -2
  65. data/test/multiverse/suites/rails/app/views/views/_a_partial.html.erb +1 -0
  66. data/test/multiverse/suites/rails/app/views/views/index.html.erb +1 -1
  67. data/test/multiverse/suites/rails/error_tracing_test.rb +1 -1
  68. data/test/multiverse/suites/rails/request_statistics_test.rb +9 -4
  69. data/test/multiverse/suites/rails/view_instrumentation_test.rb +111 -106
  70. data/test/multiverse/suites/typhoeus/Envfile +1 -1
  71. data/test/multiverse/suites/typhoeus/typhoeus_test.rb +16 -2
  72. data/test/multiverse/test/multiverse_test.rb +2 -2
  73. data/test/new_relic/agent/agent/connect_test.rb +1 -1
  74. data/test/new_relic/agent/agent/start_test.rb +1 -1
  75. data/test/new_relic/agent/agent/start_worker_thread_test.rb +1 -1
  76. data/test/new_relic/agent/agent_logger_test.rb +3 -7
  77. data/test/new_relic/agent/agent_test.rb +33 -57
  78. data/test/new_relic/agent/apdex_from_server_test.rb +1 -1
  79. data/test/new_relic/agent/audit_logger_test.rb +5 -8
  80. data/test/new_relic/agent/autostart_test.rb +1 -1
  81. data/test/new_relic/agent/browser_token_test.rb +1 -1
  82. data/test/new_relic/agent/busy_calculator_test.rb +2 -4
  83. data/test/new_relic/agent/commands/agent_command_router_test.rb +5 -5
  84. data/test/new_relic/agent/commands/agent_command_test.rb +1 -1
  85. data/test/new_relic/agent/commands/thread_profiler_session_test.rb +6 -6
  86. data/test/new_relic/agent/commands/xray_session_collection_test.rb +10 -10
  87. data/test/new_relic/agent/commands/xray_session_test.rb +1 -1
  88. data/test/new_relic/agent/configuration/default_source_test.rb +4 -4
  89. data/test/new_relic/agent/configuration/environment_source_test.rb +14 -2
  90. data/test/new_relic/agent/configuration/manager_test.rb +3 -3
  91. data/test/new_relic/agent/configuration/orphan_configuration_test.rb +1 -1
  92. data/test/new_relic/agent/configuration/server_source_test.rb +1 -1
  93. data/test/new_relic/agent/configuration/yaml_source_test.rb +2 -2
  94. data/test/new_relic/agent/cpu_sampler_test.rb +1 -1
  95. data/test/new_relic/agent/cross_app_monitor_test.rb +3 -3
  96. data/test/new_relic/agent/cross_app_tracing_test.rb +5 -4
  97. data/test/new_relic/agent/database_test.rb +1 -1
  98. data/test/new_relic/agent/datastores/mongo/metric_generator_test.rb +1 -1
  99. data/test/new_relic/agent/datastores/mongo/metric_translator_test.rb +1 -1
  100. data/test/new_relic/agent/datastores/mongo/obfuscator_test.rb +1 -1
  101. data/test/new_relic/agent/datastores/mongo/statement_formatter_test.rb +2 -2
  102. data/test/new_relic/agent/error_collector/notice_error_test.rb +1 -1
  103. data/test/new_relic/agent/error_collector_test.rb +5 -3
  104. data/test/new_relic/agent/event_listener_test.rb +1 -1
  105. data/test/new_relic/agent/harvester_test.rb +1 -1
  106. data/test/new_relic/agent/http_clients/uri_util_test.rb +1 -1
  107. data/test/new_relic/agent/instrumentation/action_controller_subscriber_test.rb +1 -1
  108. data/test/new_relic/agent/instrumentation/action_view_subscriber_test.rb +1 -1
  109. data/test/new_relic/agent/instrumentation/active_record_helper_test.rb +1 -1
  110. data/test/new_relic/agent/instrumentation/active_record_instrumentation_test.rb +495 -495
  111. data/test/new_relic/agent/instrumentation/active_record_subscriber_test.rb +2 -2
  112. data/test/new_relic/agent/instrumentation/controller_instrumentation_test.rb +1 -1
  113. data/test/new_relic/agent/instrumentation/instrumentation_test.rb +1 -1
  114. data/test/new_relic/agent/instrumentation/metric_frame_test.rb +1 -1
  115. data/test/new_relic/agent/instrumentation/net_instrumentation_test.rb +4 -6
  116. data/test/new_relic/agent/instrumentation/queue_time_test.rb +1 -1
  117. data/test/new_relic/agent/instrumentation/rack_test.rb +1 -1
  118. data/test/new_relic/agent/instrumentation/sinatra/transaction_namer_test.rb +1 -1
  119. data/test/new_relic/agent/instrumentation/sinatra_test.rb +1 -1
  120. data/test/new_relic/agent/instrumentation/task_instrumentation_test.rb +7 -7
  121. data/test/new_relic/agent/javascript_instrumentor_test.rb +47 -55
  122. data/test/new_relic/agent/memcache_instrumentation_test.rb +1 -1
  123. data/test/new_relic/agent/memory_logger_test.rb +1 -1
  124. data/test/new_relic/agent/method_interrobang_test.rb +2 -3
  125. data/test/new_relic/agent/method_tracer/class_methods/add_method_tracer_test.rb +4 -4
  126. data/test/new_relic/agent/method_tracer/instance_methods/trace_execution_scoped_test.rb +1 -1
  127. data/test/new_relic/agent/method_tracer_test.rb +6 -7
  128. data/test/new_relic/agent/method_visibility_test.rb +1 -1
  129. data/test/new_relic/agent/new_relic_service_test.rb +129 -19
  130. data/test/new_relic/agent/obfuscator_test.rb +1 -1
  131. data/test/new_relic/agent/pipe_channel_manager_test.rb +143 -145
  132. data/test/new_relic/agent/pipe_service_test.rb +2 -4
  133. data/test/new_relic/agent/request_sampler_test.rb +23 -19
  134. data/test/new_relic/agent/rpm_agent_test.rb +3 -3
  135. data/test/new_relic/agent/rules_engine_test.rb +1 -1
  136. data/test/new_relic/agent/sampled_buffer_test.rb +1 -1
  137. data/test/new_relic/agent/sampler_collection_test.rb +3 -3
  138. data/test/new_relic/agent/sampler_test.rb +1 -1
  139. data/test/new_relic/agent/shim_agent_test.rb +1 -1
  140. data/test/new_relic/agent/sql_sampler_test.rb +4 -6
  141. data/test/new_relic/agent/stats_engine/gc_profiler_test.rb +1 -1
  142. data/test/new_relic/agent/stats_engine/metric_stats_test.rb +5 -5
  143. data/test/new_relic/agent/stats_engine/samplers_test.rb +2 -2
  144. data/test/new_relic/agent/stats_engine_test.rb +3 -3
  145. data/test/new_relic/agent/stats_hash_test.rb +2 -2
  146. data/test/new_relic/agent/stats_test.rb +1 -1
  147. data/test/new_relic/agent/threading/agent_thread_test.rb +2 -4
  148. data/test/new_relic/agent/threading/backtrace_node_test.rb +1 -1
  149. data/test/new_relic/agent/threading/backtrace_service_test.rb +5 -5
  150. data/test/new_relic/agent/threading/thread_profile_test.rb +1 -1
  151. data/test/new_relic/agent/transaction/developer_mode_sample_buffer_test.rb +1 -1
  152. data/test/new_relic/agent/transaction/force_persist_sample_buffer_test.rb +1 -1
  153. data/test/new_relic/agent/transaction/pop_test.rb +1 -1
  154. data/test/new_relic/agent/transaction/slowest_sample_buffer_test.rb +1 -1
  155. data/test/new_relic/agent/transaction/xray_sample_buffer_test.rb +1 -1
  156. data/test/new_relic/agent/transaction_interrobang_test.rb +2 -3
  157. data/test/new_relic/agent/transaction_sample_builder_test.rb +16 -14
  158. data/test/new_relic/agent/transaction_sampler_test.rb +16 -21
  159. data/test/new_relic/agent/transaction_state_test.rb +1 -1
  160. data/test/new_relic/agent/transaction_test.rb +61 -1
  161. data/test/new_relic/agent/transaction_timings_test.rb +1 -1
  162. data/test/new_relic/agent/worker_loop_test.rb +1 -1
  163. data/test/new_relic/agent_test.rb +2 -3
  164. data/test/new_relic/cli/deployments_test.rb +3 -3
  165. data/test/new_relic/coerce_test.rb +1 -1
  166. data/test/new_relic/collection_helper_test.rb +1 -1
  167. data/test/new_relic/control/class_methods_test.rb +2 -2
  168. data/test/new_relic/control/frameworks/rails_test.rb +1 -1
  169. data/test/new_relic/control_test.rb +9 -4
  170. data/test/new_relic/dependency_detection_test.rb +1 -1
  171. data/test/new_relic/dispatcher_test.rb +1 -1
  172. data/test/new_relic/environment_report_test.rb +4 -6
  173. data/test/new_relic/fake_collector.rb +1 -158
  174. data/test/new_relic/framework_test.rb +2 -1
  175. data/test/new_relic/http_client_test_cases.rb +2 -3
  176. data/test/new_relic/json_wrapper_test.rb +77 -0
  177. data/test/new_relic/language_support_test.rb +1 -1
  178. data/test/new_relic/license_test.rb +2 -2
  179. data/test/new_relic/load_test.rb +2 -8
  180. data/test/new_relic/local_environment_test.rb +1 -1
  181. data/test/new_relic/metric_data_test.rb +1 -1
  182. data/test/new_relic/metric_parser/metric_parser_test.rb +1 -1
  183. data/test/new_relic/metric_spec_test.rb +1 -1
  184. data/test/new_relic/multiverse_helpers.rb +26 -30
  185. data/test/new_relic/noticed_error_test.rb +1 -1
  186. data/test/new_relic/rack/agent_hooks_test.rb +1 -1
  187. data/test/new_relic/rack/all_test.rb +1 -1
  188. data/test/new_relic/rack/browser_monitoring_test.rb +4 -2
  189. data/test/new_relic/rack/deferred_instrumentation_test.rb +3 -5
  190. data/test/new_relic/rack/developer_mode_helper_test.rb +1 -1
  191. data/test/new_relic/rack/developer_mode_test.rb +1 -1
  192. data/test/new_relic/rack/error_collector_test.rb +8 -8
  193. data/test/new_relic/rack/transaction_reset_test.rb +35 -0
  194. data/test/new_relic/transaction_analysis/segment_summary_test.rb +2 -2
  195. data/test/new_relic/transaction_analysis_test.rb +1 -1
  196. data/test/new_relic/transaction_sample/composite_segment_test.rb +1 -1
  197. data/test/new_relic/transaction_sample/fake_segment_test.rb +2 -4
  198. data/test/new_relic/transaction_sample/segment_test.rb +3 -7
  199. data/test/new_relic/transaction_sample/summary_segment_test.rb +1 -1
  200. data/test/new_relic/transaction_sample_subtest_test.rb +1 -1
  201. data/test/new_relic/transaction_sample_test.rb +4 -6
  202. data/test/new_relic/version_number_test.rb +1 -1
  203. data/test/performance/lib/performance/instrumentation/gc_stats.rb +1 -1
  204. data/test/performance/lib/performance/json_reporter.rb +1 -1
  205. data/test/performance/suites/marshalling.rb +76 -0
  206. data/test/test_helper.rb +6 -39
  207. metadata +19 -12
  208. metadata.gz.sig +0 -0
  209. data/test/new_relic/helper_test.rb +0 -32
@@ -4,7 +4,7 @@
4
4
 
5
5
  require File.expand_path(File.join(File.dirname(__FILE__),'..','test_helper'))
6
6
 
7
- class NewRelic::Agent::NoticedErrorTest < Test::Unit::TestCase
7
+ class NewRelic::Agent::NoticedErrorTest < MiniTest::Unit::TestCase
8
8
  include NewRelic::TestHelpers::Exceptions
9
9
 
10
10
  def setup
@@ -5,7 +5,7 @@
5
5
  require File.expand_path(File.join(File.dirname(__FILE__),'..','..','test_helper'))
6
6
  require 'new_relic/rack/agent_hooks'
7
7
 
8
- class AgentHooksTest < Test::Unit::TestCase
8
+ class AgentHooksTest < MiniTest::Unit::TestCase
9
9
 
10
10
  def setup
11
11
  @app = stub_everything
@@ -5,7 +5,7 @@
5
5
  require File.expand_path(File.join(File.dirname(__FILE__),'..','..','test_helper'))
6
6
  require 'new_relic/rack/browser_monitoring'
7
7
  require 'new_relic/rack/developer_mode'
8
- class NewRelic::Rack::AllTest < Test::Unit::TestCase
8
+ class NewRelic::Rack::AllTest < MiniTest::Unit::TestCase
9
9
  # just here to load the files above
10
10
 
11
11
  def test_truth
@@ -10,7 +10,7 @@ require 'new_relic/rack/browser_monitoring'
10
10
 
11
11
  ENV['RACK_ENV'] = 'test'
12
12
 
13
- class BrowserMonitoringTest < Test::Unit::TestCase
13
+ class BrowserMonitoringTest < MiniTest::Unit::TestCase
14
14
  include Rack::Test::Methods
15
15
 
16
16
  class TestApp
@@ -75,7 +75,9 @@ EOL
75
75
  end
76
76
 
77
77
  def test_make_sure_header_is_set
78
- assert NewRelic::Agent.browser_timing_header.size > 0
78
+ in_transaction do
79
+ assert NewRelic::Agent.browser_timing_header.size > 0
80
+ end
79
81
  end
80
82
 
81
83
  def test_should_only_instrument_successfull_html_requests
@@ -4,7 +4,7 @@
4
4
 
5
5
  require File.expand_path(File.join(File.dirname(__FILE__),'..','..','test_helper'))
6
6
 
7
- class NewRelic::Rack::DeferredInstrumentationTest < Test::Unit::TestCase
7
+ class NewRelic::Rack::DeferredInstrumentationTest < MiniTest::Unit::TestCase
8
8
  class TestApp
9
9
  def call(env)
10
10
  [200, {}, ["whatever"]]
@@ -19,7 +19,7 @@ class NewRelic::Rack::DeferredInstrumentationTest < Test::Unit::TestCase
19
19
  # On Ruby 1.8.7, this will cause the file to be evaluated multiple times.
20
20
  path1 = "new_relic/agent/instrumentation/rack"
21
21
  path2 = File.expand_path(File.join(File.dirname(__FILE__), '..', '..', '..', 'lib', 'new_relic', 'agent', 'instrumentation', 'rack'))
22
- assert_not_equal(path2, path1)
22
+ refute_equal(path2, path1)
23
23
 
24
24
  require path1
25
25
  require path2
@@ -28,8 +28,6 @@ class NewRelic::Rack::DeferredInstrumentationTest < Test::Unit::TestCase
28
28
  run(::NewRelic::Rack::DeferredInstrumentationTest::TestApp.new)
29
29
  end
30
30
 
31
- assert_nothing_raised do
32
- builder.to_app
33
- end
31
+ builder.to_app
34
32
  end
35
33
  end
@@ -8,7 +8,7 @@ require File.expand_path(File.join(File.dirname(__FILE__),'..','..','..','ui',
8
8
  'helpers','developer_mode_helper.rb'))
9
9
 
10
10
  ENV['RACK_ENV'] = 'test'
11
- class DeveloperModeTest < Test::Unit::TestCase
11
+ class DeveloperModeTest < MiniTest::Unit::TestCase
12
12
  include NewRelic::DeveloperModeHelper
13
13
 
14
14
 
@@ -11,7 +11,7 @@ require 'new_relic/rack/developer_mode'
11
11
 
12
12
  ENV['RACK_ENV'] = 'test'
13
13
 
14
- class DeveloperModeTest < Test::Unit::TestCase
14
+ class DeveloperModeTest < MiniTest::Unit::TestCase
15
15
  include Rack::Test::Methods
16
16
  include TransactionSampleTestHelper
17
17
 
@@ -8,7 +8,7 @@ require 'rack/test'
8
8
  require 'new_relic/rack/error_collector'
9
9
 
10
10
  module NewRelic::Rack
11
- class ErrorCollectorTest < Test::Unit::TestCase
11
+ class ErrorCollectorTest < MiniTest::Unit::TestCase
12
12
  include Rack::Test::Methods
13
13
 
14
14
  class TestApp
@@ -41,7 +41,7 @@ module NewRelic::Rack
41
41
  end
42
42
 
43
43
  def test_notice_and_reraise_errors
44
- assert_raise RuntimeError do
44
+ assert_raises RuntimeError do
45
45
  get '/'
46
46
  end
47
47
 
@@ -53,7 +53,7 @@ module NewRelic::Rack
53
53
  !error.kind_of?(RuntimeError)
54
54
  end
55
55
 
56
- assert_raise RuntimeError do
56
+ assert_raises RuntimeError do
57
57
  get '/'
58
58
  end
59
59
 
@@ -63,7 +63,7 @@ module NewRelic::Rack
63
63
 
64
64
  if defined?(::Rails)
65
65
  def test_ignore_errors_from_ignored_actions
66
- assert_raise RuntimeError do
66
+ assert_raises RuntimeError do
67
67
  get '/ignored'
68
68
  end
69
69
 
@@ -84,7 +84,7 @@ module NewRelic::Rack
84
84
  Rack::Request.stubs(:new).returns(bad_request)
85
85
  end
86
86
 
87
- assert_raise RuntimeError do
87
+ assert_raises RuntimeError do
88
88
  get '/'
89
89
  end
90
90
 
@@ -100,7 +100,7 @@ module NewRelic::Rack
100
100
  if defined?(ActionDispatch::Request)
101
101
  ActionDispatch::Request.stubs(:new).raises('bad news')
102
102
 
103
- assert_raise RuntimeError do
103
+ assert_raises RuntimeError do
104
104
  get '/foo/bar?q=12'
105
105
  end
106
106
 
@@ -110,7 +110,7 @@ module NewRelic::Rack
110
110
  end
111
111
 
112
112
  def test_captures_parameters_with_rails
113
- assert_raise RuntimeError do
113
+ assert_raises RuntimeError do
114
114
  get '/?foo=bar&baz=qux'
115
115
  end
116
116
 
@@ -121,7 +121,7 @@ module NewRelic::Rack
121
121
 
122
122
  def test_captures_parameters_without_rails
123
123
  undefine_constant(:'ActionDispatch::Request') do
124
- assert_raise RuntimeError do
124
+ assert_raises RuntimeError do
125
125
  get '/?foo=bar&baz=qux'
126
126
  end
127
127
  end
@@ -0,0 +1,35 @@
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 'new_relic/rack/transaction_reset'
7
+ require 'new_relic/agent/transaction_state'
8
+
9
+ module NewRelic
10
+ module Rack
11
+ class TransactionResetTest < MiniTest::Unit::TestCase
12
+ class ExampleMiddleware
13
+ include TransactionReset
14
+ end
15
+
16
+ attr_reader :middleware, :env
17
+
18
+ def setup
19
+ @middleware = ExampleMiddleware.new
20
+ @env = {}
21
+ end
22
+
23
+ def test_resets
24
+ NewRelic::Agent::TransactionState.expects(:reset).once
25
+ middleware.ensure_transaction_reset(env)
26
+ end
27
+
28
+ def test_resets_only_once
29
+ NewRelic::Agent::TransactionState.expects(:reset).once
30
+ middleware.ensure_transaction_reset(env)
31
+ middleware.ensure_transaction_reset(env)
32
+ end
33
+ end
34
+ end
35
+ end
@@ -4,7 +4,7 @@
4
4
 
5
5
  require File.expand_path(File.join(File.dirname(__FILE__),'..', '..','test_helper'))
6
6
  require 'new_relic/transaction_analysis/segment_summary'
7
- class NewRelic::TransactionAnalysis::SegmentSummaryTest < Test::Unit::TestCase
7
+ class NewRelic::TransactionAnalysis::SegmentSummaryTest < MiniTest::Unit::TestCase
8
8
 
9
9
  def setup
10
10
  @sample = mock('sample')
@@ -28,7 +28,7 @@ class NewRelic::TransactionAnalysis::SegmentSummaryTest < Test::Unit::TestCase
28
28
  def test_insert_error
29
29
  segment = mock('segment')
30
30
  segment.expects(:metric_name).returns('Controller/bar').twice
31
- assert_raise(ArgumentError) do
31
+ assert_raises(ArgumentError) do
32
32
  @ss << segment
33
33
  end
34
34
  end
@@ -4,7 +4,7 @@
4
4
 
5
5
  require File.expand_path(File.join(File.dirname(__FILE__),'..', 'test_helper'))
6
6
  require 'new_relic/transaction_analysis'
7
- class NewRelic::TransactionAnalysisTest < Test::Unit::TestCase
7
+ class NewRelic::TransactionAnalysisTest < MiniTest::Unit::TestCase
8
8
  include NewRelic::TransactionAnalysis
9
9
 
10
10
  # these are mostly stub tests just making sure that the API doesn't
@@ -4,7 +4,7 @@
4
4
 
5
5
  require File.expand_path(File.join(File.dirname(__FILE__), '..', '..', 'test_helper'))
6
6
  require 'new_relic/transaction_sample/composite_segment'
7
- class NewRelic::TransactionSample::CompositeSegmentTest < Test::Unit::TestCase
7
+ class NewRelic::TransactionSample::CompositeSegmentTest < MiniTest::Unit::TestCase
8
8
  def test_composite_segment_creation
9
9
  fake_segment = mock_segment
10
10
  NewRelic::TransactionSample::CompositeSegment.new([fake_segment])
@@ -4,11 +4,9 @@
4
4
 
5
5
  require File.expand_path(File.join(File.dirname(__FILE__), '..', '..', 'test_helper'))
6
6
  require 'new_relic/transaction_sample/fake_segment'
7
- class NewRelic::TransactionSample::FakeSegmentTest < Test::Unit::TestCase
7
+ class NewRelic::TransactionSample::FakeSegmentTest < MiniTest::Unit::TestCase
8
8
  def test_fake_segment_creation
9
- assert_nothing_raised do
10
- NewRelic::TransactionSample::FakeSegment.new(0.1, 'Custom/test/metric', nil)
11
- end
9
+ NewRelic::TransactionSample::FakeSegment.new(0.1, 'Custom/test/metric', nil)
12
10
  end
13
11
 
14
12
  def test_parent_segment
@@ -4,7 +4,7 @@
4
4
 
5
5
  require File.expand_path(File.join(File.dirname(__FILE__), '..', '..', 'test_helper'))
6
6
  require 'new_relic/transaction_sample/segment'
7
- class NewRelic::TransactionSample::SegmentTest < Test::Unit::TestCase
7
+ class NewRelic::TransactionSample::SegmentTest < MiniTest::Unit::TestCase
8
8
  def test_segment_creation
9
9
  # basic smoke test
10
10
  s = NewRelic::TransactionSample::Segment.new(Time.now, 'Custom/test/metric', nil)
@@ -321,18 +321,14 @@ class NewRelic::TransactionSample::SegmentTest < Test::Unit::TestCase
321
321
  s.params = {:sql => statement}
322
322
  connection = mock('connection')
323
323
  NewRelic::Agent::Database.expects(:get_connection).with(config).raises(RuntimeError.new("whee"))
324
- assert_nothing_raised do
325
- s.explain_sql
326
- end
324
+ s.explain_sql
327
325
  end
328
326
 
329
327
  def test_explain_sql_can_handle_missing_config
330
328
  # If TT segment came over from Resque child, might not be a Statement
331
329
  s = NewRelic::TransactionSample::Segment.new(Time.now, 'Custom/test/metric', nil)
332
330
  s.params = { :sql => "SELECT * FROM galaxy" }
333
- assert_nothing_raised do
334
- s.explain_sql
335
- end
331
+ s.explain_sql
336
332
  end
337
333
 
338
334
  def test_explain_sql_can_use_already_existing_plan
@@ -4,7 +4,7 @@
4
4
 
5
5
  require File.expand_path(File.join(File.dirname(__FILE__), '..', '..', 'test_helper'))
6
6
  require 'new_relic/transaction_sample/summary_segment'
7
- class NewRelic::TransactionSample::SummarySegmentTest < Test::Unit::TestCase
7
+ class NewRelic::TransactionSample::SummarySegmentTest < MiniTest::Unit::TestCase
8
8
  def test_summary_segment_creation
9
9
  fake_segment = mock_segment
10
10
  NewRelic::TransactionSample::SummarySegment.new(fake_segment)
@@ -2,7 +2,7 @@
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
- class NewRelic::TransactionSample::SubTest < Test::Unit::TestCase
5
+ class NewRelic::TransactionSample::SubTest < MiniTest::Unit::TestCase
6
6
  def setup
7
7
  @t = NewRelic::TransactionSample.new
8
8
 
@@ -4,7 +4,7 @@
4
4
 
5
5
  require File.expand_path('../../test_helper.rb', __FILE__)
6
6
 
7
- class NewRelic::TransactionSampleTest < Test::Unit::TestCase
7
+ class NewRelic::TransactionSampleTest < MiniTest::Unit::TestCase
8
8
  include TransactionSampleTestHelper
9
9
  ::SQL_STATEMENT = "SELECT * from sandwiches WHERE meat='bacon'"
10
10
  ::OBFUSCATED_SQL_STATEMENT = "SELECT * from sandwiches WHERE meat=?"
@@ -30,7 +30,7 @@ class NewRelic::TransactionSampleTest < Test::Unit::TestCase
30
30
  end
31
31
 
32
32
  def test_be_recorded
33
- assert_not_nil @t
33
+ refute_nil @t
34
34
  end
35
35
 
36
36
  def test_prepare_to_send_strips_sql_if_record_sql_is_off_or_none_or_false
@@ -104,9 +104,7 @@ class NewRelic::TransactionSampleTest < Test::Unit::TestCase
104
104
 
105
105
  @connection_stub.expects(:execute).raises
106
106
  with_config(config) do
107
- assert_nothing_raised do
108
- @t.prepare_to_send!
109
- end
107
+ @t.prepare_to_send!
110
108
  end
111
109
  end
112
110
 
@@ -162,7 +160,7 @@ class NewRelic::TransactionSampleTest < Test::Unit::TestCase
162
160
  def test_to_s_with_bad_object
163
161
  @t.prepare_to_send!
164
162
  @t.params[:fake] = Hat.new
165
- assert_raise(RuntimeError) do
163
+ assert_raises(RuntimeError) do
166
164
  @t.to_s
167
165
  end
168
166
  end
@@ -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::VersionNumberTest < Test::Unit::TestCase
6
+ class NewRelic::VersionNumberTest < MiniTest::Unit::TestCase
7
7
 
8
8
  def test_comparison__first
9
9
  versions = %w[1.0.0 0.1.0 0.0.1 10.0.1 1.10.0].map {|s| NewRelic::VersionNumber.new s }
@@ -50,4 +50,4 @@ module Performance
50
50
  end
51
51
  end
52
52
  end
53
- end
53
+ end
@@ -12,4 +12,4 @@ module Performance
12
12
  puts JSON.dump(@results.map { |result| result.to_h })
13
13
  end
14
14
  end
15
- end
15
+ end
@@ -20,6 +20,42 @@ class Marshalling < Performance::TestCase
20
20
  end
21
21
  end
22
22
 
23
+ def test_json_marshalling_binary_strings(timer)
24
+ marshaller = NewRelic::Agent::NewRelicService::JsonMarshaller.new
25
+ convert_strings_to_binary(@payload)
26
+ convert_strings_to_binary(@tt_payload)
27
+ timer.measure do
28
+ (iterations / 100).times do
29
+ marshaller.dump(@payload)
30
+ marshaller.dump(@tt_payload)
31
+ end
32
+ end
33
+ end
34
+
35
+ def test_json_marshalling_utf16_strings(timer)
36
+ marshaller = NewRelic::Agent::NewRelicService::JsonMarshaller.new
37
+ convert_strings_to_utf16(@payload)
38
+ convert_strings_to_utf16(@tt_payload)
39
+ timer.measure do
40
+ (iterations / 100).times do
41
+ marshaller.dump(@payload)
42
+ marshaller.dump(@tt_payload)
43
+ end
44
+ end
45
+ end
46
+
47
+ def test_json_marshalling_latin1_strings(timer)
48
+ marshaller = NewRelic::Agent::NewRelicService::JsonMarshaller.new
49
+ convert_strings_to_latin1(@payload)
50
+ convert_strings_to_latin1(@tt_payload)
51
+ timer.measure do
52
+ (iterations / 100).times do
53
+ marshaller.dump(@payload)
54
+ marshaller.dump(@tt_payload)
55
+ end
56
+ end
57
+ end
58
+
23
59
  def test_basic_marshalling_pruby(timer)
24
60
  marshaller = NewRelic::Agent::NewRelicService::PrubyMarshaller.new
25
61
  timer.measure do
@@ -30,6 +66,46 @@ class Marshalling < Performance::TestCase
30
66
  end
31
67
  end
32
68
 
69
+ # Skips Strings used as Hash keys, since they are frozen
70
+ def each_string(object, &blk)
71
+ case object
72
+ when String
73
+ blk.call(object)
74
+ when Array
75
+ object.map! { |x| each_string(x, &blk) }
76
+ when Hash
77
+ object.values.each do |v|
78
+ each_string(v, &blk)
79
+ end
80
+ end
81
+ end
82
+
83
+ BYTE_ALPHABET = (0..255).to_a.freeze
84
+
85
+ def generate_random_string(length)
86
+ bytes = []
87
+ length.times { bytes << BYTE_ALPHABET.sample }
88
+ bytes.pack("C*")
89
+ end
90
+
91
+ def convert_strings_to_binary(object)
92
+ each_string(object) do |s|
93
+ s.replace(generate_random_string(s.bytesize))
94
+ end
95
+ end
96
+
97
+ def convert_strings_to_utf16(object)
98
+ each_string(object) do |s|
99
+ s.encode!('UTF-16')
100
+ end
101
+ end
102
+
103
+ def convert_strings_to_latin1(object)
104
+ each_string(object) do |s|
105
+ s.replace(generate_random_string(s.bytesize)).force_encoding('ISO-8859-1')
106
+ end
107
+ end
108
+
33
109
  # Build an object graph that approximates a transaction trace in structure
34
110
  def build_transaction_trace_payload(depth=6)
35
111
  root = []