newrelic_rpm 3.9.1.236 → 3.9.2.239
Sign up to get free protection for your applications and to get access to all the features.
- data.tar.gz.sig +2 -4
- data/CHANGELOG +96 -2
- data/lib/new_relic/agent.rb +47 -4
- data/lib/new_relic/agent/agent.rb +51 -26
- data/lib/new_relic/agent/agent_logger.rb +4 -0
- data/lib/new_relic/agent/configuration.rb +2 -32
- data/lib/new_relic/agent/configuration/default_source.rb +153 -118
- data/lib/new_relic/agent/configuration/dotted_hash.rb +52 -0
- data/lib/new_relic/agent/configuration/environment_source.rb +1 -1
- data/lib/new_relic/agent/configuration/manager.rb +101 -2
- data/lib/new_relic/agent/configuration/manual_source.rb +17 -0
- data/lib/new_relic/agent/configuration/server_source.rb +12 -4
- data/lib/new_relic/agent/configuration/yaml_source.rb +46 -22
- data/lib/new_relic/agent/cross_app_monitor.rb +1 -1
- data/lib/new_relic/agent/cross_app_tracing.rb +1 -1
- data/lib/new_relic/agent/database/obfuscation_helpers.rb +55 -14
- data/lib/new_relic/agent/database/obfuscator.rb +22 -7
- data/lib/new_relic/agent/database/postgres_explain_obfuscator.rb +6 -8
- data/lib/new_relic/agent/error_collector.rb +24 -16
- data/lib/new_relic/agent/event_loop.rb +189 -0
- data/lib/new_relic/agent/instrumentation/action_controller_subscriber.rb +8 -17
- data/lib/new_relic/agent/instrumentation/active_record_helper.rb +1 -1
- data/lib/new_relic/agent/instrumentation/active_record_subscriber.rb +1 -1
- data/lib/new_relic/agent/instrumentation/controller_instrumentation.rb +17 -16
- data/lib/new_relic/agent/instrumentation/ignore_actions.rb +41 -0
- data/lib/new_relic/agent/instrumentation/merb/controller.rb +0 -11
- data/lib/new_relic/agent/instrumentation/middleware_tracing.rb +1 -1
- data/lib/new_relic/agent/instrumentation/rails/action_controller.rb +0 -8
- data/lib/new_relic/agent/instrumentation/rails3/action_controller.rb +1 -9
- data/lib/new_relic/agent/instrumentation/rails4/action_controller.rb +0 -18
- data/lib/new_relic/agent/instrumentation/rubyprof.rb +1 -1
- data/lib/new_relic/agent/instrumentation/sidekiq.rb +1 -1
- data/lib/new_relic/agent/instrumentation/sinatra.rb +12 -1
- data/lib/new_relic/agent/instrumentation/sinatra/transaction_namer.rb +1 -1
- data/lib/new_relic/agent/method_tracer.rb +33 -39
- data/lib/new_relic/agent/new_relic_service.rb +35 -156
- data/lib/new_relic/agent/new_relic_service/encoders.rb +34 -0
- data/lib/new_relic/agent/new_relic_service/json_marshaller.rb +50 -0
- data/lib/new_relic/agent/new_relic_service/marshaller.rb +52 -0
- data/lib/new_relic/agent/new_relic_service/pruby_marshaller.rb +52 -0
- data/lib/new_relic/agent/threading/backtrace_node.rb +1 -1
- data/lib/new_relic/agent/traced_method_stack.rb +16 -2
- data/lib/new_relic/agent/transaction.rb +0 -4
- data/lib/new_relic/collection_helper.rb +2 -2
- data/lib/new_relic/control/frameworks/rails.rb +3 -0
- data/lib/new_relic/control/instrumentation.rb +6 -2
- data/lib/new_relic/json_wrapper.rb +47 -25
- data/lib/new_relic/language_support.rb +0 -4
- data/lib/new_relic/latest_changes.rb +2 -2
- data/lib/new_relic/rack/developer_mode.rb +4 -3
- data/lib/new_relic/recipes/capistrano3.rb +2 -2
- data/lib/new_relic/recipes/capistrano_legacy.rb +1 -1
- data/lib/new_relic/timer_lib.rb +1 -1
- data/lib/new_relic/version.rb +2 -2
- data/lib/tasks/config.html.erb +28 -0
- data/lib/tasks/config.rake +134 -0
- data/lib/tasks/config.text.erb +7 -0
- data/lib/tasks/install.rake +0 -63
- data/newrelic.yml +7 -0
- data/test/active_record_fixtures.rb +4 -4
- data/test/agent_helper.rb +58 -18
- data/test/environments/lib/environments/runner.rb +1 -1
- data/test/environments/rails21/Gemfile +1 -1
- data/test/environments/rails21/config/boot.rb +1 -1
- data/test/environments/rails22/Gemfile +1 -1
- data/test/environments/rails22/config/boot.rb +1 -1
- data/test/environments/rails23/config/boot.rb +2 -2
- data/test/environments/rails30/Gemfile +1 -1
- data/test/environments/rails31/Gemfile +1 -1
- data/test/environments/rails32/Gemfile +1 -1
- data/test/environments/rails40/Gemfile +1 -1
- data/test/environments/rails41/Gemfile +1 -1
- data/test/fixtures/cross_agent_tests/labels.json +104 -0
- data/test/fixtures/cross_agent_tests/sql_obfuscation/README.md +23 -0
- data/test/fixtures/cross_agent_tests/sql_obfuscation/back_quoted_identifiers.mysql.obfuscated +1 -0
- data/test/fixtures/cross_agent_tests/sql_obfuscation/back_quoted_identifiers.mysql.sql +1 -0
- data/test/fixtures/cross_agent_tests/sql_obfuscation/comment_delimiters_in_strings.obfuscated +1 -0
- data/test/fixtures/cross_agent_tests/sql_obfuscation/comment_delimiters_in_strings.sql +1 -0
- data/test/fixtures/cross_agent_tests/sql_obfuscation/double_quoted_identifiers.postgres.obfuscated +1 -0
- data/test/fixtures/cross_agent_tests/sql_obfuscation/double_quoted_identifiers.postgres.sql +1 -0
- data/test/fixtures/cross_agent_tests/sql_obfuscation/end_of_line_comment_in_string.obfuscated +2 -0
- data/test/fixtures/cross_agent_tests/sql_obfuscation/end_of_line_comment_in_string.sql +2 -0
- data/test/fixtures/cross_agent_tests/sql_obfuscation/end_of_line_comments_with_quotes.obfuscated +1 -0
- data/test/fixtures/cross_agent_tests/sql_obfuscation/end_of_line_comments_with_quotes.sql +2 -0
- data/test/fixtures/cross_agent_tests/sql_obfuscation/end_of_query_comment_cstyle.obfuscated +1 -0
- data/test/fixtures/cross_agent_tests/sql_obfuscation/end_of_query_comment_cstyle.sql +1 -0
- data/test/fixtures/cross_agent_tests/sql_obfuscation/end_of_query_comment_doubledash.obfuscated +2 -0
- data/test/fixtures/cross_agent_tests/sql_obfuscation/end_of_query_comment_doubledash.sql +2 -0
- data/test/fixtures/cross_agent_tests/sql_obfuscation/end_of_query_comment_hash.obfuscated +1 -0
- data/test/fixtures/cross_agent_tests/sql_obfuscation/end_of_query_comment_hash.sql +1 -0
- data/test/fixtures/cross_agent_tests/sql_obfuscation/escape_string_constants.postgres.obfuscated +1 -0
- data/test/fixtures/cross_agent_tests/sql_obfuscation/escape_string_constants.postgres.sql +4 -0
- data/test/fixtures/cross_agent_tests/sql_obfuscation/malformed/unterminated_double_quoted_string.mysql.sql +1 -0
- data/test/fixtures/cross_agent_tests/sql_obfuscation/malformed/unterminated_single_quoted_string.sql +1 -0
- data/test/fixtures/cross_agent_tests/sql_obfuscation/mixed_comments_and_quotes.obfuscated +1 -0
- data/test/fixtures/cross_agent_tests/sql_obfuscation/mixed_comments_and_quotes.sql +2 -0
- data/test/fixtures/cross_agent_tests/sql_obfuscation/mixed_quotes_comments_and_newlines.obfuscated +1 -0
- data/test/fixtures/cross_agent_tests/sql_obfuscation/mixed_quotes_comments_and_newlines.sql +4 -0
- data/test/fixtures/cross_agent_tests/sql_obfuscation/mixed_quotes_end_of_line_comments.obfuscated +1 -0
- data/test/fixtures/cross_agent_tests/sql_obfuscation/mixed_quotes_end_of_line_comments.sql +3 -0
- data/test/fixtures/cross_agent_tests/sql_obfuscation/multiple_literal_types.mysql.obfuscated +1 -0
- data/test/fixtures/cross_agent_tests/sql_obfuscation/multiple_literal_types.mysql.sql +1 -0
- data/test/fixtures/cross_agent_tests/sql_obfuscation/numbers_in_identifiers.obfuscated +1 -0
- data/test/fixtures/cross_agent_tests/sql_obfuscation/numbers_in_identifiers.sql +1 -0
- data/test/fixtures/cross_agent_tests/sql_obfuscation/numeric_literals.obfuscated +1 -0
- data/test/fixtures/cross_agent_tests/sql_obfuscation/numeric_literals.sql +1 -0
- data/test/fixtures/cross_agent_tests/sql_obfuscation/quote_delimiters_in_comments.obfuscated +1 -0
- data/test/fixtures/cross_agent_tests/sql_obfuscation/quote_delimiters_in_comments.sql +1 -0
- data/test/fixtures/cross_agent_tests/sql_obfuscation/string_double_quoted.mysql.obfuscated +1 -0
- data/test/fixtures/cross_agent_tests/sql_obfuscation/string_double_quoted.mysql.sql +1 -0
- data/test/fixtures/cross_agent_tests/sql_obfuscation/string_single_quoted.obfuscated +1 -0
- data/test/fixtures/cross_agent_tests/sql_obfuscation/string_single_quoted.sql +1 -0
- data/test/fixtures/cross_agent_tests/sql_obfuscation/string_with_backslash_and_twin_single_quotes.obfuscated +1 -0
- data/test/fixtures/cross_agent_tests/sql_obfuscation/string_with_backslash_and_twin_single_quotes.sql +4 -0
- data/test/fixtures/cross_agent_tests/sql_obfuscation/string_with_embedded_double_quote.obfuscated +1 -0
- data/test/fixtures/cross_agent_tests/sql_obfuscation/string_with_embedded_double_quote.sql +1 -0
- data/test/fixtures/cross_agent_tests/sql_obfuscation/string_with_embedded_newline.obfuscated +1 -0
- data/test/fixtures/cross_agent_tests/sql_obfuscation/string_with_embedded_newline.sql +2 -0
- data/test/fixtures/cross_agent_tests/sql_obfuscation/string_with_embedded_single_quote.mysql.obfuscated +1 -0
- data/test/fixtures/cross_agent_tests/sql_obfuscation/string_with_embedded_single_quote.mysql.sql +1 -0
- data/test/fixtures/cross_agent_tests/sql_obfuscation/string_with_escaped_quotes.mysql.obfuscated +1 -0
- data/test/fixtures/cross_agent_tests/sql_obfuscation/string_with_escaped_quotes.mysql.sql +1 -0
- data/test/fixtures/cross_agent_tests/sql_obfuscation/string_with_trailing_backslash.obfuscated +1 -0
- data/test/fixtures/cross_agent_tests/sql_obfuscation/string_with_trailing_backslash.sql +4 -0
- data/test/fixtures/cross_agent_tests/sql_obfuscation/string_with_trailing_escaped_backslash.mysql.obfuscated +1 -0
- data/test/fixtures/cross_agent_tests/sql_obfuscation/string_with_trailing_escaped_backslash.mysql.sql +1 -0
- data/test/fixtures/cross_agent_tests/sql_obfuscation/string_with_trailing_escaped_backslash_single_quoted.obfuscated +1 -0
- data/test/fixtures/cross_agent_tests/sql_obfuscation/string_with_trailing_escaped_backslash_single_quoted.sql +1 -0
- data/test/fixtures/cross_agent_tests/sql_obfuscation/string_with_trailing_escaped_quote.obfuscated +1 -0
- data/test/fixtures/cross_agent_tests/sql_obfuscation/string_with_trailing_escaped_quote.sql +1 -0
- data/test/fixtures/cross_agent_tests/sql_obfuscation/string_with_twin_single_quotes.obfuscated +1 -0
- data/test/fixtures/cross_agent_tests/sql_obfuscation/string_with_twin_single_quotes.sql +1 -0
- data/test/multiverse/lib/multiverse/output_collector.rb +1 -1
- data/test/multiverse/lib/multiverse/runner.rb +1 -1
- data/test/multiverse/lib/multiverse/suite.rb +19 -4
- data/test/multiverse/suites/agent_only/audit_log_test.rb +1 -38
- data/test/multiverse/suites/agent_only/collector_exception_handling_test.rb +25 -35
- data/test/multiverse/suites/agent_only/config/newrelic.yml +2 -0
- data/test/multiverse/suites/agent_only/encoding_handling_test.rb +1 -0
- data/test/multiverse/suites/agent_only/harvest_timestamps_test.rb +1 -1
- data/test/multiverse/suites/agent_only/keepalive_test.rb +29 -0
- data/test/multiverse/suites/agent_only/labels_test.rb +89 -0
- data/test/multiverse/suites/agent_only/marshaling_test.rb +1 -3
- data/test/multiverse/suites/agent_only/service_timeout_test.rb +1 -1
- data/test/multiverse/suites/agent_only/start_up_test.rb +9 -1
- data/test/multiverse/suites/capistrano/config/deploy.rb +6 -2
- data/test/multiverse/suites/capistrano/deployment_test.rb +12 -4
- data/test/multiverse/suites/config_file_loading/config_file_loading_test.rb +29 -1
- data/test/multiverse/suites/curb/Envfile +6 -2
- data/test/multiverse/suites/datamapper/Envfile +0 -4
- data/test/multiverse/suites/deferred_instrumentation/Envfile +0 -4
- data/test/multiverse/suites/deferred_instrumentation/sinatra_test.rb +1 -1
- data/test/multiverse/suites/excon/Envfile +5 -4
- data/test/multiverse/suites/excon/excon_test.rb +1 -1
- data/test/multiverse/suites/httpclient/Envfile +0 -4
- data/test/multiverse/suites/marshalling/Envfile +12 -0
- data/test/multiverse/suites/marshalling/config/newrelic.yml +20 -0
- data/test/multiverse/suites/marshalling/marshalling_test.rb +60 -0
- data/test/multiverse/suites/mongo/helpers/mongo_operation_tests.rb +1 -1
- data/test/multiverse/suites/mongo/helpers/mongo_replica_set.rb +1 -1
- data/test/multiverse/suites/mongo/helpers/mongo_server.rb +4 -4
- data/test/multiverse/suites/padrino/Envfile +0 -5
- data/test/multiverse/suites/padrino/padrino_test.rb +1 -1
- data/test/multiverse/suites/rack/rack_auto_instrumentation_test.rb +1 -1
- data/test/multiverse/suites/rails/gc_instrumentation_test.rb +2 -1
- data/test/multiverse/suites/rails/ignore_test.rb +22 -0
- data/test/multiverse/suites/rails/rails2_app/config/boot.rb +2 -2
- data/test/multiverse/suites/rails/rails2_app/config/routes.rb +1 -0
- data/test/multiverse/suites/resque/Envfile +0 -4
- data/test/multiverse/suites/sequel/Envfile +0 -5
- data/test/multiverse/suites/sinatra/sinatra_classic_test.rb +1 -1
- data/test/multiverse/suites/sinatra/sinatra_modular_test.rb +1 -1
- data/test/multiverse/suites/sinatra/sinatra_test_cases.rb +22 -0
- data/test/multiverse/suites/typhoeus/Envfile +1 -4
- data/test/new_relic/agent/agent/start_worker_thread_test.rb +1 -13
- data/test/new_relic/agent/agent_logger_test.rb +11 -0
- data/test/new_relic/agent/agent_test.rb +43 -20
- data/test/new_relic/agent/audit_logger_test.rb +7 -3
- data/test/new_relic/agent/commands/thread_profiler_session_test.rb +0 -1
- data/test/new_relic/agent/commands/xray_session_collection_test.rb +1 -1
- data/test/new_relic/agent/configuration/dotted_hash_test.rb +53 -0
- data/test/new_relic/agent/configuration/manager_test.rb +99 -6
- data/test/new_relic/agent/configuration/manual_source_test.rb +18 -0
- data/test/new_relic/agent/configuration/orphan_configuration_test.rb +1 -1
- data/test/new_relic/agent/configuration/yaml_source_test.rb +8 -4
- data/test/new_relic/agent/database/sql_obfuscation_test.rb +76 -0
- data/test/new_relic/agent/database_test.rb +2 -38
- data/test/new_relic/agent/error_collector/notice_error_test.rb +21 -3
- data/test/new_relic/agent/error_collector_test.rb +15 -2
- data/test/new_relic/agent/event_loop_test.rb +202 -0
- data/test/new_relic/agent/instrumentation/active_record_helper_test.rb +4 -0
- data/test/new_relic/agent/instrumentation/controller_instrumentation_test.rb +283 -182
- data/test/new_relic/agent/method_tracer_test.rb +1 -2
- data/test/new_relic/agent/new_relic_service_test.rb +83 -27
- data/test/new_relic/agent/pipe_channel_manager_test.rb +6 -6
- data/test/new_relic/agent/rpm_agent_test.rb +1 -8
- data/test/new_relic/agent/sql_sampler_test.rb +10 -8
- data/test/new_relic/agent/threading/backtrace_service_test.rb +1 -1
- data/test/new_relic/agent/traced_method_stack_test.rb +45 -13
- data/test/new_relic/agent/transaction_sample_builder_test.rb +1 -2
- data/test/new_relic/agent/transaction_test.rb +3 -3
- data/test/new_relic/agent_test.rb +47 -8
- data/test/new_relic/collection_helper_test.rb +5 -5
- data/test/new_relic/control/instrumentation_test.rb +56 -0
- data/test/new_relic/control_test.rb +4 -3
- data/test/new_relic/fake_collector.rb +7 -2
- data/test/new_relic/http_client_test_cases.rb +4 -4
- data/test/new_relic/latest_changes_test.rb +3 -3
- data/test/new_relic/transaction_sample/segment_test.rb +0 -1
- data/test/new_relic/transaction_sample_test.rb +19 -2
- data/test/performance/lib/performance/runner.rb +4 -4
- data/test/performance/suites/marshalling.rb +46 -30
- data/test/performance/suites/sql_obfuscation.rb +30 -0
- data/test/test_helper.rb +1 -1
- data/ui/helpers/developer_mode_helper.rb +2 -2
- data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/java.rb +1 -1
- data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/view.rb +1 -1
- metadata +84 -3
- metadata.gz.sig +0 -0
- data/test/environments/rails23/config/environments/development.rb +0 -11
@@ -176,8 +176,19 @@ module Multiverse
|
|
176
176
|
ENV['SERIALIZE'] || debug
|
177
177
|
end
|
178
178
|
|
179
|
+
def check_environment_condition
|
180
|
+
if environments.condition && !environments.condition.call
|
181
|
+
puts yellow("SKIPPED #{directory.inspect}: #{environments.skip_message}")
|
182
|
+
false
|
183
|
+
else
|
184
|
+
true
|
185
|
+
end
|
186
|
+
end
|
187
|
+
|
179
188
|
def prime
|
180
189
|
ENV["VERBOSE"]= "1"
|
190
|
+
return unless check_environment_condition
|
191
|
+
|
181
192
|
puts yellow("\nPriming #{directory.inspect}")
|
182
193
|
@environments = nil
|
183
194
|
|
@@ -196,10 +207,7 @@ module Multiverse
|
|
196
207
|
# implement #fork so we resort to a hack. We exec this lib file, which
|
197
208
|
# loads a new JVM for the tests to run in.
|
198
209
|
def execute
|
199
|
-
|
200
|
-
puts yellow("SKIPPED #{directory.inspect}: #{environments.skip_message}")
|
201
|
-
return
|
202
|
-
end
|
210
|
+
return unless check_environment_condition
|
203
211
|
|
204
212
|
label = should_serialize? ? 'serial' : 'parallel'
|
205
213
|
env_count = filter_env ? 1 : environments.size
|
@@ -212,6 +220,13 @@ module Multiverse
|
|
212
220
|
execute_parallel
|
213
221
|
end
|
214
222
|
environments.after.call if environments.after
|
223
|
+
rescue => e
|
224
|
+
puts red("Failure during execution of suite #{directory.inspect}.")
|
225
|
+
puts red("This typically is a result of a Ruby failure in your Envfile.")
|
226
|
+
puts
|
227
|
+
puts red(e.class)
|
228
|
+
puts red(e.message)
|
229
|
+
exit(1)
|
215
230
|
end
|
216
231
|
|
217
232
|
def execute_serial
|
@@ -23,43 +23,6 @@ class AuditLogTest < Minitest::Test
|
|
23
23
|
@contents
|
24
24
|
end
|
25
25
|
|
26
|
-
def assert_audit_log_contains(needle)
|
27
|
-
# Original request bodies dumped to the log have symbol keys, but once
|
28
|
-
# they go through a dump/load, they're strings again, so we strip
|
29
|
-
# double-quotes and colons from the log, and the strings we searching for.
|
30
|
-
regex = /[:"]/
|
31
|
-
needle = needle.gsub(regex, '')
|
32
|
-
haystack = audit_log_contents.gsub(regex, '')
|
33
|
-
assert(haystack.include?(needle), "Expected log to contain '#{needle}'")
|
34
|
-
end
|
35
|
-
|
36
|
-
# Because we don't generate a strictly machine-readable representation of
|
37
|
-
# request bodies for the audit log, the transformation into strings is
|
38
|
-
# effectively one-way. This, combined with the fact that Hash traversal order
|
39
|
-
# is arbitrary in Ruby 1.8.x means that it's difficult to directly assert that
|
40
|
-
# some object graph made it into the audit log (due to different possible
|
41
|
-
# orderings of the key/value pairs in Hashes that were embedded in the request
|
42
|
-
# body). So, this method traverses an object graph and only makes assertions
|
43
|
-
# about the terminal (non-Array-or-Hash) nodes therein.
|
44
|
-
def assert_audit_log_contains_object(o, format)
|
45
|
-
if format == :json
|
46
|
-
assert_audit_log_contains(JSON.dump(o))
|
47
|
-
else
|
48
|
-
case o
|
49
|
-
when Hash
|
50
|
-
o.each do |k,v|
|
51
|
-
assert_audit_log_contains_object(v, format)
|
52
|
-
end
|
53
|
-
when Array
|
54
|
-
o.each do |el|
|
55
|
-
assert_audit_log_contains_object(el, format)
|
56
|
-
end
|
57
|
-
else
|
58
|
-
assert_audit_log_contains(o.inspect)
|
59
|
-
end
|
60
|
-
end
|
61
|
-
end
|
62
|
-
|
63
26
|
def test_logs_nothing_by_default
|
64
27
|
run_agent do
|
65
28
|
perform_actions
|
@@ -79,7 +42,7 @@ class AuditLogTest < Minitest::Test
|
|
79
42
|
perform_actions
|
80
43
|
format = NewRelic::Agent::NewRelicService::JsonMarshaller.is_supported? ? :json : :pruby
|
81
44
|
$collector.agent_data.each do |req|
|
82
|
-
assert_audit_log_contains_object(req.body, format)
|
45
|
+
assert_audit_log_contains_object(audit_log_contents, req.body, format)
|
83
46
|
end
|
84
47
|
end
|
85
48
|
end
|
@@ -8,19 +8,30 @@ require 'open3'
|
|
8
8
|
class CollectorExceptionHandlingTest < Minitest::Test
|
9
9
|
include MultiverseHelpers
|
10
10
|
|
11
|
-
setup_and_teardown_agent
|
11
|
+
setup_and_teardown_agent do
|
12
|
+
NewRelic::Agent.agent.stubs(:sleep)
|
13
|
+
end
|
12
14
|
|
13
|
-
def
|
15
|
+
def after_setup
|
16
|
+
# there's a call to sleep in handle_force_restart that we want to skip
|
14
17
|
$collector.reset
|
18
|
+
end
|
19
|
+
|
20
|
+
|
21
|
+
RESTART_PAYLOAD = { 'error_type' => 'NewRelic::Agent::ForceRestartException' }
|
22
|
+
DISCONNECT_PAYLOAD = { 'error_type' => 'NewRelic::Agent::ForceDisconnectException' }
|
23
|
+
RUNTIME_ERROR_PAYLOAD = { 'error_type' => 'RuntimeError' }
|
24
|
+
|
25
|
+
|
26
|
+
def test_should_reconnect_on_force_restart_exception
|
27
|
+
# We stub these exceptions because we want the EventLoop to exit with a
|
28
|
+
# ForceRestartException the first time through, then (after reconnecting)
|
29
|
+
# we force the disconnect so that this test will end cleanly.
|
15
30
|
|
16
|
-
|
17
|
-
$collector.stub_exception('
|
31
|
+
$collector.stub_exception('metric_data' , RESTART_PAYLOAD ).once
|
32
|
+
$collector.stub_exception('get_agent_commands', DISCONNECT_PAYLOAD).once
|
18
33
|
|
19
34
|
with_config(:data_report_period => 0) do
|
20
|
-
worker_loop = NewRelic::Agent::WorkerLoop.new(:limit => 1)
|
21
|
-
NewRelic::Agent.agent.stubs(:create_worker_loop).returns(worker_loop)
|
22
|
-
# there's a call to sleep in handle_force_restart that we want to skip
|
23
|
-
NewRelic::Agent.agent.stubs(:sleep)
|
24
35
|
NewRelic::Agent.agent.deferred_work!({})
|
25
36
|
end
|
26
37
|
|
@@ -34,10 +45,7 @@ class CollectorExceptionHandlingTest < Minitest::Test
|
|
34
45
|
end
|
35
46
|
|
36
47
|
def test_should_stop_reporting_after_force_disconnect
|
37
|
-
$collector.
|
38
|
-
|
39
|
-
payload = { 'error_type' => 'NewRelic::Agent::ForceDisconnectException' }
|
40
|
-
$collector.stub_exception('metric_data', payload).once
|
48
|
+
$collector.stub_exception('metric_data', DISCONNECT_PAYLOAD).once
|
41
49
|
|
42
50
|
with_config(:data_report_period => 0) do
|
43
51
|
NewRelic::Agent.agent.deferred_work!({})
|
@@ -48,15 +56,9 @@ class CollectorExceptionHandlingTest < Minitest::Test
|
|
48
56
|
end
|
49
57
|
|
50
58
|
def test_should_stop_reporting_after_force_disconnect_on_connect
|
51
|
-
$collector.
|
52
|
-
|
53
|
-
payload = { 'error_type' => 'NewRelic::Agent::ForceDisconnectException' }
|
54
|
-
$collector.stub_exception('connect', payload).once
|
59
|
+
$collector.stub_exception('connect', DISCONNECT_PAYLOAD).once
|
55
60
|
|
56
61
|
with_config(:data_report_period => 0) do
|
57
|
-
worker_loop = NewRelic::Agent::WorkerLoop.new(:limit => 1)
|
58
|
-
NewRelic::Agent.agent.stubs(:create_worker_loop).returns(worker_loop)
|
59
|
-
NewRelic::Agent.agent.stubs(:sleep)
|
60
62
|
NewRelic::Agent.agent.deferred_work!({})
|
61
63
|
end
|
62
64
|
|
@@ -64,16 +66,10 @@ class CollectorExceptionHandlingTest < Minitest::Test
|
|
64
66
|
end
|
65
67
|
|
66
68
|
def test_should_reconnect_on_connect_exception
|
67
|
-
$collector.
|
68
|
-
|
69
|
-
payload = { 'error_type' => 'RuntimeError' }
|
70
|
-
$collector.stub_exception('connect', payload).once
|
69
|
+
$collector.stub_exception('connect', RUNTIME_ERROR_PAYLOAD).once
|
70
|
+
$collector.stub_exception('metric_data', DISCONNECT_PAYLOAD).once
|
71
71
|
|
72
72
|
with_config(:data_report_period => 0) do
|
73
|
-
worker_loop = NewRelic::Agent::WorkerLoop.new(:limit => 1)
|
74
|
-
NewRelic::Agent.agent.stubs(:create_worker_loop).returns(worker_loop)
|
75
|
-
# there's a call to sleep in connect that we want to skip
|
76
|
-
NewRelic::Agent.agent.stubs(:sleep)
|
77
73
|
NewRelic::Agent.agent.deferred_work!({})
|
78
74
|
end
|
79
75
|
|
@@ -81,16 +77,10 @@ class CollectorExceptionHandlingTest < Minitest::Test
|
|
81
77
|
end
|
82
78
|
|
83
79
|
def test_should_reconnect_on_get_redirect_host_exception
|
84
|
-
$collector.
|
85
|
-
|
86
|
-
payload = { 'error_type' => 'RuntimeError' }
|
87
|
-
$collector.stub_exception('get_redirect_host', payload).once
|
80
|
+
$collector.stub_exception('get_redirect_host', RUNTIME_ERROR_PAYLOAD).once
|
81
|
+
$collector.stub_exception('metric_data', DISCONNECT_PAYLOAD).once
|
88
82
|
|
89
83
|
with_config(:data_report_period => 0) do
|
90
|
-
worker_loop = NewRelic::Agent::WorkerLoop.new(:limit => 1)
|
91
|
-
NewRelic::Agent.agent.stubs(:create_worker_loop).returns(worker_loop)
|
92
|
-
# there's a call to sleep in connect that we want to skip
|
93
|
-
NewRelic::Agent.agent.stubs(:sleep)
|
94
84
|
NewRelic::Agent.agent.deferred_work!({})
|
95
85
|
end
|
96
86
|
|
@@ -88,6 +88,7 @@ class EncodingHandlingTest < Minitest::Test
|
|
88
88
|
|
89
89
|
def assert_endpoint_received_string(endpoint, string)
|
90
90
|
agent.send(:transmit_data)
|
91
|
+
agent.send(:transmit_transaction_event_data)
|
91
92
|
requests = $collector.calls_for(endpoint)
|
92
93
|
assert_equal(1, requests.size)
|
93
94
|
request = requests.first
|
@@ -0,0 +1,29 @@
|
|
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 'newrelic_rpm'
|
6
|
+
require 'multiverse_helpers'
|
7
|
+
|
8
|
+
class KeepaliveTest < Minitest::Test
|
9
|
+
include MultiverseHelpers
|
10
|
+
|
11
|
+
def test_can_reestablish_connection
|
12
|
+
setup_agent(:aggressive_keepalive => true)
|
13
|
+
|
14
|
+
NewRelic::Agent.agent.send(:transmit_data)
|
15
|
+
|
16
|
+
# This is the closest I can easily get to closing the underlying TCP
|
17
|
+
# connection from the server side in between harvests.
|
18
|
+
conn0 = NewRelic::Agent.agent.service.http_connection
|
19
|
+
conn0.instance_variable_get(:@socket).close
|
20
|
+
|
21
|
+
NewRelic::Agent.agent.send(:transmit_data)
|
22
|
+
|
23
|
+
conn1 = NewRelic::Agent.agent.service.http_connection
|
24
|
+
|
25
|
+
metric_data_calls = $collector.calls_for('metric_data')
|
26
|
+
assert_equal(2, metric_data_calls.size)
|
27
|
+
assert_same(conn0, conn1)
|
28
|
+
end
|
29
|
+
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 File.join(File.dirname(__FILE__), '..', '..', '..', 'agent_helper')
|
6
|
+
require 'fake_collector'
|
7
|
+
require 'multiverse_helpers'
|
8
|
+
|
9
|
+
class LabelsTest < Minitest::Test
|
10
|
+
include MultiverseHelpers
|
11
|
+
|
12
|
+
setup_and_teardown_agent
|
13
|
+
|
14
|
+
EXPECTED = [{'label_type' => 'Server', 'label_value' => 'East'}]
|
15
|
+
YML_EXPECTED = [{'label_type' => 'Server', 'label_value' => 'Yaml'}]
|
16
|
+
|
17
|
+
def after_setup
|
18
|
+
$collector.reset
|
19
|
+
make_sure_agent_reconnects({})
|
20
|
+
end
|
21
|
+
|
22
|
+
def test_yaml_makes_it_to_the_collector
|
23
|
+
# Relies on the agent_only/config/newrelic.yml!
|
24
|
+
NewRelic::Agent.manual_start
|
25
|
+
assert_connect_had_labels(YML_EXPECTED)
|
26
|
+
end
|
27
|
+
|
28
|
+
def test_labels_from_config_hash_make_it_to_the_collector
|
29
|
+
with_config("labels" => { "Server" => "East" }) do
|
30
|
+
NewRelic::Agent.manual_start
|
31
|
+
assert_connect_had_labels(EXPECTED)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
def test_labels_from_manual_start_hash_make_it_to_the_collector
|
36
|
+
NewRelic::Agent.manual_start(:labels => { "Server" => "East" })
|
37
|
+
assert_connect_had_labels(EXPECTED)
|
38
|
+
end
|
39
|
+
|
40
|
+
def test_numeric_values_for_labels
|
41
|
+
NewRelic::Agent.manual_start(:labels => { "Server" => 42 })
|
42
|
+
expected = [
|
43
|
+
{ 'label_type' => 'Server', 'label_value' => '42' }
|
44
|
+
]
|
45
|
+
assert_connect_had_labels(expected)
|
46
|
+
end
|
47
|
+
|
48
|
+
def test_boolean_values_for_labels
|
49
|
+
NewRelic::Agent.manual_start(:labels => { "Server" => true })
|
50
|
+
expected = [
|
51
|
+
{ 'label_type' => 'Server', 'label_value' => 'true' }
|
52
|
+
]
|
53
|
+
assert_connect_had_labels(expected)
|
54
|
+
end
|
55
|
+
|
56
|
+
# All testing of string parsed label pairs should go through the cross agent
|
57
|
+
# test file for labels. Our dictionary passing is custom to Ruby, though.
|
58
|
+
load_cross_agent_test("labels").each do |testcase|
|
59
|
+
define_method("test_#{testcase['name']}_from_config_string") do
|
60
|
+
with_config("labels" => testcase["labelString"]) do
|
61
|
+
NewRelic::Agent.manual_start
|
62
|
+
assert_connect_had_labels(testcase["expected"])
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
define_method("test_#{testcase['name']}_from_manual_start") do
|
67
|
+
NewRelic::Agent.manual_start(:labels => testcase["labelString"])
|
68
|
+
assert_connect_had_labels(testcase["expected"])
|
69
|
+
end
|
70
|
+
|
71
|
+
define_method("test_#{testcase['name']}_from_env") do
|
72
|
+
begin
|
73
|
+
# Value must be here before reset for EnvironmentSource to see it
|
74
|
+
ENV['NEW_RELIC_LABELS'] = testcase["labelString"]
|
75
|
+
NewRelic::Agent.config.reset_to_defaults
|
76
|
+
|
77
|
+
NewRelic::Agent.manual_start
|
78
|
+
assert_connect_had_labels(testcase["expected"])
|
79
|
+
ensure
|
80
|
+
ENV['NEW_RELIC_LABELS'] = nil
|
81
|
+
end
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
def assert_connect_had_labels(expected)
|
86
|
+
result = $collector.calls_for('connect').first['labels']
|
87
|
+
assert_equal expected, result
|
88
|
+
end
|
89
|
+
end
|
@@ -16,7 +16,7 @@ class MarshalingTest < Minitest::Test
|
|
16
16
|
end
|
17
17
|
|
18
18
|
def test_transaction_trace_marshaling
|
19
|
-
|
19
|
+
freeze_time
|
20
20
|
|
21
21
|
in_transaction do
|
22
22
|
trace_execution_scoped('a') do
|
@@ -31,8 +31,6 @@ class MarshalingTest < Minitest::Test
|
|
31
31
|
agent.service.connect
|
32
32
|
agent.send(:harvest_and_send_transaction_traces)
|
33
33
|
|
34
|
-
marshaller = agent.service.marshaller
|
35
|
-
|
36
34
|
actual = $collector.calls_for('transaction_sample_data')[0][1][0]
|
37
35
|
encoder = NewRelic::Agent::NewRelicService::Encoders::Identity
|
38
36
|
|
@@ -10,7 +10,7 @@ class StartUpTest < Minitest::Test
|
|
10
10
|
ruby = 'require "newrelic_rpm"; NewRelic::Agent.manual_start; NewRelic::Agent.shutdown'
|
11
11
|
cmd = "bundle exec ruby -e '#{ruby}'"
|
12
12
|
|
13
|
-
|
13
|
+
_sin, sout, serr = Open3.popen3(cmd)
|
14
14
|
output = sout.read + serr.read
|
15
15
|
|
16
16
|
expected_noise = [
|
@@ -30,4 +30,12 @@ class StartUpTest < Minitest::Test
|
|
30
30
|
problems = output.scan(/ERROR : .*/)
|
31
31
|
assert_empty problems
|
32
32
|
end
|
33
|
+
|
34
|
+
def test_after_fork_does_not_blow_away_manual_start_settings
|
35
|
+
NewRelic::Agent.manual_start(:app_name => 'my great app')
|
36
|
+
|
37
|
+
NewRelic::Agent.after_fork
|
38
|
+
|
39
|
+
assert_equal('my great app', NewRelic::Agent.config[:app_name])
|
40
|
+
end
|
33
41
|
end
|
@@ -6,5 +6,9 @@ set :application, 'test'
|
|
6
6
|
|
7
7
|
# Since Capistrano 3 doesn't allow settings direct from command-line, add any
|
8
8
|
# settings we want to conditionally toggle from tests in the following manner.
|
9
|
-
|
10
|
-
|
9
|
+
ENV.keys.each do |key|
|
10
|
+
if key.match(/NEWRELIC_CAPISTRANO_/)
|
11
|
+
name = key.gsub('NEWRELIC_CAPISTRANO_', '').downcase
|
12
|
+
set "newrelic_#{name}".to_sym, ENV[key]
|
13
|
+
end
|
14
|
+
end
|
@@ -4,6 +4,7 @@
|
|
4
4
|
|
5
5
|
require 'fake_rpm_site'
|
6
6
|
require 'multiverse_helpers'
|
7
|
+
require 'new_relic/cli/command'
|
7
8
|
|
8
9
|
class DeploymentTest < Minitest::Test
|
9
10
|
def setup
|
@@ -21,14 +22,21 @@ class DeploymentTest < Minitest::Test
|
|
21
22
|
# Capistrano 3 doesn't provide built-in commandline params -> settings
|
22
23
|
# We wire our own up via ENV to test setting out setting custom values
|
23
24
|
env = {
|
24
|
-
'
|
25
|
-
'
|
25
|
+
'NEWRELIC_CAPISTRANO_USER' => "Optimus Prime",
|
26
|
+
'NEWRELIC_CAPISTRANO_APPNAME' => "Tesseract",
|
27
|
+
'NEWRELIC_CAPISTRANO_REVISION' => "C-001",
|
28
|
+
'NEWRELIC_CAPISTRANO_CHANGELOG' => "The greatest weakness of most humans is their hesitancy to tell others they love them while they're alive.",
|
26
29
|
}
|
27
30
|
|
28
31
|
cap_it(env)
|
29
32
|
|
30
|
-
assert_deployment_value("user", "
|
31
|
-
assert_deployment_value("application_id", "
|
33
|
+
assert_deployment_value("user", "Optimus Prime")
|
34
|
+
assert_deployment_value("application_id", "Tesseract")
|
35
|
+
assert_deployment_value("revision", "C-001")
|
36
|
+
assert_deployment_value("changelog", "The greatest weakness of most humans is their hesitancy to tell others they love them while they're alive.")
|
37
|
+
end
|
38
|
+
|
39
|
+
def test_newrelic_revision_override
|
32
40
|
end
|
33
41
|
|
34
42
|
def assert_deployment_value(key, value)
|