Sha256: f6ff60397868d7710b1c288ea3058fde684bede0fbe21f3e313e3cc4b75c38f7

Contents?: true

Size: 1.01 KB

Versions: 18

Compression:

Stored size: 1.01 KB

Contents

# frozen_string_literal: true
# encoding: utf-8

require 'spec_helper'

describe Mongo::Cluster::SocketReaper do

  let(:cluster) do
    authorized_client.cluster
  end

  let(:reaper) do
    described_class.new(cluster)
  end

  describe '#initialize' do

    it 'takes a cluster as an argument' do
      expect(reaper).to be_a(described_class)
    end
  end

  describe '#execute' do

    before do
      # Ensure all servers are discovered
      cluster.servers_list.each do |server|
        server.scan!
      end

      # Stop the reaper that is attached to the cluster, since it
      # runs the same code we are running and can interfere with our assertions
      cluster.instance_variable_get('@periodic_executor').stop!
    end

    it 'calls close_idle_sockets on each connection pool in the cluster' do
      RSpec::Mocks.with_temporary_scope do
        cluster.servers.each do |s|
          expect(s.pool).to receive(:close_idle_sockets).and_call_original
        end

        reaper.execute
      end
    end
  end
end

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
mongo-2.16.4 spec/mongo/cluster/socket_reaper_spec.rb
mongo-2.17.4 spec/mongo/cluster/socket_reaper_spec.rb
mongo-2.18.3 spec/mongo/cluster/socket_reaper_spec.rb
mongo-2.18.2 spec/mongo/cluster/socket_reaper_spec.rb
mongo-2.17.3 spec/mongo/cluster/socket_reaper_spec.rb
mongo-2.18.1 spec/mongo/cluster/socket_reaper_spec.rb
mongo-2.18.0 spec/mongo/cluster/socket_reaper_spec.rb
mongo-2.17.2 spec/mongo/cluster/socket_reaper_spec.rb
mongo-2.16.3 spec/mongo/cluster/socket_reaper_spec.rb
mongo-2.18.0.beta1 spec/mongo/cluster/socket_reaper_spec.rb
mongo-2.16.2 spec/mongo/cluster/socket_reaper_spec.rb
mongo-2.17.1 spec/mongo/cluster/socket_reaper_spec.rb
mongo-2.16.1 spec/mongo/cluster/socket_reaper_spec.rb
mongo-2.17.0 spec/mongo/cluster/socket_reaper_spec.rb
mongo-2.16.0 spec/mongo/cluster/socket_reaper_spec.rb
mongo-2.15.1 spec/mongo/cluster/socket_reaper_spec.rb
mongo-2.16.0.alpha1 spec/mongo/cluster/socket_reaper_spec.rb
mongo-2.15.0 spec/mongo/cluster/socket_reaper_spec.rb