diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index ddc47f50..7485e17e 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -79,4 +79,4 @@ jobs: path: | test/dummy/log/test.log if-no-files-found: ignore - retention-days: 7 + retention-days: 30 diff --git a/test/integration/concurrency_controls_test.rb b/test/integration/concurrency_controls_test.rb index 178c796d..b3be95c5 100644 --- a/test/integration/concurrency_controls_test.rb +++ b/test/integration/concurrency_controls_test.rb @@ -36,14 +36,16 @@ class ConcurrencyControlsTest < ActiveSupport::TestCase end test "schedule several conflicting jobs over the same record sequentially" do - UpdateResultJob.set(wait: 0.23.seconds).perform_later(@result, name: "000", pause: 0.1.seconds) + # Writes to @result at 0.4s + UpdateResultJob.set(wait: 0.2.seconds).perform_later(@result, name: "000", pause: 0.2.seconds) ("A".."F").each_with_index do |name, i| - NonOverlappingUpdateResultJob.set(wait: (0.2 + i * 0.01).seconds).perform_later(@result, name: name, pause: 0.3.seconds) + # "A" is enqueued at 0.2s and writes to @result at 0.6s, the write at 0.4s gets overwritten + NonOverlappingUpdateResultJob.set(wait: (0.2 + i * 0.1).seconds).perform_later(@result, name: name, pause: 0.4.seconds) end ("G".."K").each_with_index do |name, i| - NonOverlappingUpdateResultJob.set(wait: (0.3 + i * 0.01).seconds).perform_later(@result, name: name) + NonOverlappingUpdateResultJob.set(wait: (1 + i * 0.1).seconds).perform_later(@result, name: name) end wait_for_jobs_to_finish_for(5.seconds) diff --git a/test/unit/dispatcher_test.rb b/test/unit/dispatcher_test.rb index 9aa2196e..89d87c1a 100644 --- a/test/unit/dispatcher_test.rb +++ b/test/unit/dispatcher_test.rb @@ -107,6 +107,8 @@ class DispatcherTest < ActiveSupport::TestCase assert_equal 0, SolidQueue::ScheduledExecution.count assert_equal 3, SolidQueue::ReadyExecution.count + ensure + dispatcher.stop end test "sleeps `polling_interval` between polls if there are no un-dispatched jobs" do @@ -117,6 +119,8 @@ class DispatcherTest < ActiveSupport::TestCase dispatcher.start wait_while_with_timeout(1.second) { !SolidQueue::ScheduledExecution.exists? } + ensure + dispatcher.stop end private