newrelic_rpm 3.9.3.241 → 3.9.4.245
Sign up to get free protection for your applications and to get access to all the features.
- data.tar.gz.sig +0 -0
- data/.gitignore +1 -0
- data/CHANGELOG +29 -0
- data/Rakefile +41 -0
- data/cert/cacert.pem +1176 -117
- data/lib/new_relic/agent/agent_logger.rb +14 -0
- data/lib/new_relic/agent/configuration/default_source.rb +88 -86
- data/lib/new_relic/agent/configuration/environment_source.rb +5 -1
- data/lib/new_relic/agent/configuration/high_security_source.rb +3 -1
- data/lib/new_relic/agent/configuration/yaml_source.rb +3 -3
- data/lib/new_relic/agent/instrumentation/active_record_subscriber.rb +4 -0
- data/lib/new_relic/agent/method_tracer.rb +17 -2
- data/lib/new_relic/agent/new_relic_service.rb +21 -19
- data/lib/new_relic/agent/new_relic_service/json_marshaller.rb +8 -2
- data/lib/new_relic/agent/request_sampler.rb +9 -11
- data/lib/new_relic/version.rb +1 -1
- data/lib/tasks/config.html.erb +2 -2
- data/lib/tasks/config.rake +6 -6
- data/test/environments/lib/environments/runner.rb +4 -4
- data/test/environments/rails42/Gemfile +35 -0
- data/test/environments/rails42/Rakefile +11 -0
- data/test/environments/rails42/config/application.rb +18 -0
- data/test/environments/rails42/config/boot.rb +10 -0
- data/test/environments/rails42/config/database.yml +26 -0
- data/test/environments/rails42/config/environment.rb +6 -0
- data/test/environments/rails42/db/schema.rb +5 -0
- data/test/fixtures/cross_agent_tests/README.md +40 -1
- data/test/fixtures/cross_agent_tests/cat_map.json +305 -73
- data/test/fixtures/cross_agent_tests/sql_obfuscation/pathological/README.md +4 -0
- data/test/fixtures/cross_agent_tests/sql_obfuscation/{end_of_line_comments_with_quotes.obfuscated → pathological/end_of_line_comments_with_quotes.obfuscated} +0 -0
- data/test/fixtures/cross_agent_tests/sql_obfuscation/{end_of_line_comments_with_quotes.sql → pathological/end_of_line_comments_with_quotes.sql} +0 -0
- data/test/fixtures/cross_agent_tests/sql_obfuscation/{mixed_comments_and_quotes.obfuscated → pathological/mixed_comments_and_quotes.obfuscated} +0 -0
- data/test/fixtures/cross_agent_tests/sql_obfuscation/{mixed_comments_and_quotes.sql → pathological/mixed_comments_and_quotes.sql} +0 -0
- data/test/fixtures/cross_agent_tests/sql_obfuscation/{mixed_quotes_comments_and_newlines.obfuscated → pathological/mixed_quotes_comments_and_newlines.obfuscated} +0 -0
- data/test/fixtures/cross_agent_tests/sql_obfuscation/{mixed_quotes_comments_and_newlines.sql → pathological/mixed_quotes_comments_and_newlines.sql} +0 -0
- data/test/fixtures/cross_agent_tests/sql_obfuscation/{mixed_quotes_end_of_line_comments.obfuscated → pathological/mixed_quotes_end_of_line_comments.obfuscated} +0 -0
- data/test/fixtures/cross_agent_tests/sql_obfuscation/{mixed_quotes_end_of_line_comments.sql → pathological/mixed_quotes_end_of_line_comments.sql} +0 -0
- data/test/fixtures/cross_agent_tests/sql_obfuscation/{quote_delimiters_in_comments.obfuscated → pathological/quote_delimiters_in_comments.obfuscated} +0 -0
- data/test/fixtures/cross_agent_tests/sql_obfuscation/{quote_delimiters_in_comments.sql → pathological/quote_delimiters_in_comments.sql} +0 -0
- data/test/multiverse/suites/agent_only/cross_application_tracing_test.rb +9 -4
- data/test/multiverse/suites/rails/Envfile +6 -0
- data/test/multiverse/suites/rails/ignore_test.rb +7 -7
- data/test/multiverse/suites/rails/view_instrumentation_test.rb +13 -13
- data/test/new_relic/agent/configuration/environment_source_test.rb +8 -0
- data/test/new_relic/agent/configuration/yaml_source_test.rb +1 -1
- data/test/new_relic/agent/database/sql_obfuscation_test.rb +17 -8
- data/test/new_relic/agent/instrumentation/active_record_test.rb +50 -7
- data/test/new_relic/agent/new_relic_service_test.rb +17 -4
- data/test/new_relic/http_client_test_cases.rb +15 -5
- data/test/performance/lib/performance.rb +8 -0
- data/test/performance/lib/performance/baseline.rb +36 -0
- data/test/performance/lib/performance/baseline_compare_reporter.rb +82 -0
- data/test/performance/lib/performance/baseline_save_reporter.rb +24 -0
- data/test/performance/lib/performance/console_reporter.rb +7 -20
- data/test/performance/lib/performance/reporting.rb +36 -0
- data/test/performance/lib/performance/table.rb +105 -0
- data/test/performance/script/runner +26 -20
- data/test/performance/suites/marshalling.rb +12 -12
- data/test/script/path_hash.rb +1 -1
- metadata +25 -25
- metadata.gz.sig +0 -0
- data/cert/oldsite.pem +0 -28
- data/cert/site.pem +0 -27
- data/test/flaky_proxy/Gemfile +0 -3
- data/test/flaky_proxy/README.md +0 -140
- data/test/flaky_proxy/lib/flaky_proxy.rb +0 -23
- data/test/flaky_proxy/lib/flaky_proxy/connection.rb +0 -45
- data/test/flaky_proxy/lib/flaky_proxy/http_message.rb +0 -107
- data/test/flaky_proxy/lib/flaky_proxy/proxy.rb +0 -58
- data/test/flaky_proxy/lib/flaky_proxy/rule.rb +0 -72
- data/test/flaky_proxy/lib/flaky_proxy/rule_set.rb +0 -45
- data/test/flaky_proxy/lib/flaky_proxy/sequence.rb +0 -14
- data/test/flaky_proxy/lib/flaky_proxy/server.rb +0 -22
- data/test/flaky_proxy/script/flaky_proxy +0 -39
@@ -0,0 +1,4 @@
|
|
1
|
+
# Pathological SQL Obfuscation Test Cases
|
2
|
+
|
3
|
+
## Why are these pathological?
|
4
|
+
Because obfuscating dialect-specific SQL is difficult without building a comprehensive lexer, so there are some edge cases where agents are expected to err on the side of over-obfuscation, even though the resulting obfuscation differs from how a perfect lexer might parse and obfuscate it.
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
@@ -59,11 +59,11 @@ class CrossApplicationTracingTest < Minitest::Test
|
|
59
59
|
|
60
60
|
load_cross_agent_test("cat_map").each do |test_case|
|
61
61
|
# We only can do test cases here that don't involve outgoing calls
|
62
|
-
if !test_case["
|
63
|
-
if test_case['
|
62
|
+
if !test_case["outboundRequests"]
|
63
|
+
if test_case['inboundPayload']
|
64
64
|
request_headers = {
|
65
65
|
'X-NewRelic-ID' => Base64.encode64('1#234'),
|
66
|
-
'X-NewRelic-Transaction' => json_dump_and_encode(test_case['
|
66
|
+
'X-NewRelic-Transaction' => json_dump_and_encode(test_case['inboundPayload'])
|
67
67
|
}
|
68
68
|
else
|
69
69
|
request_headers = {}
|
@@ -82,7 +82,12 @@ class CrossApplicationTracingTest < Minitest::Test
|
|
82
82
|
end
|
83
83
|
|
84
84
|
event = get_last_analytics_event
|
85
|
-
assert_event_attributes(
|
85
|
+
assert_event_attributes(
|
86
|
+
event,
|
87
|
+
test_case['name'],
|
88
|
+
test_case['expectedIntrinsicFields'],
|
89
|
+
test_case['nonExpectedIntrinsicFields']
|
90
|
+
)
|
86
91
|
end
|
87
92
|
end
|
88
93
|
end
|
@@ -47,32 +47,32 @@ class IgnoredActionsTest < RailsMultiverseTest
|
|
47
47
|
end
|
48
48
|
|
49
49
|
def test_metric__ignore
|
50
|
-
get 'ignored/action_to_ignore'
|
50
|
+
get '/ignored/action_to_ignore'
|
51
51
|
assert_metrics_recorded_exclusive([])
|
52
52
|
end
|
53
53
|
|
54
54
|
def test_metric__ignore_apdex
|
55
|
-
get 'ignored/action_to_ignore_apdex'
|
55
|
+
get '/ignored/action_to_ignore_apdex'
|
56
56
|
assert_metrics_recorded(["Controller/ignored/action_to_ignore_apdex"])
|
57
57
|
assert_metrics_not_recorded(["Apdex"])
|
58
58
|
end
|
59
59
|
|
60
60
|
def test_ignored_transaction_traces_dont_leak
|
61
|
-
get 'ignored/action_to_ignore'
|
62
|
-
get 'request_stats/stats_action'
|
61
|
+
get '/ignored/action_to_ignore'
|
62
|
+
get '/request_stats/stats_action'
|
63
63
|
|
64
64
|
trace = NewRelic::Agent.instance.transaction_sampler.last_sample
|
65
65
|
assert_equal 1, trace.root_segment.called_segments.count
|
66
66
|
end
|
67
67
|
|
68
68
|
def test_should_not_write_cat_response_headers_for_ignored_transactions
|
69
|
-
get 'ignored/action_to_ignore', nil, {'X-NewRelic-ID' => Base64.encode64('1#234')}
|
69
|
+
get '/ignored/action_to_ignore', nil, {'X-NewRelic-ID' => Base64.encode64('1#234')}
|
70
70
|
assert_nil @response.headers["X-NewRelic-App-Data"]
|
71
71
|
end
|
72
72
|
|
73
73
|
def test_apdex_ignored_if_ignored_in_parent_class
|
74
|
-
get 'child/foo'
|
75
|
-
get 'child/bar'
|
74
|
+
get '/child/foo'
|
75
|
+
get '/child/bar'
|
76
76
|
|
77
77
|
assert_metrics_not_recorded("Apdex")
|
78
78
|
end
|
@@ -103,17 +103,17 @@ class ViewInstrumentationTest < RailsMultiverseTest
|
|
103
103
|
next if method == 'proc_render' && Rails::VERSION::MAJOR <= 2
|
104
104
|
|
105
105
|
define_method("test_sanity_#{method}") do
|
106
|
-
get "views/#{method}"
|
106
|
+
get "/views/#{method}"
|
107
107
|
assert_equal 200, status
|
108
108
|
end
|
109
109
|
|
110
110
|
def test_should_allow_uncaught_exception_to_propagate
|
111
|
-
get "views/raise_render"
|
111
|
+
get "/views/raise_render"
|
112
112
|
assert_equal 500, status
|
113
113
|
end
|
114
114
|
|
115
115
|
def test_should_count_all_the_template_and_partial_segments
|
116
|
-
get 'views/template_render_with_3_partial_renders'
|
116
|
+
get '/views/template_render_with_3_partial_renders'
|
117
117
|
sample = NewRelic::Agent.agent.transaction_sampler.last_sample
|
118
118
|
segments = find_all_segments_with_name_matching(sample, ['^Nested/Controller/views', '^View'])
|
119
119
|
segments_list = "Found these nodes:\n #{segments.map(&:metric_name).join("\n ")}"
|
@@ -126,7 +126,7 @@ class ViewInstrumentationTest < RailsMultiverseTest
|
|
126
126
|
end
|
127
127
|
|
128
128
|
def test_should_have_3_segments_with_the_correct_metric_name
|
129
|
-
get 'views/template_render_with_3_partial_renders'
|
129
|
+
get '/views/template_render_with_3_partial_renders'
|
130
130
|
|
131
131
|
sample = NewRelic::Agent.agent.transaction_sampler.last_sample
|
132
132
|
partial_segments = find_all_segments_with_name_matching(sample, 'View/views/_a_partial.html.erb/Partial')
|
@@ -138,7 +138,7 @@ class ViewInstrumentationTest < RailsMultiverseTest
|
|
138
138
|
# We don't capture text or inline template rendering on Rails 2
|
139
139
|
if Rails::VERSION::MAJOR >= 3
|
140
140
|
def test_should_create_a_metric_for_the_rendered_inline_template
|
141
|
-
get 'views/inline_render'
|
141
|
+
get '/views/inline_render'
|
142
142
|
|
143
143
|
sample = NewRelic::Agent.agent.transaction_sampler.last_sample
|
144
144
|
text_segment = find_segment_with_name(sample, 'View/inline template/Rendering')
|
@@ -150,13 +150,13 @@ class ViewInstrumentationTest < RailsMultiverseTest
|
|
150
150
|
# It doesn't seem worth it to get consistent behavior here.
|
151
151
|
if Rails::VERSION::MAJOR.to_i == 3 && Rails::VERSION::MINOR.to_i == 0
|
152
152
|
def test_should_not_instrument_rendering_of_text
|
153
|
-
get 'views/text_render'
|
153
|
+
get '/views/text_render'
|
154
154
|
sample = NewRelic::Agent.agent.transaction_sampler.last_sample
|
155
155
|
refute find_segment_with_name(sample, 'View/text template/Rendering')
|
156
156
|
end
|
157
157
|
else
|
158
158
|
def test_should_create_a_metric_for_the_rendered_text
|
159
|
-
get 'views/text_render'
|
159
|
+
get '/views/text_render'
|
160
160
|
|
161
161
|
sample = NewRelic::Agent.agent.transaction_sampler.last_sample
|
162
162
|
text_segment = find_segment_with_name(sample, 'View/text template/Rendering')
|
@@ -168,7 +168,7 @@ class ViewInstrumentationTest < RailsMultiverseTest
|
|
168
168
|
end
|
169
169
|
|
170
170
|
def test_should_create_a_metric_for_the_rendered_haml_template
|
171
|
-
get 'views/haml_render'
|
171
|
+
get '/views/haml_render'
|
172
172
|
|
173
173
|
sample = NewRelic::Agent.agent.transaction_sampler.last_sample
|
174
174
|
text_segment = find_segment_with_name(sample, 'View/views/haml_view.html.haml/Rendering')
|
@@ -178,7 +178,7 @@ class ViewInstrumentationTest < RailsMultiverseTest
|
|
178
178
|
end
|
179
179
|
|
180
180
|
def test_should_create_a_proper_metric_when_the_template_is_unknown
|
181
|
-
get 'views/no_template'
|
181
|
+
get '/views/no_template'
|
182
182
|
sample = NewRelic::Agent.agent.transaction_sampler.last_sample
|
183
183
|
|
184
184
|
# Different versions have significant difference in handling, but we're
|
@@ -193,7 +193,7 @@ class ViewInstrumentationTest < RailsMultiverseTest
|
|
193
193
|
end
|
194
194
|
|
195
195
|
def test_should_create_a_proper_metric_when_we_render_a_collection
|
196
|
-
get 'views/collection_render'
|
196
|
+
get '/views/collection_render'
|
197
197
|
sample = NewRelic::Agent.agent.transaction_sampler.last_sample
|
198
198
|
assert find_segment_with_name(sample, "View/foos/_foo.html.haml/Partial")
|
199
199
|
end
|
@@ -201,7 +201,7 @@ class ViewInstrumentationTest < RailsMultiverseTest
|
|
201
201
|
[:js_render, :xml_render, :proc_render, :json_render ].each do |action|
|
202
202
|
next if action == :proc_render && Rails::VERSION::MAJOR <= 2
|
203
203
|
define_method("test_should_not_instrument_rendering_of_#{action}") do
|
204
|
-
get "views/#{action}"
|
204
|
+
get "/views/#{action}"
|
205
205
|
sample = NewRelic::Agent.agent.transaction_sampler.last_sample
|
206
206
|
view_segment = find_segment_with_name_matching(sample, /^View\//)
|
207
207
|
refute view_segment, "Should not instrument rendering of #{action}, found #{view_segment}."
|
@@ -212,7 +212,7 @@ class ViewInstrumentationTest < RailsMultiverseTest
|
|
212
212
|
# hasn't been a problem thus far, so we're letting it slide.
|
213
213
|
if Rails::VERSION::MAJOR >= 3
|
214
214
|
def test_should_create_a_metric_for_rendered_file_that_does_not_include_the_filename_so_it_doesnt_metric_explode
|
215
|
-
get 'views/file_render'
|
215
|
+
get '/views/file_render'
|
216
216
|
sample = NewRelic::Agent.agent.transaction_sampler.last_sample
|
217
217
|
assert find_segment_with_name(sample, 'View/file/Rendering')
|
218
218
|
refute find_segment_with_name_matching(sample, 'dummy')
|
@@ -220,7 +220,7 @@ class ViewInstrumentationTest < RailsMultiverseTest
|
|
220
220
|
end
|
221
221
|
|
222
222
|
def test_exclusive_time_for_template_render_metrics_should_not_include_partial_rendering_time
|
223
|
-
get 'views/render_with_delays'
|
223
|
+
get '/views/render_with_delays'
|
224
224
|
|
225
225
|
expected_stats_partial = {
|
226
226
|
:call_count => 3,
|
@@ -165,6 +165,14 @@ module NewRelic::Agent::Configuration
|
|
165
165
|
assert_equal keys, result
|
166
166
|
end
|
167
167
|
|
168
|
+
def test_does_not_warn_for_new_relic_env_environment_variable
|
169
|
+
expects_no_logging(:warn)
|
170
|
+
expects_no_logging(:info)
|
171
|
+
with_environment('NEW_RELIC_ENV' => 'foo') do
|
172
|
+
@environment_source.set_values_from_new_relic_environment_variables
|
173
|
+
end
|
174
|
+
end
|
175
|
+
|
168
176
|
def assert_applied_string(env_var, config_var)
|
169
177
|
ENV[env_var] = 'test value'
|
170
178
|
assert_equal 'test value', EnvironmentSource.new[config_var.to_sym]
|
@@ -49,19 +49,28 @@ module NewRelic::Agent::Database
|
|
49
49
|
|
50
50
|
query
|
51
51
|
end
|
52
|
+
|
53
|
+
def self.create_regular_obfuscation_test(filename, type = "normal")
|
54
|
+
name = name_for_input_file(filename)
|
52
55
|
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
define_method("test_sql_obfuscation_#{name}") do
|
58
|
-
query = read_query(input_file)
|
59
|
-
expected_obfuscated = File.read(obfuscated_filename(input_file))
|
56
|
+
define_method("test_sql_obfuscation_#{type}_#{name}") do
|
57
|
+
query = read_query(filename)
|
58
|
+
expected_obfuscated = File.read(obfuscated_filename(filename))
|
60
59
|
actual_obfuscated = NewRelic::Agent::Database.obfuscate_sql(query)
|
61
|
-
assert_equal(expected_obfuscated, actual_obfuscated, "Failed to obfuscate query from #{
|
60
|
+
assert_equal(expected_obfuscated, actual_obfuscated, "Failed to obfuscate #{type} query from #{filename}\nQuery: #{query}")
|
62
61
|
end
|
63
62
|
end
|
64
63
|
|
64
|
+
# Normal queries
|
65
|
+
input_files.each do |input_file|
|
66
|
+
create_regular_obfuscation_test(input_file)
|
67
|
+
end
|
68
|
+
|
69
|
+
# Pathological queries
|
70
|
+
input_files('pathological').each do |input_file|
|
71
|
+
create_regular_obfuscation_test(input_file, "pathological")
|
72
|
+
end
|
73
|
+
|
65
74
|
# Malformed queries
|
66
75
|
input_files('malformed').each do |input_file|
|
67
76
|
name = name_for_input_file(input_file)
|
@@ -301,6 +301,37 @@ class NewRelic::Agent::Instrumentation::NewActiveRecordInstrumentationTest < Min
|
|
301
301
|
end
|
302
302
|
end
|
303
303
|
|
304
|
+
def test_cached_calls_are_not_recorded_with_find
|
305
|
+
in_web_transaction do
|
306
|
+
order = ActiveRecordFixtures::Order.create(:name => 'Oberon')
|
307
|
+
ActiveRecordFixtures::Order.connection.cache do
|
308
|
+
ActiveRecordFixtures::Order.find(order.id)
|
309
|
+
ActiveRecordFixtures::Order.find(order.id)
|
310
|
+
ActiveRecordFixtures::Order.find(order.id)
|
311
|
+
end
|
312
|
+
end
|
313
|
+
|
314
|
+
call_count = active_record_query_caching_broken_for_find ? 3 : 1
|
315
|
+
assert_activerecord_metrics(ActiveRecordFixtures::Order, 'find', :call_count => call_count)
|
316
|
+
assert_remote_service_metrics
|
317
|
+
end
|
318
|
+
|
319
|
+
def test_cached_calls_are_not_recorded_with_select_all
|
320
|
+
query = "SELECT * FROM #{ActiveRecordFixtures::Order.table_name} WHERE name = 'Oberon'"
|
321
|
+
in_web_transaction do
|
322
|
+
ActiveRecordFixtures::Order.create(:name => 'Oberon')
|
323
|
+
ActiveRecordFixtures::Order.connection.cache do
|
324
|
+
ActiveRecordFixtures::Order.connection.select_all(query)
|
325
|
+
ActiveRecordFixtures::Order.connection.select_all(query)
|
326
|
+
ActiveRecordFixtures::Order.connection.select_all(query)
|
327
|
+
end
|
328
|
+
end
|
329
|
+
|
330
|
+
assert_metrics_recorded(
|
331
|
+
{'Database/SQL/select' => {:call_count => 1}}
|
332
|
+
)
|
333
|
+
end
|
334
|
+
|
304
335
|
# helpers
|
305
336
|
|
306
337
|
def rails_env
|
@@ -354,13 +385,25 @@ class NewRelic::Agent::Instrumentation::NewActiveRecordInstrumentationTest < Min
|
|
354
385
|
end
|
355
386
|
end
|
356
387
|
|
357
|
-
def
|
358
|
-
|
359
|
-
|
360
|
-
|
361
|
-
|
362
|
-
|
363
|
-
|
388
|
+
def active_record_query_caching_broken_for_find
|
389
|
+
# For ActiveRecord 3.1 and 3.2 running in JRuby, some
|
390
|
+
# query caching does not work.
|
391
|
+
return false unless defined? JRuby
|
392
|
+
return false unless active_record_major_version == 3
|
393
|
+
|
394
|
+
case active_record_minor_version
|
395
|
+
when 1, 2 then true
|
396
|
+
else false
|
397
|
+
end
|
398
|
+
end
|
399
|
+
|
400
|
+
def assert_activerecord_metrics(model, operation, stats={})
|
401
|
+
assert_metrics_recorded({
|
402
|
+
"ActiveRecord/all" => {},
|
403
|
+
"ActiveRecord/#{operation}" => {},
|
404
|
+
"ActiveRecord/#{model}/#{operation}" => stats,
|
405
|
+
"Datastore/all" => {}
|
406
|
+
})
|
364
407
|
end
|
365
408
|
|
366
409
|
def assert_generic_rollup_metrics(operation)
|
@@ -150,6 +150,13 @@ class NewRelicServiceTest < Minitest::Test
|
|
150
150
|
assert_equal File.expand_path(File.join(File.dirname(__FILE__), '..', '..', '..', 'cert', 'cacert.pem')), @service.cert_file_path
|
151
151
|
end
|
152
152
|
|
153
|
+
def test_cert_file_path_uses_path_from_config
|
154
|
+
fake_cert_path = '/certpath/cert.pem'
|
155
|
+
with_config(:ca_bundle_path => fake_cert_path) do
|
156
|
+
assert_equal @service.cert_file_path, fake_cert_path
|
157
|
+
end
|
158
|
+
end
|
159
|
+
|
153
160
|
def test_initialize_uses_correct_license_key_settings
|
154
161
|
with_config(:license_key => 'abcde') do
|
155
162
|
service = NewRelic::Agent::NewRelicService.new
|
@@ -323,6 +330,12 @@ class NewRelicServiceTest < Minitest::Test
|
|
323
330
|
assert_equal({ "profile" => 123 }, response)
|
324
331
|
end
|
325
332
|
|
333
|
+
def test_profile_data_does_not_normalize_encodings
|
334
|
+
@http_handle.respond_to(:profile_data, nil)
|
335
|
+
NewRelic::JSONWrapper.expects(:normalize).never
|
336
|
+
@service.profile_data([])
|
337
|
+
end
|
338
|
+
|
326
339
|
def test_get_agent_commands
|
327
340
|
@service.agent_id = 666
|
328
341
|
@http_handle.respond_to(:get_agent_commands, [1,2,3])
|
@@ -419,7 +432,7 @@ class NewRelicServiceTest < Minitest::Test
|
|
419
432
|
def test_raises_serialization_error_if_json_serialization_fails
|
420
433
|
::NewRelic::JSONWrapper.stubs(:dump).raises(RuntimeError.new('blah'))
|
421
434
|
assert_raises(NewRelic::Agent::SerializationError) do
|
422
|
-
@service.send(:invoke_remote, 'wiggle', {})
|
435
|
+
@service.send(:invoke_remote, 'wiggle', [{}])
|
423
436
|
end
|
424
437
|
end
|
425
438
|
|
@@ -428,7 +441,7 @@ class NewRelicServiceTest < Minitest::Test
|
|
428
441
|
@http_handle.respond_to(:wiggle, 'hi')
|
429
442
|
NewRelic::JSONWrapper.stubs(:normalize).raises('blah')
|
430
443
|
assert_raises(NewRelic::Agent::SerializationError) do
|
431
|
-
@service.send(:invoke_remote, 'wiggle', {})
|
444
|
+
@service.send(:invoke_remote, 'wiggle', [{}])
|
432
445
|
end
|
433
446
|
end
|
434
447
|
end
|
@@ -437,7 +450,7 @@ class NewRelicServiceTest < Minitest::Test
|
|
437
450
|
@http_handle.respond_to(:wiggle, 'hello')
|
438
451
|
with_config(:normalize_json_string_encodings => false) do
|
439
452
|
NewRelic::JSONWrapper.expects(:normalize).never
|
440
|
-
@service.send(:invoke_remote, 'wiggle', { 'foo' => 'bar' })
|
453
|
+
@service.send(:invoke_remote, 'wiggle', [{ 'foo' => 'bar' }])
|
441
454
|
end
|
442
455
|
end
|
443
456
|
|
@@ -689,7 +702,7 @@ class NewRelicServiceTest < Minitest::Test
|
|
689
702
|
def roundtrip_data(data, normalize = true)
|
690
703
|
with_config(:normalize_json_string_encodings => normalize) do
|
691
704
|
@http_handle.respond_to(:roundtrip, 'roundtrip')
|
692
|
-
@service.send(:invoke_remote, 'roundtrip', data)
|
705
|
+
@service.send(:invoke_remote, 'roundtrip', [data])
|
693
706
|
@http_handle.last_request_payload[0]
|
694
707
|
end
|
695
708
|
end
|
@@ -482,7 +482,7 @@ module HttpClientTestCases
|
|
482
482
|
|
483
483
|
load_cross_agent_test("cat_map").each do |test_case|
|
484
484
|
# Test cases that don't involve outgoing calls are done elsewhere
|
485
|
-
if test_case['
|
485
|
+
if test_case['outboundRequests']
|
486
486
|
define_method("test_#{test_case['name']}") do
|
487
487
|
config = {
|
488
488
|
:app_name => test_case['appName'],
|
@@ -491,18 +491,28 @@ module HttpClientTestCases
|
|
491
491
|
with_config(config) do
|
492
492
|
in_transaction do
|
493
493
|
state = NewRelic::Agent::TransactionState.tl_get
|
494
|
-
state.referring_transaction_info = test_case['
|
494
|
+
state.referring_transaction_info = test_case['inboundPayload']
|
495
495
|
stub_transaction_guid(test_case['transactionGuid'])
|
496
|
-
test_case['
|
497
|
-
set_explicit_transaction_name(
|
496
|
+
test_case['outboundRequests'].each do |req|
|
497
|
+
set_explicit_transaction_name(req['outboundTxnName'])
|
498
498
|
get_response
|
499
|
+
|
500
|
+
outbound_payload = server.requests.last["HTTP_X_NEWRELIC_TRANSACTION"]
|
501
|
+
decoded_outbound_payload = decode_payload(outbound_payload)
|
502
|
+
|
503
|
+
assert_equal(req['expectedOutboundPayload'], decoded_outbound_payload)
|
499
504
|
end
|
500
505
|
set_explicit_transaction_name(test_case['transactionName'])
|
501
506
|
end
|
502
507
|
end
|
503
508
|
|
504
509
|
event = get_last_analytics_event
|
505
|
-
assert_event_attributes(
|
510
|
+
assert_event_attributes(
|
511
|
+
event,
|
512
|
+
test_case['name'],
|
513
|
+
test_case['expectedIntrinsicFields'],
|
514
|
+
test_case['nonExpectedIntrinsicFields']
|
515
|
+
)
|
506
516
|
end
|
507
517
|
end
|
508
518
|
end
|