Skip to content

Commit

Permalink
test our branch
Browse files Browse the repository at this point in the history
  • Loading branch information
onyxraven committed Oct 16, 2024
1 parent b7c9f63 commit 1fd7999
Show file tree
Hide file tree
Showing 3 changed files with 102 additions and 5 deletions.
1 change: 1 addition & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ jobs:
- "4.3.0"
- "< 4.9.0"
- "~> 4.9"
- "https://github.com/Ibotta/resque-scheduler.git@enqueue-multi-rollback"
exclude:
# resque-scheduler (= 4.3.0) depends on redis (~> 3.3)
- redis-version: "~> 4.8"
Expand Down
12 changes: 8 additions & 4 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ when /^git:/, /^https:/
when 'latest'
gem 'resque'
else
gem 'resque', resque_version
versions = resque_version.split(',')
gem 'resque', *versions
end

case redis_version = ENV.fetch('REDIS_VERSION', 'latest')
Expand All @@ -19,20 +20,23 @@ when /^git:/, /^https:/
when 'latest'
gem 'redis'
else
gem 'redis', redis_version
versions = redis_version.split(',')
gem 'redis', *versions
end

case resque_scheduler_version = ENV.fetch('RESQUE_SCHEDULER_VERSION', 'none')
when 'master'
gem 'resque-scheduler', git: 'https://github.com/resque/resque-scheduler'
when /^git:/, /^https:/
gem 'resque-scheduler', git: resque_scheduler_version
repo, ref = resque_scheduler_version.split('@', 2)
gem 'resque-scheduler', git: repo, ref: ref
when 'latest'
gem 'resque-scheduler'
when 'none'
#noop
else
gem 'resque-scheduler', resque_scheduler_version
versions = resque_scheduler_version.split(',')
gem 'resque-scheduler', *versions
end

gemspec
94 changes: 93 additions & 1 deletion test/integration/resque-scheduler/delayed_job_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ def setup
Resque::Scheduler.quiet = true
Resque.redis.redis.flushall
@worker = Resque::Worker.new(:test)
# Resque::Scheduler.delayed_requeue_batch_size = 100
end

def test_delayed_item_enqueue
Expand All @@ -30,10 +29,103 @@ def test_delayed_item_enqueue
# assert that the active queue has the lonely job
if scheduler_version_compare('< 4.9')
assert_equal(1, Resque.size(Resque.queue_from_class(LonelyJob)))
elsif Resque::Scheduler::VERSION.end_with?('-ibotta')
assert_equal(1, Resque.size(Resque.queue_from_class(LonelyJob)))
else
# this is asserting that > 4.9 "fails" without the patch
assert_equal(0, Resque.size(Resque.queue_from_class(LonelyJob)))
end
end
end

class LockBatchOffTest < Minitest::Test

def setup
return unless Resque::Scheduler::VERSION.end_with?('-ibotta')

@batch_enabled = Resque::Scheduler.enable_delayed_requeue_batches
@batch_size = Resque::Scheduler.delayed_requeue_batch_size

$success = $lock_failed = $lock_expired = $enqueue_failed = 0
Resque::Scheduler.quiet = true
Resque.redis.redis.flushall
@worker = Resque::Worker.new(:test)

Resque::Scheduler.enable_delayed_requeue_batches = false
Resque::Scheduler.delayed_requeue_batch_size = 1
end

def teardown
Resque::Scheduler.enable_delayed_requeue_batches = @batch_enabled
Resque::Scheduler.delayed_requeue_batch_size = @batch_size
end

def test_delayed_item_enqueue
t = Time.now + 60

# Resque::Scheduler.expects(:enqueue_next_item).never

# create 90 jobs
90.times { Resque.enqueue_at(t, LonelyJob) }
assert_equal(90, Resque.delayed_timestamp_size(t))

Resque::Scheduler.enqueue_delayed_items_for_timestamp(t)
assert_equal(0, Resque.delayed_timestamp_size(t))

# assert that the active queue has the lonely job
if scheduler_version_compare('< 4.9')
assert_equal(1, Resque.size(Resque.queue_from_class(LonelyJob)))
elsif Resque::Scheduler::VERSION.end_with?('-ibotta')
assert_equal(1, Resque.size(Resque.queue_from_class(LonelyJob)))
else
# this is asserting that > 4.9 "fails" without the patch
assert_equal(0, Resque.size(Resque.queue_from_class(LonelyJob)))
end
end
end

class LockBatchOnTest < Minitest::Test

def setup
return unless Resque::Scheduler::VERSION.end_with?('-ibotta')

@batch_enabled = Resque::Scheduler.enable_delayed_requeue_batches
@batch_size = Resque::Scheduler.delayed_requeue_batch_size

$success = $lock_failed = $lock_expired = $enqueue_failed = 0
Resque::Scheduler.quiet = true
Resque.redis.redis.flushall
@worker = Resque::Worker.new(:test)

Resque::Scheduler.enable_delayed_requeue_batches = true
Resque::Scheduler.delayed_requeue_batch_size = 100
end

def teardown
Resque::Scheduler.enable_delayed_requeue_batches = @batch_enabled
Resque::Scheduler.delayed_requeue_batch_size = @batch_size
end

def test_delayed_item_enqueue
t = Time.now + 60

# Resque::Scheduler.expects(:enqueue_next_item).never

# create 90 jobs
90.times { Resque.enqueue_at(t, LonelyJob) }
assert_equal(90, Resque.delayed_timestamp_size(t))

Resque::Scheduler.enqueue_delayed_items_for_timestamp(t)
assert_equal(0, Resque.delayed_timestamp_size(t))

# assert that the active queue has the lonely job
if scheduler_version_compare('< 4.9')
assert_equal(1, Resque.size(Resque.queue_from_class(LonelyJob)))
elsif Resque::Scheduler::VERSION.end_with?('-ibotta')
assert_equal(0, Resque.size(Resque.queue_from_class(LonelyJob)))
else
# this is asserting that > 4.9 "fails" without the patch
assert_equal(0, Resque.size(Resque.queue_from_class(LonelyJob)))
end
end
end

0 comments on commit 1fd7999

Please sign in to comment.