Sha256: 0538b74b2e9e855bdfa84a8e9cfd9edb31c5e8db217c522ff111c9752384d4a8

Contents?: true

Size: 781 Bytes

Versions: 22

Compression:

Stored size: 781 Bytes

Contents

require 'spec_helper'

describe 'Client after reconnect' do
  let(:client) { authorized_client }

  it 'works' do
    client['test'].insert_one('testk' => 'testv')

    client.reconnect

    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

    thread.kill
    # context switch to let the thread get killed
    sleep 0.1
    expect(thread).not_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

Version data entries

22 entries across 22 versions & 2 rubygems

Version Path
tdiary-5.1.6 vendor/bundle/ruby/2.7.0/gems/mongo-2.8.0/spec/integration/reconnect_spec.rb
mongo-2.10.5 spec/integration/reconnect_spec.rb
mongo-2.10.4 spec/integration/reconnect_spec.rb
mongo-2.10.3 spec/integration/reconnect_spec.rb
mongo-2.9.2 spec/integration/reconnect_spec.rb
mongo-2.10.2 spec/integration/reconnect_spec.rb
mongo-2.10.1 spec/integration/reconnect_spec.rb
mongo-2.10.0 spec/integration/reconnect_spec.rb
mongo-2.9.1 spec/integration/reconnect_spec.rb
mongo-2.10.0.rc0 spec/integration/reconnect_spec.rb
mongo-2.9.1.rc0 spec/integration/reconnect_spec.rb
mongo-2.9.0 spec/integration/reconnect_spec.rb
mongo-2.9.0.rc1 spec/integration/reconnect_spec.rb
mongo-2.9.0.rc0 spec/integration/reconnect_spec.rb
mongo-2.8.0 spec/integration/reconnect_spec.rb
mongo-2.7.2 spec/integration/reconnect_spec.rb
mongo-2.8.0.rc0 spec/integration/reconnect_spec.rb
mongo-2.7.1 spec/integration/reconnect_spec.rb
mongo-2.7.0 spec/integration/reconnect_spec.rb
mongo-2.7.0.rc0 spec/integration/reconnect_spec.rb