wd_newrelic_rpm 3.3.4.1 → 3.5.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (290) hide show
  1. data/.gitignore +20 -0
  2. data/.project +23 -0
  3. data/.travis.yml +9 -0
  4. data/CHANGELOG +317 -39
  5. data/GUIDELINES_FOR_CONTRIBUTING.md +76 -0
  6. data/Gemfile +16 -0
  7. data/LICENSE +1 -1
  8. data/{README.rdoc → README.md} +71 -55
  9. data/Rakefile +62 -0
  10. data/bin/mongrel_rpm +1 -1
  11. data/config.dot +290 -0
  12. data/config/database.yml +5 -0
  13. data/init.rb +31 -0
  14. data/lib/new_relic/agent.rb +31 -60
  15. data/lib/new_relic/agent/agent.rb +277 -502
  16. data/lib/new_relic/agent/agent_logger.rb +165 -0
  17. data/lib/new_relic/agent/audit_logger.rb +72 -0
  18. data/lib/new_relic/agent/beacon_configuration.rb +36 -50
  19. data/lib/new_relic/agent/browser_monitoring.rb +114 -61
  20. data/lib/new_relic/agent/busy_calculator.rb +14 -6
  21. data/lib/new_relic/agent/configuration.rb +74 -0
  22. data/lib/new_relic/agent/configuration/defaults.rb +126 -0
  23. data/lib/new_relic/agent/configuration/environment_source.rb +49 -0
  24. data/lib/new_relic/agent/configuration/manager.rb +136 -0
  25. data/lib/new_relic/agent/configuration/mask_defaults.rb +10 -0
  26. data/lib/new_relic/agent/configuration/server_source.rb +27 -0
  27. data/lib/new_relic/agent/configuration/yaml_source.rb +63 -0
  28. data/lib/new_relic/agent/cross_process_monitoring.rb +43 -0
  29. data/lib/new_relic/agent/database.rb +39 -26
  30. data/lib/new_relic/agent/error_collector.rb +48 -49
  31. data/lib/new_relic/agent/instrumentation/active_merchant.rb +1 -1
  32. data/lib/new_relic/agent/instrumentation/active_record.rb +4 -7
  33. data/lib/new_relic/agent/instrumentation/acts_as_solr.rb +1 -1
  34. data/lib/new_relic/agent/instrumentation/authlogic.rb +1 -1
  35. data/lib/new_relic/agent/instrumentation/browser_monitoring_timings.rb +41 -0
  36. data/lib/new_relic/agent/instrumentation/controller_instrumentation.rb +35 -12
  37. data/lib/new_relic/agent/instrumentation/data_mapper.rb +4 -12
  38. data/lib/new_relic/agent/instrumentation/delayed_job_instrumentation.rb +2 -2
  39. data/lib/new_relic/agent/instrumentation/memcache.rb +6 -6
  40. data/lib/new_relic/agent/instrumentation/merb/controller.rb +1 -1
  41. data/lib/new_relic/agent/instrumentation/merb/errors.rb +1 -1
  42. data/lib/new_relic/agent/instrumentation/metric_frame.rb +4 -14
  43. data/lib/new_relic/agent/instrumentation/metric_frame/pop.rb +1 -1
  44. data/lib/new_relic/agent/instrumentation/net.rb +1 -1
  45. data/lib/new_relic/agent/instrumentation/passenger_instrumentation.rb +6 -20
  46. data/lib/new_relic/agent/instrumentation/queue_time.rb +2 -2
  47. data/lib/new_relic/agent/instrumentation/rack.rb +1 -1
  48. data/lib/new_relic/agent/instrumentation/rails/action_controller.rb +7 -7
  49. data/lib/new_relic/agent/instrumentation/rails/action_web_service.rb +1 -1
  50. data/lib/new_relic/agent/instrumentation/rails/errors.rb +1 -1
  51. data/lib/new_relic/agent/instrumentation/rails3/action_controller.rb +5 -5
  52. data/lib/new_relic/agent/instrumentation/rails3/errors.rb +6 -2
  53. data/lib/new_relic/agent/instrumentation/resque.rb +81 -0
  54. data/lib/new_relic/agent/instrumentation/sinatra.rb +21 -10
  55. data/lib/new_relic/agent/instrumentation/sunspot.rb +1 -1
  56. data/lib/new_relic/agent/instrumentation/unicorn_instrumentation.rb +5 -4
  57. data/lib/new_relic/agent/method_tracer.rb +11 -9
  58. data/lib/new_relic/agent/new_relic_service.rb +379 -0
  59. data/lib/new_relic/agent/pipe_channel_manager.rb +175 -0
  60. data/lib/new_relic/agent/pipe_service.rb +58 -0
  61. data/lib/new_relic/agent/samplers/delayed_job_sampler.rb +86 -0
  62. data/lib/new_relic/agent/samplers/memory_sampler.rb +6 -8
  63. data/lib/new_relic/agent/sql_sampler.rb +31 -74
  64. data/lib/new_relic/agent/stats_engine.rb +0 -5
  65. data/lib/new_relic/agent/stats_engine/gc_profiler.rb +40 -24
  66. data/lib/new_relic/agent/stats_engine/metric_stats.rb +89 -14
  67. data/lib/new_relic/agent/stats_engine/samplers.rb +9 -7
  68. data/lib/new_relic/agent/stats_engine/transactions.rb +20 -12
  69. data/lib/new_relic/agent/thread.rb +32 -0
  70. data/lib/new_relic/agent/thread_profiler.rb +306 -0
  71. data/lib/new_relic/agent/transaction_info.rb +24 -4
  72. data/lib/new_relic/agent/transaction_sample_builder.rb +12 -13
  73. data/lib/new_relic/agent/transaction_sampler.rb +49 -65
  74. data/lib/new_relic/agent/worker_loop.rb +31 -25
  75. data/lib/new_relic/collection_helper.rb +1 -1
  76. data/lib/new_relic/commands/deployments.rb +19 -10
  77. data/lib/new_relic/control.rb +1 -3
  78. data/lib/new_relic/control/class_methods.rb +10 -5
  79. data/lib/new_relic/control/frameworks/merb.rb +0 -6
  80. data/lib/new_relic/control/frameworks/rails.rb +30 -45
  81. data/lib/new_relic/control/frameworks/rails3.rb +23 -18
  82. data/lib/new_relic/control/frameworks/rails4.rb +23 -0
  83. data/lib/new_relic/control/frameworks/ruby.rb +2 -23
  84. data/lib/new_relic/control/instance_methods.rb +35 -73
  85. data/lib/new_relic/control/instrumentation.rb +7 -12
  86. data/lib/new_relic/control/server_methods.rb +17 -19
  87. data/lib/new_relic/delayed_job_injection.rb +2 -2
  88. data/lib/new_relic/helper.rb +34 -0
  89. data/lib/new_relic/language_support.rb +56 -37
  90. data/lib/new_relic/local_environment.rb +32 -67
  91. data/lib/new_relic/metric_data.rb +10 -2
  92. data/lib/new_relic/metric_spec.rb +7 -3
  93. data/lib/new_relic/noticed_error.rb +32 -9
  94. data/lib/new_relic/rack.rb +4 -0
  95. data/lib/new_relic/rack/browser_monitoring.rb +34 -25
  96. data/lib/new_relic/rack/developer_mode.rb +3 -0
  97. data/lib/new_relic/rack/error_collector.rb +56 -0
  98. data/lib/new_relic/stats.rb +9 -7
  99. data/lib/new_relic/transaction_sample.rb +19 -18
  100. data/lib/new_relic/transaction_sample/segment.rb +13 -15
  101. data/lib/new_relic/version.rb +19 -3
  102. data/lib/newrelic_rpm.rb +1 -1
  103. data/lib/tasks/tests.rake +6 -8
  104. data/newrelic.yml +15 -32
  105. data/newrelic_rpm.gemspec +224 -43
  106. data/newrelic_rpm.gemspec.erb +54 -0
  107. data/test/config/newrelic.yml +4 -3
  108. data/test/config/test_control.rb +18 -18
  109. data/test/fixtures/gemspec_no_build.rb +442 -0
  110. data/test/fixtures/gemspec_with_build.rb +442 -0
  111. data/test/fixtures/gemspec_with_build_and_stage.rb +442 -0
  112. data/test/intentional_fail.rb +10 -0
  113. data/test/multiverse/.gitignore +10 -0
  114. data/test/multiverse/README.md +85 -0
  115. data/test/multiverse/lib/multiverse/color.rb +13 -0
  116. data/test/multiverse/lib/multiverse/envfile.rb +66 -0
  117. data/test/multiverse/lib/multiverse/environment.rb +16 -0
  118. data/test/multiverse/lib/multiverse/output_collector.rb +29 -0
  119. data/test/multiverse/lib/multiverse/runner.rb +44 -0
  120. data/test/multiverse/lib/multiverse/suite.rb +162 -0
  121. data/test/multiverse/script/run_one +3 -0
  122. data/test/multiverse/script/runner +9 -0
  123. data/test/multiverse/suites/active_record/Envfile +13 -0
  124. data/test/multiverse/suites/active_record/ar_method_aliasing.rb +94 -0
  125. data/test/multiverse/suites/active_record/config/newrelic.yml +22 -0
  126. data/test/multiverse/suites/active_record/encoding_test.rb +26 -0
  127. data/test/multiverse/suites/agent_only/Envfile +4 -0
  128. data/test/multiverse/suites/agent_only/audit_log_test.rb +99 -0
  129. data/test/multiverse/suites/agent_only/config/newrelic.yml +22 -0
  130. data/test/multiverse/suites/agent_only/http_response_code_test.rb +53 -0
  131. data/test/multiverse/suites/agent_only/marshaling_test.rb +109 -0
  132. data/test/multiverse/suites/agent_only/method_visibility_test.rb +98 -0
  133. data/test/multiverse/suites/agent_only/pipe_manager_test.rb +33 -0
  134. data/test/multiverse/suites/agent_only/service_timeout_test.rb +29 -0
  135. data/test/multiverse/suites/agent_only/test_trace_method_with_punctuation.rb +30 -0
  136. data/test/multiverse/suites/agent_only/test_trace_transaction_with_punctuation.rb +32 -0
  137. data/test/multiverse/suites/agent_only/thread_profiling_test.rb +80 -0
  138. data/test/multiverse/suites/config_file_loading/Envfile +7 -0
  139. data/test/multiverse/suites/config_file_loading/config_file_loading_test.rb +106 -0
  140. data/test/multiverse/suites/datamapper/Envfile +8 -0
  141. data/test/multiverse/suites/datamapper/config/newrelic.yml +22 -0
  142. data/test/multiverse/suites/datamapper/encoding_test.rb +36 -0
  143. data/test/multiverse/suites/logging/Envfile +4 -0
  144. data/test/multiverse/suites/logging/config/newrelic.yml +22 -0
  145. data/test/multiverse/suites/logging/logging_test.rb +143 -0
  146. data/test/multiverse/suites/monitor_mode_false/Envfile +2 -0
  147. data/test/multiverse/suites/monitor_mode_false/config/newrelic.yml +25 -0
  148. data/test/multiverse/suites/monitor_mode_false/no_dns_resolv.rb +29 -0
  149. data/test/multiverse/suites/no_load/Envfile +2 -0
  150. data/test/multiverse/suites/no_load/config/newrelic.yml +22 -0
  151. data/test/multiverse/suites/no_load/start_up_test.rb +14 -0
  152. data/test/multiverse/suites/rails_3_error_tracing/Envfile +15 -0
  153. data/test/multiverse/suites/rails_3_error_tracing/config/newrelic.yml +165 -0
  154. data/test/multiverse/suites/rails_3_error_tracing/error_tracing_test.rb +236 -0
  155. data/test/multiverse/suites/rails_3_gc/Envfile +8 -0
  156. data/test/multiverse/suites/rails_3_gc/config/newrelic.yml +167 -0
  157. data/test/multiverse/suites/rails_3_gc/instrumentation_test.rb +92 -0
  158. data/test/multiverse/suites/rails_3_queue_time/Envfile +15 -0
  159. data/test/multiverse/suites/rails_3_queue_time/config/newrelic.yml +165 -0
  160. data/test/multiverse/suites/rails_3_queue_time/queue_time_test.rb +75 -0
  161. data/test/multiverse/suites/rails_3_views/.gitignore +3 -0
  162. data/test/multiverse/suites/rails_3_views/Envfile +16 -0
  163. data/test/multiverse/suites/rails_3_views/app/views/foos/_foo.html.haml +1 -0
  164. data/test/multiverse/suites/rails_3_views/app/views/test/_a_partial.html.erb +1 -0
  165. data/test/multiverse/suites/rails_3_views/app/views/test/_mid_partial.html.erb +1 -0
  166. data/test/multiverse/suites/rails_3_views/app/views/test/_top_partial.html.erb +3 -0
  167. data/test/multiverse/suites/rails_3_views/app/views/test/deep_partial.html.erb +3 -0
  168. data/test/multiverse/suites/rails_3_views/app/views/test/haml_view.html.haml +6 -0
  169. data/test/multiverse/suites/rails_3_views/app/views/test/index.html.erb +4 -0
  170. data/test/multiverse/suites/rails_3_views/config/newrelic.yml +164 -0
  171. data/test/multiverse/suites/rails_3_views/view_instrumentation_test.rb +245 -0
  172. data/test/multiverse/suites/resque/Envfile +21 -0
  173. data/test/multiverse/suites/resque/config/newrelic.yml +22 -0
  174. data/test/multiverse/suites/resque/dump.rdb +0 -0
  175. data/test/multiverse/suites/resque/instrumentation_test.rb +73 -0
  176. data/test/multiverse/suites/rum_auto_instrumentation/Envfile +4 -0
  177. data/test/multiverse/suites/rum_auto_instrumentation/config/newrelic.yml +24 -0
  178. data/test/multiverse/suites/rum_auto_instrumentation/responses/worst_case_small.html +5000 -0
  179. data/test/multiverse/suites/rum_auto_instrumentation/sanity_test.rb +102 -0
  180. data/test/multiverse/suites/sinatra/Envfile +13 -0
  181. data/test/multiverse/suites/sinatra/config/newrelic.yml +24 -0
  182. data/test/multiverse/suites/sinatra/sinatra_metric_explosion_test.rb +77 -0
  183. data/test/multiverse/suites/sinatra/sinatra_routes_test.rb +46 -0
  184. data/test/multiverse/suites/sinatra/sinatra_test.rb +55 -0
  185. data/test/multiverse/test/multiverse_test.rb +55 -0
  186. data/test/multiverse/test/suite_examples/one/a/Envfile +3 -0
  187. data/test/multiverse/test/suite_examples/one/a/a_test.rb +11 -0
  188. data/test/multiverse/test/suite_examples/one/a/config/newrelic.yml +24 -0
  189. data/test/multiverse/test/suite_examples/one/b/Envfile +3 -0
  190. data/test/multiverse/test/suite_examples/one/b/b_test.rb +11 -0
  191. data/test/multiverse/test/suite_examples/one/b/config/newrelic.yml +24 -0
  192. data/test/multiverse/test/suite_examples/three/a/Envfile +2 -0
  193. data/test/multiverse/test/suite_examples/three/a/fail_test.rb +6 -0
  194. data/test/multiverse/test/suite_examples/three/b/Envfile +2 -0
  195. data/test/multiverse/test/suite_examples/three/b/win_test.rb +6 -0
  196. data/test/multiverse/test/suite_examples/two/a/Envfile +1 -0
  197. data/test/multiverse/test/suite_examples/two/a/fail_test.rb +6 -0
  198. data/test/new_relic/agent/agent/connect_test.rb +151 -227
  199. data/test/new_relic/agent/agent/start_test.rb +68 -118
  200. data/test/new_relic/agent/agent/start_worker_thread_test.rb +12 -74
  201. data/test/new_relic/agent/agent_logger_test.rb +153 -0
  202. data/test/new_relic/agent/agent_test.rb +116 -30
  203. data/test/new_relic/agent/agent_test_controller.rb +1 -1
  204. data/test/new_relic/agent/agent_test_controller_test.rb +42 -10
  205. data/test/new_relic/agent/audit_logger_test.rb +105 -0
  206. data/test/new_relic/agent/beacon_configuration_test.rb +63 -67
  207. data/test/new_relic/agent/browser_monitoring_test.rb +151 -79
  208. data/test/new_relic/agent/busy_calculator_test.rb +7 -0
  209. data/test/new_relic/agent/configuration/environment_source_test.rb +79 -0
  210. data/test/new_relic/agent/configuration/manager_test.rb +204 -0
  211. data/test/new_relic/agent/configuration/server_source_test.rb +45 -0
  212. data/test/new_relic/agent/configuration/yaml_source_test.rb +75 -0
  213. data/test/new_relic/agent/cross_process_monitoring_test.rb +77 -0
  214. data/test/new_relic/agent/database_test.rb +12 -11
  215. data/test/new_relic/agent/error_collector/notice_error_test.rb +64 -53
  216. data/test/new_relic/agent/error_collector_test.rb +33 -19
  217. data/test/new_relic/agent/instrumentation/active_record_instrumentation_test.rb +60 -30
  218. data/test/new_relic/agent/instrumentation/browser_monitoring_timings_test.rb +39 -0
  219. data/test/new_relic/agent/instrumentation/metric_frame/pop_test.rb +1 -1
  220. data/test/new_relic/agent/instrumentation/metric_frame_test.rb +6 -0
  221. data/test/new_relic/agent/instrumentation/queue_time_test.rb +14 -0
  222. data/test/new_relic/agent/instrumentation/sinatra_test.rb +25 -0
  223. data/test/new_relic/agent/instrumentation/task_instrumentation_test.rb +2 -2
  224. data/test/new_relic/agent/method_tracer/class_methods/add_method_tracer_test.rb +4 -10
  225. data/test/new_relic/agent/method_tracer/instance_methods/trace_execution_scoped_test.rb +3 -15
  226. data/test/new_relic/agent/method_tracer_test.rb +7 -6
  227. data/test/new_relic/agent/mock_scope_listener.rb +3 -0
  228. data/test/new_relic/agent/new_relic_service_test.rb +376 -0
  229. data/test/new_relic/agent/pipe_channel_manager_test.rb +131 -0
  230. data/test/new_relic/agent/pipe_service_test.rb +113 -0
  231. data/test/new_relic/agent/rpm_agent_test.rb +27 -50
  232. data/test/new_relic/agent/sql_sampler_test.rb +81 -56
  233. data/test/new_relic/agent/stats_engine/metric_stats/harvest_test.rb +3 -20
  234. data/test/new_relic/agent/stats_engine/metric_stats_test.rb +12 -1
  235. data/test/new_relic/agent/stats_engine_test.rb +17 -8
  236. data/test/new_relic/agent/thread_profiler_test.rb +537 -0
  237. data/test/new_relic/agent/thread_test.rb +89 -0
  238. data/test/new_relic/agent/threaded_test.rb +65 -0
  239. data/test/new_relic/agent/transaction_info_test.rb +45 -4
  240. data/test/new_relic/agent/transaction_sample_builder_test.rb +8 -7
  241. data/test/new_relic/agent/transaction_sampler_test.rb +193 -204
  242. data/test/new_relic/agent/worker_loop_test.rb +26 -11
  243. data/test/new_relic/agent_test.rb +113 -33
  244. data/test/new_relic/collection_helper_test.rb +7 -8
  245. data/test/new_relic/command/deployments_test.rb +18 -2
  246. data/test/new_relic/control/class_methods_test.rb +0 -18
  247. data/test/new_relic/control/frameworks/rails_test.rb +26 -0
  248. data/test/new_relic/control_test.rb +96 -137
  249. data/test/new_relic/delayed_job_injection_test.rb +6 -1
  250. data/test/new_relic/dispatcher_test.rb +54 -0
  251. data/test/new_relic/fake_collector.rb +283 -0
  252. data/test/new_relic/fake_service.rb +53 -0
  253. data/test/new_relic/fakes_sending_data.rb +30 -0
  254. data/test/new_relic/framework_test.rb +53 -0
  255. data/test/new_relic/load_test.rb +13 -0
  256. data/test/new_relic/local_environment_test.rb +11 -11
  257. data/test/new_relic/metric_data_test.rb +45 -16
  258. data/test/new_relic/noticed_error_test.rb +24 -0
  259. data/test/new_relic/rack/browser_monitoring_test.rb +20 -10
  260. data/test/new_relic/rack/developer_mode_test.rb +13 -7
  261. data/test/new_relic/rack/error_collector_test.rb +74 -0
  262. data/test/new_relic/stats_test.rb +10 -0
  263. data/test/new_relic/transaction_sample/segment_test.rb +23 -4
  264. data/test/new_relic/transaction_sample_test.rb +47 -2
  265. data/test/new_relic/version_number_test.rb +32 -0
  266. data/test/script/build_test_gem.sh +9 -3
  267. data/test/script/ci.sh +108 -35
  268. data/test/script/ci_agent-tests_runner.sh +82 -0
  269. data/test/script/ci_multiverse_runner.sh +63 -0
  270. data/test/test_contexts.rb +1 -0
  271. data/test/test_helper.rb +68 -18
  272. data/ui/helpers/developer_mode_helper.rb +21 -11
  273. data/ui/views/layouts/newrelic_default.rhtml +1 -0
  274. data/ui/views/newrelic/file/images/arrow-close.png +0 -0
  275. data/ui/views/newrelic/file/images/arrow-open.png +0 -0
  276. data/ui/views/newrelic/file/images/blue_bar.gif +0 -0
  277. data/ui/views/newrelic/file/images/file_icon.png +0 -0
  278. data/ui/views/newrelic/file/images/gray_bar.gif +0 -0
  279. data/ui/views/newrelic/show_sample.rhtml +1 -1
  280. data/ui/views/newrelic/threads.rhtml +2 -10
  281. data/vendor/gems/metric_parser-0.1.0.pre1/.specification +116 -0
  282. data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/servlet_init.rb +7 -0
  283. metadata +191 -65
  284. data/lib/new_relic/agent/samplers/delayed_job_lock_sampler.rb +0 -40
  285. data/lib/new_relic/control/configuration.rb +0 -206
  286. data/lib/new_relic/control/logging_methods.rb +0 -143
  287. data/lib/new_relic/data_serialization.rb +0 -151
  288. data/test/new_relic/control/configuration_test.rb +0 -84
  289. data/test/new_relic/control/logging_methods_test.rb +0 -185
  290. data/test/new_relic/data_serialization_test.rb +0 -208
@@ -5,6 +5,8 @@ class NewRelic::TransactionSampleTest < Test::Unit::TestCase
5
5
  ::SQL_STATEMENT = "SELECT * from sandwiches"
6
6
 
7
7
  def setup
8
+ @test_config = { :developer_mode => true }
9
+ NewRelic::Agent.config.apply_config(@test_config)
8
10
  @connection_stub = Mocha::Mockery.instance.named_mock('connection')
9
11
  @connection_stub.stubs(:execute).returns([['QUERY RESULT']])
10
12
 
@@ -12,6 +14,10 @@ class NewRelic::TransactionSampleTest < Test::Unit::TestCase
12
14
  @t = make_sql_transaction(::SQL_STATEMENT, ::SQL_STATEMENT)
13
15
  end
14
16
 
17
+ def teardown
18
+ NewRelic::Agent.config.remove_config(@test_config)
19
+ end
20
+
15
21
  def test_be_recorded
16
22
  assert_not_nil @t
17
23
  end
@@ -78,7 +84,7 @@ class NewRelic::TransactionSampleTest < Test::Unit::TestCase
78
84
 
79
85
  def test_have_explains
80
86
  s = @t.prepare_to_send(:record_sql => :obfuscated, :explain_sql => 0.00000001)
81
-
87
+
82
88
  s.each_segment do |segment|
83
89
  if segment.params[:explain_plan]
84
90
  explanation = segment.params[:explain_plan]
@@ -138,7 +144,7 @@ class NewRelic::TransactionSampleTest < Test::Unit::TestCase
138
144
  s.to_s
139
145
  end
140
146
  end
141
-
147
+
142
148
  def test_to_s_includes_keys
143
149
  s = @t.prepare_to_send(:explain_sql => 0.1)
144
150
  s.params[:fake_key] = 'a fake param'
@@ -174,4 +180,43 @@ class NewRelic::TransactionSampleTest < Test::Unit::TestCase
174
180
  end
175
181
  assert_equal 6, transaction.count_segments
176
182
  end
183
+
184
+ def test_to_array
185
+ expected_array = [@t.start_time.to_f,
186
+ @t.params[:request_params],
187
+ @t.params[:custom_params],
188
+ @t.root_segment.to_array]
189
+ assert_equal expected_array, @t.to_array
190
+ end
191
+
192
+ if RUBY_VERSION >= '1.9.2'
193
+ def test_to_json
194
+ expected_string = JSON.dump([@t.start_time.to_f,
195
+ @t.params[:request_params],
196
+ @t.params[:custom_params],
197
+ @t.root_segment.to_array])
198
+ assert_equal expected_string, @t.to_json
199
+ end
200
+ end
201
+
202
+ def test_to_collector_array
203
+ if NewRelic::Agent::NewRelicService::JsonMarshaller.is_supported?
204
+ marshaller = NewRelic::Agent::NewRelicService::JsonMarshaller.new
205
+ trace_tree = compress(@t.to_json)
206
+ else
207
+ marshaller = NewRelic::Agent::NewRelicService::PrubyMarshaller.new
208
+ trace_tree = @t.to_array
209
+ end
210
+ expected_array = [(@t.start_time.to_f * 1000).round,
211
+ (@t.duration * 1000).round,
212
+ @t.params[:path], @t.params[:uri],
213
+ trace_tree,
214
+ @t.guid, nil, !!@t.force_persist]
215
+
216
+ assert_equal expected_array, @t.to_collector_array(marshaller.default_encoder)
217
+ end
218
+
219
+ def compress(string)
220
+ Base64.encode64(Zlib::Deflate.deflate(string, Zlib::DEFAULT_COMPRESSION))
221
+ end
177
222
  end
@@ -86,4 +86,36 @@ class NewRelic::VersionNumberTest < Test::Unit::TestCase
86
86
  assert_equal '1.2.0', NewRelic::VersionNumber.new('1.2.0').to_s
87
87
  assert_equal '1.2', NewRelic::VersionNumber.new('1.2').to_s
88
88
  end
89
+
90
+ def test_gemspec_version_parsing
91
+ gemspec_contents = File.read(File.join(File.dirname(__FILE__), '..', '..', 'newrelic_rpm.gemspec'))
92
+ gemspec_contents =~ /s\.version\s*=\s*"(.*)"/
93
+ real_version = $1
94
+ assert_equal real_version, NewRelic::VERSION::STRING
95
+ end
96
+
97
+ def test_gemspec_parse_no_build
98
+ version = NewRelic::VERSION.parse_build_from_gemspec(NewRelic.fixture_path('gemspec_no_build.rb'))
99
+ assert_nil version
100
+ end
101
+
102
+ def test_gemspec_parse_with_build
103
+ version = NewRelic::VERSION.parse_build_from_gemspec(NewRelic.fixture_path('gemspec_with_build.rb'))
104
+ assert_equal '123', version
105
+ end
106
+
107
+ def test_gemspec_parse_with_build_and_stage
108
+ version = NewRelic::VERSION.parse_build_from_gemspec(NewRelic.fixture_path('gemspec_with_build_and_stage.rb'))
109
+ assert_equal '123.dev', version
110
+ end
111
+
112
+ def test_gemspec_parse_no_rubygems
113
+ Kernel.stubs(:const_defined?).with(:Gem).returns(false)
114
+ version = NewRelic::VERSION.parse_build_from_gemspec(NewRelic.fixture_path('gemspec_with_build_and_stage.rb'))
115
+ assert_equal '123.dev', version
116
+ end
117
+
118
+ def test_gemspec_parse_nonexistent
119
+ assert_nil NewRelic::VERSION.parse_build_from_gemspec('/really/not/a/real/path')
120
+ end
89
121
  end
@@ -1,10 +1,15 @@
1
1
  #!/bin/bash
2
2
 
3
3
  # print commands in this script as they're invoked
4
- set -x
4
+ #set -x
5
5
  # fail if any command fails
6
6
  set -e
7
7
 
8
+ . "$HOME/.rvm/scripts/rvm"
9
+
10
+ #rvm 1.9.3
11
+
12
+
8
13
  if [ "x$BUILD_NUMBER" == "x" ]; then
9
14
  echo '$BUILD_NUMBER is undefined'
10
15
  echo 'setting $BUILD_NUMBER to alpha'
@@ -12,7 +17,7 @@ if [ "x$BUILD_NUMBER" == "x" ]; then
12
17
  fi
13
18
 
14
19
  SHA1=`git log --pretty=format:'%h' -n 1`
15
- echo "building gem for commit $SHA"
20
+ echo "building gem for commit $SHA1"
16
21
 
17
22
  if [[ `gem list jeweler | grep [j]eweler | wc -l` -eq 1 ]]; then
18
23
  echo "detected jeweler. skipping install"
@@ -28,7 +33,8 @@ mkdir gems
28
33
 
29
34
  # FIXME: don't include the $SHA1 since some of our builds systems are confused
30
35
  # by this.
31
- BUILD_ID=$BUILD_NUMBER #.$SHA1
36
+ #BUILD_ID="$SHA1.$BUILD_NUMBER" #.$SHA1
37
+ BUILD_ID="$BUILD_NUMBER" #.$SHA1
32
38
 
33
39
  # rewrite the version file, setting the patch identifier to include the
34
40
  # BUILD_ID
data/test/script/ci.sh CHANGED
@@ -1,55 +1,75 @@
1
1
  #!/bin/bash
2
2
 
3
3
  # Script to run test suites in CI or in development mode. This script handles
4
- # checking out test dependencies (currently rpm_test_app and it's dependencies)
4
+ # checking out test dependencies (currently rpm_test_app and its dependencies)
5
5
  # and executing them.
6
6
  #
7
- # It relies on 3 environment variables:
7
+ # It relies on 2 environment variables:
8
8
  #
9
- # RUBY - The rvm ruby you want to use (e.g. 1.8.7, ree, jruby)
9
+ # RUBY - The rbenv ruby you want to use (e.g. 1.8.7, ree, jruby)
10
10
  #
11
11
  # BRANCH - The rpm_test_app branch you want to use (e.g. rails20, rails31)
12
12
  #
13
- # RPM_TEST_APP_CLONE_URL - where to clone the test app from (e.g.
14
- # git://github.com/newrelic/rpm_test_app.git, /path/in/my/filesystem)
15
- #
16
13
  # Example usage:
17
- # RPM_TEST_APP_CLONE_URL=git://github.com/newrelic/rpm_test_app.git \
18
14
  # RUBY=ree BRANCH=rails20 test/script/ci.sh
19
15
  #
20
- # RPM_TEST_APP_CLONE_URL=git://github.com/newrelic/rpm_test_app.git \
21
16
  # RUBY=ree BRANCH=rails20 test/script/ci.sh
22
17
  #
23
- # RPM_TEST_APP_CLONE_URL=~/dev/rpm_test_app/ \
24
18
  # RUBY=jruby BRANCH=rails22 test/script/ci.sh
25
19
 
26
20
  echo "Executing $0"
27
21
  echo "Running in $(pwd)"
28
22
 
29
-
30
-
31
23
  # print commands in this script as they're invoked
32
- # set -x
24
+ #set -x
33
25
  # fail if any command fails
34
26
  set -e
35
27
 
36
28
  # check for require environment variables
37
29
  if [ "x$RUBY" == "x" ]; then
38
30
  echo '$RUBY is undefined'
39
- exit 1
31
+ echo 'defaulting to 1.9.3'
32
+ export RUBY=1.9.3-p286
40
33
  fi
41
34
  if [ "x$BRANCH" == "x" ]; then
42
35
  echo '$BRANCH is undefined'
43
- exit 1
36
+ echo 'defaulting to rails31'
37
+ export BRANCH=rails31
38
+ fi
39
+
40
+ if [ "x$JOB_NAME" == "x" ]; then
41
+ echo '$JOB_NAME is undefined'
42
+ echo 'defaulting to clrun'
43
+ export PROJECT_NAME=clrun
44
+ else
45
+ CLEANSED_NAME=`echo $JOB_NAME | sed "s/label//" | sed "s/Portland//" | sed "s/BRANCH//" | sed "s/RUBY//" | sed "s/[=\/,\._]//g" | sed "s/ReleaseCandidate/RC/"`
46
+ echo "setting PROJECT_NAME to $CLEANSED_NAME"
47
+ export PROJECT_NAME="$CLEANSED_NAME"
44
48
  fi
45
- if [ "x$RPM_TEST_APP_CLONE_URL" == "x" ]; then
46
- echo '$RPM_TEST_APP_CLONE_URL is undefined'
47
- exit 1
49
+
50
+ eval "$(rbenv init -)" || true
51
+ rbenv shell $RUBY
52
+ if [ "x$(rbenv version-name)" = "x$RUBY" ]; then
53
+ echo "switched to ruby $RUBY"
54
+ else
55
+ rbenv install $RUBY
56
+ rbenv shell $RUBY
57
+ if [ "x$(rbenv version-name)" = "x$RUBY" ]; then
58
+ echo "switched to ruby $RUBY"
59
+ else
60
+ echo "failed to install ruby $RUBY"
61
+ exit 1
62
+ fi
48
63
  fi
49
64
 
50
- . "$HOME/.rvm/scripts/rvm"
51
- rvm use $RUBY || rvm install $RUBY
52
65
  echo `which ruby`
66
+ ruby -v
67
+
68
+ rake -h > /dev/null || gem install rake
69
+
70
+ echo "generating gemspec"
71
+ rake gemspec
72
+
53
73
 
54
74
  # make sure that we're in the project root
55
75
  script_dirname=`dirname $0`
@@ -59,36 +79,89 @@ pwd
59
79
  rm -rf tmp
60
80
  mkdir -p tmp
61
81
  cd tmp
62
- git clone --depth=1 $RPM_TEST_APP_CLONE_URL rpm_test_app
82
+
83
+
84
+ #rpm_test_app_cache=~/.rpm_test_app_cache
85
+ rpm_test_app_cache=~/workspace/.rpm_test_app_cache
86
+ (
87
+ echo "updating local cache of rpm_test_app in $rpm_test_app_cache"
88
+ git clone --mirror git://github.com/newrelic/rpm_test_app.git $rpm_test_app_cache || true
89
+ cd $rpm_test_app_cache
90
+ )
91
+
92
+ git clone $rpm_test_app_cache rpm_test_app
63
93
  cd rpm_test_app
94
+
64
95
  git checkout -t origin/$BRANCH || git checkout $BRANCH
96
+
97
+
98
+ # Re-write database.yml to this here doc
99
+ ( cat << "YAML" ) > config/database.yml
100
+ # Shared properties for mysql db
101
+ mysql: &mysql
102
+ adapter: mysql
103
+ socket: <%= (`uname -s` =~ /Linux/ ) ? "" :"/tmp/mysql.sock" %>
104
+ username: root
105
+ host: localhost
106
+ database: <%= ENV['PROJECT_NAME'] %>
107
+
108
+ # Shared properties for postgres. This won't work with our schema but
109
+ # Does work with agent tests
110
+ sqlite3: &sqlite3
111
+ <% if defined?(JRuby) %>
112
+ adapter: jdbcsqlite3
113
+ <% else %>
114
+ adapter: sqlite3
115
+ <% end %>
116
+ database: db/all.sqlite3
117
+ pool: 5
118
+ timeout: 5000
119
+ host: localhost
120
+
121
+ # SQLite version 3.x
122
+ # gem install sqlite3-ruby (not necessary on OS X Leopard)
123
+ development:
124
+ <<: *sqlite3
125
+
126
+ test:
127
+ <<: *mysql
128
+
129
+ production:
130
+ <<: *mysql
131
+ YAML
132
+
133
+
65
134
  mkdir -p log
66
135
  mkdir -p tmp
67
136
  if [ "x$BRANCH" == "xrails20" ]; then
68
- printf "\e[0;31;49mWarning:\e[0m "
69
- echo "Testing against the rails20 branch requires your changes to be committed. Uncommitted changes will not be used."
137
+ echo "Warning: Rails 2.0 support in progress. This probably only works in CI"
70
138
  mkdir -p vendor/plugins
71
- git clone ../.. vendor/plugins/newrelic_rpm
139
+ GEM=`ls ../../../*.gem | tail -n1`
140
+ (cd vendor/plugins && gem unpack ../../$GEM)
141
+ mv vendor/plugins/newrelic_rpm* vendor/plugins/newrelic_rpm
72
142
  else
73
143
  perl -p -i'.bak' -e 's#gem .newrelic_rpm.*$#gem "newrelic_rpm", :path => "\.\.\/\.\.\/"#' Gemfile
74
144
  fi
75
145
 
76
- rvm --force gemset delete ruby_agent_tests_$BRANCH
77
- rvm gemset create ruby_agent_tests_$BRANCH
78
- rvm gemset use ruby_agent_tests_$BRANCH
79
-
80
146
  if [ "x$RUBY" == "x1.8.6" ]; then
81
147
  # Bundler 1.1 dropped support for ruby 1.8.6
82
- gem install bundler -v'~>1.0.0' --no-rdoc --no-ri
148
+ bundle -h > /dev/null || gem install bundler -v'~>1.0.0' --no-rdoc --no-ri
83
149
  else
84
- gem install bundler --no-rdoc --no-ri
150
+ bundle -h > /dev/null || gem install bundler --no-rdoc --no-ri
85
151
  fi
86
152
 
87
153
 
88
154
  export RAILS_ENV=test
89
- bundle
90
- bundle exec rake --trace db:create:all ci:setup:testunit test:newrelic
91
-
92
-
93
-
94
-
155
+ bundle --local || bundle
156
+
157
+ # FIXME: Here we actually trigger the tests. Since the agent deals so heavily
158
+ # in units of time we have many tests that assert that durations are measured
159
+ # correctly. These almost always pass, but as the CI machine has come under
160
+ # heavier load there tend to be discrepencies between the duration measured in
161
+ # the test and the duration the agent measures. This is due to lags in CPU
162
+ # scheduling since many processes are running on the box simultaneously.
163
+ # To reduce the noise from these sporardic failures we rerun the test suite if
164
+ # there are failures to see if they are transient (instead of re-running it by
165
+ # hand). Ultimately we'll move towards a more elegant solution.
166
+
167
+ bundle exec rake --trace db:create:all test:newrelic || bundle exec rake --trace test:newrelic
@@ -0,0 +1,82 @@
1
+ #!/bin/bash -e
2
+
3
+ SCRATH_DIR=./agent-tests_tmp
4
+ #git pull git@github.com:newrelic/ruby_agent-tests.git
5
+
6
+ #echo $PWD
7
+ script_dirname=`dirname $0`
8
+ #echo $script_dirname
9
+ #echo $0
10
+
11
+ # make sure that we're in the project root
12
+ script_dirname=`dirname $0`
13
+ cd "$script_dirname/../../"
14
+
15
+
16
+
17
+ if [ -x $SCRATH_DIR ] ; then
18
+ echo "found tmp, deleting"
19
+ rm -fr $SCRATH_DIR
20
+ fi
21
+
22
+ mkdir $SCRATH_DIR
23
+ cd $SCRATH_DIR
24
+
25
+ git clone --depth=1 git@github.com:newrelic/ruby_agent-tests.git ruby_agent-tests
26
+ git clone --depth=1 git@github.com:newrelic/rpm_contrib.git rpm_contrib
27
+
28
+ if [ -x ../../Ruby_Agent ] ; then
29
+ ln -s ../../Ruby_Agent ./ruby_agent
30
+ else
31
+ echo "*********** Ruby_Agent can't be found ***********"
32
+ exit 1
33
+ fi
34
+
35
+ #exit 0
36
+
37
+ cd ruby_agent-tests
38
+ ./ci_run.sh
39
+
40
+ #echo "creating tmp dir"
41
+ #mkdir tmp
42
+ #echo "cd'ing to tmp"
43
+ # cd tmp
44
+ # echo $PWD
45
+
46
+
47
+ # exit 0
48
+ #env
49
+ #ls -al /home/hudson/.rvm/bin
50
+ # source ~/.rvm/scripts/rvm
51
+ #rvm 1.9.2
52
+ #ruby -v
53
+
54
+ # rvm --force gemset delete ruby_agent-tests
55
+
56
+ # rvm gemset create ruby_agent-tests
57
+
58
+ # rvm gemset use ruby_agent-tests
59
+ # gem install bundler
60
+ # bundle update
61
+ # bundle
62
+
63
+ ##
64
+ # bundle exec ruby fake_collector.rb
65
+ # bundle exec ruby sinatra_metric_explosion_test.rb
66
+
67
+ ########
68
+ # clear out gemset for next test set
69
+ #
70
+
71
+ # cd rails3viewfedex
72
+ # rvm --force gemset delete ruby_agent-tests
73
+
74
+ # rvm gemset create ruby_agent-tests
75
+
76
+ # rvm gemset use ruby_agent-tests
77
+
78
+ # gem install bundler
79
+ # bundle update
80
+ # bundle
81
+ # bundle exec ruby view_instrumentation_test.rb
82
+ #exit 0
@@ -0,0 +1,63 @@
1
+ #!/bin/bash -e
2
+
3
+ export PATH=$PATH:$HOME/bin
4
+
5
+ echo $HOME
6
+ echo $PATH
7
+ #ls $HOME/bin
8
+
9
+
10
+
11
+ if [ "x$RUBY" == "x" ] ; then
12
+ export RUBY=1.9.3
13
+ fi
14
+
15
+ echo "Tests will be run using $RUBY"
16
+ #uname -a
17
+
18
+ SCRATH_DIR=./multiverse_tmp
19
+ script_dirname=`dirname $0`
20
+
21
+ # make sure that we're in the project root
22
+ cd "$script_dirname/../../"
23
+
24
+ #pwd
25
+
26
+ if [ -x $SCRATH_DIR ] ; then
27
+ echo "found tmp, deleting"
28
+ rm -fr $SCRATH_DIR
29
+ fi
30
+
31
+ mkdir $SCRATH_DIR
32
+ cd $SCRATH_DIR
33
+
34
+ #pwd
35
+ if [[ $JOB_NAME =~ "Pangalactic" ]] ; then
36
+ AGENT_LOCATION="../../../../../../Ruby_Agent"
37
+ else
38
+ AGENT_LOCATION="../../Ruby_Agent"
39
+ fi
40
+
41
+ git clone --depth=1 git@github.com:newrelic/multiverse.git multiverse
42
+ git clone --depth=1 git@github.com:newrelic/rpm_contrib.git rpm_contrib
43
+
44
+ echo "Looking for Ruby Agent at $AGENT_LOCATION"
45
+ #ls -l ../../../../../../
46
+ #ls -l /home/hudson/workspace/
47
+
48
+ if [ -x $AGENT_LOCATION ] ; then
49
+ ln -s $AGENT_LOCATION ./ruby_agent
50
+ else
51
+ echo "*********** Ruby_Agent not found ***********"
52
+ exit 1
53
+ fi
54
+
55
+ cd multiverse
56
+ #./ci_run.sh
57
+
58
+ #pwd
59
+ #ls -l ../
60
+
61
+ eval "$(rbenv init -)" || true
62
+ rbenv shell $RUBY
63
+ script/runner