Skip to content
Merged
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
13 changes: 8 additions & 5 deletions test/test_concurrent_workers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,8 @@

class TestConcurrentWorkers < RSpecQTest
# The 'passing_concurrent' suite contains 5 spec files each containing a
# single example taking 2". We spawn that many workers so we expect roughly
# 2 second total execution time. We some more to account for fork and
# rspec boot and other setup overheads
# single example taking 2". We spawn that many workers, so the work should
# overlap rather than run back to back.
def test_passing_suite
build_id = rand_id
pids = []
Expand All @@ -20,10 +19,14 @@ def test_passing_suite

elapsed = Process.clock_gettime(Process::CLOCK_MONOTONIC) - start

assert_operator elapsed, :<, 5

queue = RSpecQ::Queue.new(build_id, "foo", REDIS_OPTS, 60)

# Parallelism, not runner speed: wall clock has to beat the summed job
# time, since a serialized run takes at least as long as the sum. A fixed
# threshold flakes instead on a loaded CI box, where booting five rubies
# eats the margin even though the work did overlap.
assert_operator elapsed, :<, queue.total_execution_time_ms / 1000.0

assert_queue_well_formed(queue)
assert queue.build_successful?
assert_equal job_count, queue.example_count
Expand Down