mongo 2.14.1 → 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/README.md +4 -1
- data/Rakefile +8 -15
- 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/bulk_write.rb +21 -18
- data/lib/mongo/client.rb +82 -6
- data/lib/mongo/cluster/reapers/cursor_reaper.rb +6 -2
- data/lib/mongo/cluster.rb +19 -2
- 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 +7 -17
- 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/collection.rb +6 -6
- data/lib/mongo/cursor.rb +2 -12
- data/lib/mongo/database/view.rb +1 -1
- data/lib/mongo/database.rb +8 -3
- 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/error.rb +9 -1
- data/lib/mongo/index/view.rb +21 -11
- 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/monitoring.rb +13 -4
- data/lib/mongo/operation/collections_info/command.rb +2 -2
- data/lib/mongo/operation/collections_info.rb +18 -1
- 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/parallel_scan/command.rb +2 -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/read_preference_supported.rb +36 -38
- data/lib/mongo/operation/shared/response_handling.rb +23 -23
- data/lib/mongo/operation/shared/sessions_supported.rb +15 -5
- data/lib/mongo/operation/shared/write.rb +8 -18
- data/lib/mongo/operation.rb +2 -2
- data/lib/mongo/protocol/compressed.rb +51 -5
- data/lib/mongo/protocol/message.rb +20 -2
- data/lib/mongo/protocol/msg.rb +38 -13
- data/lib/mongo/protocol/query.rb +11 -11
- data/lib/mongo/query_cache.rb +30 -0
- data/lib/mongo/retryable.rb +1 -1
- 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 -2
- data/lib/mongo/server/description/features.rb +9 -8
- data/lib/mongo/server/description.rb +4 -0
- data/lib/mongo/server/monitor/app_metadata.rb +1 -1
- data/lib/mongo/server/monitor/connection.rb +9 -10
- data/lib/mongo/server/monitor.rb +20 -1
- data/lib/mongo/server/pending_connection.rb +24 -6
- data/lib/mongo/server/push_monitor.rb +11 -1
- data/lib/mongo/server.rb +7 -1
- data/lib/mongo/server_selector/secondary_preferred.rb +7 -2
- data/lib/mongo/session/session_pool.rb +4 -2
- data/lib/mongo/session.rb +2 -2
- data/lib/mongo/socket/ssl.rb +8 -0
- data/lib/mongo/socket.rb +29 -4
- data/lib/mongo/uri/options_mapper.rb +38 -0
- data/lib/mongo/utils.rb +15 -0
- data/lib/mongo/version.rb +1 -1
- data/lib/mongo.rb +23 -0
- 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/query_cache_spec.rb +0 -45
- data/spec/integration/reconnect_spec.rb +1 -1
- 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 +1 -0
- 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 +4 -0
- 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/read_preference_legacy_spec.rb +19 -9
- data/spec/mongo/operation/read_preference_op_msg_spec.rb +3 -3
- 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_shared.rb +7 -33
- 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_selector/secondary_preferred_spec.rb +6 -6
- 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 +1 -1
- data/spec/runners/transactions/test.rb +1 -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/runners/unified.rb +96 -0
- data/spec/shared/lib/mrss/cluster_config.rb +0 -3
- data/spec/shared/lib/mrss/docker_runner.rb +0 -3
- data/spec/shared/lib/mrss/lite_constraints.rb +0 -16
- data/spec/shared/lib/mrss/server_version_registry.rb +0 -3
- data/spec/shared/lib/mrss/spec_organizer.rb +0 -3
- data/spec/shared/shlib/server.sh +1 -1
- 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/client_registry.rb +4 -8
- data/spec/support/client_registry_macros.rb +4 -4
- data/spec/support/common_shortcuts.rb +15 -1
- data/spec/support/shared/session.rb +2 -2
- data/spec/support/spec_config.rb +42 -11
- data/spec/support/utils.rb +64 -3
- data.tar.gz.sig +0 -0
- metadata +1005 -915
- 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/integration/secondary_reads_spec.rb +0 -102
- data/spec/support/cluster_config.rb +0 -207
@@ -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
|
@@ -1042,49 +1042,4 @@ describe 'QueryCache' do
|
|
1042
1042
|
expect(events.length).to eq(2)
|
1043
1043
|
end
|
1044
1044
|
end
|
1045
|
-
|
1046
|
-
context 'when result set has multiple documents and cursor is iterated partially' do
|
1047
|
-
|
1048
|
-
before do
|
1049
|
-
Mongo::QueryCache.enabled = false
|
1050
|
-
5.times do
|
1051
|
-
authorized_collection.insert_one({ name: 'testing' })
|
1052
|
-
end
|
1053
|
-
end
|
1054
|
-
|
1055
|
-
shared_examples 'retrieves full result set on second iteration' do
|
1056
|
-
it 'retrieves full result set on second iteration' do
|
1057
|
-
Mongo::QueryCache.clear
|
1058
|
-
Mongo::QueryCache.enabled = true
|
1059
|
-
|
1060
|
-
partial_first_iteration
|
1061
|
-
|
1062
|
-
authorized_collection.find.to_a.length.should == 5
|
1063
|
-
end
|
1064
|
-
|
1065
|
-
end
|
1066
|
-
|
1067
|
-
context 'using each & break' do
|
1068
|
-
let(:partial_first_iteration) do
|
1069
|
-
called = false
|
1070
|
-
authorized_collection.find.each do
|
1071
|
-
called = true
|
1072
|
-
break
|
1073
|
-
end
|
1074
|
-
called.should be true
|
1075
|
-
end
|
1076
|
-
|
1077
|
-
include_examples 'retrieves full result set on second iteration'
|
1078
|
-
end
|
1079
|
-
|
1080
|
-
context 'using next' do
|
1081
|
-
let(:partial_first_iteration) do
|
1082
|
-
# #next is executed in its own fiber, and query cache is disabled
|
1083
|
-
# for that operation.
|
1084
|
-
authorized_collection.find.to_enum.next
|
1085
|
-
end
|
1086
|
-
|
1087
|
-
include_examples 'retrieves full result set on second iteration'
|
1088
|
-
end
|
1089
|
-
end
|
1090
1045
|
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
|
|
@@ -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
|
data/spec/lite_spec_helper.rb
CHANGED
@@ -69,6 +69,10 @@ unless SpecConfig.instance.client_debug?
|
|
69
69
|
end
|
70
70
|
Encoding.default_external = Encoding::UTF_8
|
71
71
|
|
72
|
+
module Mrss
|
73
|
+
autoload :Utils, 'mrss/utils'
|
74
|
+
end
|
75
|
+
|
72
76
|
require 'mrss/lite_constraints'
|
73
77
|
require 'support/matchers'
|
74
78
|
require 'support/event_subscriber'
|
@@ -88,6 +92,8 @@ else
|
|
88
92
|
TimeoutInterrupt = Timeout
|
89
93
|
end
|
90
94
|
|
95
|
+
class ExampleTimeout < StandardError; end
|
96
|
+
|
91
97
|
RSpec.configure do |config|
|
92
98
|
config.extend(CommonShortcuts::ClassMethods)
|
93
99
|
config.include(CommonShortcuts::InstanceMethods)
|
@@ -118,7 +124,7 @@ RSpec.configure do |config|
|
|
118
124
|
else
|
119
125
|
45
|
120
126
|
end
|
121
|
-
TimeoutInterrupt.timeout(timeout) do
|
127
|
+
TimeoutInterrupt.timeout(timeout, ExampleTimeout) do
|
122
128
|
example.run
|
123
129
|
end
|
124
130
|
end
|
data/spec/mongo/address_spec.rb
CHANGED
@@ -263,21 +263,25 @@ describe Mongo::Address do
|
|
263
263
|
end
|
264
264
|
end
|
265
265
|
|
266
|
-
|
267
|
-
|
268
|
-
|
266
|
+
context 'keep-alive options' do
|
267
|
+
fails_on_jruby
|
268
|
+
|
269
|
+
if Socket.const_defined?(:TCP_KEEPINTVL)
|
270
|
+
it 'sets the socket TCP_KEEPINTVL option' do
|
271
|
+
expect(socket.getsockopt(Socket::IPPROTO_TCP, Socket::TCP_KEEPINTVL).int).to be <= 10
|
272
|
+
end
|
269
273
|
end
|
270
|
-
end
|
271
274
|
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
+
if Socket.const_defined?(:TCP_KEEPCNT)
|
276
|
+
it 'sets the socket TCP_KEEPCNT option' do
|
277
|
+
expect(socket.getsockopt(Socket::IPPROTO_TCP, Socket::TCP_KEEPCNT).int).to be <= 9
|
278
|
+
end
|
275
279
|
end
|
276
|
-
end
|
277
280
|
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
+
if Socket.const_defined?(:TCP_KEEPIDLE)
|
282
|
+
it 'sets the socket TCP_KEEPIDLE option' do
|
283
|
+
expect(socket.getsockopt(Socket::IPPROTO_TCP, Socket::TCP_KEEPIDLE).int).to be <= 120
|
284
|
+
end
|
281
285
|
end
|
282
286
|
end
|
283
287
|
end
|
@@ -11,7 +11,11 @@ describe Mongo::Auth::LDAP do
|
|
11
11
|
end
|
12
12
|
|
13
13
|
let(:user) do
|
14
|
-
Mongo::Auth::User.new(
|
14
|
+
Mongo::Auth::User.new(
|
15
|
+
database: '$external',
|
16
|
+
user: 'driver',
|
17
|
+
password: 'password',
|
18
|
+
)
|
15
19
|
end
|
16
20
|
|
17
21
|
describe '#login' do
|
@@ -329,7 +329,7 @@ describe 'SCRAM-SHA auth mechanism negotiation' do
|
|
329
329
|
end
|
330
330
|
|
331
331
|
let(:client) do
|
332
|
-
new_local_client(uri, SpecConfig.instance.
|
332
|
+
new_local_client(uri, SpecConfig.instance.monitoring_options.merge(max_pool_size: 1))
|
333
333
|
end
|
334
334
|
|
335
335
|
context 'when the user exists' do
|
@@ -8,7 +8,7 @@ describe Mongo::Auth::Scram do
|
|
8
8
|
end
|
9
9
|
|
10
10
|
let(:connection) do
|
11
|
-
Mongo::Server::Connection.new(server, SpecConfig.instance.
|
11
|
+
Mongo::Server::Connection.new(server, SpecConfig.instance.monitoring_options)
|
12
12
|
end
|
13
13
|
|
14
14
|
let(:cache_mod) { Mongo::Auth::CredentialCache }
|
@@ -4,7 +4,7 @@ describe Mongo::Auth::X509::Conversation do
|
|
4
4
|
|
5
5
|
let(:user) do
|
6
6
|
Mongo::Auth::User.new(
|
7
|
-
database:
|
7
|
+
database: '$external',
|
8
8
|
user: 'user',
|
9
9
|
)
|
10
10
|
end
|
@@ -35,7 +35,7 @@ describe Mongo::Auth::X509::Conversation do
|
|
35
35
|
|
36
36
|
let(:user) do
|
37
37
|
Mongo::Auth::User.new(
|
38
|
-
database:
|
38
|
+
database: '$external',
|
39
39
|
)
|
40
40
|
end
|
41
41
|
|
@@ -52,7 +52,7 @@ describe Mongo::Auth::X509::Conversation do
|
|
52
52
|
|
53
53
|
let(:user) do
|
54
54
|
Mongo::Auth::User.new(
|
55
|
-
database:
|
55
|
+
database: '$external',
|
56
56
|
user: nil
|
57
57
|
)
|
58
58
|
end
|