Skip to content

Commit 9e90d91

Browse files
committed
Refactored brittle thread pool tests.
1 parent 2eb120e commit 9e90d91

File tree

2 files changed

+27
-12
lines changed

2 files changed

+27
-12
lines changed

spec/concurrent/ruby_thread_pool_executor_spec.rb

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,33 @@ module Concurrent
2222

2323
it_should_behave_like :thread_pool_executor
2424

25+
context '#remaining_capacity' do
26+
27+
let!(:expected_max){ 100 }
28+
29+
subject do
30+
RubyThreadPoolExecutor.new(
31+
min_threads: 10,
32+
max_threads: 20,
33+
idletime: 60,
34+
max_queue: expected_max,
35+
overflow_policy: :discard
36+
)
37+
end
38+
39+
it 'returns :max_length when no tasks are enqueued' do
40+
5.times{ subject.post{ nil } }
41+
sleep(0.1)
42+
subject.remaining_capacity.should eq expected_max
43+
end
44+
45+
it 'returns the remaining capacity when tasks are enqueued' do
46+
100.times{ subject.post{ sleep(0.5) } }
47+
sleep(0.1)
48+
subject.remaining_capacity.should < expected_max
49+
end
50+
end
51+
2552
context '#overload_policy' do
2653

2754
let!(:min_threads){ 1 }

spec/concurrent/thread_pool_executor_shared.rb

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -144,18 +144,6 @@
144144
subject.remaining_capacity.should eq expected_max
145145
end
146146

147-
it 'returns :max_length when no tasks are enqueued' do
148-
5.times{ subject.post{ nil } }
149-
sleep(0.1)
150-
subject.remaining_capacity.should eq eq expected_max
151-
end
152-
153-
it 'returns the remaining capacity when tasks are enqueued' do
154-
pending('intermittently failing')
155-
100.times{ subject.post{ sleep(0.5) } }
156-
subject.remaining_capacity.should < expected_max
157-
end
158-
159147
it 'returns :max_length when stopped' do
160148
100.times{ subject.post{ sleep(0.5) } }
161149
sleep(0.1)

0 commit comments

Comments
 (0)