Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -79,4 +79,4 @@ jobs:
path: |
test/dummy/log/test.log
if-no-files-found: ignore
retention-days: 7
retention-days: 30
8 changes: 5 additions & 3 deletions test/integration/concurrency_controls_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 4 additions & 0 deletions test/unit/dispatcher_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -117,6 +119,8 @@ class DispatcherTest < ActiveSupport::TestCase

dispatcher.start
wait_while_with_timeout(1.second) { !SolidQueue::ScheduledExecution.exists? }
ensure
dispatcher.stop
end

private
Expand Down
Loading