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.
Files changed (122) hide show
  1. data.tar.gz.sig +0 -0
  2. data/CHANGELOG +45 -0
  3. data/lib/new_relic/agent.rb +0 -1
  4. data/lib/new_relic/agent/agent.rb +61 -22
  5. data/lib/new_relic/agent/agent_logger.rb +11 -9
  6. data/lib/new_relic/agent/configuration/default_source.rb +25 -2
  7. data/lib/new_relic/agent/cross_app_monitor.rb +15 -53
  8. data/lib/new_relic/agent/cross_app_tracing.rb +11 -3
  9. data/lib/new_relic/agent/custom_event_aggregator.rb +98 -0
  10. data/lib/new_relic/agent/event_buffer.rb +84 -0
  11. data/lib/new_relic/agent/harvester.rb +4 -15
  12. data/lib/new_relic/agent/hostname.rb +1 -9
  13. data/lib/new_relic/agent/inbound_request_monitor.rb +41 -0
  14. data/lib/new_relic/agent/instrumentation/controller_instrumentation.rb +2 -2
  15. data/lib/new_relic/agent/instrumentation/queue_time.rb +0 -5
  16. data/lib/new_relic/agent/instrumentation/resque.rb +4 -9
  17. data/lib/new_relic/agent/javascript_instrumentor.rb +0 -12
  18. data/lib/new_relic/agent/method_tracer_helpers.rb +3 -1
  19. data/lib/new_relic/agent/new_relic_service.rb +1 -1
  20. data/lib/new_relic/agent/sampled_buffer.rb +13 -41
  21. data/lib/new_relic/agent/samplers/delayed_job_sampler.rb +52 -24
  22. data/lib/new_relic/agent/sized_buffer.rb +23 -0
  23. data/lib/new_relic/agent/synthetics_monitor.rb +50 -0
  24. data/lib/new_relic/agent/system_info.rb +28 -0
  25. data/lib/new_relic/agent/transaction.rb +78 -9
  26. data/lib/new_relic/agent/transaction/synthetics_sample_buffer.rb +25 -0
  27. data/lib/new_relic/agent/{request_sampler.rb → transaction_event_aggregator.rb} +53 -19
  28. data/lib/new_relic/agent/transaction_sample_builder.rb +3 -1
  29. data/lib/new_relic/agent/transaction_sampler.rb +10 -0
  30. data/lib/new_relic/agent/transaction_state.rb +1 -9
  31. data/lib/new_relic/coerce.rb +8 -2
  32. data/lib/new_relic/control.rb +0 -1
  33. data/lib/new_relic/local_environment.rb +12 -8
  34. data/lib/new_relic/metric_spec.rb +11 -2
  35. data/lib/new_relic/rack/developer_mode.rb +9 -1
  36. data/lib/new_relic/transaction_sample.rb +4 -10
  37. data/lib/new_relic/version.rb +1 -1
  38. data/newrelic_rpm.gemspec +1 -0
  39. data/test/agent_helper.rb +15 -2
  40. data/test/environments/norails/Gemfile +1 -0
  41. data/test/environments/rails21/Gemfile +1 -0
  42. data/test/environments/rails22/Gemfile +1 -0
  43. data/test/environments/rails23/Gemfile +1 -0
  44. data/test/environments/rails30/Gemfile +1 -0
  45. data/test/environments/rails31/Gemfile +1 -0
  46. data/test/environments/rails32/Gemfile +2 -1
  47. data/test/environments/rails40/Gemfile +2 -1
  48. data/test/environments/rails41/Gemfile +3 -1
  49. data/test/environments/rails42/Gemfile +3 -1
  50. data/test/fixtures/cross_agent_tests/README.md +6 -2
  51. data/test/fixtures/cross_agent_tests/docker_container_id/README.md +6 -0
  52. data/test/fixtures/cross_agent_tests/docker_container_id/cases.json +22 -0
  53. data/test/fixtures/cross_agent_tests/docker_container_id/docker-0.9.1.txt +10 -0
  54. data/test/fixtures/cross_agent_tests/docker_container_id/docker-1.0.0.txt +10 -0
  55. data/test/fixtures/cross_agent_tests/docker_container_id/docker-1.3.txt +9 -0
  56. data/test/fixtures/cross_agent_tests/docker_container_id/empty.txt +0 -0
  57. data/test/fixtures/cross_agent_tests/docker_container_id/lxc-containers-without-docker.txt +10 -0
  58. data/test/fixtures/cross_agent_tests/proc_meminfo/README.md +7 -0
  59. data/test/fixtures/cross_agent_tests/proc_meminfo/meminfo_4096MB.txt +47 -0
  60. data/test/fixtures/cross_agent_tests/rum_client_config.json +0 -80
  61. data/test/fixtures/cross_agent_tests/synthetics/synthetics.json +317 -0
  62. data/test/multiverse/lib/multiverse/runner.rb +1 -1
  63. data/test/multiverse/lib/multiverse/suite.rb +1 -0
  64. data/test/multiverse/suites/active_record/Envfile +42 -8
  65. data/test/multiverse/suites/active_record/ar_method_aliasing.rb +8 -4
  66. data/test/multiverse/suites/agent_only/audit_log_test.rb +0 -2
  67. data/test/multiverse/suites/agent_only/collector_exception_handling_test.rb +1 -2
  68. data/test/multiverse/suites/agent_only/cross_application_tracing_test.rb +5 -5
  69. data/test/multiverse/suites/agent_only/encoding_handling_test.rb +2 -0
  70. data/test/multiverse/suites/agent_only/harvest_timestamps_test.rb +8 -0
  71. data/test/multiverse/suites/agent_only/synthetics_test.rb +139 -0
  72. data/test/multiverse/suites/delayed_job/Envfile +79 -0
  73. data/test/multiverse/suites/delayed_job/before_suite.rb +33 -0
  74. data/test/multiverse/suites/delayed_job/config/newrelic.yml +18 -0
  75. data/test/multiverse/suites/delayed_job/delayed_job_sampler_test.rb +131 -0
  76. data/test/multiverse/suites/delayed_job/unsupported_backend_test.rb +24 -0
  77. data/test/multiverse/suites/high_security/high_security_test.rb +3 -10
  78. data/test/multiverse/suites/rails/Envfile +4 -4
  79. data/test/multiverse/suites/rails/request_statistics_test.rb +4 -4
  80. data/test/new_relic/agent/agent_test.rb +32 -4
  81. data/test/new_relic/agent/configuration/default_source_test.rb +6 -0
  82. data/test/new_relic/agent/cross_app_monitor_test.rb +23 -29
  83. data/test/new_relic/agent/custom_event_aggregator_test.rb +88 -0
  84. data/test/new_relic/agent/event_buffer_test_cases.rb +152 -0
  85. data/test/new_relic/agent/harvester_test.rb +5 -25
  86. data/test/new_relic/agent/hostname_test.rb +1 -1
  87. data/test/new_relic/agent/inbound_request_monitor_test.rb +49 -0
  88. data/test/new_relic/agent/instrumentation/controller_instrumentation_test.rb +9 -9
  89. data/test/new_relic/agent/instrumentation/queue_time_test.rb +0 -19
  90. data/test/new_relic/agent/javascript_instrumentor_test.rb +0 -45
  91. data/test/new_relic/agent/new_relic_service_test.rb +17 -12
  92. data/test/new_relic/agent/pipe_channel_manager_test.rb +4 -4
  93. data/test/new_relic/agent/sampled_buffer_test.rb +73 -145
  94. data/test/new_relic/agent/sized_buffer_test.rb +29 -0
  95. data/test/new_relic/agent/synthetics_monitor_test.rb +96 -0
  96. data/test/new_relic/agent/system_info_test.rb +19 -3
  97. data/test/new_relic/agent/transaction/developer_mode_sample_buffer_test.rb +14 -8
  98. data/test/new_relic/agent/transaction/synthetics_sample_buffer_test.rb +38 -0
  99. data/test/new_relic/agent/{request_sampler_test.rb → transaction_event_aggregator_test.rb} +55 -4
  100. data/test/new_relic/agent/transaction_sampler_test.rb +33 -11
  101. data/test/new_relic/agent/transaction_state_test.rb +0 -1
  102. data/test/new_relic/agent/transaction_test.rb +121 -19
  103. data/test/new_relic/coerce_test.rb +38 -3
  104. data/test/new_relic/control_test.rb +1 -0
  105. data/test/new_relic/fake_collector.rb +6 -2
  106. data/test/new_relic/fake_external_server.rb +2 -6
  107. data/test/new_relic/fake_server.rb +46 -29
  108. data/test/new_relic/http_client_test_cases.rb +71 -2
  109. data/test/new_relic/local_environment_test.rb +78 -0
  110. data/test/new_relic/metric_parser/metric_parser_test.rb +2 -0
  111. data/test/new_relic/metric_spec_test.rb +43 -0
  112. data/test/new_relic/multiverse_helpers.rb +11 -18
  113. data/test/new_relic/rack/browser_monitoring_test.rb +1 -18
  114. data/test/new_relic/rack/developer_mode_test.rb +1 -1
  115. data/test/new_relic/transaction_sample_test.rb +14 -4
  116. data/test/performance/suites/rack_middleware.rb +3 -1
  117. data/test/test_helper.rb +33 -0
  118. metadata +48 -7
  119. metadata.gz.sig +0 -0
  120. data/lib/new_relic/agent/browser_token.rb +0 -41
  121. data/test/multiverse/suites/agent_only/before_suite.rb +0 -7
  122. data/test/new_relic/agent/browser_token_test.rb +0 -56
@@ -84,7 +84,7 @@ module Multiverse
84
84
  GROUPS = {
85
85
  "agent" => ["agent_only", "bare", "config_file_loading",
86
86
  "deferred_instrumentation", "high_security"],
87
- "background" => ["resque", "sidekiq"],
87
+ "background" => ["delayed_job", "resque", "sidekiq"],
88
88
  "database" => ["datamapper", "mongo", "sequel"],
89
89
  "httpclients" => ["curb", "excon", "httpclient", "typhoeus", "net_http"],
90
90
  "rails" => ["active_record", "rails"],
@@ -227,6 +227,7 @@ module Multiverse
227
227
 
228
228
  def execute_child_environment(env_index)
229
229
  with_clean_env do
230
+ ENV["MULTIVERSE_ENV"] = env_index.to_s
230
231
  log_test_running_process
231
232
  configure_before_bundling
232
233
 
@@ -1,13 +1,47 @@
1
- gemfile <<-RB
1
+ boilerplate_gems = <<-SQLITE
2
2
  gem 'rack'
3
- if RUBY_VERSION == '1.8.6'
4
- gem 'activerecord', '2.3.14'
5
- elsif RUBY_PLATFORM == 'java'
6
- gem 'activerecord-jdbcsqlite3-adapter', '1.2.2.1'
7
- gem 'jdbc-sqlite3', '3.7.2'
8
- gem 'activerecord', '~> 3.2.0'
3
+ if RUBY_PLATFORM == 'java'
4
+ gem 'activerecord-jdbcsqlite3-adapter'
9
5
  else
10
- gem 'activerecord', '~> 3.2.0'
11
6
  gem 'sqlite3'
12
7
  end
8
+ SQLITE
9
+
10
+ if RUBY_VERSION >= '1.9.3'
11
+ # JRuby currently having problem with Rails 4.2 beta. Remove condition on GA.
12
+ if !defined?(RUBY_ENGINE) || RUBY_ENGINE != 'jruby'
13
+ gemfile <<-RB
14
+ gem 'activerecord', '~> 4.2.0.beta2'
15
+ gem 'minitest', '~> 5.2.3'
16
+ #{boilerplate_gems}
17
+ RB
18
+ end
19
+
20
+ gemfile <<-RB
21
+ gem 'activerecord', '~> 4.1.6'
22
+ gem 'minitest', '~> 5.2.3'
23
+ #{boilerplate_gems}
24
+ RB
25
+ end
26
+
27
+ gemfile <<-RB
28
+ gem 'activerecord', '~> 3.2.19'
29
+ #{boilerplate_gems}
30
+ RB
31
+
32
+ gemfile <<-RB
33
+ gem 'activerecord', '~> 3.1.12'
34
+ #{boilerplate_gems}
35
+ RB
36
+
37
+ gemfile <<-RB
38
+ gem 'activerecord', '~> 3.0.20'
39
+ #{boilerplate_gems}
40
+ RB
41
+
42
+ if RUBY_VERSION <= '1.9.3'
43
+ gemfile <<-RB
44
+ gem 'activerecord', '~> 2.3.18'
45
+ #{boilerplate_gems}
13
46
  RB
47
+ end
@@ -5,6 +5,8 @@
5
5
  require 'rubygems'
6
6
 
7
7
  require 'active_record'
8
+ require 'active_support/multibyte'
9
+
8
10
  require 'newrelic_rpm'
9
11
  require 'multiverse/color'
10
12
  require 'multiverse_helpers'
@@ -33,7 +35,9 @@ class InstrumentActiveRecordMethods < Minitest::Test
33
35
  end
34
36
 
35
37
  def after_setup
36
- @db_connection = ActiveRecord::Base.establish_connection( :adapter => 'sqlite3', :database => 'testdb.sqlite3')
38
+ database_name = "testdb.#{ENV["MULTIVERSE_ENV"]}.sqlite3"
39
+ @db_connection = ActiveRecord::Base.establish_connection(:adapter => 'sqlite3',
40
+ :database => database_name)
37
41
  ActiveRecord::Migration.class_eval do
38
42
  @connection = @db_connection
39
43
  create_table :users do |t|
@@ -60,7 +64,7 @@ class InstrumentActiveRecordMethods < Minitest::Test
60
64
  assert a_user.new_record?
61
65
  a_user.save!
62
66
  assert User.connected?
63
- assert a_user.persisted?
67
+ assert a_user.persisted? if a_user.respond_to?(:persisted?)
64
68
  assert a_user.id == 1
65
69
  end
66
70
 
@@ -74,8 +78,8 @@ class InstrumentActiveRecordMethods < Minitest::Test
74
78
  an_alias = Alias.new :user_id => a_user.id, :aka => "the Blob"
75
79
  assert an_alias.new_record?
76
80
  an_alias.save!
77
- assert an_alias.persisted?
81
+ assert an_alias.persisted? if a_user.respond_to?(:persisted?)
78
82
  an_alias.destroy
79
- assert an_alias.destroyed?
83
+ assert an_alias.destroyed? if a_user.respond_to?(:destroyed?)
80
84
  end
81
85
  end
@@ -48,8 +48,6 @@ class AuditLogTest < Minitest::Test
48
48
  end
49
49
 
50
50
  def perform_actions
51
- reset_collector
52
-
53
51
  state = NewRelic::Agent::TransactionState.tl_get
54
52
  NewRelic::Agent.instance.sql_sampler.on_start_transaction(state, nil)
55
53
  NewRelic::Agent.instance.sql_sampler.notice_sql("select * from test",
@@ -2,8 +2,7 @@
2
2
  # This file is distributed under New Relic's license terms.
3
3
  # See https://github.com/newrelic/rpm/blob/master/LICENSE for complete details.
4
4
 
5
- # RUBY-839 make sure there is no STDOUT chatter
6
- require 'open3'
5
+ require 'multiverse_helpers'
7
6
 
8
7
  class CollectorExceptionHandlingTest < Minitest::Test
9
8
  include MultiverseHelpers
@@ -42,18 +42,18 @@ class CrossApplicationTracingTest < Minitest::Test
42
42
  end
43
43
 
44
44
  def test_cross_app_doesnt_modify_with_invalid_header
45
- get '/', nil, {'X-NewRelic-ID' => Base64.encode64('otherjunk')}
45
+ get '/', nil, {'HTTP_X_NEWRELIC_ID' => Base64.encode64('otherjunk')}
46
46
  assert_nil last_response.headers["X-NewRelic-App-Data"]
47
47
  end
48
48
 
49
49
  def test_cross_app_writes_out_information
50
- get '/', nil, {'X-NewRelic-ID' => Base64.encode64('1#234')}
50
+ get '/', nil, {'HTTP_X_NEWRELIC_ID' => Base64.encode64('1#234')}
51
51
  refute_nil last_response.headers["X-NewRelic-App-Data"]
52
52
  assert_metrics_recorded(['ClientApplication/1#234/all'])
53
53
  end
54
54
 
55
55
  def test_cross_app_doesnt_modify_if_txn_is_ignored
56
- get '/', {'transaction_name' => 'ignored_transaction'}, {'X-NewRelic-ID' => Base64.encode64('1#234')}
56
+ get '/', {'transaction_name' => 'ignored_transaction'}, {'HTTP_X_NEWRELIC_ID' => Base64.encode64('1#234')}
57
57
  assert_nil last_response.headers["X-NewRelic-App-Data"]
58
58
  end
59
59
 
@@ -62,8 +62,8 @@ class CrossApplicationTracingTest < Minitest::Test
62
62
  if !test_case["outboundRequests"]
63
63
  if test_case['inboundPayload']
64
64
  request_headers = {
65
- 'X-NewRelic-ID' => Base64.encode64('1#234'),
66
- 'X-NewRelic-Transaction' => json_dump_and_encode(test_case['inboundPayload'])
65
+ 'HTTP_X_NEWRELIC_ID' => Base64.encode64('1#234'),
66
+ 'HTTP_X_NEWRELIC_TRANSACTION' => json_dump_and_encode(test_case['inboundPayload'])
67
67
  }
68
68
  else
69
69
  request_headers = {}
@@ -2,6 +2,8 @@
2
2
  # This file is distributed under New Relic's license terms.
3
3
  # See https://github.com/newrelic/rpm/blob/master/LICENSE for complete details.
4
4
 
5
+ require 'multiverse_helpers'
6
+
5
7
  if RUBY_VERSION >= '1.9'
6
8
 
7
9
  class EncodingHandlingTest < Minitest::Test
@@ -14,6 +14,8 @@ class HarvestTimestampsTest < Minitest::Test
14
14
  freeze_time
15
15
 
16
16
  t1 = advance_time 10
17
+
18
+ simulate_fork
17
19
  NewRelic::Agent.after_fork
18
20
 
19
21
  t2 = advance_time 10
@@ -29,6 +31,7 @@ class HarvestTimestampsTest < Minitest::Test
29
31
  def test_start_timestamp_maintained_on_harvest_failure
30
32
  t0 = freeze_time.to_f
31
33
 
34
+ simulate_fork
32
35
  NewRelic::Agent.after_fork
33
36
 
34
37
  $collector.stub('metric_data', {}, 503)
@@ -48,6 +51,7 @@ class HarvestTimestampsTest < Minitest::Test
48
51
  def test_timestamps_updated_even_if_filling_metric_id_cache_fails
49
52
  t0 = freeze_time.to_f
50
53
 
54
+ simulate_fork
51
55
  NewRelic::Agent.after_fork
52
56
 
53
57
  # Induce a failure in filling the metric ID cache by handing back a bogus
@@ -73,4 +77,8 @@ class HarvestTimestampsTest < Minitest::Test
73
77
  def last_metric_data_post
74
78
  $collector.calls_for('metric_data').last
75
79
  end
80
+
81
+ def simulate_fork
82
+ NewRelic::Agent.instance.harvester.instance_variable_set(:@starting_pid, nil)
83
+ end
76
84
  end
@@ -0,0 +1,139 @@
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 'rack/test'
6
+ require 'multiverse_helpers'
7
+ require 'new_relic/rack/agent_hooks'
8
+ require './testing_app'
9
+
10
+ class SyntheticsTest < Minitest::Test
11
+ @app = TestingApp.new
12
+ @wrapper_app = NewRelic::Rack::AgentHooks.new(@app)
13
+
14
+ def self.wrapper_app
15
+ @wrapper_app
16
+ end
17
+
18
+ include MultiverseHelpers
19
+ include Rack::Test::Methods
20
+
21
+ setup_and_teardown_agent
22
+
23
+ def app
24
+ self.class.wrapper_app
25
+ end
26
+
27
+ def last_sent_analytics_event
28
+ calls = $collector.calls_for(:analytic_event_data)
29
+ assert_equal(1, calls.size)
30
+ events = calls.first.events
31
+ assert_equal(1, events.size)
32
+ events.first
33
+ end
34
+
35
+ def last_sent_transaction_trace
36
+ calls = $collector.calls_for(:transaction_sample_data)
37
+ assert_equal(1, calls.size)
38
+ traces = calls.first.samples
39
+ assert_equal(1, traces.size)
40
+ traces.first
41
+ end
42
+
43
+ def generate_synthetics_header(test)
44
+ synthetics_key = test['settings']['syntheticsEncodingKey']
45
+ synthetics_payload = test['inputHeaderPayload']
46
+
47
+ return nil if synthetics_payload.empty?
48
+
49
+ encoded_synthetics_payload = ::NewRelic::JSONWrapper.dump(synthetics_payload)
50
+ obfuscated_synthetics_header = ::NewRelic::Agent::Obfuscator.new(synthetics_key).obfuscate(encoded_synthetics_payload)
51
+
52
+ assert_equal(test['inputObfuscatedHeader']['X-NewRelic-Synthetics'], obfuscated_synthetics_header)
53
+ obfuscated_synthetics_header
54
+ end
55
+
56
+ def request_headers_for_test(test)
57
+ header_value = generate_synthetics_header(test)
58
+ if header_value
59
+ { 'HTTP_X_NEWRELIC_SYNTHETICS' => header_value }
60
+ else
61
+ {}
62
+ end
63
+ end
64
+
65
+ def request_params_for_test(test)
66
+ if test['settings']
67
+ { 'guid' => test['settings']['transactionGuid'] }
68
+ else
69
+ {}
70
+ end
71
+ end
72
+
73
+ def validate_transaction_event(event, test)
74
+ event_spec = test['outputTransactionEvent']
75
+ expected_event_attrs = event_spec['expectedAttributes']
76
+ non_expected_event_attrs = event_spec['nonExpectedAttributes']
77
+
78
+ expected_event_attrs.each do |key, value|
79
+ msg = "Incorrect value for analytic event key '#{key}'. Full event = #{event.inspect}"
80
+ assert_equal(value, event[0][key], msg) unless key == 'nr.guid' && event[0][key] == nil
81
+ end
82
+
83
+ non_expected_event_attrs.each do |key|
84
+ msg = "Did not expect key '#{key}' on analytics event. Actual value was #{event[0][key]}"
85
+ refute_includes(event[0].keys, key, msg)
86
+ end
87
+ end
88
+
89
+ def validate_transaction_trace(trace, test)
90
+ trace_spec = test['outputTransactionTrace']
91
+ expected_resource_id = trace_spec['header']['field_9']
92
+ expected_attrs = trace_spec['expectedIntrinsics']
93
+ non_expected_attrs = trace_spec['nonExpectedIntrinsics']
94
+
95
+ trace_attrs = trace.tree.custom_params
96
+
97
+ assert_equal(expected_resource_id, trace.synthetics_resource_id)
98
+
99
+ expected_attrs.each do |key, value|
100
+ key = "nr.#{key}"
101
+ msg = "Incorrect value for transaction trace intrinsic '#{key}'. All intrinsics = #{trace_attrs.inspect}"
102
+ assert_equal(value, trace_attrs[key], msg)
103
+ end
104
+
105
+ non_expected_attrs.each do |key|
106
+ key = "nr.#{key}"
107
+ msg = "Did not expect key '#{key}' on transaction trace. Actual value was #{trace_attrs[key]}"
108
+ refute_includes(trace_attrs.keys, key, msg)
109
+ end
110
+ end
111
+
112
+ # These tests do *not* cover passing on the correct synthetics header to
113
+ # outgoing HTTP requests, since testing that requires our various HTTP client
114
+ # libraries to be present. That aspect is tested in http_client_test_cases.rb
115
+ load_cross_agent_test('synthetics/synthetics').each do |test|
116
+ define_method("test_synthetics_#{test['name']}") do
117
+ config = {
118
+ :encoding_key => test['settings']['agentEncodingKey'],
119
+ :trusted_account_ids => test['settings']['trustedAccountIds'],
120
+ :'transaction_tracer.transaction_threshold' => 0.0
121
+ }
122
+
123
+ with_config(config) do
124
+ NewRelic::Agent.instance.events.notify(:finished_configuring)
125
+
126
+ get '/', request_params_for_test(test), request_headers_for_test(test)
127
+
128
+ NewRelic::Agent.agent.send(:transmit_data)
129
+ NewRelic::Agent.agent.send(:harvest_and_send_analytic_event_data)
130
+
131
+ event = last_sent_analytics_event
132
+ validate_transaction_event(event, test)
133
+
134
+ trace = last_sent_transaction_trace
135
+ validate_transaction_trace(trace, test)
136
+ end
137
+ end
138
+ end
139
+ end
@@ -0,0 +1,79 @@
1
+ suite_condition("Rails 2.2.0-preview1 and Rubinius problems prevent these from running") do
2
+ # https://github.com/rails/rails/issues/17017
3
+ RUBY_VERSION != '2.2.0' && (!defined?(RUBY_ENGINE) || RUBY_ENGINE != "rbx")
4
+ end
5
+
6
+ boilerplate_gems = <<-SQLITE
7
+ gem 'rack'
8
+ if RUBY_PLATFORM == 'java'
9
+ gem 'activerecord-jdbcsqlite3-adapter'
10
+ else
11
+ gem 'sqlite3'
12
+ end
13
+ SQLITE
14
+
15
+ # delayed_job_mongoid is currently unsupported, but check that we behave
16
+ # mongoid 3.x is only supported on Ruby 1.9.3, though
17
+ if RUBY_VERSION >= '1.9.3'
18
+ gemfile <<-RB
19
+ gem 'delayed_job', '~> 4.0.4'
20
+ gem 'delayed_job_mongoid', '~> 2.1.0'
21
+ #{boilerplate_gems}
22
+ RB
23
+ end
24
+
25
+ # delayed_job_active_record (and older baked into delayed_job) support
26
+ dj4_with_active_record = <<-DJ
27
+ gem 'delayed_job', '~> 4.0.4'
28
+ gem 'delayed_job_active_record', '~> 4.0.2'
29
+ #{boilerplate_gems}
30
+ DJ
31
+
32
+ dj3_with_active_record = <<-DJ
33
+ gem 'delayed_job', '~> 3.0.5'
34
+ gem 'delayed_job_active_record', '~> 0.4.4'
35
+ #{boilerplate_gems}
36
+ DJ
37
+
38
+ dj2_with_active_record3 = <<-DJ
39
+ gem 'delayed_job', '~> 2.1.4'
40
+ #{boilerplate_gems}
41
+ DJ
42
+
43
+ if RUBY_VERSION >= '1.9.3'
44
+ gemfile <<-RB
45
+ gem 'activerecord', '~> 4.1.6'
46
+ #{dj4_with_active_record}
47
+ gem 'minitest', '~> 5.2.3'
48
+ RB
49
+
50
+ gemfile <<-RB
51
+ gem 'activerecord', '~>4.0.10'
52
+ #{dj4_with_active_record}
53
+ RB
54
+ end
55
+
56
+ [dj4_with_active_record, dj3_with_active_record, dj2_with_active_record3].each do |dj|
57
+ gemfile <<-RB
58
+ gem 'activerecord', '~> 3.2.19'
59
+ #{dj}
60
+ RB
61
+
62
+ gemfile <<-RB
63
+ gem 'activerecord', '~> 3.1.12'
64
+ #{dj}
65
+ RB
66
+
67
+ gemfile <<-RB
68
+ gem 'activerecord', '~> 3.0.20'
69
+ #{dj}
70
+ RB
71
+ end
72
+
73
+ if RUBY_VERSION <= '1.9.3'
74
+ gemfile <<-RB
75
+ gem 'activerecord', '~> 2.3.18'
76
+ gem 'delayed_job', '~> 2.0.8'
77
+ #{boilerplate_gems}
78
+ RB
79
+ end
@@ -0,0 +1,33 @@
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 'delayed_job'
6
+ begin
7
+ require 'active_record'
8
+ rescue LoadError
9
+ # Let it fail, might be working with another library
10
+ end
11
+
12
+ # Deprecated on some versions, required on others. Hurray!
13
+ Delayed::Worker.guess_backend
14
+
15
+ if Delayed::Worker.backend.to_s == "Delayed::Backend::ActiveRecord::Job"
16
+ $db_connection = ActiveRecord::Base.establish_connection(:adapter => "sqlite3",
17
+ :database => ":memory:")
18
+
19
+ begin
20
+ require 'generators/delayed_job/templates/migration'
21
+ rescue MissingSourceFile
22
+ # Back on DJ v2 the generators aren't in the lib folder so we have to do some
23
+ # sneaky stuff to get them loaded. Still better than dup'ing them, though.
24
+ dj_dir = ($:).grep(/delayed_job-/).first
25
+ require "#{dj_dir}/../generators/delayed_job/templates/migration"
26
+ end
27
+
28
+ class CreateDelayedJobs
29
+ @connection = $db_connection
30
+ end
31
+
32
+ CreateDelayedJobs.up
33
+ end