Skip to content

Commit

Permalink
Merge pull request #1770 from newrelic/hide_warnings_fix_active_job
Browse files Browse the repository at this point in the history
Fix active job 6.0 failures when retry job
  • Loading branch information
tannalynn authored Jan 26, 2023
2 parents 70429a0 + 5d3dba6 commit e7514f4
Show file tree
Hide file tree
Showing 13 changed files with 32 additions and 2 deletions.
2 changes: 2 additions & 0 deletions test/environments/norails/Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
# Add your own tasks in files placed in lib/tasks ending in .rake,
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.

require_relative '../../warning_test_helper'

require 'rake'
require 'tasks/all'

Expand Down
1 change: 1 addition & 0 deletions test/environments/rails32/Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
# Add your own tasks in files placed in lib/tasks ending in .rake,
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.

require_relative '../../warning_test_helper'
require_relative 'config/application'
require 'rake'

Expand Down
2 changes: 2 additions & 0 deletions test/environments/rails40/Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
# Add your own tasks in files placed in lib/tasks ending in .rake,
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.

require_relative '../../warning_test_helper'

require_relative 'config/application'
require 'rake'

Expand Down
2 changes: 2 additions & 0 deletions test/environments/rails41/Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
# Add your own tasks in files placed in lib/tasks ending in .rake,
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.

require_relative '../../warning_test_helper'

require_relative 'config/application'
require 'rake'

Expand Down
2 changes: 2 additions & 0 deletions test/environments/rails42/Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
# Add your own tasks in files placed in lib/tasks ending in .rake,
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.

require_relative '../../warning_test_helper'

require_relative 'config/application'
require 'rake'

Expand Down
2 changes: 2 additions & 0 deletions test/environments/rails50/Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
# Add your own tasks in files placed in lib/tasks ending in .rake,
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.

require_relative '../../warning_test_helper'

require_relative 'config/application'
require 'rake'

Expand Down
2 changes: 2 additions & 0 deletions test/environments/rails52/Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
# Add your own tasks in files placed in lib/tasks ending in .rake,
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.

require_relative '../../warning_test_helper'

require_relative 'config/application'
require 'rake'

Expand Down
2 changes: 2 additions & 0 deletions test/environments/rails60/Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
# Add your own tasks in files placed in lib/tasks ending in .rake,
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.

require_relative '../../warning_test_helper'

require_relative 'config/application'
require 'rake'

Expand Down
2 changes: 2 additions & 0 deletions test/environments/rails61/Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
# Add your own tasks in files placed in lib/tasks ending in .rake,
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.

require_relative '../../warning_test_helper'

require_relative 'config/application'
require 'rake'

Expand Down
2 changes: 2 additions & 0 deletions test/environments/rails70/Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
# Add your own tasks in files placed in lib/tasks ending in .rake,
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.

require_relative '../../warning_test_helper'

require_relative 'config/application'

Rails.application.load_tasks
Expand Down
2 changes: 2 additions & 0 deletions test/environments/railsedge/Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
# Add your own tasks in files placed in lib/tasks ending in .rake,
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.

require_relative '../../warning_test_helper'

require_relative "config/application"

Rails.application.load_tasks
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@
ActiveJob.gem_version >= Gem::Version.new('6.0.0')
require_relative 'rails/active_job_subscriber'
else
puts "Skipping tests in #{__FILE__} because ActiveJob is unavailable or < 6.0"
puts "Skipping tests in #{File.basename(__FILE__)} because ActiveJob is unavailable or < 6.0" if ENV['VERBOSE_TEST_OUPUT']
end
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ class TestJob < ActiveJob::Base
discard_on DiscardMe

def perform(error = nil)
# rails 6.0 job serialization breaks if you try to retry a job with a class as a param
raise RetryMe if error == 'RetryMe'
raise error if error

rand(1138)
Expand Down Expand Up @@ -60,7 +62,14 @@ def test_enqueue_active_job
# enqueue_retry.active_job
def test_perform_start_active_job_and_enqueue_retry_active_job
in_transaction do |txn|
TestJob.perform_now(RetryMe)
# rails 6.0 job serialization breaks if you try to retry a job with a class as a param
# this works fine if you aren't attempting to retry or you're using a later rails version
job_arg = if Gem::Version.new(Rails::VERSION::STRING) < Gem::Version.new('6.1.0')
'RetryMe'
else
RetryMe
end
TestJob.perform_now(job_arg)
validate_transaction(txn, %w[enqueue_retry perform_start])
end
end
Expand Down

0 comments on commit e7514f4

Please sign in to comment.