spec/integration/reconnect_spec.rb in mongo-2.15.1 vs spec/integration/reconnect_spec.rb in mongo-2.16.0.alpha1

- old
+ new

@@ -14,26 +14,44 @@ doc = client['test'].find('testk' => 'testv').first expect(doc).not_to be_nil expect(doc['testk']).to eq('testv') end - it 'recreates monitor thread' do - thread = client.cluster.servers.first.monitor.instance_variable_get('@thread') - expect(thread).to be_alive + context 'non-lb' do + require_topology :single, :replica_set, :sharded - thread.kill - # context switch to let the thread get killed - sleep 0.1 - expect(thread).not_to be_alive + it 'recreates monitor thread' do + thread = client.cluster.servers.first.monitor.instance_variable_get('@thread') + expect(thread).to be_alive - client.reconnect + thread.kill + # context switch to let the thread get killed + sleep 0.1 + expect(thread).not_to be_alive - new_thread = client.cluster.servers.first.monitor.instance_variable_get('@thread') - expect(new_thread).not_to eq(thread) - expect(new_thread).to be_alive + client.reconnect + + new_thread = client.cluster.servers.first.monitor.instance_variable_get('@thread') + expect(new_thread).not_to eq(thread) + expect(new_thread).to be_alive + end end + context 'lb' do + require_topology :load_balanced + + it 'does not recreate monitor thread' do + thread = client.cluster.servers.first.monitor.instance_variable_get('@thread') + expect(thread).to be nil + + client.reconnect + + new_thread = client.cluster.servers.first.monitor.instance_variable_get('@thread') + expect(new_thread).to be nil + end + end + context 'with min_pool_size > 0' do let(:client) { authorized_client.with(min_pool_size: 1) } it 'recreates connection pool populator thread' do server = client.cluster.next_primary @@ -112,10 +130,10 @@ end context 'in sharded topology' do require_topology :sharded require_default_port_deployment - require_multi_shard + require_multi_mongos let(:expected_topology_cls) { Mongo::Cluster::Topology::Sharded } it_behaves_like 'recreates SRV monitor' end