Sha256: 4f006759bf34d770c240f2c48b865504ef52b85a1e40de1222514647dc2f6157

Contents?: true

Size: 1.16 KB

Versions: 9

Compression:

Stored size: 1.16 KB

Contents

# frozen_string_literal: true
# rubocop:todo all

require 'spec_helper'

# This test repeatedly creates and closes clients across several threads.
# Its goal is to ensure that the push monitor connections specifically get
# closed without any errors or warnings being reported to applications.
#
# Although the test is specifically meant to test 4.4+ servers (that utilize
# the push monitor) in non-LB connections, run it everywhere for good measure.
describe 'Push monitor close test' do
  require_stress

  let(:options) do
    SpecConfig.instance.all_test_options
  end

  before(:all) do
    # load if necessary
    ClusterConfig.instance.primary_address
    ClientRegistry.instance.close_all_clients
  end

  it 'does not warn/error on cleanup' do
    Mongo::Logger.logger.should_not receive(:warn)

    threads = 10.times.map do
      Thread.new do
        10.times do
          client = new_local_client([ClusterConfig.instance.primary_address.seed], options)
          if rand > 0.33
            client.command(ping: 1)
            sleep(rand * 3)
          end
          client.close
          STDOUT << '.'
        end
      end
    end
    threads.each(&:join)
    puts
  end
end

Version data entries

9 entries across 9 versions & 2 rubygems

Version Path
mongo-2.21.0 spec/stress/push_monitor_close_spec.rb
mongo-2.20.1 spec/stress/push_monitor_close_spec.rb
mogno-2.20.0 spec/stress/push_monitor_close_spec.rb
mogno-1.0.0 spec/stress/push_monitor_close_spec.rb
mongo-2.20.0 spec/stress/push_monitor_close_spec.rb
mongo-2.19.3 spec/stress/push_monitor_close_spec.rb
mongo-2.19.2 spec/stress/push_monitor_close_spec.rb
mongo-2.19.1 spec/stress/push_monitor_close_spec.rb
mongo-2.19.0 spec/stress/push_monitor_close_spec.rb