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
@@ -1,11 +1,8 @@
|
|
1
|
-
suite_condition("Typhoeus
|
2
|
-
|
1
|
+
suite_condition("Typhoeus excluded on 1.8.7 non-REE") do
|
3
2
|
# Under Ruby 1.8.7 (but not REE), there are persistent segfaults with Typhoeus
|
4
3
|
# and the Ruby agent. This predated our Typhoeus instrumentation, but given
|
5
4
|
# usage levels and obscurity of the issue, it isn't worth deeper digging.
|
6
5
|
# Just use REE, or better yet >= 1.9
|
7
|
-
|
8
|
-
(RUBY_VERSION != '1.8.6') &&
|
9
6
|
(RUBY_VERSION != '1.8.7' || RUBY_DESCRIPTION =~ /Enterprise/)
|
10
7
|
end
|
11
8
|
|
@@ -11,8 +11,7 @@ class NewRelic::Agent::Agent::StartWorkerThreadTest < Minitest::Test
|
|
11
11
|
self.expects(:catch_errors).yields
|
12
12
|
self.expects(:connect).with('connection_options')
|
13
13
|
self.stubs(:connected?).returns(true)
|
14
|
-
self.expects(:
|
15
|
-
self.expects(:create_and_run_worker_loop)
|
14
|
+
self.expects(:create_and_run_event_loop)
|
16
15
|
deferred_work!('connection_options')
|
17
16
|
end
|
18
17
|
|
@@ -23,17 +22,6 @@ class NewRelic::Agent::Agent::StartWorkerThreadTest < Minitest::Test
|
|
23
22
|
deferred_work!('connection_options')
|
24
23
|
end
|
25
24
|
|
26
|
-
def test_create_and_run_worker_loop
|
27
|
-
@should_send_samples = true
|
28
|
-
wl = mock('worker loop')
|
29
|
-
NewRelic::Agent::WorkerLoop.expects(:new).returns(wl)
|
30
|
-
wl.expects(:run).with(30).yields
|
31
|
-
self.expects(:transmit_data)
|
32
|
-
with_config(:data_report_period => 30) do
|
33
|
-
create_and_run_worker_loop
|
34
|
-
end
|
35
|
-
end
|
36
|
-
|
37
25
|
def test_handle_force_restart
|
38
26
|
# hooray for methods with no branches
|
39
27
|
error = mock(:message => 'a message')
|
@@ -337,6 +337,17 @@ class AgentLoggerTest < Minitest::Test
|
|
337
337
|
)
|
338
338
|
end
|
339
339
|
|
340
|
+
def test_can_overwrite_log_formatter
|
341
|
+
log_message = 'How are you?'
|
342
|
+
log_formatter = Proc.new { |s, t, p, m| m.reverse }
|
343
|
+
|
344
|
+
logger = create_basic_logger
|
345
|
+
logger.log_formatter = log_formatter
|
346
|
+
logger.warn log_message
|
347
|
+
|
348
|
+
assert_logged log_message.reverse
|
349
|
+
end
|
350
|
+
|
340
351
|
#
|
341
352
|
# Helpers
|
342
353
|
#
|
@@ -311,15 +311,21 @@ module NewRelic
|
|
311
311
|
end
|
312
312
|
|
313
313
|
def test_connect_settings
|
314
|
-
|
315
|
-
|
316
|
-
|
317
|
-
|
318
|
-
|
319
|
-
|
320
|
-
|
321
|
-
|
322
|
-
|
314
|
+
expected = [
|
315
|
+
:pid,
|
316
|
+
:host,
|
317
|
+
:app_name,
|
318
|
+
:language,
|
319
|
+
:labels,
|
320
|
+
:agent_version,
|
321
|
+
:environment,
|
322
|
+
:settings,
|
323
|
+
:high_security
|
324
|
+
]
|
325
|
+
|
326
|
+
expected.each do |expect_key|
|
327
|
+
assert_includes @agent.connect_settings.keys, expect_key
|
328
|
+
end
|
323
329
|
end
|
324
330
|
|
325
331
|
def test_connect_settings_checks_environment_report_can_marshal
|
@@ -327,6 +333,23 @@ module NewRelic
|
|
327
333
|
assert_equal [], @agent.connect_settings[:environment]
|
328
334
|
end
|
329
335
|
|
336
|
+
def test_connect_settings_includes_labels_from_config
|
337
|
+
with_config({:labels => {'Server' => 'East'}}) do
|
338
|
+
expected = [ {"label_type"=>"Server", "label_value"=>"East"} ]
|
339
|
+
assert_equal expected, @agent.connect_settings[:labels]
|
340
|
+
end
|
341
|
+
end
|
342
|
+
|
343
|
+
def test_connect_settings_includes_labels_from_semicolon_separated_config
|
344
|
+
with_config(:labels => "Server:East;Server:West;") do
|
345
|
+
expected = [
|
346
|
+
{"label_type"=>"Server", "label_value"=>"East"},
|
347
|
+
{"label_type"=>"Server", "label_value"=>"West"}
|
348
|
+
]
|
349
|
+
assert_equal expected, @agent.connect_settings[:labels]
|
350
|
+
end
|
351
|
+
end
|
352
|
+
|
330
353
|
def test_defer_start_if_resque_dispatcher_and_channel_manager_isnt_started_and_forkable
|
331
354
|
NewRelic::LanguageSupport.stubs(:can_fork?).returns(true)
|
332
355
|
NewRelic::Agent::PipeChannelManager.listener.stubs(:started?).returns(false)
|
@@ -514,37 +537,37 @@ module NewRelic
|
|
514
537
|
end
|
515
538
|
end
|
516
539
|
|
517
|
-
def
|
540
|
+
def test_stop_event_loop_runs_loop_before_exit_with_force_send_config
|
518
541
|
fake_loop = mock
|
519
|
-
fake_loop.expects(:
|
542
|
+
fake_loop.expects(:run_once)
|
520
543
|
fake_loop.stubs(:stop)
|
521
544
|
|
522
|
-
@agent.instance_variable_set(:@
|
545
|
+
@agent.instance_variable_set(:@event_loop, fake_loop)
|
523
546
|
|
524
547
|
with_config(:force_send => true) do
|
525
|
-
@agent.
|
548
|
+
@agent.stop_event_loop
|
526
549
|
end
|
527
550
|
end
|
528
551
|
|
529
|
-
def
|
552
|
+
def test_stop_event_loop_doesnt_run_loop_if_force_send_is_false
|
530
553
|
fake_loop = mock
|
531
|
-
fake_loop.expects(:
|
554
|
+
fake_loop.expects(:run_once).never
|
532
555
|
fake_loop.stubs(:stop)
|
533
556
|
|
534
|
-
@agent.instance_variable_set(:@
|
557
|
+
@agent.instance_variable_set(:@event_loop, fake_loop)
|
535
558
|
|
536
559
|
with_config(:force_send => false) do
|
537
|
-
@agent.
|
560
|
+
@agent.stop_event_loop
|
538
561
|
end
|
539
562
|
end
|
540
563
|
|
541
|
-
def
|
564
|
+
def test_stop_event_loop_stops_the_loop
|
542
565
|
fake_loop = mock
|
543
566
|
fake_loop.expects(:stop)
|
544
567
|
|
545
|
-
@agent.instance_variable_set(:@
|
568
|
+
@agent.instance_variable_set(:@event_loop, fake_loop)
|
546
569
|
|
547
|
-
@agent.
|
570
|
+
@agent.stop_event_loop
|
548
571
|
end
|
549
572
|
|
550
573
|
def test_untraced_graceful_disconnect_logs_errors
|
@@ -32,9 +32,13 @@ class AuditLoggerTest < Minitest::Test
|
|
32
32
|
end
|
33
33
|
|
34
34
|
def assert_log_contains_string(str)
|
35
|
+
log_body = read_log_body
|
36
|
+
assert(log_body.include?(str), "Expected log to contain string '#{str}'\nLog body was: #{log_body}")
|
37
|
+
end
|
38
|
+
|
39
|
+
def read_log_body
|
35
40
|
@fakelog.rewind
|
36
|
-
|
37
|
-
assert(log_body.include?(str), "Expected log to contain string '#{str}'")
|
41
|
+
@fakelog.read
|
38
42
|
end
|
39
43
|
|
40
44
|
def test_never_setup_if_disabled
|
@@ -117,7 +121,7 @@ class AuditLoggerTest < Minitest::Test
|
|
117
121
|
setup_fake_logger
|
118
122
|
json_marshaller = marshaller_cls.new
|
119
123
|
@logger.log_request(@uri, @dummy_data, json_marshaller)
|
120
|
-
|
124
|
+
assert_audit_log_contains_object(read_log_body, @dummy_data, :json)
|
121
125
|
end
|
122
126
|
end
|
123
127
|
|
@@ -63,7 +63,6 @@ if !NewRelic::Agent::Threading::BacktraceService.is_supported?
|
|
63
63
|
end
|
64
64
|
|
65
65
|
def test_wont_start_and_reports_error
|
66
|
-
errors = nil
|
67
66
|
assert_raises NewRelic::Agent::Commands::AgentCommandRouter::AgentCommandError do
|
68
67
|
@profiler.handle_start_command(start_command)
|
69
68
|
end
|
@@ -0,0 +1,53 @@
|
|
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.expand_path(File.join(File.dirname(__FILE__),'..','..','..','test_helper'))
|
6
|
+
|
7
|
+
module NewRelic::Agent::Configuration
|
8
|
+
class DottedHashTest < Minitest::Test
|
9
|
+
def test_without_nesting
|
10
|
+
hash = DottedHash.new({ :turtle => 1 })
|
11
|
+
assert_equal({ :turtle => 1 }, hash)
|
12
|
+
end
|
13
|
+
|
14
|
+
def test_with_nesting
|
15
|
+
hash = DottedHash.new({ :turtle => { :turtle => 1 } })
|
16
|
+
assert_equal({ :'turtle.turtle' => 1 }, hash)
|
17
|
+
end
|
18
|
+
|
19
|
+
def test_with_multiple_layers_of_nesting
|
20
|
+
hash = DottedHash.new({ :turtle => { :turtle => { :turtle => 1 } } })
|
21
|
+
assert_equal({ :'turtle.turtle.turtle' => 1 }, hash)
|
22
|
+
end
|
23
|
+
|
24
|
+
def test_turns_keys_to_symbols
|
25
|
+
hash = DottedHash.new({ "turtle" => { "turtle" => { "turtle" => 1 } } })
|
26
|
+
assert_equal({ :'turtle.turtle.turtle' => 1 }, hash)
|
27
|
+
end
|
28
|
+
|
29
|
+
def test_to_hash
|
30
|
+
dotted = DottedHash.new({ "turtle" => { "turtle" => { "turtle" => 1 } } })
|
31
|
+
hash = dotted.to_hash
|
32
|
+
|
33
|
+
assert_instance_of(Hash, hash)
|
34
|
+
assert_equal({ :'turtle.turtle.turtle' => 1 }, hash)
|
35
|
+
end
|
36
|
+
|
37
|
+
def test_option_to_keep_nesting
|
38
|
+
hash = DottedHash.new({ :turtle => { :turtle => 1 } }, true)
|
39
|
+
expected = {
|
40
|
+
:turtle => { :turtle => 1},
|
41
|
+
:'turtle.turtle' => 1,
|
42
|
+
}
|
43
|
+
|
44
|
+
assert_equal(expected, hash)
|
45
|
+
end
|
46
|
+
|
47
|
+
def test_borks_with_non_symbolizing_key
|
48
|
+
assert_raises(NoMethodError) do
|
49
|
+
DottedHash.new({ Object.new => 2 }, true)
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
@@ -32,11 +32,11 @@ module NewRelic::Agent::Configuration
|
|
32
32
|
:bar => 'default bar',
|
33
33
|
:baz => 'default baz'
|
34
34
|
}
|
35
|
-
@manager.add_config_for_testing(config0)
|
36
|
-
config1 = { :foo => '
|
35
|
+
@manager.add_config_for_testing(config0, false)
|
36
|
+
config1 = { :foo => 'wrong foo', :bar => 'real bar' }
|
37
37
|
@manager.add_config_for_testing(config1)
|
38
|
-
config2 = { :foo => '
|
39
|
-
@manager.add_config_for_testing(config2
|
38
|
+
config2 = { :foo => 'real foo' }
|
39
|
+
@manager.add_config_for_testing(config2)
|
40
40
|
|
41
41
|
assert_equal 'real foo' , @manager['foo']
|
42
42
|
assert_equal 'real bar' , @manager['bar']
|
@@ -63,7 +63,7 @@ module NewRelic::Agent::Configuration
|
|
63
63
|
|
64
64
|
def test_identifying_config_source
|
65
65
|
hash_source = {:foo => 'foo', :bar => 'default'}
|
66
|
-
@manager.add_config_for_testing(hash_source,
|
66
|
+
@manager.add_config_for_testing(hash_source, false)
|
67
67
|
test_source = ManualSource.new(:bar => 'bar', :baz => 'baz')
|
68
68
|
@manager.replace_or_add_config(test_source)
|
69
69
|
|
@@ -109,7 +109,7 @@ module NewRelic::Agent::Configuration
|
|
109
109
|
def test_should_read_license_key_from_env
|
110
110
|
ENV['NEWRELIC_LICENSE_KEY'] = 'right'
|
111
111
|
manager = NewRelic::Agent::Configuration::Manager.new
|
112
|
-
manager.add_config_for_testing({:license_key => 'wrong'},
|
112
|
+
manager.add_config_for_testing({:license_key => 'wrong'}, false)
|
113
113
|
|
114
114
|
assert_equal 'right', manager['license_key']
|
115
115
|
ensure
|
@@ -282,5 +282,98 @@ module NewRelic::Agent::Configuration
|
|
282
282
|
refute @manager.config_classes_for_testing.include?(YamlSource)
|
283
283
|
refute @manager.config_classes_for_testing.include?(HighSecuritySource)
|
284
284
|
end
|
285
|
+
|
286
|
+
load_cross_agent_test("labels").each do |testcase|
|
287
|
+
define_method("test_#{testcase['name']}") do
|
288
|
+
@manager.add_config_for_testing(:labels => testcase["labelString"])
|
289
|
+
|
290
|
+
assert_warning if testcase["warning"]
|
291
|
+
assert_equal(testcase["expected"], @manager.parse_labels_from_string)
|
292
|
+
end
|
293
|
+
end
|
294
|
+
|
295
|
+
def test_parse_labels_from_dictionary_with_hard_failure
|
296
|
+
bad_label_object = Object.new
|
297
|
+
@manager.add_config_for_testing(:labels => bad_label_object)
|
298
|
+
|
299
|
+
assert_parsing_error
|
300
|
+
assert_parsed_labels([])
|
301
|
+
end
|
302
|
+
|
303
|
+
def test_parse_labels_from_string_with_hard_failure
|
304
|
+
bad_string = "baaaad"
|
305
|
+
bad_string.stubs(:gsub).raises("Booom")
|
306
|
+
@manager.add_config_for_testing(:labels => bad_string)
|
307
|
+
|
308
|
+
assert_parsing_error
|
309
|
+
assert_parsed_labels([])
|
310
|
+
end
|
311
|
+
|
312
|
+
def test_parse_labels_from_dictionary
|
313
|
+
@manager.add_config_for_testing(:labels => { 'Server' => 'East', 'Data Center' => 'North' })
|
314
|
+
|
315
|
+
assert_parsed_labels([
|
316
|
+
{ 'label_type' => 'Server', 'label_value' => 'East' },
|
317
|
+
{ 'label_type' => 'Data Center', 'label_value' => 'North' }
|
318
|
+
])
|
319
|
+
end
|
320
|
+
|
321
|
+
def test_parse_labels_from_dictionary_applies_length_limits
|
322
|
+
@manager.add_config_for_testing(:labels => { 'K' * 256 => 'V' * 256 })
|
323
|
+
expected = [ { 'label_type' => 'K' * 255, 'label_value' => 'V' * 255 } ]
|
324
|
+
|
325
|
+
expects_logging(:warn, includes("truncated"))
|
326
|
+
assert_parsed_labels(expected)
|
327
|
+
end
|
328
|
+
|
329
|
+
def test_parse_labels_from_dictionary_disallows_further_nested_hashes
|
330
|
+
@manager.add_config_for_testing(:labels => {
|
331
|
+
"More Nesting" => { "Hahaha" => "Ha" }
|
332
|
+
})
|
333
|
+
|
334
|
+
assert_warning
|
335
|
+
assert_parsed_labels([])
|
336
|
+
end
|
337
|
+
|
338
|
+
def test_parse_labels_from_dictionary_allows_numerics
|
339
|
+
@manager.add_config_for_testing(:labels => {
|
340
|
+
"the answer" => 42
|
341
|
+
})
|
342
|
+
|
343
|
+
expected = [{ 'label_type' => 'the answer', 'label_value' => '42' }]
|
344
|
+
assert_parsed_labels(expected)
|
345
|
+
end
|
346
|
+
|
347
|
+
def test_parse_labels_from_dictionary_allows_booleans
|
348
|
+
@manager.add_config_for_testing(:labels => {
|
349
|
+
"truthy" => true,
|
350
|
+
"falsy" => false
|
351
|
+
})
|
352
|
+
|
353
|
+
expected = [
|
354
|
+
{ 'label_type' => 'truthy', 'label_value' => 'true' },
|
355
|
+
{ 'label_type' => 'falsy', 'label_value' => 'false' }
|
356
|
+
]
|
357
|
+
assert_parsed_labels(expected)
|
358
|
+
end
|
359
|
+
|
360
|
+
def assert_parsed_labels(expected)
|
361
|
+
result = @manager.parsed_labels
|
362
|
+
|
363
|
+
# 1.8.7 hash ordering means we can't directly compare. Lean on the
|
364
|
+
# structure and flattened array sorting to do the comparison we need.
|
365
|
+
result = result.map(&:to_a).sort
|
366
|
+
expected = expected.map(&:to_a).sort
|
367
|
+
|
368
|
+
assert_equal expected, result
|
369
|
+
end
|
370
|
+
|
371
|
+
def assert_warning
|
372
|
+
expects_logging(:warn, any_parameters, any_parameters)
|
373
|
+
end
|
374
|
+
|
375
|
+
def assert_parsing_error
|
376
|
+
expects_logging(:error, includes(Manager::PARSING_LABELS_FAILURE), any_parameters)
|
377
|
+
end
|
285
378
|
end
|
286
379
|
end
|
@@ -0,0 +1,18 @@
|
|
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.expand_path(File.join(File.dirname(__FILE__),'..','..','..','test_helper'))
|
6
|
+
|
7
|
+
module NewRelic::Agent::Configuration
|
8
|
+
class ManualSourceTest < Minitest::Test
|
9
|
+
def test_prepopulates_nested_keys
|
10
|
+
source = ManualSource.new({ :outer => { :inner => "stuff" } })
|
11
|
+
expected = {
|
12
|
+
:outer => { :inner => "stuff" },
|
13
|
+
:'outer.inner' => "stuff"
|
14
|
+
}
|
15
|
+
assert_equal(expected, source)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -33,7 +33,7 @@ class OrphanedConfigTest < Minitest::Test
|
|
33
33
|
end
|
34
34
|
end
|
35
35
|
|
36
|
-
AGENT_CONFIG_PATTERN = /Agent\.config\[:['"]?([a-z\._]+)['"]?\]/
|
36
|
+
AGENT_CONFIG_PATTERN = /Agent\.config\[:['"]?([a-z\._]+)['"]?\s*\]/
|
37
37
|
REGISTER_CALLBACK_PATTERN = /register_callback\(:['"]?([a-z\._]+)['"]?\)/
|
38
38
|
NAMED_DEPENDENCY_PATTERN = /^\s*named[ (]+\:?([a-z\._]+).*$/
|
39
39
|
|
@@ -44,6 +44,10 @@ module NewRelic::Agent::Configuration
|
|
44
44
|
assert_equal 'raw', @source[:'transaction_tracer.record_sql']
|
45
45
|
end
|
46
46
|
|
47
|
+
def test_should_still_have_nested_hashes_around
|
48
|
+
refute_nil @source[:transaction_tracer]
|
49
|
+
end
|
50
|
+
|
47
51
|
def test_should_ignore_apdex_f_setting_for_transaction_threshold
|
48
52
|
assert_equal nil, @source[:'transaction_tracer.transaction_threshold']
|
49
53
|
end
|
@@ -59,18 +63,18 @@ module NewRelic::Agent::Configuration
|
|
59
63
|
|
60
64
|
def test_should_log_if_no_file_is_found
|
61
65
|
expects_logging(:warn, any_parameters)
|
62
|
-
|
66
|
+
YamlSource.new('no_such_file.yml', 'test')
|
63
67
|
end
|
64
68
|
|
65
69
|
def test_should_log_if_environment_is_not_present
|
66
70
|
expects_logging(:error, any_parameters)
|
67
|
-
|
71
|
+
YamlSource.new(@test_yml_path, 'nonsense')
|
68
72
|
end
|
69
73
|
|
70
74
|
def test_should_not_fail_to_log_missing_file_during_startup
|
71
75
|
without_logger do
|
72
76
|
::NewRelic::Agent::StartupLogger.any_instance.expects(:warn)
|
73
|
-
|
77
|
+
YamlSource.new('no_such_file.yml', 'test')
|
74
78
|
end
|
75
79
|
end
|
76
80
|
|
@@ -81,7 +85,7 @@ module NewRelic::Agent::Configuration
|
|
81
85
|
File.stubs(:exists?).returns(true)
|
82
86
|
File.stubs(:read).raises(StandardError.new("boo"))
|
83
87
|
|
84
|
-
|
88
|
+
YamlSource.new('fake.yml', 'test')
|
85
89
|
end
|
86
90
|
end
|
87
91
|
|