Sha256: bb3add5ce468a436144ec5f64492c1255bffc9b228bb5642c67e20903aad3479

Contents?: true

Size: 1.29 KB

Versions: 9

Compression:

Stored size: 1.29 KB

Contents

require 'spec_helper'

describe 'Server::Monitor' do

  let(:client) do
    new_local_client([ClusterConfig.instance.primary_address_str],
      SpecConfig.instance.test_options.merge(SpecConfig.instance.auth_options.merge(
        monitor_options)))
  end

  let(:monitor_options) do
    {heartbeat_frequency: 1}
  end

  it 'refreshes server descriptions in background', retry: 3 do
    server = client.cluster.next_primary

    expect(server.description).not_to be_unknown

    server.unknown!

    # This is racy, especially in JRuby, because the monitor may have
    # already run and updated the description. Because of this we retry
    # the test a few times.
    expect(server.description).to be_unknown

    # Wait for background thread to update the description
    sleep 1.5

    expect(server.description).not_to be_unknown
  end

  context 'server-pushed ismaster' do
    min_server_fcv '4.4'
    require_topology :replica_set

    let(:monitor_options) do
      {heartbeat_frequency: 20}
    end

    it 'updates server description' do
      starting_primary_address = client.cluster.next_primary.address

      ClusterTools.instance.step_down

      sleep 2

      new_primary_address = client.cluster.next_primary.address
      new_primary_address.should_not == starting_primary_address
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
mongo-2.13.3 spec/integration/server_monitor_spec.rb
mongo-2.14.1 spec/integration/server_monitor_spec.rb
mongo-2.15.0.alpha spec/integration/server_monitor_spec.rb
mongo-2.13.2 spec/integration/server_monitor_spec.rb
mongo-2.14.0 spec/integration/server_monitor_spec.rb
mongo-2.14.0.rc1 spec/integration/server_monitor_spec.rb
mongo-2.13.1 spec/integration/server_monitor_spec.rb
mongo-2.13.0 spec/integration/server_monitor_spec.rb
mongo-2.13.0.rc1 spec/integration/server_monitor_spec.rb