From 1af474550492f23349dc9cf2e21d81273cd66aca Mon Sep 17 00:00:00 2001 From: Justin Hart Date: Fri, 8 Nov 2024 15:31:15 -0800 Subject: [PATCH 1/4] ability to switch to the ibotta-gem --- .github/workflows/test-scheduler-lock.yml | 2 +- scheduler-lock/Gemfile | 21 ++++++++++++++++----- 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/.github/workflows/test-scheduler-lock.yml b/.github/workflows/test-scheduler-lock.yml index 727bb9b..ee7166f 100644 --- a/.github/workflows/test-scheduler-lock.yml +++ b/.github/workflows/test-scheduler-lock.yml @@ -40,7 +40,7 @@ jobs: resque-lock-timeout-version: - "latest" - "https://github.com/Ibotta/resque-lock-timeout.git@v0.5.0-ibotta" - - "https://github.com/Ibotta/resque-lock-timeout.git@tests-with-scheduler" + - "ibotta-resque-lock-timeout:https://github.com/Ibotta/resque-lock-timeout.git@v0.5.1" exclude: # resque-scheduler (= 4.3.0) depends on redis (~> 3.3) - redis-version: "~> 4.8" diff --git a/scheduler-lock/Gemfile b/scheduler-lock/Gemfile index 0018697..cf95b91 100644 --- a/scheduler-lock/Gemfile +++ b/scheduler-lock/Gemfile @@ -37,17 +37,28 @@ else gem "resque-scheduler", *versions end -case resque_lock_timeout_version = ENV.fetch("RESQUE_LOCK_TIMEOUT_VERSION", "latest") +resque_lock_timeout_version = ENV.fetch("RESQUE_LOCK_TIMEOUT_VERSION", "latest") +capture_resque_lock_timeout = resque_lock_timeout_version.split(":", 2) +resque_lock_timeout_gem = if capture_resque_lock_timeout[1] + resque_lock_timeout_version = capture_resque_lock_timeout[1] + capture_resque_lock_timeout[0] +else + "resque-lock-timeout" +end +puts "resque_lock_timeout_gem: #{resque_lock_timeout_gem}" +puts "resque_lock_timeout_version: #{resque_lock_timeout_version}" + +case resque_lock_timeout_version when "master" - gem "resque-lock-timeout", git: "https://github.com/Ibotta/resque-lock-timeout.git" + gem resque_lock_timeout_gem, git: "https://github.com/Ibotta/resque-lock-timeout.git" when /^git:/, /^https:/ repo, ref = resque_lock_timeout_version.split("@", 2) - gem "resque-lock-timeout", git: repo, ref: ref + gem resque_lock_timeout_gem, git: repo, ref: ref when "latest" - gem "resque-lock-timeout" + gem resque_lock_timeout_gem else versions = resque_lock_timeout_version.split(",") - gem "resque-lock-timeout", *versions + gem resque_lock_timeout_gem, *versions end gem "rake" From 7871ccf231ac6b60495ccccb0d27bb2d82fb3925 Mon Sep 17 00:00:00 2001 From: Justin Hart Date: Fri, 8 Nov 2024 15:36:34 -0800 Subject: [PATCH 2/4] use a semicolon instead i guess :P --- .github/workflows/test-scheduler-lock.yml | 2 +- scheduler-lock/Gemfile | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test-scheduler-lock.yml b/.github/workflows/test-scheduler-lock.yml index ee7166f..f55bb46 100644 --- a/.github/workflows/test-scheduler-lock.yml +++ b/.github/workflows/test-scheduler-lock.yml @@ -40,7 +40,7 @@ jobs: resque-lock-timeout-version: - "latest" - "https://github.com/Ibotta/resque-lock-timeout.git@v0.5.0-ibotta" - - "ibotta-resque-lock-timeout:https://github.com/Ibotta/resque-lock-timeout.git@v0.5.1" + - "ibotta-resque-lock-timeout;https://github.com/Ibotta/resque-lock-timeout.git@v0.5.1" exclude: # resque-scheduler (= 4.3.0) depends on redis (~> 3.3) - redis-version: "~> 4.8" diff --git a/scheduler-lock/Gemfile b/scheduler-lock/Gemfile index cf95b91..35e4aee 100644 --- a/scheduler-lock/Gemfile +++ b/scheduler-lock/Gemfile @@ -38,7 +38,7 @@ else end resque_lock_timeout_version = ENV.fetch("RESQUE_LOCK_TIMEOUT_VERSION", "latest") -capture_resque_lock_timeout = resque_lock_timeout_version.split(":", 2) +capture_resque_lock_timeout = resque_lock_timeout_version.split(";", 2) resque_lock_timeout_gem = if capture_resque_lock_timeout[1] resque_lock_timeout_version = capture_resque_lock_timeout[1] capture_resque_lock_timeout[0] From 7b92d7b0903a6d0bc07e6febf747dcc8b7388982 Mon Sep 17 00:00:00 2001 From: Justin Hart Date: Mon, 11 Nov 2024 13:25:37 -0800 Subject: [PATCH 3/4] use workflow --- .github/workflows/test-scheduler-lock.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/test-scheduler-lock.yml b/.github/workflows/test-scheduler-lock.yml index f55bb46..62c701f 100644 --- a/.github/workflows/test-scheduler-lock.yml +++ b/.github/workflows/test-scheduler-lock.yml @@ -2,6 +2,7 @@ on: push: branches: [$default-branch] pull_request: + workflow_dispatch: jobs: test-scheduler-lock: runs-on: ubuntu-latest From d77ea58c49e8ea4a0429335a8b34ddfb107868fc Mon Sep 17 00:00:00 2001 From: Justin Hart Date: Mon, 11 Nov 2024 13:42:22 -0800 Subject: [PATCH 4/4] simplify, and disable instead of enable --- scheduler-lock/test/delayed_job_test.rb | 38 +++++++------------------ 1 file changed, 11 insertions(+), 27 deletions(-) diff --git a/scheduler-lock/test/delayed_job_test.rb b/scheduler-lock/test/delayed_job_test.rb index 30cb36d..7a4c6dc 100644 --- a/scheduler-lock/test/delayed_job_test.rb +++ b/scheduler-lock/test/delayed_job_test.rb @@ -30,8 +30,6 @@ 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))) @@ -39,10 +37,10 @@ def test_delayed_item_enqueue end end -if Resque::Scheduler::VERSION.end_with?("-ibotta") +if scheduler_version_compare(">= 4.11") class LockBatchOffTest < Minitest::Test def setup - @batch_enabled = Resque::Scheduler.enable_delayed_requeue_batches + @batch_enabled = Resque::Scheduler.disable_delayed_requeue_batches @batch_size = Resque::Scheduler.delayed_requeue_batch_size $success = $lock_failed = $lock_expired = $enqueue_failed = 0 @@ -50,12 +48,12 @@ def setup Resque.redis.redis.flushall @worker = Resque::Worker.new(:test) - Resque::Scheduler.enable_delayed_requeue_batches = false + Resque::Scheduler.disable_delayed_requeue_batches = true Resque::Scheduler.delayed_requeue_batch_size = 1 end def teardown - Resque::Scheduler.enable_delayed_requeue_batches = @batch_enabled + Resque::Scheduler.disable_delayed_requeue_batches = @batch_enabled Resque::Scheduler.delayed_requeue_batch_size = @batch_size end @@ -72,21 +70,14 @@ def test_delayed_item_enqueue 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") - # should act like before - 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 + # should act like before, and have an item queued + assert_equal(1, Resque.size(Resque.queue_from_class(LonelyJob))) end end class LockBatchOnTest < Minitest::Test def setup - @batch_enabled = Resque::Scheduler.enable_delayed_requeue_batches + @batch_enabled = Resque::Scheduler.disable_delayed_requeue_batches @batch_size = Resque::Scheduler.delayed_requeue_batch_size $success = $lock_failed = $lock_expired = $enqueue_failed = 0 @@ -94,12 +85,12 @@ def setup Resque.redis.redis.flushall @worker = Resque::Worker.new(:test) - Resque::Scheduler.enable_delayed_requeue_batches = true + Resque::Scheduler.disable_delayed_requeue_batches = false Resque::Scheduler.delayed_requeue_batch_size = 100 end def teardown - Resque::Scheduler.enable_delayed_requeue_batches = @batch_enabled + Resque::Scheduler.disable_delayed_requeue_batches = @batch_enabled Resque::Scheduler.delayed_requeue_batch_size = @batch_size end @@ -115,15 +106,8 @@ def test_delayed_item_enqueue 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 + # using batches, so the lonely job gets rejected "fail" + assert_equal(0, Resque.size(Resque.queue_from_class(LonelyJob))) end end