Skip to content

Commit ad57f9a

Browse files
committed
[CLIENT] Fix specs for selecting a connection
1 parent 3da23a1 commit ad57f9a

File tree

2 files changed

+13
-10
lines changed

2 files changed

+13
-10
lines changed

elasticsearch-transport/spec/elasticsearch/connections/collection_spec.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -238,16 +238,16 @@
238238
end
239239

240240
it 'allows threads to select connections in parallel' do
241-
expect(10.times.collect do
241+
expect(10.times.collect do
242242
threads = []
243243
20.times do
244244
threads << Thread.new do
245245
collection.get_connection
246246
end
247247
end
248-
threads.collect { |t| t.join }
248+
threads.map { |t| t.join }
249249
collection.get_connection.host[:host]
250-
end).to all(eq(0))
250+
end).to eq((0..9).to_a)
251251
end
252252
end
253253
end

elasticsearch-transport/spec/elasticsearch/connections/selector_spec.rb

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -96,17 +96,20 @@ def select(options={})
9696
context 'when multiple threads are used' do
9797

9898
let(:connections) do
99-
(1..100).to_a
99+
(0..19).to_a
100100
end
101101

102102
it 'allows threads to select connections in parallel' do
103-
threads = []
104-
threads << Thread.new do
105-
2000.times do |i|
106-
selector.select
103+
expect(10.times.collect do
104+
threads = []
105+
20.times do
106+
threads << Thread.new do
107+
selector.select
108+
end
107109
end
108-
end
109-
threads.collect {|t| t.join}
110+
threads.map { |t| t.join }
111+
selector.select
112+
end).to eq((0..9).to_a)
110113
end
111114
end
112115
end

0 commit comments

Comments
 (0)