Sha256: 545b01d9fb9f099761e082cf84015b066586685c1bfddf85c15aacb7d798be89

Contents?: true

Size: 1.38 KB

Versions: 13

Compression:

Stored size: 1.38 KB

Contents

require 'spec_helper'

describe 'SDAM events' do
  let(:subscriber) { Mongo::SDAMMonitoring::TestSubscriber.new }

  before do
    ClientRegistry.instance.close_all_clients
  end

  describe 'server closed event' do
    it 'is published when client is closed' do
      client = ClientRegistry.instance.new_local_client(
        SpecConfig.instance.addresses, SpecConfig.instance.test_options)
      client.subscribe(Mongo::Monitoring::SERVER_CLOSED, subscriber)

      # get the client connected
      client.database.command(ismaster: 1)
      expect(subscriber.events).to be_empty

      client.close

      expect(subscriber.events).not_to be_empty
      event = subscriber.first_event('server_closed_event')
      expect(event).not_to be_nil
    end
  end

  describe 'topology closed event' do
    it 'is published when client is closed' do
      client = ClientRegistry.instance.new_local_client(
        SpecConfig.instance.addresses, SpecConfig.instance.test_options)
      client.subscribe(Mongo::Monitoring::TOPOLOGY_CLOSED, subscriber)

      # get the client connected
      client.database.command(ismaster: 1)
      expect(subscriber.events).to be_empty

      client.close

      expect(subscriber.events).not_to be_empty
      event = subscriber.first_event('topology_closed_event')
      expect(event).not_to be_nil

      expect(event.topology).to eql(client.cluster.topology)
    end
  end
end

Version data entries

13 entries across 13 versions & 2 rubygems

Version Path
tdiary-5.1.6 vendor/bundle/ruby/2.7.0/gems/mongo-2.8.0/spec/integration/sdam_events_spec.rb
mongo-2.9.2 spec/integration/sdam_events_spec.rb
mongo-2.9.1 spec/integration/sdam_events_spec.rb
mongo-2.9.1.rc0 spec/integration/sdam_events_spec.rb
mongo-2.9.0 spec/integration/sdam_events_spec.rb
mongo-2.9.0.rc1 spec/integration/sdam_events_spec.rb
mongo-2.9.0.rc0 spec/integration/sdam_events_spec.rb
mongo-2.8.0 spec/integration/sdam_events_spec.rb
mongo-2.7.2 spec/integration/sdam_events_spec.rb
mongo-2.8.0.rc0 spec/integration/sdam_events_spec.rb
mongo-2.7.1 spec/integration/sdam_events_spec.rb
mongo-2.7.0 spec/integration/sdam_events_spec.rb
mongo-2.7.0.rc0 spec/integration/sdam_events_spec.rb