newrelic_rpm 3.9.6.257 → 3.9.7.266
Sign up to get free protection for your applications and to get access to all the features.
- data.tar.gz.sig +0 -0
- data/CHANGELOG +45 -0
- data/lib/new_relic/agent.rb +0 -1
- data/lib/new_relic/agent/agent.rb +61 -22
- data/lib/new_relic/agent/agent_logger.rb +11 -9
- data/lib/new_relic/agent/configuration/default_source.rb +25 -2
- data/lib/new_relic/agent/cross_app_monitor.rb +15 -53
- data/lib/new_relic/agent/cross_app_tracing.rb +11 -3
- data/lib/new_relic/agent/custom_event_aggregator.rb +98 -0
- data/lib/new_relic/agent/event_buffer.rb +84 -0
- data/lib/new_relic/agent/harvester.rb +4 -15
- data/lib/new_relic/agent/hostname.rb +1 -9
- data/lib/new_relic/agent/inbound_request_monitor.rb +41 -0
- data/lib/new_relic/agent/instrumentation/controller_instrumentation.rb +2 -2
- data/lib/new_relic/agent/instrumentation/queue_time.rb +0 -5
- data/lib/new_relic/agent/instrumentation/resque.rb +4 -9
- data/lib/new_relic/agent/javascript_instrumentor.rb +0 -12
- data/lib/new_relic/agent/method_tracer_helpers.rb +3 -1
- data/lib/new_relic/agent/new_relic_service.rb +1 -1
- data/lib/new_relic/agent/sampled_buffer.rb +13 -41
- data/lib/new_relic/agent/samplers/delayed_job_sampler.rb +52 -24
- data/lib/new_relic/agent/sized_buffer.rb +23 -0
- data/lib/new_relic/agent/synthetics_monitor.rb +50 -0
- data/lib/new_relic/agent/system_info.rb +28 -0
- data/lib/new_relic/agent/transaction.rb +78 -9
- data/lib/new_relic/agent/transaction/synthetics_sample_buffer.rb +25 -0
- data/lib/new_relic/agent/{request_sampler.rb → transaction_event_aggregator.rb} +53 -19
- data/lib/new_relic/agent/transaction_sample_builder.rb +3 -1
- data/lib/new_relic/agent/transaction_sampler.rb +10 -0
- data/lib/new_relic/agent/transaction_state.rb +1 -9
- data/lib/new_relic/coerce.rb +8 -2
- data/lib/new_relic/control.rb +0 -1
- data/lib/new_relic/local_environment.rb +12 -8
- data/lib/new_relic/metric_spec.rb +11 -2
- data/lib/new_relic/rack/developer_mode.rb +9 -1
- data/lib/new_relic/transaction_sample.rb +4 -10
- data/lib/new_relic/version.rb +1 -1
- data/newrelic_rpm.gemspec +1 -0
- data/test/agent_helper.rb +15 -2
- data/test/environments/norails/Gemfile +1 -0
- data/test/environments/rails21/Gemfile +1 -0
- data/test/environments/rails22/Gemfile +1 -0
- data/test/environments/rails23/Gemfile +1 -0
- data/test/environments/rails30/Gemfile +1 -0
- data/test/environments/rails31/Gemfile +1 -0
- data/test/environments/rails32/Gemfile +2 -1
- data/test/environments/rails40/Gemfile +2 -1
- data/test/environments/rails41/Gemfile +3 -1
- data/test/environments/rails42/Gemfile +3 -1
- data/test/fixtures/cross_agent_tests/README.md +6 -2
- data/test/fixtures/cross_agent_tests/docker_container_id/README.md +6 -0
- data/test/fixtures/cross_agent_tests/docker_container_id/cases.json +22 -0
- data/test/fixtures/cross_agent_tests/docker_container_id/docker-0.9.1.txt +10 -0
- data/test/fixtures/cross_agent_tests/docker_container_id/docker-1.0.0.txt +10 -0
- data/test/fixtures/cross_agent_tests/docker_container_id/docker-1.3.txt +9 -0
- data/test/fixtures/cross_agent_tests/docker_container_id/empty.txt +0 -0
- data/test/fixtures/cross_agent_tests/docker_container_id/lxc-containers-without-docker.txt +10 -0
- data/test/fixtures/cross_agent_tests/proc_meminfo/README.md +7 -0
- data/test/fixtures/cross_agent_tests/proc_meminfo/meminfo_4096MB.txt +47 -0
- data/test/fixtures/cross_agent_tests/rum_client_config.json +0 -80
- data/test/fixtures/cross_agent_tests/synthetics/synthetics.json +317 -0
- data/test/multiverse/lib/multiverse/runner.rb +1 -1
- data/test/multiverse/lib/multiverse/suite.rb +1 -0
- data/test/multiverse/suites/active_record/Envfile +42 -8
- data/test/multiverse/suites/active_record/ar_method_aliasing.rb +8 -4
- data/test/multiverse/suites/agent_only/audit_log_test.rb +0 -2
- data/test/multiverse/suites/agent_only/collector_exception_handling_test.rb +1 -2
- data/test/multiverse/suites/agent_only/cross_application_tracing_test.rb +5 -5
- data/test/multiverse/suites/agent_only/encoding_handling_test.rb +2 -0
- data/test/multiverse/suites/agent_only/harvest_timestamps_test.rb +8 -0
- data/test/multiverse/suites/agent_only/synthetics_test.rb +139 -0
- data/test/multiverse/suites/delayed_job/Envfile +79 -0
- data/test/multiverse/suites/delayed_job/before_suite.rb +33 -0
- data/test/multiverse/suites/delayed_job/config/newrelic.yml +18 -0
- data/test/multiverse/suites/delayed_job/delayed_job_sampler_test.rb +131 -0
- data/test/multiverse/suites/delayed_job/unsupported_backend_test.rb +24 -0
- data/test/multiverse/suites/high_security/high_security_test.rb +3 -10
- data/test/multiverse/suites/rails/Envfile +4 -4
- data/test/multiverse/suites/rails/request_statistics_test.rb +4 -4
- data/test/new_relic/agent/agent_test.rb +32 -4
- data/test/new_relic/agent/configuration/default_source_test.rb +6 -0
- data/test/new_relic/agent/cross_app_monitor_test.rb +23 -29
- data/test/new_relic/agent/custom_event_aggregator_test.rb +88 -0
- data/test/new_relic/agent/event_buffer_test_cases.rb +152 -0
- data/test/new_relic/agent/harvester_test.rb +5 -25
- data/test/new_relic/agent/hostname_test.rb +1 -1
- data/test/new_relic/agent/inbound_request_monitor_test.rb +49 -0
- data/test/new_relic/agent/instrumentation/controller_instrumentation_test.rb +9 -9
- data/test/new_relic/agent/instrumentation/queue_time_test.rb +0 -19
- data/test/new_relic/agent/javascript_instrumentor_test.rb +0 -45
- data/test/new_relic/agent/new_relic_service_test.rb +17 -12
- data/test/new_relic/agent/pipe_channel_manager_test.rb +4 -4
- data/test/new_relic/agent/sampled_buffer_test.rb +73 -145
- data/test/new_relic/agent/sized_buffer_test.rb +29 -0
- data/test/new_relic/agent/synthetics_monitor_test.rb +96 -0
- data/test/new_relic/agent/system_info_test.rb +19 -3
- data/test/new_relic/agent/transaction/developer_mode_sample_buffer_test.rb +14 -8
- data/test/new_relic/agent/transaction/synthetics_sample_buffer_test.rb +38 -0
- data/test/new_relic/agent/{request_sampler_test.rb → transaction_event_aggregator_test.rb} +55 -4
- data/test/new_relic/agent/transaction_sampler_test.rb +33 -11
- data/test/new_relic/agent/transaction_state_test.rb +0 -1
- data/test/new_relic/agent/transaction_test.rb +121 -19
- data/test/new_relic/coerce_test.rb +38 -3
- data/test/new_relic/control_test.rb +1 -0
- data/test/new_relic/fake_collector.rb +6 -2
- data/test/new_relic/fake_external_server.rb +2 -6
- data/test/new_relic/fake_server.rb +46 -29
- data/test/new_relic/http_client_test_cases.rb +71 -2
- data/test/new_relic/local_environment_test.rb +78 -0
- data/test/new_relic/metric_parser/metric_parser_test.rb +2 -0
- data/test/new_relic/metric_spec_test.rb +43 -0
- data/test/new_relic/multiverse_helpers.rb +11 -18
- data/test/new_relic/rack/browser_monitoring_test.rb +1 -18
- data/test/new_relic/rack/developer_mode_test.rb +1 -1
- data/test/new_relic/transaction_sample_test.rb +14 -4
- data/test/performance/suites/rack_middleware.rb +3 -1
- data/test/test_helper.rb +33 -0
- metadata +48 -7
- metadata.gz.sig +0 -0
- data/lib/new_relic/agent/browser_token.rb +0 -41
- data/test/multiverse/suites/agent_only/before_suite.rb +0 -7
- data/test/new_relic/agent/browser_token_test.rb +0 -56
@@ -10,7 +10,7 @@ class NewRelic::Agent::PipeChannelManagerTest < Minitest::Test
|
|
10
10
|
include TransactionSampleTestHelper
|
11
11
|
|
12
12
|
def setup
|
13
|
-
@test_config = { :
|
13
|
+
@test_config = { :monitor_mode => true }
|
14
14
|
NewRelic::Agent.agent.drop_buffered_data
|
15
15
|
NewRelic::Agent.config.add_config_for_testing(@test_config)
|
16
16
|
|
@@ -102,13 +102,13 @@ class NewRelic::Agent::PipeChannelManagerTest < Minitest::Test
|
|
102
102
|
end
|
103
103
|
|
104
104
|
def test_listener_merges_analytics_events
|
105
|
-
|
105
|
+
transaction_event_aggregator = NewRelic::Agent.agent.instance_variable_get(:@transaction_event_aggregator)
|
106
106
|
|
107
107
|
start_listener_with_pipe(699)
|
108
108
|
NewRelic::Agent.agent.stubs(:connected?).returns(true)
|
109
109
|
run_child(699) do
|
110
110
|
NewRelic::Agent.after_fork(:report_to_channel => 699)
|
111
|
-
|
111
|
+
transaction_event_aggregator.on_transaction_finished({
|
112
112
|
:start_timestamp => Time.now,
|
113
113
|
:name => 'whatever',
|
114
114
|
:duration => 10,
|
@@ -117,7 +117,7 @@ class NewRelic::Agent::PipeChannelManagerTest < Minitest::Test
|
|
117
117
|
NewRelic::Agent.agent.send(:transmit_event_data)
|
118
118
|
end
|
119
119
|
|
120
|
-
assert_equal(1,
|
120
|
+
assert_equal(1, transaction_event_aggregator.samples.size)
|
121
121
|
end
|
122
122
|
|
123
123
|
def test_listener_merges_sql_traces
|
@@ -3,176 +3,104 @@
|
|
3
3
|
# See https://github.com/newrelic/rpm/blob/master/LICENSE for complete details.
|
4
4
|
|
5
5
|
require File.expand_path(File.join(File.dirname(__FILE__),'..','..','test_helper'))
|
6
|
+
require 'test/new_relic/agent/event_buffer_test_cases'
|
6
7
|
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
all = []
|
11
|
-
100.times do |i|
|
12
|
-
buffer << i
|
13
|
-
all << i
|
14
|
-
end
|
15
|
-
|
16
|
-
assert_equal(100, buffer.size)
|
17
|
-
assert_equal(all, buffer.to_a)
|
18
|
-
end
|
8
|
+
module NewRelic::Agent
|
9
|
+
class SampledBufferTest < Minitest::Test
|
10
|
+
include EventBufferTestCases
|
19
11
|
|
20
|
-
|
21
|
-
|
12
|
+
def buffer_class
|
13
|
+
SampledBuffer
|
14
|
+
end
|
22
15
|
|
23
|
-
|
24
|
-
|
25
|
-
buffer.expects(:rand).with(8).returns(2)
|
26
|
-
buffer.expects(:rand).with(9).returns(3)
|
27
|
-
buffer.expects(:rand).with(10).returns(4)
|
16
|
+
def test_replaces_old_entries_when_necessary
|
17
|
+
buffer = buffer_class.new(5)
|
28
18
|
|
29
|
-
|
19
|
+
buffer.expects(:rand).with(6).returns(0)
|
20
|
+
buffer.expects(:rand).with(7).returns(1)
|
21
|
+
buffer.expects(:rand).with(8).returns(2)
|
22
|
+
buffer.expects(:rand).with(9).returns(3)
|
23
|
+
buffer.expects(:rand).with(10).returns(4)
|
30
24
|
|
31
|
-
|
32
|
-
end
|
33
|
-
|
34
|
-
def test_discards_new_entries_when_necessary
|
35
|
-
buffer = NewRelic::Agent::SampledBuffer.new(5)
|
25
|
+
10.times { |i| buffer << i }
|
36
26
|
|
37
|
-
|
38
|
-
|
39
|
-
buffer.expects(:rand).with(8).returns(7)
|
40
|
-
buffer.expects(:rand).with(9).returns(8)
|
41
|
-
buffer.expects(:rand).with(10).returns(9)
|
27
|
+
assert_equal([5, 6, 7, 8, 9], buffer.to_a)
|
28
|
+
end
|
42
29
|
|
43
|
-
|
30
|
+
def test_discards_new_entries_when_necessary
|
31
|
+
buffer = buffer_class.new(5)
|
44
32
|
|
45
|
-
|
46
|
-
|
33
|
+
buffer.expects(:rand).with(6).returns(5)
|
34
|
+
buffer.expects(:rand).with(7).returns(6)
|
35
|
+
buffer.expects(:rand).with(8).returns(7)
|
36
|
+
buffer.expects(:rand).with(9).returns(8)
|
37
|
+
buffer.expects(:rand).with(10).returns(9)
|
47
38
|
|
48
|
-
# This test is non-deterministic: there is some (low) probability that it will
|
49
|
-
# fail. We repeatedly stream 10 items into a buffer of capacity 5, and verify
|
50
|
-
# that each item is included ~50% of the time.
|
51
|
-
#
|
52
|
-
# Because of the non-determinism, it is possible that we'll want to disable
|
53
|
-
# this test. That said, I've thus far been unsuccessful in making it fail, so
|
54
|
-
# I'm leaving it here for now.
|
55
|
-
def test_should_sample_evenly
|
56
|
-
buffer = NewRelic::Agent::SampledBuffer.new(5)
|
57
|
-
results = []
|
58
|
-
|
59
|
-
10000.times do
|
60
|
-
buffer.reset
|
61
39
|
10.times { |i| buffer << i }
|
62
|
-
results << buffer.to_a
|
63
|
-
end
|
64
40
|
|
65
|
-
|
66
|
-
num_results_including_v = results.select { |r| r.include?(v) }.size
|
67
|
-
assert_in_delta(0.5, num_results_including_v.to_f / results.size, 0.05)
|
41
|
+
assert_equal([0, 1, 2, 3, 4], buffer.to_a)
|
68
42
|
end
|
69
|
-
end
|
70
|
-
|
71
|
-
def test_to_a_should_dup_the_returned_array
|
72
|
-
buffer = NewRelic::Agent::SampledBuffer.new(10)
|
73
43
|
|
74
|
-
|
44
|
+
def test_append_returns_whether_item_was_stored
|
45
|
+
buffer = buffer_class.new(5)
|
75
46
|
|
76
|
-
|
77
|
-
items << 'noodles'
|
78
|
-
|
79
|
-
assert_equal([0, 1, 2, 3, 4], buffer.to_a)
|
80
|
-
end
|
47
|
+
buffer.expects(:rand).with(6).returns(5)
|
81
48
|
|
82
|
-
|
83
|
-
|
49
|
+
5.times do |i|
|
50
|
+
result = buffer.append(i)
|
51
|
+
assert(result)
|
52
|
+
end
|
84
53
|
|
85
|
-
|
86
|
-
|
54
|
+
result = buffer.append('foo')
|
55
|
+
refute(result)
|
87
56
|
end
|
88
57
|
|
89
|
-
|
90
|
-
|
58
|
+
# This test is non-deterministic: there is some (low) probability that it will
|
59
|
+
# fail. We repeatedly stream 10 items into a buffer of capacity 5, and verify
|
60
|
+
# that each item is included ~50% of the time.
|
61
|
+
#
|
62
|
+
# Because of the non-determinism, it is possible that we'll want to disable
|
63
|
+
# this test. That said, I've thus far been unsuccessful in making it fail, so
|
64
|
+
# I'm leaving it here for now.
|
65
|
+
def test_should_sample_evenly
|
66
|
+
buffer = buffer_class.new(5)
|
67
|
+
results = []
|
68
|
+
|
69
|
+
10000.times do
|
70
|
+
buffer.reset!
|
71
|
+
10.times { |i| buffer << i }
|
72
|
+
results << buffer.to_a
|
73
|
+
end
|
74
|
+
|
75
|
+
(0...10).each do |v|
|
76
|
+
num_results_including_v = results.select { |r| r.include?(v) }.size
|
77
|
+
assert_in_delta(0.5, num_results_including_v.to_f / results.size, 0.05)
|
78
|
+
end
|
91
79
|
end
|
92
|
-
end
|
93
80
|
|
94
|
-
|
95
|
-
|
96
|
-
10.times { |i| buffer << i }
|
81
|
+
def test_seen_lifetime_should_persist_across_resets
|
82
|
+
buffer = buffer_class.new(10)
|
97
83
|
|
98
|
-
|
99
|
-
|
84
|
+
100.times { |i| buffer << i }
|
85
|
+
buffer.reset!
|
86
|
+
assert_equal(100, buffer.seen_lifetime)
|
100
87
|
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
buffer.to_a.each do |v|
|
105
|
-
assert_includes(allowed_values, v)
|
88
|
+
100.times { |i| buffer << i }
|
89
|
+
buffer.reset!
|
90
|
+
assert_equal(200, buffer.seen_lifetime)
|
106
91
|
end
|
107
|
-
end
|
108
|
-
|
109
|
-
def test_should_not_discard_items_if_not_needed_when_capacity_is_reset
|
110
|
-
buffer = NewRelic::Agent::SampledBuffer.new(10)
|
111
|
-
10.times { |i| buffer << i }
|
112
|
-
|
113
|
-
buffer.capacity = 20
|
114
|
-
assert_equal(10, buffer.size)
|
115
|
-
assert_equal((0..9).to_a, buffer.to_a)
|
116
|
-
end
|
117
|
-
|
118
|
-
def test_should_not_exceed_capacity
|
119
|
-
buffer = NewRelic::Agent::SampledBuffer.new(100)
|
120
|
-
200.times { |i| buffer << i }
|
121
|
-
assert_equal(100, buffer.size)
|
122
|
-
end
|
123
|
-
|
124
|
-
def test_reset_should_reset
|
125
|
-
buffer = NewRelic::Agent::SampledBuffer.new(10)
|
126
|
-
100.times { |i| buffer << i }
|
127
|
-
buffer.reset
|
128
|
-
assert_equal(0, buffer.size)
|
129
|
-
assert_equal([], buffer.to_a)
|
130
|
-
end
|
131
|
-
|
132
|
-
def test_seen_counts_all_seen_samples_since_last_reset
|
133
|
-
buffer = NewRelic::Agent::SampledBuffer.new(10)
|
134
|
-
assert_equal(0, buffer.seen)
|
135
|
-
|
136
|
-
20.times { |i| buffer << i }
|
137
|
-
assert_equal(20, buffer.seen)
|
138
|
-
|
139
|
-
buffer.reset
|
140
|
-
assert_equal(0, buffer.seen)
|
141
|
-
end
|
142
92
|
|
143
|
-
|
144
|
-
|
93
|
+
def test_sample_rate_lifetime
|
94
|
+
buffer = buffer_class.new(10)
|
95
|
+
assert_equal(0, buffer.sample_rate_lifetime)
|
145
96
|
|
146
|
-
|
147
|
-
|
148
|
-
|
97
|
+
10.times { buffer << 'x' }
|
98
|
+
buffer.reset!
|
99
|
+
assert_equal(1.0, buffer.sample_rate_lifetime)
|
149
100
|
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
def test_sample_rate
|
156
|
-
buffer = NewRelic::Agent::SampledBuffer.new(10)
|
157
|
-
assert_equal(0, buffer.sample_rate)
|
158
|
-
|
159
|
-
10.times { buffer << 'x' }
|
160
|
-
assert_equal(1.0, buffer.sample_rate)
|
161
|
-
|
162
|
-
10.times { buffer << 'x' }
|
163
|
-
assert_equal(0.5, buffer.sample_rate)
|
164
|
-
end
|
165
|
-
|
166
|
-
def test_sample_rate_lifetime
|
167
|
-
buffer = NewRelic::Agent::SampledBuffer.new(10)
|
168
|
-
assert_equal(0, buffer.sample_rate_lifetime)
|
169
|
-
|
170
|
-
10.times { buffer << 'x' }
|
171
|
-
buffer.reset
|
172
|
-
assert_equal(1.0, buffer.sample_rate_lifetime)
|
173
|
-
|
174
|
-
30.times { buffer << 'x' }
|
175
|
-
buffer.reset
|
176
|
-
assert_equal(0.5, buffer.sample_rate_lifetime)
|
101
|
+
30.times { buffer << 'x' }
|
102
|
+
buffer.reset!
|
103
|
+
assert_equal(0.5, buffer.sample_rate_lifetime)
|
104
|
+
end
|
177
105
|
end
|
178
106
|
end
|
@@ -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 File.expand_path(File.join(File.dirname(__FILE__),'..','..','test_helper'))
|
6
|
+
require 'test/new_relic/agent/event_buffer_test_cases'
|
7
|
+
require 'new_relic/agent/sized_buffer'
|
8
|
+
|
9
|
+
module NewRelic::Agent
|
10
|
+
class SizedBufferTest < Minitest::Test
|
11
|
+
include EventBufferTestCases
|
12
|
+
|
13
|
+
def buffer_class
|
14
|
+
SizedBuffer
|
15
|
+
end
|
16
|
+
|
17
|
+
def test_append_returns_whether_item_was_stored
|
18
|
+
buffer = buffer_class.new(5)
|
19
|
+
|
20
|
+
5.times do |i|
|
21
|
+
result = buffer.append(i)
|
22
|
+
assert(result)
|
23
|
+
end
|
24
|
+
|
25
|
+
result = buffer.append('foo')
|
26
|
+
refute(result)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,96 @@
|
|
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
|
+
require 'new_relic/agent/synthetics_monitor'
|
7
|
+
|
8
|
+
module NewRelic::Agent
|
9
|
+
class SyntheticsMonitorTest < Minitest::Test
|
10
|
+
ENCODING_KEY_NOOP = "\0"
|
11
|
+
TRUSTED_ACCOUNT_IDS = [42,13]
|
12
|
+
|
13
|
+
VERSION_ID = 1
|
14
|
+
ACCOUNT_ID = 42
|
15
|
+
RESOURCE_ID = 100
|
16
|
+
JOB_ID = 200
|
17
|
+
MONITOR_ID = 300
|
18
|
+
|
19
|
+
BAD_ACCOUNT_ID = 7
|
20
|
+
BAD_VERSION_ID = 2
|
21
|
+
|
22
|
+
STANDARD_DATA = [ACCOUNT_ID, RESOURCE_ID, JOB_ID, MONITOR_ID]
|
23
|
+
|
24
|
+
def setup
|
25
|
+
@events = EventListener.new
|
26
|
+
@monitor = SyntheticsMonitor.new(@events)
|
27
|
+
|
28
|
+
NewRelic::Agent.reset_config
|
29
|
+
@config = {
|
30
|
+
:encoding_key => ENCODING_KEY_NOOP,
|
31
|
+
:trusted_account_ids => TRUSTED_ACCOUNT_IDS
|
32
|
+
}
|
33
|
+
NewRelic::Agent.config.add_config_for_testing(@config)
|
34
|
+
|
35
|
+
@events.notify(:finished_configuring)
|
36
|
+
end
|
37
|
+
|
38
|
+
def test_doesnt_record_synthetics_state_without_header
|
39
|
+
in_transaction do
|
40
|
+
# Make sure we're not just erroring in the event notification handler
|
41
|
+
expects_no_logging(:debug)
|
42
|
+
|
43
|
+
@events.notify(:before_call, {})
|
44
|
+
assert_no_synthetics_payload
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
def test_doesnt_record_synthetics_if_incoming_request_higher_version
|
49
|
+
synthetics_payload = [BAD_VERSION_ID] + STANDARD_DATA
|
50
|
+
with_synthetics_headers(synthetics_payload) do
|
51
|
+
assert_no_synthetics_payload
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
def test_doesnt_record_synthetics_if_not_trusted_account
|
56
|
+
synthetics_payload = [VERSION_ID, BAD_ACCOUNT_ID] + STANDARD_DATA[1..-1]
|
57
|
+
with_synthetics_headers(synthetics_payload) do
|
58
|
+
assert_no_synthetics_payload
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
def test_doesnt_record_synthetics_if_data_too_short
|
63
|
+
synthetics_payload = [VERSION_ID, ACCOUNT_ID]
|
64
|
+
with_synthetics_headers(synthetics_payload) do
|
65
|
+
assert_no_synthetics_payload
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
def test_records_synthetics_state_from_header
|
70
|
+
key = SyntheticsMonitor::SYNTHETICS_HEADER_KEY
|
71
|
+
synthetics_payload = [VERSION_ID] + STANDARD_DATA
|
72
|
+
with_synthetics_headers(synthetics_payload, key) do
|
73
|
+
state = NewRelic::Agent::TransactionState.tl_get
|
74
|
+
txn = state.current_transaction
|
75
|
+
assert_equal @last_encoded_header, txn.raw_synthetics_header
|
76
|
+
assert_equal synthetics_payload, txn.synthetics_payload
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
def synthetics_header(payload, header_key = SyntheticsMonitor::SYNTHETICS_HEADER_KEY)
|
81
|
+
@last_encoded_header = json_dump_and_encode(payload)
|
82
|
+
{ header_key => @last_encoded_header }
|
83
|
+
end
|
84
|
+
|
85
|
+
def assert_no_synthetics_payload
|
86
|
+
assert_nil NewRelic::Agent::TransactionState.tl_get.current_transaction.synthetics_payload
|
87
|
+
end
|
88
|
+
|
89
|
+
def with_synthetics_headers(payload, header_key = SyntheticsMonitor::SYNTHETICS_HEADER_KEY)
|
90
|
+
in_transaction do
|
91
|
+
@events.notify(:before_call, synthetics_header(payload, header_key))
|
92
|
+
yield
|
93
|
+
end
|
94
|
+
end
|
95
|
+
end
|
96
|
+
end
|
@@ -11,13 +11,13 @@ class NewRelic::Agent::SystemInfoTest < Minitest::Test
|
|
11
11
|
@sysinfo.clear_processor_info
|
12
12
|
end
|
13
13
|
|
14
|
-
|
14
|
+
cpuinfo_test_dir = File.join(cross_agent_tests_dir, 'proc_cpuinfo')
|
15
15
|
|
16
|
-
Dir.chdir(
|
16
|
+
Dir.chdir(cpuinfo_test_dir) do
|
17
17
|
Dir.glob("*.txt") do |file|
|
18
18
|
if file =~ /^((\d+|X)pack_(\d+|X)core_(\d+|X)logical).txt$/
|
19
19
|
test_name = "test_#{$1}"
|
20
|
-
test_path = File.join(
|
20
|
+
test_path = File.join(cpuinfo_test_dir, file)
|
21
21
|
|
22
22
|
num_physical_packages = $2.to_i
|
23
23
|
num_physical_cores = $3.to_i
|
@@ -41,5 +41,21 @@ class NewRelic::Agent::SystemInfoTest < Minitest::Test
|
|
41
41
|
end
|
42
42
|
end
|
43
43
|
|
44
|
+
docker_id_test_dir = File.join(cross_agent_tests_dir, 'docker_container_id')
|
45
|
+
docker_id_test_cases = load_cross_agent_test(File.join('docker_container_id', 'cases'))
|
46
|
+
|
47
|
+
docker_id_test_cases.each do |test_case|
|
48
|
+
filename = test_case['filename']
|
49
|
+
basename = File.basename(filename, '.txt')
|
50
|
+
test_name = "test_docker_container_id_#{basename}"
|
51
|
+
|
52
|
+
define_method(test_name) do
|
53
|
+
input = File.read(File.join(docker_id_test_dir, filename))
|
54
|
+
container_id = @sysinfo.parse_docker_container_id(input)
|
55
|
+
|
56
|
+
message = "Parsed incorrect Docker container ID from #{filename}"
|
57
|
+
assert_equal(test_case['dockerContainerId'], container_id, message)
|
58
|
+
end
|
59
|
+
end
|
44
60
|
end
|
45
61
|
|
@@ -26,17 +26,21 @@ class NewRelic::Agent::Transaction
|
|
26
26
|
end
|
27
27
|
|
28
28
|
def test_stores_up_to_truncate_max
|
29
|
-
|
30
|
-
|
29
|
+
with_config(:developer_mode => true) do
|
30
|
+
sample = stub
|
31
|
+
@buffer.capacity.times { @buffer.store(sample) }
|
31
32
|
|
32
|
-
|
33
|
+
assert_equal(Array.new(@buffer.capacity, sample), @buffer.samples)
|
34
|
+
end
|
33
35
|
end
|
34
36
|
|
35
37
|
def test_stores_and_truncates
|
36
|
-
|
37
|
-
|
38
|
+
with_config(:developer_mode => true) do
|
39
|
+
sample = stub
|
40
|
+
(@buffer.capacity * 2).times { @buffer.store(sample) }
|
38
41
|
|
39
|
-
|
42
|
+
assert_equal(Array.new(@buffer.capacity, sample), @buffer.samples)
|
43
|
+
end
|
40
44
|
end
|
41
45
|
|
42
46
|
def test_visit_segment_takes_backtraces_in_dev_mode
|
@@ -62,8 +66,10 @@ class NewRelic::Agent::Transaction
|
|
62
66
|
end
|
63
67
|
|
64
68
|
def test_doesnt_store_previous
|
65
|
-
|
66
|
-
|
69
|
+
with_config(:developer_mode => true) do
|
70
|
+
@buffer.store_previous([stub])
|
71
|
+
assert @buffer.samples.empty?
|
72
|
+
end
|
67
73
|
end
|
68
74
|
end
|
69
75
|
end
|