Skip to content
Open
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
10 changes: 7 additions & 3 deletions test/unit/dispatcher_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,17 @@ class DispatcherTest < ActiveSupport::TestCase

test "polling queries are logged" do
log = StringIO.new
polling_query = /SELECT .* FROM .solid_queue_scheduled_executions. WHERE/

with_active_record_logger(ActiveSupport::Logger.new(log)) do
with_polling(silence: false) do
rewind_io(log)
@dispatcher.start
sleep 0.5.second
wait_while_with_timeout(3.seconds) { !log.string.match?(polling_query) }
end
end

assert_match /SELECT .* FROM .solid_queue_scheduled_executions. WHERE/, log.string
assert_match polling_query, log.string
end

test "polling queries can be silenced" do
Expand Down Expand Up @@ -108,7 +110,9 @@ class DispatcherTest < ActiveSupport::TestCase
assert_equal 3, SolidQueue::ScheduledExecution.count

dispatcher.start
wait_while_with_timeout(1.second) { SolidQueue::ScheduledExecution.any? }
# Give the dispatcher thread enough margin to boot and run its first polls
# on a slow runner; the wait returns as soon as everything is dispatched.
wait_while_with_timeout(5.seconds) { SolidQueue::ScheduledExecution.any? }

skip_active_record_query_cache do
assert_equal 0, SolidQueue::ScheduledExecution.count
Expand Down
6 changes: 4 additions & 2 deletions test/unit/worker_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -146,14 +146,16 @@ class WorkerTest < ActiveSupport::TestCase

test "polling queries are logged" do
log = StringIO.new
polling_query = /SELECT .* FROM .solid_queue_ready_executions. WHERE .solid_queue_ready_executions...queue_name./

with_active_record_logger(ActiveSupport::Logger.new(log)) do
with_polling(silence: false) do
@worker.start
sleep 0.2
wait_while_with_timeout(3.seconds) { !log.string.match?(polling_query) }
end
end

assert_match /SELECT .* FROM .solid_queue_ready_executions. WHERE .solid_queue_ready_executions...queue_name./, log.string
assert_match polling_query, log.string
end

test "polling queries can be silenced" do
Expand Down
Loading