newrelic_rpm 3.7.3.204 → 3.8.0.218

Sign up to get free protection for your applications and to get access to all the features.
Files changed (154) hide show
  1. data.tar.gz.sig +0 -0
  2. data/CHANGELOG +73 -0
  3. data/README.md +1 -1
  4. data/Rakefile +1 -5
  5. data/lib/new_relic/agent.rb +1 -0
  6. data/lib/new_relic/agent/agent.rb +47 -18
  7. data/lib/new_relic/agent/agent_logger.rb +11 -1
  8. data/lib/new_relic/agent/configuration/default_source.rb +85 -1
  9. data/lib/new_relic/agent/configuration/manager.rb +5 -1
  10. data/lib/new_relic/agent/datastores/mongo.rb +8 -3
  11. data/lib/new_relic/agent/harvester.rb +5 -1
  12. data/lib/new_relic/agent/instrumentation/action_controller_subscriber.rb +1 -0
  13. data/lib/new_relic/agent/instrumentation/active_merchant.rb +7 -3
  14. data/lib/new_relic/agent/instrumentation/controller_instrumentation.rb +13 -3
  15. data/lib/new_relic/agent/instrumentation/rails/action_controller.rb +7 -1
  16. data/lib/new_relic/agent/instrumentation/sidekiq.rb +3 -1
  17. data/lib/new_relic/agent/instrumentation/sinatra.rb +3 -1
  18. data/lib/new_relic/agent/new_relic_service.rb +8 -0
  19. data/lib/new_relic/agent/request_sampler.rb +1 -1
  20. data/lib/new_relic/agent/sampler.rb +22 -2
  21. data/lib/new_relic/agent/sampler_collection.rb +13 -1
  22. data/lib/new_relic/agent/samplers/cpu_sampler.rb +3 -1
  23. data/lib/new_relic/agent/samplers/delayed_job_sampler.rb +2 -1
  24. data/lib/new_relic/agent/samplers/memory_sampler.rb +2 -1
  25. data/lib/new_relic/agent/samplers/object_sampler.rb +1 -3
  26. data/lib/new_relic/agent/samplers/vm_sampler.rb +126 -0
  27. data/lib/new_relic/agent/stats.rb +0 -15
  28. data/lib/new_relic/agent/stats_engine/gc_profiler.rb +66 -75
  29. data/lib/new_relic/agent/stats_engine/stats_hash.rb +1 -1
  30. data/lib/new_relic/agent/supported_versions.rb +2 -2
  31. data/lib/new_relic/agent/transaction.rb +6 -3
  32. data/lib/new_relic/agent/vm/monotonic_gc_profiler.rb +17 -5
  33. data/lib/new_relic/agent/vm/mri_vm.rb +2 -1
  34. data/lib/new_relic/agent/vm/snapshot.rb +5 -1
  35. data/lib/new_relic/control/instance_methods.rb +8 -5
  36. data/lib/new_relic/control/instrumentation.rb +0 -9
  37. data/lib/new_relic/environment_report.rb +1 -1
  38. data/lib/new_relic/language_support.rb +4 -0
  39. data/lib/new_relic/local_environment.rb +39 -14
  40. data/lib/new_relic/noticed_error.rb +7 -4
  41. data/lib/new_relic/rack/browser_monitoring.rb +16 -3
  42. data/lib/new_relic/version.rb +2 -2
  43. data/newrelic_rpm.gemspec +1 -1
  44. data/test/agent_helper.rb +5 -3
  45. data/test/environments/lib/environments/runner.rb +8 -7
  46. data/test/environments/norails/Gemfile +1 -1
  47. data/test/environments/rails21/Gemfile +1 -0
  48. data/test/environments/rails22/Gemfile +1 -0
  49. data/test/environments/rails23/Gemfile +1 -0
  50. data/test/environments/rails30/Gemfile +4 -1
  51. data/test/environments/rails31/Gemfile +4 -1
  52. data/test/environments/rails32/Gemfile +3 -4
  53. data/test/environments/rails40/Gemfile +1 -1
  54. data/test/environments/rails41/Gemfile +1 -1
  55. data/test/flaky_proxy/lib/flaky_proxy/proxy.rb +1 -0
  56. data/test/multiverse/lib/multiverse/output_collector.rb +3 -1
  57. data/test/multiverse/lib/multiverse/runner.rb +2 -10
  58. data/test/multiverse/lib/multiverse/suite.rb +100 -30
  59. data/test/multiverse/suites/activemerchant/Envfile +16 -0
  60. data/test/multiverse/suites/activemerchant/activemerchant_test.rb +65 -0
  61. data/test/multiverse/suites/agent_only/custom_queue_time_test.rb +57 -0
  62. data/test/multiverse/suites/config_file_loading/config_file_loading_test.rb +1 -1
  63. data/test/multiverse/suites/mongo/Envfile +9 -1
  64. data/test/multiverse/suites/rails/Envfile +2 -2
  65. data/test/multiverse/suites/rails/app.rb +3 -0
  66. data/test/multiverse/suites/rails/bad_instrumentation_test.rb +0 -2
  67. data/test/multiverse/suites/rails/error_tracing_test.rb +1 -2
  68. data/test/multiverse/suites/rails/gc_instrumentation_test.rb +17 -8
  69. data/test/multiverse/suites/rails/ignore_test.rb +0 -2
  70. data/test/multiverse/suites/rails/mongrel_queue_depth_test.rb +0 -2
  71. data/test/multiverse/suites/rails/queue_time_test.rb +40 -11
  72. data/test/multiverse/suites/rails/request_statistics_test.rb +0 -3
  73. data/test/multiverse/suites/rails/view_instrumentation_test.rb +0 -2
  74. data/test/multiverse/suites/sidekiq/Envfile +7 -2
  75. data/test/multiverse/suites/sinatra/Envfile +1 -1
  76. data/test/multiverse/suites/sinatra/nested_middleware_test.rb +41 -0
  77. data/test/multiverse/suites/sinatra/sinatra_metric_explosion_test.rb +1 -1
  78. data/test/new_relic/agent/agent/connect_test.rb +32 -4
  79. data/test/new_relic/agent/agent/start_test.rb +9 -1
  80. data/test/new_relic/agent/agent_logger_test.rb +23 -2
  81. data/test/new_relic/agent/agent_test.rb +49 -7
  82. data/test/new_relic/agent/configuration/manager_test.rb +8 -0
  83. data/test/new_relic/agent/configuration/orphan_configuration_test.rb +7 -0
  84. data/test/new_relic/agent/cross_app_monitor_test.rb +5 -6
  85. data/test/new_relic/agent/harvester_test.rb +13 -8
  86. data/test/new_relic/agent/instrumentation/action_controller_subscriber_test.rb +28 -7
  87. data/test/new_relic/agent/instrumentation/controller_instrumentation_test.rb +32 -21
  88. data/test/new_relic/agent/new_relic_service_test.rb +14 -0
  89. data/test/new_relic/agent/request_sampler_test.rb +5 -3
  90. data/test/new_relic/agent/rpm_agent_test.rb +2 -3
  91. data/test/new_relic/agent/sampler_collection_test.rb +15 -5
  92. data/test/new_relic/agent/sampler_test.rb +43 -0
  93. data/test/new_relic/agent/{cpu_sampler_test.rb → samplers/cpu_sampler_test.rb} +1 -1
  94. data/test/new_relic/agent/samplers/vm_sampler_test.rb +349 -0
  95. data/test/new_relic/agent/stats_engine/gc_profiler_test.rb +165 -44
  96. data/test/new_relic/agent/stats_hash_test.rb +1 -1
  97. data/test/new_relic/agent/transaction_test.rb +14 -0
  98. data/test/new_relic/agent/vm/monotonic_gc_profiler_test.rb +5 -5
  99. data/test/new_relic/agent/vm/mri_vm_test.rb +7 -0
  100. data/test/new_relic/agent/vm/snapshot_test.rb +5 -0
  101. data/test/new_relic/agent_test.rb +2 -2
  102. data/test/new_relic/control/instance_methods_test.rb +30 -0
  103. data/test/new_relic/control_test.rb +43 -21
  104. data/test/new_relic/dispatcher_test.rb +5 -0
  105. data/test/new_relic/local_environment_test.rb +3 -26
  106. data/test/new_relic/multiverse_helpers.rb +5 -0
  107. data/test/new_relic/noticed_error_test.rb +7 -0
  108. data/test/new_relic/rack/browser_monitoring_test.rb +13 -14
  109. data/test/test_helper.rb +2 -1
  110. metadata +56 -68
  111. metadata.gz.sig +1 -1
  112. data/lib/new_relic/agent/instrumentation/puma.rb +0 -25
  113. data/lib/new_relic/agent/instrumentation/unicorn_instrumentation.rb +0 -26
  114. data/test/multiverse/script/run_one +0 -5
  115. data/test/rum/basic.result.html +0 -10
  116. data/test/rum/basic.source.html +0 -10
  117. data/test/rum/comments1.result.html +0 -24
  118. data/test/rum/comments1.source.html +0 -24
  119. data/test/rum/comments2.result.html +0 -24
  120. data/test/rum/comments2.source.html +0 -24
  121. data/test/rum/gt_in_quotes1.result.html +0 -27
  122. data/test/rum/gt_in_quotes1.source.html +0 -27
  123. data/test/rum/gt_in_quotes2.result.html +0 -24
  124. data/test/rum/gt_in_quotes2.source.html +0 -24
  125. data/test/rum/gt_in_quotes_mismatch.result.html +0 -24
  126. data/test/rum/gt_in_quotes_mismatch.source.html +0 -24
  127. data/test/rum/gt_in_single_quotes1.result.html +0 -25
  128. data/test/rum/gt_in_single_quotes1.source.html +0 -25
  129. data/test/rum/gt_in_single_quotes_mismatch.result.html +0 -25
  130. data/test/rum/gt_in_single_quotes_mismatch.source.html +0 -25
  131. data/test/rum/incomplete_non_meta_tags.result.html +0 -10
  132. data/test/rum/incomplete_non_meta_tags.source.html +0 -10
  133. data/test/rum/no_body.result.html +0 -21
  134. data/test/rum/no_body.source.html +0 -21
  135. data/test/rum/no_header.result.html +0 -7
  136. data/test/rum/no_header.source.html +0 -7
  137. data/test/rum/no_html_and_no_header.result.html +0 -3
  138. data/test/rum/no_html_and_no_header.source.html +0 -3
  139. data/test/rum/no_start_header.result.html +0 -9
  140. data/test/rum/no_start_header.source.html +0 -9
  141. data/test/rum/script1.result.html +0 -19
  142. data/test/rum/script1.source.html +0 -19
  143. data/test/rum/script2.result.html +0 -17
  144. data/test/rum/script2.source.html +0 -17
  145. data/test/rum/x_ua_meta_tag.result.html +0 -10
  146. data/test/rum/x_ua_meta_tag.source.html +0 -10
  147. data/test/rum/x_ua_meta_tag_multiline.result.html +0 -11
  148. data/test/rum/x_ua_meta_tag_multiline.source.html +0 -11
  149. data/test/rum/x_ua_meta_tag_spaces_around_equals.result.html +0 -10
  150. data/test/rum/x_ua_meta_tag_spaces_around_equals.source.html +0 -10
  151. data/test/rum/x_ua_meta_tag_with_others.result.html +0 -11
  152. data/test/rum/x_ua_meta_tag_with_others.source.html +0 -11
  153. data/test/rum/x_ua_meta_tag_with_spaces.result.html +0 -10
  154. data/test/rum/x_ua_meta_tag_with_spaces.source.html +0 -10
@@ -2,6 +2,7 @@ source 'http://rubygems.org'
2
2
 
3
3
  gem "rails", "~>2.1.2"
4
4
 
5
+ gem 'rake', '~>10.1.1'
5
6
  gem 'minitest', '~>4.7.5'
6
7
  gem "mocha", :require => false
7
8
  gem "jeweler", "1.4.0"
@@ -2,6 +2,7 @@ source 'http://rubygems.org'
2
2
 
3
3
  gem "rails", "~>2.2.3"
4
4
 
5
+ gem 'rake', '~>10.1.1'
5
6
  gem 'minitest', '~>4.7.5'
6
7
  gem "mocha", :require => false
7
8
  gem "jeweler", "1.4.0"
@@ -2,6 +2,7 @@ source 'https://rubygems.org'
2
2
 
3
3
  gem "rails", "~> 2.3.18"
4
4
 
5
+ gem 'rake', '~>10.1.1'
5
6
  gem 'minitest', '~>4.7.5'
6
7
  gem 'mocha', :require => false
7
8
  gem 'rack'
@@ -1,12 +1,15 @@
1
1
  source 'http://rubygems.org'
2
2
 
3
3
  gem 'rails', '~>3.0.20'
4
- gem 'newrelic_rpm', :path => '../../..'
4
+
5
+ gem 'rake', '~>10.1.1'
5
6
  gem 'minitest', '~>4.7.5'
6
7
  gem 'mocha', :require => false
7
8
  gem 'rack'
8
9
  gem 'rack-test'
9
10
 
11
+ gem 'newrelic_rpm', :path => '../../..'
12
+
10
13
  if (RUBY_PLATFORM == 'java')
11
14
  gem "activerecord-jdbcmysql-adapter", '1.2.5'
12
15
  gem "activerecord-jdbcsqlite3-adapter", '1.2.5'
@@ -1,12 +1,15 @@
1
1
  source 'http://rubygems.org'
2
2
 
3
3
  gem 'rails', '~>3.1.12'
4
- gem 'newrelic_rpm', :path => '../../..'
4
+
5
+ gem 'rake', '~>10.1.1'
5
6
  gem 'minitest', '~>4.7.5'
6
7
  gem 'mocha', :require => false
7
8
  gem 'rack'
8
9
  gem 'rack-test'
9
10
 
11
+ gem 'newrelic_rpm', :path => '../../..'
12
+
10
13
  if (RUBY_PLATFORM == 'java')
11
14
  gem "activerecord-jdbcmysql-adapter", "~>1.2.9"
12
15
  gem "activerecord-jdbcsqlite3-adapter", "~>1.2.9"
@@ -1,14 +1,15 @@
1
1
  source 'http://rubygems.org'
2
2
 
3
- gem 'rake'
4
-
5
3
  gem 'rails', '~>3.2.15'
6
4
 
5
+ gem 'rake', '~>10.1.1'
7
6
  gem 'minitest', '~>4.7.5'
8
7
  gem 'mocha', :require => false
9
8
  gem 'rack'
10
9
  gem 'rack-test'
11
10
 
11
+ gem "newrelic_rpm", :path => "../../.."
12
+
12
13
  platforms :jruby do
13
14
  gem "activerecord-jdbcmysql-adapter", "~>1.2.9"
14
15
  gem "activerecord-jdbcsqlite3-adapter", "~>1.2.9"
@@ -19,5 +20,3 @@ platforms :ruby, :rbx do
19
20
  gem "mysql", "~>2.9.1"
20
21
  gem "sqlite3"
21
22
  end
22
-
23
- gem "newrelic_rpm", :path => "../../.."
@@ -2,7 +2,7 @@ source 'http://rubygems.org'
2
2
 
3
3
  gem 'rake'
4
4
 
5
- gem 'rails', '~>4.0.1'
5
+ gem 'rails', '~>4.0.4'
6
6
 
7
7
  # Do not automatically require minitest, since this will break with rbx-2.2.5.
8
8
  # rbx-2.2.5 helpfully bundles minitest-5.3.0.
@@ -2,7 +2,7 @@ source 'http://rubygems.org'
2
2
 
3
3
  gem 'rake'
4
4
 
5
- gem 'rails', '~>4.1.0.rc1'
5
+ gem 'rails', '~>4.1.0'
6
6
 
7
7
  gem 'minitest', '5.2.3'
8
8
  gem 'mocha', :require => false
@@ -13,6 +13,7 @@ module FlakyProxy
13
13
  @rules = RuleSet.build('')
14
14
  @rules_path = options[:rules_path]
15
15
  @listen_socket = nil
16
+ reload_rules_file
16
17
  end
17
18
 
18
19
  def service_connection(client_socket)
@@ -48,8 +48,10 @@ module Multiverse
48
48
  output(green("There were no test failures"))
49
49
  else
50
50
  output(
51
+ red("*" * 80),
51
52
  red("There were failures in #{failing_output.size} test suites"),
52
- "Here is their output",
53
+ red("Here is their output"),
54
+ red("*" * 80),
53
55
  *failing_output)
54
56
  end
55
57
  end
@@ -25,7 +25,8 @@ module Multiverse
25
25
  end
26
26
 
27
27
  # Args without a = are turned into just opts[key] = true
28
- # Args with = get split, then assigned as key + value
28
+ # Args with = get split, then assigned as key + value. Repeats overwrite
29
+ # Args with name= will tally up rather than overwriting
29
30
  # :suite gets ignored
30
31
  def parse_args(args)
31
32
  opts = {}
@@ -67,14 +68,5 @@ module Multiverse
67
68
  OutputCollector.overall_report
68
69
  exit exit_status
69
70
  end
70
-
71
- # run_one is used to run a suite directly in process
72
- # Pipe shenanigans in the typical Suite runner interferes with the debugger
73
- def run_one(filter="", opts={})
74
- dir = Dir.new(SUITES_DIRECTORY).entries.find { |d| d.include?(filter) }
75
- full_path = File.join(SUITES_DIRECTORY, dir)
76
- $stderr.reopen($stdout)
77
- Suite.new(full_path, opts).execute_child_environment(opts.fetch(:env, "0").to_i)
78
- end
79
71
  end
80
72
  end
@@ -7,20 +7,52 @@
7
7
  # version of Minitest, which we use throughout, not the one in stdlib on
8
8
  # Rubies starting with 1.9.x
9
9
  require 'rubygems'
10
+ require 'base64'
10
11
 
11
12
  require File.expand_path(File.join(File.dirname(__FILE__), 'environment'))
12
13
 
13
14
  module Multiverse
14
15
  class Suite
15
16
  include Color
16
- attr_accessor :directory, :include_debugger, :seed, :names
17
+ attr_accessor :directory, :opts
17
18
 
18
19
  def initialize(directory, opts={})
19
- self.directory = directory
20
- self.include_debugger = opts.fetch(:run_one, false)
21
- self.seed = opts.fetch(:seed, "")
22
- self.names = opts.fetch(:names, [])
23
- ENV["VERBOSE"] = '1' if opts[:verbose]
20
+ self.directory = directory
21
+ self.opts = opts
22
+ ENV["VERBOSE"] = '1' if opts[:verbose]
23
+ end
24
+
25
+ def self.encode_options(decoded_opts)
26
+ Base64.encode64(Marshal.dump(decoded_opts)).gsub("\n", "")
27
+ end
28
+
29
+ def self.decode_options(encoded_opts)
30
+ Marshal.load(Base64.decode64(encoded_opts))
31
+ end
32
+
33
+ def suite
34
+ File.basename(directory)
35
+ end
36
+
37
+ def seed
38
+ opts.fetch(:seed, "")
39
+ end
40
+
41
+ def debug
42
+ opts.fetch(:debug, false)
43
+ end
44
+
45
+ def names
46
+ opts.fetch(:names, [])
47
+ end
48
+
49
+ def filter_env
50
+ value = opts.fetch(:env, nil)
51
+ value = value.to_i if value
52
+ end
53
+
54
+ def filter_file
55
+ opts.fetch(:file, nil)
24
56
  end
25
57
 
26
58
  def clean_gemfiles(env_index)
@@ -75,13 +107,8 @@ module Multiverse
75
107
 
76
108
  f.puts " gem 'mocha', '0.14.0', :require => false"
77
109
 
78
- # Need to get Rubinius' debugger wired in, but MRI's doesn't work
79
- if include_debugger
80
- if RUBY_VERSION > '1.8.7'
81
- f.puts " gem 'debugger', :platforms => [:mri]"
82
- else
83
- f.puts " gem 'ruby-debug', :platforms => [:mri]"
84
- end
110
+ if debug
111
+ f.puts " gem 'pry'"
85
112
  end
86
113
  end
87
114
  puts yellow("Gemfile.#{env_index} set to:") if verbose?
@@ -127,6 +154,7 @@ module Multiverse
127
154
 
128
155
  def execute_child_environment(env_index)
129
156
  with_clean_env do
157
+ log_test_running_process
130
158
  configure_before_bundling
131
159
 
132
160
  gemfile_text = environments[env_index]
@@ -139,8 +167,12 @@ module Multiverse
139
167
  end
140
168
  end
141
169
 
170
+ def log_test_running_process
171
+ puts yellow("Starting tests in child PID #{Process.pid}\n")
172
+ end
173
+
142
174
  def should_serialize?
143
- ENV['SERIALIZE']
175
+ ENV['SERIALIZE'] || debug
144
176
  end
145
177
 
146
178
  # Load the test suite's environment and execute it.
@@ -156,7 +188,8 @@ module Multiverse
156
188
  end
157
189
 
158
190
  label = should_serialize? ? 'serial' : 'parallel'
159
- puts yellow("\nRunning #{directory.inspect} in #{environments.size} environments in #{label}")
191
+ env_count = filter_env ? 1 : environments.size
192
+ puts yellow("\nRunning #{directory.inspect} in #{env_count} environments in #{label}")
160
193
 
161
194
  environments.before.call if environments.before
162
195
  if should_serialize?
@@ -168,19 +201,35 @@ module Multiverse
168
201
  end
169
202
 
170
203
  def execute_serial
171
- environments.each_with_index do |gemfile_text, i|
172
- execute_with_pipe(i)
204
+ with_each_environment do |_, i|
205
+ if debug
206
+ execute_in_foreground(i)
207
+ else
208
+ execute_in_background(i)
209
+ end
173
210
  end
174
211
  end
175
212
 
176
213
  def execute_parallel
177
214
  threads = []
178
- environments.each_with_index do |gemfile_text, i|
179
- threads << Thread.new { execute_with_pipe(i) }
215
+ with_each_environment do |_, i|
216
+ threads << Thread.new { execute_in_background(i) }
180
217
  end
181
218
  threads.each {|t| t.join}
182
219
  end
183
220
 
221
+ def with_each_environment
222
+ environments.each_with_index do |gemfile_text, i|
223
+ next unless should_run_environment?(i)
224
+ yield gemfile_text, i
225
+ end
226
+ end
227
+
228
+ def should_run_environment?(index)
229
+ return true unless filter_env
230
+ return filter_env == index
231
+ end
232
+
184
233
  def with_clean_env
185
234
  if defined?(Bundler)
186
235
  # clear $BUNDLE_GEMFILE and $RUBYOPT so that the ruby subprocess can run
@@ -191,12 +240,19 @@ module Multiverse
191
240
  end
192
241
  end
193
242
 
194
- def execute_with_pipe(env)
243
+ def execute_in_foreground(env)
244
+ with_clean_env do
245
+ puts yellow("Running #{suite.inspect} for Envfile entry #{env}\n")
246
+ system(child_command_line(env))
247
+ check_for_failure(env)
248
+ end
249
+ end
250
+
251
+ def execute_in_background(env)
195
252
  with_clean_env do
196
- suite = File.basename(directory)
197
- IO.popen("#{__FILE__} #{directory} #{env} '#{seed}' '#{names.join(",")}'") do |io|
198
- OutputCollector.write(suite, env, yellow("Running #{suite.inspect} for Envfile entry #{env}\n"))
199
- OutputCollector.write(suite, env, yellow("Starting tests in child PID #{io.pid}\n"))
253
+ OutputCollector.write(suite, env, yellow("Running #{suite.inspect} for Envfile entry #{env}\n"))
254
+
255
+ IO.popen(child_command_line(env)) do |io|
200
256
  until io.eof do
201
257
  chars = io.read
202
258
  OutputCollector.write(suite, env, chars)
@@ -204,11 +260,20 @@ module Multiverse
204
260
  OutputCollector.suite_report(suite, env)
205
261
  end
206
262
 
207
- if $? != 0
208
- OutputCollector.failed(suite, env)
209
- end
210
- Multiverse::Runner.notice_exit_status $?
263
+ check_for_failure(env)
264
+ end
265
+ end
266
+
267
+ def child_command_line(env)
268
+ "#{__FILE__} #{directory} #{env} '#{Suite.encode_options(opts)}'"
269
+ end
270
+
271
+ def check_for_failure(env)
272
+ if $? != 0
273
+ OutputCollector.write(suite, env, red("#{suite.inspect} for Envfile entry #{env} failed!"))
274
+ OutputCollector.failed(suite, env)
211
275
  end
276
+ Multiverse::Runner.notice_exit_status $?
212
277
  end
213
278
 
214
279
  def trigger_test_run
@@ -312,6 +377,10 @@ module Multiverse
312
377
  files.delete(before)
313
378
  files.delete(after)
314
379
 
380
+ # Important that we filter after removing before/after so they don't get
381
+ # tromped for not matching our pattern!
382
+ files.select! {|file| file.include?(filter_file) } if filter_file
383
+
315
384
  files.insert(0, before) if before
316
385
  files.insert(-1, after) if after
317
386
 
@@ -335,7 +404,8 @@ if $0 == __FILE__ && $already_running.nil?
335
404
  $stderr.reopen($stdout)
336
405
 
337
406
  # Ugly, but seralized args passed along to #popen when kicking child off
338
- dir, env_index, seed, names, _ = *ARGV
339
- suite = Multiverse::Suite.new(dir, {:seed => seed, :names => names.split(",")})
407
+ dir, env_index, encoded_opts, _ = *ARGV
408
+ opts = Multiverse::Suite.decode_options(encoded_opts)
409
+ suite = Multiverse::Suite.new(dir, opts)
340
410
  suite.execute_child_environment(env_index.to_i)
341
411
  end
@@ -0,0 +1,16 @@
1
+ gemfile <<-RB
2
+ gem 'activemerchant', '~>1.42.7'
3
+ gem 'rack'
4
+
5
+ if RUBY_VERSION <= '1.9.2'
6
+ # Very special versioning to keep us running on 1.8.7 versions of Ruby
7
+ gem 'activesupport', '~>2.3.14', :require => 'active_support'
8
+ gem 'nokogiri', '~>1.4.7'
9
+ else
10
+ gem 'activesupport', '~>4.0.4'
11
+ gem 'nokogiri', '~>1.6.1'
12
+ end
13
+
14
+ # Need to load newrelic_rpm after ActiveMerchant Gateways are required
15
+ gem 'newrelic_rpm', :require => false, :path => File.expand_path('../../../../')
16
+ RB
@@ -0,0 +1,65 @@
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
+ # Let ActiveSupport's auto-loading make sure the testing gateway's there.
6
+ # require complains of redefine on certain Rubies, (looking at you REE)
7
+ ActiveMerchant::Billing::BogusGateway
8
+
9
+ class ActiveMerchant::Billing::BogusGateway
10
+ # Testing class doesn't have this, but we instrument it for other gateways
11
+ def update(*_)
12
+ end
13
+ end
14
+
15
+ require 'newrelic_rpm'
16
+
17
+ require File.join(File.dirname(__FILE__), '..', '..', '..', 'agent_helper.rb')
18
+ require 'multiverse_helpers'
19
+
20
+ class ActiveMerchantTest < Minitest::Test
21
+
22
+ attr_reader :gateway
23
+
24
+ include MultiverseHelpers
25
+
26
+ setup_and_teardown_agent do
27
+ @gateway = ActiveMerchant::Billing::BogusGateway.new
28
+ end
29
+
30
+ # Methods with parameters (money, paysource) can just be added to this list
31
+ [:authorize, :purchase, :credit, :capture, :recurring, :update].each do |operation|
32
+ define_method("test_#{operation}") do
33
+ assert_merchant_transaction(operation)
34
+ end
35
+ end
36
+
37
+ # Tests for methods that require more specific parameters should go here
38
+ def test_void
39
+ assert_merchant_transaction(:void, REFERENCE)
40
+ end
41
+
42
+ def test_store
43
+ assert_merchant_transaction(:store, PAYSOURCE)
44
+ end
45
+
46
+ def test_unstore
47
+ assert_merchant_transaction(:unstore, "1")
48
+ end
49
+
50
+ # Helper
51
+ PAYSOURCE = 1
52
+ REFERENCE = 3
53
+
54
+ def assert_merchant_transaction(operation, *args)
55
+ in_transaction('txn') do
56
+ # Default arguments if not provided by test
57
+ args = [100, PAYSOURCE] if args.empty?
58
+
59
+ gateway.send(operation, *args)
60
+ end
61
+ assert_metrics_recorded([["ActiveMerchant/gateway/BogusGateway/#{operation}", "txn"],
62
+ "ActiveMerchant/gateway/BogusGateway",
63
+ "ActiveMerchant/operation/#{operation}"])
64
+ end
65
+ end