mongo 2.6.1 → 2.6.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (47) hide show
  1. checksums.yaml +4 -4
  2. checksums.yaml.gz.sig +4 -1
  3. data.tar.gz.sig +0 -0
  4. data/lib/mongo/client.rb +27 -16
  5. data/lib/mongo/cluster/topology/replica_set.rb +15 -3
  6. data/lib/mongo/error/lint_error.rb +1 -1
  7. data/lib/mongo/server/description.rb +1 -1
  8. data/lib/mongo/version.rb +1 -1
  9. data/spec/{mongo → integration}/change_stream_examples_spec.rb +0 -0
  10. data/spec/{mongo → integration}/docs_examples_spec.rb +0 -0
  11. data/spec/integration/reconnect_spec.rb +31 -0
  12. data/spec/{mongo → integration}/retryable_writes_spec.rb +0 -0
  13. data/spec/{mongo → integration}/shell_examples_spec.rb +0 -0
  14. data/spec/{mongo → integration}/transactions_examples_spec.rb +46 -61
  15. data/spec/lite_spec_helper.rb +7 -2
  16. data/spec/mongo/address/unix_spec.rb +1 -1
  17. data/spec/mongo/address_spec.rb +10 -10
  18. data/spec/mongo/auth/scram/conversation_spec.rb +2 -1
  19. data/spec/mongo/auth/scram/negotiation_spec.rb +6 -5
  20. data/spec/mongo/auth/scram_spec.rb +5 -4
  21. data/spec/mongo/bulk_write_spec.rb +3 -2
  22. data/spec/mongo/client_spec.rb +15 -7
  23. data/spec/mongo/cluster/topology/replica_set_spec.rb +46 -10
  24. data/spec/mongo/cluster_spec.rb +3 -3
  25. data/spec/mongo/collection/view/aggregation_spec.rb +2 -1
  26. data/spec/mongo/collection/view/readable_spec.rb +2 -1
  27. data/spec/mongo/collection_spec.rb +40 -23
  28. data/spec/mongo/database_spec.rb +3 -3
  29. data/spec/mongo/index/view_spec.rb +4 -2
  30. data/spec/mongo/server/connection_pool_spec.rb +1 -1
  31. data/spec/mongo/socket/ssl_spec.rb +3 -3
  32. data/spec/mongo/socket/unix_spec.rb +1 -1
  33. data/spec/mongo/socket_spec.rb +2 -2
  34. data/spec/mongo/uri/srv_protocol_spec.rb +2 -1
  35. data/spec/mongo/uri_spec.rb +6 -5
  36. data/spec/spec_helper.rb +7 -28
  37. data/spec/spec_tests/dns_seedlist_discovery_spec.rb +61 -63
  38. data/spec/spec_tests/sdam_monitoring_spec.rb +10 -7
  39. data/spec/{mongo → spec_tests}/transactions_spec.rb +8 -3
  40. data/spec/support/authorization.rb +10 -55
  41. data/spec/support/constraints.rb +34 -10
  42. data/spec/support/lite_constraints.rb +18 -0
  43. data/spec/support/sdam/rs/secondary_ignore_ok_0.yml +85 -0
  44. data/spec/support/spec_config.rb +73 -0
  45. data/spec/support/transactions.rb +1 -1
  46. metadata +170 -162
  47. metadata.gz.sig +1 -2
@@ -279,7 +279,8 @@ describe Mongo::Database do
279
279
  end
280
280
  end
281
281
 
282
- context 'when a read concern is provided', if: find_command_enabled? do
282
+ context 'when a read concern is provided' do
283
+ min_server_version '3.2'
283
284
 
284
285
  context 'when the read concern is valid' do
285
286
 
@@ -291,8 +292,7 @@ describe Mongo::Database do
291
292
  end
292
293
 
293
294
  context 'when the read concern is not valid' do
294
-
295
- it 'raises an exception', if: (find_command_enabled? && !sharded?) do
295
+ it 'raises an exception', if: !sharded? do
296
296
  expect {
297
297
  database.command(:ismaster => 1, readConcern: { level: 'yay' })
298
298
  }.to raise_error(Mongo::Error::OperationFailure)
@@ -663,7 +663,8 @@ describe Mongo::Index::View do
663
663
  end
664
664
  end
665
665
 
666
- context 'when providing an invalid partial index filter', if: find_command_enabled? do
666
+ context 'when providing an invalid partial index filter' do
667
+ min_server_version '3.2'
667
668
 
668
669
  it 'raises an exception' do
669
670
  expect {
@@ -672,7 +673,8 @@ describe Mongo::Index::View do
672
673
  end
673
674
  end
674
675
 
675
- context 'when providing a valid partial index filter', if: find_command_enabled? do
676
+ context 'when providing a valid partial index filter' do
677
+ min_server_version '3.2'
676
678
 
677
679
  let(:expression) do
678
680
  {'a' => {'$lte' => 1.5}}
@@ -7,7 +7,7 @@ describe Mongo::Server::ConnectionPool do
7
7
  end
8
8
 
9
9
  let(:address) do
10
- Mongo::Address.new('127.0.0.1:27017')
10
+ Mongo::Address.new(SpecConfig.instance.addresses.first)
11
11
  end
12
12
 
13
13
  let(:monitoring) do
@@ -1,6 +1,6 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe Mongo::Socket::SSL, if: running_ssl? do
3
+ describe Mongo::Socket::SSL, if: SpecConfig.instance.ssl? do
4
4
 
5
5
  let(:address) do
6
6
  default_address
@@ -278,7 +278,7 @@ describe Mongo::Socket::SSL, if: running_ssl? do
278
278
  end
279
279
  end
280
280
 
281
- context 'when ruby version is < 2.4.1', if: (RUBY_VERSION < '2.4.1' && running_ssl?) do
281
+ context 'when ruby version is < 2.4.1', if: (RUBY_VERSION < '2.4.1' && SpecConfig.instance.ssl?) do
282
282
 
283
283
  context 'when a key is passed, but it is not of the right type' do
284
284
 
@@ -302,7 +302,7 @@ describe Mongo::Socket::SSL, if: running_ssl? do
302
302
 
303
303
  # Note that as of MRI 2.4, Creating a socket with the wrong key type raises
304
304
  # a NoMethodError because #private? is attempted to be called on the key.
305
- context 'when ruby version is >= 2.4.1', if: (RUBY_VERSION >= '2.4.1' && running_ssl?) do
305
+ context 'when ruby version is >= 2.4.1', if: (RUBY_VERSION >= '2.4.1' && SpecConfig.instance.ssl?) do
306
306
 
307
307
  context 'when a key is passed, but it is not of the right type' do
308
308
 
@@ -3,7 +3,7 @@ require 'spec_helper'
3
3
  describe Mongo::Socket::Unix do
4
4
 
5
5
  let(:socket) do
6
- described_class.new("/tmp/mongodb-27017.sock", 5)
6
+ described_class.new("/tmp/mongodb-#{SpecConfig.instance.any_port}.sock", 5)
7
7
  end
8
8
 
9
9
  describe '#connect!' do
@@ -18,9 +18,9 @@ describe Mongo::Socket do
18
18
  it 'maps SystemCallError and preserves message' do
19
19
  expect do
20
20
  socket.send(:handle_errors) do
21
- raise SystemCallError.new('Test error', Errno::ENOMEDIUM::Errno)
21
+ raise SystemCallError.new('Test error', Errno::ENFILE::Errno)
22
22
  end
23
- end.to raise_error(Mongo::Error::SocketError, 'Errno::ENOMEDIUM: No medium found - Test error')
23
+ end.to raise_error(Mongo::Error::SocketError, 'Errno::ENFILE: Too many open files in system - Test error')
24
24
  end
25
25
 
26
26
  it 'maps IOError and preserves message' do
@@ -200,7 +200,8 @@ describe Mongo::URI::SRVProtocol do
200
200
  end
201
201
  end
202
202
 
203
- describe 'valid uris', if: test_connecting_externally? do
203
+ describe 'valid uris' do
204
+ require_external_connectivity
204
205
 
205
206
  describe 'invalid query results' do
206
207
 
@@ -1,4 +1,4 @@
1
- require 'spec_helper'
1
+ require 'lite_spec_helper'
2
2
 
3
3
  describe Mongo::URI do
4
4
 
@@ -17,7 +17,8 @@ describe Mongo::URI do
17
17
  end
18
18
  end
19
19
 
20
- context 'when the scheme is mongodb+srv://', if: test_connecting_externally? do
20
+ context 'when the scheme is mongodb+srv://' do
21
+ require_external_connectivity
21
22
 
22
23
  let(:string) do
23
24
  'mongodb+srv://test5.test.build.10gen.cc'
@@ -325,7 +326,7 @@ describe Mongo::URI do
325
326
 
326
327
  describe '#client_options' do
327
328
 
328
- let(:db) { TEST_DB }
329
+ let(:db) { 'dummy_db' }
329
330
  let(:servers) { 'localhost' }
330
331
  let(:string) { "#{scheme}#{credentials}@#{servers}/#{db}" }
331
332
  let(:user) { 'tyler' }
@@ -337,7 +338,7 @@ describe Mongo::URI do
337
338
  end
338
339
 
339
340
  it 'includes the database in the options' do
340
- expect(options[:database]).to eq(TEST_DB)
341
+ expect(options[:database]).to eq('dummy_db')
341
342
  end
342
343
 
343
344
  it 'includes the user in the options' do
@@ -624,7 +625,7 @@ describe Mongo::URI do
624
625
  end
625
626
 
626
627
  context 'replica set option provided' do
627
- let(:rs_name) { TEST_SET }
628
+ let(:rs_name) { 'dummy_rs' }
628
629
  let(:options) { "replicaSet=#{rs_name}" }
629
630
 
630
631
  it 'sets the replica set option' do
@@ -70,8 +70,11 @@
70
70
 
71
71
  require 'lite_spec_helper'
72
72
 
73
- if RUBY_PLATFORM !~ /\bjava\b/
73
+ if SpecConfig.instance.mri?
74
74
  require 'timeout_interrupt'
75
+ else
76
+ require 'timeout'
77
+ TimeoutInterrupt = Timeout
75
78
  end
76
79
 
77
80
  # Replica set name can be overridden via replicaSet parameter in MONGODB_URI
@@ -160,7 +163,7 @@ end
160
163
  #
161
164
  # @since 2.0.0
162
165
  def single_seed?
163
- ADDRESSES.size == 1
166
+ SpecConfig.instance.addresses.size == 1
164
167
  end
165
168
 
166
169
  # For instances where behaviour is different on different versions, we need to
@@ -191,14 +194,6 @@ def test_change_streams?
191
194
  !BSON::Environment.jruby? && change_stream_enabled? & replica_set?
192
195
  end
193
196
 
194
- # Whether transactions can be tested. Transactions are available on server versions 4.0 and higher
195
- # and when connected to a replica set.
196
- #
197
- # @since 2.6.0
198
- def test_transactions?
199
- transactions_enabled? && replica_set?
200
- end
201
-
202
197
  # For instances where behaviour is different on different versions, we need to
203
198
  # determine in the specs if we are 3.6 or higher.
204
199
  #
@@ -245,27 +240,11 @@ def scram_sha_256_enabled?
245
240
  $scram_sha_256_enabled ||= $mongo_client.cluster.servers.first.features.scram_sha_256_enabled?
246
241
  end
247
242
 
248
- alias :transactions_enabled? :scram_sha_256_enabled?
249
-
250
243
  # Is the test suite running locally (not on Travis).
251
244
  #
252
245
  # @since 2.1.0
253
246
  def testing_ssl_locally?
254
- running_ssl? && !(ENV['CI'])
255
- end
256
-
257
- # Should tests relying on external connections be run.
258
- #
259
- # @since 2.5.1
260
- def test_connecting_externally?
261
- !ENV['CI'] && !ENV['EXTERNAL_DISABLED']
262
- end
263
-
264
- # Is the test suite running on SSL.
265
- #
266
- # @since 2.0.2
267
- def running_ssl?
268
- SSL
247
+ SpecConfig.instance.ssl? && !(ENV['CI'])
269
248
  end
270
249
 
271
250
  # Is the test suite using compression.
@@ -317,7 +296,7 @@ end
317
296
  #
318
297
  # @since 2.0.0
319
298
  def initialize_scanned_client!
320
- Mongo::Client.new(ADDRESSES, TEST_OPTIONS.merge(database: TEST_DB))
299
+ Mongo::Client.new(SpecConfig.instance.addresses, TEST_OPTIONS.merge(database: TEST_DB))
321
300
  end
322
301
 
323
302
  # Converts a 'camelCase' string or symbol to a :snake_case symbol.
@@ -1,96 +1,94 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe 'DNS Seedlist Discovery' do
4
+ require_external_connectivity
4
5
 
5
- if test_connecting_externally?
6
+ include Mongo::ConnectionString
6
7
 
7
- include Mongo::ConnectionString
8
+ before(:all) do
8
9
 
9
- before(:all) do
10
+ module Mongo
11
+ class Server
12
+ # The constructor keeps the same API, but does not instantiate a
13
+ # monitor and run it.
14
+ alias :original_initialize :initialize
10
15
 
11
- module Mongo
12
- class Server
13
- # The constructor keeps the same API, but does not instantiate a
14
- # monitor and run it.
15
- alias :original_initialize :initialize
16
-
17
- def initialize(address, cluster, monitoring, event_listeners, options = {})
18
- @address = address
19
- @cluster = cluster
20
- @monitoring = monitoring
21
- @options = options.freeze
22
- @monitor = Monitor.new(address, event_listeners, options)
23
- end
16
+ def initialize(address, cluster, monitoring, event_listeners, options = {})
17
+ @address = address
18
+ @cluster = cluster
19
+ @monitoring = monitoring
20
+ @options = options.freeze
21
+ @monitor = Monitor.new(address, event_listeners, options)
22
+ end
24
23
 
25
- # Disconnect simply needs to return true since we have no monitor and
26
- # no connection.
27
- alias :original_disconnect! :disconnect!
24
+ # Disconnect simply needs to return true since we have no monitor and
25
+ # no connection.
26
+ alias :original_disconnect! :disconnect!
28
27
 
29
- def disconnect!;
30
- true;
31
- end
28
+ def disconnect!;
29
+ true;
32
30
  end
33
31
  end
34
32
  end
33
+ end
35
34
 
36
- after(:all) do
35
+ after(:all) do
37
36
 
38
- module Mongo
39
- class Server
40
- alias :initialize :original_initialize
41
- remove_method(:original_initialize)
37
+ module Mongo
38
+ class Server
39
+ alias :initialize :original_initialize
40
+ remove_method(:original_initialize)
42
41
 
43
- alias :disconnect! :original_disconnect!
44
- remove_method(:original_disconnect!)
45
- end
42
+ alias :disconnect! :original_disconnect!
43
+ remove_method(:original_disconnect!)
46
44
  end
47
45
  end
46
+ end
48
47
 
49
- DNS_SEEDLIST_DISCOVERY_TESTS.each do |file_name|
48
+ DNS_SEEDLIST_DISCOVERY_TESTS.each do |file_name|
50
49
 
51
- file = File.new(file_name)
52
- spec = YAML.load(ERB.new(file.read).result)
53
- file.close
50
+ file = File.new(file_name)
51
+ spec = YAML.load(ERB.new(file.read).result)
52
+ file.close
54
53
 
55
- test = Mongo::ConnectionString::Test.new(spec)
54
+ test = Mongo::ConnectionString::Test.new(spec)
56
55
 
57
- context(File.basename(file_name)) do
56
+ context(File.basename(file_name)) do
58
57
 
59
- context 'when the uri is invalid', if: test.raise_error? do
58
+ context 'when the uri is invalid', if: test.raise_error? do
60
59
 
61
- let(:valid_errors) do
62
- [
63
- Mongo::Error::InvalidTXTRecord,
64
- Mongo::Error::NoSRVRecords,
65
- Mongo::Error::InvalidURI,
66
- Mongo::Error::MismatchedDomain,
67
- ]
68
- end
60
+ let(:valid_errors) do
61
+ [
62
+ Mongo::Error::InvalidTXTRecord,
63
+ Mongo::Error::NoSRVRecords,
64
+ Mongo::Error::InvalidURI,
65
+ Mongo::Error::MismatchedDomain,
66
+ ]
67
+ end
69
68
 
70
- let(:error) do
71
- e = nil
72
- begin; test.uri; rescue => ex; e = ex; end
73
- e
74
- end
69
+ let(:error) do
70
+ e = nil
71
+ begin; test.uri; rescue => ex; e = ex; end
72
+ e
73
+ end
75
74
 
76
- it 'raises an error' do
77
- expect(valid_errors).to include(error.class)
78
- end
75
+ it 'raises an error' do
76
+ expect(valid_errors).to include(error.class)
79
77
  end
78
+ end
80
79
 
81
- context 'when the uri is valid', unless: test.raise_error? do
80
+ context 'when the uri is valid', unless: test.raise_error? do
82
81
 
83
- it 'does not raise an exception' do
84
- expect(test.uri).to be_a(Mongo::URI::SRVProtocol)
85
- end
82
+ it 'does not raise an exception' do
83
+ expect(test.uri).to be_a(Mongo::URI::SRVProtocol)
84
+ end
86
85
 
87
- it 'creates a client with the correct hosts' do
88
- expect(test.client).to have_hosts(test)
89
- end
86
+ it 'creates a client with the correct hosts' do
87
+ expect(test.client).to have_hosts(test)
88
+ end
90
89
 
91
- it 'creates a client with the correct options' do
92
- expect(test.client).to match_options(test)
93
- end
90
+ it 'creates a client with the correct options' do
91
+ expect(test.client).to match_options(test)
94
92
  end
95
93
  end
96
94
  end
@@ -10,14 +10,17 @@ describe 'SDAM Monitoring' do
10
10
  context("#{spec.description} (#{file.sub(%r'.*support/sdam_monitoring/', '')})") do
11
11
 
12
12
  before(:all) do
13
- @client = Mongo::Client.new([], heartbeat_frequency: 100, connect_timeout: 0.1)
14
13
  @subscriber = Mongo::SDAMMonitoring::TestSubscriber.new
15
- @client.subscribe(Mongo::Monitoring::SERVER_OPENING, @subscriber)
16
- @client.subscribe(Mongo::Monitoring::SERVER_CLOSED, @subscriber)
17
- @client.subscribe(Mongo::Monitoring::SERVER_DESCRIPTION_CHANGED, @subscriber)
18
- @client.subscribe(Mongo::Monitoring::TOPOLOGY_OPENING, @subscriber)
19
- @client.subscribe(Mongo::Monitoring::TOPOLOGY_CHANGED, @subscriber)
20
- @client.send(:create_from_uri, spec.uri_string)
14
+ sdam_proc = lambda do |client|
15
+ client.subscribe(Mongo::Monitoring::SERVER_OPENING, @subscriber)
16
+ client.subscribe(Mongo::Monitoring::SERVER_CLOSED, @subscriber)
17
+ client.subscribe(Mongo::Monitoring::SERVER_DESCRIPTION_CHANGED, @subscriber)
18
+ client.subscribe(Mongo::Monitoring::TOPOLOGY_OPENING, @subscriber)
19
+ client.subscribe(Mongo::Monitoring::TOPOLOGY_CHANGED, @subscriber)
20
+ end
21
+ @client = Mongo::Client.new(spec.uri_string,
22
+ sdam_proc: sdam_proc,
23
+ heartbeat_frequency: 100, connect_timeout: 0.1)
21
24
  end
22
25
 
23
26
  after(:all) do
@@ -9,24 +9,29 @@ describe 'Transactions' do
9
9
  context(spec.description) do
10
10
  spec.tests.each do |test|
11
11
  context(test.description) do
12
+ require_transaction_support
12
13
 
13
14
  before(:each) do
14
15
  test.setup_test
15
16
  end
16
17
 
18
+ after(:each) do
19
+ test.teardown_test
20
+ end
21
+
17
22
  let(:results) do
18
23
  test.run
19
24
  end
20
25
 
21
- it 'returns the correct result', if: test_transactions? do
26
+ it 'returns the correct result' do
22
27
  expect(results[:results]).to match_operation_result(test)
23
28
  end
24
29
 
25
- it 'has the correct data in the collection', if: test_transactions? && test.outcome_collection_data do
30
+ it 'has the correct data in the collection', if: test.outcome_collection_data do
26
31
  expect(results[:contents]).to match_collection_data(test)
27
32
  end
28
33
 
29
- it 'has the correct command_started events', if: test_transactions? && test.expectations do
34
+ it 'has the correct command_started events', if: test.expectations do
30
35
  test.expectations.each do |expectation|
31
36
  # We convert the hashes to sorted arrays to ensure that asserting equality between
32
37
  # the expected and actual event descriptions don't fail due to the same entries being
@@ -22,46 +22,16 @@ TEST_DB = 'ruby-driver'.freeze
22
22
  # @since 2.0.0
23
23
  TEST_COLL = 'test'.freeze
24
24
 
25
- # For Evergreen
26
- if ENV['MONGODB_URI']
27
- MONGODB_URI = Mongo::URI.new(ENV['MONGODB_URI'])
28
- URI_OPTIONS = Mongo::Options::Mapper.transform_keys_to_symbols(MONGODB_URI.uri_options)
29
- if URI_OPTIONS[:replica_set]
30
- ADDRESSES = MONGODB_URI.servers
31
- CONNECT = { connect: :replica_set, replica_set: URI_OPTIONS[:replica_set] }
32
- elsif ENV['TOPOLOGY'] == 'sharded_cluster'
33
- ADDRESSES = [ MONGODB_URI.servers.first ] # See SERVER-16836 for why we can only use one host:port
34
- CONNECT = { connect: :sharded }
35
- else
36
- ADDRESSES = MONGODB_URI.servers
37
- CONNECT = { connect: :direct }
38
- end
39
- else
40
- ADDRESSES = ENV['MONGODB_ADDRESSES'] ? ENV['MONGODB_ADDRESSES'].split(',').freeze : [ '127.0.0.1:27017' ].freeze
41
- if ENV['RS_ENABLED']
42
- CONNECT = { connect: :replica_set, replica_set: ENV['RS_NAME'] }
43
- elsif ENV['SHARDED_ENABLED']
44
- CONNECT = { connect: :sharded }
45
- else
46
- CONNECT = { connect: :direct }
47
- end
48
- end
49
-
50
25
  # The write concern to use in the tests.
51
26
  #
52
27
  # @since 2.0.0
53
- WRITE_CONCERN = CONNECT[:connect] == :replica_set ? { w: 2 } : { w: 1 }
28
+ WRITE_CONCERN = SpecConfig.instance.connect_replica_set? ? { w: 2 } : { w: 1 }
54
29
 
55
30
  # An invalid write concern.
56
31
  #
57
32
  # @since 2.4.2
58
33
  INVALID_WRITE_CONCERN = { w: 4 }
59
34
 
60
- # Whether to use SSL.
61
- #
62
- # @since 2.0.3
63
- SSL = (ENV['SSL'] == 'ssl') || (ENV['SSL_ENABLED'] == 'true')
64
-
65
35
  # What compressor to use, if any.
66
36
  #
67
37
  # @since 2.5.0
@@ -71,7 +41,7 @@ COMPRESSORS = ENV['COMPRESSORS'] ? { compressors: ENV['COMPRESSORS'].split(',')
71
41
  #
72
42
  # @since 2.1.0
73
43
  SSL_OPTIONS = {
74
- ssl: SSL,
44
+ ssl: SpecConfig.instance.ssl?,
75
45
  ssl_verify: false,
76
46
  ssl_cert: CLIENT_CERT_PEM,
77
47
  ssl_key: CLIENT_KEY_PEM
@@ -100,29 +70,14 @@ BASE_OPTIONS = {
100
70
  # Options for test suite clients.
101
71
  #
102
72
  # @since 2.0.3
103
- TEST_OPTIONS = BASE_OPTIONS.merge(CONNECT).merge(SSL_OPTIONS).merge(COMPRESSORS)
104
-
105
- # The root user name.
106
- #
107
- # @since 2.0.0
108
- ROOT_USER_NAME = (defined?(MONGODB_URI) && MONGODB_URI.credentials[:user]) || 'root-user'
109
-
110
- # The root user password.
111
- #
112
- # @since 2.0.0
113
- ROOT_USER_PWD = (defined?(MONGODB_URI) && MONGODB_URI.credentials[:password]) || 'password'
114
-
115
- # The root user auth source.
116
- #
117
- # @since 2.4.2
118
- ROOT_USER_AUTH_SOURCE = (defined?(URI_OPTIONS) && URI_OPTIONS[:auth_source]) || Mongo::Database::ADMIN
73
+ TEST_OPTIONS = BASE_OPTIONS.merge(SpecConfig.instance.connect).merge(SSL_OPTIONS).merge(COMPRESSORS)
119
74
 
120
75
  # Gets the root system administrator user.
121
76
  #
122
77
  # @since 2.0.0
123
78
  ROOT_USER = Mongo::Auth::User.new(
124
- user: ROOT_USER_NAME,
125
- password: ROOT_USER_PWD,
79
+ user: SpecConfig.instance.user || 'root-user',
80
+ password: SpecConfig.instance.password || 'password',
126
81
  roles: [
127
82
  Mongo::Auth::Roles::USER_ADMIN_ANY_DATABASE,
128
83
  Mongo::Auth::Roles::DATABASE_ADMIN_ANY_DATABASE,
@@ -171,7 +126,7 @@ TEST_READ_WRITE_USER = Mongo::Auth::User.new(
171
126
  #
172
127
  # @since 2.0.0
173
128
  AUTHORIZED_CLIENT = Mongo::Client.new(
174
- ADDRESSES,
129
+ SpecConfig.instance.addresses,
175
130
  TEST_OPTIONS.merge(
176
131
  database: TEST_DB,
177
132
  user: TEST_USER.name,
@@ -187,7 +142,7 @@ AUTHROIZED_CLIENT_WITH_RETRY_WRITES = AUTHORIZED_CLIENT.with(retry_writes: true)
187
142
  #
188
143
  # @since 2.0.0
189
144
  UNAUTHORIZED_CLIENT = Mongo::Client.new(
190
- ADDRESSES,
145
+ SpecConfig.instance.addresses,
191
146
  TEST_OPTIONS.merge(database: TEST_DB, monitoring: false)
192
147
  )
193
148
 
@@ -196,7 +151,7 @@ UNAUTHORIZED_CLIENT = Mongo::Client.new(
196
151
  #
197
152
  # @since 2.0.0
198
153
  ADMIN_UNAUTHORIZED_CLIENT = Mongo::Client.new(
199
- ADDRESSES,
154
+ SpecConfig.instance.addresses,
200
155
  TEST_OPTIONS.merge(database: Mongo::Database::ADMIN, monitoring: false)
201
156
  )
202
157
 
@@ -208,7 +163,7 @@ ADMIN_AUTHORIZED_TEST_CLIENT = ADMIN_UNAUTHORIZED_CLIENT.with(
208
163
  user: ROOT_USER.name,
209
164
  password: ROOT_USER.password,
210
165
  database: TEST_DB,
211
- auth_source: ROOT_USER_AUTH_SOURCE,
166
+ auth_source: SpecConfig.instance.auth_source || Mongo::Database::ADMIN,
212
167
  monitoring: false
213
168
  )
214
169
 
@@ -216,7 +171,7 @@ ADMIN_AUTHORIZED_TEST_CLIENT = ADMIN_UNAUTHORIZED_CLIENT.with(
216
171
  #
217
172
  # @since 2.5.1
218
173
  SUBSCRIBED_CLIENT = Mongo::Client.new(
219
- ADDRESSES,
174
+ SpecConfig.instance.addresses,
220
175
  TEST_OPTIONS.merge(
221
176
  database: TEST_DB,
222
177
  user: TEST_USER.name,