mongo 2.14.0 → 2.15.0.alpha
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +0 -0
- data/README.md +4 -1
- data/Rakefile +8 -15
- data/lib/mongo.rb +23 -0
- data/lib/mongo/auth/aws/conversation.rb +1 -4
- data/lib/mongo/auth/base.rb +13 -7
- data/lib/mongo/auth/conversation_base.rb +32 -0
- data/lib/mongo/auth/cr/conversation.rb +6 -29
- data/lib/mongo/auth/gssapi/conversation.rb +4 -15
- data/lib/mongo/auth/ldap/conversation.rb +3 -14
- data/lib/mongo/auth/sasl_conversation_base.rb +1 -13
- data/lib/mongo/auth/scram_conversation_base.rb +7 -34
- data/lib/mongo/auth/user/view.rb +16 -9
- data/lib/mongo/auth/x509/conversation.rb +4 -25
- data/lib/mongo/background_thread.rb +11 -0
- data/lib/mongo/bulk_write.rb +21 -18
- data/lib/mongo/client.rb +82 -6
- data/lib/mongo/cluster.rb +19 -28
- data/lib/mongo/cluster/reapers/cursor_reaper.rb +6 -2
- data/lib/mongo/cluster/sdam_flow.rb +14 -0
- data/lib/mongo/collection.rb +8 -6
- data/lib/mongo/collection/view/aggregation.rb +1 -1
- data/lib/mongo/collection/view/change_stream.rb +1 -1
- data/lib/mongo/collection/view/iterable.rb +1 -1
- data/lib/mongo/collection/view/map_reduce.rb +2 -2
- data/lib/mongo/collection/view/readable.rb +42 -20
- data/lib/mongo/collection/view/writable.rb +14 -14
- data/lib/mongo/cursor.rb +2 -2
- data/lib/mongo/database.rb +22 -5
- data/lib/mongo/database/view.rb +1 -1
- data/lib/mongo/error.rb +9 -1
- data/lib/mongo/error/bulk_write_error.rb +17 -3
- data/lib/mongo/error/internal_driver_error.rb +22 -0
- data/lib/mongo/error/operation_failure.rb +21 -2
- data/lib/mongo/error/parser.rb +65 -12
- data/lib/mongo/error/server_api_conflict.rb +23 -0
- data/lib/mongo/error/server_api_not_supported.rb +24 -0
- data/lib/mongo/error/unmet_dependency.rb +21 -0
- data/lib/mongo/grid/fs_bucket.rb +37 -37
- data/lib/mongo/index/view.rb +21 -11
- data/lib/mongo/monitoring.rb +13 -4
- data/lib/mongo/monitoring/event/server_heartbeat_failed.rb +27 -16
- data/lib/mongo/monitoring/event/server_heartbeat_succeeded.rb +26 -15
- data/lib/mongo/operation.rb +2 -2
- data/lib/mongo/operation/collections_info.rb +18 -1
- data/lib/mongo/operation/collections_info/command.rb +2 -2
- data/lib/mongo/operation/context.rb +99 -0
- data/lib/mongo/operation/indexes.rb +15 -1
- data/lib/mongo/operation/insert/command.rb +2 -2
- data/lib/mongo/operation/insert/legacy.rb +2 -2
- data/lib/mongo/operation/insert/op_msg.rb +2 -2
- data/lib/mongo/operation/list_collections/result.rb +4 -1
- data/lib/mongo/operation/result.rb +2 -0
- data/lib/mongo/operation/shared/executable.rb +24 -14
- data/lib/mongo/operation/shared/executable_no_validate.rb +2 -2
- data/lib/mongo/operation/shared/op_msg_or_command.rb +1 -7
- data/lib/mongo/operation/shared/op_msg_or_find_command.rb +1 -7
- data/lib/mongo/operation/shared/polymorphic_operation.rb +39 -0
- data/lib/mongo/operation/shared/response_handling.rb +23 -23
- data/lib/mongo/operation/shared/sessions_supported.rb +13 -2
- data/lib/mongo/operation/shared/write.rb +8 -18
- data/lib/mongo/protocol/compressed.rb +51 -5
- data/lib/mongo/protocol/message.rb +20 -2
- data/lib/mongo/protocol/msg.rb +36 -11
- data/lib/mongo/query_cache.rb +30 -0
- data/lib/mongo/retryable.rb +1 -1
- data/lib/mongo/server.rb +7 -15
- data/lib/mongo/server/app_metadata.rb +52 -18
- data/lib/mongo/server/connection.rb +5 -0
- data/lib/mongo/server/connection_base.rb +13 -10
- data/lib/mongo/server/connection_pool.rb +6 -4
- data/lib/mongo/server/description.rb +4 -0
- data/lib/mongo/server/description/features.rb +9 -8
- data/lib/mongo/server/monitor.rb +20 -1
- data/lib/mongo/server/monitor/app_metadata.rb +1 -1
- data/lib/mongo/server/monitor/connection.rb +9 -10
- data/lib/mongo/server/pending_connection.rb +24 -6
- data/lib/mongo/server/push_monitor.rb +11 -1
- data/lib/mongo/session.rb +2 -2
- data/lib/mongo/session/session_pool.rb +4 -2
- data/lib/mongo/socket.rb +29 -4
- data/lib/mongo/socket/ssl.rb +8 -0
- data/lib/mongo/srv/monitor.rb +0 -11
- data/lib/mongo/uri/options_mapper.rb +38 -0
- data/lib/mongo/utils.rb +15 -0
- data/lib/mongo/version.rb +1 -1
- data/spec/README.md +24 -1
- data/spec/integration/auth_spec.rb +25 -15
- data/spec/integration/bulk_write_error_message_spec.rb +41 -0
- data/spec/integration/change_stream_spec.rb +4 -4
- data/spec/integration/command_monitoring_spec.rb +2 -2
- data/spec/integration/connection_spec.rb +2 -0
- data/spec/integration/docs_examples_spec.rb +8 -1
- data/spec/integration/fork_reconnect_spec.rb +4 -1
- data/spec/integration/ocsp_verifier_spec.rb +13 -7
- data/spec/integration/operation_failure_code_spec.rb +1 -1
- data/spec/integration/operation_failure_message_spec.rb +90 -0
- data/spec/integration/reconnect_spec.rb +1 -1
- data/spec/integration/sdam_error_handling_spec.rb +1 -1
- data/spec/integration/sdam_events_spec.rb +3 -5
- data/spec/integration/snappy_compression_spec.rb +25 -0
- data/spec/integration/srv_monitoring_spec.rb +1 -1
- data/spec/integration/transactions_examples_spec.rb +6 -0
- data/spec/integration/zlib_compression_spec.rb +1 -1
- data/spec/integration/zstd_compression_spec.rb +26 -0
- data/spec/lite_spec_helper.rb +7 -1
- data/spec/mongo/address_spec.rb +15 -11
- data/spec/mongo/auth/ldap/conversation_spec.rb +1 -1
- data/spec/mongo/auth/ldap_spec.rb +5 -1
- data/spec/mongo/auth/scram_negotiation_spec.rb +1 -1
- data/spec/mongo/auth/scram_spec.rb +1 -1
- data/spec/mongo/auth/x509/conversation_spec.rb +3 -3
- data/spec/mongo/client_construction_spec.rb +207 -33
- data/spec/mongo/client_spec.rb +17 -0
- data/spec/mongo/cluster_spec.rb +3 -18
- data/spec/mongo/collection/view/explainable_spec.rb +1 -1
- data/spec/mongo/collection/view/readable_spec.rb +33 -19
- data/spec/mongo/collection_crud_spec.rb +4357 -0
- data/spec/mongo/collection_ddl_spec.rb +534 -0
- data/spec/mongo/collection_spec.rb +5 -4859
- data/spec/mongo/database_spec.rb +66 -4
- data/spec/mongo/error/bulk_write_error_spec.rb +3 -3
- data/spec/mongo/error/parser_spec.rb +37 -6
- data/spec/mongo/index/view_spec.rb +8 -2
- data/spec/mongo/monitoring/event/server_heartbeat_failed_spec.rb +1 -1
- data/spec/mongo/monitoring/event/server_heartbeat_succeeded_spec.rb +1 -1
- data/spec/mongo/operation/aggregate_spec.rb +2 -1
- data/spec/mongo/operation/collections_info_spec.rb +4 -1
- data/spec/mongo/operation/command_spec.rb +6 -3
- data/spec/mongo/operation/create_index_spec.rb +6 -3
- data/spec/mongo/operation/create_user_spec.rb +6 -3
- data/spec/mongo/operation/delete/bulk_spec.rb +9 -6
- data/spec/mongo/operation/delete_spec.rb +11 -7
- data/spec/mongo/operation/drop_index_spec.rb +6 -2
- data/spec/mongo/operation/find/legacy_spec.rb +3 -1
- data/spec/mongo/operation/get_more_spec.rb +3 -1
- data/spec/mongo/operation/indexes_spec.rb +5 -1
- data/spec/mongo/operation/insert/bulk_spec.rb +10 -7
- data/spec/mongo/operation/insert_spec.rb +15 -12
- data/spec/mongo/operation/map_reduce_spec.rb +5 -2
- data/spec/mongo/operation/remove_user_spec.rb +6 -3
- data/spec/mongo/operation/result_spec.rb +1 -1
- data/spec/mongo/operation/update/bulk_spec.rb +9 -6
- data/spec/mongo/operation/update_spec.rb +10 -7
- data/spec/mongo/operation/update_user_spec.rb +4 -1
- data/spec/mongo/protocol/compressed_spec.rb +26 -12
- data/spec/mongo/query_cache_middleware_spec.rb +55 -0
- data/spec/mongo/retryable_spec.rb +3 -2
- data/spec/mongo/server/app_metadata_spec.rb +2 -0
- data/spec/mongo/server/connection_pool/populator_spec.rb +3 -1
- data/spec/mongo/server/connection_pool_spec.rb +1 -1
- data/spec/mongo/server/connection_spec.rb +24 -17
- data/spec/mongo/server/monitor/connection_spec.rb +17 -7
- data/spec/mongo/server/monitor_spec.rb +9 -1
- data/spec/mongo/server_spec.rb +15 -2
- data/spec/mongo/socket/ssl_spec.rb +40 -0
- data/spec/mongo/socket_spec.rb +2 -2
- data/spec/mongo/tls_context_hooks_spec.rb +37 -0
- data/spec/runners/connection_string.rb +0 -4
- data/spec/runners/crud/requirement.rb +40 -3
- data/spec/runners/crud/verifier.rb +8 -0
- data/spec/runners/transactions/operation.rb +13 -2
- data/spec/runners/transactions/test.rb +1 -0
- data/spec/runners/unified.rb +96 -0
- data/spec/runners/unified/assertions.rb +249 -0
- data/spec/runners/unified/change_stream_operations.rb +26 -0
- data/spec/runners/unified/crud_operations.rb +199 -0
- data/spec/runners/unified/ddl_operations.rb +96 -0
- data/spec/runners/unified/entity_map.rb +39 -0
- data/spec/runners/unified/error.rb +25 -0
- data/spec/runners/unified/event_subscriber.rb +91 -0
- data/spec/runners/unified/exceptions.rb +21 -0
- data/spec/runners/unified/grid_fs_operations.rb +55 -0
- data/spec/runners/unified/support_operations.rb +250 -0
- data/spec/runners/unified/test.rb +393 -0
- data/spec/runners/unified/test_group.rb +28 -0
- data/spec/runners/unified/using_hash.rb +31 -0
- data/spec/shared/bin/get-mongodb-download-url +17 -0
- data/spec/shared/lib/mrss/cluster_config.rb +218 -0
- data/spec/shared/lib/mrss/constraints.rb +43 -0
- data/spec/shared/lib/mrss/docker_runner.rb +262 -0
- data/spec/shared/lib/mrss/server_version_registry.rb +112 -0
- data/spec/shared/lib/mrss/utils.rb +15 -0
- data/spec/shared/share/Dockerfile.erb +231 -0
- data/spec/shared/shlib/distro.sh +73 -0
- data/spec/shared/shlib/server.sh +290 -0
- data/spec/shared/shlib/set_env.sh +128 -0
- data/spec/solo/clean_exit_spec.rb +21 -0
- data/spec/spec_helper.rb +4 -1
- data/spec/spec_tests/crud_unified_spec.rb +10 -0
- data/spec/spec_tests/data/change_streams/change-streams.yml +0 -1
- data/spec/spec_tests/data/crud_unified/estimatedDocumentCount.yml +267 -0
- data/spec/spec_tests/data/retryable_reads/estimatedDocumentCount-4.9.yml +60 -0
- data/spec/spec_tests/data/retryable_reads/{estimatedDocumentCount.yml → estimatedDocumentCount-pre4.9.yml} +2 -0
- data/spec/spec_tests/data/retryable_reads/estimatedDocumentCount-serverErrors-4.9.yml +146 -0
- data/spec/spec_tests/data/retryable_reads/{estimatedDocumentCount-serverErrors.yml → estimatedDocumentCount-serverErrors-pre4.9.yml} +2 -0
- data/spec/spec_tests/data/retryable_reads/listIndexNames.yml +1 -1
- data/spec/spec_tests/data/unified/valid-fail/operation-failure.yml +31 -0
- data/spec/spec_tests/data/unified/valid-pass/poc-change-streams.yml +220 -0
- data/spec/spec_tests/data/unified/valid-pass/poc-command-monitoring.yml +102 -0
- data/spec/spec_tests/data/unified/valid-pass/poc-crud.yml +184 -0
- data/spec/spec_tests/data/unified/valid-pass/poc-gridfs.yml +155 -0
- data/spec/spec_tests/data/unified/valid-pass/poc-retryable-reads.yml +193 -0
- data/spec/spec_tests/data/unified/valid-pass/poc-retryable-writes.yml +210 -0
- data/spec/spec_tests/data/unified/valid-pass/poc-sessions.yml +215 -0
- data/spec/spec_tests/data/unified/valid-pass/poc-transactions-convenient-api.yml +235 -0
- data/spec/spec_tests/data/unified/valid-pass/poc-transactions-mongos-pin-auto.yml +169 -0
- data/spec/spec_tests/data/unified/valid-pass/poc-transactions.yml +170 -0
- data/spec/spec_tests/data/uri_options/compression-options.yml +1 -1
- data/spec/spec_tests/data/versioned_api/crud-api-version-1-strict.yml +416 -0
- data/spec/spec_tests/data/versioned_api/crud-api-version-1.yml +409 -0
- data/spec/spec_tests/data/versioned_api/runcommand-helper-no-api-version-declared.yml +67 -0
- data/spec/spec_tests/data/versioned_api/test-commands-deprecation-errors.yml +47 -0
- data/spec/spec_tests/data/versioned_api/test-commands-strict-mode.yml +44 -0
- data/spec/spec_tests/data/versioned_api/transaction-handling.yml +180 -0
- data/spec/spec_tests/unified_spec.rb +15 -0
- data/spec/spec_tests/uri_options_spec.rb +16 -0
- data/spec/spec_tests/versioned_api_spec.rb +10 -0
- data/spec/support/common_shortcuts.rb +15 -1
- data/spec/support/shared/session.rb +2 -2
- data/spec/support/spec_config.rb +46 -3
- data/spec/support/spec_setup.rb +48 -38
- data/spec/support/utils.rb +64 -3
- metadata +1104 -992
- metadata.gz.sig +0 -0
- data/lib/mongo/operation/shared/collections_info_or_list_collections.rb +0 -58
- data/lib/mongo/operation/shared/op_msg_or_list_indexes_command.rb +0 -47
- data/spec/support/cluster_config.rb +0 -207
@@ -0,0 +1,41 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe 'BulkWriteError message' do
|
4
|
+
let(:client) { authorized_client }
|
5
|
+
let(:collection_name) { 'bulk_write_error_message_spec' }
|
6
|
+
let(:collection) { client[collection_name] }
|
7
|
+
|
8
|
+
before do
|
9
|
+
collection.delete_many
|
10
|
+
end
|
11
|
+
|
12
|
+
context 'a bulk write with one error' do
|
13
|
+
it 'reports code name, code and message' do
|
14
|
+
begin
|
15
|
+
collection.insert_many([
|
16
|
+
{_id: 1},
|
17
|
+
{_id: 1},
|
18
|
+
{_id: 1},
|
19
|
+
], ordered: true)
|
20
|
+
fail('Should have raised')
|
21
|
+
rescue Mongo::Error::BulkWriteError => e
|
22
|
+
e.message.should =~ %r,\A\[11000\]: (insertDocument :: caused by :: 11000 )?E11000 duplicate key error (collection|index):,
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
context 'a bulk write with multiple errors' do
|
28
|
+
it 'reports code name, code and message' do
|
29
|
+
begin
|
30
|
+
collection.insert_many([
|
31
|
+
{_id: 1},
|
32
|
+
{_id: 1},
|
33
|
+
{_id: 1},
|
34
|
+
], ordered: false)
|
35
|
+
fail('Should have raised')
|
36
|
+
rescue Mongo::Error::BulkWriteError => e
|
37
|
+
e.message.should =~ %r,\AMultiple errors: \[11000\]: (insertDocument :: caused by :: 11000 )?E11000 duplicate key error (collection|index):.*\[11000\]: (insertDocument :: caused by :: 11000 )?E11000 duplicate key error (collection|index):,
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
@@ -98,7 +98,7 @@ describe 'Change stream integration', retry: 4 do
|
|
98
98
|
it 'watch raises error' do
|
99
99
|
expect do
|
100
100
|
client['change-stream'].watch
|
101
|
-
end.to raise_error(Mongo::Error::OperationFailure, /Failing command due to 'failCommand' failpoint
|
101
|
+
end.to raise_error(Mongo::Error::OperationFailure, /10107\b.*Failing command due to 'failCommand' failpoint/)
|
102
102
|
end
|
103
103
|
end
|
104
104
|
|
@@ -283,7 +283,7 @@ describe 'Change stream integration', retry: 4 do
|
|
283
283
|
|
284
284
|
expect do
|
285
285
|
enum.next
|
286
|
-
end.to raise_error(Mongo::Error::OperationFailure, /Failing command due to 'failCommand' failpoint
|
286
|
+
end.to raise_error(Mongo::Error::OperationFailure, /101\b.*Failing command due to 'failCommand' failpoint/)
|
287
287
|
end
|
288
288
|
end
|
289
289
|
end
|
@@ -414,7 +414,7 @@ describe 'Change stream integration', retry: 4 do
|
|
414
414
|
|
415
415
|
expect do
|
416
416
|
enum.try_next
|
417
|
-
end.to raise_error(Mongo::Error::OperationFailure, /Failing command due to 'failCommand' failpoint
|
417
|
+
end.to raise_error(Mongo::Error::OperationFailure, /10107\b.*Failing command due to 'failCommand' failpoint/)
|
418
418
|
end
|
419
419
|
end
|
420
420
|
|
@@ -441,7 +441,7 @@ describe 'Change stream integration', retry: 4 do
|
|
441
441
|
|
442
442
|
expect do
|
443
443
|
enum.try_next
|
444
|
-
end.to raise_error(Mongo::Error::OperationFailure, /Failing command due to 'failCommand' failpoint
|
444
|
+
end.to raise_error(Mongo::Error::OperationFailure, /10107\b.*Failing command due to 'failCommand' failpoint/)
|
445
445
|
end
|
446
446
|
end
|
447
447
|
end
|
@@ -135,8 +135,8 @@ describe 'Command monitoring' do
|
|
135
135
|
|
136
136
|
subscriber.clear_events!
|
137
137
|
expect do
|
138
|
-
command.execute(server,
|
139
|
-
end.to raise_error(Mongo::Error::OperationFailure, /Not enough data-bearing nodes
|
138
|
+
command.execute(server, context: Mongo::Operation::Context.new(session: session))
|
139
|
+
end.to raise_error(Mongo::Error::OperationFailure, /100\b.*Not enough data-bearing nodes/)
|
140
140
|
|
141
141
|
expect(subscriber.started_events.length).to eq(1)
|
142
142
|
event = subscriber.started_events.first
|
@@ -232,6 +232,8 @@ describe 'Connections' do
|
|
232
232
|
end
|
233
233
|
|
234
234
|
describe 'wire protocol version range update' do
|
235
|
+
require_no_required_api_version
|
236
|
+
|
235
237
|
# 3.2 wire protocol is 4.
|
236
238
|
# Wire protocol < 2 means only scram auth is available,
|
237
239
|
# which is not supported by modern mongos.
|
@@ -4,7 +4,14 @@ describe 'aggregation examples in Ruby' do
|
|
4
4
|
before(:all) do
|
5
5
|
# In sharded clusters we need to ensure the database exists before running
|
6
6
|
# the tests in this file.
|
7
|
-
|
7
|
+
begin
|
8
|
+
ClientRegistry.instance.global_client('authorized')['_placeholder'].create
|
9
|
+
rescue Mongo::Error::OperationFailure => e
|
10
|
+
# Collection already exists
|
11
|
+
if e.code != 48
|
12
|
+
raise
|
13
|
+
end
|
14
|
+
end
|
8
15
|
end
|
9
16
|
|
10
17
|
let(:client) do
|
@@ -18,7 +18,10 @@ describe 'fork reconnect' do
|
|
18
18
|
|
19
19
|
describe 'monitoring connection' do
|
20
20
|
let(:monitor) do
|
21
|
-
Mongo::Server::Monitor.new(server, [], Mongo::Monitoring.new, server.options
|
21
|
+
Mongo::Server::Monitor.new(server, [], Mongo::Monitoring.new, server.options.merge(
|
22
|
+
app_metadata: client.cluster.monitor_app_metadata,
|
23
|
+
push_monitor_app_metadata: client.cluster.push_monitor_app_metadata,
|
24
|
+
))
|
22
25
|
end
|
23
26
|
|
24
27
|
it 'reconnects' do
|
@@ -42,7 +42,7 @@ describe Mongo::Socket::OcspVerifier do
|
|
42
42
|
lambda do
|
43
43
|
verifier.verify
|
44
44
|
end.should raise_error(Mongo::Error::ServerCertificateRevoked)
|
45
|
-
end.should take_shorter_than
|
45
|
+
end.should take_shorter_than 7
|
46
46
|
end
|
47
47
|
end
|
48
48
|
|
@@ -76,7 +76,7 @@ describe Mongo::Socket::OcspVerifier do
|
|
76
76
|
end
|
77
77
|
|
78
78
|
let(:verifier) do
|
79
|
-
described_class.new('foo', cert, ca_cert, cert_store, timeout:
|
79
|
+
described_class.new('foo', cert, ca_cert, cert_store, timeout: 7)
|
80
80
|
end
|
81
81
|
end
|
82
82
|
|
@@ -101,7 +101,7 @@ describe Mongo::Socket::OcspVerifier do
|
|
101
101
|
# the operation complete quickly.
|
102
102
|
lambda do
|
103
103
|
verifier.verify
|
104
|
-
end.should take_shorter_than
|
104
|
+
end.should take_shorter_than 7
|
105
105
|
end
|
106
106
|
end
|
107
107
|
|
@@ -124,7 +124,7 @@ describe Mongo::Socket::OcspVerifier do
|
|
124
124
|
it 'does not wait for the timeout' do
|
125
125
|
lambda do
|
126
126
|
verifier.verify
|
127
|
-
end.should take_shorter_than
|
127
|
+
end.should take_shorter_than 7
|
128
128
|
end
|
129
129
|
end
|
130
130
|
|
@@ -152,7 +152,7 @@ describe Mongo::Socket::OcspVerifier do
|
|
152
152
|
it 'does not wait for the timeout' do
|
153
153
|
lambda do
|
154
154
|
verifier.verify
|
155
|
-
end.should take_shorter_than
|
155
|
+
end.should take_shorter_than 7
|
156
156
|
end
|
157
157
|
end
|
158
158
|
end
|
@@ -198,7 +198,7 @@ describe Mongo::Socket::OcspVerifier do
|
|
198
198
|
it 'does not wait for the timeout' do
|
199
199
|
lambda do
|
200
200
|
verifier.verify
|
201
|
-
end.should take_shorter_than
|
201
|
+
end.should take_shorter_than 7
|
202
202
|
end
|
203
203
|
end
|
204
204
|
|
@@ -228,7 +228,7 @@ describe Mongo::Socket::OcspVerifier do
|
|
228
228
|
it 'does not wait for the timeout' do
|
229
229
|
lambda do
|
230
230
|
verifier.verify
|
231
|
-
end.should take_shorter_than
|
231
|
+
end.should take_shorter_than 7
|
232
232
|
end
|
233
233
|
end
|
234
234
|
end
|
@@ -278,6 +278,8 @@ describe Mongo::Socket::OcspVerifier do
|
|
278
278
|
ensure
|
279
279
|
server.shutdown
|
280
280
|
end
|
281
|
+
|
282
|
+
::Utils.wait_for_port_free(8100, 5)
|
281
283
|
end
|
282
284
|
|
283
285
|
[400, 404, 500, 503].each do |_code|
|
@@ -312,6 +314,9 @@ describe Mongo::Socket::OcspVerifier do
|
|
312
314
|
context 'responder URI has no path' do
|
313
315
|
require_external_connectivity
|
314
316
|
|
317
|
+
# https://github.com/jruby/jruby-openssl/issues/210
|
318
|
+
fails_on_jruby
|
319
|
+
|
315
320
|
include_context 'basic verifier'
|
316
321
|
|
317
322
|
let(:cert_path) { File.join(File.dirname(__FILE__), '../support/certificates/atlas-ocsp.crt') }
|
@@ -323,6 +328,7 @@ describe Mongo::Socket::OcspVerifier do
|
|
323
328
|
end
|
324
329
|
|
325
330
|
before do
|
331
|
+
verifier.ocsp_uris.length.should > 0
|
326
332
|
URI.parse(verifier.ocsp_uris.first).path.should == ''
|
327
333
|
end
|
328
334
|
|
@@ -0,0 +1,90 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe 'OperationFailure message' do
|
4
|
+
let(:client) { authorized_client }
|
5
|
+
let(:collection_name) { 'operation_failure_message_spec' }
|
6
|
+
let(:collection) { client[collection_name] }
|
7
|
+
|
8
|
+
context 'crud error' do
|
9
|
+
before do
|
10
|
+
collection.delete_many
|
11
|
+
end
|
12
|
+
|
13
|
+
context 'a command error with code and code name' do
|
14
|
+
context 'on modern servers that provide code name' do
|
15
|
+
# Sharded clusters include the code name: SERVER-55582
|
16
|
+
require_topology :single, :replica_set
|
17
|
+
|
18
|
+
min_server_fcv '3.4'
|
19
|
+
|
20
|
+
it 'reports code, code name and message' do
|
21
|
+
begin
|
22
|
+
client.command(bogus_command: nil)
|
23
|
+
fail('Should have raised')
|
24
|
+
rescue Mongo::Error::OperationFailure => e
|
25
|
+
e.code_name.should == 'CommandNotFound'
|
26
|
+
e.message.should =~ %r,\A\[59:CommandNotFound\]: no such (?:command|cmd): '?bogus_command'?,
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
context 'on legacy servers where code name is not provided' do
|
32
|
+
max_server_version '3.2'
|
33
|
+
|
34
|
+
it 'reports code and message' do
|
35
|
+
begin
|
36
|
+
client.command(bogus_command: nil)
|
37
|
+
fail('Should have raised')
|
38
|
+
rescue Mongo::Error::OperationFailure => e
|
39
|
+
e.code_name.should be nil
|
40
|
+
e.message.should =~ %r,\A\[59\]: no such (?:command|cmd): '?bogus_command'?,
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
context 'a write error with code and no code name' do
|
47
|
+
# Sharded clusters include the code name: SERVER-55582
|
48
|
+
require_topology :single, :replica_set
|
49
|
+
|
50
|
+
it 'reports code name, code and message' do
|
51
|
+
begin
|
52
|
+
collection.insert_one(_id: 1)
|
53
|
+
collection.insert_one(_id: 1)
|
54
|
+
fail('Should have raised')
|
55
|
+
rescue Mongo::Error::OperationFailure => e
|
56
|
+
e.code_name.should be nil
|
57
|
+
e.message.should =~ %r,\A\[11000\]: (?:insertDocument :: caused by :: 11000 )?E11000 duplicate key error (?:collection|index):,
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
context 'authentication error' do
|
64
|
+
require_no_external_user
|
65
|
+
|
66
|
+
let(:client) do
|
67
|
+
authorized_client.with(user: 'bogus', password: 'bogus')
|
68
|
+
end
|
69
|
+
|
70
|
+
context 'on modern servers where code name is provided' do
|
71
|
+
min_server_fcv '3.4'
|
72
|
+
|
73
|
+
it 'includes code and code name in the message' do
|
74
|
+
lambda do
|
75
|
+
client.command(ping: 1)
|
76
|
+
end.should raise_error(Mongo::Auth::Unauthorized, /User bogus.*is not authorized.*\[18:AuthenticationFailed\]: Authentication failed/)
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
context 'on legacy servers where code name is not provided' do
|
81
|
+
max_server_version '3.2'
|
82
|
+
|
83
|
+
it 'includes code only in the message' do
|
84
|
+
lambda do
|
85
|
+
client.command(ping: 1)
|
86
|
+
end.should raise_error(Mongo::Auth::Unauthorized, /User bogus.*is not authorized.*\[18\]: (?:Authentication|auth) failed/)
|
87
|
+
end
|
88
|
+
end
|
89
|
+
end
|
90
|
+
end
|
@@ -65,7 +65,7 @@ describe 'Client after reconnect' do
|
|
65
65
|
end
|
66
66
|
|
67
67
|
let(:client) do
|
68
|
-
new_local_client(uri, SpecConfig.instance.
|
68
|
+
new_local_client(uri, SpecConfig.instance.monitoring_options.merge(
|
69
69
|
server_selection_timeout: 3.86, logger: logger))
|
70
70
|
end
|
71
71
|
|
@@ -67,10 +67,8 @@ describe 'SDAM events' do
|
|
67
67
|
started_events.length.should <= 10
|
68
68
|
|
69
69
|
succeeded_events = subscriber.select_succeeded_events(Mongo::Monitoring::Event::ServerHeartbeatSucceeded)
|
70
|
-
# Since we gracefully close the client, we expect each heartbeat
|
71
|
-
# to complete.
|
72
70
|
started_events.length.should > 1
|
73
|
-
(succeeded_events.length
|
71
|
+
(succeeded_events.length..succeeded_events.length+1).should include(started_events.length)
|
74
72
|
end
|
75
73
|
end
|
76
74
|
|
@@ -109,9 +107,9 @@ describe 'SDAM events' do
|
|
109
107
|
# There may be in-flight ismasters that don't complete, both
|
110
108
|
# regular and awaited.
|
111
109
|
started_awaited.length.should > 1
|
112
|
-
(succeeded_awaited.length
|
110
|
+
(succeeded_awaited.length..succeeded_awaited.length+1).should include(started_awaited.length)
|
113
111
|
started_regular.length.should > 1
|
114
|
-
(succeeded_regular.length
|
112
|
+
(succeeded_regular.length..succeeded_regular.length+1).should include(started_regular.length)
|
115
113
|
end
|
116
114
|
end
|
117
115
|
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe 'Snappy compression' do
|
4
|
+
require_snappy_compression
|
5
|
+
|
6
|
+
before do
|
7
|
+
authorized_client['test'].drop
|
8
|
+
end
|
9
|
+
|
10
|
+
context 'when client has snappy compressor option enabled' do
|
11
|
+
it 'compresses the message to the server' do
|
12
|
+
# Double check that the client has snappy compression enabled
|
13
|
+
expect(authorized_client.options[:compressors]).to include('snappy')
|
14
|
+
|
15
|
+
expect(Mongo::Protocol::Compressed).to receive(:new).twice.and_call_original
|
16
|
+
expect(Snappy).to receive(:deflate).twice.and_call_original
|
17
|
+
expect(Snappy).to receive(:inflate).twice.and_call_original
|
18
|
+
|
19
|
+
authorized_client['test'].insert_one(_id: 1, text: 'hello world')
|
20
|
+
document = authorized_client['test'].find(_id: 1).first
|
21
|
+
|
22
|
+
expect(document['text']).to eq('hello world')
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -117,7 +117,7 @@ describe 'SRV Monitoring' do
|
|
117
117
|
|
118
118
|
let(:client) do
|
119
119
|
new_local_client(uri,
|
120
|
-
SpecConfig.instance.
|
120
|
+
SpecConfig.instance.monitoring_options.merge(
|
121
121
|
server_selection_timeout: 3.16,
|
122
122
|
socket_timeout: 8.11,
|
123
123
|
connect_timeout: 8.12,
|
@@ -8,6 +8,12 @@ describe 'Transactions examples' do
|
|
8
8
|
authorized_client.with(read_concern: {level: :majority}, write: {w: :majority})
|
9
9
|
end
|
10
10
|
|
11
|
+
before do
|
12
|
+
if SpecConfig.instance.client_debug?
|
13
|
+
Mongo::Logger.logger.level = 0
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
11
17
|
let(:hr) do
|
12
18
|
client.use(:hr).database
|
13
19
|
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe 'Zstd compression' do
|
4
|
+
min_server_version '4.2'
|
5
|
+
require_zstd_compression
|
6
|
+
|
7
|
+
before do
|
8
|
+
authorized_client['test'].drop
|
9
|
+
end
|
10
|
+
|
11
|
+
context 'when client has snappy compressor option enabled' do
|
12
|
+
it 'compresses the message to the server' do
|
13
|
+
# Double check that the client has zstd compression enabled
|
14
|
+
expect(authorized_client.options[:compressors]).to include('zstd')
|
15
|
+
|
16
|
+
expect(Mongo::Protocol::Compressed).to receive(:new).twice.and_call_original
|
17
|
+
expect(Zstd).to receive(:compress).twice.and_call_original
|
18
|
+
expect(Zstd).to receive(:decompress).twice.and_call_original
|
19
|
+
|
20
|
+
authorized_client['test'].insert_one(_id: 1, text: 'hello world')
|
21
|
+
document = authorized_client['test'].find(_id: 1).first
|
22
|
+
|
23
|
+
expect(document['text']).to eq('hello world')
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|