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.
- data.tar.gz.sig +0 -0
- data/CHANGELOG +73 -0
- data/README.md +1 -1
- data/Rakefile +1 -5
- data/lib/new_relic/agent.rb +1 -0
- data/lib/new_relic/agent/agent.rb +47 -18
- data/lib/new_relic/agent/agent_logger.rb +11 -1
- data/lib/new_relic/agent/configuration/default_source.rb +85 -1
- data/lib/new_relic/agent/configuration/manager.rb +5 -1
- data/lib/new_relic/agent/datastores/mongo.rb +8 -3
- data/lib/new_relic/agent/harvester.rb +5 -1
- data/lib/new_relic/agent/instrumentation/action_controller_subscriber.rb +1 -0
- data/lib/new_relic/agent/instrumentation/active_merchant.rb +7 -3
- data/lib/new_relic/agent/instrumentation/controller_instrumentation.rb +13 -3
- data/lib/new_relic/agent/instrumentation/rails/action_controller.rb +7 -1
- data/lib/new_relic/agent/instrumentation/sidekiq.rb +3 -1
- data/lib/new_relic/agent/instrumentation/sinatra.rb +3 -1
- data/lib/new_relic/agent/new_relic_service.rb +8 -0
- data/lib/new_relic/agent/request_sampler.rb +1 -1
- data/lib/new_relic/agent/sampler.rb +22 -2
- data/lib/new_relic/agent/sampler_collection.rb +13 -1
- data/lib/new_relic/agent/samplers/cpu_sampler.rb +3 -1
- data/lib/new_relic/agent/samplers/delayed_job_sampler.rb +2 -1
- data/lib/new_relic/agent/samplers/memory_sampler.rb +2 -1
- data/lib/new_relic/agent/samplers/object_sampler.rb +1 -3
- data/lib/new_relic/agent/samplers/vm_sampler.rb +126 -0
- data/lib/new_relic/agent/stats.rb +0 -15
- data/lib/new_relic/agent/stats_engine/gc_profiler.rb +66 -75
- data/lib/new_relic/agent/stats_engine/stats_hash.rb +1 -1
- data/lib/new_relic/agent/supported_versions.rb +2 -2
- data/lib/new_relic/agent/transaction.rb +6 -3
- data/lib/new_relic/agent/vm/monotonic_gc_profiler.rb +17 -5
- data/lib/new_relic/agent/vm/mri_vm.rb +2 -1
- data/lib/new_relic/agent/vm/snapshot.rb +5 -1
- data/lib/new_relic/control/instance_methods.rb +8 -5
- data/lib/new_relic/control/instrumentation.rb +0 -9
- data/lib/new_relic/environment_report.rb +1 -1
- data/lib/new_relic/language_support.rb +4 -0
- data/lib/new_relic/local_environment.rb +39 -14
- data/lib/new_relic/noticed_error.rb +7 -4
- data/lib/new_relic/rack/browser_monitoring.rb +16 -3
- data/lib/new_relic/version.rb +2 -2
- data/newrelic_rpm.gemspec +1 -1
- data/test/agent_helper.rb +5 -3
- data/test/environments/lib/environments/runner.rb +8 -7
- data/test/environments/norails/Gemfile +1 -1
- data/test/environments/rails21/Gemfile +1 -0
- data/test/environments/rails22/Gemfile +1 -0
- data/test/environments/rails23/Gemfile +1 -0
- data/test/environments/rails30/Gemfile +4 -1
- data/test/environments/rails31/Gemfile +4 -1
- data/test/environments/rails32/Gemfile +3 -4
- data/test/environments/rails40/Gemfile +1 -1
- data/test/environments/rails41/Gemfile +1 -1
- data/test/flaky_proxy/lib/flaky_proxy/proxy.rb +1 -0
- data/test/multiverse/lib/multiverse/output_collector.rb +3 -1
- data/test/multiverse/lib/multiverse/runner.rb +2 -10
- data/test/multiverse/lib/multiverse/suite.rb +100 -30
- data/test/multiverse/suites/activemerchant/Envfile +16 -0
- data/test/multiverse/suites/activemerchant/activemerchant_test.rb +65 -0
- data/test/multiverse/suites/agent_only/custom_queue_time_test.rb +57 -0
- data/test/multiverse/suites/config_file_loading/config_file_loading_test.rb +1 -1
- data/test/multiverse/suites/mongo/Envfile +9 -1
- data/test/multiverse/suites/rails/Envfile +2 -2
- data/test/multiverse/suites/rails/app.rb +3 -0
- data/test/multiverse/suites/rails/bad_instrumentation_test.rb +0 -2
- data/test/multiverse/suites/rails/error_tracing_test.rb +1 -2
- data/test/multiverse/suites/rails/gc_instrumentation_test.rb +17 -8
- data/test/multiverse/suites/rails/ignore_test.rb +0 -2
- data/test/multiverse/suites/rails/mongrel_queue_depth_test.rb +0 -2
- data/test/multiverse/suites/rails/queue_time_test.rb +40 -11
- data/test/multiverse/suites/rails/request_statistics_test.rb +0 -3
- data/test/multiverse/suites/rails/view_instrumentation_test.rb +0 -2
- data/test/multiverse/suites/sidekiq/Envfile +7 -2
- data/test/multiverse/suites/sinatra/Envfile +1 -1
- data/test/multiverse/suites/sinatra/nested_middleware_test.rb +41 -0
- data/test/multiverse/suites/sinatra/sinatra_metric_explosion_test.rb +1 -1
- data/test/new_relic/agent/agent/connect_test.rb +32 -4
- data/test/new_relic/agent/agent/start_test.rb +9 -1
- data/test/new_relic/agent/agent_logger_test.rb +23 -2
- data/test/new_relic/agent/agent_test.rb +49 -7
- data/test/new_relic/agent/configuration/manager_test.rb +8 -0
- data/test/new_relic/agent/configuration/orphan_configuration_test.rb +7 -0
- data/test/new_relic/agent/cross_app_monitor_test.rb +5 -6
- data/test/new_relic/agent/harvester_test.rb +13 -8
- data/test/new_relic/agent/instrumentation/action_controller_subscriber_test.rb +28 -7
- data/test/new_relic/agent/instrumentation/controller_instrumentation_test.rb +32 -21
- data/test/new_relic/agent/new_relic_service_test.rb +14 -0
- data/test/new_relic/agent/request_sampler_test.rb +5 -3
- data/test/new_relic/agent/rpm_agent_test.rb +2 -3
- data/test/new_relic/agent/sampler_collection_test.rb +15 -5
- data/test/new_relic/agent/sampler_test.rb +43 -0
- data/test/new_relic/agent/{cpu_sampler_test.rb → samplers/cpu_sampler_test.rb} +1 -1
- data/test/new_relic/agent/samplers/vm_sampler_test.rb +349 -0
- data/test/new_relic/agent/stats_engine/gc_profiler_test.rb +165 -44
- data/test/new_relic/agent/stats_hash_test.rb +1 -1
- data/test/new_relic/agent/transaction_test.rb +14 -0
- data/test/new_relic/agent/vm/monotonic_gc_profiler_test.rb +5 -5
- data/test/new_relic/agent/vm/mri_vm_test.rb +7 -0
- data/test/new_relic/agent/vm/snapshot_test.rb +5 -0
- data/test/new_relic/agent_test.rb +2 -2
- data/test/new_relic/control/instance_methods_test.rb +30 -0
- data/test/new_relic/control_test.rb +43 -21
- data/test/new_relic/dispatcher_test.rb +5 -0
- data/test/new_relic/local_environment_test.rb +3 -26
- data/test/new_relic/multiverse_helpers.rb +5 -0
- data/test/new_relic/noticed_error_test.rb +7 -0
- data/test/new_relic/rack/browser_monitoring_test.rb +13 -14
- data/test/test_helper.rb +2 -1
- metadata +56 -68
- metadata.gz.sig +1 -1
- data/lib/new_relic/agent/instrumentation/puma.rb +0 -25
- data/lib/new_relic/agent/instrumentation/unicorn_instrumentation.rb +0 -26
- data/test/multiverse/script/run_one +0 -5
- data/test/rum/basic.result.html +0 -10
- data/test/rum/basic.source.html +0 -10
- data/test/rum/comments1.result.html +0 -24
- data/test/rum/comments1.source.html +0 -24
- data/test/rum/comments2.result.html +0 -24
- data/test/rum/comments2.source.html +0 -24
- data/test/rum/gt_in_quotes1.result.html +0 -27
- data/test/rum/gt_in_quotes1.source.html +0 -27
- data/test/rum/gt_in_quotes2.result.html +0 -24
- data/test/rum/gt_in_quotes2.source.html +0 -24
- data/test/rum/gt_in_quotes_mismatch.result.html +0 -24
- data/test/rum/gt_in_quotes_mismatch.source.html +0 -24
- data/test/rum/gt_in_single_quotes1.result.html +0 -25
- data/test/rum/gt_in_single_quotes1.source.html +0 -25
- data/test/rum/gt_in_single_quotes_mismatch.result.html +0 -25
- data/test/rum/gt_in_single_quotes_mismatch.source.html +0 -25
- data/test/rum/incomplete_non_meta_tags.result.html +0 -10
- data/test/rum/incomplete_non_meta_tags.source.html +0 -10
- data/test/rum/no_body.result.html +0 -21
- data/test/rum/no_body.source.html +0 -21
- data/test/rum/no_header.result.html +0 -7
- data/test/rum/no_header.source.html +0 -7
- data/test/rum/no_html_and_no_header.result.html +0 -3
- data/test/rum/no_html_and_no_header.source.html +0 -3
- data/test/rum/no_start_header.result.html +0 -9
- data/test/rum/no_start_header.source.html +0 -9
- data/test/rum/script1.result.html +0 -19
- data/test/rum/script1.source.html +0 -19
- data/test/rum/script2.result.html +0 -17
- data/test/rum/script2.source.html +0 -17
- data/test/rum/x_ua_meta_tag.result.html +0 -10
- data/test/rum/x_ua_meta_tag.source.html +0 -10
- data/test/rum/x_ua_meta_tag_multiline.result.html +0 -11
- data/test/rum/x_ua_meta_tag_multiline.source.html +0 -11
- data/test/rum/x_ua_meta_tag_spaces_around_equals.result.html +0 -10
- data/test/rum/x_ua_meta_tag_spaces_around_equals.source.html +0 -10
- data/test/rum/x_ua_meta_tag_with_others.result.html +0 -11
- data/test/rum/x_ua_meta_tag_with_others.source.html +0 -11
- data/test/rum/x_ua_meta_tag_with_spaces.result.html +0 -10
- data/test/rum/x_ua_meta_tag_with_spaces.source.html +0 -10
@@ -1,12 +1,15 @@
|
|
1
1
|
source 'http://rubygems.org'
|
2
2
|
|
3
3
|
gem 'rails', '~>3.0.20'
|
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'
|
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
|
-
|
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 => "../../.."
|
@@ -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, :
|
17
|
+
attr_accessor :directory, :opts
|
17
18
|
|
18
19
|
def initialize(directory, opts={})
|
19
|
-
self.directory
|
20
|
-
self.
|
21
|
-
|
22
|
-
|
23
|
-
|
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
|
-
|
79
|
-
|
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
|
-
|
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
|
-
|
172
|
-
|
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
|
-
|
179
|
-
threads << Thread.new {
|
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
|
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
|
197
|
-
|
198
|
-
|
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
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
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,
|
339
|
-
|
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
|