newrelic_rpm 3.5.2.17 → 3.5.3.24

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of newrelic_rpm might be problematic. Click here for more details.

Files changed (134) hide show
  1. data/.travis.yml +3 -1
  2. data/CHANGELOG +39 -23
  3. data/GUIDELINES_FOR_CONTRIBUTING.md +23 -2
  4. data/Rakefile +32 -0
  5. data/lib/new_relic/agent.rb +1 -0
  6. data/lib/new_relic/agent/agent.rb +45 -6
  7. data/lib/new_relic/agent/browser_monitoring.rb +36 -20
  8. data/lib/new_relic/agent/busy_calculator.rb +12 -4
  9. data/lib/new_relic/agent/configuration/defaults.rb +6 -1
  10. data/lib/new_relic/agent/configuration/environment_source.rb +14 -0
  11. data/lib/new_relic/agent/instrumentation/sinatra.rb +14 -10
  12. data/lib/new_relic/agent/new_relic_service.rb +192 -34
  13. data/lib/new_relic/agent/pipe_channel_manager.rb +1 -2
  14. data/lib/new_relic/agent/pipe_service.rb +5 -1
  15. data/lib/new_relic/agent/samplers/memory_sampler.rb +1 -1
  16. data/lib/new_relic/agent/sql_sampler.rb +29 -10
  17. data/lib/new_relic/agent/stats_engine/metric_stats.rb +40 -0
  18. data/lib/new_relic/agent/stats_engine/samplers.rb +1 -2
  19. data/lib/new_relic/agent/thread.rb +27 -0
  20. data/lib/new_relic/agent/thread_profiler.rb +295 -0
  21. data/lib/new_relic/agent/worker_loop.rb +29 -15
  22. data/lib/new_relic/control/frameworks/rails.rb +4 -4
  23. data/lib/new_relic/control/frameworks/rails3.rb +1 -1
  24. data/lib/new_relic/helper.rb +3 -0
  25. data/lib/new_relic/metric_data.rb +10 -2
  26. data/lib/new_relic/noticed_error.rb +5 -0
  27. data/lib/new_relic/transaction_sample.rb +23 -13
  28. data/lib/new_relic/transaction_sample/segment.rb +13 -15
  29. data/lib/new_relic/version.rb +1 -1
  30. data/lib/tasks/tests.rake +5 -11
  31. data/test/multiverse/.gitignore +10 -0
  32. data/test/multiverse/README.md +90 -0
  33. data/test/multiverse/Rakefile +17 -0
  34. data/test/multiverse/lib/multiverse/color.rb +13 -0
  35. data/test/multiverse/lib/multiverse/envfile.rb +66 -0
  36. data/test/multiverse/lib/multiverse/environment.rb +16 -0
  37. data/test/multiverse/lib/multiverse/output_collector.rb +29 -0
  38. data/test/multiverse/lib/multiverse/runner.rb +44 -0
  39. data/test/multiverse/lib/multiverse/suite.rb +162 -0
  40. data/test/multiverse/script/run_one +3 -0
  41. data/test/multiverse/script/runner +9 -0
  42. data/test/multiverse/suites/active_record/Envfile +13 -0
  43. data/test/multiverse/suites/active_record/ar_method_aliasing.rb +94 -0
  44. data/test/multiverse/suites/active_record/config/newrelic.yml +22 -0
  45. data/test/multiverse/suites/active_record/encoding_test.rb +26 -0
  46. data/test/multiverse/suites/agent_only/Envfile +3 -0
  47. data/test/multiverse/suites/agent_only/config/newrelic.yml +22 -0
  48. data/test/multiverse/suites/agent_only/http_response_code_test.rb +53 -0
  49. data/test/multiverse/suites/agent_only/marshaling_test.rb +109 -0
  50. data/test/multiverse/suites/agent_only/method_visibility_test.rb +98 -0
  51. data/test/multiverse/suites/agent_only/pipe_manager_test.rb +33 -0
  52. data/test/multiverse/suites/agent_only/service_timeout_test.rb +29 -0
  53. data/test/multiverse/suites/agent_only/test_trace_method_with_punctuation.rb +30 -0
  54. data/test/multiverse/suites/agent_only/test_trace_transaction_with_punctuation.rb +32 -0
  55. data/test/multiverse/suites/agent_only/thread_profiling_test.rb +80 -0
  56. data/test/multiverse/suites/datamapper/Envfile +8 -0
  57. data/test/multiverse/suites/datamapper/config/newrelic.yml +22 -0
  58. data/test/multiverse/suites/datamapper/encoding_test.rb +36 -0
  59. data/test/multiverse/suites/monitor_mode_false/Envfile +2 -0
  60. data/test/multiverse/suites/monitor_mode_false/config/newrelic.yml +25 -0
  61. data/test/multiverse/suites/monitor_mode_false/no_dns_resolv.rb +29 -0
  62. data/test/multiverse/suites/no_load/Envfile +2 -0
  63. data/test/multiverse/suites/no_load/config/newrelic.yml +23 -0
  64. data/test/multiverse/suites/no_load/start_up_test.rb +14 -0
  65. data/test/multiverse/suites/rails_3_error_tracing/Envfile +15 -0
  66. data/test/multiverse/suites/rails_3_error_tracing/config/newrelic.yml +165 -0
  67. data/test/multiverse/suites/rails_3_error_tracing/error_tracing_test.rb +236 -0
  68. data/test/multiverse/suites/rails_3_gc/Envfile +8 -0
  69. data/test/multiverse/suites/rails_3_gc/config/newrelic.yml +167 -0
  70. data/test/multiverse/suites/rails_3_gc/instrumentation_test.rb +92 -0
  71. data/test/multiverse/suites/rails_3_queue_time/Envfile +15 -0
  72. data/test/multiverse/suites/rails_3_queue_time/config/newrelic.yml +165 -0
  73. data/test/multiverse/suites/rails_3_queue_time/queue_time_test.rb +75 -0
  74. data/test/multiverse/suites/rails_3_views/.gitignore +3 -0
  75. data/test/multiverse/suites/rails_3_views/Envfile +16 -0
  76. data/test/multiverse/suites/rails_3_views/app/views/foos/_foo.html.haml +1 -0
  77. data/test/multiverse/suites/rails_3_views/app/views/test/_a_partial.html.erb +1 -0
  78. data/test/multiverse/suites/rails_3_views/app/views/test/_mid_partial.html.erb +1 -0
  79. data/test/multiverse/suites/rails_3_views/app/views/test/_top_partial.html.erb +3 -0
  80. data/test/multiverse/suites/rails_3_views/app/views/test/deep_partial.html.erb +3 -0
  81. data/test/multiverse/suites/rails_3_views/app/views/test/haml_view.html.haml +6 -0
  82. data/test/multiverse/suites/rails_3_views/app/views/test/index.html.erb +4 -0
  83. data/test/multiverse/suites/rails_3_views/config/newrelic.yml +164 -0
  84. data/test/multiverse/suites/rails_3_views/view_instrumentation_test.rb +245 -0
  85. data/test/multiverse/suites/resque/Envfile +21 -0
  86. data/test/multiverse/suites/resque/config/newrelic.yml +22 -0
  87. data/test/multiverse/suites/resque/dump.rdb +0 -0
  88. data/test/multiverse/suites/resque/instrumentation_test.rb +73 -0
  89. data/test/multiverse/suites/rum_auto_instrumentation/Envfile +4 -0
  90. data/test/multiverse/suites/rum_auto_instrumentation/config/newrelic.yml +24 -0
  91. data/test/multiverse/suites/rum_auto_instrumentation/problem_response.html +422 -0
  92. data/test/multiverse/suites/rum_auto_instrumentation/responses/worst_case_small.html +5000 -0
  93. data/test/multiverse/suites/rum_auto_instrumentation/sanity_test.rb +115 -0
  94. data/test/multiverse/suites/sinatra/Envfile +13 -0
  95. data/test/multiverse/suites/sinatra/config/newrelic.yml +24 -0
  96. data/test/multiverse/suites/sinatra/sinatra_metric_explosion_test.rb +76 -0
  97. data/test/multiverse/suites/sinatra/sinatra_routes_test.rb +46 -0
  98. data/test/multiverse/test/multiverse_test.rb +55 -0
  99. data/test/multiverse/test/suite_examples/one/a/Envfile +3 -0
  100. data/test/multiverse/test/suite_examples/one/a/a_test.rb +11 -0
  101. data/test/multiverse/test/suite_examples/one/a/config/newrelic.yml +24 -0
  102. data/test/multiverse/test/suite_examples/one/b/Envfile +3 -0
  103. data/test/multiverse/test/suite_examples/one/b/b_test.rb +11 -0
  104. data/test/multiverse/test/suite_examples/one/b/config/newrelic.yml +24 -0
  105. data/test/multiverse/test/suite_examples/three/a/Envfile +2 -0
  106. data/test/multiverse/test/suite_examples/three/a/fail_test.rb +6 -0
  107. data/test/multiverse/test/suite_examples/three/b/Envfile +2 -0
  108. data/test/multiverse/test/suite_examples/three/b/win_test.rb +6 -0
  109. data/test/multiverse/test/suite_examples/two/a/Envfile +1 -0
  110. data/test/multiverse/test/suite_examples/two/a/fail_test.rb +6 -0
  111. data/test/new_relic/agent/agent_test.rb +54 -2
  112. data/test/new_relic/agent/agent_test_controller.rb +1 -1
  113. data/test/new_relic/agent/agent_test_controller_test.rb +35 -5
  114. data/test/new_relic/agent/browser_monitoring_test.rb +8 -8
  115. data/test/new_relic/agent/configuration/environment_source_test.rb +16 -0
  116. data/test/new_relic/agent/method_tracer_test.rb +6 -6
  117. data/test/new_relic/agent/new_relic_service_test.rb +137 -20
  118. data/test/new_relic/agent/sql_sampler_test.rb +26 -0
  119. data/test/new_relic/agent/stats_engine/metric_stats_test.rb +1 -1
  120. data/test/new_relic/agent/stats_engine_test.rb +1 -0
  121. data/test/new_relic/agent/thread_profiler_test.rb +536 -0
  122. data/test/new_relic/agent/thread_test.rb +76 -0
  123. data/test/new_relic/agent/threaded_test.rb +65 -0
  124. data/test/new_relic/agent/transaction_sampler_test.rb +16 -13
  125. data/test/new_relic/agent/worker_loop_test.rb +20 -0
  126. data/test/new_relic/fake_collector.rb +103 -31
  127. data/test/new_relic/fake_service.rb +7 -1
  128. data/test/new_relic/metric_data_test.rb +45 -16
  129. data/test/new_relic/noticed_error_test.rb +14 -0
  130. data/test/new_relic/transaction_sample/segment_test.rb +23 -4
  131. data/test/new_relic/transaction_sample_test.rb +39 -0
  132. data/ui/views/layouts/newrelic_default.rhtml +1 -0
  133. data/ui/views/newrelic/threads.rhtml +2 -10
  134. metadata +88 -2
@@ -0,0 +1,22 @@
1
+ ---
2
+ development:
3
+ error_collector:
4
+ capture_source: true
5
+ enabled: true
6
+ apdex_t: 0.5
7
+ ssl: false
8
+ monitor_mode: true
9
+ license_key: bootstrap_newrelic_admin_license_key_000
10
+ developer_mode: false
11
+ app_name: test
12
+ host: 127.0.0.1
13
+ api_host: 127.0.0.1
14
+ port: 30303
15
+ transaction_tracer:
16
+ record_sql: obfuscated
17
+ enabled: true
18
+ stack_trace_threshold: 0.5
19
+ transaction_threshold: 1.0
20
+ capture_params: false
21
+ log_level: debug
22
+ log_file_path: agent.log
@@ -0,0 +1,26 @@
1
+ # https://support.newrelic.com/tickets/2101
2
+ # https://github.com/newrelic/rpm/pull/42
3
+ # https://github.com/newrelic/rpm/pull/45
4
+ require 'new_relic/agent/instrumentation/active_record'
5
+
6
+ class DatabaseAdapter
7
+ # we patch in here
8
+ def log(*args)
9
+ end
10
+ include ::NewRelic::Agent::Instrumentation::ActiveRecord
11
+ end
12
+
13
+ class EncodingTest < Test::Unit::TestCase
14
+
15
+ def test_should_not_bomb_out_if_a_query_is_in_an_invalid_encoding
16
+ # Contains invalid UTF8 Byte
17
+ query = "select ICS95095010000000000083320000BS01030000004100+\xFF00000000000000000"
18
+ if RUBY_VERSION >= '1.9'
19
+ # Force the query to an invalid encoding
20
+ query.force_encoding 'UTF-8'
21
+ assert_equal false, query.valid_encoding?
22
+ end
23
+ db = DatabaseAdapter.new
24
+ db.send(:log, query)
25
+ end
26
+ end
@@ -0,0 +1,3 @@
1
+ gemfile <<-RB
2
+ gem 'rack'
3
+ RB
@@ -0,0 +1,22 @@
1
+ ---
2
+ development:
3
+ error_collector:
4
+ capture_source: true
5
+ enabled: true
6
+ apdex_t: 0.5
7
+ ssl: false
8
+ monitor_mode: true
9
+ license_key: bootstrap_newrelic_admin_license_key_000
10
+ developer_mode: false
11
+ app_name: test
12
+ host: 127.0.0.1
13
+ api_host: 127.0.0.1
14
+ port: 30303
15
+ transaction_tracer:
16
+ record_sql: obfuscated
17
+ enabled: true
18
+ stack_trace_threshold: 0.5
19
+ transaction_threshold: 1.0
20
+ capture_params: false
21
+ log_level: debug
22
+ log_file_path: agent.log
@@ -0,0 +1,53 @@
1
+ # https://newrelic.atlassian.net/browse/RUBY-765
2
+ require 'fake_collector'
3
+
4
+ class HttpResponseCodeTest < Test::Unit::TestCase
5
+ def setup
6
+ $collector ||= NewRelic::FakeCollector.new
7
+ $collector.reset
8
+ $collector.run
9
+ NewRelic::Agent.manual_start(:send_data_on_exit => false)
10
+ @agent = NewRelic::Agent.instance
11
+ end
12
+
13
+ def teardown
14
+ $collector.reset
15
+ NewRelic::Agent.shutdown
16
+ end
17
+
18
+ def test_request_entity_too_large
19
+ $collector.mock['metric_data'] = [413, {'exception' => {'error_type' => 'RuntimeError', 'message' => 'too much'}}]
20
+
21
+ @agent.stats_engine.get_stats_no_scope('Custom/too_big') \
22
+ .record_data_point(1)
23
+ assert_equal 1, @agent.stats_engine \
24
+ .get_stats_no_scope('Custom/too_big').call_count
25
+
26
+ @agent.send(:harvest_and_send_timeslice_data)
27
+
28
+ # make sure the data gets thrown away without crashing
29
+ assert_equal 0, @agent.stats_engine \
30
+ .get_stats_no_scope('Custom/too_big').call_count
31
+
32
+ # make sure we actually talked to the collector
33
+ assert_equal(1, $collector.agent_data.select{|x| x.action == 'metric_data'}.size)
34
+ end
35
+
36
+ def test_unsupported_media_type
37
+ $collector.mock['metric_data'] = [415, {'exception' => {'error_type' => 'RuntimeError', 'message' => 'looks bad'}}]
38
+
39
+ @agent.stats_engine.get_stats_no_scope('Custom/too_big') \
40
+ .record_data_point(1)
41
+ assert_equal 1, @agent.stats_engine \
42
+ .get_stats_no_scope('Custom/too_big').call_count
43
+
44
+ @agent.send(:harvest_and_send_timeslice_data)
45
+
46
+ # make sure the data gets thrown away without crashing
47
+ assert_equal 0, @agent.stats_engine \
48
+ .get_stats_no_scope('Custom/too_big').call_count
49
+
50
+ # make sure we actually talked to the collector
51
+ assert_equal(1, $collector.agent_data.select{|x| x.action == 'metric_data'}.size)
52
+ end
53
+ end
@@ -0,0 +1,109 @@
1
+ # https://newrelic.atlassian.net/wiki/display/eng/The+Terror+and+Glory+of+Transaction+Traces
2
+ # https://newrelic.atlassian.net/browse/RUBY-914
3
+
4
+ class MarshalingTest < Test::Unit::TestCase
5
+ def setup
6
+ NewRelic::Agent.manual_start(:'transaction_tracer.transaction_threshold' => 0.0)
7
+ @agent = NewRelic::Agent.instance
8
+ @sampler = @agent.transaction_sampler
9
+
10
+ $collector ||= NewRelic::FakeCollector.new
11
+ $collector.reset
12
+ $collector.mock['connect'] = [200, {'return_value' => { 'agent_run_id' => 666 }}]
13
+ $collector.run
14
+ end
15
+
16
+ def teardown
17
+ Thread.current[:transaction_sample_builder] = nil
18
+ $collector.reset
19
+ end
20
+
21
+ def test_transaction_trace_marshaling
22
+ # create fake transaction trace
23
+ time = Time.now.to_f
24
+ @sampler.notice_first_scope_push time
25
+ @sampler.notice_transaction '/path', nil, {}
26
+ @sampler.notice_push_scope "a"
27
+ @sampler.notice_push_scope "ab"
28
+ sleep 1
29
+ @sampler.notice_pop_scope "ab"
30
+ @sampler.notice_pop_scope "a"
31
+ @sampler.notice_scope_empty
32
+
33
+ expected_sample = @sampler.instance_variable_get(:@slowest_sample)
34
+
35
+ @agent.service.connect
36
+ @agent.send(:harvest_and_send_slowest_sample)
37
+
38
+ if NewRelic::Agent::NewRelicService::JsonMarshaller.is_supported?
39
+ marshaller = NewRelic::Agent::NewRelicService::JsonMarshaller.new
40
+ else
41
+ marshaller = NewRelic::Agent::NewRelicService::PrubyMarshaller.new
42
+ end
43
+
44
+ assert_equal(666,
45
+ $collector.agent_data.select{|x| x.action == 'transaction_sample_data'}[0].body[0])
46
+ assert_equal(expected_sample.to_collector_array(marshaller),
47
+ $collector.agent_data.select{|x| x.action == 'transaction_sample_data'}[0].body[1][0])
48
+ end
49
+
50
+ def test_metric_data_marshalling
51
+ stats = NewRelic::Agent.instance.stats_engine.get_stats_no_scope('Custom/test/method')
52
+ stats.record_data_point(1.0)
53
+ stats.record_data_point(2.0, 1.0)
54
+ expected = [ [ {'name' => 'Custom/test/method', 'scope' => ''},
55
+ [2, 3.0, 2.0, 1.0, 2.0, 5.0] ] ]
56
+
57
+ @agent.service.connect
58
+ @agent.send(:harvest_and_send_timeslice_data)
59
+
60
+ assert_equal(666,
61
+ $collector.agent_data.select{|x| x.action == 'metric_data'}[0].body[0])
62
+
63
+ metric_data = $collector.agent_data \
64
+ .select{|x| x.action == 'metric_data'}[0].body[3]
65
+ assert metric_data
66
+
67
+ custom_metric = metric_data \
68
+ .select{|m| m[0]['name'] == 'Custom/test/method' }
69
+ assert_equal(expected, custom_metric)
70
+ end
71
+
72
+ def test_error_data_marshalling
73
+ @agent.error_collector.notice_error(Exception.new('test error'))
74
+ @agent.service.connect
75
+ @agent.send(:harvest_and_send_errors)
76
+
77
+ assert_equal(666,
78
+ $collector.agent_data.select{|x| x.action == 'error_data'}[0].body[0])
79
+
80
+ error_data = $collector.agent_data \
81
+ .select{|x| x.action == 'error_data'}[0].body[1][0]
82
+ assert_equal('test error', error_data[2])
83
+ end
84
+
85
+ def test_sql_trace_data_marshalling
86
+ @agent.sql_sampler.notice_first_scope_push(nil)
87
+ @agent.sql_sampler.notice_sql("select * from test",
88
+ "Database/test/select",
89
+ nil, 1.5)
90
+ @agent.sql_sampler.notice_scope_empty
91
+
92
+ @agent.service.connect
93
+ @agent.send(:harvest_and_send_slowest_sql)
94
+
95
+ sql_data = $collector.agent_data \
96
+ .select{|x| x.action == 'sql_trace_data'}[0].body[0]
97
+ assert_equal('select * from test', sql_data[0][3])
98
+ end
99
+
100
+ def test_connect_marshalling
101
+ @agent.service.connect('pid' => 1, 'agent_version' => '9000',
102
+ 'app_name' => 'test')
103
+
104
+ connect_data = $collector.agent_data \
105
+ .select{|x| x.action == 'connect'}[0].body[0]
106
+ assert_equal '9000', connect_data['agent_version']
107
+ end
108
+ end
109
+
@@ -0,0 +1,98 @@
1
+ require 'multiverse/color'
2
+
3
+ class MethodVisibilityTest < Test::Unit::TestCase
4
+ extend Multiverse::Color
5
+
6
+ class InstrumentedClass
7
+ include NewRelic::Agent::MethodTracer
8
+ include NewRelic::Agent::Instrumentation::ControllerInstrumentation
9
+
10
+ def public_method!
11
+ end
12
+
13
+ def public_transaction!
14
+ end
15
+
16
+ private
17
+ def private_method!
18
+ end
19
+
20
+ def private_transaction!
21
+ end
22
+
23
+ protected
24
+ def protected_method!
25
+ end
26
+
27
+ def protected_transaction!
28
+ end
29
+
30
+ add_method_tracer :public_method!
31
+ add_method_tracer :private_method!
32
+ add_method_tracer :protected_method!
33
+
34
+ add_transaction_tracer :public_transaction!
35
+ add_transaction_tracer :private_transaction!
36
+ add_transaction_tracer :protected_transaction!
37
+ end
38
+
39
+
40
+ class ObjectWithInstrumentation
41
+ include NewRelic::Agent::MethodTracer
42
+ include NewRelic::Agent::Instrumentation::ControllerInstrumentation
43
+ end
44
+
45
+ class ObjectWithTracers < ObjectWithInstrumentation
46
+ private
47
+ def a_private_method
48
+ end
49
+ def a_private_transaction
50
+ end
51
+ protected
52
+ def a_protected_method
53
+ end
54
+ def a_protected_transaction
55
+ end
56
+
57
+ add_method_tracer :a_private_method
58
+ add_method_tracer :a_protected_method
59
+ add_transaction_tracer :a_private_transaction
60
+ add_transaction_tracer :a_protected_transaction
61
+ end
62
+
63
+
64
+ def setup
65
+ @instance = InstrumentedClass.new
66
+ end
67
+
68
+ if NewRelic::VERSION::STRING >= '3.4.0.2'
69
+ %w| public private protected |.each do |visibility|
70
+ define_method "test_should_preserve_visibility_of_#{visibility}_traced_method" do
71
+ assert @instance.send("#{visibility}_methods").map{|s|s.to_sym}.include?(:"#{visibility}_method!"), "Method #{visibility}_method should be #{visibility}"
72
+ end
73
+
74
+ define_method "test_should_preserve_visibility_of_#{visibility}_traced_transaction" do
75
+ assert @instance.send("#{visibility}_methods").map{|s|s.to_sym}.include?(:"#{visibility}_transaction!"), "Transcation #{visibility}_transaction should be #{visibility}"
76
+ end
77
+ end
78
+
79
+ def test_tracing_non_public_methods_doesnt_add_public_methods
80
+ assert_equal [], ObjectWithTracers.public_instance_methods - ObjectWithInstrumentation.public_instance_methods
81
+ end
82
+
83
+ # FIXME: Currently including MethodTracer and ControllerInstrumentation
84
+ # adds a bunch of public methods to the class. It probably shouldn't do this.
85
+ #def test_instrumentation_doesnt_add_any_public_methods
86
+ # assert_equal [], ObjectWithInstrumentation.public_instance_methods - Object.public_instance_methods
87
+ #end
88
+ #
89
+
90
+
91
+
92
+ else
93
+ def test_truth
94
+ assert true # jruby freaks out if there are no tests defined in the test class
95
+ end
96
+ puts yellow('SKIPPED! 3.4.0.1 and earlier fail preserve_visibility tests')
97
+ end
98
+ end
@@ -0,0 +1,33 @@
1
+ # https://newrelic.atlassian.net/browse/RUBY-669
2
+
3
+ class PipeManagerTest < Test::Unit::TestCase
4
+ def setup
5
+ @listener = NewRelic::Agent::PipeChannelManager.listener
6
+ end
7
+
8
+ def teardown
9
+ @listener.stop
10
+ end
11
+
12
+ def test_old_pipes_are_cleaned_up_after_timeout
13
+ @listener.timeout = 1
14
+ NewRelic::Agent::PipeChannelManager.register_report_channel(:timeout_test)
15
+ sleep 2
16
+ @listener.start
17
+ sleep 0.5 # give the thread some time to start, and clean things up
18
+ assert_nil NewRelic::Agent::PipeChannelManager.channels[:timeout_test]
19
+ end
20
+
21
+ def test_pipes_are_regularly_checked_for_freshness
22
+ @listener.select_timeout = 1
23
+ @listener.timeout = 2
24
+ NewRelic::Agent::PipeChannelManager.register_report_channel(:select_test)
25
+
26
+ sleep 1.5
27
+ @listener.start
28
+ assert NewRelic::Agent::PipeChannelManager.channels[:select_test]
29
+
30
+ sleep 1.5
31
+ assert_nil NewRelic::Agent::PipeChannelManager.channels[:select_test]
32
+ end
33
+ end
@@ -0,0 +1,29 @@
1
+ require 'socket'
2
+
3
+ class ServiceTimeoutTest < Test::Unit::TestCase
4
+ def setup
5
+ hk = TCPServer.new('127.0.0.1',8081)
6
+
7
+ Thread.new {
8
+ client = hk.accept
9
+ what = client.gets
10
+ sleep 4
11
+ client.close
12
+ Thread.exit
13
+ }
14
+ end
15
+
16
+ def test_service_timeout
17
+ server = NewRelic::Control::Server.new('localhost', 8081,'127.0.0.1')
18
+ NewRelic::Agent.config.apply_config(:timeout => 2)
19
+
20
+ service = NewRelic::Agent::NewRelicService.new('deadbeef', server)
21
+
22
+ assert_raise Timeout::Error do
23
+ service.send('send_request',
24
+ :uri => '/agent_listener/8/bd0e1d52adade840f7ca727d29a86249e89a6f1c/get_redirect_host',
25
+ :encoding => 'UTF-8', :collector => server, :data => 'blah')
26
+ end
27
+ end
28
+
29
+ end
@@ -0,0 +1,30 @@
1
+
2
+ require 'test/unit'
3
+ require 'newrelic_rpm'
4
+ require 'new_relic/agent/method_tracer'
5
+
6
+
7
+ class MethodInterrobangTest < Test::Unit::TestCase
8
+ include NewRelic::Agent::MethodTracer
9
+
10
+ def interrogate?
11
+ "say what?"
12
+ end
13
+
14
+ def mutate!
15
+ "oh yeah!"
16
+ end
17
+
18
+ add_method_tracer :interrogate?
19
+ add_method_tracer :mutate!
20
+
21
+ def test_alias_method_ending_in_question_mark
22
+ assert_respond_to self,:interrogate?
23
+ assert_equal "say what?", interrogate?
24
+ end
25
+
26
+ def test_aliase_method_ending_in_exclamation_makr
27
+ assert_respond_to self,:mutate!
28
+ assert_equal "oh yeah!",mutate!
29
+ end
30
+ end
@@ -0,0 +1,32 @@
1
+
2
+ require 'test/unit'
3
+ require 'newrelic_rpm'
4
+ require 'new_relic/agent/instrumentation/controller_instrumentation'
5
+
6
+
7
+ class TransactionInterrobangTest < Test::Unit::TestCase
8
+ include NewRelic::Agent::Instrumentation::ControllerInstrumentation
9
+
10
+ def interrogate?
11
+ "say what?"
12
+ end
13
+
14
+ def mutate!
15
+ "oh yeah!"
16
+ end
17
+
18
+ add_transaction_tracer :interrogate?
19
+ add_transaction_tracer :mutate!
20
+
21
+ def test_alias_method_ending_in_question_mark
22
+ assert_respond_to self,:interrogate?
23
+ assert_respond_to self, :interrogate_with_newrelic_transaction_trace?
24
+ assert_equal "say what?", interrogate?
25
+ end
26
+
27
+ def test_aliase_method_ending_in_exclamation_makr
28
+ assert_respond_to self,:mutate!
29
+ assert_respond_to self, :mutate_with_newrelic_transaction_trace!
30
+ assert_equal "oh yeah!",mutate!
31
+ end
32
+ end