newrelic_rpm 3.10.0.279 → 3.11.0.283

Sign up to get free protection for your applications and to get access to all the features.
Files changed (180) hide show
  1. checksums.yaml +7 -0
  2. data/CHANGELOG +61 -0
  3. data/lib/new_relic/agent.rb +14 -8
  4. data/lib/new_relic/agent/agent.rb +43 -28
  5. data/lib/new_relic/agent/agent_logger.rb +21 -20
  6. data/lib/new_relic/agent/configuration/default_source.rb +31 -1
  7. data/lib/new_relic/agent/database.rb +2 -1
  8. data/lib/new_relic/agent/datastores.rb +177 -0
  9. data/lib/new_relic/agent/datastores/metric_helper.rb +85 -0
  10. data/lib/new_relic/agent/datastores/mongo/metric_translator.rb +11 -20
  11. data/lib/new_relic/agent/deprecator.rb +18 -0
  12. data/lib/new_relic/agent/instrumentation/active_record.rb +20 -35
  13. data/lib/new_relic/agent/instrumentation/active_record_helper.rb +116 -57
  14. data/lib/new_relic/agent/instrumentation/active_record_subscriber.rb +11 -20
  15. data/lib/new_relic/agent/instrumentation/data_mapper.rb +104 -172
  16. data/lib/new_relic/agent/instrumentation/memcache.rb +104 -52
  17. data/lib/new_relic/agent/instrumentation/metric_frame.rb +9 -0
  18. data/lib/new_relic/agent/instrumentation/middleware_proxy.rb +15 -2
  19. data/lib/new_relic/agent/instrumentation/mongo.rb +5 -18
  20. data/lib/new_relic/agent/instrumentation/sequel_helper.rb +36 -0
  21. data/lib/new_relic/agent/new_relic_service.rb +4 -0
  22. data/lib/new_relic/agent/stats_engine/metric_stats.rb +2 -17
  23. data/lib/new_relic/agent/threading/backtrace_service.rb +28 -5
  24. data/lib/new_relic/agent/transaction.rb +63 -34
  25. data/lib/new_relic/agent/transaction_event_aggregator.rb +0 -4
  26. data/lib/new_relic/agent/transaction_sampler.rb +11 -5
  27. data/lib/new_relic/rack/error_collector.rb +0 -1
  28. data/lib/new_relic/version.rb +1 -1
  29. data/lib/sequel/extensions/newrelic_instrumentation.rb +28 -56
  30. data/lib/sequel/plugins/newrelic_instrumentation.rb +28 -45
  31. data/newrelic_rpm.gemspec +0 -7
  32. data/test/agent_helper.rb +35 -16
  33. data/test/environments/rails31/Gemfile +1 -0
  34. data/test/environments/rails32/Gemfile +1 -0
  35. data/test/helpers/mongo_metric_builder.rb +2 -3
  36. data/test/multiverse/lib/multiverse/output_collector.rb +24 -9
  37. data/test/multiverse/lib/multiverse/suite.rb +5 -0
  38. data/test/multiverse/suites/active_record/Envfile +6 -4
  39. data/test/multiverse/suites/active_record/active_record_test.rb +32 -73
  40. data/test/multiverse/suites/active_record/ar_method_aliasing.rb +0 -1
  41. data/test/multiverse/suites/activemerchant/activemerchant_test.rb +0 -3
  42. data/test/multiverse/suites/agent_only/agent_run_id_handling_test.rb +0 -1
  43. data/test/multiverse/suites/agent_only/audit_log_test.rb +0 -1
  44. data/test/multiverse/suites/agent_only/collector_exception_handling_test.rb +0 -2
  45. data/test/multiverse/suites/agent_only/cross_application_tracing_test.rb +0 -1
  46. data/test/multiverse/suites/agent_only/custom_analytics_events_test.rb +0 -2
  47. data/test/multiverse/suites/agent_only/custom_queue_time_test.rb +0 -1
  48. data/test/multiverse/suites/agent_only/encoding_handling_test.rb +0 -2
  49. data/test/multiverse/suites/agent_only/exclusive_time_test.rb +0 -2
  50. data/test/multiverse/suites/agent_only/harvest_timestamps_test.rb +0 -1
  51. data/test/multiverse/suites/agent_only/http_response_code_test.rb +0 -1
  52. data/test/multiverse/suites/agent_only/keepalive_test.rb +0 -1
  53. data/test/multiverse/suites/agent_only/key_transactions_test.rb +54 -9
  54. data/test/multiverse/suites/agent_only/labels_test.rb +0 -2
  55. data/test/multiverse/suites/agent_only/logging_test.rb +0 -1
  56. data/test/multiverse/suites/agent_only/marshaling_test.rb +0 -1
  57. data/test/multiverse/suites/agent_only/pipe_manager_test.rb +0 -2
  58. data/test/multiverse/suites/agent_only/rename_rule_test.rb +5 -7
  59. data/test/multiverse/suites/agent_only/rum_instrumentation_test.rb +0 -1
  60. data/test/multiverse/suites/agent_only/set_transaction_name_test.rb +0 -2
  61. data/test/multiverse/suites/agent_only/ssl_test.rb +0 -2
  62. data/test/multiverse/suites/agent_only/synthetics_test.rb +0 -1
  63. data/test/multiverse/suites/agent_only/testing_app.rb +21 -0
  64. data/test/multiverse/suites/agent_only/thread_profiling_test.rb +1 -2
  65. data/test/multiverse/suites/agent_only/transaction_ignoring_test.rb +0 -2
  66. data/test/multiverse/suites/agent_only/utilization_data_collection_test.rb +0 -1
  67. data/test/multiverse/suites/agent_only/xray_sessions_test.rb +69 -34
  68. data/test/multiverse/suites/capistrano/deployment_test.rb +0 -1
  69. data/test/multiverse/suites/capistrano2/deployment_test.rb +0 -1
  70. data/test/multiverse/suites/config_file_loading/config_file_loading_test.rb +0 -2
  71. data/test/multiverse/suites/curb/curb_test.rb +0 -2
  72. data/test/multiverse/suites/datamapper/Envfile +26 -3
  73. data/test/multiverse/suites/datamapper/config/newrelic.yml +1 -0
  74. data/test/multiverse/suites/datamapper/datamapper_test.rb +271 -37
  75. data/test/multiverse/suites/deferred_instrumentation/sinatra_test.rb +0 -1
  76. data/test/multiverse/suites/delayed_job/Envfile +31 -8
  77. data/test/multiverse/suites/delayed_job/delayed_job_sampler_test.rb +0 -3
  78. data/test/multiverse/suites/delayed_job/unsupported_backend_test.rb +0 -3
  79. data/test/multiverse/suites/excon/excon_test.rb +0 -2
  80. data/test/multiverse/suites/grape/grape_test.rb +0 -3
  81. data/test/multiverse/suites/grape/grape_versioning_test.rb +0 -3
  82. data/test/multiverse/suites/grape/unsupported_version_test.rb +0 -3
  83. data/test/multiverse/suites/high_security/high_security_test.rb +0 -1
  84. data/test/multiverse/suites/httpclient/httpclient_test.rb +0 -2
  85. data/test/multiverse/suites/json/json_test.rb +0 -1
  86. data/test/multiverse/suites/marshalling/marshalling_test.rb +0 -1
  87. data/test/multiverse/suites/memcached/Envfile +52 -0
  88. data/test/multiverse/suites/memcached/dalli_test.rb +89 -0
  89. data/test/multiverse/suites/memcached/memcache_client_test.rb +25 -0
  90. data/test/multiverse/suites/memcached/memcache_test_cases.rb +302 -0
  91. data/test/multiverse/suites/memcached/memcached_test.rb +159 -0
  92. data/test/multiverse/suites/mongo/helpers/mongo_operation_tests.rb +26 -17
  93. data/test/multiverse/suites/mongo/mongo_connection_test.rb +0 -1
  94. data/test/multiverse/suites/mongo/mongo_instrumentation_test.rb +0 -1
  95. data/test/multiverse/suites/mongo/mongo_unsupported_version_test.rb +0 -1
  96. data/test/multiverse/suites/net_http/net_http_test.rb +0 -2
  97. data/test/multiverse/suites/padrino/padrino_test.rb +0 -3
  98. data/test/multiverse/suites/rack/http_response_code_test.rb +0 -1
  99. data/test/multiverse/suites/rack/nested_non_rack_app_test.rb +1 -1
  100. data/test/multiverse/suites/rack/rack_auto_instrumentation_test.rb +12 -12
  101. data/test/multiverse/suites/rack/rack_cascade_test.rb +0 -1
  102. data/test/multiverse/suites/rack/rack_env_mutation_test.rb +0 -1
  103. data/test/multiverse/suites/rack/rack_parameter_filtering_test.rb +0 -1
  104. data/test/multiverse/suites/rack/rack_unsupported_version_test.rb +0 -2
  105. data/test/multiverse/suites/rack/url_map_test.rb +3 -2
  106. data/test/multiverse/suites/rails/Envfile +3 -0
  107. data/test/multiverse/suites/rails/activejob_test.rb +0 -1
  108. data/test/multiverse/suites/rails/app.rb +0 -1
  109. data/test/multiverse/suites/rails/parameter_capture_test.rb +13 -0
  110. data/test/multiverse/suites/rails/rails3_app/app_rails3_plus.rb +5 -0
  111. data/test/multiverse/suites/rails/transaction_ignoring_test.rb +0 -2
  112. data/test/multiverse/suites/resque/instrumentation_test.rb +0 -2
  113. data/test/multiverse/suites/resque/resque_marshalling_test.rb +0 -1
  114. data/test/multiverse/suites/sequel/sequel_extension_test.rb +135 -0
  115. data/test/multiverse/suites/sequel/sequel_helpers.rb +62 -0
  116. data/test/multiverse/suites/sequel/sequel_plugin_test.rb +230 -0
  117. data/test/multiverse/suites/sidekiq/sidekiq_instrumentation_test.rb +0 -2
  118. data/test/multiverse/suites/sinatra/ignoring_test.rb +0 -2
  119. data/test/multiverse/suites/sinatra/nested_middleware_test.rb +0 -2
  120. data/test/multiverse/suites/sinatra/sinatra_classic_test.rb +0 -1
  121. data/test/multiverse/suites/sinatra/sinatra_error_tracing_test.rb +0 -2
  122. data/test/multiverse/suites/sinatra/sinatra_metric_explosion_test.rb +14 -12
  123. data/test/multiverse/suites/sinatra/sinatra_modular_test.rb +0 -1
  124. data/test/multiverse/suites/sinatra/sinatra_routes_test.rb +0 -2
  125. data/test/multiverse/suites/sinatra/sinatra_test_cases.rb +0 -2
  126. data/test/multiverse/suites/typhoeus/typhoeus_test.rb +0 -2
  127. data/test/multiverse/suites/yajl/yajl_test.rb +0 -1
  128. data/test/new_relic/agent/agent/start_test.rb +2 -2
  129. data/test/new_relic/agent/agent_logger_test.rb +6 -3
  130. data/test/new_relic/agent/datastores/metric_helper_test.rb +61 -0
  131. data/test/new_relic/agent/datastores/mongo/metric_translator_test.rb +20 -21
  132. data/test/new_relic/agent/datastores_test.rb +195 -0
  133. data/test/new_relic/agent/deprecator_test.rb +52 -0
  134. data/test/new_relic/agent/instrumentation/action_view_subscriber_test.rb +20 -26
  135. data/test/new_relic/agent/instrumentation/active_record_helper_test.rb +58 -53
  136. data/test/new_relic/agent/instrumentation/active_record_subscriber_test.rb +7 -20
  137. data/test/new_relic/agent/instrumentation/middleware_proxy_test.rb +19 -0
  138. data/test/new_relic/agent/instrumentation/sequel_helper_test.rb +36 -0
  139. data/test/new_relic/agent/instrumentation/task_instrumentation_test.rb +1 -0
  140. data/test/new_relic/agent/method_tracer_test.rb +3 -4
  141. data/test/new_relic/agent/pipe_channel_manager_test.rb +1 -1
  142. data/test/new_relic/agent/threading/backtrace_service_test.rb +29 -4
  143. data/test/new_relic/agent/transaction_event_aggregator_test.rb +0 -4
  144. data/test/new_relic/agent/transaction_test.rb +100 -2
  145. data/test/new_relic/agent_test.rb +3 -3
  146. data/test/new_relic/http_client_test_cases.rb +0 -1
  147. data/test/new_relic/multiverse_helpers.rb +7 -0
  148. data/test/new_relic/transaction_ignoring_test_cases.rb +0 -2
  149. data/test/new_relic/transaction_sample_test.rb +11 -2
  150. data/test/performance/README.md +37 -17
  151. data/test/performance/lib/performance.rb +1 -0
  152. data/test/performance/lib/performance/baseline_compare_reporter.rb +11 -7
  153. data/test/performance/lib/performance/console_reporter.rb +29 -5
  154. data/test/performance/lib/performance/formatting_helpers.rb +22 -0
  155. data/test/performance/lib/performance/instrumentation/stackprof.rb +11 -1
  156. data/test/performance/lib/performance/result.rb +17 -6
  157. data/test/performance/lib/performance/runner.rb +7 -3
  158. data/test/performance/lib/performance/test_case.rb +89 -21
  159. data/test/performance/script/runner +13 -1
  160. data/test/performance/suites/active_record.rb +47 -0
  161. data/test/performance/suites/config.rb +4 -48
  162. data/test/performance/suites/marshalling.rb +20 -30
  163. data/test/performance/suites/queue_time.rb +1 -1
  164. data/test/performance/suites/rack_middleware.rb +1 -1
  165. data/test/performance/suites/rum_autoinsertion.rb +1 -1
  166. data/test/performance/suites/sql_obfuscation.rb +2 -2
  167. data/test/performance/suites/startup.rb +1 -1
  168. data/test/performance/suites/stats_hash.rb +7 -11
  169. data/test/performance/suites/thread_profiling.rb +20 -25
  170. data/test/performance/suites/trace_execution_scoped.rb +2 -2
  171. data/test/performance/suites/transaction_tracing.rb +4 -2
  172. data/test/test_helper.rb +5 -1
  173. metadata +53 -100
  174. data.tar.gz.sig +0 -0
  175. data/gem-public_cert.pem +0 -20
  176. data/lib/new_relic/agent/datastores/mongo/metric_generator.rb +0 -33
  177. data/test/multiverse/suites/sequel/sequel_instrumentation_test.rb +0 -289
  178. data/test/new_relic/agent/datastores/mongo/metric_generator_test.rb +0 -69
  179. data/test/new_relic/agent/memcache_instrumentation_test.rb +0 -155
  180. metadata.gz.sig +0 -2
@@ -3,7 +3,6 @@
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__), '..', 'sinatra', 'sinatra_test_cases'))
6
- require File.expand_path(File.join(File.dirname(__FILE__), '..', '..', '..', 'agent_helper'))
7
6
  require File.expand_path(File.join(File.dirname(__FILE__), '..', '..', '..', 'helpers', 'exceptions'))
8
7
 
9
8
  require 'newrelic_rpm'
@@ -1,6 +1,5 @@
1
- suite_condition("Rails 2.2.0-preview1 and Rubinius problems prevent these from running") do
2
- # https://github.com/rails/rails/issues/17017
3
- RUBY_VERSION != '2.2.0' && (!defined?(RUBY_ENGINE) || RUBY_ENGINE != "rbx")
1
+ suite_condition("Rubinius problems prevent these from running") do
2
+ (!defined?(RUBY_ENGINE) || RUBY_ENGINE != "rbx")
4
3
  end
5
4
 
6
5
  boilerplate_gems = <<-SQLITE
@@ -18,16 +17,27 @@ if RUBY_VERSION >= '1.9.3'
18
17
  gemfile <<-RB
19
18
  gem 'delayed_job', '~> 4.0.4'
20
19
  gem 'delayed_job_mongoid', '~> 2.1.0'
20
+ gem 'i18n', '~> 0.6.11'
21
21
  #{boilerplate_gems}
22
22
  RB
23
23
  end
24
24
 
25
25
  # delayed_job_active_record (and older baked into delayed_job) support
26
- dj4_with_active_record = <<-DJ
27
- gem 'delayed_job', '~> 4.0.4'
28
- gem 'delayed_job_active_record', '~> 4.0.2'
29
- #{boilerplate_gems}
30
- DJ
26
+ if RUBY_VERSION >= '1.9.3'
27
+ dj4_with_active_record = <<-DJ
28
+ gem 'delayed_job', '~> 4.0.4'
29
+ gem 'delayed_job_active_record', '~> 4.0.2'
30
+ #{boilerplate_gems}
31
+ DJ
32
+ else
33
+ dj4_with_active_record = <<-DJ
34
+ gem 'delayed_job', '~> 4.0.4'
35
+
36
+ # 4.0.3 breaks 1.8.7 compatibility
37
+ gem 'delayed_job_active_record', '= 4.0.2'
38
+ #{boilerplate_gems}
39
+ DJ
40
+ end
31
41
 
32
42
  dj3_with_active_record = <<-DJ
33
43
  gem 'delayed_job', '~> 3.0.5'
@@ -41,14 +51,23 @@ dj2_with_active_record3 = <<-DJ
41
51
  DJ
42
52
 
43
53
  if RUBY_VERSION >= '1.9.3'
54
+ gemfile <<-RB
55
+ gem 'activerecord', '~> 4.2.0'
56
+ gem 'i18n', '~> 0.7.0'
57
+ #{dj4_with_active_record}
58
+ gem 'minitest', '~> 5.2.3'
59
+ RB
60
+
44
61
  gemfile <<-RB
45
62
  gem 'activerecord', '~> 4.1.6'
63
+ gem 'i18n', '~> 0.6.11'
46
64
  #{dj4_with_active_record}
47
65
  gem 'minitest', '~> 5.2.3'
48
66
  RB
49
67
 
50
68
  gemfile <<-RB
51
69
  gem 'activerecord', '~>4.0.10'
70
+ gem 'i18n', '~> 0.6.11'
52
71
  #{dj4_with_active_record}
53
72
  RB
54
73
  end
@@ -56,16 +75,19 @@ end
56
75
  [dj4_with_active_record, dj3_with_active_record, dj2_with_active_record3].each do |dj|
57
76
  gemfile <<-RB
58
77
  gem 'activerecord', '~> 3.2.19'
78
+ gem 'i18n', '~> 0.6.11'
59
79
  #{dj}
60
80
  RB
61
81
 
62
82
  gemfile <<-RB
63
83
  gem 'activerecord', '~> 3.1.12'
84
+ gem 'i18n', '~> 0.6.11'
64
85
  #{dj}
65
86
  RB
66
87
 
67
88
  gemfile <<-RB
68
89
  gem 'activerecord', '~> 3.0.20'
90
+ gem 'i18n', '~> 0.5.4'
69
91
  #{dj}
70
92
  RB
71
93
  end
@@ -74,6 +96,7 @@ if RUBY_VERSION <= '1.9.3'
74
96
  gemfile <<-RB
75
97
  gem 'activerecord', '~> 2.3.18'
76
98
  gem 'delayed_job', '~> 2.0.8'
99
+ gem 'i18n', '~> 0.5.4'
77
100
  #{boilerplate_gems}
78
101
  RB
79
102
  end
@@ -2,9 +2,6 @@
2
2
  # This file is distributed under New Relic's license terms.
3
3
  # See https://github.com/newrelic/rpm/blob/master/LICENSE for complete details.
4
4
 
5
- require 'multiverse_helpers'
6
- require 'minitest/unit'
7
-
8
5
  require 'new_relic/delayed_job_injection'
9
6
 
10
7
  if NewRelic::Agent::Samplers::DelayedJobSampler.supported_backend?
@@ -2,9 +2,6 @@
2
2
  # This file is distributed under New Relic's license terms.
3
3
  # See https://github.com/newrelic/rpm/blob/master/LICENSE for complete details.
4
4
 
5
- require 'multiverse_helpers'
6
- require 'minitest/unit'
7
-
8
5
  require 'new_relic/delayed_job_injection'
9
6
 
10
7
  if !NewRelic::Agent::Samplers::DelayedJobSampler.supported_backend?
@@ -6,8 +6,6 @@ require "excon"
6
6
  require "newrelic_rpm"
7
7
  require "http_client_test_cases"
8
8
 
9
- require File.join(File.dirname(__FILE__), "..", "..", "..", "agent_helper")
10
-
11
9
  class ExconTest < Minitest::Test
12
10
  include HttpClientTestCases
13
11
 
@@ -4,11 +4,8 @@
4
4
 
5
5
  require "grape"
6
6
  require "newrelic_rpm"
7
- require 'multiverse_helpers'
8
7
  require './grape_test_api'
9
8
 
10
- require File.join(File.dirname(__FILE__), "..", "..", "..", "agent_helper")
11
-
12
9
  class GrapeTest < Minitest::Test
13
10
  include Rack::Test::Methods
14
11
  include MultiverseHelpers
@@ -3,11 +3,8 @@
3
3
  # See https://github.com/newrelic/rpm/blob/master/LICENSE for complete details.
4
4
 
5
5
  unless ::Grape::VERSION == '0.1.5'
6
- require 'multiverse_helpers'
7
6
  require './grape_versioning_test_api'
8
7
 
9
- require File.join(File.dirname(__FILE__), "..", "..", "..", "agent_helper")
10
-
11
8
  class GrapeVersioningTest < Minitest::Test
12
9
  include Rack::Test::Methods
13
10
  include MultiverseHelpers
@@ -4,11 +4,8 @@
4
4
 
5
5
  require "grape"
6
6
  require "newrelic_rpm"
7
- require 'multiverse_helpers'
8
7
  require './grape_test_api'
9
8
 
10
- require File.join(File.dirname(__FILE__), "..", "..", "..", "agent_helper")
11
-
12
9
  class UnsupportedGrapeTest < Minitest::Test
13
10
  include Rack::Test::Methods
14
11
  include MultiverseHelpers
@@ -2,7 +2,6 @@
2
2
  # This file is distributed under New Relic's license terms.
3
3
  # See https://github.com/newrelic/rpm/blob/master/LICENSE for complete details.
4
4
 
5
- require 'multiverse_helpers'
6
5
  require 'fake_server'
7
6
 
8
7
  # These tests are designed to work in conjunction with a local newrelic.yml
@@ -6,8 +6,6 @@ require "httpclient"
6
6
  require "newrelic_rpm"
7
7
  require "http_client_test_cases"
8
8
 
9
- require File.join(File.dirname(__FILE__), "..", "..", "..", "agent_helper")
10
-
11
9
  class HTTPClientTest < Minitest::Test
12
10
  include HttpClientTestCases
13
11
 
@@ -2,7 +2,6 @@
2
2
  # This file is distributed under New Relic's license terms.
3
3
  # See https://github.com/newrelic/rpm/blob/master/LICENSE for complete details.
4
4
 
5
- require 'multiverse_helpers'
6
5
  require File.join(File.dirname(__FILE__), '..', '..', '..', 'new_relic', 'marshalling_test_cases')
7
6
 
8
7
  # This is intended as a sanity check for our serialization to JSON via the
@@ -2,7 +2,6 @@
2
2
  # This file is distributed under New Relic's license terms.
3
3
  # See https://github.com/newrelic/rpm/blob/master/LICENSE for complete details.
4
4
 
5
- require 'multiverse_helpers'
6
5
  require File.join(File.dirname(__FILE__), '..', '..', '..', 'new_relic', 'marshalling_test_cases')
7
6
 
8
7
  # These tests are intended to exercise the basic marshalling functionality of
@@ -0,0 +1,52 @@
1
+ dalli_versions = %w(1.0.5)
2
+ dalli_versions += %w(2.7.2 2.6.4 2.2.1) if RUBY_VERSION >= "1.9.3"
3
+
4
+ dalli_versions.each do |version|
5
+ gemfile <<-RB
6
+ gem 'dalli', '~> #{version}'
7
+ RB
8
+ end
9
+
10
+ memcache_client_versions = %w(1.8.5 1.5.0)
11
+
12
+ memcache_client_versions.each do |version|
13
+ gemfile <<-RB
14
+ gem 'memcache-client', '~> #{version}', :require => 'memcache'
15
+ # version lockdown for ZenTest that cooperates with all Rubies
16
+ # and the build VMs
17
+ gem 'ZenTest', '3.4.2'
18
+ RB
19
+ end
20
+
21
+
22
+ if RUBY_VERSION == "1.8.7"
23
+ memcached_client_versions = ['1.4.1']
24
+ elsif RUBY_VERSION > "1.9.3"
25
+ memcached_client_versions = ['1.8.0']
26
+ else
27
+ memcached_client_versions = %w(1.8.0 1.4.1)
28
+ end
29
+
30
+ if RUBY_PLATFORM == 'java'
31
+ memcached_client_versions = []
32
+ end
33
+
34
+ memcached_client_versions.each do |version|
35
+ gemfile <<-RB
36
+ gem 'memcached', '~> #{version}'
37
+ RB
38
+ end
39
+
40
+ def memcache_running?
41
+ begin
42
+ require 'socket'
43
+ TCPSocket.new('localhost', 11211)
44
+ true
45
+ rescue => e
46
+ false
47
+ end
48
+ end
49
+
50
+ before_suite do
51
+ system('memcached -d -l localhost') unless memcache_running?
52
+ end
@@ -0,0 +1,89 @@
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 "./memcache_test_cases"
6
+
7
+ if defined?(Dalli)
8
+ class DalliTest < Minitest::Test
9
+ include MemcacheTestCases
10
+
11
+ def setup
12
+ @cache = Dalli::Client.new("127.0.0.1:11211", :socket_timeout => 2.0)
13
+ end
14
+ end
15
+
16
+ if Dalli::VERSION >= '2.7'
17
+ require 'dalli/cas/client'
18
+ DependencyDetection.detect!
19
+
20
+ class DalliCasClientTest < DalliTest
21
+
22
+ def after_setup
23
+ super
24
+ @cas_key = set_key_for_testcase(1)
25
+ end
26
+
27
+ def test_get_cas
28
+ expected_metrics = expected_web_metrics(:get_cas)
29
+
30
+ value = nil
31
+ in_web_transaction("Controller/#{self.class}/action") do
32
+ value, _ = @cache.get_cas(@cas_key)
33
+ end
34
+
35
+ assert_memcache_metrics_recorded expected_metrics
36
+ assert_equal value, @cache.get(@cas_key)
37
+ end
38
+
39
+ def test_get_multi_cas
40
+ expected_metrics = expected_web_metrics(:get_multi_cas)
41
+
42
+ value = nil
43
+ in_web_transaction("Controller/#{self.class}/action") do
44
+ # returns { "cas_key" => [value, cas] }
45
+ value, _ = @cache.get_multi_cas(@cas_key)
46
+ end
47
+
48
+ assert_memcache_metrics_recorded expected_metrics
49
+ assert_equal 1, value.values.length
50
+ assert_equal value.values.first.first, @cache.get(@cas_key)
51
+ end
52
+
53
+
54
+ def test_set_cas
55
+ expected_metrics = expected_web_metrics(:set_cas)
56
+
57
+ in_web_transaction("Controller/#{self.class}/action") do
58
+ @cache.set_cas(@cas_key, 2, 0)
59
+ end
60
+
61
+ assert_memcache_metrics_recorded expected_metrics
62
+ assert_equal 2, @cache.get(@cas_key)
63
+ end
64
+
65
+ def test_replace_cas
66
+ expected_metrics = expected_web_metrics(:replace_cas)
67
+
68
+ in_web_transaction("Controller/#{self.class}/action") do
69
+ @cache.replace_cas(@cas_key, 2, 0)
70
+ end
71
+
72
+ assert_memcache_metrics_recorded expected_metrics
73
+ assert_equal 2, @cache.get(@cas_key)
74
+ end
75
+
76
+ def test_delete_cas
77
+ expected_metrics = expected_web_metrics(:delete_cas)
78
+
79
+ in_web_transaction("Controller/#{self.class}/action") do
80
+ @cache.delete_cas(@cas_key)
81
+ end
82
+
83
+ assert_memcache_metrics_recorded expected_metrics
84
+ assert_equal nil, @cache.get(@cas_key)
85
+ end
86
+
87
+ end
88
+ end
89
+ end
@@ -0,0 +1,25 @@
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 "./memcache_test_cases"
6
+
7
+ if defined?(MemCache)
8
+ class MemcacheTest < Minitest::Test
9
+ include MemcacheTestCases
10
+
11
+ def setup
12
+ @cache = MemCache.new("localhost:11211")
13
+ end
14
+
15
+ if MemCache::VERSION <= "1.5.0"
16
+ undef_method :test_append_in_web, :test_prepend_in_web, :test_replace_in_web,
17
+ :test_append_in_background, :test_prepend_in_background,
18
+ :test_replace_in_background
19
+ end
20
+
21
+ if MemCache::VERSION <= "1.7.0"
22
+ undef_method :test_cas_in_web, :test_cas_in_background
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,302 @@
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
+ module MemcacheTestCases
6
+ def after_setup
7
+ @keys = []
8
+ end
9
+
10
+ def teardown
11
+ @keys.each { |key| @cache.delete(key) rescue nil }
12
+ NewRelic::Agent.drop_buffered_data
13
+ end
14
+
15
+ def randomized_key
16
+ "test_#{rand(1e18)}".tap do |key|
17
+ @keys << key
18
+ end
19
+ end
20
+
21
+ def set_key_for_testcase(value = "value")
22
+ randomized_key.tap do |key|
23
+ @cache.set(key, value)
24
+ NewRelic::Agent.drop_buffered_data
25
+ end
26
+ end
27
+
28
+ def expected_web_metrics(command)
29
+ [
30
+ "Datastore/all",
31
+ "Datastore/Memcached/all",
32
+ "Datastore/operation/Memcached/#{command}",
33
+ "Datastore/allWeb",
34
+ "Datastore/Memcached/allWeb",
35
+ ["Datastore/operation/Memcached/#{command}", "Controller/#{self.class}/action"]
36
+ ]
37
+ end
38
+
39
+ def expected_bg_metrics(command)
40
+ [
41
+ "Datastore/all",
42
+ "Datastore/Memcached/all",
43
+ "Datastore/operation/Memcached/#{command}",
44
+ "Datastore/allOther",
45
+ "Datastore/Memcached/allOther",
46
+ ["Datastore/operation/Memcached/#{command}", "OtherTransaction/Background/#{self.class}/bg_task"]
47
+ ]
48
+ end
49
+
50
+ def assert_memcache_metrics_recorded(expected_metrics)
51
+ assert_metrics_recorded_exclusive expected_metrics, :filter => /^memcache.*/i
52
+ end
53
+
54
+ def test_get_in_web
55
+ key = set_key_for_testcase
56
+
57
+ expected_metrics = expected_web_metrics(:get)
58
+
59
+ in_web_transaction("Controller/#{self.class}/action") do
60
+ @cache.get(key)
61
+ end
62
+
63
+ assert_memcache_metrics_recorded expected_metrics
64
+ end
65
+
66
+ def test_get_multi_in_web
67
+ key = set_key_for_testcase
68
+
69
+ expected_metrics = expected_web_metrics(:get_multi)
70
+
71
+ in_web_transaction("Controller/#{self.class}/action") do
72
+ @cache.get_multi(key)
73
+ end
74
+
75
+ assert_memcache_metrics_recorded expected_metrics
76
+ end
77
+
78
+ def test_set_in_web
79
+ expected_metrics = expected_web_metrics(:set)
80
+
81
+ in_web_transaction("Controller/#{self.class}/action") do
82
+ @cache.set(randomized_key, "value")
83
+ end
84
+
85
+ assert_memcache_metrics_recorded expected_metrics
86
+ end
87
+
88
+ def test_add_in_web
89
+ expected_metrics = expected_web_metrics(:add)
90
+
91
+ in_web_transaction("Controller/#{self.class}/action") do
92
+ @cache.add(randomized_key, "value")
93
+ end
94
+
95
+ assert_memcache_metrics_recorded expected_metrics
96
+ end
97
+
98
+ def test_delete_in_web
99
+ key = set_key_for_testcase
100
+
101
+ expected_metrics = expected_web_metrics(:delete)
102
+
103
+ in_web_transaction("Controller/#{self.class}/action") do
104
+ @cache.delete(key)
105
+ end
106
+
107
+ assert_memcache_metrics_recorded expected_metrics
108
+ end
109
+
110
+ def test_incr_in_web
111
+ expected_metrics = expected_web_metrics(:incr)
112
+
113
+ in_web_transaction("Controller/#{self.class}/action") do
114
+ @cache.incr("incr_test", 0)
115
+ end
116
+
117
+ assert_memcache_metrics_recorded expected_metrics
118
+ end
119
+
120
+ def test_decr_in_web
121
+ expected_metrics = expected_web_metrics(:decr)
122
+
123
+ in_web_transaction("Controller/#{self.class}/action") do
124
+ @cache.decr("decr_test", 1)
125
+ end
126
+
127
+ assert_memcache_metrics_recorded expected_metrics
128
+ end
129
+
130
+ def test_replace_in_web
131
+ key = set_key_for_testcase
132
+
133
+ expected_metrics = expected_web_metrics(:replace)
134
+
135
+ in_web_transaction("Controller/#{self.class}/action") do
136
+ @cache.replace(key, 1337807)
137
+ end
138
+
139
+ assert_memcache_metrics_recorded expected_metrics
140
+ end
141
+
142
+ def test_append_in_web
143
+ key = set_key_for_testcase
144
+
145
+ expected_metrics = expected_web_metrics(:append)
146
+
147
+ in_web_transaction("Controller/#{self.class}/action") do
148
+ @cache.append(key, 1337807)
149
+ end
150
+
151
+ assert_memcache_metrics_recorded expected_metrics
152
+ end
153
+
154
+ def test_prepend_in_web
155
+ key = set_key_for_testcase
156
+
157
+ expected_metrics = expected_web_metrics(:prepend)
158
+
159
+ in_web_transaction("Controller/#{self.class}/action") do
160
+ @cache.prepend(key, 1337807)
161
+ end
162
+
163
+ assert_memcache_metrics_recorded expected_metrics
164
+ end
165
+
166
+ def test_cas_in_web
167
+ key = set_key_for_testcase(1)
168
+
169
+ expected_metrics = expected_web_metrics(:cas)
170
+
171
+ in_web_transaction("Controller/#{self.class}/action") do
172
+ @cache.cas(key) {|val| val += 2}
173
+ end
174
+
175
+ assert_memcache_metrics_recorded expected_metrics
176
+ assert_equal 3, @cache.get(key)
177
+ end
178
+
179
+ def test_get_in_background
180
+ key = set_key_for_testcase
181
+
182
+ expected_metrics = expected_bg_metrics(:get)
183
+
184
+ in_background_transaction("OtherTransaction/Background/#{self.class}/bg_task") do
185
+ @cache.get(key)
186
+ end
187
+
188
+ assert_memcache_metrics_recorded expected_metrics
189
+ end
190
+
191
+ def test_get_multi_in_background
192
+ key = set_key_for_testcase
193
+
194
+ expected_metrics = expected_bg_metrics(:get_multi)
195
+
196
+ in_background_transaction("OtherTransaction/Background/#{self.class}/bg_task") do
197
+ @cache.get_multi(key)
198
+ end
199
+
200
+ assert_memcache_metrics_recorded expected_metrics
201
+ end
202
+
203
+ def test_set_in_background
204
+ expected_metrics = expected_bg_metrics(:set)
205
+
206
+ in_background_transaction("OtherTransaction/Background/#{self.class}/bg_task") do
207
+ @cache.set(randomized_key, "value")
208
+ end
209
+
210
+ assert_memcache_metrics_recorded expected_metrics
211
+ end
212
+
213
+ def test_add_in_background
214
+ expected_metrics = expected_bg_metrics(:add)
215
+
216
+ in_background_transaction("OtherTransaction/Background/#{self.class}/bg_task") do
217
+ @cache.add(randomized_key, "value")
218
+ end
219
+
220
+ assert_memcache_metrics_recorded expected_metrics
221
+ end
222
+
223
+ def test_delete_in_background
224
+ key = set_key_for_testcase
225
+
226
+ expected_metrics = expected_bg_metrics(:delete)
227
+
228
+ in_background_transaction("OtherTransaction/Background/#{self.class}/bg_task") do
229
+ @cache.delete(key)
230
+ end
231
+
232
+ assert_memcache_metrics_recorded expected_metrics
233
+ end
234
+
235
+ def test_incr_in_background
236
+ expected_metrics = expected_bg_metrics(:incr)
237
+
238
+ in_background_transaction("OtherTransaction/Background/#{self.class}/bg_task") do
239
+ @cache.incr("incr_test", 0)
240
+ end
241
+
242
+ assert_memcache_metrics_recorded expected_metrics
243
+ end
244
+
245
+ def test_decr_in_background
246
+ expected_metrics = expected_bg_metrics(:decr)
247
+
248
+ in_background_transaction("OtherTransaction/Background/#{self.class}/bg_task") do
249
+ @cache.decr("decr_test", 0)
250
+ end
251
+
252
+ assert_memcache_metrics_recorded expected_metrics
253
+ end
254
+
255
+ def test_replace_in_background
256
+ key = set_key_for_testcase
257
+
258
+ expected_metrics = expected_bg_metrics(:replace)
259
+
260
+ in_background_transaction("OtherTransaction/Background/#{self.class}/bg_task") do
261
+ @cache.replace(key, 1337807)
262
+ end
263
+
264
+ assert_memcache_metrics_recorded expected_metrics
265
+ end
266
+
267
+ def test_append_in_background
268
+ key = set_key_for_testcase
269
+
270
+ expected_metrics = expected_bg_metrics(:append)
271
+
272
+ in_background_transaction("OtherTransaction/Background/#{self.class}/bg_task") do
273
+ @cache.append(key, 1337807)
274
+ end
275
+
276
+ assert_memcache_metrics_recorded expected_metrics
277
+ end
278
+
279
+ def test_prepend_in_background
280
+ key = set_key_for_testcase
281
+
282
+ expected_metrics = expected_bg_metrics(:prepend)
283
+
284
+ in_background_transaction("OtherTransaction/Background/#{self.class}/bg_task") do
285
+ @cache.prepend(key, 1337807)
286
+ end
287
+
288
+ assert_memcache_metrics_recorded expected_metrics
289
+ end
290
+
291
+ def test_cas_in_background
292
+ key = set_key_for_testcase(1)
293
+ expected_metrics = expected_bg_metrics(:cas)
294
+
295
+ in_background_transaction("OtherTransaction/Background/#{self.class}/bg_task") do
296
+ @cache.cas(key) {|val| val += 2}
297
+ end
298
+
299
+ assert_memcache_metrics_recorded expected_metrics
300
+ assert_equal 3, @cache.get(key)
301
+ end
302
+ end