mongo 2.13.3 → 2.14.0.rc1
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/lib/mongo/address/ipv4.rb +1 -1
- data/lib/mongo/address/ipv6.rb +1 -1
- data/lib/mongo/address.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/topology/single.rb +1 -1
- data/lib/mongo/cluster.rb +3 -3
- 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/collection/view.rb +24 -20
- data/lib/mongo/collection.rb +26 -2
- data/lib/mongo/crypt/encryption_io.rb +6 -6
- data/lib/mongo/cursor.rb +1 -0
- data/lib/mongo/database/view.rb +1 -1
- data/lib/mongo/database.rb +8 -14
- 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/error.rb +2 -0
- data/lib/mongo/grid/fs_bucket.rb +37 -37
- data/lib/mongo/lint.rb +2 -1
- data/lib/mongo/logger.rb +3 -3
- data/lib/mongo/operation/aggregate/result.rb +9 -8
- data/lib/mongo/operation/collections_info/command.rb +0 -5
- data/lib/mongo/operation/collections_info/result.rb +3 -16
- 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/command.rb +2 -1
- 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/read_preference_supported.rb +36 -38
- data/lib/mongo/operation/shared/result/aggregatable.rb +1 -0
- data/lib/mongo/operation/shared/sessions_supported.rb +3 -3
- 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/operation.rb +2 -0
- data/lib/mongo/protocol/msg.rb +2 -2
- data/lib/mongo/protocol/query.rb +11 -11
- data/lib/mongo/query_cache.rb +242 -0
- data/lib/mongo/retryable.rb +8 -1
- data/lib/mongo/server/connection_common.rb +2 -2
- data/lib/mongo/server/connection_pool.rb +3 -0
- data/lib/mongo/server/monitor/connection.rb +3 -3
- data/lib/mongo/server/monitor.rb +1 -1
- data/lib/mongo/server/pending_connection.rb +2 -2
- data/lib/mongo/server/push_monitor.rb +1 -1
- data/lib/mongo/server.rb +5 -1
- data/lib/mongo/server_selector/base.rb +5 -1
- data/lib/mongo/server_selector/secondary_preferred.rb +7 -2
- data/lib/mongo/session.rb +3 -0
- 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/socket.rb +6 -4
- 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/options_mapper.rb +582 -0
- data/lib/mongo/uri/srv_protocol.rb +3 -2
- data/lib/mongo/uri.rb +21 -390
- data/lib/mongo/utils.rb +12 -1
- data/lib/mongo/version.rb +1 -1
- data/lib/mongo.rb +9 -0
- data/spec/NOTES.aws-auth.md +12 -7
- data/spec/README.md +56 -1
- data/spec/integration/bson_symbol_spec.rb +2 -4
- 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 +69 -18
- data/spec/integration/sdam_events_spec.rb +7 -8
- 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 +4 -2
- 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_encryption_spec.rb +10 -16
- 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/data_key_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 -64
- data/spec/mongo/error/no_server_available_spec.rb +1 -1
- data/spec/mongo/index/view_spec.rb +2 -4
- data/spec/mongo/logger_spec.rb +13 -11
- 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/query_cache_spec.rb +279 -0
- data/spec/mongo/server/app_metadata_shared.rb +7 -33
- data/spec/mongo/server/connection_pool_spec.rb +7 -3
- data/spec/mongo/server/connection_spec.rb +14 -7
- data/spec/mongo/server_selector/secondary_preferred_spec.rb +6 -6
- 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/runners/transactions/operation.rb +2 -13
- 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.rb +4 -8
- data/spec/support/client_registry_macros.rb +4 -4
- 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 -12
- data/spec/support/spec_setup.rb +38 -48
- data/spec/support/utils.rb +19 -1
- data.tar.gz.sig +1 -3
- metadata +938 -933
- metadata.gz.sig +0 -0
- data/spec/integration/secondary_reads_spec.rb +0 -102
- data/spec/shared/LICENSE +0 -20
- data/spec/shared/bin/get-mongodb-download-url +0 -17
- data/spec/shared/lib/mrss/child_process_helper.rb +0 -80
- data/spec/shared/lib/mrss/cluster_config.rb +0 -221
- data/spec/shared/lib/mrss/constraints.rb +0 -346
- data/spec/shared/lib/mrss/docker_runner.rb +0 -265
- data/spec/shared/lib/mrss/lite_constraints.rb +0 -191
- data/spec/shared/lib/mrss/server_version_registry.rb +0 -115
- data/spec/shared/lib/mrss/spec_organizer.rb +0 -152
- data/spec/shared/lib/mrss/utils.rb +0 -15
- data/spec/shared/share/Dockerfile.erb +0 -231
- data/spec/shared/shlib/distro.sh +0 -73
- data/spec/shared/shlib/server.sh +0 -290
- data/spec/shared/shlib/set_env.sh +0 -128
@@ -0,0 +1,52 @@
|
|
1
|
+
require 'singleton'
|
2
|
+
|
3
|
+
module Mongo
|
4
|
+
class Client
|
5
|
+
alias :get_session_without_tracking :get_session
|
6
|
+
|
7
|
+
def get_session(options = {})
|
8
|
+
get_session_without_tracking(options).tap do |session|
|
9
|
+
SessionRegistry.instance.register(session)
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
class Session
|
15
|
+
alias :end_session_without_tracking :end_session
|
16
|
+
|
17
|
+
def end_session
|
18
|
+
SessionRegistry.instance.unregister(self)
|
19
|
+
end_session_without_tracking
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
|
25
|
+
class SessionRegistry
|
26
|
+
include Singleton
|
27
|
+
|
28
|
+
def initialize
|
29
|
+
@registry = {}
|
30
|
+
end
|
31
|
+
|
32
|
+
def register(session)
|
33
|
+
@registry[session.session_id] = session if session
|
34
|
+
end
|
35
|
+
|
36
|
+
def unregister(session)
|
37
|
+
@registry.delete(session.session_id) unless session.ended?
|
38
|
+
end
|
39
|
+
|
40
|
+
def verify_sessions_ended!
|
41
|
+
@registry.delete_if { |_, session| session.ended? }
|
42
|
+
|
43
|
+
unless @registry.empty?
|
44
|
+
sessions = @registry.map { |_, session| session }
|
45
|
+
raise "Session registry contains live sessions: #{sessions.join(', ')}"
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
def clear_registry
|
50
|
+
@registry = {}
|
51
|
+
end
|
52
|
+
end
|
data/spec/support/spec_config.rb
CHANGED
@@ -110,14 +110,6 @@ class SpecConfig
|
|
110
110
|
!!(RUBY_PLATFORM =~ /\bjava\b/)
|
111
111
|
end
|
112
112
|
|
113
|
-
def linux?
|
114
|
-
!!(RbConfig::CONFIG['host_os'].downcase =~ /\blinux/)
|
115
|
-
end
|
116
|
-
|
117
|
-
def macos?
|
118
|
-
!!(RbConfig::CONFIG['host_os'].downcase =~ /\bdarwin/)
|
119
|
-
end
|
120
|
-
|
121
113
|
def platform
|
122
114
|
RUBY_PLATFORM
|
123
115
|
end
|
@@ -130,6 +122,24 @@ class SpecConfig
|
|
130
122
|
%w(1 true yes).include?(ENV['FORK']&.downcase)
|
131
123
|
end
|
132
124
|
|
125
|
+
# OCSP tests require python and various dependencies.
|
126
|
+
# Assumes an OCSP responder is running on port 8100 (configured externally
|
127
|
+
# to the test suite).
|
128
|
+
def ocsp?
|
129
|
+
%w(1 true yes).include?(ENV['OCSP']&.downcase)
|
130
|
+
end
|
131
|
+
|
132
|
+
# OCSP tests require python and various dependencies.
|
133
|
+
# When testing OCSP verifier, there cannot be a responder running on
|
134
|
+
# port 8100 or the tests will fail.
|
135
|
+
def ocsp_verifier?
|
136
|
+
%w(1 true yes).include?(ENV['OCSP_VERIFIER']&.downcase)
|
137
|
+
end
|
138
|
+
|
139
|
+
def ocsp_connectivity?
|
140
|
+
ENV.key?('OCSP_CONNECTIVITY') && ENV['OCSP_CONNECTIVITY'] != ''
|
141
|
+
end
|
142
|
+
|
133
143
|
# Test suite configuration
|
134
144
|
|
135
145
|
def client_debug?
|
@@ -229,6 +239,10 @@ EOT
|
|
229
239
|
Pathname.new("#{spec_root}/support/certificates")
|
230
240
|
end
|
231
241
|
|
242
|
+
def ocsp_files_dir
|
243
|
+
Pathname.new("#{spec_root}/../.mod/drivers-evergreen-tools/.evergreen/ocsp")
|
244
|
+
end
|
245
|
+
|
232
246
|
# TLS certificates & keys
|
233
247
|
|
234
248
|
def local_client_key_path
|
@@ -350,10 +364,6 @@ EOT
|
|
350
364
|
end
|
351
365
|
end
|
352
366
|
|
353
|
-
def auth?
|
354
|
-
x509_auth? || user
|
355
|
-
end
|
356
|
-
|
357
367
|
# Option hashes
|
358
368
|
|
359
369
|
def auth_options
|
data/spec/support/spec_setup.rb
CHANGED
@@ -8,50 +8,38 @@ class SpecSetup
|
|
8
8
|
return
|
9
9
|
end
|
10
10
|
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
#
|
18
|
-
#
|
19
|
-
#
|
20
|
-
#
|
21
|
-
#
|
22
|
-
|
23
|
-
|
24
|
-
#
|
25
|
-
#
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
# for trying to make a user when not authenticated,
|
33
|
-
# and prior to 4.0 or so the codes are supposedly not reliable either.
|
34
|
-
# In order: 4.0, 3.6, 3.4 through 2.6
|
35
|
-
if e.message =~ /command createUser requires authentication|there are no users authenticated|not authorized on admin to execute command.*createUser/
|
36
|
-
# However, if the cluster is configured to require auth but
|
37
|
-
# test suite has wrong credentials, then admin_authorized_test_client
|
38
|
-
# won't be authenticated and the following line will raise an
|
39
|
-
# exception
|
40
|
-
if client.use('admin').database.users.info(SpecConfig.instance.root_user.name).any?
|
41
|
-
warn "Skipping root user creation, likely auth is enabled on cluster"
|
42
|
-
else
|
43
|
-
raise
|
44
|
-
end
|
45
|
-
else
|
46
|
-
raise
|
47
|
-
end
|
11
|
+
# Create the root user administrator as the first user to be added to the
|
12
|
+
# database. This user will need to be authenticated in order to add any
|
13
|
+
# more users to any other databases.
|
14
|
+
begin
|
15
|
+
create_user(admin_unauthorized_client, SpecConfig.instance.root_user)
|
16
|
+
rescue Mongo::Error::OperationFailure => e
|
17
|
+
# When testing a cluster that requires auth, root user is already set up
|
18
|
+
# and it is not creatable without auth.
|
19
|
+
# Seems like every mongodb version has its own error message
|
20
|
+
# for trying to make a user when not authenticated,
|
21
|
+
# and prior to 4.0 or so the codes are supposedly not reliable either.
|
22
|
+
# In order: 4.0, 3.6, 3.4 through 2.6
|
23
|
+
if e.message =~ /command createUser requires authentication|there are no users authenticated|not authorized on admin to execute command.*createUser/
|
24
|
+
# However, if the cluster is configured to require auth but
|
25
|
+
# test suite has wrong credentials, then admin_authorized_test_client
|
26
|
+
# won't be authenticated and the following line will raise an
|
27
|
+
# exception
|
28
|
+
if admin_authorized_test_client.with(database: 'admin').database.users.info(SpecConfig.instance.root_user.name).any?
|
29
|
+
warn "Skipping root user creation, likely auth is enabled on cluster"
|
30
|
+
else
|
31
|
+
raise
|
48
32
|
end
|
33
|
+
else
|
34
|
+
raise
|
49
35
|
end
|
50
|
-
|
51
|
-
# Adds the test user to the test database with permissions on all
|
52
|
-
# databases that will be used in the test suite.
|
53
|
-
create_user(client, SpecConfig.instance.test_user)
|
54
36
|
end
|
37
|
+
admin_unauthorized_client.close
|
38
|
+
|
39
|
+
# Adds the test user to the test database with permissions on all
|
40
|
+
# databases that will be used in the test suite.
|
41
|
+
create_user(admin_authorized_test_client, SpecConfig.instance.test_user)
|
42
|
+
admin_authorized_test_client.close
|
55
43
|
end
|
56
44
|
|
57
45
|
def create_user(client, user)
|
@@ -68,13 +56,15 @@ class SpecSetup
|
|
68
56
|
end
|
69
57
|
end
|
70
58
|
|
71
|
-
def
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
59
|
+
def admin_unauthorized_client
|
60
|
+
ClientRegistry.instance.global_client('admin_unauthorized').with(
|
61
|
+
socket_timeout: 5, connect_timeout: 5,
|
62
|
+
)
|
63
|
+
end
|
64
|
+
|
65
|
+
def admin_authorized_test_client
|
66
|
+
ClientRegistry.instance.global_client('root_authorized').with(
|
67
|
+
socket_timeout: 5, connect_timeout: 5,
|
78
68
|
)
|
79
69
|
end
|
80
70
|
end
|
data/spec/support/utils.rb
CHANGED
@@ -85,6 +85,13 @@ module Utils
|
|
85
85
|
end
|
86
86
|
module_function :camelize
|
87
87
|
|
88
|
+
module_function def downcase_keys(hash)
|
89
|
+
# TODO replace with Hash#transform_keys when we require Ruby 2.5+
|
90
|
+
Hash[hash.map do |k, v|
|
91
|
+
[k.downcase, v]
|
92
|
+
end]
|
93
|
+
end
|
94
|
+
|
88
95
|
module_function def disable_retries_client_options
|
89
96
|
{
|
90
97
|
retry_reads: false,
|
@@ -98,6 +105,7 @@ module Utils
|
|
98
105
|
# to Ruby driver underscore options.
|
99
106
|
def convert_client_options(spec_test_options)
|
100
107
|
uri = Mongo::URI.new('mongodb://localhost')
|
108
|
+
mapper = Mongo::URI::OptionsMapper.new
|
101
109
|
spec_test_options.reduce({}) do |opts, (name, value)|
|
102
110
|
if name == 'autoEncryptOpts'
|
103
111
|
opts.merge!(
|
@@ -111,7 +119,7 @@ module Utils
|
|
111
119
|
)
|
112
120
|
)
|
113
121
|
else
|
114
|
-
|
122
|
+
mapper.add_uri_option(name, value.to_s, opts)
|
115
123
|
end
|
116
124
|
|
117
125
|
opts
|
@@ -494,4 +502,14 @@ module Utils
|
|
494
502
|
|
495
503
|
subscriber.single_command_started_event(command_name, include_auth: include_auth)
|
496
504
|
end
|
505
|
+
|
506
|
+
# Drops and creates a collection for the purpose of starting the test from
|
507
|
+
# a clean slate.
|
508
|
+
#
|
509
|
+
# @param [ Mongo::Client ] client
|
510
|
+
# @param [ String ] collection_name
|
511
|
+
module_function def create_collection(client, collection_name)
|
512
|
+
client[collection_name].drop
|
513
|
+
client[collection_name].create
|
514
|
+
end
|
497
515
|
end
|
data.tar.gz.sig
CHANGED