File tree Expand file tree Collapse file tree 1 file changed +23
-8
lines changed
elasticsearch-transport/spec/elasticsearch/connections Expand file tree Collapse file tree 1 file changed +23
-8
lines changed Original file line number Diff line number Diff line change @@ -41,30 +41,41 @@ def select(options={})
4141
4242 describe 'the Random selector' do
4343
44+ let ( :connections ) do
45+ [ 1 , 2 ]
46+ end
47+
4448 let ( :selector ) do
45- described_class ::Random . new ( connections : [ 1 , 2 ] )
49+ described_class ::Random . new ( connections : connections )
4650 end
4751
4852 it 'is initialized with connections' do
49- expect ( selector . connections ) . to eq ( [ 1 , 2 ] )
53+ expect ( selector . connections ) . to eq ( connections )
5054 end
5155
5256 describe '#select' do
5357
58+ let ( :connections ) do
59+ ( 0 ..19 ) . to_a
60+ end
61+
5462 it 'returns a connection' do
5563 expect ( selector . select ) . to be_a ( Integer )
5664 end
5765
5866 context 'when multiple threads are used' do
5967
6068 it 'allows threads to select connections in parallel' do
61- threads = [ ]
62- threads << Thread . new do
63- 50 . times do
64- selector . select
69+ expect ( 10 . times . collect do
70+ threads = [ ]
71+ 20 . times do
72+ threads << Thread . new do
73+ selector . select
74+ end
6575 end
66- end
67- threads . collect { |t | t . join }
76+ threads . map { |t | t . join }
77+ selector . select
78+ end ) . to all ( be_a ( Integer ) )
6879 end
6980 end
7081 end
@@ -99,6 +110,10 @@ def select(options={})
99110 ( 0 ..19 ) . to_a
100111 end
101112
113+ it 'returns a connection' do
114+ expect ( selector . select ) . to be_a ( Integer )
115+ end
116+
102117 it 'allows threads to select connections in parallel' do
103118 expect ( 10 . times . collect do
104119 threads = [ ]
You can’t perform that action at this time.
0 commit comments