mongo 2.13.1 → 2.14.0.rc1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +1 -4
- data/lib/mongo.rb +9 -0
- data/lib/mongo/address/ipv4.rb +1 -1
- data/lib/mongo/address/ipv6.rb +1 -1
- data/lib/mongo/bulk_write.rb +17 -0
- data/lib/mongo/caching_cursor.rb +74 -0
- data/lib/mongo/client.rb +47 -8
- data/lib/mongo/cluster.rb +3 -3
- data/lib/mongo/cluster/topology/single.rb +1 -1
- data/lib/mongo/collection.rb +26 -0
- data/lib/mongo/collection/view.rb +24 -20
- data/lib/mongo/collection/view/aggregation.rb +25 -4
- data/lib/mongo/collection/view/builder/find_command.rb +38 -18
- data/lib/mongo/collection/view/explainable.rb +27 -8
- data/lib/mongo/collection/view/iterable.rb +72 -12
- data/lib/mongo/collection/view/readable.rb +12 -2
- data/lib/mongo/collection/view/writable.rb +15 -1
- data/lib/mongo/crypt/encryption_io.rb +6 -6
- data/lib/mongo/cursor.rb +1 -0
- data/lib/mongo/database.rb +6 -0
- data/lib/mongo/error.rb +2 -0
- data/lib/mongo/error/invalid_read_concern.rb +28 -0
- data/lib/mongo/error/server_certificate_revoked.rb +22 -0
- data/lib/mongo/error/unsupported_option.rb +14 -12
- data/lib/mongo/lint.rb +2 -1
- data/lib/mongo/logger.rb +3 -3
- data/lib/mongo/operation.rb +2 -0
- data/lib/mongo/operation/aggregate/result.rb +9 -8
- data/lib/mongo/operation/collections_info/result.rb +2 -0
- data/lib/mongo/operation/delete/bulk_result.rb +2 -0
- data/lib/mongo/operation/delete/result.rb +3 -0
- data/lib/mongo/operation/explain/command.rb +4 -0
- data/lib/mongo/operation/explain/legacy.rb +4 -0
- data/lib/mongo/operation/explain/op_msg.rb +6 -0
- data/lib/mongo/operation/explain/result.rb +3 -0
- data/lib/mongo/operation/find/legacy/result.rb +2 -0
- data/lib/mongo/operation/find/result.rb +3 -0
- data/lib/mongo/operation/get_more/result.rb +3 -0
- data/lib/mongo/operation/indexes/result.rb +5 -0
- data/lib/mongo/operation/insert/bulk_result.rb +5 -0
- data/lib/mongo/operation/insert/result.rb +5 -0
- data/lib/mongo/operation/list_collections/result.rb +5 -0
- data/lib/mongo/operation/map_reduce/result.rb +10 -0
- data/lib/mongo/operation/parallel_scan/result.rb +4 -0
- data/lib/mongo/operation/result.rb +35 -6
- data/lib/mongo/operation/shared/bypass_document_validation.rb +1 -0
- data/lib/mongo/operation/shared/causal_consistency_supported.rb +1 -0
- data/lib/mongo/operation/shared/collections_info_or_list_collections.rb +2 -0
- data/lib/mongo/operation/shared/executable.rb +1 -0
- data/lib/mongo/operation/shared/idable.rb +2 -1
- data/lib/mongo/operation/shared/limited.rb +1 -0
- data/lib/mongo/operation/shared/object_id_generator.rb +1 -0
- data/lib/mongo/operation/shared/result/aggregatable.rb +1 -0
- data/lib/mongo/operation/shared/sessions_supported.rb +1 -0
- data/lib/mongo/operation/shared/specifiable.rb +1 -0
- data/lib/mongo/operation/shared/write.rb +1 -0
- data/lib/mongo/operation/shared/write_concern_supported.rb +1 -0
- data/lib/mongo/operation/update/legacy/result.rb +7 -0
- data/lib/mongo/operation/update/result.rb +8 -0
- data/lib/mongo/operation/users_info/result.rb +3 -0
- data/lib/mongo/query_cache.rb +242 -0
- data/lib/mongo/retryable.rb +8 -1
- data/lib/mongo/server.rb +5 -1
- data/lib/mongo/server/connection_common.rb +2 -2
- data/lib/mongo/server/connection_pool.rb +3 -0
- data/lib/mongo/server/monitor.rb +1 -1
- data/lib/mongo/server/monitor/connection.rb +3 -3
- data/lib/mongo/server/pending_connection.rb +2 -2
- data/lib/mongo/server/push_monitor.rb +1 -1
- data/lib/mongo/server_selector/base.rb +5 -1
- data/lib/mongo/session.rb +3 -0
- data/lib/mongo/socket.rb +6 -4
- data/lib/mongo/socket/ocsp_cache.rb +97 -0
- data/lib/mongo/socket/ocsp_verifier.rb +368 -0
- data/lib/mongo/socket/ssl.rb +45 -24
- data/lib/mongo/srv/monitor.rb +7 -13
- data/lib/mongo/srv/resolver.rb +14 -10
- data/lib/mongo/timeout.rb +2 -0
- data/lib/mongo/uri.rb +21 -390
- data/lib/mongo/uri/options_mapper.rb +582 -0
- data/lib/mongo/uri/srv_protocol.rb +3 -2
- data/lib/mongo/utils.rb +12 -1
- data/lib/mongo/version.rb +1 -1
- data/spec/NOTES.aws-auth.md +12 -7
- data/spec/README.md +56 -1
- data/spec/integration/bulk_write_spec.rb +48 -0
- data/spec/integration/client_authentication_options_spec.rb +55 -28
- data/spec/integration/connection_pool_populator_spec.rb +3 -1
- data/spec/integration/cursor_reaping_spec.rb +53 -17
- data/spec/integration/ocsp_connectivity_spec.rb +26 -0
- data/spec/integration/ocsp_verifier_cache_spec.rb +188 -0
- data/spec/integration/ocsp_verifier_spec.rb +334 -0
- data/spec/integration/query_cache_spec.rb +1045 -0
- data/spec/integration/query_cache_transactions_spec.rb +179 -0
- data/spec/integration/retryable_writes/retryable_writes_40_and_newer_spec.rb +1 -0
- data/spec/integration/retryable_writes/shared/performs_legacy_retries.rb +2 -0
- data/spec/integration/sdam_error_handling_spec.rb +68 -0
- data/spec/integration/server_selection_spec.rb +36 -0
- data/spec/integration/srv_monitoring_spec.rb +38 -3
- data/spec/integration/srv_spec.rb +56 -0
- data/spec/lite_spec_helper.rb +3 -1
- data/spec/mongo/address_spec.rb +1 -1
- data/spec/mongo/caching_cursor_spec.rb +70 -0
- data/spec/mongo/client_construction_spec.rb +54 -1
- data/spec/mongo/client_spec.rb +40 -0
- data/spec/mongo/cluster/topology/single_spec.rb +14 -5
- data/spec/mongo/cluster_spec.rb +3 -0
- data/spec/mongo/collection/view/explainable_spec.rb +87 -4
- data/spec/mongo/collection/view/map_reduce_spec.rb +2 -0
- data/spec/mongo/collection_spec.rb +60 -0
- data/spec/mongo/crypt/auto_decryption_context_spec.rb +1 -1
- data/spec/mongo/crypt/auto_encryption_context_spec.rb +1 -1
- data/spec/mongo/crypt/explicit_decryption_context_spec.rb +1 -1
- data/spec/mongo/crypt/explicit_encryption_context_spec.rb +1 -1
- data/spec/mongo/database_spec.rb +44 -0
- data/spec/mongo/error/no_server_available_spec.rb +1 -1
- data/spec/mongo/logger_spec.rb +13 -11
- data/spec/mongo/query_cache_spec.rb +279 -0
- data/spec/mongo/server/connection_pool_spec.rb +7 -3
- data/spec/mongo/server/connection_spec.rb +14 -7
- data/spec/mongo/socket/ssl_spec.rb +1 -1
- data/spec/mongo/socket_spec.rb +1 -1
- data/spec/mongo/uri/srv_protocol_spec.rb +64 -33
- data/spec/mongo/uri_option_parsing_spec.rb +11 -11
- data/spec/mongo/uri_spec.rb +68 -41
- data/spec/mongo/utils_spec.rb +39 -0
- data/spec/runners/auth.rb +3 -0
- data/spec/runners/connection_string.rb +35 -124
- data/spec/spec_tests/cmap_spec.rb +7 -3
- data/spec/spec_tests/data/change_streams/change-streams-errors.yml +0 -1
- data/spec/spec_tests/data/change_streams/change-streams.yml +0 -1
- data/spec/spec_tests/data/cmap/pool-checkout-connection.yml +6 -2
- data/spec/spec_tests/data/cmap/pool-create-min-size.yml +3 -0
- data/spec/spec_tests/data/connection_string/valid-warnings.yml +24 -0
- data/spec/spec_tests/data/sdam_monitoring/discovered_standalone.yml +1 -3
- data/spec/spec_tests/data/sdam_monitoring/standalone.yml +2 -2
- data/spec/spec_tests/data/sdam_monitoring/standalone_repeated.yml +2 -2
- data/spec/spec_tests/data/sdam_monitoring/standalone_suppress_equal_description_changes.yml +2 -2
- data/spec/spec_tests/data/sdam_monitoring/standalone_to_rs_with_me_mismatch.yml +2 -2
- data/spec/spec_tests/data/uri_options/auth-options.yml +25 -0
- data/spec/spec_tests/data/uri_options/compression-options.yml +6 -3
- data/spec/spec_tests/data/uri_options/read-preference-options.yml +24 -0
- data/spec/spec_tests/data/uri_options/ruby-connection-options.yml +1 -0
- data/spec/spec_tests/data/uri_options/tls-options.yml +160 -4
- data/spec/spec_tests/dns_seedlist_discovery_spec.rb +9 -1
- data/spec/spec_tests/uri_options_spec.rb +31 -33
- data/spec/support/certificates/atlas-ocsp-ca.crt +28 -0
- data/spec/support/certificates/atlas-ocsp.crt +41 -0
- data/spec/support/client_registry_macros.rb +11 -2
- data/spec/support/common_shortcuts.rb +45 -0
- data/spec/support/constraints.rb +23 -0
- data/spec/support/lite_constraints.rb +24 -0
- data/spec/support/matchers.rb +16 -0
- data/spec/support/ocsp +1 -0
- data/spec/support/session_registry.rb +52 -0
- data/spec/support/spec_config.rb +22 -0
- data/spec/support/utils.rb +19 -1
- metadata +38 -3
- metadata.gz.sig +0 -0
data/spec/mongo/address_spec.rb
CHANGED
@@ -0,0 +1,70 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Mongo::CachingCursor do
|
4
|
+
|
5
|
+
around do |spec|
|
6
|
+
Mongo::QueryCache.clear
|
7
|
+
Mongo::QueryCache.cache { spec.run }
|
8
|
+
end
|
9
|
+
|
10
|
+
let(:authorized_collection) do
|
11
|
+
authorized_client['caching_cursor']
|
12
|
+
end
|
13
|
+
|
14
|
+
before do
|
15
|
+
authorized_collection.drop
|
16
|
+
end
|
17
|
+
|
18
|
+
let(:server) do
|
19
|
+
view.send(:server_selector).select_server(authorized_client.cluster)
|
20
|
+
end
|
21
|
+
|
22
|
+
let(:reply) do
|
23
|
+
view.send(:send_initial_query, server)
|
24
|
+
end
|
25
|
+
|
26
|
+
let(:cursor) do
|
27
|
+
described_class.new(view, reply, server)
|
28
|
+
end
|
29
|
+
|
30
|
+
let(:view) do
|
31
|
+
Mongo::Collection::View.new(authorized_collection)
|
32
|
+
end
|
33
|
+
|
34
|
+
before do
|
35
|
+
authorized_collection.delete_many
|
36
|
+
3.times { |i| authorized_collection.insert_one(_id: i) }
|
37
|
+
end
|
38
|
+
|
39
|
+
describe '#cached_docs' do
|
40
|
+
context 'when no query has been performed' do
|
41
|
+
it 'returns nil' do
|
42
|
+
expect(cursor.cached_docs).to be_nil
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
context 'when a query has been performed' do
|
47
|
+
it 'returns the number of documents' do
|
48
|
+
cursor.to_a
|
49
|
+
expect(cursor.cached_docs.length).to eq(3)
|
50
|
+
expect(cursor.cached_docs).to eq([{ '_id' => 0 }, { '_id' => 1 }, { '_id' => 2 }])
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
describe '#try_next' do
|
56
|
+
it 'fetches the next document' do
|
57
|
+
expect(cursor.try_next).to eq('_id' => 0)
|
58
|
+
expect(cursor.try_next).to eq('_id' => 1)
|
59
|
+
expect(cursor.try_next).to eq('_id' => 2)
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
describe '#each' do
|
64
|
+
it 'iterates the cursor' do
|
65
|
+
result = cursor.each.to_a
|
66
|
+
expect(result.length).to eq(3)
|
67
|
+
expect(result).to eq([{ '_id' => 0 }, { '_id' => 1 }, { '_id' => 2 }])
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
@@ -496,6 +496,7 @@ describe Mongo::Client do
|
|
496
496
|
end
|
497
497
|
|
498
498
|
context 'when the compressor is not supported by the driver' do
|
499
|
+
require_warning_clean
|
499
500
|
|
500
501
|
let(:options) do
|
501
502
|
{ compressors: ['snoopy'] }
|
@@ -674,7 +675,7 @@ describe Mongo::Client do
|
|
674
675
|
context 'when providing a custom logger' do
|
675
676
|
|
676
677
|
let(:logger) do
|
677
|
-
Logger.new(
|
678
|
+
Logger.new(STDOUT).tap do |l|
|
678
679
|
l.level = Logger::FATAL
|
679
680
|
end
|
680
681
|
end
|
@@ -1343,6 +1344,46 @@ describe Mongo::Client do
|
|
1343
1344
|
end
|
1344
1345
|
end
|
1345
1346
|
|
1347
|
+
context 'when setting read concern options' do
|
1348
|
+
min_server_fcv '3.2'
|
1349
|
+
|
1350
|
+
context 'when read concern is valid' do
|
1351
|
+
let(:options) do
|
1352
|
+
{ read_concern: { level: :local } }
|
1353
|
+
end
|
1354
|
+
|
1355
|
+
it 'does not warn' do
|
1356
|
+
expect(Mongo::Logger.logger).to_not receive(:warn)
|
1357
|
+
new_local_client_nmio(SpecConfig.instance.addresses, options)
|
1358
|
+
end
|
1359
|
+
end
|
1360
|
+
|
1361
|
+
context 'when read concern has an invalid key' do
|
1362
|
+
skip_if_linting
|
1363
|
+
|
1364
|
+
let(:options) do
|
1365
|
+
{ read_concern: { hello: :local } }
|
1366
|
+
end
|
1367
|
+
|
1368
|
+
it 'logs a warning' do
|
1369
|
+
expect(Mongo::Logger.logger).to receive(:warn).with(/Read concern has invalid keys: hello/)
|
1370
|
+
new_local_client_nmio(SpecConfig.instance.addresses, options)
|
1371
|
+
end
|
1372
|
+
end
|
1373
|
+
|
1374
|
+
context 'when read concern has a non-user-settable key' do
|
1375
|
+
let(:options) do
|
1376
|
+
{ read_concern: { after_cluster_time: 100 } }
|
1377
|
+
end
|
1378
|
+
|
1379
|
+
it 'raises an exception' do
|
1380
|
+
expect do
|
1381
|
+
new_local_client_nmio(SpecConfig.instance.addresses, options)
|
1382
|
+
end.to raise_error(Mongo::Error::InvalidReadConcern, 'The after_cluster_time read_concern option cannot be specified by the user')
|
1383
|
+
end
|
1384
|
+
end
|
1385
|
+
end
|
1386
|
+
|
1346
1387
|
context 'when an invalid option is provided' do
|
1347
1388
|
|
1348
1389
|
let(:options) do
|
@@ -1494,6 +1535,18 @@ describe Mongo::Client do
|
|
1494
1535
|
end
|
1495
1536
|
end
|
1496
1537
|
end
|
1538
|
+
|
1539
|
+
context ':auth_mech_properties option' do
|
1540
|
+
context 'is nil' do
|
1541
|
+
let(:options) do
|
1542
|
+
{auth_mech_properties: nil}
|
1543
|
+
end
|
1544
|
+
|
1545
|
+
it 'creates the client without the option' do
|
1546
|
+
client.options.should_not have_key(:auth_mech_properties)
|
1547
|
+
end
|
1548
|
+
end
|
1549
|
+
end
|
1497
1550
|
end
|
1498
1551
|
|
1499
1552
|
context 'when making a block client' do
|
data/spec/mongo/client_spec.rb
CHANGED
@@ -894,4 +894,44 @@ describe Mongo::Client do
|
|
894
894
|
end
|
895
895
|
end
|
896
896
|
end
|
897
|
+
|
898
|
+
describe '#summary' do
|
899
|
+
|
900
|
+
context 'monitoring omitted' do
|
901
|
+
let(:client) do
|
902
|
+
new_local_client_nmio(
|
903
|
+
['127.0.0.1:27017'],
|
904
|
+
:read => { :mode => :primary },
|
905
|
+
:database => SpecConfig.instance.test_db
|
906
|
+
)
|
907
|
+
end
|
908
|
+
|
909
|
+
it 'indicates lack of monitoring' do
|
910
|
+
client.summary.should =~ /servers=.*UNKNOWN.*NO-MONITORING/
|
911
|
+
end
|
912
|
+
end
|
913
|
+
|
914
|
+
context 'monitoring present' do
|
915
|
+
let(:client) do
|
916
|
+
authorized_client
|
917
|
+
end
|
918
|
+
|
919
|
+
it 'does not indicate lack of monitoring' do
|
920
|
+
client.summary.should =~ /servers=.*(STANDALONE|PRIMARY|MONGOS)/
|
921
|
+
client.summary.should_not =~ /servers=.*(STANDALONE|PRIMARY|MONGOS).*NO-MONITORING/
|
922
|
+
end
|
923
|
+
end
|
924
|
+
|
925
|
+
context 'background threads killed' do
|
926
|
+
let(:client) do
|
927
|
+
authorized_client.tap do |client|
|
928
|
+
client.cluster.servers.map(&:disconnect!)
|
929
|
+
end
|
930
|
+
end
|
931
|
+
|
932
|
+
it 'does not indicate lack of monitoring' do
|
933
|
+
client.summary.should =~ /servers=.*(STANDALONE|PRIMARY|MONGOS).*NO-MONITORING/
|
934
|
+
end
|
935
|
+
end
|
936
|
+
end
|
897
937
|
end
|
@@ -113,19 +113,28 @@ describe Mongo::Cluster::Topology::Single do
|
|
113
113
|
monitoring, temp_cluster)
|
114
114
|
end
|
115
115
|
|
116
|
+
let(:server_1) do
|
117
|
+
double('server').tap do |server|
|
118
|
+
allow(server).to receive(:address).and_return(Mongo::Address.new('one'))
|
119
|
+
end
|
120
|
+
end
|
121
|
+
|
122
|
+
let(:server_2) do
|
123
|
+
double('server').tap do |server|
|
124
|
+
allow(server).to receive(:address).and_return(Mongo::Address.new('two'))
|
125
|
+
end
|
126
|
+
end
|
127
|
+
|
116
128
|
let(:temp_cluster) do
|
117
129
|
double('temp cluster').tap do |cluster|
|
118
|
-
allow(cluster).to receive(:servers_list).and_return([
|
119
|
-
double('server'),
|
120
|
-
double('server'),
|
121
|
-
])
|
130
|
+
allow(cluster).to receive(:servers_list).and_return([server_1, server_2])
|
122
131
|
end
|
123
132
|
end
|
124
133
|
|
125
134
|
it 'fails' do
|
126
135
|
expect do
|
127
136
|
topology
|
128
|
-
end.to raise_error(ArgumentError,
|
137
|
+
end.to raise_error(ArgumentError, /Cannot instantiate a single topology with more than one server in the cluster: one, two/)
|
129
138
|
end
|
130
139
|
end
|
131
140
|
end
|
data/spec/mongo/cluster_spec.rb
CHANGED
@@ -178,6 +178,9 @@ describe Mongo::Cluster do
|
|
178
178
|
before do
|
179
179
|
expect(server).to receive(:monitor).at_least(:once).and_return(monitor)
|
180
180
|
expect(monitor).to receive(:scan!)
|
181
|
+
|
182
|
+
# scan! complains that there isn't a monitor on the server, calls summary
|
183
|
+
allow(monitor).to receive(:running?)
|
181
184
|
end
|
182
185
|
|
183
186
|
it 'returns true' do
|
@@ -20,12 +20,95 @@ describe Mongo::Collection::View::Explainable do
|
|
20
20
|
|
21
21
|
describe '#explain' do
|
22
22
|
|
23
|
-
|
24
|
-
|
23
|
+
shared_examples 'executes the explain' do
|
24
|
+
context '3.0+ server' do
|
25
|
+
min_server_fcv '3.0'
|
26
|
+
|
27
|
+
context 'not sharded' do
|
28
|
+
require_topology :single, :replica_set
|
29
|
+
|
30
|
+
it 'executes the explain' do
|
31
|
+
explain[:queryPlanner][:namespace].should == authorized_collection.namespace
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
context 'sharded' do
|
36
|
+
require_topology :sharded
|
37
|
+
|
38
|
+
context 'pre-3.2 server' do
|
39
|
+
max_server_version '3.0'
|
40
|
+
|
41
|
+
it 'executes the explain' do
|
42
|
+
explain[:queryPlanner][:parsedQuery].should be_a(Hash)
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
context '3.2+ server' do
|
47
|
+
min_server_fcv '3.2'
|
48
|
+
|
49
|
+
it 'executes the explain' do
|
50
|
+
explain[:queryPlanner][:mongosPlannerVersion].should == 1
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
context '2.6 server' do
|
57
|
+
max_server_version '2.6'
|
58
|
+
|
59
|
+
it 'executes the explain' do
|
60
|
+
explain[:cursor].should == 'BasicCursor'
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
context 'without arguments' do
|
66
|
+
let(:explain) do
|
67
|
+
view.explain
|
68
|
+
end
|
69
|
+
|
70
|
+
include_examples 'executes the explain'
|
25
71
|
end
|
26
72
|
|
27
|
-
|
28
|
-
|
73
|
+
context 'with verbosity argument' do
|
74
|
+
let(:explain) do
|
75
|
+
view.explain(verbosity: verbosity)
|
76
|
+
end
|
77
|
+
|
78
|
+
shared_examples 'triggers server error' do
|
79
|
+
# 3.0 does not produce the error.
|
80
|
+
min_server_fcv '3.2'
|
81
|
+
|
82
|
+
it 'triggers server error' do
|
83
|
+
lambda do
|
84
|
+
explain
|
85
|
+
end.should raise_error(Mongo::Error::OperationFailure, /verbosity string must be/)
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
89
|
+
context 'valid symbol value' do
|
90
|
+
let(:verbosity) { :query_planner }
|
91
|
+
|
92
|
+
include_examples 'executes the explain'
|
93
|
+
end
|
94
|
+
|
95
|
+
context 'valid string value' do
|
96
|
+
let(:verbosity) { 'executionStats' }
|
97
|
+
|
98
|
+
include_examples 'executes the explain'
|
99
|
+
end
|
100
|
+
|
101
|
+
context 'invalid symbol value' do
|
102
|
+
let(:verbosity) { :bogus }
|
103
|
+
|
104
|
+
include_examples 'triggers server error'
|
105
|
+
end
|
106
|
+
|
107
|
+
context 'invalid string value' do
|
108
|
+
let(:verbosity) { 'bogus' }
|
109
|
+
|
110
|
+
include_examples 'triggers server error'
|
111
|
+
end
|
29
112
|
end
|
30
113
|
end
|
31
114
|
end
|
@@ -581,6 +581,7 @@ describe Mongo::Collection::View::MapReduce do
|
|
581
581
|
|
582
582
|
context 'when the server is not valid for writing' do
|
583
583
|
clean_slate
|
584
|
+
require_warning_clean
|
584
585
|
|
585
586
|
before do
|
586
587
|
stop_monitoring(authorized_client)
|
@@ -661,6 +662,7 @@ describe Mongo::Collection::View::MapReduce do
|
|
661
662
|
|
662
663
|
context 'when the server is a valid for writing' do
|
663
664
|
clean_slate
|
665
|
+
require_warning_clean
|
664
666
|
|
665
667
|
before do
|
666
668
|
stop_monitoring(authorized_client)
|
@@ -821,6 +821,38 @@ describe Mongo::Collection do
|
|
821
821
|
end
|
822
822
|
end
|
823
823
|
|
824
|
+
context 'when write concern passed in as an option' do
|
825
|
+
min_server_fcv '3.4'
|
826
|
+
require_topology :replica_set
|
827
|
+
|
828
|
+
before do
|
829
|
+
database['collection_spec'].drop
|
830
|
+
end
|
831
|
+
|
832
|
+
let(:events) do
|
833
|
+
subscriber.command_started_events('create')
|
834
|
+
end
|
835
|
+
|
836
|
+
let(:options) do
|
837
|
+
{ write_concern: {w: 1} }
|
838
|
+
end
|
839
|
+
|
840
|
+
let!(:collection) do
|
841
|
+
authorized_collection.with(options)
|
842
|
+
end
|
843
|
+
|
844
|
+
let!(:command) do
|
845
|
+
Utils.get_command_event(authorized_client, 'create') do |client|
|
846
|
+
collection.create({ write_concern: {w: 2} })
|
847
|
+
end.command
|
848
|
+
end
|
849
|
+
|
850
|
+
it 'applies the write concern passed in as an option' do
|
851
|
+
expect(events.length).to eq(1)
|
852
|
+
expect(command[:writeConcern][:w]).to eq(2)
|
853
|
+
end
|
854
|
+
end
|
855
|
+
|
824
856
|
context 'when the server does not support write concern on the create command' do
|
825
857
|
max_server_version '3.2'
|
826
858
|
|
@@ -1059,6 +1091,34 @@ describe Mongo::Collection do
|
|
1059
1091
|
end
|
1060
1092
|
end
|
1061
1093
|
|
1094
|
+
context 'when write concern passed in as an option' do
|
1095
|
+
min_server_fcv '3.4'
|
1096
|
+
require_set_write_concern
|
1097
|
+
|
1098
|
+
let(:events) do
|
1099
|
+
subscriber.command_started_events('drop')
|
1100
|
+
end
|
1101
|
+
|
1102
|
+
let(:options) do
|
1103
|
+
{ write_concern: {w: 1} }
|
1104
|
+
end
|
1105
|
+
|
1106
|
+
let!(:collection) do
|
1107
|
+
authorized_collection.with(options)
|
1108
|
+
end
|
1109
|
+
|
1110
|
+
let!(:command) do
|
1111
|
+
Utils.get_command_event(authorized_client, 'drop') do |client|
|
1112
|
+
collection.drop({ write_concern: {w: 0} })
|
1113
|
+
end.command
|
1114
|
+
end
|
1115
|
+
|
1116
|
+
it 'applies the write concern passed in as an option' do
|
1117
|
+
expect(events.length).to eq(1)
|
1118
|
+
expect(command[:writeConcern][:w]).to eq(0)
|
1119
|
+
end
|
1120
|
+
end
|
1121
|
+
|
1062
1122
|
context 'when the server does not support write concern on the drop command' do
|
1063
1123
|
max_server_version '3.2'
|
1064
1124
|
|