dolores_rpm 3.2.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (257) hide show
  1. data/CHANGELOG +559 -0
  2. data/LICENSE +64 -0
  3. data/README.rdoc +179 -0
  4. data/bin/mongrel_rpm +33 -0
  5. data/bin/newrelic +13 -0
  6. data/bin/newrelic_cmd +5 -0
  7. data/cert/cacert.pem +118 -0
  8. data/cert/oldsite.pem +28 -0
  9. data/cert/site.pem +27 -0
  10. data/dolores_rpm-3.3.4.fork.gem +0 -0
  11. data/install.rb +9 -0
  12. data/lib/conditional_vendored_dependency_detection.rb +3 -0
  13. data/lib/conditional_vendored_metric_parser.rb +5 -0
  14. data/lib/new_relic/agent/agent.rb +1311 -0
  15. data/lib/new_relic/agent/beacon_configuration.rb +110 -0
  16. data/lib/new_relic/agent/browser_monitoring.rb +102 -0
  17. data/lib/new_relic/agent/busy_calculator.rb +99 -0
  18. data/lib/new_relic/agent/chained_call.rb +13 -0
  19. data/lib/new_relic/agent/database.rb +203 -0
  20. data/lib/new_relic/agent/error_collector.rb +251 -0
  21. data/lib/new_relic/agent/instrumentation/active_merchant.rb +27 -0
  22. data/lib/new_relic/agent/instrumentation/acts_as_solr.rb +68 -0
  23. data/lib/new_relic/agent/instrumentation/authlogic.rb +19 -0
  24. data/lib/new_relic/agent/instrumentation/controller_instrumentation.rb +424 -0
  25. data/lib/new_relic/agent/instrumentation/data_mapper.rb +57 -0
  26. data/lib/new_relic/agent/instrumentation/delayed_job_instrumentation.rb +52 -0
  27. data/lib/new_relic/agent/instrumentation/memcache.rb +80 -0
  28. data/lib/new_relic/agent/instrumentation/merb/controller.rb +41 -0
  29. data/lib/new_relic/agent/instrumentation/merb/errors.rb +29 -0
  30. data/lib/new_relic/agent/instrumentation/metric_frame/pop.rb +80 -0
  31. data/lib/new_relic/agent/instrumentation/metric_frame.rb +332 -0
  32. data/lib/new_relic/agent/instrumentation/net.rb +29 -0
  33. data/lib/new_relic/agent/instrumentation/passenger_instrumentation.rb +36 -0
  34. data/lib/new_relic/agent/instrumentation/queue_time.rb +210 -0
  35. data/lib/new_relic/agent/instrumentation/rack.rb +98 -0
  36. data/lib/new_relic/agent/instrumentation/rails/action_controller.rb +114 -0
  37. data/lib/new_relic/agent/instrumentation/rails/action_web_service.rb +42 -0
  38. data/lib/new_relic/agent/instrumentation/rails/active_record_instrumentation.rb +115 -0
  39. data/lib/new_relic/agent/instrumentation/rails/errors.rb +42 -0
  40. data/lib/new_relic/agent/instrumentation/rails3/action_controller.rb +118 -0
  41. data/lib/new_relic/agent/instrumentation/rails3/active_record_instrumentation.rb +122 -0
  42. data/lib/new_relic/agent/instrumentation/rails3/errors.rb +37 -0
  43. data/lib/new_relic/agent/instrumentation/sinatra.rb +58 -0
  44. data/lib/new_relic/agent/instrumentation/sunspot.rb +29 -0
  45. data/lib/new_relic/agent/instrumentation/unicorn_instrumentation.rb +21 -0
  46. data/lib/new_relic/agent/instrumentation.rb +9 -0
  47. data/lib/new_relic/agent/method_tracer.rb +528 -0
  48. data/lib/new_relic/agent/sampler.rb +50 -0
  49. data/lib/new_relic/agent/samplers/cpu_sampler.rb +58 -0
  50. data/lib/new_relic/agent/samplers/delayed_job_lock_sampler.rb +40 -0
  51. data/lib/new_relic/agent/samplers/memory_sampler.rb +144 -0
  52. data/lib/new_relic/agent/samplers/object_sampler.rb +26 -0
  53. data/lib/new_relic/agent/shim_agent.rb +29 -0
  54. data/lib/new_relic/agent/sql_sampler.rb +267 -0
  55. data/lib/new_relic/agent/stats_engine/metric_stats.rb +187 -0
  56. data/lib/new_relic/agent/stats_engine/samplers.rb +95 -0
  57. data/lib/new_relic/agent/stats_engine/transactions.rb +208 -0
  58. data/lib/new_relic/agent/stats_engine.rb +25 -0
  59. data/lib/new_relic/agent/transaction_sample_builder.rb +101 -0
  60. data/lib/new_relic/agent/transaction_sampler.rb +397 -0
  61. data/lib/new_relic/agent/worker_loop.rb +89 -0
  62. data/lib/new_relic/agent.rb +454 -0
  63. data/lib/new_relic/collection_helper.rb +75 -0
  64. data/lib/new_relic/command.rb +85 -0
  65. data/lib/new_relic/commands/deployments.rb +105 -0
  66. data/lib/new_relic/commands/install.rb +80 -0
  67. data/lib/new_relic/control/class_methods.rb +53 -0
  68. data/lib/new_relic/control/configuration.rb +202 -0
  69. data/lib/new_relic/control/frameworks/external.rb +16 -0
  70. data/lib/new_relic/control/frameworks/merb.rb +31 -0
  71. data/lib/new_relic/control/frameworks/rails.rb +164 -0
  72. data/lib/new_relic/control/frameworks/rails3.rb +75 -0
  73. data/lib/new_relic/control/frameworks/ruby.rb +42 -0
  74. data/lib/new_relic/control/frameworks/sinatra.rb +20 -0
  75. data/lib/new_relic/control/frameworks.rb +10 -0
  76. data/lib/new_relic/control/instance_methods.rb +179 -0
  77. data/lib/new_relic/control/instrumentation.rb +100 -0
  78. data/lib/new_relic/control/logging_methods.rb +143 -0
  79. data/lib/new_relic/control/profiling.rb +25 -0
  80. data/lib/new_relic/control/server_methods.rb +114 -0
  81. data/lib/new_relic/control.rb +46 -0
  82. data/lib/new_relic/data_serialization.rb +157 -0
  83. data/lib/new_relic/delayed_job_injection.rb +46 -0
  84. data/lib/new_relic/language_support.rb +69 -0
  85. data/lib/new_relic/local_environment.rb +414 -0
  86. data/lib/new_relic/merbtasks.rb +6 -0
  87. data/lib/new_relic/metric_data.rb +51 -0
  88. data/lib/new_relic/metric_spec.rb +75 -0
  89. data/lib/new_relic/metrics.rb +9 -0
  90. data/lib/new_relic/noticed_error.rb +24 -0
  91. data/lib/new_relic/rack/browser_monitoring.rb +68 -0
  92. data/lib/new_relic/rack/developer_mode.rb +268 -0
  93. data/lib/new_relic/recipes.rb +73 -0
  94. data/lib/new_relic/stats.rb +388 -0
  95. data/lib/new_relic/timer_lib.rb +27 -0
  96. data/lib/new_relic/transaction_analysis/segment_summary.rb +49 -0
  97. data/lib/new_relic/transaction_analysis.rb +77 -0
  98. data/lib/new_relic/transaction_sample/composite_segment.rb +27 -0
  99. data/lib/new_relic/transaction_sample/fake_segment.rb +9 -0
  100. data/lib/new_relic/transaction_sample/segment.rb +201 -0
  101. data/lib/new_relic/transaction_sample/summary_segment.rb +21 -0
  102. data/lib/new_relic/transaction_sample.rb +245 -0
  103. data/lib/new_relic/url_rule.rb +14 -0
  104. data/lib/new_relic/version.rb +55 -0
  105. data/lib/newrelic_rpm.rb +49 -0
  106. data/lib/tasks/all.rb +4 -0
  107. data/lib/tasks/install.rake +7 -0
  108. data/lib/tasks/tests.rake +19 -0
  109. data/newrelic.yml +265 -0
  110. data/recipes/newrelic.rb +6 -0
  111. data/test/active_record_fixtures.rb +77 -0
  112. data/test/config/newrelic.yml +48 -0
  113. data/test/config/test_control.rb +48 -0
  114. data/test/new_relic/agent/agent/connect_test.rb +410 -0
  115. data/test/new_relic/agent/agent/start_test.rb +255 -0
  116. data/test/new_relic/agent/agent/start_worker_thread_test.rb +153 -0
  117. data/test/new_relic/agent/agent_test.rb +139 -0
  118. data/test/new_relic/agent/agent_test_controller.rb +77 -0
  119. data/test/new_relic/agent/agent_test_controller_test.rb +363 -0
  120. data/test/new_relic/agent/apdex_from_server_test.rb +9 -0
  121. data/test/new_relic/agent/beacon_configuration_test.rb +108 -0
  122. data/test/new_relic/agent/browser_monitoring_test.rb +278 -0
  123. data/test/new_relic/agent/busy_calculator_test.rb +81 -0
  124. data/test/new_relic/agent/database_test.rb +162 -0
  125. data/test/new_relic/agent/error_collector/notice_error_test.rb +257 -0
  126. data/test/new_relic/agent/error_collector_test.rb +175 -0
  127. data/test/new_relic/agent/instrumentation/active_record_instrumentation_test.rb +538 -0
  128. data/test/new_relic/agent/instrumentation/controller_instrumentation_test.rb +36 -0
  129. data/test/new_relic/agent/instrumentation/instrumentation_test.rb +11 -0
  130. data/test/new_relic/agent/instrumentation/metric_frame/pop_test.rb +172 -0
  131. data/test/new_relic/agent/instrumentation/metric_frame_test.rb +50 -0
  132. data/test/new_relic/agent/instrumentation/net_instrumentation_test.rb +84 -0
  133. data/test/new_relic/agent/instrumentation/queue_time_test.rb +387 -0
  134. data/test/new_relic/agent/instrumentation/rack_test.rb +35 -0
  135. data/test/new_relic/agent/instrumentation/task_instrumentation_test.rb +184 -0
  136. data/test/new_relic/agent/memcache_instrumentation_test.rb +143 -0
  137. data/test/new_relic/agent/method_tracer/class_methods/add_method_tracer_test.rb +164 -0
  138. data/test/new_relic/agent/method_tracer/instance_methods/trace_execution_scoped_test.rb +234 -0
  139. data/test/new_relic/agent/method_tracer_test.rb +386 -0
  140. data/test/new_relic/agent/mock_scope_listener.rb +23 -0
  141. data/test/new_relic/agent/rpm_agent_test.rb +149 -0
  142. data/test/new_relic/agent/sampler_test.rb +19 -0
  143. data/test/new_relic/agent/shim_agent_test.rb +20 -0
  144. data/test/new_relic/agent/sql_sampler_test.rb +160 -0
  145. data/test/new_relic/agent/stats_engine/metric_stats/harvest_test.rb +150 -0
  146. data/test/new_relic/agent/stats_engine/metric_stats_test.rb +82 -0
  147. data/test/new_relic/agent/stats_engine/samplers_test.rb +99 -0
  148. data/test/new_relic/agent/stats_engine_test.rb +185 -0
  149. data/test/new_relic/agent/transaction_sample_builder_test.rb +195 -0
  150. data/test/new_relic/agent/transaction_sampler_test.rb +955 -0
  151. data/test/new_relic/agent/worker_loop_test.rb +66 -0
  152. data/test/new_relic/agent_test.rb +175 -0
  153. data/test/new_relic/collection_helper_test.rb +149 -0
  154. data/test/new_relic/command/deployments_test.rb +68 -0
  155. data/test/new_relic/control/class_methods_test.rb +62 -0
  156. data/test/new_relic/control/configuration_test.rb +72 -0
  157. data/test/new_relic/control/logging_methods_test.rb +185 -0
  158. data/test/new_relic/control_test.rb +254 -0
  159. data/test/new_relic/data_serialization_test.rb +208 -0
  160. data/test/new_relic/delayed_job_injection_test.rb +16 -0
  161. data/test/new_relic/local_environment_test.rb +72 -0
  162. data/test/new_relic/metric_data_test.rb +125 -0
  163. data/test/new_relic/metric_spec_test.rb +95 -0
  164. data/test/new_relic/rack/all_test.rb +11 -0
  165. data/test/new_relic/rack/browser_monitoring_test.rb +84 -0
  166. data/test/new_relic/rack/developer_mode_helper_test.rb +141 -0
  167. data/test/new_relic/rack/developer_mode_test.rb +43 -0
  168. data/test/new_relic/stats_test.rb +426 -0
  169. data/test/new_relic/transaction_analysis/segment_summary_test.rb +91 -0
  170. data/test/new_relic/transaction_analysis_test.rb +121 -0
  171. data/test/new_relic/transaction_sample/composite_segment_test.rb +35 -0
  172. data/test/new_relic/transaction_sample/fake_segment_test.rb +17 -0
  173. data/test/new_relic/transaction_sample/segment_test.rb +389 -0
  174. data/test/new_relic/transaction_sample/summary_segment_test.rb +31 -0
  175. data/test/new_relic/transaction_sample_subtest_test.rb +56 -0
  176. data/test/new_relic/transaction_sample_test.rb +164 -0
  177. data/test/new_relic/version_number_test.rb +89 -0
  178. data/test/test_contexts.rb +29 -0
  179. data/test/test_helper.rb +154 -0
  180. data/ui/helpers/developer_mode_helper.rb +357 -0
  181. data/ui/helpers/google_pie_chart.rb +48 -0
  182. data/ui/views/layouts/newrelic_default.rhtml +47 -0
  183. data/ui/views/newrelic/_explain_plans.rhtml +27 -0
  184. data/ui/views/newrelic/_sample.rhtml +20 -0
  185. data/ui/views/newrelic/_segment.rhtml +28 -0
  186. data/ui/views/newrelic/_segment_limit_message.rhtml +1 -0
  187. data/ui/views/newrelic/_segment_row.rhtml +12 -0
  188. data/ui/views/newrelic/_show_sample_detail.rhtml +24 -0
  189. data/ui/views/newrelic/_show_sample_sql.rhtml +24 -0
  190. data/ui/views/newrelic/_show_sample_summary.rhtml +3 -0
  191. data/ui/views/newrelic/_sql_row.rhtml +16 -0
  192. data/ui/views/newrelic/_stack_trace.rhtml +15 -0
  193. data/ui/views/newrelic/_table.rhtml +12 -0
  194. data/ui/views/newrelic/explain_sql.rhtml +43 -0
  195. data/ui/views/newrelic/file/images/arrow-close.png +0 -0
  196. data/ui/views/newrelic/file/images/arrow-open.png +0 -0
  197. data/ui/views/newrelic/file/images/blue_bar.gif +0 -0
  198. data/ui/views/newrelic/file/images/file_icon.png +0 -0
  199. data/ui/views/newrelic/file/images/gray_bar.gif +0 -0
  200. data/ui/views/newrelic/file/images/new-relic-rpm-desktop.gif +0 -0
  201. data/ui/views/newrelic/file/images/new_relic_rpm_desktop.gif +0 -0
  202. data/ui/views/newrelic/file/images/textmate.png +0 -0
  203. data/ui/views/newrelic/file/javascript/jquery-1.4.2.js +6240 -0
  204. data/ui/views/newrelic/file/javascript/transaction_sample.js +120 -0
  205. data/ui/views/newrelic/file/stylesheets/style.css +490 -0
  206. data/ui/views/newrelic/index.rhtml +71 -0
  207. data/ui/views/newrelic/sample_not_found.rhtml +2 -0
  208. data/ui/views/newrelic/show_sample.rhtml +80 -0
  209. data/ui/views/newrelic/show_source.rhtml +3 -0
  210. data/ui/views/newrelic/threads.rhtml +53 -0
  211. data/vendor/gems/dependency_detection-0.0.1.build/LICENSE +5 -0
  212. data/vendor/gems/dependency_detection-0.0.1.build/lib/dependency_detection/version.rb +3 -0
  213. data/vendor/gems/dependency_detection-0.0.1.build/lib/dependency_detection.rb +62 -0
  214. data/vendor/gems/metric_parser-0.1.0.pre1/lib/metric_parser.rb +1 -0
  215. data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/action_mailer.rb +14 -0
  216. data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/active_merchant.rb +31 -0
  217. data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/active_record.rb +33 -0
  218. data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/apdex.rb +89 -0
  219. data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/background_transaction.rb +7 -0
  220. data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/client.rb +46 -0
  221. data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/controller.rb +67 -0
  222. data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/controller_cpu.rb +43 -0
  223. data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/controller_ext.rb +17 -0
  224. data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/database.rb +48 -0
  225. data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/database_pool.rb +24 -0
  226. data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/dot_net.rb +28 -0
  227. data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/dot_net_parser.rb +17 -0
  228. data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/errors.rb +11 -0
  229. data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/external.rb +55 -0
  230. data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/frontend.rb +40 -0
  231. data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/gc.rb +20 -0
  232. data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/hibernate_session.rb +7 -0
  233. data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/java.rb +31 -0
  234. data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/java_parser.rb +17 -0
  235. data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/jsp.rb +34 -0
  236. data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/jsp_tag.rb +7 -0
  237. data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/mem_cache.rb +55 -0
  238. data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/metric_parser.rb +122 -0
  239. data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/orm.rb +27 -0
  240. data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/other_transaction.rb +40 -0
  241. data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/servlet.rb +7 -0
  242. data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/servlet_context_listener.rb +7 -0
  243. data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/servlet_filter.rb +7 -0
  244. data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/solr.rb +27 -0
  245. data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/solr_request_handler.rb +15 -0
  246. data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/spring.rb +54 -0
  247. data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/spring_controller.rb +6 -0
  248. data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/spring_view.rb +6 -0
  249. data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/struts_action.rb +20 -0
  250. data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/struts_result.rb +20 -0
  251. data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/version.rb +5 -0
  252. data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/view.rb +70 -0
  253. data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/web_frontend.rb +18 -0
  254. data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/web_service.rb +14 -0
  255. data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/web_transaction.rb +133 -0
  256. data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser.rb +64 -0
  257. metadata +398 -0
@@ -0,0 +1,185 @@
1
+ require File.expand_path(File.join(File.dirname(__FILE__), '..', '..', 'test_helper'))
2
+ require 'new_relic/control/logging_methods'
3
+ require 'fileutils'
4
+
5
+ class BaseLoggingMethods
6
+ # stub class to enable testing of the module
7
+ include NewRelic::Control::LoggingMethods
8
+ include NewRelic::Control::Configuration
9
+ def root; "."; end
10
+ end
11
+
12
+ class NewRelic::Control::LoggingMethodsTest < Test::Unit::TestCase
13
+ def setup
14
+ @base = BaseLoggingMethods.new
15
+ @base.settings['log_file_path'] = 'log/'
16
+ @base.settings['log_file_name'] = 'newrelic_agent.log'
17
+ super
18
+ end
19
+
20
+ def test_log_basic
21
+ mock_logger = mock('logger')
22
+ @base.instance_eval { @log = mock_logger }
23
+ assert_equal mock_logger, @base.log
24
+ end
25
+
26
+ def test_log_no_log
27
+ log = @base.log
28
+ assert_equal Logger, log.class
29
+ assert_equal Logger::INFO, log.level
30
+ # have to root around in the logger for the logdev
31
+ assert_equal STDOUT, log.instance_eval { @logdev }.dev
32
+ end
33
+
34
+ def test_logbang_basic
35
+ @base.expects(:should_log?).returns(true)
36
+ @base.expects(:to_stdout).with('whee')
37
+ @base.instance_eval { @log = nil }
38
+ @base.log!('whee')
39
+ end
40
+
41
+ def test_logbang_should_not_log
42
+ @base.expects(:should_log?).returns(false)
43
+ @base.stubs(:to_stdout)
44
+ assert_equal nil, @base.log!('whee')
45
+ end
46
+
47
+ def test_logbang_with_log
48
+ @base.expects(:should_log?).returns(true)
49
+ @base.expects(:to_stdout).with('whee')
50
+ fake_logger = mock('log')
51
+ fake_logger.expects(:send).with(:info, 'whee')
52
+ @base.instance_eval { @log = fake_logger }
53
+ @base.log!('whee')
54
+ end
55
+
56
+ def test_should_log_no_settings
57
+ @base.instance_eval { @settings = nil }
58
+ assert !@base.should_log?
59
+ end
60
+
61
+ def test_should_log_agent_disabled
62
+ @base.instance_eval { @settings = true }
63
+ @base.expects(:agent_enabled?).returns(false)
64
+ assert !@base.should_log?
65
+ end
66
+
67
+ def test_should_log_agent_enabled
68
+ @base.instance_eval { @settings = true }
69
+ @base.expects(:agent_enabled?).returns(true)
70
+ assert @base.should_log?
71
+ end
72
+
73
+ def test_set_log_level_base
74
+ fake_logger = mock('logger')
75
+ # bad configuration
76
+ @base.expects(:fetch).with('log_level', 'info').returns('whee')
77
+ fake_logger.expects(:level=).with(Logger::INFO)
78
+ assert_equal fake_logger, @base.set_log_level!(fake_logger)
79
+ end
80
+
81
+ def test_set_log_level_with_each_level
82
+ fake_logger = mock('logger')
83
+ %w[debug info warn error fatal].each do |level|
84
+ @base.expects(:fetch).with('log_level', 'info').returns(level)
85
+ fake_logger.expects(:level=).with(Logger.const_get(level.upcase))
86
+ assert_equal fake_logger, @base.set_log_level!(fake_logger)
87
+ end
88
+ end
89
+
90
+ def test_set_log_format
91
+ fake_logger = Object.new
92
+ assert !fake_logger.respond_to?(:format_message)
93
+ assert_equal fake_logger, @base.set_log_format!(fake_logger)
94
+ assert fake_logger.respond_to?(:format_message)
95
+ end
96
+
97
+ def test_setup_log_existing_file
98
+ fake_logger = mock('logger')
99
+ Logger.expects(:new).with('logpath/logfilename').returns(fake_logger)
100
+ @base.expects(:log_path).returns('logpath').at_least_once
101
+ @base.expects(:log_file_name).returns('logfilename')
102
+ @base.expects(:set_log_format!).with(fake_logger)
103
+ @base.expects(:set_log_level!).with(fake_logger)
104
+ assert_equal fake_logger, @base.setup_log
105
+ assert_equal fake_logger, @base.instance_eval { @log }
106
+ assert_equal 'logpath/logfilename', @base.instance_eval { @log_file }
107
+ end
108
+
109
+ def test_to_stdout
110
+ STDOUT.expects(:puts).with('** [NewRelic] whee')
111
+ @base.to_stdout('whee')
112
+ end
113
+
114
+ def test_log_path_exists
115
+ @base.instance_eval { @log_path = 'logpath' }
116
+ assert_equal 'logpath', @base.log_path
117
+ end
118
+
119
+ def test_log_path_path_exists
120
+ @base.settings['log_file_path'] = 'log'
121
+ assert File.directory?('log')
122
+ assert_equal File.expand_path('log'), @base.log_path
123
+ end
124
+
125
+ def test_log_path_path_created
126
+ path = File.expand_path('tmp/log_path_test')
127
+ @base.instance_eval { @log_path = nil }
128
+ @base.settings['log_file_path'] = 'tmp/log_path_test'
129
+ assert !File.directory?(path) || FileUtils.rmdir(path)
130
+ @base.expects(:log!).never
131
+ assert_equal path, @base.log_path
132
+ assert File.directory?(path)
133
+ end
134
+
135
+ def test_log_path_path_unable_to_create
136
+ path = File.expand_path('tmp/log_path_test')
137
+ @base.instance_eval { @log_path = nil }
138
+ @base.settings['log_file_path'] = 'tmp/log_path_test'
139
+ assert !File.directory?(path) || FileUtils.rmdir(path)
140
+ @base.expects(:log!).with("Error creating log directory tmp/log_path_test, using standard out for logging.", :warn)
141
+ Dir.expects(:mkdir).with(path).raises('cannot make directory bro!').twice # once for the relative directory, once for the directory relative to Rails.root
142
+ assert_nil @base.log_path
143
+ assert !File.directory?(path)
144
+ assert_equal STDOUT, @base.log.instance_eval { @logdev }.dev
145
+ end
146
+
147
+ def test_log_file_name
148
+ @base.expects(:fetch).with('log_file_name', 'newrelic_agent.log').returns('log_file_name')
149
+ assert_equal 'log_file_name', @base.log_file_name
150
+ end
151
+
152
+ def test_log_to_stdout_when_log_file_path_set_to_STDOUT
153
+ @base.stubs(:fetch).returns('whatever')
154
+ @base.expects(:fetch).with('log_file_path', 'log').returns('STDOUT')
155
+ Dir.expects(:mkdir).never
156
+ @base.setup_log
157
+ assert_equal STDOUT, @base.log.instance_eval { @logdev }.dev
158
+ end
159
+
160
+ def test_logs_to_stdout_include_newrelic_prefix
161
+ @base.stubs(:fetch).returns('whatever')
162
+ @base.expects(:fetch).with('log_file_path', 'log').returns('STDOUT')
163
+ STDOUT.expects(:write).with(regexp_matches(/\*\* \[NewRelic\].*whee/))
164
+ @base.setup_log
165
+ @base.log.info('whee')
166
+ end
167
+
168
+ def test_set_stdout_destination_from_NEW_RELIC_LOG_env_var
169
+ @base.stubs(:fetch).returns('whatever')
170
+ ENV['NEW_RELIC_LOG'] = 'stdout'
171
+ Dir.expects(:mkdir).never
172
+ @base.setup_log
173
+ assert_equal STDOUT, @base.log.instance_eval { @logdev }.dev
174
+ ENV['NEW_RELIC_LOG'] = nil
175
+ end
176
+
177
+ def test_set_file_destination_from_NEW_RELIC_LOG_env_var
178
+ @base.stubs(:fetch).returns('whatever')
179
+ ENV['NEW_RELIC_LOG'] = 'log/file.log'
180
+ @base.setup_log
181
+ assert_equal 'log', File.basename(@base.log_path)
182
+ assert_equal 'file.log', @base.log_file_name
183
+ ENV['NEW_RELIC_LOG'] = nil
184
+ end
185
+ end
@@ -0,0 +1,254 @@
1
+ require File.expand_path(File.join(File.dirname(__FILE__),'/../test_helper'))
2
+ class NewRelic::ControlTest < Test::Unit::TestCase
3
+
4
+ attr_reader :control
5
+
6
+ def setup
7
+ NewRelic::Agent.manual_start(:dispatcher_instance_id => 'test')
8
+ @control = NewRelic::Control.instance
9
+ raise 'oh geez, wrong class' unless NewRelic::Control.instance.is_a?(::NewRelic::Control::Frameworks::Test)
10
+ end
11
+
12
+ def shutdown
13
+ NewRelic::Agent.shutdown
14
+ end
15
+
16
+ def test_cert_file_path
17
+ assert @control.cert_file_path
18
+ assert_equal File.expand_path(File.join(File.dirname(__FILE__), '..', '..', 'cert', 'cacert.pem')), @control.cert_file_path
19
+ end
20
+
21
+ # This test does not actually use the ruby agent in any way - it's
22
+ # testing that the CA file we ship actually validates our server's
23
+ # certificate. It's used for customers who enable verify_certificate
24
+ def test_cert_file
25
+ require 'socket'
26
+ require 'openssl'
27
+
28
+ s = TCPSocket.new 'collector.newrelic.com', 443
29
+ ctx = OpenSSL::SSL::SSLContext.new
30
+ ctx.ca_file = @control.cert_file_path
31
+ ctx.verify_mode = OpenSSL::SSL::VERIFY_PEER
32
+ s = OpenSSL::SSL::SSLSocket.new s, ctx
33
+ s.connect
34
+ # should not raise an error
35
+ end
36
+
37
+ # see above, but for staging, as well. This allows us to test new
38
+ # certificates in a non-customer-facing place before setting them
39
+ # live.
40
+ def test_staging_cert_file
41
+ require 'socket'
42
+ require 'openssl'
43
+
44
+ s = TCPSocket.new 'staging-collector.newrelic.com', 443
45
+ ctx = OpenSSL::SSL::SSLContext.new
46
+ ctx.ca_file = @control.cert_file_path
47
+ ctx.verify_mode = OpenSSL::SSL::VERIFY_PEER
48
+ s = OpenSSL::SSL::SSLSocket.new s, ctx
49
+ s.connect
50
+ # should not raise an error
51
+ end
52
+
53
+ def test_monitor_mode
54
+ assert ! @control.monitor_mode?
55
+ @control.settings.delete 'enabled'
56
+ @control.settings.delete 'monitor_mode'
57
+ assert !@control.monitor_mode?
58
+ @control['enabled'] = false
59
+ assert ! @control.monitor_mode?
60
+ @control['enabled'] = true
61
+ assert @control.monitor_mode?
62
+ @control['monitor_mode'] = nil
63
+ assert !@control.monitor_mode?
64
+ @control['monitor_mode'] = false
65
+ assert !@control.monitor_mode?
66
+ @control['monitor_mode'] = true
67
+ assert @control.monitor_mode?
68
+ ensure
69
+ @control['enabled'] = false
70
+ @control['monitor_mode'] = false
71
+ end
72
+
73
+ def test_test_config
74
+ if defined?(Rails) && Rails::VERSION::MAJOR.to_i == 3
75
+ assert_equal :rails3, control.app
76
+ elsif defined?(Rails)
77
+ assert_equal :rails, control.app
78
+ else
79
+ assert_equal :test, control.app
80
+ end
81
+ assert_equal :test, control.framework
82
+ assert_match /test/i, control.dispatcher_instance_id
83
+ assert("" == control.dispatcher.to_s, "Expected dispatcher to be empty, but was #{control.dispatcher.to_s}")
84
+ assert !control['enabled']
85
+ assert_equal false, control['monitor_mode']
86
+ control.local_env
87
+ end
88
+
89
+ def test_root
90
+ assert File.directory?(NewRelic::Control.newrelic_root), NewRelic::Control.newrelic_root
91
+ if defined?(Rails)
92
+ assert File.directory?(File.join(NewRelic::Control.newrelic_root, "lib")), NewRelic::Control.newrelic_root + "/lib"
93
+ end
94
+ end
95
+
96
+ def test_info
97
+ props = NewRelic::Control.instance.local_env.snapshot
98
+ if defined?(Rails)
99
+ assert_match /jdbc|postgres|mysql|sqlite/, props.assoc('Database adapter').last, props.inspect
100
+ end
101
+ end
102
+
103
+ def test_resolve_ip
104
+ assert_equal nil, control.send(:convert_to_ip_address, 'localhost')
105
+ assert_equal nil, control.send(:convert_to_ip_address, 'q1239988737.us')
106
+ # This will fail if you don't have a valid, accessible, DNS server
107
+ assert_equal '204.93.223.153', control.send(:convert_to_ip_address, 'collector.newrelic.com')
108
+ end
109
+
110
+ class FakeResolv
111
+ def self.getaddress(host)
112
+ raise 'deliberately broken'
113
+ end
114
+ end
115
+
116
+ def test_resolve_ip_with_broken_dns
117
+ # Here be dragons: disable the ruby DNS lookup methods we use so
118
+ # that it will actually fail to resolve.
119
+ old_resolv = Resolv
120
+ old_ipsocket = IPSocket
121
+ Object.instance_eval { remove_const :Resolv}
122
+ Object.instance_eval {remove_const:'IPSocket' }
123
+ assert_equal(nil, control.send(:convert_to_ip_address, 'collector.newrelic.com'), "DNS is down, should be no IP for server")
124
+
125
+ Object.instance_eval {const_set('Resolv', old_resolv); const_set('IPSocket', old_ipsocket)}
126
+ # these are here to make sure that the constant tomfoolery above
127
+ # has not broket the system unduly
128
+ assert_equal old_resolv, Resolv
129
+ assert_equal old_ipsocket, IPSocket
130
+ end
131
+
132
+ def test_config_yaml_erb
133
+ assert_equal 'heyheyhey', control['erb_value']
134
+ assert_equal '', control['message']
135
+ assert_equal '', control['license_key']
136
+ end
137
+
138
+ def test_appnames
139
+ assert_equal %w[a b c], NewRelic::Control.instance.app_names
140
+ end
141
+
142
+ def test_config_booleans
143
+ assert_equal control['tval'], true
144
+ assert_equal control['fval'], false
145
+ assert_nil control['not_in_yaml_val']
146
+ assert_equal control['yval'], true
147
+ assert_equal control['sval'], 'sure'
148
+ end
149
+
150
+ def test_config_apdex
151
+ assert_equal 1.1, control.apdex_t
152
+ end
153
+
154
+ # def test_transaction_threshold
155
+ # assert_equal 'Apdex_f', c['transaction_tracer']['transaction_threshold']
156
+ # assert_equal 4.4, NewRelic::Agent::Agent.instance.instance_variable_get('@slowest_transaction_threshold')
157
+ # end
158
+
159
+ def test_log_file_name
160
+ NewRelic::Control.instance.setup_log
161
+ assert_match /newrelic_agent.log$/, control.instance_variable_get('@log_file')
162
+ end
163
+
164
+ # def test_transaction_threshold__apdex
165
+ # forced_start
166
+ # assert_equal 'Apdex_f', c['transaction_tracer']['transaction_threshold']
167
+ # assert_equal 4.4, NewRelic::Agent::Agent.instance.instance_variable_get('@slowest_transaction_threshold')
168
+ # end
169
+
170
+ def test_transaction_threshold__default
171
+ forced_start :transaction_tracer => { :transaction_threshold => nil}
172
+ assert_nil control['transaction_tracer']['transaction_threshold']
173
+ assert_equal 2.0, NewRelic::Agent::Agent.instance.instance_variable_get('@slowest_transaction_threshold')
174
+ end
175
+
176
+ def test_transaction_threshold__override
177
+ forced_start :transaction_tracer => { :transaction_threshold => 1}
178
+ assert_equal 1, control['transaction_tracer']['transaction_threshold']
179
+ assert_equal 1, NewRelic::Agent::Agent.instance.instance_variable_get('@slowest_transaction_threshold')
180
+ end
181
+
182
+ def test_transaction_tracer_disabled
183
+ forced_start(:transaction_tracer => { :enabled => false },
184
+ :developer_mode => false, :monitor_mode => true)
185
+ NewRelic::Agent::Agent.instance.check_transaction_sampler_status
186
+
187
+ assert(!NewRelic::Agent::Agent.instance.transaction_sampler.enabled?,
188
+ 'transaction tracer enabled when config calls for disabled')
189
+
190
+ @control['developer_mode'] = true
191
+ @control['monitor_mode'] = false
192
+ end
193
+
194
+ def test_sql_tracer_disabled
195
+ forced_start(:slow_sql => { :enabled => false }, :monitor_mode => true)
196
+ NewRelic::Agent::Agent.instance.check_sql_sampler_status
197
+
198
+ assert(!NewRelic::Agent::Agent.instance.sql_sampler.enabled?,
199
+ 'sql tracer enabled when config calls for disabled')
200
+
201
+ @control['monitor_mode'] = false
202
+ end
203
+
204
+ def test_sql_tracer_disabled_with_record_sql_false
205
+ forced_start(:slow_sql => { :enabled => true, :record_sql => 'off' })
206
+ NewRelic::Agent::Agent.instance.check_sql_sampler_status
207
+
208
+ assert(!NewRelic::Agent::Agent.instance.sql_sampler.enabled?,
209
+ 'sql tracer enabled when config calls for disabled')
210
+ end
211
+
212
+ def test_sql_tracer_disabled_when_tt_disabled
213
+ forced_start(:transaction_tracer => { :enabled => false },
214
+ :slow_sql => { :enabled => true },
215
+ :developer_mode => false, :monitor_mode => true)
216
+ NewRelic::Agent::Agent.instance.check_sql_sampler_status
217
+
218
+ assert(!NewRelic::Agent::Agent.instance.sql_sampler.enabled?,
219
+ 'sql enabled when transaction tracer disabled')
220
+
221
+ @control['developer_mode'] = true
222
+ @control['monitor_mode'] = false
223
+ end
224
+
225
+ def test_sql_tracer_disabled_when_tt_disabled_by_server
226
+ forced_start(:slow_sql => { :enabled => true },
227
+ :transaction_tracer => { :enabled => true },
228
+ :monitor_mode => true)
229
+ NewRelic::Agent::Agent.instance.check_sql_sampler_status
230
+ NewRelic::Agent::Agent.instance.finish_setup('collect_traces' => false)
231
+
232
+ assert(!NewRelic::Agent::Agent.instance.sql_sampler.enabled?,
233
+ 'sql enabled when tracing disabled by server')
234
+
235
+ @control['monitor_mode'] = false
236
+ end
237
+
238
+ def test_merging_options
239
+ NewRelic::Control.send :public, :merge_options
240
+ @control.merge_options :api_port => 66, :transaction_tracer => { :explain_threshold => 2.0 }
241
+ assert_equal 66, NewRelic::Control.instance['api_port']
242
+ assert_equal 2.0, NewRelic::Control.instance['transaction_tracer']['explain_threshold']
243
+ assert_equal 'raw', NewRelic::Control.instance['transaction_tracer']['record_sql']
244
+ end
245
+
246
+ private
247
+
248
+ def forced_start overrides = {}
249
+ NewRelic::Agent.manual_start overrides
250
+ # This is to force the agent to start again.
251
+ NewRelic::Agent.instance.stubs(:started?).returns(nil)
252
+ NewRelic::Agent.instance.start
253
+ end
254
+ end
@@ -0,0 +1,208 @@
1
+ require File.expand_path(File.join(File.dirname(__FILE__),'..', 'test_helper'))
2
+ require 'new_relic/data_serialization'
3
+ class NewRelic::DataSerializationTest < Test::Unit::TestCase
4
+
5
+ attr_reader :file, :path
6
+
7
+ def setup
8
+ NewRelic::Control.instance['log_file_path'] = './log'
9
+ @path = NewRelic::Control.instance.log_path
10
+ @file = "#{path}/newrelic_agent_store.db"
11
+ Dir.mkdir(path) if !File.directory?(path)
12
+ FileUtils.rm_rf(@file)
13
+ FileUtils.rm_rf("#{@path}/newrelic_agent_store.pid")
14
+ end
15
+
16
+ def teardown
17
+ # this gets set to true in some tests
18
+ NewRelic::Control.instance['disable_serialization'] = false
19
+ mocha_teardown
20
+ end
21
+
22
+ def test_read_and_write_from_file_read_only
23
+ File.open(file, 'w') do |f|
24
+ f.write(Marshal.dump('a happy string'))
25
+ end
26
+ NewRelic::DataSerialization.read_and_write_to_file do |data|
27
+ assert_equal('a happy string', data, "should pull the dumped item from the file")
28
+ nil # must explicitly return nil or the return value will be dumped
29
+ end
30
+ assert_equal(0, File.size(file), "Should not leave any data in the file")
31
+ end
32
+
33
+ def test_bad_paths
34
+ NewRelic::Control.instance.stubs(:log_path).returns("/bad/path")
35
+ assert NewRelic::DataSerialization.should_send_data?
36
+ NewRelic::DataSerialization.read_and_write_to_file do
37
+ 'a happy string'
38
+ end
39
+ assert !File.exists?(file)
40
+ end
41
+
42
+ def test_read_and_write_to_file_dumping_contents
43
+ expected_contents = Marshal.dump('a happy string')
44
+ NewRelic::DataSerialization.read_and_write_to_file do
45
+ 'a happy string'
46
+ end
47
+ assert_equal(expected_contents, File.read(file), "should have dumped the contents")
48
+ end
49
+
50
+ def test_read_and_write_to_file_yields_old_data
51
+ expected_contents = 'a happy string'
52
+ File.open(file, 'w') do |f|
53
+ f.write(Marshal.dump(expected_contents))
54
+ end
55
+ contents = nil
56
+ NewRelic::DataSerialization.read_and_write_to_file do |old_data|
57
+ contents = old_data
58
+ 'a happy string'
59
+ end
60
+ assert_equal(contents, expected_contents, "should have dumped the contents")
61
+ end
62
+
63
+ def test_read_and_write_to_file_round_trip
64
+ old_data = nil
65
+ NewRelic::DataSerialization.read_and_write_to_file do |data|
66
+ old_data = data
67
+ 'a' * 30
68
+ end
69
+ NewRelic::DataSerialization.read_and_write_to_file do |data|
70
+ assert_equal('a'*30, data, "should be the same after serialization")
71
+ end
72
+ end
73
+
74
+ def test_should_send_data_when_over_limit
75
+ NewRelic::DataSerialization.stubs(:max_size).returns(20)
76
+ NewRelic::DataSerialization.read_and_write_to_file do
77
+ "a" * 30
78
+ end
79
+ assert(NewRelic::DataSerialization.should_send_data?, 'Should be over limit')
80
+ end
81
+
82
+ def test_read_until_eoferror
83
+ File.open(file, 'w') do |f|
84
+ f.write("a" * 10_001)
85
+ end
86
+ value = ""
87
+ File.open(file,'r') do |f|
88
+ value << NewRelic::DataSerialization.instance_eval { read_until_eof_error(f) }
89
+ end
90
+ assert_equal('a' * 10_001, value, "should retrieve all the contents from the string and not raise EOFerrors")
91
+ end
92
+
93
+ def test_write_contents_nonblockingly
94
+ File.open(file, 'w') do |f|
95
+ f.write("") # write nothing! NOTHING
96
+ end
97
+
98
+ File.open(file, 'w') do |f|
99
+ NewRelic::DataSerialization.instance_eval { write_contents_nonblockingly(f, 'a' * 10_001) }
100
+ end
101
+ value = File.read(file)
102
+ assert_equal('a' * 10_001, value, "should write a couple thousand 'a's to a file without exploding")
103
+ end
104
+
105
+ def test_should_send_data_disabled
106
+ NewRelic::Control.instance.disable_serialization = true
107
+ assert(NewRelic::DataSerialization.should_send_data?,
108
+ 'should send data when disabled')
109
+ end
110
+
111
+ def test_should_send_data_under_limit
112
+ NewRelic::DataSerialization.expects(:max_size).returns(2000)
113
+ NewRelic::DataSerialization.read_and_write_to_file do |old_data|
114
+ "a" * 5
115
+ end
116
+
117
+ assert(!NewRelic::DataSerialization.store_too_large?,
118
+ 'Should be under the limit')
119
+ end
120
+
121
+ def test_should_handle_empty_spool_file
122
+ NewRelic::Control.instance.log.expects(:error).never
123
+ assert_nil NewRelic::DataSerialization.instance_eval { load('') }
124
+ end
125
+
126
+ def test_spool_file_location_respects_log_file_path_setting
127
+ NewRelic::Control.instance.expects(:log_path).returns('./tmp')
128
+ Dir.mkdir('./tmp') if !File.directory?('./tmp')
129
+ NewRelic::DataSerialization.read_and_write_to_file do |_|
130
+ 'a' * 30
131
+ end
132
+ assert(File.exists?('./tmp/newrelic_agent_store.db'),
133
+ "Spool file not created at user specified location")
134
+ end
135
+
136
+ def test_age_file_location_respects_log_file_path_setting
137
+ NewRelic::Control.instance.expects(:log_path).returns('./tmp')
138
+ Dir.mkdir('./tmp') if !File.directory?('./tmp')
139
+ NewRelic::DataSerialization.update_last_sent!
140
+ assert(File.exists?('./tmp/newrelic_agent_store.pid'),
141
+ "Age file not created at user specified location")
142
+ end
143
+
144
+ def test_pid_age_creates_pid_file_if_none_exists
145
+ assert(!File.exists?("#{@path}/newrelic_agent_store.pid"),
146
+ 'pid file found, should not be there')
147
+ assert(!NewRelic::DataSerialization.pid_too_old?,
148
+ "new pid should not be too old")
149
+ assert(File.exists?("#{@path}/newrelic_agent_store.pid"),
150
+ 'pid file not found, should be there')
151
+ end
152
+
153
+ def test_loading_does_not_seg_fault_if_gc_triggers
154
+ require 'timeout'
155
+
156
+ Thread.abort_on_exception = true
157
+ rcv,snd = IO.pipe
158
+
159
+ write = Thread.new do
160
+ obj = ('a'..'z').inject({}){|h,s|h[s.intern]=s*1024;h}
161
+ data = Marshal.dump(obj)
162
+ snd.write(data[0,data.size/2])
163
+ sleep(0.1)
164
+ snd.write(data[(data.size/2)..-1])
165
+ snd.close
166
+ end
167
+
168
+ read = Thread.new do
169
+ lock = Mutex.new
170
+ lock.synchronize do
171
+ NewRelic::DataSerialization.class_eval { load(rcv) }
172
+ end
173
+ end
174
+
175
+ gc = Thread.new do
176
+ 10.times do
177
+ GC.start
178
+ end
179
+ end
180
+
181
+ Timeout::timeout(5) do
182
+ write.join
183
+ read.join
184
+ gc.join
185
+ end
186
+ # should not seg fault
187
+ end
188
+
189
+ def test_dump_should_be_thread_safe
190
+ stats_hash = {}
191
+
192
+ 2000.times do |i|
193
+ stats_hash[i.to_s] = NewRelic::StatsBase.new
194
+ end
195
+
196
+ harvest = Thread.new do
197
+ NewRelic::DataSerialization.class_eval { dump(stats_hash) }
198
+ end
199
+
200
+ app = Thread.new do
201
+ stats_hash["a"] = NewRelic::StatsBase.new
202
+ end
203
+
204
+ assert_nothing_raised do
205
+ [app, harvest].each{|t| t.join}
206
+ end
207
+ end
208
+ end
@@ -0,0 +1,16 @@
1
+ require File.expand_path(File.join(File.dirname(__FILE__),'..','test_helper'))
2
+
3
+ class NewRelic::DelayedJobInstrumentationTest < Test::Unit::TestCase
4
+ def test_skip_logging_if_no_logger_found
5
+ Object.const_set('Delayed', Module.new) unless defined?(Delayed)
6
+ ::Delayed.const_set('Worker', Class.new) unless defined?(::Delayed::Worker)
7
+
8
+ NewRelic::Agent.stubs(:logger).raises(NoMethodError,
9
+ 'tempoarily not allowed')
10
+ NewRelic::Agent.stubs(:respond_to?).with(:logger).returns(false)
11
+
12
+ assert DependencyDetection.detect!
13
+
14
+ Object.class_eval { remove_const('Delayed') }
15
+ end
16
+ end