mongo 2.10.5 → 2.15.1
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/CONTRIBUTING.md +8 -36
- data/LICENSE +1 -1
- data/README.md +57 -53
- data/Rakefile +76 -16
- data/lib/mongo/active_support.rb +4 -1
- data/lib/mongo/address/ipv4.rb +35 -5
- data/lib/mongo/address/ipv6.rb +35 -5
- data/lib/mongo/address/unix.rb +6 -3
- data/lib/mongo/address/validator.rb +102 -0
- data/lib/mongo/address.rb +121 -46
- data/lib/mongo/auth/aws/conversation.rb +128 -0
- data/lib/mongo/auth/aws/credentials_retriever.rb +222 -0
- data/lib/mongo/auth/aws/request.rb +286 -0
- data/lib/mongo/auth/aws.rb +40 -0
- data/lib/mongo/auth/base.rb +138 -0
- data/lib/mongo/auth/conversation_base.rb +87 -0
- data/lib/mongo/auth/cr/conversation.rb +24 -89
- data/lib/mongo/auth/cr.rb +13 -36
- data/lib/mongo/auth/credential_cache.rb +54 -0
- data/lib/mongo/auth/gssapi/conversation.rb +100 -0
- data/lib/mongo/auth/gssapi.rb +41 -0
- data/lib/mongo/auth/ldap/conversation.rb +12 -63
- data/lib/mongo/auth/ldap.rb +13 -34
- data/lib/mongo/auth/roles.rb +4 -1
- data/lib/mongo/auth/sasl_conversation_base.rb +102 -0
- data/lib/mongo/auth/scram/conversation.rb +16 -491
- data/lib/mongo/auth/scram.rb +43 -51
- data/lib/mongo/auth/scram256/conversation.rb +66 -0
- data/lib/mongo/auth/scram256.rb +34 -0
- data/lib/mongo/auth/scram_conversation_base.rb +378 -0
- data/lib/mongo/auth/stringprep/profiles/sasl.rb +5 -1
- data/lib/mongo/auth/stringprep/tables.rb +5 -1
- data/lib/mongo/auth/stringprep/unicode_normalize/normalize.rb +3 -2
- data/lib/mongo/auth/stringprep/unicode_normalize/tables.rb +2 -1
- data/lib/mongo/auth/stringprep.rb +9 -5
- data/lib/mongo/auth/user/view.rb +30 -14
- data/lib/mongo/auth/user.rb +17 -8
- data/lib/mongo/auth/x509/conversation.rb +26 -62
- data/lib/mongo/auth/x509.rb +29 -33
- data/lib/mongo/auth.rb +84 -23
- data/lib/mongo/background_thread.rb +173 -0
- data/lib/mongo/bson.rb +4 -1
- data/lib/mongo/bulk_write/combineable.rb +23 -8
- data/lib/mongo/bulk_write/ordered_combiner.rb +4 -1
- data/lib/mongo/bulk_write/result.rb +4 -1
- data/lib/mongo/bulk_write/result_combiner.rb +4 -1
- data/lib/mongo/bulk_write/transformable.rb +12 -10
- data/lib/mongo/bulk_write/unordered_combiner.rb +4 -1
- data/lib/mongo/bulk_write/validatable.rb +8 -1
- data/lib/mongo/bulk_write.rb +85 -26
- data/lib/mongo/caching_cursor.rb +77 -0
- data/lib/mongo/client.rb +584 -66
- data/lib/mongo/client_encryption.rb +106 -0
- data/lib/mongo/cluster/periodic_executor.rb +35 -44
- data/lib/mongo/cluster/reapers/cursor_reaper.rb +26 -7
- data/lib/mongo/cluster/reapers/socket_reaper.rb +4 -1
- data/lib/mongo/cluster/sdam_flow.rb +165 -26
- data/lib/mongo/cluster/topology/base.rb +4 -1
- data/lib/mongo/cluster/topology/no_replica_set_options.rb +4 -1
- data/lib/mongo/cluster/topology/replica_set_no_primary.rb +7 -3
- data/lib/mongo/cluster/topology/replica_set_with_primary.rb +4 -1
- data/lib/mongo/cluster/topology/sharded.rb +5 -2
- data/lib/mongo/cluster/topology/single.rb +6 -3
- data/lib/mongo/cluster/topology/unknown.rb +4 -1
- data/lib/mongo/cluster/topology.rb +22 -2
- data/lib/mongo/cluster.rb +426 -150
- data/lib/mongo/cluster_time.rb +4 -1
- data/lib/mongo/collection/view/aggregation.rb +35 -8
- data/lib/mongo/collection/view/builder/aggregation.rb +4 -1
- data/lib/mongo/collection/view/builder/find_command.rb +50 -19
- data/lib/mongo/collection/view/builder/flags.rb +4 -1
- data/lib/mongo/collection/view/builder/map_reduce.rb +4 -1
- data/lib/mongo/collection/view/builder/modifiers.rb +4 -1
- data/lib/mongo/collection/view/builder/op_query.rb +4 -1
- data/lib/mongo/collection/view/builder.rb +4 -1
- data/lib/mongo/collection/view/change_stream/retryable.rb +4 -1
- data/lib/mongo/collection/view/change_stream.rb +23 -10
- data/lib/mongo/collection/view/explainable.rb +31 -9
- data/lib/mongo/collection/view/immutable.rb +4 -1
- data/lib/mongo/collection/view/iterable.rb +106 -18
- data/lib/mongo/collection/view/map_reduce.rb +12 -6
- data/lib/mongo/collection/view/readable.rb +81 -25
- data/lib/mongo/collection/view/writable.rb +127 -28
- data/lib/mongo/collection/view.rb +33 -22
- data/lib/mongo/collection.rb +129 -41
- data/lib/mongo/crypt/auto_decryption_context.rb +43 -0
- data/lib/mongo/crypt/auto_encrypter.rb +182 -0
- data/lib/mongo/crypt/auto_encryption_context.rb +47 -0
- data/lib/mongo/crypt/binary.rb +158 -0
- data/lib/mongo/crypt/binding.rb +1232 -0
- data/lib/mongo/crypt/context.rb +138 -0
- data/lib/mongo/crypt/data_key_context.rb +165 -0
- data/lib/mongo/crypt/encryption_io.rb +309 -0
- data/lib/mongo/crypt/explicit_decryption_context.rb +43 -0
- data/lib/mongo/crypt/explicit_encrypter.rb +120 -0
- data/lib/mongo/crypt/explicit_encryption_context.rb +92 -0
- data/lib/mongo/crypt/handle.rb +318 -0
- data/lib/mongo/crypt/hooks.rb +93 -0
- data/lib/mongo/crypt/kms_context.rb +70 -0
- data/lib/mongo/crypt/status.rb +134 -0
- data/lib/mongo/crypt.rb +36 -0
- data/lib/mongo/cursor/builder/get_more_command.rb +4 -1
- data/lib/mongo/cursor/builder/kill_cursors_command.rb +4 -1
- data/lib/mongo/cursor/builder/op_get_more.rb +4 -1
- data/lib/mongo/cursor/builder/op_kill_cursors.rb +4 -1
- data/lib/mongo/cursor/builder.rb +4 -1
- data/lib/mongo/cursor.rb +97 -38
- data/lib/mongo/database/view.rb +34 -7
- data/lib/mongo/database.rb +87 -14
- data/lib/mongo/dbref.rb +13 -3
- data/lib/mongo/distinguishing_semaphore.rb +58 -0
- data/lib/mongo/error/auth_error.rb +5 -2
- data/lib/mongo/error/bulk_write_error.rb +34 -15
- data/lib/mongo/error/change_stream_resumable.rb +4 -1
- data/lib/mongo/error/closed_stream.rb +4 -1
- data/lib/mongo/error/connection_check_out_timeout.rb +11 -9
- data/lib/mongo/error/connection_perished.rb +26 -0
- data/lib/mongo/error/credential_check_error.rb +29 -0
- data/lib/mongo/error/crypt_error.rb +34 -0
- data/lib/mongo/error/extra_file_chunk.rb +4 -1
- data/lib/mongo/error/{failed_stringprep_validation.rb → failed_string_prep_validation.rb} +3 -0
- data/lib/mongo/error/file_not_found.rb +4 -1
- data/lib/mongo/error/handshake_error.rb +4 -1
- data/lib/mongo/error/insufficient_iteration_count.rb +4 -1
- data/lib/mongo/error/internal_driver_error.rb +25 -0
- data/lib/mongo/error/invalid_address.rb +27 -0
- data/lib/mongo/error/invalid_application_name.rb +4 -1
- data/lib/mongo/error/invalid_bulk_operation.rb +4 -1
- data/lib/mongo/error/invalid_bulk_operation_type.rb +4 -1
- data/lib/mongo/error/invalid_collection_name.rb +4 -1
- data/lib/mongo/error/invalid_cursor_operation.rb +30 -0
- data/lib/mongo/error/invalid_database_name.rb +4 -1
- data/lib/mongo/error/invalid_document.rb +4 -1
- data/lib/mongo/error/invalid_file.rb +4 -1
- data/lib/mongo/error/invalid_file_revision.rb +4 -1
- data/lib/mongo/error/invalid_min_pool_size.rb +4 -1
- data/lib/mongo/error/invalid_nonce.rb +5 -2
- data/lib/mongo/error/invalid_read_concern.rb +31 -0
- data/lib/mongo/error/invalid_read_option.rb +4 -1
- data/lib/mongo/error/invalid_replacement_document.rb +4 -1
- data/lib/mongo/error/invalid_server_auth_host.rb +25 -0
- data/lib/mongo/error/invalid_server_auth_response.rb +26 -0
- data/lib/mongo/error/invalid_server_preference.rb +9 -1
- data/lib/mongo/error/invalid_session.rb +6 -2
- data/lib/mongo/error/invalid_signature.rb +4 -1
- data/lib/mongo/error/invalid_transaction_operation.rb +4 -1
- data/lib/mongo/error/invalid_txt_record.rb +4 -1
- data/lib/mongo/error/invalid_update_document.rb +4 -1
- data/lib/mongo/error/invalid_uri.rb +4 -1
- data/lib/mongo/error/invalid_write_concern.rb +4 -1
- data/{spec/support/crud/context.rb → lib/mongo/error/kms_error.rb} +8 -6
- data/lib/mongo/error/lint_error.rb +4 -1
- data/lib/mongo/error/max_bson_size.rb +18 -4
- data/lib/mongo/error/max_message_size.rb +4 -1
- data/lib/mongo/error/mismatched_domain.rb +4 -1
- data/lib/mongo/error/missing_file_chunk.rb +4 -1
- data/lib/mongo/error/missing_password.rb +4 -1
- data/lib/mongo/error/missing_resume_token.rb +4 -1
- data/lib/mongo/error/missing_scram_server_signature.rb +30 -0
- data/lib/mongo/error/mongocryptd_spawn_error.rb +25 -0
- data/lib/mongo/error/multi_index_drop.rb +4 -1
- data/lib/mongo/error/need_primary_server.rb +4 -1
- data/lib/mongo/error/no_server_available.rb +12 -4
- data/lib/mongo/error/no_srv_records.rb +4 -1
- data/lib/mongo/error/notable.rb +22 -19
- data/lib/mongo/error/operation_failure.rb +92 -50
- data/lib/mongo/error/parser.rb +85 -18
- data/lib/mongo/error/pool_closed_error.rb +15 -5
- data/lib/mongo/error/raise_original_error.rb +32 -0
- data/lib/mongo/error/sdam_error_detection.rb +16 -5
- data/lib/mongo/error/server_api_conflict.rb +26 -0
- data/lib/mongo/error/server_api_not_supported.rb +27 -0
- data/lib/mongo/error/server_certificate_revoked.rb +25 -0
- data/lib/mongo/error/session_ended.rb +4 -1
- data/lib/mongo/error/sessions_not_supported.rb +38 -0
- data/lib/mongo/error/socket_error.rb +4 -1
- data/lib/mongo/error/socket_timeout_error.rb +4 -1
- data/lib/mongo/error/unchangeable_collection_option.rb +4 -1
- data/lib/mongo/error/unexpected_chunk_length.rb +4 -1
- data/lib/mongo/error/unexpected_response.rb +4 -1
- data/lib/mongo/error/unknown_payload_type.rb +4 -1
- data/lib/mongo/error/unmet_dependency.rb +24 -0
- data/lib/mongo/error/unsupported_array_filters.rb +10 -2
- data/lib/mongo/error/unsupported_collation.rb +10 -2
- data/lib/mongo/error/unsupported_features.rb +4 -1
- data/lib/mongo/error/unsupported_message_type.rb +4 -1
- data/lib/mongo/error/unsupported_option.rb +104 -0
- data/lib/mongo/error/write_retryable.rb +4 -1
- data/lib/mongo/error.rb +48 -4
- data/lib/mongo/event/base.rb +10 -1
- data/lib/mongo/event/listeners.rb +4 -1
- data/lib/mongo/event/publisher.rb +4 -1
- data/lib/mongo/event/subscriber.rb +4 -1
- data/lib/mongo/event.rb +5 -2
- data/lib/mongo/grid/file/chunk.rb +5 -2
- data/lib/mongo/grid/file/info.rb +7 -3
- data/lib/mongo/grid/file.rb +4 -1
- data/lib/mongo/grid/fs_bucket.rb +74 -48
- data/lib/mongo/grid/stream/read.rb +23 -8
- data/lib/mongo/grid/stream/write.rb +4 -1
- data/lib/mongo/grid/stream.rb +4 -1
- data/lib/mongo/grid.rb +4 -1
- data/lib/mongo/id.rb +4 -1
- data/lib/mongo/index/view.rb +78 -15
- data/lib/mongo/index.rb +5 -1
- data/lib/mongo/lint.rb +14 -0
- data/lib/mongo/loggable.rb +9 -2
- data/lib/mongo/logger.rb +7 -4
- data/lib/mongo/monitoring/cmap_log_subscriber.rb +4 -1
- data/lib/mongo/monitoring/command_log_subscriber.rb +24 -4
- data/lib/mongo/monitoring/event/cmap/base.rb +4 -1
- data/lib/mongo/monitoring/event/cmap/connection_check_out_failed.rb +12 -2
- data/lib/mongo/monitoring/event/cmap/connection_check_out_started.rb +4 -1
- data/lib/mongo/monitoring/event/cmap/connection_checked_in.rb +15 -4
- data/lib/mongo/monitoring/event/cmap/connection_checked_out.rb +15 -4
- data/lib/mongo/monitoring/event/cmap/connection_closed.rb +4 -1
- data/lib/mongo/monitoring/event/cmap/connection_created.rb +4 -1
- data/lib/mongo/monitoring/event/cmap/connection_ready.rb +4 -1
- data/lib/mongo/monitoring/event/cmap/pool_cleared.rb +4 -1
- data/lib/mongo/monitoring/event/cmap/pool_closed.rb +15 -4
- data/lib/mongo/monitoring/event/cmap/pool_created.rb +16 -4
- data/lib/mongo/monitoring/event/cmap.rb +4 -1
- data/lib/mongo/monitoring/event/command_failed.rb +44 -6
- data/lib/mongo/monitoring/event/command_started.rb +79 -5
- data/lib/mongo/monitoring/event/command_succeeded.rb +41 -4
- data/lib/mongo/monitoring/event/secure.rb +44 -4
- data/lib/mongo/monitoring/event/server_closed.rb +5 -2
- data/lib/mongo/monitoring/event/server_description_changed.rb +31 -5
- data/lib/mongo/monitoring/event/server_heartbeat_failed.rb +39 -18
- data/lib/mongo/monitoring/event/server_heartbeat_started.rb +13 -3
- data/lib/mongo/monitoring/event/server_heartbeat_succeeded.rb +34 -13
- data/lib/mongo/monitoring/event/server_opening.rb +5 -2
- data/lib/mongo/monitoring/event/topology_changed.rb +5 -2
- data/lib/mongo/monitoring/event/topology_closed.rb +5 -2
- data/lib/mongo/monitoring/event/topology_opening.rb +5 -2
- data/lib/mongo/monitoring/event.rb +4 -1
- data/lib/mongo/monitoring/publishable.rb +41 -17
- data/lib/mongo/monitoring/sdam_log_subscriber.rb +4 -1
- data/lib/mongo/monitoring/server_closed_log_subscriber.rb +4 -1
- data/lib/mongo/monitoring/server_description_changed_log_subscriber.rb +13 -2
- data/lib/mongo/monitoring/server_opening_log_subscriber.rb +4 -1
- data/lib/mongo/monitoring/topology_changed_log_subscriber.rb +5 -2
- data/lib/mongo/monitoring/topology_closed_log_subscriber.rb +4 -1
- data/lib/mongo/monitoring/topology_opening_log_subscriber.rb +4 -1
- data/lib/mongo/monitoring/unified_sdam_log_subscriber.rb +65 -0
- data/lib/mongo/monitoring.rb +52 -1
- data/lib/mongo/operation/aggregate/command.rb +8 -5
- data/lib/mongo/operation/aggregate/op_msg.rb +4 -1
- data/lib/mongo/operation/aggregate/result.rb +13 -9
- data/lib/mongo/operation/aggregate.rb +4 -1
- data/lib/mongo/operation/collections_info/command.rb +48 -0
- data/lib/mongo/operation/collections_info/result.rb +22 -2
- data/lib/mongo/operation/collections_info.rb +18 -28
- data/lib/mongo/operation/command/command.rb +6 -3
- data/lib/mongo/operation/command/op_msg.rb +4 -1
- data/lib/mongo/operation/command.rb +4 -1
- data/lib/mongo/operation/context.rb +102 -0
- data/lib/mongo/operation/count/command.rb +6 -3
- data/lib/mongo/operation/count/op_msg.rb +4 -1
- data/lib/mongo/operation/count.rb +4 -1
- data/lib/mongo/operation/create/command.rb +6 -3
- data/lib/mongo/operation/create/op_msg.rb +4 -1
- data/lib/mongo/operation/create.rb +4 -1
- data/lib/mongo/operation/create_index/command.rb +7 -4
- data/lib/mongo/operation/create_index/op_msg.rb +9 -3
- data/lib/mongo/operation/create_index.rb +4 -1
- data/lib/mongo/operation/create_user/command.rb +8 -4
- data/lib/mongo/operation/create_user/op_msg.rb +5 -2
- data/lib/mongo/operation/create_user.rb +4 -1
- data/lib/mongo/operation/delete/bulk_result.rb +6 -1
- data/lib/mongo/operation/delete/command.rb +7 -4
- data/lib/mongo/operation/delete/legacy.rb +5 -2
- data/lib/mongo/operation/delete/op_msg.rb +8 -5
- data/lib/mongo/operation/delete/result.rb +8 -2
- data/lib/mongo/operation/delete.rb +4 -1
- data/lib/mongo/operation/distinct/command.rb +6 -3
- data/lib/mongo/operation/distinct/op_msg.rb +4 -1
- data/lib/mongo/operation/distinct.rb +4 -1
- data/lib/mongo/operation/drop/command.rb +6 -3
- data/lib/mongo/operation/drop/op_msg.rb +4 -1
- data/lib/mongo/operation/drop.rb +4 -1
- data/lib/mongo/operation/drop_database/command.rb +6 -3
- data/lib/mongo/operation/drop_database/op_msg.rb +4 -1
- data/lib/mongo/operation/drop_database.rb +4 -1
- data/lib/mongo/operation/drop_index/command.rb +7 -4
- data/lib/mongo/operation/drop_index/op_msg.rb +5 -2
- data/lib/mongo/operation/drop_index.rb +4 -1
- data/lib/mongo/operation/explain/command.rb +10 -3
- data/lib/mongo/operation/explain/legacy.rb +10 -3
- data/lib/mongo/operation/explain/op_msg.rb +10 -1
- data/lib/mongo/operation/explain/result.rb +7 -1
- data/lib/mongo/operation/explain.rb +4 -1
- data/lib/mongo/operation/find/command.rb +6 -3
- data/lib/mongo/operation/find/legacy/result.rb +6 -1
- data/lib/mongo/operation/find/legacy.rb +6 -3
- data/lib/mongo/operation/find/op_msg.rb +5 -9
- data/lib/mongo/operation/find/result.rb +17 -1
- data/lib/mongo/operation/find.rb +4 -1
- data/lib/mongo/operation/get_more/command.rb +6 -3
- data/lib/mongo/operation/get_more/legacy.rb +5 -2
- data/lib/mongo/operation/get_more/op_msg.rb +5 -9
- data/lib/mongo/operation/get_more/result.rb +7 -1
- data/lib/mongo/operation/get_more.rb +4 -1
- data/lib/mongo/operation/indexes/command.rb +6 -3
- data/lib/mongo/operation/indexes/legacy.rb +7 -4
- data/lib/mongo/operation/indexes/op_msg.rb +4 -1
- data/lib/mongo/operation/indexes/result.rb +9 -1
- data/lib/mongo/operation/indexes.rb +19 -2
- data/lib/mongo/operation/insert/bulk_result.rb +14 -2
- data/lib/mongo/operation/insert/command.rb +11 -7
- data/lib/mongo/operation/insert/legacy.rb +13 -5
- data/lib/mongo/operation/insert/op_msg.rb +10 -7
- data/lib/mongo/operation/insert/result.rb +15 -4
- data/lib/mongo/operation/insert.rb +6 -2
- data/lib/mongo/operation/kill_cursors/command.rb +6 -3
- data/lib/mongo/operation/kill_cursors/legacy.rb +5 -2
- data/lib/mongo/operation/kill_cursors/op_msg.rb +4 -1
- data/lib/mongo/operation/kill_cursors.rb +4 -1
- data/lib/mongo/operation/list_collections/command.rb +7 -4
- data/lib/mongo/operation/list_collections/op_msg.rb +5 -2
- data/lib/mongo/operation/list_collections/result.rb +13 -2
- data/lib/mongo/operation/list_collections.rb +4 -1
- data/lib/mongo/operation/map_reduce/command.rb +6 -3
- data/lib/mongo/operation/map_reduce/op_msg.rb +4 -1
- data/lib/mongo/operation/map_reduce/result.rb +14 -1
- data/lib/mongo/operation/map_reduce.rb +4 -1
- data/lib/mongo/operation/op_msg_base.rb +6 -3
- data/lib/mongo/operation/parallel_scan/command.rb +8 -6
- data/lib/mongo/operation/parallel_scan/op_msg.rb +5 -2
- data/lib/mongo/operation/parallel_scan/result.rb +8 -1
- data/lib/mongo/operation/parallel_scan.rb +4 -1
- data/lib/mongo/operation/remove_user/command.rb +8 -4
- data/lib/mongo/operation/remove_user/op_msg.rb +5 -2
- data/lib/mongo/operation/remove_user.rb +4 -1
- data/lib/mongo/operation/result.rb +104 -37
- data/lib/mongo/operation/shared/bypass_document_validation.rb +14 -4
- data/lib/mongo/operation/shared/causal_consistency_supported.rb +7 -3
- data/lib/mongo/operation/shared/executable.rb +60 -34
- data/lib/mongo/operation/shared/executable_no_validate.rb +6 -3
- data/lib/mongo/operation/shared/executable_transaction_label.rb +4 -1
- data/lib/mongo/operation/shared/idable.rb +6 -2
- data/lib/mongo/operation/shared/limited.rb +14 -2
- data/lib/mongo/operation/shared/object_id_generator.rb +5 -1
- data/lib/mongo/operation/shared/op_msg_or_command.rb +7 -8
- data/lib/mongo/operation/shared/op_msg_or_find_command.rb +8 -9
- data/lib/mongo/operation/shared/polymorphic_lookup.rb +4 -1
- data/lib/mongo/operation/shared/polymorphic_operation.rb +42 -0
- data/lib/mongo/operation/shared/polymorphic_result.rb +4 -1
- data/lib/mongo/operation/shared/read_preference_supported.rb +80 -23
- data/lib/mongo/operation/shared/response_handling.rb +91 -13
- data/lib/mongo/operation/shared/result/aggregatable.rb +5 -1
- data/lib/mongo/operation/shared/result/use_legacy_error_parser.rb +4 -1
- data/lib/mongo/operation/shared/sessions_supported.rb +104 -28
- data/lib/mongo/operation/shared/specifiable.rb +36 -20
- data/lib/mongo/operation/shared/write.rb +31 -24
- data/lib/mongo/operation/shared/write_concern_supported.rb +10 -6
- data/lib/mongo/operation/update/bulk_result.rb +4 -1
- data/lib/mongo/operation/update/command.rb +7 -4
- data/lib/mongo/operation/update/legacy/result.rb +11 -1
- data/lib/mongo/operation/update/legacy.rb +5 -2
- data/lib/mongo/operation/update/op_msg.rb +8 -5
- data/lib/mongo/operation/update/result.rb +13 -2
- data/lib/mongo/operation/update.rb +4 -1
- data/lib/mongo/operation/update_user/command.rb +8 -4
- data/lib/mongo/operation/update_user/op_msg.rb +5 -2
- data/lib/mongo/operation/update_user.rb +4 -1
- data/lib/mongo/operation/users_info/command.rb +7 -4
- data/lib/mongo/operation/users_info/op_msg.rb +5 -2
- data/lib/mongo/operation/users_info/result.rb +7 -1
- data/lib/mongo/operation/users_info.rb +4 -1
- data/lib/mongo/operation.rb +7 -1
- data/lib/mongo/options/mapper.rb +4 -1
- data/lib/mongo/options/redacted.rb +4 -1
- data/lib/mongo/options.rb +4 -1
- data/lib/mongo/protocol/bit_vector.rb +6 -2
- data/lib/mongo/protocol/compressed.rb +61 -11
- data/lib/mongo/protocol/delete.rb +4 -1
- data/lib/mongo/protocol/get_more.rb +4 -1
- data/lib/mongo/protocol/insert.rb +7 -2
- data/lib/mongo/protocol/kill_cursors.rb +4 -1
- data/lib/mongo/protocol/message.rb +158 -21
- data/lib/mongo/protocol/msg.rb +248 -41
- data/lib/mongo/protocol/query.rb +62 -24
- data/lib/mongo/protocol/registry.rb +4 -1
- data/lib/mongo/protocol/reply.rb +4 -1
- data/lib/mongo/protocol/serializers.rb +47 -16
- data/lib/mongo/protocol/update.rb +4 -1
- data/lib/mongo/protocol.rb +3 -0
- data/lib/mongo/query_cache.rb +275 -0
- data/lib/mongo/retryable.rb +36 -13
- data/lib/mongo/semaphore.rb +5 -2
- data/lib/mongo/server/app_metadata.rb +128 -35
- data/lib/mongo/server/connection.rb +52 -111
- data/lib/mongo/server/connection_base.rb +167 -35
- data/lib/mongo/server/connection_common.rb +168 -0
- data/lib/mongo/server/connection_pool/populator.rb +61 -0
- data/lib/mongo/server/connection_pool.rb +315 -42
- data/lib/mongo/server/context.rb +4 -1
- data/lib/mongo/server/description/features.rb +23 -10
- data/lib/mongo/server/description.rb +135 -46
- data/lib/mongo/server/monitor/app_metadata.rb +5 -2
- data/lib/mongo/server/monitor/connection.rb +142 -116
- data/lib/mongo/server/monitor.rb +197 -131
- data/lib/mongo/server/pending_connection.rb +237 -1
- data/lib/mongo/server/push_monitor/connection.rb +31 -0
- data/lib/mongo/server/push_monitor.rb +194 -0
- data/lib/mongo/server/round_trip_time_averager.rb +18 -6
- data/lib/mongo/server.rb +197 -68
- data/lib/mongo/server_selector/{selectable.rb → base.rb} +183 -95
- data/lib/mongo/server_selector/nearest.rb +32 -25
- data/lib/mongo/server_selector/primary.rb +30 -32
- data/lib/mongo/server_selector/primary_preferred.rb +38 -29
- data/lib/mongo/server_selector/secondary.rb +32 -25
- data/lib/mongo/server_selector/secondary_preferred.rb +30 -38
- data/lib/mongo/server_selector.rb +5 -2
- data/lib/mongo/session/server_session.rb +4 -1
- data/lib/mongo/session/session_pool.rb +14 -4
- data/lib/mongo/session.rb +48 -37
- data/lib/mongo/socket/ocsp_cache.rb +100 -0
- data/lib/mongo/socket/ocsp_verifier.rb +376 -0
- data/lib/mongo/socket/ssl.rb +165 -55
- data/lib/mongo/socket/tcp.rb +45 -25
- data/lib/mongo/socket/unix.rb +17 -6
- data/lib/mongo/socket.rb +176 -42
- data/lib/mongo/srv/monitor.rb +113 -0
- data/lib/mongo/srv/resolver.rb +137 -0
- data/lib/mongo/srv/result.rb +128 -0
- data/lib/mongo/srv.rb +20 -0
- data/lib/mongo/timeout.rb +54 -0
- data/lib/mongo/topology_version.rb +92 -0
- data/lib/mongo/uri/options_mapper.rb +623 -0
- data/lib/mongo/uri/srv_protocol.rb +105 -46
- data/lib/mongo/uri.rb +102 -471
- data/lib/mongo/utils.rb +118 -0
- data/lib/mongo/version.rb +5 -2
- data/lib/mongo/write_concern/acknowledged.rb +4 -1
- data/lib/mongo/write_concern/base.rb +4 -1
- data/lib/mongo/write_concern/unacknowledged.rb +4 -1
- data/lib/mongo/write_concern.rb +4 -1
- data/lib/mongo.rb +47 -2
- data/mongo.gemspec +14 -8
- data/spec/NOTES.aws-auth.md +296 -0
- data/spec/README.aws-auth.md +318 -0
- data/spec/README.md +491 -24
- data/spec/USERS.md +72 -0
- data/spec/atlas/atlas_connectivity_spec.rb +3 -0
- data/spec/atlas/operations_spec.rb +3 -0
- data/spec/integration/auth_spec.rb +135 -16
- data/spec/integration/awaited_ismaster_spec.rb +31 -0
- data/spec/integration/aws_auth_request_spec.rb +77 -0
- data/spec/integration/aws_credentials_retriever_spec.rb +106 -0
- data/spec/integration/bson_symbol_spec.rb +8 -3
- data/spec/integration/bulk_insert_spec.rb +3 -0
- data/spec/integration/bulk_write_error_message_spec.rb +41 -0
- data/spec/integration/bulk_write_spec.rb +70 -0
- data/spec/integration/change_stream_examples_spec.rb +9 -6
- data/spec/integration/change_stream_spec.rb +128 -53
- data/spec/integration/check_clean_slate_spec.rb +19 -0
- data/spec/integration/client_authentication_options_spec.rb +514 -0
- data/spec/integration/client_connectivity_spec.rb +4 -1
- data/spec/integration/client_construction_aws_auth_spec.rb +194 -0
- data/spec/integration/client_construction_spec.rb +134 -3
- data/spec/integration/client_side_encryption/auto_encryption_bulk_writes_spec.rb +360 -0
- data/spec/integration/client_side_encryption/auto_encryption_command_monitoring_spec.rb +306 -0
- data/spec/integration/client_side_encryption/auto_encryption_mongocryptd_spawn_spec.rb +75 -0
- data/spec/integration/client_side_encryption/auto_encryption_old_wire_version_spec.rb +82 -0
- data/spec/integration/client_side_encryption/auto_encryption_reconnect_spec.rb +224 -0
- data/spec/integration/client_side_encryption/auto_encryption_spec.rb +604 -0
- data/spec/integration/client_side_encryption/bson_size_limit_spec.rb +190 -0
- data/spec/integration/client_side_encryption/bypass_mongocryptd_spawn_spec.rb +81 -0
- data/spec/integration/client_side_encryption/client_close_spec.rb +66 -0
- data/spec/integration/client_side_encryption/corpus_spec.rb +236 -0
- data/spec/integration/client_side_encryption/custom_endpoint_spec.rb +135 -0
- data/spec/integration/client_side_encryption/data_key_spec.rb +168 -0
- data/spec/integration/client_side_encryption/explicit_encryption_spec.rb +117 -0
- data/spec/integration/client_side_encryption/external_key_vault_spec.rb +144 -0
- data/spec/integration/client_side_encryption/views_spec.rb +47 -0
- data/spec/integration/client_spec.rb +5 -2
- data/spec/integration/client_update_spec.rb +157 -0
- data/spec/integration/collection_indexes_prose_spec.rb +58 -0
- data/spec/integration/command_monitoring_spec.rb +97 -30
- data/spec/integration/command_spec.rb +58 -19
- data/spec/integration/connect_single_rs_name_spec.rb +17 -9
- data/spec/integration/connection_pool_populator_spec.rb +305 -0
- data/spec/integration/connection_spec.rb +159 -34
- data/spec/integration/crud_spec.rb +152 -4
- data/spec/integration/cursor_reaping_spec.rb +71 -28
- data/spec/integration/docs_examples_spec.rb +13 -1
- data/spec/integration/error_detection_spec.rb +3 -0
- data/spec/integration/fork_reconnect_spec.rb +204 -0
- data/spec/integration/get_more_spec.rb +13 -3
- data/spec/integration/grid_fs_bucket_spec.rb +4 -1
- data/spec/integration/heartbeat_events_spec.rb +27 -41
- data/spec/integration/mmapv1_spec.rb +3 -0
- data/spec/integration/mongos_pinning_spec.rb +3 -0
- data/spec/integration/ocsp_connectivity_spec.rb +29 -0
- data/spec/integration/ocsp_verifier_cache_spec.rb +191 -0
- data/spec/integration/ocsp_verifier_spec.rb +355 -0
- data/spec/integration/operation_failure_code_spec.rb +4 -1
- data/spec/integration/operation_failure_message_spec.rb +90 -0
- data/spec/integration/query_cache_spec.rb +1093 -0
- data/spec/integration/query_cache_transactions_spec.rb +193 -0
- data/spec/integration/read_concern_spec.rb +4 -1
- data/spec/integration/read_preference_spec.rb +70 -11
- data/spec/integration/reconnect_spec.rb +147 -1
- data/spec/integration/retryable_errors_spec.rb +38 -17
- data/spec/integration/{retryable_writes_spec.rb → retryable_writes/retryable_writes_36_and_older_spec.rb} +58 -51
- data/spec/integration/retryable_writes/retryable_writes_40_and_newer_spec.rb +405 -0
- data/spec/integration/retryable_writes/shared/adds_diagnostics.rb +18 -0
- data/spec/integration/retryable_writes/shared/does_not_support_retries.rb +27 -0
- data/spec/integration/retryable_writes/shared/only_supports_legacy_retries.rb +28 -0
- data/spec/integration/retryable_writes/shared/performs_legacy_retries.rb +220 -0
- data/spec/integration/retryable_writes/shared/performs_modern_retries.rb +235 -0
- data/spec/integration/retryable_writes/shared/performs_no_retries.rb +113 -0
- data/spec/integration/retryable_writes/shared/supports_legacy_retries.rb +22 -0
- data/spec/integration/retryable_writes/shared/supports_modern_retries.rb +28 -0
- data/spec/integration/retryable_writes/shared/supports_retries.rb +19 -0
- data/spec/integration/retryable_writes_errors_spec.rb +14 -14
- data/spec/integration/sdam_error_handling_spec.rb +257 -43
- data/spec/integration/sdam_events_spec.rb +88 -13
- data/spec/integration/sdam_prose_spec.rb +67 -0
- data/spec/integration/secondary_reads_spec.rb +102 -0
- data/spec/integration/server_description_spec.rb +3 -0
- data/spec/integration/server_monitor_spec.rb +55 -0
- data/spec/integration/server_selection_spec.rb +39 -0
- data/spec/integration/server_selector_spec.rb +10 -5
- data/spec/integration/server_spec.rb +45 -26
- data/spec/integration/shell_examples_spec.rb +3 -0
- data/spec/integration/{size_limit_spec.rb~12e1e9c4f... RUBY-2242 Fix zlib compression (#2021) → size_limit_spec.rb} +26 -9
- data/spec/integration/snappy_compression_spec.rb +28 -0
- data/spec/integration/srv_monitoring_spec.rb +406 -0
- data/spec/integration/srv_spec.rb +59 -0
- data/spec/integration/ssl_uri_options_spec.rb +5 -2
- data/spec/integration/step_down_spec.rb +19 -18
- data/spec/integration/time_zone_querying_spec.rb +3 -0
- data/spec/integration/transactions_api_examples_spec.rb +62 -0
- data/spec/integration/transactions_examples_spec.rb +31 -9
- data/spec/integration/truncated_utf8_spec.rb +26 -0
- data/spec/integration/versioned_api_examples_spec.rb +69 -0
- data/spec/integration/x509_auth_spec.rb +112 -0
- data/spec/integration/zlib_compression_spec.rb +28 -0
- data/spec/integration/zstd_compression_spec.rb +29 -0
- data/spec/kerberos/kerberos_spec.rb +94 -0
- data/spec/lite_spec_helper.rb +85 -33
- data/spec/mongo/address/ipv4_spec.rb +4 -1
- data/spec/mongo/address/ipv6_spec.rb +3 -0
- data/spec/mongo/address/unix_spec.rb +3 -0
- data/spec/mongo/address/validator_spec.rb +54 -0
- data/spec/mongo/address_spec.rb +37 -24
- data/spec/mongo/auth/aws/request_region_spec.rb +45 -0
- data/spec/mongo/auth/aws/request_spec.rb +79 -0
- data/spec/mongo/auth/cr_spec.rb +19 -36
- data/spec/mongo/auth/gssapi/conversation_spec.rb +124 -0
- data/spec/mongo/auth/invalid_mechanism_spec.rb +4 -1
- data/spec/mongo/auth/ldap/conversation_spec.rb +6 -3
- data/spec/mongo/auth/ldap_spec.rb +17 -34
- data/spec/mongo/auth/scram/conversation_spec.rb +124 -328
- data/spec/mongo/auth/scram256/conversation_spec.rb +174 -0
- data/spec/mongo/auth/{scram/negotiation_spec.rb → scram_negotiation_spec.rb} +83 -76
- data/spec/mongo/auth/scram_spec.rb +56 -110
- data/spec/mongo/auth/stringprep/profiles/sasl_spec.rb +3 -0
- data/spec/mongo/auth/stringprep_spec.rb +3 -0
- data/spec/mongo/auth/user/view_spec.rb +108 -7
- data/spec/mongo/auth/user_spec.rb +61 -17
- data/spec/mongo/auth/x509/conversation_spec.rb +8 -5
- data/spec/mongo/auth/x509_spec.rb +42 -33
- data/spec/mongo/auth_spec.rb +7 -4
- data/spec/mongo/bson_spec.rb +3 -0
- data/spec/mongo/bulk_write/ordered_combiner_spec.rb +3 -0
- data/spec/mongo/bulk_write/result_spec.rb +14 -7
- data/spec/mongo/bulk_write/unordered_combiner_spec.rb +3 -0
- data/spec/mongo/bulk_write_spec.rb +209 -2
- data/spec/mongo/caching_cursor_spec.rb +73 -0
- data/spec/mongo/client_construction_spec.rb +1296 -305
- data/spec/mongo/client_encryption_spec.rb +414 -0
- data/spec/mongo/client_spec.rb +157 -32
- data/spec/mongo/cluster/cursor_reaper_spec.rb +15 -8
- data/spec/mongo/cluster/periodic_executor_spec.rb +19 -0
- data/spec/mongo/cluster/socket_reaper_spec.rb +17 -3
- data/spec/mongo/cluster/topology/replica_set_spec.rb +81 -30
- data/spec/mongo/cluster/topology/sharded_spec.rb +18 -12
- data/spec/mongo/cluster/topology/single_spec.rb +44 -21
- data/spec/mongo/cluster/topology/unknown_spec.rb +4 -1
- data/spec/mongo/cluster/topology_spec.rb +4 -1
- data/spec/mongo/cluster_spec.rb +114 -48
- data/spec/mongo/cluster_time_spec.rb +3 -0
- data/spec/mongo/collection/view/aggregation_spec.rb +9 -4
- data/spec/mongo/collection/view/builder/find_command_spec.rb +20 -6
- data/spec/mongo/collection/view/builder/flags_spec.rb +3 -0
- data/spec/mongo/collection/view/builder/modifiers_spec.rb +3 -0
- data/spec/mongo/collection/view/builder/op_query_spec.rb +3 -0
- data/spec/mongo/collection/view/change_stream_resume_spec.rb +397 -0
- data/spec/mongo/collection/view/change_stream_spec.rb +21 -323
- data/spec/mongo/collection/view/explainable_spec.rb +90 -4
- data/spec/mongo/collection/view/immutable_spec.rb +3 -0
- data/spec/mongo/collection/view/iterable_spec.rb +41 -0
- data/spec/mongo/collection/view/map_reduce_spec.rb +29 -15
- data/spec/mongo/collection/view/readable_spec.rb +92 -21
- data/spec/mongo/collection/view/writable_spec.rb +211 -1
- data/spec/mongo/collection/view_spec.rb +4 -1
- data/spec/mongo/collection_crud_spec.rb +4360 -0
- data/spec/mongo/collection_ddl_spec.rb +537 -0
- data/spec/mongo/collection_spec.rb +21 -4361
- data/spec/mongo/crypt/auto_decryption_context_spec.rb +93 -0
- data/spec/mongo/crypt/auto_encrypter_spec.rb +190 -0
- data/spec/mongo/crypt/auto_encryption_context_spec.rb +110 -0
- data/spec/mongo/crypt/binary_spec.rb +113 -0
- data/spec/mongo/crypt/binding/binary_spec.rb +54 -0
- data/spec/mongo/crypt/binding/context_spec.rb +255 -0
- data/spec/mongo/crypt/binding/helpers_spec.rb +44 -0
- data/spec/mongo/crypt/binding/mongocrypt_spec.rb +142 -0
- data/spec/mongo/crypt/binding/status_spec.rb +97 -0
- data/spec/mongo/crypt/binding/version_spec.rb +20 -0
- data/spec/mongo/crypt/binding_unloaded_spec.rb +23 -0
- data/spec/mongo/crypt/data_key_context_spec.rb +216 -0
- data/spec/mongo/crypt/encryption_io_spec.rb +139 -0
- data/spec/mongo/crypt/explicit_decryption_context_spec.rb +75 -0
- data/spec/mongo/crypt/explicit_encryption_context_spec.rb +173 -0
- data/spec/mongo/crypt/handle_spec.rb +235 -0
- data/spec/mongo/crypt/helpers/mongo_crypt_spec_helper.rb +111 -0
- data/spec/mongo/crypt/status_spec.rb +150 -0
- data/spec/mongo/cursor/builder/get_more_command_spec.rb +11 -1
- data/spec/mongo/cursor/builder/op_get_more_spec.rb +11 -1
- data/spec/mongo/cursor/builder/op_kill_cursors_spec.rb +11 -1
- data/spec/mongo/cursor_spec.rb +130 -15
- data/spec/mongo/database_spec.rb +451 -17
- data/spec/mongo/dbref_spec.rb +3 -0
- data/spec/mongo/distinguishing_semaphore_spec.rb +66 -0
- data/spec/mongo/error/bulk_write_error_spec.rb +52 -0
- data/spec/mongo/error/crypt_error_spec.rb +29 -0
- data/spec/mongo/error/max_bson_size_spec.rb +38 -0
- data/spec/mongo/error/no_server_available_spec.rb +15 -2
- data/spec/mongo/error/notable_spec.rb +62 -0
- data/spec/mongo/error/operation_failure_heavy_spec.rb +61 -0
- data/spec/mongo/error/operation_failure_spec.rb +231 -70
- data/spec/mongo/error/parser_spec.rb +40 -6
- data/spec/mongo/error/unsupported_option_spec.rb +57 -0
- data/spec/mongo/event/publisher_spec.rb +3 -0
- data/spec/mongo/event/subscriber_spec.rb +3 -0
- data/spec/mongo/grid/file/chunk_spec.rb +7 -4
- data/spec/mongo/grid/file/info_spec.rb +3 -0
- data/spec/mongo/grid/file_spec.rb +4 -1
- data/spec/mongo/grid/fs_bucket_spec.rb +40 -5
- data/spec/mongo/grid/stream/read_spec.rb +33 -10
- data/spec/mongo/grid/stream/write_spec.rb +35 -0
- data/spec/mongo/grid/stream_spec.rb +3 -0
- data/spec/mongo/id_spec.rb +3 -0
- data/spec/mongo/index/view_spec.rb +321 -0
- data/spec/mongo/lint_spec.rb +3 -0
- data/spec/mongo/logger_spec.rb +16 -11
- data/spec/mongo/monitoring/command_log_subscriber_spec.rb +3 -0
- data/spec/mongo/monitoring/event/cmap/connection_check_out_failed_spec.rb +3 -0
- data/spec/mongo/monitoring/event/cmap/connection_check_out_started_spec.rb +3 -0
- data/spec/mongo/monitoring/event/cmap/connection_checked_in_spec.rb +13 -3
- data/spec/mongo/monitoring/event/cmap/connection_checked_out_spec.rb +13 -3
- data/spec/mongo/monitoring/event/cmap/connection_closed_spec.rb +3 -0
- data/spec/mongo/monitoring/event/cmap/connection_created_spec.rb +3 -0
- data/spec/mongo/monitoring/event/cmap/connection_ready_spec.rb +3 -0
- data/spec/mongo/monitoring/event/cmap/pool_cleared_spec.rb +3 -0
- data/spec/mongo/monitoring/event/cmap/pool_closed_spec.rb +13 -3
- data/spec/mongo/monitoring/event/cmap/pool_created_spec.rb +13 -3
- data/spec/mongo/monitoring/event/command_failed_spec.rb +59 -2
- data/spec/mongo/monitoring/event/command_started_spec.rb +3 -0
- data/spec/mongo/monitoring/event/command_succeeded_spec.rb +46 -6
- data/spec/mongo/monitoring/event/secure_spec.rb +28 -4
- data/spec/mongo/monitoring/event/server_closed_spec.rb +4 -1
- data/spec/mongo/monitoring/event/server_description_changed_spec.rb +4 -4
- data/spec/mongo/monitoring/event/server_heartbeat_failed_spec.rb +4 -1
- data/spec/mongo/monitoring/event/server_heartbeat_started_spec.rb +3 -0
- data/spec/mongo/monitoring/event/server_heartbeat_succeeded_spec.rb +4 -1
- data/spec/mongo/monitoring/event/server_opening_spec.rb +4 -1
- data/spec/mongo/monitoring/event/topology_changed_spec.rb +4 -1
- data/spec/mongo/monitoring/event/topology_closed_spec.rb +4 -1
- data/spec/mongo/monitoring/event/topology_opening_spec.rb +4 -1
- data/spec/mongo/monitoring_spec.rb +3 -0
- data/spec/mongo/operation/aggregate/result_spec.rb +11 -1
- data/spec/mongo/operation/aggregate_spec.rb +5 -1
- data/spec/mongo/operation/collections_info_spec.rb +7 -1
- data/spec/mongo/operation/command_spec.rb +11 -5
- data/spec/mongo/operation/create_index_spec.rb +9 -3
- data/spec/mongo/operation/create_user_spec.rb +9 -3
- data/spec/mongo/operation/delete/bulk_spec.rb +24 -6
- data/spec/mongo/operation/delete/command_spec.rb +3 -0
- data/spec/mongo/operation/delete/op_msg_spec.rb +36 -21
- data/spec/mongo/operation/delete_spec.rb +14 -7
- data/spec/mongo/operation/drop_index_spec.rb +9 -2
- data/spec/mongo/operation/find/legacy_spec.rb +33 -7
- data/spec/mongo/operation/get_more_spec.rb +11 -1
- data/spec/mongo/operation/indexes_spec.rb +8 -1
- data/spec/mongo/operation/insert/bulk_spec.rb +27 -7
- data/spec/mongo/operation/insert/command_spec.rb +7 -0
- data/spec/mongo/operation/insert/op_msg_spec.rb +67 -44
- data/spec/mongo/operation/insert_spec.rb +18 -12
- data/spec/mongo/operation/kill_cursors_spec.rb +3 -0
- data/spec/mongo/operation/limited_spec.rb +8 -3
- data/spec/mongo/operation/map_reduce_spec.rb +8 -2
- data/spec/mongo/operation/read_preference_legacy_spec.rb +356 -0
- data/spec/mongo/operation/read_preference_op_msg_spec.rb +307 -0
- data/spec/mongo/operation/remove_user_spec.rb +9 -3
- data/spec/mongo/operation/result_spec.rb +14 -4
- data/spec/mongo/operation/specifiable_spec.rb +3 -0
- data/spec/mongo/operation/update/bulk_spec.rb +24 -6
- data/spec/mongo/operation/update/command_spec.rb +7 -0
- data/spec/mongo/operation/update/op_msg_spec.rb +35 -20
- data/spec/mongo/operation/update_spec.rb +13 -7
- data/spec/mongo/operation/update_user_spec.rb +7 -1
- data/spec/mongo/options/redacted_spec.rb +3 -0
- data/spec/mongo/protocol/compressed_spec.rb +29 -13
- data/spec/mongo/protocol/delete_spec.rb +12 -8
- data/spec/mongo/protocol/get_more_spec.rb +12 -8
- data/spec/mongo/protocol/insert_spec.rb +12 -8
- data/spec/mongo/protocol/kill_cursors_spec.rb +9 -5
- data/spec/mongo/protocol/msg_spec.rb +70 -53
- data/spec/mongo/protocol/query_spec.rb +18 -15
- data/spec/mongo/protocol/registry_spec.rb +4 -1
- data/spec/mongo/protocol/reply_spec.rb +4 -1
- data/spec/mongo/protocol/update_spec.rb +13 -9
- data/spec/mongo/query_cache_middleware_spec.rb +55 -0
- data/spec/mongo/query_cache_spec.rb +283 -0
- data/spec/mongo/retryable_spec.rb +77 -72
- data/spec/mongo/semaphore_spec.rb +54 -0
- data/spec/mongo/server/app_metadata_spec.rb +53 -29
- data/spec/mongo/server/connection_auth_spec.rb +45 -23
- data/spec/mongo/server/connection_common_spec.rb +24 -0
- data/spec/mongo/server/connection_pool/populator_spec.rb +106 -0
- data/spec/mongo/server/connection_pool_spec.rb +259 -130
- data/spec/mongo/server/connection_spec.rb +277 -121
- data/spec/mongo/server/description/features_spec.rb +3 -0
- data/spec/mongo/server/description_query_methods_spec.rb +4 -1
- data/spec/mongo/server/description_spec.rb +630 -561
- data/spec/mongo/server/monitor/app_metadata_spec.rb +10 -1
- data/spec/mongo/server/monitor/connection_spec.rb +66 -79
- data/spec/mongo/server/monitor_spec.rb +173 -126
- data/spec/mongo/server/round_trip_time_averager_spec.rb +8 -3
- data/spec/mongo/server_selector/nearest_spec.rb +32 -25
- data/spec/mongo/server_selector/primary_preferred_spec.rb +35 -28
- data/spec/mongo/server_selector/primary_spec.rb +35 -11
- data/spec/mongo/server_selector/secondary_preferred_spec.rb +52 -29
- data/spec/mongo/server_selector/secondary_spec.rb +27 -20
- data/spec/mongo/server_selector_spec.rb +11 -8
- data/spec/mongo/server_spec.rb +100 -62
- data/spec/mongo/session/server_session_spec.rb +3 -0
- data/spec/mongo/session/session_pool_spec.rb +11 -8
- data/spec/mongo/session_spec.rb +38 -4
- data/spec/mongo/session_transaction_spec.rb +7 -12
- data/spec/mongo/socket/ssl_spec.rb +180 -103
- data/spec/mongo/socket/tcp_spec.rb +6 -11
- data/spec/mongo/socket/unix_spec.rb +5 -2
- data/spec/mongo/socket_spec.rb +14 -11
- data/spec/mongo/srv/monitor_spec.rb +233 -0
- data/spec/mongo/srv/result_spec.rb +57 -0
- data/spec/mongo/timeout_spec.rb +42 -0
- data/spec/mongo/tls_context_hooks_spec.rb +40 -0
- data/spec/mongo/uri/srv_protocol_spec.rb +95 -58
- data/spec/mongo/uri_option_parsing_spec.rb +14 -19
- data/spec/mongo/uri_spec.rb +253 -54
- data/spec/mongo/utils_spec.rb +56 -0
- data/spec/mongo/write_concern/acknowledged_spec.rb +3 -0
- data/spec/mongo/write_concern/unacknowledged_spec.rb +3 -0
- data/spec/mongo/write_concern_spec.rb +16 -1
- data/spec/runners/auth.rb +140 -0
- data/spec/runners/change_streams/outcome.rb +45 -0
- data/spec/runners/change_streams/spec.rb +60 -0
- data/spec/runners/change_streams/test.rb +232 -0
- data/spec/{support → runners}/cmap/verifier.rb +8 -6
- data/spec/{support → runners}/cmap.rb +29 -23
- data/spec/{support → runners}/command_monitoring.rb +10 -43
- data/spec/runners/connection_string.rb +381 -0
- data/spec/{support/transactions → runners/crud}/context.rb +12 -15
- data/spec/{support → runners}/crud/operation.rb +187 -58
- data/spec/{support → runners}/crud/outcome.rb +4 -1
- data/spec/runners/crud/requirement.rb +133 -0
- data/spec/{support → runners}/crud/spec.rb +20 -16
- data/spec/{support → runners}/crud/test.rb +11 -26
- data/spec/runners/crud/test_base.rb +53 -0
- data/spec/{support → runners}/crud/verifier.rb +40 -13
- data/spec/{support → runners}/crud.rb +33 -11
- data/spec/{support → runners}/gridfs.rb +8 -8
- data/spec/runners/read_write_concern_document.rb +70 -0
- data/spec/runners/sdam/verifier.rb +35 -11
- data/spec/{support/server_discovery_and_monitoring.rb → runners/sdam.rb} +51 -32
- data/spec/runners/server_selection.rb +365 -0
- data/spec/{support → runners}/server_selection_rtt.rb +8 -8
- data/spec/runners/transactions/operation.rb +328 -0
- data/spec/{support → runners}/transactions/spec.rb +4 -1
- data/spec/runners/transactions/test.rb +326 -0
- data/spec/{support → runners}/transactions.rb +19 -19
- data/spec/runners/unified/assertions.rb +282 -0
- data/spec/runners/unified/change_stream_operations.rb +29 -0
- data/spec/runners/unified/crud_operations.rb +206 -0
- data/spec/runners/unified/ddl_operations.rb +106 -0
- data/spec/runners/unified/entity_map.rb +42 -0
- data/spec/runners/unified/error.rb +28 -0
- data/spec/runners/unified/event_subscriber.rb +104 -0
- data/spec/runners/unified/exceptions.rb +24 -0
- data/spec/runners/unified/grid_fs_operations.rb +58 -0
- data/spec/runners/unified/support_operations.rb +253 -0
- data/spec/runners/unified/test.rb +423 -0
- data/spec/runners/unified/test_group.rb +31 -0
- data/spec/runners/unified/using_hash.rb +34 -0
- data/spec/runners/unified.rb +99 -0
- data/spec/shared/LICENSE +20 -0
- data/spec/shared/bin/get-mongodb-download-url +17 -0
- data/spec/shared/bin/s3-copy +45 -0
- data/spec/shared/bin/s3-upload +69 -0
- data/spec/shared/lib/mrss/child_process_helper.rb +80 -0
- data/spec/shared/lib/mrss/cluster_config.rb +226 -0
- data/spec/shared/lib/mrss/constraints.rb +379 -0
- data/spec/shared/lib/mrss/docker_runner.rb +271 -0
- data/spec/shared/lib/mrss/lite_constraints.rb +191 -0
- data/spec/shared/lib/mrss/server_version_registry.rb +115 -0
- data/spec/shared/lib/mrss/spec_organizer.rb +179 -0
- data/spec/shared/lib/mrss/utils.rb +15 -0
- data/spec/shared/share/Dockerfile.erb +322 -0
- data/spec/shared/share/haproxy-1.conf +16 -0
- data/spec/shared/share/haproxy-2.conf +17 -0
- data/spec/shared/shlib/distro.sh +73 -0
- data/spec/shared/shlib/server.sh +317 -0
- data/spec/shared/shlib/set_env.sh +131 -0
- data/spec/solo/clean_exit_spec.rb +24 -0
- data/spec/spec_helper.rb +15 -7
- data/spec/spec_tests/auth_spec.rb +58 -0
- data/spec/spec_tests/change_streams_spec.rb +58 -5
- data/spec/spec_tests/change_streams_unified_spec.rb +13 -0
- data/spec/spec_tests/client_side_encryption_spec.rb +14 -0
- data/spec/spec_tests/cmap_spec.rb +67 -8
- data/spec/spec_tests/collection_management_spec.rb +13 -0
- data/spec/spec_tests/command_monitoring_spec.rb +51 -33
- data/spec/spec_tests/command_monitoring_unified_spec.rb +13 -0
- data/spec/spec_tests/connection_string_spec.rb +6 -83
- data/spec/spec_tests/crud_spec.rb +6 -1
- data/spec/spec_tests/crud_unified_spec.rb +13 -0
- data/spec/spec_tests/data/auth/connection-string.yml +366 -0
- data/spec/spec_tests/data/change_streams/change-streams-errors.yml +30 -5
- data/spec/spec_tests/data/change_streams/change-streams-resume-allowlist.yml +1173 -0
- data/spec/spec_tests/data/change_streams/change-streams-resume-errorLabels.yml +1105 -0
- data/spec/spec_tests/data/change_streams/change-streams.yml +83 -16
- data/spec/spec_tests/data/change_streams_unified/change-streams.yml +72 -0
- data/spec/spec_tests/data/client_side_encryption/aggregate.yml +134 -0
- data/spec/spec_tests/data/client_side_encryption/badQueries.yml +526 -0
- data/spec/spec_tests/data/client_side_encryption/badSchema.yml +73 -0
- data/spec/spec_tests/data/client_side_encryption/basic.yml +116 -0
- data/spec/spec_tests/data/client_side_encryption/bulk.yml +88 -0
- data/spec/spec_tests/data/client_side_encryption/bypassAutoEncryption.yml +100 -0
- data/spec/spec_tests/data/client_side_encryption/bypassedCommand.yml +42 -0
- data/spec/spec_tests/data/client_side_encryption/count.yml +61 -0
- data/spec/spec_tests/data/client_side_encryption/countDocuments.yml +59 -0
- data/spec/spec_tests/data/client_side_encryption/delete.yml +105 -0
- data/spec/spec_tests/data/client_side_encryption/distinct.yml +73 -0
- data/spec/spec_tests/data/client_side_encryption/explain.yml +64 -0
- data/spec/spec_tests/data/client_side_encryption/find.yml +119 -0
- data/spec/spec_tests/data/client_side_encryption/findOneAndDelete.yml +57 -0
- data/spec/spec_tests/data/client_side_encryption/findOneAndReplace.yml +57 -0
- data/spec/spec_tests/data/client_side_encryption/findOneAndUpdate.yml +57 -0
- data/spec/spec_tests/data/client_side_encryption/getMore.yml +68 -0
- data/spec/spec_tests/data/client_side_encryption/insert.yml +102 -0
- data/spec/spec_tests/data/client_side_encryption/keyAltName.yml +71 -0
- data/spec/spec_tests/data/client_side_encryption/localKMS.yml +54 -0
- data/spec/spec_tests/data/client_side_encryption/localSchema.yml +72 -0
- data/spec/spec_tests/data/client_side_encryption/malformedCiphertext.yml +69 -0
- data/spec/spec_tests/data/client_side_encryption/maxWireVersion.yml +20 -0
- data/spec/spec_tests/data/client_side_encryption/missingKey.yml +49 -0
- data/spec/spec_tests/data/client_side_encryption/replaceOne.yml +64 -0
- data/spec/spec_tests/data/client_side_encryption/types.yml +527 -0
- data/spec/spec_tests/data/client_side_encryption/unsupportedCommand.yml +25 -0
- data/spec/spec_tests/data/client_side_encryption/updateMany.yml +77 -0
- data/spec/spec_tests/data/client_side_encryption/updateOne.yml +171 -0
- data/spec/spec_tests/data/cmap/connection-must-have-id.yml +6 -0
- data/spec/spec_tests/data/cmap/connection-must-order-ids.yml +6 -0
- data/spec/spec_tests/data/cmap/pool-checkin-destroy-closed.yml +3 -0
- data/spec/spec_tests/data/cmap/pool-checkin-destroy-stale.yml +3 -0
- data/spec/spec_tests/data/cmap/pool-checkin-make-available.yml +3 -0
- data/spec/spec_tests/data/cmap/pool-checkin.yml +1 -0
- data/spec/spec_tests/data/cmap/pool-checkout-connection.yml +8 -2
- data/spec/spec_tests/data/cmap/pool-checkout-error-closed.yml +9 -1
- data/spec/spec_tests/data/cmap/pool-checkout-multiple.yml +3 -0
- data/spec/spec_tests/data/cmap/pool-checkout-no-idle.yml +4 -0
- data/spec/spec_tests/data/cmap/pool-checkout-no-stale.yml +4 -0
- data/spec/spec_tests/data/cmap/pool-close-destroy-conns.yml +2 -0
- data/spec/spec_tests/data/cmap/pool-create-max-size.yml +15 -0
- data/spec/spec_tests/data/cmap/pool-create-min-size.yml +7 -0
- data/spec/spec_tests/data/cmap/pool-create-with-options.yml +1 -0
- data/spec/spec_tests/data/cmap/wait-queue-fairness.yml +31 -1
- data/spec/spec_tests/data/cmap/wait-queue-timeout.yml +5 -0
- data/spec/spec_tests/data/collection_management/timeseries-collection.yml +129 -0
- data/spec/spec_tests/data/command_monitoring/insertMany.yml +1 -1
- data/spec/spec_tests/data/command_monitoring_unified/redacted-commands.yml +340 -0
- data/spec/spec_tests/data/connection_string/invalid-uris.yml +20 -0
- data/spec/spec_tests/data/connection_string/valid-auth.yml +16 -0
- data/spec/spec_tests/data/connection_string/valid-warnings.yml +50 -30
- data/spec/spec_tests/data/crud/write/bulkWrite.yml +26 -22
- data/spec/spec_tests/data/crud/write/insertMany.yml +26 -22
- data/spec/spec_tests/data/crud_unified/estimatedDocumentCount.yml +267 -0
- data/spec/spec_tests/data/crud_unified/updateWithPipelines.yml +305 -0
- data/spec/spec_tests/data/crud_v2/aggregate-merge.yml +1 -1
- data/spec/spec_tests/data/crud_v2/aggregate-out-readConcern.yml +1 -0
- data/spec/spec_tests/data/crud_v2/bulkWrite-arrayFilters.yml +33 -11
- data/spec/spec_tests/data/crud_v2/bulkWrite-delete-hint-clientError.yml +63 -0
- data/spec/spec_tests/data/crud_v2/bulkWrite-delete-hint-serverError.yml +92 -0
- data/spec/spec_tests/data/crud_v2/bulkWrite-delete-hint.yml +103 -0
- data/spec/spec_tests/data/crud_v2/bulkWrite-update-hint-clientError.yml +90 -0
- data/spec/spec_tests/data/crud_v2/bulkWrite-update-hint-serverError.yml +147 -0
- data/spec/spec_tests/data/crud_v2/bulkWrite-update-hint.yml +164 -0
- data/spec/spec_tests/data/crud_v2/db-aggregate.yml +1 -0
- data/spec/spec_tests/data/crud_v2/deleteMany-hint-clientError.yml +43 -0
- data/spec/spec_tests/data/crud_v2/deleteMany-hint-serverError.yml +62 -0
- data/spec/spec_tests/data/crud_v2/deleteMany-hint.yml +58 -0
- data/spec/spec_tests/data/crud_v2/deleteOne-hint-clientError.yml +41 -0
- data/spec/spec_tests/data/crud_v2/deleteOne-hint-serverError.yml +60 -0
- data/spec/spec_tests/data/crud_v2/deleteOne-hint.yml +57 -0
- data/spec/spec_tests/data/crud_v2/find-allowdiskuse-clientError.yml +28 -0
- data/spec/spec_tests/data/crud_v2/find-allowdiskuse-serverError.yml +44 -0
- data/spec/spec_tests/data/crud_v2/find-allowdiskuse.yml +50 -0
- data/spec/spec_tests/data/crud_v2/findOneAndDelete-hint-clientError.yml +45 -0
- data/spec/spec_tests/data/crud_v2/findOneAndDelete-hint-serverError.yml +60 -0
- data/spec/spec_tests/data/crud_v2/findOneAndDelete-hint.yml +56 -0
- data/spec/spec_tests/data/crud_v2/findOneAndReplace-hint-clientError.yml +40 -0
- data/spec/spec_tests/data/crud_v2/findOneAndReplace-hint-serverError.yml +59 -0
- data/spec/spec_tests/data/crud_v2/findOneAndReplace-hint.yml +55 -0
- data/spec/spec_tests/data/crud_v2/findOneAndUpdate-hint-clientError.yml +40 -0
- data/spec/spec_tests/data/crud_v2/findOneAndUpdate-hint-serverError.yml +58 -0
- data/spec/spec_tests/data/crud_v2/findOneAndUpdate-hint.yml +55 -0
- data/spec/spec_tests/data/crud_v2/replaceOne-hint.yml +61 -0
- data/spec/spec_tests/data/crud_v2/unacknowledged-bulkWrite-delete-hint-clientError.yml +60 -0
- data/spec/spec_tests/data/crud_v2/unacknowledged-bulkWrite-update-hint-clientError.yml +88 -0
- data/spec/spec_tests/data/crud_v2/unacknowledged-deleteMany-hint-clientError.yml +40 -0
- data/spec/spec_tests/data/crud_v2/unacknowledged-deleteOne-hint-clientError.yml +38 -0
- data/spec/spec_tests/data/crud_v2/unacknowledged-findOneAndDelete-hint-clientError.yml +42 -0
- data/spec/spec_tests/data/crud_v2/unacknowledged-findOneAndReplace-hint-clientError.yml +40 -0
- data/spec/spec_tests/data/crud_v2/unacknowledged-findOneAndUpdate-hint-clientError.yml +40 -0
- data/spec/spec_tests/data/crud_v2/unacknowledged-replaceOne-hint-clientError.yml +40 -0
- data/spec/spec_tests/data/crud_v2/unacknowledged-updateMany-hint-clientError.yml +43 -0
- data/spec/spec_tests/data/crud_v2/unacknowledged-updateOne-hint-clientError.yml +40 -0
- data/spec/spec_tests/data/crud_v2/updateMany-hint-clientError.yml +45 -0
- data/spec/spec_tests/data/crud_v2/updateMany-hint-serverError.yml +66 -0
- data/spec/spec_tests/data/crud_v2/updateMany-hint.yml +65 -0
- data/spec/spec_tests/data/crud_v2/updateOne-hint-clientError.yml +43 -0
- data/spec/spec_tests/data/crud_v2/updateOne-hint-serverError.yml +62 -0
- data/spec/spec_tests/data/crud_v2/updateOne-hint.yml +61 -0
- data/spec/spec_tests/data/crud_v2/updateWithPipelines.yml +65 -0
- data/spec/spec_tests/data/dns_seedlist_discovery/direct-connection-false.yml +10 -0
- data/spec/spec_tests/data/dns_seedlist_discovery/direct-connection-true.yml +5 -0
- data/spec/spec_tests/data/max_staleness/ReplicaSetNoPrimary/MaxStalenessTooSmall.yml +15 -0
- data/spec/spec_tests/data/max_staleness/ReplicaSetNoPrimary/NoKnownServers.yml +4 -3
- data/spec/spec_tests/data/max_staleness/Unknown/SmallMaxStaleness.yml +1 -0
- data/spec/spec_tests/data/read_write_concern/connection-string/read-concern.yml +32 -0
- data/spec/spec_tests/data/read_write_concern/connection-string/write-concern.yml +79 -0
- data/spec/spec_tests/data/read_write_concern/document/read-concern.yml +37 -0
- data/spec/spec_tests/data/read_write_concern/document/write-concern.yml +100 -0
- data/spec/spec_tests/data/read_write_concern/operation/default-write-concern-2.6.yml +215 -0
- data/spec/spec_tests/data/read_write_concern/operation/default-write-concern-3.2.yml +58 -0
- data/spec/spec_tests/data/read_write_concern/operation/default-write-concern-3.4.yml +95 -0
- data/spec/spec_tests/data/read_write_concern/operation/default-write-concern-4.2.yml +36 -0
- data/spec/spec_tests/data/retryable_reads/aggregate-merge.yml +39 -0
- data/spec/spec_tests/data/retryable_reads/aggregate-serverErrors.yml +2 -2
- data/spec/spec_tests/data/retryable_reads/changeStreams-client.watch-serverErrors.yml +8 -7
- data/spec/spec_tests/data/retryable_reads/changeStreams-client.watch.yml +2 -1
- data/spec/spec_tests/data/retryable_reads/changeStreams-db.coll.watch-serverErrors.yml +8 -7
- data/spec/spec_tests/data/retryable_reads/changeStreams-db.coll.watch.yml +2 -1
- data/spec/spec_tests/data/retryable_reads/changeStreams-db.watch-serverErrors.yml +8 -7
- data/spec/spec_tests/data/retryable_reads/changeStreams-db.watch.yml +2 -1
- data/spec/spec_tests/data/retryable_reads/count-serverErrors.yml +2 -2
- data/spec/spec_tests/data/retryable_reads/countDocuments-serverErrors.yml +2 -2
- data/spec/spec_tests/data/retryable_reads/distinct-serverErrors.yml +2 -2
- 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} +4 -2
- data/spec/spec_tests/data/retryable_reads/find-serverErrors.yml +2 -2
- data/spec/spec_tests/data/retryable_reads/findOne-serverErrors.yml +2 -2
- data/spec/spec_tests/data/retryable_reads/gridfs-download-serverErrors.yml +2 -2
- data/spec/spec_tests/data/retryable_reads/gridfs-downloadByName-serverErrors.yml +2 -2
- data/spec/spec_tests/data/retryable_reads/listCollectionNames-serverErrors.yml +2 -2
- data/spec/spec_tests/data/retryable_reads/listCollectionObjects-serverErrors.yml +2 -2
- data/spec/spec_tests/data/retryable_reads/listCollections-serverErrors.yml +2 -2
- data/spec/spec_tests/data/retryable_reads/listDatabaseNames-serverErrors.yml +2 -2
- data/spec/spec_tests/data/retryable_reads/listDatabaseObjects-serverErrors.yml +2 -2
- data/spec/spec_tests/data/retryable_reads/listDatabases-serverErrors.yml +2 -2
- data/spec/spec_tests/data/retryable_reads/listIndexNames-serverErrors.yml +2 -2
- data/spec/spec_tests/data/retryable_reads/listIndexNames.yml +1 -1
- data/spec/spec_tests/data/retryable_reads/listIndexes-serverErrors.yml +2 -2
- data/spec/spec_tests/data/retryable_writes/bulkWrite-errorLabels.yml +77 -0
- data/spec/spec_tests/data/retryable_writes/bulkWrite-serverErrors.yml +37 -0
- data/spec/spec_tests/data/retryable_writes/bulkWrite.yml +30 -24
- data/spec/spec_tests/data/retryable_writes/deleteOne-errorLabels.yml +48 -0
- data/spec/spec_tests/data/retryable_writes/deleteOne-serverErrors.yml +22 -0
- data/spec/spec_tests/data/retryable_writes/findOneAndDelete-errorLabels.yml +49 -0
- data/spec/spec_tests/data/retryable_writes/findOneAndDelete-serverErrors.yml +23 -0
- data/spec/spec_tests/data/retryable_writes/findOneAndReplace-errorLabels.yml +52 -0
- data/spec/spec_tests/data/retryable_writes/findOneAndReplace-serverErrors.yml +25 -0
- data/spec/spec_tests/data/retryable_writes/findOneAndUpdate-errorLabels.yml +52 -0
- data/spec/spec_tests/data/retryable_writes/findOneAndUpdate-serverErrors.yml +24 -0
- data/spec/spec_tests/data/retryable_writes/insertMany-errorLabels.yml +54 -0
- data/spec/spec_tests/data/retryable_writes/insertMany-serverErrors.yml +24 -0
- data/spec/spec_tests/data/retryable_writes/insertOne-errorLabels.yml +44 -0
- data/spec/spec_tests/data/retryable_writes/insertOne-serverErrors.yml +94 -3
- data/spec/spec_tests/data/retryable_writes/replaceOne-errorLabels.yml +53 -0
- data/spec/spec_tests/data/retryable_writes/replaceOne-serverErrors.yml +23 -0
- data/spec/spec_tests/data/retryable_writes/updateOne-errorLabels.yml +53 -0
- data/spec/spec_tests/data/retryable_writes/updateOne-serverErrors.yml +23 -0
- data/spec/spec_tests/data/sdam/errors/error_handling_handshake.yml +55 -0
- data/spec/spec_tests/data/sdam/errors/non-stale-network-error.yml +47 -0
- data/spec/spec_tests/data/sdam/errors/non-stale-network-timeout-error.yml +38 -0
- data/spec/spec_tests/data/sdam/errors/non-stale-topologyVersion-greater-InterruptedAtShutdown.yml +61 -0
- data/spec/spec_tests/data/sdam/errors/non-stale-topologyVersion-greater-InterruptedDueToReplStateChange.yml +61 -0
- data/spec/spec_tests/data/sdam/errors/non-stale-topologyVersion-greater-LegacyNotPrimary.yml +61 -0
- data/spec/spec_tests/data/sdam/errors/non-stale-topologyVersion-greater-NotPrimaryNoSecondaryOk.yml +61 -0
- data/spec/spec_tests/data/sdam/errors/non-stale-topologyVersion-greater-NotPrimaryOrSecondary.yml +61 -0
- data/spec/spec_tests/data/sdam/errors/non-stale-topologyVersion-greater-NotWritablePrimary.yml +61 -0
- data/spec/spec_tests/data/sdam/errors/non-stale-topologyVersion-greater-PrimarySteppedDown.yml +61 -0
- data/spec/spec_tests/data/sdam/errors/non-stale-topologyVersion-greater-ShutdownInProgress.yml +61 -0
- data/spec/spec_tests/data/sdam/errors/non-stale-topologyVersion-missing-InterruptedAtShutdown.yml +52 -0
- data/spec/spec_tests/data/sdam/errors/non-stale-topologyVersion-missing-InterruptedDueToReplStateChange.yml +52 -0
- data/spec/spec_tests/data/sdam/errors/non-stale-topologyVersion-missing-LegacyNotPrimary.yml +52 -0
- data/spec/spec_tests/data/sdam/errors/non-stale-topologyVersion-missing-NotPrimaryNoSecondaryOk.yml +52 -0
- data/spec/spec_tests/data/sdam/errors/non-stale-topologyVersion-missing-NotPrimaryOrSecondary.yml +52 -0
- data/spec/spec_tests/data/sdam/errors/non-stale-topologyVersion-missing-NotWritablePrimary.yml +52 -0
- data/spec/spec_tests/data/sdam/errors/non-stale-topologyVersion-missing-PrimarySteppedDown.yml +52 -0
- data/spec/spec_tests/data/sdam/errors/non-stale-topologyVersion-missing-ShutdownInProgress.yml +52 -0
- data/spec/spec_tests/data/sdam/errors/non-stale-topologyVersion-proccessId-changed-InterruptedAtShutdown.yml +61 -0
- data/spec/spec_tests/data/sdam/errors/non-stale-topologyVersion-proccessId-changed-InterruptedDueToReplStateChange.yml +61 -0
- data/spec/spec_tests/data/sdam/errors/non-stale-topologyVersion-proccessId-changed-LegacyNotPrimary.yml +61 -0
- data/spec/spec_tests/data/sdam/errors/non-stale-topologyVersion-proccessId-changed-NotPrimaryNoSecondaryOk.yml +61 -0
- data/spec/spec_tests/data/sdam/errors/non-stale-topologyVersion-proccessId-changed-NotPrimaryOrSecondary.yml +61 -0
- data/spec/spec_tests/data/sdam/errors/non-stale-topologyVersion-proccessId-changed-NotWritablePrimary.yml +61 -0
- data/spec/spec_tests/data/sdam/errors/non-stale-topologyVersion-proccessId-changed-PrimarySteppedDown.yml +61 -0
- data/spec/spec_tests/data/sdam/errors/non-stale-topologyVersion-proccessId-changed-ShutdownInProgress.yml +61 -0
- data/spec/spec_tests/data/sdam/errors/post-42-InterruptedAtShutdown.yml +47 -0
- data/spec/spec_tests/data/sdam/errors/post-42-InterruptedDueToReplStateChange.yml +47 -0
- data/spec/spec_tests/data/sdam/errors/post-42-LegacyNotPrimary.yml +47 -0
- data/spec/spec_tests/data/sdam/errors/post-42-NotPrimaryNoSecondaryOk.yml +47 -0
- data/spec/spec_tests/data/sdam/errors/post-42-NotPrimaryOrSecondary.yml +47 -0
- data/spec/spec_tests/data/sdam/errors/post-42-NotWritablePrimary.yml +47 -0
- data/spec/spec_tests/data/sdam/errors/post-42-PrimarySteppedDown.yml +47 -0
- data/spec/spec_tests/data/sdam/errors/post-42-ShutdownInProgress.yml +47 -0
- data/spec/spec_tests/data/sdam/errors/pre-42-InterruptedAtShutdown.yml +47 -0
- data/spec/spec_tests/data/sdam/errors/pre-42-InterruptedDueToReplStateChange.yml +47 -0
- data/spec/spec_tests/data/sdam/errors/pre-42-LegacyNotPrimary.yml +47 -0
- data/spec/spec_tests/data/sdam/errors/pre-42-NotPrimaryNoSecondaryOk.yml +47 -0
- data/spec/spec_tests/data/sdam/errors/pre-42-NotPrimaryOrSecondary.yml +47 -0
- data/spec/spec_tests/data/sdam/errors/pre-42-NotWritablePrimary.yml +47 -0
- data/spec/spec_tests/data/sdam/errors/pre-42-PrimarySteppedDown.yml +47 -0
- data/spec/spec_tests/data/sdam/errors/pre-42-ShutdownInProgress.yml +47 -0
- data/spec/spec_tests/data/sdam/errors/prefer-error-code.yml +54 -0
- data/spec/spec_tests/data/sdam/errors/stale-generation-InterruptedAtShutdown.yml +91 -0
- data/spec/spec_tests/data/sdam/errors/stale-generation-InterruptedDueToReplStateChange.yml +91 -0
- data/spec/spec_tests/data/sdam/errors/stale-generation-NotPrimaryNoSecondaryOk.yml +91 -0
- data/spec/spec_tests/data/sdam/errors/stale-generation-NotPrimaryOrSecondary.yml +91 -0
- data/spec/spec_tests/data/sdam/errors/stale-generation-NotWritablePrimary.yml +91 -0
- data/spec/spec_tests/data/sdam/errors/stale-generation-PrimarySteppedDown.yml +91 -0
- data/spec/spec_tests/data/sdam/errors/stale-generation-ShutdownInProgress.yml +91 -0
- data/spec/spec_tests/data/sdam/errors/stale-generation-afterHandshakeCompletes-InterruptedAtShutdown.yml +91 -0
- data/spec/spec_tests/data/sdam/errors/stale-generation-afterHandshakeCompletes-InterruptedDueToReplStateChange.yml +91 -0
- data/spec/spec_tests/data/sdam/errors/stale-generation-afterHandshakeCompletes-LegacyNotPrimary.yml +91 -0
- data/spec/spec_tests/data/sdam/errors/stale-generation-afterHandshakeCompletes-NotPrimaryNoSecondaryOk.yml +91 -0
- data/spec/spec_tests/data/sdam/errors/stale-generation-afterHandshakeCompletes-NotPrimaryOrSecondary.yml +91 -0
- data/spec/spec_tests/data/sdam/errors/stale-generation-afterHandshakeCompletes-NotWritablePrimary.yml +91 -0
- data/spec/spec_tests/data/sdam/errors/stale-generation-afterHandshakeCompletes-PrimarySteppedDown.yml +91 -0
- data/spec/spec_tests/data/sdam/errors/stale-generation-afterHandshakeCompletes-ShutdownInProgress.yml +91 -0
- data/spec/spec_tests/data/sdam/errors/stale-generation-afterHandshakeCompletes-network.yml +82 -0
- data/spec/spec_tests/data/sdam/errors/stale-generation-afterHandshakeCompletes-timeout.yml +82 -0
- data/spec/spec_tests/data/sdam/errors/stale-generation-beforeHandshakeCompletes-InterruptedAtShutdown.yml +91 -0
- data/spec/spec_tests/data/sdam/errors/stale-generation-beforeHandshakeCompletes-InterruptedDueToReplStateChange.yml +91 -0
- data/spec/spec_tests/data/sdam/errors/stale-generation-beforeHandshakeCompletes-LegacyNotPrimary.yml +91 -0
- data/spec/spec_tests/data/sdam/errors/stale-generation-beforeHandshakeCompletes-NotPrimaryNoSecondaryOk.yml +91 -0
- data/spec/spec_tests/data/sdam/errors/stale-generation-beforeHandshakeCompletes-NotPrimaryOrSecondary.yml +91 -0
- data/spec/spec_tests/data/sdam/errors/stale-generation-beforeHandshakeCompletes-NotWritablePrimary.yml +91 -0
- data/spec/spec_tests/data/sdam/errors/stale-generation-beforeHandshakeCompletes-PrimarySteppedDown.yml +91 -0
- data/spec/spec_tests/data/sdam/errors/stale-generation-beforeHandshakeCompletes-ShutdownInProgress.yml +91 -0
- data/spec/spec_tests/data/sdam/errors/stale-generation-beforeHandshakeCompletes-network.yml +82 -0
- data/spec/spec_tests/data/sdam/errors/stale-generation-beforeHandshakeCompletes-timeout.yml +82 -0
- data/spec/spec_tests/data/sdam/errors/stale-topologyVersion-InterruptedAtShutdown.yml +65 -0
- data/spec/spec_tests/data/sdam/errors/stale-topologyVersion-InterruptedDueToReplStateChange.yml +65 -0
- data/spec/spec_tests/data/sdam/errors/stale-topologyVersion-LegacyNotPrimary.yml +65 -0
- data/spec/spec_tests/data/sdam/errors/stale-topologyVersion-NotPrimaryNoSecondaryOk.yml +65 -0
- data/spec/spec_tests/data/sdam/errors/stale-topologyVersion-NotPrimaryOrSecondary.yml +65 -0
- data/spec/spec_tests/data/sdam/errors/stale-topologyVersion-NotWritablePrimary.yml +65 -0
- data/spec/spec_tests/data/sdam/errors/stale-topologyVersion-PrimarySteppedDown.yml +65 -0
- data/spec/spec_tests/data/sdam/errors/stale-topologyVersion-ShutdownInProgress.yml +65 -0
- data/spec/spec_tests/data/sdam/errors/write_errors_ignored.yml +42 -0
- data/spec/spec_tests/data/sdam/rs/compatible.yml +6 -2
- data/spec/spec_tests/data/sdam/rs/compatible_unknown.yml +4 -1
- data/spec/spec_tests/data/sdam/rs/discover_arbiters.yml +4 -3
- data/spec/spec_tests/data/sdam/rs/discover_arbiters_replicaset.yml +44 -0
- data/spec/spec_tests/data/sdam/rs/discover_ghost.yml +36 -0
- data/spec/spec_tests/data/sdam/rs/{ghost_discovered.yml → discover_ghost_replicaset.yml} +3 -2
- data/spec/spec_tests/data/sdam/rs/discover_hidden.yml +51 -0
- data/spec/spec_tests/data/sdam/rs/discover_hidden_replicaset.yml +51 -0
- data/spec/spec_tests/data/sdam/rs/discover_passives.yml +6 -4
- data/spec/spec_tests/data/sdam/rs/discover_passives_replicaset.yml +83 -0
- data/spec/spec_tests/data/sdam/rs/discover_primary.yml +4 -3
- data/spec/spec_tests/data/sdam/rs/discover_primary_replicaset.yml +43 -0
- data/spec/spec_tests/data/sdam/rs/discover_rsother.yml +50 -0
- data/spec/spec_tests/data/sdam/rs/{rsother_discovered.yml → discover_rsother_replicaset.yml} +5 -3
- data/spec/spec_tests/data/sdam/rs/discover_secondary.yml +4 -3
- data/spec/spec_tests/data/sdam/rs/discover_secondary_replicaset.yml +44 -0
- data/spec/spec_tests/data/sdam/rs/discovery.yml +8 -4
- data/spec/spec_tests/data/sdam/rs/equal_electionids.yml +4 -2
- data/spec/spec_tests/data/sdam/rs/hosts_differ_from_seeds.yml +2 -1
- data/spec/spec_tests/data/sdam/rs/incompatible_arbiter.yml +5 -1
- data/spec/spec_tests/data/sdam/rs/incompatible_ghost.yml +7 -5
- data/spec/spec_tests/data/sdam/rs/incompatible_other.yml +6 -2
- data/spec/spec_tests/data/sdam/rs/ls_timeout.yml +12 -6
- data/spec/spec_tests/data/sdam/rs/member_reconfig.yml +4 -2
- data/spec/spec_tests/data/sdam/rs/member_standalone.yml +4 -2
- data/spec/spec_tests/data/sdam/rs/new_primary.yml +4 -2
- data/spec/spec_tests/data/sdam/rs/new_primary_new_electionid.yml +6 -3
- data/spec/spec_tests/data/sdam/rs/new_primary_new_setversion.yml +6 -3
- data/spec/spec_tests/data/sdam/rs/new_primary_wrong_set_name.yml +4 -2
- data/spec/spec_tests/data/sdam/rs/non_rs_member.yml +1 -0
- data/spec/spec_tests/data/sdam/rs/normalize_case.yml +2 -1
- data/spec/spec_tests/data/sdam/rs/normalize_case_me.yml +4 -2
- data/spec/spec_tests/data/sdam/rs/null_election_id.yml +8 -4
- data/spec/spec_tests/data/sdam/rs/primary_becomes_ghost.yml +4 -2
- data/spec/spec_tests/data/sdam/rs/primary_becomes_mongos.yml +4 -2
- data/spec/spec_tests/data/sdam/rs/primary_becomes_standalone.yml +2 -1
- data/spec/spec_tests/data/sdam/rs/primary_changes_set_name.yml +4 -2
- data/spec/spec_tests/data/sdam/rs/primary_disconnect.yml +2 -1
- data/spec/spec_tests/data/sdam/rs/primary_disconnect_electionid.yml +10 -5
- data/spec/spec_tests/data/sdam/rs/primary_disconnect_setversion.yml +10 -5
- data/spec/spec_tests/data/sdam/rs/primary_hint_from_secondary_with_mismatched_me.yml +4 -2
- data/spec/spec_tests/data/sdam/rs/primary_mismatched_me.yml +2 -1
- data/spec/spec_tests/data/sdam/rs/primary_mismatched_me_not_removed.yml +75 -0
- data/spec/spec_tests/data/sdam/rs/primary_reports_new_member.yml +8 -4
- data/spec/spec_tests/data/sdam/rs/primary_to_no_primary_mismatched_me.yml +4 -2
- data/spec/spec_tests/data/sdam/rs/primary_wrong_set_name.yml +2 -1
- data/spec/spec_tests/data/sdam/rs/repeated.yml +105 -0
- data/spec/spec_tests/data/sdam/rs/replicaset_rsnp.yml +21 -0
- data/spec/spec_tests/data/sdam/rs/response_from_removed.yml +4 -2
- data/spec/spec_tests/data/sdam/rs/ruby_primary_address_change.yml +31 -0
- data/spec/spec_tests/data/sdam/rs/{secondary_wrong_set_name_with_primary_second.yml → ruby_secondary_wrong_set_name_with_primary_second.yml} +0 -0
- data/spec/spec_tests/data/sdam/rs/sec_not_auth.yml +4 -2
- data/spec/spec_tests/data/sdam/rs/secondary_ignore_ok_0.yml +4 -2
- data/spec/spec_tests/data/sdam/rs/secondary_mismatched_me.yml +5 -3
- data/spec/spec_tests/data/sdam/rs/secondary_wrong_set_name.yml +2 -1
- data/spec/spec_tests/data/sdam/rs/secondary_wrong_set_name_with_primary.yml +4 -2
- data/spec/spec_tests/data/sdam/rs/setversion_without_electionid.yml +4 -2
- data/spec/spec_tests/data/sdam/rs/stepdown_change_set_name.yml +4 -2
- data/spec/spec_tests/data/sdam/rs/too_new.yml +6 -2
- data/spec/spec_tests/data/sdam/rs/too_old.yml +4 -2
- data/spec/spec_tests/data/sdam/rs/topology_version_equal.yml +68 -0
- data/spec/spec_tests/data/sdam/rs/topology_version_greater.yml +194 -0
- data/spec/spec_tests/data/sdam/rs/topology_version_less.yml +64 -0
- data/spec/spec_tests/data/sdam/rs/unexpected_mongos.yml +2 -1
- data/spec/spec_tests/data/sdam/rs/use_setversion_without_electionid.yml +6 -3
- data/spec/spec_tests/data/sdam/rs/wrong_set_name.yml +2 -1
- data/spec/spec_tests/data/sdam/sharded/compatible.yml +4 -2
- data/spec/spec_tests/data/sdam/sharded/discover_single_mongos.yml +24 -0
- data/spec/spec_tests/data/sdam/sharded/ls_timeout_mongos.yml +9 -5
- data/spec/spec_tests/data/sdam/sharded/mongos_disconnect.yml +6 -3
- data/spec/spec_tests/data/sdam/sharded/multiple_mongoses.yml +4 -2
- data/spec/spec_tests/data/sdam/sharded/non_mongos_removed.yml +4 -2
- data/spec/spec_tests/data/sdam/sharded/ruby_primary_different_address.yml +21 -0
- data/spec/spec_tests/data/sdam/sharded/ruby_primary_mismatched_me.yml +22 -0
- data/spec/spec_tests/data/sdam/sharded/too_new.yml +4 -2
- data/spec/spec_tests/data/sdam/sharded/too_old.yml +4 -2
- data/spec/spec_tests/data/sdam/single/compatible.yml +2 -1
- data/spec/spec_tests/data/sdam/single/direct_connection_external_ip.yml +3 -2
- data/spec/spec_tests/data/sdam/single/direct_connection_mongos.yml +4 -3
- data/spec/spec_tests/data/sdam/single/direct_connection_replicaset.yml +23 -0
- data/spec/spec_tests/data/sdam/single/direct_connection_rsarbiter.yml +4 -3
- data/spec/spec_tests/data/sdam/single/direct_connection_rsprimary.yml +4 -3
- data/spec/spec_tests/data/sdam/single/direct_connection_rssecondary.yml +4 -3
- data/spec/spec_tests/data/sdam/single/direct_connection_standalone.yml +4 -3
- data/spec/spec_tests/data/sdam/single/{unavailable_seed.yml → direct_connection_unavailable_seed.yml} +2 -2
- data/spec/spec_tests/data/sdam/single/direct_connection_wrong_set_name.yml +40 -0
- data/spec/spec_tests/data/sdam/single/discover_standalone.yml +35 -0
- data/spec/spec_tests/data/sdam/single/discover_unavailable_seed.yml +28 -0
- data/spec/spec_tests/data/sdam/single/ls_timeout_standalone.yml +2 -1
- data/spec/spec_tests/data/sdam/single/not_ok_response.yml +5 -3
- data/spec/spec_tests/data/sdam/single/ruby_primary_different_address.yml +24 -0
- data/spec/spec_tests/data/sdam/single/ruby_primary_mismatched_me.yml +25 -0
- data/spec/spec_tests/data/sdam/single/standalone_removed.yml +2 -1
- data/spec/spec_tests/data/sdam/single/{direct_connection_slave.yml → standalone_using_legacy_hello.yml} +2 -2
- data/spec/spec_tests/data/sdam/single/too_new.yml +2 -1
- data/spec/spec_tests/data/sdam/single/too_old.yml +2 -1
- data/spec/spec_tests/data/sdam/single/too_old_then_upgraded.yml +48 -0
- data/spec/spec_tests/data/sdam_integration/cancel-server-check.yml +96 -0
- data/spec/spec_tests/data/sdam_integration/connectTimeoutMS.yml +88 -0
- data/spec/spec_tests/data/sdam_integration/find-network-error.yml +83 -0
- data/spec/spec_tests/data/sdam_integration/find-shutdown-error.yml +116 -0
- data/spec/spec_tests/data/sdam_integration/hello-command-error.yml +158 -0
- data/spec/spec_tests/data/sdam_integration/hello-network-error.yml +156 -0
- data/spec/spec_tests/data/sdam_integration/hello-timeout.yml +223 -0
- data/spec/spec_tests/data/sdam_integration/insert-network-error.yml +86 -0
- data/spec/spec_tests/data/sdam_integration/insert-shutdown-error.yml +115 -0
- data/spec/spec_tests/data/sdam_integration/rediscover-quickly-after-step-down.yml +98 -0
- data/spec/spec_tests/data/sdam_monitoring/discovered_standalone.yml +2 -4
- data/spec/spec_tests/data/sdam_monitoring/{replica_set_other_seed.yml → replica_set_primary_address_change.yml} +114 -96
- data/spec/spec_tests/data/sdam_monitoring/replica_set_with_me_mismatch.yml +111 -0
- data/spec/spec_tests/data/sdam_monitoring/replica_set_with_no_primary.yml +2 -1
- data/spec/spec_tests/data/sdam_monitoring/replica_set_with_primary.yml +2 -1
- data/spec/spec_tests/data/sdam_monitoring/replica_set_with_primary_removal.yml +22 -18
- data/spec/spec_tests/data/sdam_monitoring/replica_set_with_removal.yml +21 -16
- data/spec/spec_tests/data/sdam_monitoring/required_replica_set.yml +2 -1
- data/spec/spec_tests/data/sdam_monitoring/standalone.yml +3 -3
- 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 +73 -0
- data/spec/spec_tests/data/sdam_monitoring/standalone_to_rs_with_me_mismatch.yml +90 -0
- data/spec/spec_tests/data/transactions/abort.yml +3 -3
- data/spec/spec_tests/data/transactions/create-collection.yml +131 -0
- data/spec/spec_tests/data/transactions/create-index.yml +152 -0
- data/spec/spec_tests/data/transactions/error-labels.yml +93 -24
- data/spec/spec_tests/data/transactions/mongos-pin-auto.yml +3 -0
- data/spec/spec_tests/data/transactions/mongos-recovery-token.yml +3 -0
- data/spec/spec_tests/data/transactions/pin-mongos.yml +8 -6
- data/spec/spec_tests/data/transactions/read-concern.yml +6 -6
- data/spec/spec_tests/data/transactions/retryable-abort-errorLabels.yml +124 -0
- data/spec/spec_tests/data/transactions/retryable-abort.yml +17 -2
- data/spec/spec_tests/data/transactions/retryable-commit-errorLabels.yml +132 -0
- data/spec/spec_tests/data/transactions/retryable-commit.yml +24 -9
- data/spec/spec_tests/data/transactions/transaction-options-repl.yml +117 -0
- data/spec/spec_tests/data/transactions/transaction-options.yml +14 -121
- data/spec/spec_tests/data/transactions/write-concern.yml +3 -0
- data/spec/spec_tests/data/transactions_api/callback-retry.yml +3 -3
- data/spec/spec_tests/data/transactions_api/transaction-options.yml +11 -12
- data/spec/spec_tests/data/transactions_unified/mongos-unpin.yml +172 -0
- 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/auth-options.yml +36 -1
- data/spec/spec_tests/data/uri_options/compression-options.yml +7 -4
- data/spec/spec_tests/data/uri_options/connection-options.yml +43 -0
- data/spec/spec_tests/data/uri_options/read-preference-options.yml +24 -0
- data/spec/spec_tests/data/uri_options/ruby-auth-options.yml +12 -0
- data/spec/spec_tests/data/uri_options/ruby-connection-options.yml +58 -0
- data/spec/spec_tests/data/uri_options/tls-options.yml +233 -6
- data/spec/spec_tests/data/versioned_api/crud-api-version-1-strict.yml +417 -0
- data/spec/spec_tests/data/versioned_api/crud-api-version-1.yml +411 -0
- data/spec/spec_tests/data/versioned_api/runcommand-helper-no-api-version-declared.yml +75 -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 +46 -0
- data/spec/spec_tests/data/versioned_api/transaction-handling.yml +128 -0
- data/spec/spec_tests/dns_seedlist_discovery_spec.rb +32 -9
- data/spec/spec_tests/gridfs_spec.rb +5 -0
- data/spec/spec_tests/max_staleness_spec.rb +7 -135
- data/spec/spec_tests/read_write_concern_connection_string_spec.rb +13 -0
- data/spec/spec_tests/read_write_concern_document_spec.rb +77 -0
- data/spec/spec_tests/read_write_concern_operaton_spec.rb +13 -0
- data/spec/spec_tests/retryable_reads_spec.rb +7 -2
- data/spec/spec_tests/retryable_writes_spec.rb +11 -1
- data/spec/spec_tests/sdam_integration_spec.rb +16 -0
- data/spec/spec_tests/sdam_monitoring_spec.rb +15 -6
- data/spec/spec_tests/sdam_spec.rb +78 -9
- data/spec/spec_tests/server_selection_rtt_spec.rb +5 -0
- data/spec/spec_tests/server_selection_spec.rb +7 -110
- data/spec/spec_tests/transactions_api_spec.rb +8 -0
- data/spec/spec_tests/transactions_spec.rb +7 -1
- data/spec/spec_tests/transactions_unified_spec.rb +13 -0
- data/spec/spec_tests/unified_spec.rb +18 -0
- data/spec/spec_tests/uri_options_spec.rb +63 -42
- data/spec/spec_tests/versioned_api_spec.rb +13 -0
- data/spec/stress/cleanup_spec.rb +61 -0
- data/spec/stress/connection_pool_stress_spec.rb +204 -0
- data/spec/stress/connection_pool_timing_spec.rb +184 -0
- data/spec/stress/fork_reconnect_stress_spec.rb +112 -0
- data/spec/stress/push_monitor_close_spec.rb +44 -0
- data/spec/support/authorization.rb +4 -11
- data/spec/support/aws_utils/base.rb +137 -0
- data/spec/support/aws_utils/inspector.rb +227 -0
- data/spec/support/aws_utils/orchestrator.rb +373 -0
- data/spec/support/aws_utils/provisioner.rb +363 -0
- data/spec/support/aws_utils.rb +65 -0
- data/spec/support/background_thread_registry.rb +70 -0
- data/spec/support/certificates/README.md +7 -2
- data/spec/support/certificates/atlas-ocsp-ca.crt +118 -0
- data/spec/support/certificates/atlas-ocsp.crt +152 -0
- data/spec/support/certificates/client-x509.crt +78 -0
- data/spec/support/certificates/client-x509.key +27 -0
- data/spec/support/certificates/client-x509.pem +105 -0
- data/spec/support/certificates/server-second-level-bundle.pem +77 -77
- data/spec/support/certificates/server-second-level.crt +52 -52
- data/spec/support/certificates/server-second-level.key +25 -25
- data/spec/support/certificates/server-second-level.pem +77 -77
- data/spec/support/client_registry.rb +65 -37
- data/spec/support/client_registry_macros.rb +17 -5
- data/spec/support/cluster_tools.rb +15 -5
- data/spec/support/common_shortcuts.rb +239 -6
- data/spec/support/constraints.rb +9 -184
- data/spec/support/crypt/corpus/corpus-key-aws.json +33 -0
- data/spec/support/crypt/corpus/corpus-key-local.json +31 -0
- data/spec/support/crypt/corpus/corpus-schema.json +2057 -0
- data/spec/support/crypt/corpus/corpus.json +3657 -0
- data/spec/support/crypt/corpus/corpus_encrypted.json +4152 -0
- data/spec/support/crypt/data_keys/key_document_aws.json +34 -0
- data/spec/support/crypt/data_keys/key_document_local.json +31 -0
- data/spec/support/crypt/external/external-key.json +31 -0
- data/spec/support/crypt/external/external-schema.json +19 -0
- data/spec/support/crypt/limits/limits-doc.json +102 -0
- data/spec/support/crypt/limits/limits-key.json +31 -0
- data/spec/support/crypt/limits/limits-schema.json +1405 -0
- data/spec/support/crypt/schema_maps/schema_map_aws.json +17 -0
- data/spec/support/crypt/schema_maps/schema_map_aws_key_alt_names.json +12 -0
- data/spec/support/crypt/schema_maps/schema_map_local.json +18 -0
- data/spec/support/crypt/schema_maps/schema_map_local_key_alt_names.json +12 -0
- data/spec/support/crypt.rb +157 -0
- data/spec/support/dns.rb +16 -0
- data/spec/support/event_subscriber.rb +193 -84
- data/spec/support/json_ext_formatter.rb +8 -1
- data/spec/support/keyword_struct.rb +29 -0
- data/spec/support/local_resource_registry.rb +37 -0
- data/spec/support/matchers.rb +39 -1
- data/spec/support/monitoring_ext.rb +3 -0
- data/spec/support/ocsp +1 -0
- data/spec/support/primary_socket.rb +3 -0
- data/spec/support/sdam_formatter_integration.rb +3 -0
- data/spec/support/session_registry.rb +55 -0
- data/spec/support/shared/app_metadata.rb +167 -0
- data/spec/support/shared/protocol.rb +5 -0
- data/spec/support/shared/scram_conversation.rb +103 -0
- data/spec/support/shared/server_selector.rb +99 -4
- data/spec/support/shared/session.rb +34 -23
- data/spec/support/spec_config.rb +292 -56
- data/spec/support/spec_setup.rb +58 -36
- data/spec/support/utils.rb +446 -45
- data.tar.gz.sig +0 -0
- metadata +1626 -683
- metadata.gz.sig +0 -0
- data/lib/mongo/event/description_changed.rb +0 -52
- data/lib/mongo/operation/shared/op_msg_or_list_indexes_command.rb +0 -45
- data/lib/mongo/server/connectable.rb +0 -107
- data/spec/enterprise_auth/kerberos_spec.rb +0 -57
- data/spec/mongo/operation/read_preference_spec.rb +0 -245
- data/spec/spec_tests/data/sdam/sharded/single_mongos.yml +0 -33
- data/spec/support/change_streams/operation.rb +0 -89
- data/spec/support/change_streams.rb +0 -265
- data/spec/support/cluster_config.rb +0 -139
- data/spec/support/connection_string.rb +0 -326
- data/spec/support/crud/requirement.rb +0 -69
- data/spec/support/crud/test_base.rb +0 -22
- data/spec/support/lite_constraints.rb +0 -52
- data/spec/support/sdam_monitoring.rb +0 -89
- data/spec/support/server_selection.rb +0 -153
- data/spec/support/transactions/operation.rb +0 -184
- data/spec/support/transactions/test.rb +0 -252
data/lib/mongo/client.rb
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
#
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
# encoding: utf-8
|
|
3
|
+
|
|
4
|
+
# Copyright (C) 2014-2020 MongoDB Inc.
|
|
2
5
|
#
|
|
3
6
|
# Licensed under the Apache License, Version 2.0 (the 'License');
|
|
4
7
|
# you may not use this file except in compliance with the License.
|
|
@@ -27,6 +30,7 @@ module Mongo
|
|
|
27
30
|
#
|
|
28
31
|
# @since 2.1.0
|
|
29
32
|
CRUD_OPTIONS = [
|
|
33
|
+
:auto_encryption_options,
|
|
30
34
|
:database,
|
|
31
35
|
:read, :read_concern,
|
|
32
36
|
:write, :write_concern,
|
|
@@ -53,8 +57,11 @@ module Mongo
|
|
|
53
57
|
:auth_mech,
|
|
54
58
|
:auth_mech_properties,
|
|
55
59
|
:auth_source,
|
|
60
|
+
:auto_encryption_options,
|
|
61
|
+
:bg_error_backtrace,
|
|
56
62
|
:cleanup,
|
|
57
63
|
:compressors,
|
|
64
|
+
:direct_connection,
|
|
58
65
|
:connect,
|
|
59
66
|
:connect_timeout,
|
|
60
67
|
:database,
|
|
@@ -62,6 +69,7 @@ module Mongo
|
|
|
62
69
|
:id_generator,
|
|
63
70
|
:local_threshold,
|
|
64
71
|
:logger,
|
|
72
|
+
:log_prefix,
|
|
65
73
|
:max_idle_time,
|
|
66
74
|
:max_pool_size,
|
|
67
75
|
:max_read_retries,
|
|
@@ -75,10 +83,12 @@ module Mongo
|
|
|
75
83
|
:read_concern,
|
|
76
84
|
:read_retry_interval,
|
|
77
85
|
:replica_set,
|
|
86
|
+
:resolv_options,
|
|
78
87
|
:retry_reads,
|
|
79
88
|
:retry_writes,
|
|
80
89
|
:scan,
|
|
81
90
|
:sdam_proc,
|
|
91
|
+
:server_api,
|
|
82
92
|
:server_selection_timeout,
|
|
83
93
|
:socket_timeout,
|
|
84
94
|
:ssl,
|
|
@@ -95,9 +105,11 @@ module Mongo
|
|
|
95
105
|
:ssl_verify,
|
|
96
106
|
:ssl_verify_certificate,
|
|
97
107
|
:ssl_verify_hostname,
|
|
108
|
+
:ssl_verify_ocsp_endpoint,
|
|
98
109
|
:truncate_logs,
|
|
99
110
|
:user,
|
|
100
111
|
:wait_queue_timeout,
|
|
112
|
+
:wrapping_libraries,
|
|
101
113
|
:write,
|
|
102
114
|
:write_concern,
|
|
103
115
|
:zlib_compression_level,
|
|
@@ -106,7 +118,16 @@ module Mongo
|
|
|
106
118
|
# The compression algorithms supported by the driver.
|
|
107
119
|
#
|
|
108
120
|
# @since 2.5.0
|
|
109
|
-
VALID_COMPRESSORS = [
|
|
121
|
+
VALID_COMPRESSORS = [
|
|
122
|
+
Mongo::Protocol::Compressed::ZSTD,
|
|
123
|
+
Mongo::Protocol::Compressed::SNAPPY,
|
|
124
|
+
Mongo::Protocol::Compressed::ZLIB
|
|
125
|
+
].freeze
|
|
126
|
+
|
|
127
|
+
# The known server API versions.
|
|
128
|
+
VALID_SERVER_API_VERSIONS = %w(
|
|
129
|
+
1
|
|
130
|
+
).freeze
|
|
110
131
|
|
|
111
132
|
# @return [ Mongo::Cluster ] cluster The cluster of servers for the client.
|
|
112
133
|
attr_reader :cluster
|
|
@@ -117,6 +138,10 @@ module Mongo
|
|
|
117
138
|
# @return [ Hash ] options The configuration options.
|
|
118
139
|
attr_reader :options
|
|
119
140
|
|
|
141
|
+
# @return [ Mongo::Crypt::AutoEncrypter ] The object that encapsulates
|
|
142
|
+
# auto-encryption behavior
|
|
143
|
+
attr_reader :encrypter
|
|
144
|
+
|
|
120
145
|
# Delegate command and collections execution to the current database.
|
|
121
146
|
def_delegators :@database, :command, :collections
|
|
122
147
|
|
|
@@ -197,7 +222,6 @@ module Mongo
|
|
|
197
222
|
# connection string is also provided, these options take precedence over any
|
|
198
223
|
# analogous options present in the URI string.
|
|
199
224
|
#
|
|
200
|
-
#
|
|
201
225
|
# @option options [ String, Symbol ] :app_name Application name that is
|
|
202
226
|
# printed to the mongod logs upon establishing a connection in server
|
|
203
227
|
# versions >= 3.4.
|
|
@@ -205,23 +229,34 @@ module Mongo
|
|
|
205
229
|
# use. One of :mongodb_cr, :mongodb_x509, :plain, :scram, :scram256
|
|
206
230
|
# @option options [ Hash ] :auth_mech_properties
|
|
207
231
|
# @option options [ String ] :auth_source The source to authenticate from.
|
|
232
|
+
# @option options [ true | false | nil | Integer ] :bg_error_backtrace
|
|
233
|
+
# Experimental. Set to true to log complete backtraces for errors in
|
|
234
|
+
# background threads. Set to false or nil to not log backtraces. Provide
|
|
235
|
+
# a positive integer to log up to that many backtrace lines.
|
|
208
236
|
# @option options [ Array<String> ] :compressors A list of potential
|
|
209
237
|
# compressors to use, in order of preference. The driver chooses the
|
|
210
238
|
# first compressor that is also supported by the server. Currently the
|
|
211
|
-
# driver only supports 'zlib'.
|
|
212
|
-
# @option options [
|
|
239
|
+
# driver only supports 'zstd, 'snappy' and 'zlib'.
|
|
240
|
+
# @option options [ true | false ] :direct_connection Whether to connect
|
|
241
|
+
# directly to the specified seed, bypassing topology discovery. Exactly
|
|
242
|
+
# one seed must be provided.
|
|
243
|
+
# @option options [ Symbol ] :connect Deprecated - use :direct_connection
|
|
244
|
+
# option instead of this option. The connection method to use. This
|
|
213
245
|
# forces the cluster to behave in the specified way instead of
|
|
214
246
|
# auto-discovering. One of :direct, :replica_set, :sharded
|
|
215
247
|
# @option options [ Float ] :connect_timeout The timeout, in seconds, to
|
|
216
248
|
# attempt a connection.
|
|
217
249
|
# @option options [ String ] :database The database to connect to.
|
|
218
|
-
# @option options [ Float ] :heartbeat_frequency The
|
|
219
|
-
# the server monitor to refresh
|
|
250
|
+
# @option options [ Float ] :heartbeat_frequency The interval, in seconds,
|
|
251
|
+
# for the server monitor to refresh its description via hello.
|
|
220
252
|
# @option options [ Object ] :id_generator A custom object to generate ids
|
|
221
253
|
# for documents. Must respond to #generate.
|
|
222
254
|
# @option options [ Integer ] :local_threshold The local threshold boundary
|
|
223
255
|
# in seconds for selecting a near server for an operation.
|
|
224
|
-
# @option options [ Logger ] :logger A custom logger
|
|
256
|
+
# @option options [ Logger ] :logger A custom logger to use.
|
|
257
|
+
# @option options [ String ] :log_prefix A custom log prefix to use when
|
|
258
|
+
# logging. This option is experimental and subject to change in a future
|
|
259
|
+
# version of the driver.
|
|
225
260
|
# @option options [ Integer ] :max_idle_time The maximum seconds a socket can remain idle
|
|
226
261
|
# since it has been checked in to the pool.
|
|
227
262
|
# @option options [ Integer ] :max_pool_size The maximum size of the
|
|
@@ -283,18 +318,23 @@ module Mongo
|
|
|
283
318
|
# will ignore it and will never scan seeds in the constructor.
|
|
284
319
|
# @option options [ Proc ] :sdam_proc A Proc to invoke with the client
|
|
285
320
|
# as the argument prior to performing server discovery and monitoring.
|
|
286
|
-
# Use this to set up SDAM event listeners to receive events
|
|
321
|
+
# Use this to set up SDAM event listeners to receive events published
|
|
287
322
|
# during client construction.
|
|
288
323
|
#
|
|
289
324
|
# Note: the client is not fully constructed when sdam_proc is invoked,
|
|
290
325
|
# in particular the cluster is nil at this time. sdam_proc should
|
|
291
326
|
# limit itself to calling #subscribe and #unsubscribe methods on the
|
|
292
327
|
# client only.
|
|
328
|
+
# @option options [ Hash ] :server_api The requested server API version.
|
|
329
|
+
# This hash can have the following items:
|
|
330
|
+
# - *:version* -- string
|
|
331
|
+
# - *:strict* -- boolean
|
|
332
|
+
# - *:deprecation_errors* -- boolean
|
|
293
333
|
# @option options [ Integer ] :server_selection_timeout The timeout in seconds
|
|
294
334
|
# for selecting a server for an operation.
|
|
295
335
|
# @option options [ Float ] :socket_timeout The timeout, in seconds, to
|
|
296
336
|
# execute operations on a socket.
|
|
297
|
-
# @option options [ true, false ] :ssl Whether to use
|
|
337
|
+
# @option options [ true, false ] :ssl Whether to use TLS.
|
|
298
338
|
# @option options [ String ] :ssl_ca_cert The file containing concatenated
|
|
299
339
|
# certificate authority certificates used to validate certs passed from the
|
|
300
340
|
# other end of the connection. Intermediate certificates should NOT be
|
|
@@ -355,23 +395,70 @@ module Mongo
|
|
|
355
395
|
# @option options [ String ] :user The user name.
|
|
356
396
|
# @option options [ Float ] :wait_queue_timeout The time to wait, in
|
|
357
397
|
# seconds, in the connection pool for a connection to be checked in.
|
|
398
|
+
# @option options [ Array<Hash> ] :wrapping_libraries Information about
|
|
399
|
+
# libraries such as ODMs that are wrapping the driver, to be added to
|
|
400
|
+
# metadata sent to the server. Specify the lower level libraries first.
|
|
401
|
+
# Allowed hash keys: :name, :version, :platform.
|
|
358
402
|
# @option options [ Hash ] :write Deprecated. Equivalent to :write_concern
|
|
359
403
|
# option.
|
|
360
404
|
# @option options [ Hash ] :write_concern The write concern options.
|
|
361
|
-
# Can be :w => Integer|String, :
|
|
405
|
+
# Can be :w => Integer|String, :wtimeout => Integer (in milliseconds),
|
|
406
|
+
# :j => Boolean, :fsync => Boolean.
|
|
362
407
|
# @option options [ Integer ] :zlib_compression_level The Zlib compression level to use, if using compression.
|
|
363
408
|
# See Ruby's Zlib module for valid levels.
|
|
409
|
+
# @option options [ Hash ] :resolv_options For internal driver use only.
|
|
410
|
+
# Options to pass through to Resolv::DNS constructor for SRV lookups.
|
|
411
|
+
# @option options [ Hash ] :auto_encryption_options Auto-encryption related
|
|
412
|
+
# options.
|
|
413
|
+
# - :key_vault_client => Client | nil, a client connected to the MongoDB
|
|
414
|
+
# instance containing the encryption key vault
|
|
415
|
+
# - :key_vault_namespace => String, the namespace of the key vault in the
|
|
416
|
+
# format database.collection
|
|
417
|
+
# - :kms_providers => Hash, A hash of key management service configuration
|
|
418
|
+
# information. Valid hash keys are :local or :aws. There may be more
|
|
419
|
+
# than one kms provider specified.
|
|
420
|
+
# - :schema_map => Hash | nil, JSONSchema for one or more collections
|
|
421
|
+
# specifying which fields should be encrypted.
|
|
422
|
+
# - Note: Schemas supplied in the schema_map only apply to configuring
|
|
423
|
+
# automatic encryption for client side encryption. Other validation
|
|
424
|
+
# rules in the JSON schema will not be enforced by the driver and will
|
|
425
|
+
# result in an error.
|
|
426
|
+
# - Note: Supplying a schema_map provides more security than relying on
|
|
427
|
+
# JSON Schemas obtained from the server. It protects against a
|
|
428
|
+
# malicious server advertising a false JSON Schema, which could trick
|
|
429
|
+
# the client into sending unencrypted data that should be encrypted.
|
|
430
|
+
# - :bypass_auto_encryption => Boolean, when true, disables auto encryption;
|
|
431
|
+
# defaults to false.
|
|
432
|
+
# - :extra_options => Hash | nil, options related to spawning mongocryptd
|
|
433
|
+
# (this part of the API is subject to change).
|
|
434
|
+
#
|
|
435
|
+
# Notes on automatic encryption:
|
|
436
|
+
# - Automatic encryption is an enterprise only feature that only applies
|
|
437
|
+
# to operations on a collection.
|
|
438
|
+
# - Automatic encryption is not supported for operations on a database or
|
|
439
|
+
# view.
|
|
440
|
+
# - Automatic encryption requires the authenticated user to have the
|
|
441
|
+
# listCollections privilege.
|
|
442
|
+
# - At worst, automatic encryption may triple the number of connections
|
|
443
|
+
# used by the Client at any one time.
|
|
444
|
+
# - If automatic encryption fails on an operation, use a MongoClient
|
|
445
|
+
# configured with bypass_auto_encryption: true and use
|
|
446
|
+
# ClientEncryption.encrypt to manually encrypt values.
|
|
447
|
+
# - Enabling Client Side Encryption reduces the maximum write batch size
|
|
448
|
+
# and may have a negative performance impact.
|
|
364
449
|
#
|
|
365
450
|
# @since 2.0.0
|
|
366
451
|
def initialize(addresses_or_uri, options = nil)
|
|
367
|
-
|
|
368
|
-
options = options.dup
|
|
369
|
-
else
|
|
370
|
-
options = {}
|
|
371
|
-
end
|
|
452
|
+
options = options ? options.dup : {}
|
|
372
453
|
|
|
454
|
+
srv_uri = nil
|
|
373
455
|
if addresses_or_uri.is_a?(::String)
|
|
374
456
|
uri = URI.get(addresses_or_uri, options)
|
|
457
|
+
if uri.is_a?(URI::SRVProtocol)
|
|
458
|
+
# If the URI is an SRV URI, note this so that we can start
|
|
459
|
+
# SRV polling if the topology is a sharded cluster.
|
|
460
|
+
srv_uri = uri
|
|
461
|
+
end
|
|
375
462
|
addresses = uri.servers
|
|
376
463
|
uri_options = uri.client_options.dup
|
|
377
464
|
# Special handing for :write and :write_concern: allow client Ruby
|
|
@@ -382,22 +469,55 @@ module Mongo
|
|
|
382
469
|
uri_options.delete(:write_concern)
|
|
383
470
|
end
|
|
384
471
|
options = uri_options.merge(options)
|
|
472
|
+
@srv_records = uri.srv_records
|
|
385
473
|
else
|
|
386
474
|
addresses = addresses_or_uri
|
|
387
|
-
|
|
475
|
+
addresses.each do |addr|
|
|
476
|
+
if addr =~ /\Amongodb(\+srv)?:\/\//i
|
|
477
|
+
raise ArgumentError, "Host '#{addr}' should not contain protocol. Did you mean to not use an array?"
|
|
478
|
+
end
|
|
479
|
+
end
|
|
388
480
|
|
|
389
|
-
|
|
390
|
-
options[:retry_reads] = true
|
|
481
|
+
@srv_records = nil
|
|
391
482
|
end
|
|
392
|
-
|
|
393
|
-
|
|
483
|
+
|
|
484
|
+
options = self.class.canonicalize_ruby_options(options)
|
|
485
|
+
|
|
486
|
+
# The server API version is specified to be a string.
|
|
487
|
+
# However, it is very annoying to always provide the number 1 as a string,
|
|
488
|
+
# therefore cast to the string type here.
|
|
489
|
+
if server_api = options[:server_api]
|
|
490
|
+
if server_api.is_a?(Hash)
|
|
491
|
+
server_api = Options::Redacted.new(server_api)
|
|
492
|
+
if (version = server_api[:version]).is_a?(Integer)
|
|
493
|
+
options[:server_api] = server_api.merge(version: version.to_s)
|
|
494
|
+
end
|
|
495
|
+
end
|
|
394
496
|
end
|
|
395
497
|
|
|
396
498
|
# Special handling for sdam_proc as it is only used during client
|
|
397
499
|
# construction
|
|
398
500
|
sdam_proc = options.delete(:sdam_proc)
|
|
399
501
|
|
|
400
|
-
|
|
502
|
+
# For gssapi service_name, the default option is given in a hash
|
|
503
|
+
# (one level down from the top level).
|
|
504
|
+
merged_options = default_options(options)
|
|
505
|
+
options.each do |k, v|
|
|
506
|
+
default_v = merged_options[k]
|
|
507
|
+
if Hash === default_v
|
|
508
|
+
v = default_v.merge(v)
|
|
509
|
+
end
|
|
510
|
+
merged_options[k] = v
|
|
511
|
+
end
|
|
512
|
+
options = merged_options
|
|
513
|
+
|
|
514
|
+
options.keys.each do |k|
|
|
515
|
+
if options[k].nil?
|
|
516
|
+
options.delete(k)
|
|
517
|
+
end
|
|
518
|
+
end
|
|
519
|
+
|
|
520
|
+
@options = validate_new_options!(options)
|
|
401
521
|
=begin WriteConcern object support
|
|
402
522
|
if @options[:write_concern].is_a?(WriteConcern::Base)
|
|
403
523
|
# Cache the instance so that we do not needlessly reconstruct it.
|
|
@@ -406,9 +526,12 @@ module Mongo
|
|
|
406
526
|
end
|
|
407
527
|
=end
|
|
408
528
|
@options.freeze
|
|
409
|
-
validate_options!
|
|
529
|
+
validate_options!(addresses)
|
|
530
|
+
validate_authentication_options!
|
|
410
531
|
|
|
411
|
-
|
|
532
|
+
database_options = @options.dup
|
|
533
|
+
database_options.delete(:server_api)
|
|
534
|
+
@database = Database.new(self, @options[:database], database_options)
|
|
412
535
|
|
|
413
536
|
# Temporarily set monitoring so that event subscriptions can be
|
|
414
537
|
# set up without there being a cluster
|
|
@@ -418,13 +541,39 @@ module Mongo
|
|
|
418
541
|
sdam_proc.call(self)
|
|
419
542
|
end
|
|
420
543
|
|
|
421
|
-
@
|
|
422
|
-
@
|
|
544
|
+
@connect_lock = Mutex.new
|
|
545
|
+
@connect_lock.synchronize do
|
|
546
|
+
@cluster = Cluster.new(addresses, @monitoring,
|
|
547
|
+
cluster_options.merge(srv_uri: srv_uri))
|
|
548
|
+
end
|
|
423
549
|
|
|
424
|
-
|
|
425
|
-
|
|
550
|
+
begin
|
|
551
|
+
# Unset monitoring, it will be taken out of cluster from now on
|
|
552
|
+
remove_instance_variable('@monitoring')
|
|
426
553
|
|
|
427
|
-
|
|
554
|
+
if @options[:auto_encryption_options]
|
|
555
|
+
@connect_lock.synchronize do
|
|
556
|
+
build_encrypter
|
|
557
|
+
end
|
|
558
|
+
end
|
|
559
|
+
|
|
560
|
+
rescue
|
|
561
|
+
begin
|
|
562
|
+
@cluster.disconnect!
|
|
563
|
+
rescue => e
|
|
564
|
+
log_warn("Eror disconnecting cluster in client constructor's exception handler: #{e.class}: #{e}")
|
|
565
|
+
# Drop this exception so that the original exception is raised
|
|
566
|
+
end
|
|
567
|
+
raise
|
|
568
|
+
end
|
|
569
|
+
|
|
570
|
+
if block_given?
|
|
571
|
+
begin
|
|
572
|
+
yield(self)
|
|
573
|
+
ensure
|
|
574
|
+
close
|
|
575
|
+
end
|
|
576
|
+
end
|
|
428
577
|
end
|
|
429
578
|
|
|
430
579
|
# @api private
|
|
@@ -435,7 +584,6 @@ module Mongo
|
|
|
435
584
|
options.reject do |key, value|
|
|
436
585
|
CRUD_OPTIONS.include?(key.to_sym)
|
|
437
586
|
end.merge(
|
|
438
|
-
server_selection_semaphore: @server_selection_semaphore,
|
|
439
587
|
# but need to put the database back in for auth...
|
|
440
588
|
database: options[:database],
|
|
441
589
|
|
|
@@ -444,7 +592,14 @@ module Mongo
|
|
|
444
592
|
# applications should read these values from client, not from cluster
|
|
445
593
|
max_read_retries: options[:max_read_retries],
|
|
446
594
|
read_retry_interval: options[:read_retry_interval],
|
|
447
|
-
)
|
|
595
|
+
).tap do |options|
|
|
596
|
+
# If the client has a cluster already, forward srv_uri to the new
|
|
597
|
+
# cluster to maintain SRV monitoring. If the client is brand new,
|
|
598
|
+
# its constructor sets srv_uri manually.
|
|
599
|
+
if cluster
|
|
600
|
+
options.update(srv_uri: cluster.options[:srv_uri])
|
|
601
|
+
end
|
|
602
|
+
end
|
|
448
603
|
end
|
|
449
604
|
|
|
450
605
|
# Get the maximum number of times the client can retry a read operation
|
|
@@ -491,15 +646,12 @@ module Mongo
|
|
|
491
646
|
|
|
492
647
|
# Get a summary of the client state.
|
|
493
648
|
#
|
|
494
|
-
# @note
|
|
649
|
+
# @note The exact format and layout of the returned summary string is
|
|
650
|
+
# not part of the driver's public API and may be changed at any time.
|
|
495
651
|
#
|
|
496
|
-
# @
|
|
497
|
-
# client.summary
|
|
498
|
-
#
|
|
499
|
-
# @return [ String ] Summary string.
|
|
652
|
+
# @return [ String ] The summary string.
|
|
500
653
|
#
|
|
501
654
|
# @since 2.7.0
|
|
502
|
-
# @api experimental
|
|
503
655
|
def summary
|
|
504
656
|
"#<Client cluster=#{cluster.summary}>"
|
|
505
657
|
end
|
|
@@ -529,7 +681,7 @@ module Mongo
|
|
|
529
681
|
#
|
|
530
682
|
# @return [ BSON::Document ] The user-defined read preference.
|
|
531
683
|
# The document may have the following fields:
|
|
532
|
-
# - *:
|
|
684
|
+
# - *:mode* -- read preference specified as a symbol; valid values are
|
|
533
685
|
# *:primary*, *:primary_preferred*, *:secondary*, *:secondary_preferred*
|
|
534
686
|
# and *:nearest*.
|
|
535
687
|
# - *:tag_sets* -- an array of hashes.
|
|
@@ -577,9 +729,9 @@ module Mongo
|
|
|
577
729
|
# @return [ Mongo::Client ] A new client instance.
|
|
578
730
|
#
|
|
579
731
|
# @since 2.0.0
|
|
580
|
-
def with(new_options =
|
|
732
|
+
def with(new_options = nil)
|
|
581
733
|
clone.tap do |client|
|
|
582
|
-
opts = client.update_options(new_options)
|
|
734
|
+
opts = client.update_options(new_options || Options::Redacted.new)
|
|
583
735
|
Database.create(client)
|
|
584
736
|
# We can't use the same cluster if some options that would affect it
|
|
585
737
|
# have changed.
|
|
@@ -604,6 +756,10 @@ module Mongo
|
|
|
604
756
|
#
|
|
605
757
|
# @api private
|
|
606
758
|
def update_options(new_options)
|
|
759
|
+
old_options = @options
|
|
760
|
+
|
|
761
|
+
new_options = self.class.canonicalize_ruby_options(new_options || {})
|
|
762
|
+
|
|
607
763
|
validate_new_options!(new_options).tap do |opts|
|
|
608
764
|
# Our options are frozen
|
|
609
765
|
options = @options.dup
|
|
@@ -613,9 +769,31 @@ module Mongo
|
|
|
613
769
|
if options[:write_concern] && opts[:write]
|
|
614
770
|
options.delete(:write_concern)
|
|
615
771
|
end
|
|
772
|
+
|
|
616
773
|
options.update(opts)
|
|
617
774
|
@options = options.freeze
|
|
775
|
+
|
|
776
|
+
auto_encryption_options_changed =
|
|
777
|
+
@options[:auto_encryption_options] != old_options[:auto_encryption_options]
|
|
778
|
+
|
|
779
|
+
# If there are new auto_encryption_options, create a new encrypter.
|
|
780
|
+
# Otherwise, allow the new client to share an encrypter with the
|
|
781
|
+
# original client.
|
|
782
|
+
#
|
|
783
|
+
# If auto_encryption_options are nil, set @encrypter to nil, but do not
|
|
784
|
+
# close the encrypter because it may still be used by the original client.
|
|
785
|
+
if @options[:auto_encryption_options] && auto_encryption_options_changed
|
|
786
|
+
@connect_lock.synchronize do
|
|
787
|
+
build_encrypter
|
|
788
|
+
end
|
|
789
|
+
elsif @options[:auto_encryption_options].nil?
|
|
790
|
+
@connect_lock.synchronize do
|
|
791
|
+
@encrypter = nil
|
|
792
|
+
end
|
|
793
|
+
end
|
|
794
|
+
|
|
618
795
|
validate_options!
|
|
796
|
+
validate_authentication_options!
|
|
619
797
|
end
|
|
620
798
|
end
|
|
621
799
|
|
|
@@ -631,7 +809,6 @@ module Mongo
|
|
|
631
809
|
options[:read_concern]
|
|
632
810
|
end
|
|
633
811
|
|
|
634
|
-
|
|
635
812
|
# Get the write concern for this client. If no option was provided, then a
|
|
636
813
|
# default single server acknowledgement will be used.
|
|
637
814
|
#
|
|
@@ -647,17 +824,22 @@ module Mongo
|
|
|
647
824
|
|
|
648
825
|
# Close all connections.
|
|
649
826
|
#
|
|
650
|
-
# @example Disconnect the client.
|
|
651
|
-
# client.close
|
|
652
|
-
#
|
|
653
|
-
# @param [ Boolean ] wait Whether to wait for background threads to
|
|
654
|
-
# finish running.
|
|
655
|
-
#
|
|
656
827
|
# @return [ true ] Always true.
|
|
657
828
|
#
|
|
658
829
|
# @since 2.1.0
|
|
659
|
-
def close
|
|
660
|
-
@
|
|
830
|
+
def close
|
|
831
|
+
@connect_lock.synchronize do
|
|
832
|
+
do_close
|
|
833
|
+
end
|
|
834
|
+
true
|
|
835
|
+
end
|
|
836
|
+
|
|
837
|
+
# Close encrypter and clean up auto-encryption resources.
|
|
838
|
+
#
|
|
839
|
+
# @return [ true ] Always true.
|
|
840
|
+
def close_encrypter
|
|
841
|
+
@encrypter.close if @encrypter
|
|
842
|
+
|
|
661
843
|
true
|
|
662
844
|
end
|
|
663
845
|
|
|
@@ -672,9 +854,16 @@ module Mongo
|
|
|
672
854
|
def reconnect
|
|
673
855
|
addresses = cluster.addresses.map(&:to_s)
|
|
674
856
|
|
|
675
|
-
@
|
|
857
|
+
@connect_lock.synchronize do
|
|
858
|
+
do_close rescue nil
|
|
859
|
+
|
|
860
|
+
@cluster = Cluster.new(addresses, monitoring, cluster_options)
|
|
861
|
+
|
|
862
|
+
if @options[:auto_encryption_options]
|
|
863
|
+
build_encrypter
|
|
864
|
+
end
|
|
865
|
+
end
|
|
676
866
|
|
|
677
|
-
@cluster = Cluster.new(addresses, monitoring, cluster_options)
|
|
678
867
|
true
|
|
679
868
|
end
|
|
680
869
|
|
|
@@ -686,6 +875,13 @@ module Mongo
|
|
|
686
875
|
# @param [ Hash ] filter The filter criteria for getting a list of databases.
|
|
687
876
|
# @param [ Hash ] opts The command options.
|
|
688
877
|
#
|
|
878
|
+
# @option opts [ true, false ] :authorized_databases A flag that determines
|
|
879
|
+
# which databases are returned based on user privileges when access control
|
|
880
|
+
# is enabled
|
|
881
|
+
#
|
|
882
|
+
# See https://docs.mongodb.com/manual/reference/command/listDatabases/
|
|
883
|
+
# for more information and usage.
|
|
884
|
+
#
|
|
689
885
|
# @return [ Array<String> ] The names of the databases.
|
|
690
886
|
#
|
|
691
887
|
# @since 2.0.5
|
|
@@ -702,6 +898,13 @@ module Mongo
|
|
|
702
898
|
# @param [ true, false ] name_only Whether to only return each database name without full metadata.
|
|
703
899
|
# @param [ Hash ] opts The command options.
|
|
704
900
|
#
|
|
901
|
+
# @option opts [ true, false ] :authorized_databases A flag that determines
|
|
902
|
+
# which databases are returned based on user privileges when access control
|
|
903
|
+
# is enabled
|
|
904
|
+
#
|
|
905
|
+
# See https://docs.mongodb.com/manual/reference/command/listDatabases/
|
|
906
|
+
# for more information and usage.
|
|
907
|
+
#
|
|
705
908
|
# @return [ Array<Hash> ] The info for each database.
|
|
706
909
|
#
|
|
707
910
|
# @since 2.0.5
|
|
@@ -709,6 +912,7 @@ module Mongo
|
|
|
709
912
|
cmd = { listDatabases: 1 }
|
|
710
913
|
cmd[:nameOnly] = !!name_only
|
|
711
914
|
cmd[:filter] = filter unless filter.empty?
|
|
915
|
+
cmd[:authorizedDatabases] = true if opts[:authorized_databases]
|
|
712
916
|
use(Database::ADMIN).database.read_command(cmd, opts).first[Database::DATABASES]
|
|
713
917
|
end
|
|
714
918
|
|
|
@@ -749,8 +953,16 @@ module Mongo
|
|
|
749
953
|
#
|
|
750
954
|
# @since 2.5.0
|
|
751
955
|
def start_session(options = {})
|
|
752
|
-
|
|
753
|
-
|
|
956
|
+
session = get_session!(options.merge(implicit: false))
|
|
957
|
+
if block_given?
|
|
958
|
+
begin
|
|
959
|
+
yield session
|
|
960
|
+
ensure
|
|
961
|
+
session.end_session
|
|
962
|
+
end
|
|
963
|
+
else
|
|
964
|
+
session
|
|
965
|
+
end
|
|
754
966
|
end
|
|
755
967
|
|
|
756
968
|
# As of version 3.6 of the MongoDB server, a ``$changeStream`` pipeline stage is supported
|
|
@@ -796,21 +1008,136 @@ module Mongo
|
|
|
796
1008
|
options)
|
|
797
1009
|
end
|
|
798
1010
|
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
# If
|
|
802
|
-
#
|
|
803
|
-
#
|
|
804
|
-
#
|
|
1011
|
+
# Returns a session to use for operations if possible.
|
|
1012
|
+
#
|
|
1013
|
+
# If :session option is set, validates that session and returns it.
|
|
1014
|
+
# Otherwise, if deployment supports sessions, creates a new session and
|
|
1015
|
+
# returns it. When a new session is created, the session will be implicit
|
|
1016
|
+
# (lifecycle is managed by the driver) if the :implicit option is given,
|
|
1017
|
+
# otherwise the session will be explicit (lifecycle managed by the
|
|
1018
|
+
# application). If deployment does not support session, returns nil.
|
|
1019
|
+
#
|
|
1020
|
+
# @option options [ true | false ] :implicit When no session is passed in,
|
|
1021
|
+
# whether to create an implicit session.
|
|
1022
|
+
# @option options [ Session ] :session The session to validate and return.
|
|
805
1023
|
#
|
|
806
|
-
# @
|
|
807
|
-
#
|
|
1024
|
+
# @return [ Session | nil ] Session object or nil if sessions are not
|
|
1025
|
+
# supported by the deployment.
|
|
1026
|
+
#
|
|
1027
|
+
# @api private
|
|
808
1028
|
def get_session(options = {})
|
|
809
|
-
|
|
1029
|
+
get_session!(options)
|
|
1030
|
+
rescue Error::SessionsNotSupported
|
|
1031
|
+
nil
|
|
810
1032
|
end
|
|
811
1033
|
|
|
1034
|
+
# Creates a session to use for operations if possible and yields it to
|
|
1035
|
+
# the provided block.
|
|
1036
|
+
#
|
|
1037
|
+
# If :session option is set, validates that session and uses it.
|
|
1038
|
+
# Otherwise, if deployment supports sessions, creates a new session and
|
|
1039
|
+
# uses it. When a new session is created, the session will be implicit
|
|
1040
|
+
# (lifecycle is managed by the driver) if the :implicit option is given,
|
|
1041
|
+
# otherwise the session will be explicit (lifecycle managed by the
|
|
1042
|
+
# application). If deployment does not support session, yields nil to
|
|
1043
|
+
# the block.
|
|
1044
|
+
#
|
|
1045
|
+
# When the block finishes, if the session was created and was implicit,
|
|
1046
|
+
# or if an implicit session was passed in, the session is ended which
|
|
1047
|
+
# returns it to the pool of available sessions.
|
|
1048
|
+
#
|
|
1049
|
+
# @option options [ true | false ] :implicit When no session is passed in,
|
|
1050
|
+
# whether to create an implicit session.
|
|
1051
|
+
# @option options [ Session ] :session The session to validate and return.
|
|
1052
|
+
#
|
|
1053
|
+
# @api private
|
|
812
1054
|
def with_session(options = {}, &block)
|
|
813
|
-
|
|
1055
|
+
session = get_session(options)
|
|
1056
|
+
|
|
1057
|
+
yield session
|
|
1058
|
+
ensure
|
|
1059
|
+
if session && session.implicit?
|
|
1060
|
+
session.end_session
|
|
1061
|
+
end
|
|
1062
|
+
end
|
|
1063
|
+
|
|
1064
|
+
class << self
|
|
1065
|
+
# Lowercases auth mechanism properties, if given, in the specified
|
|
1066
|
+
# options, then converts the options to an instance of Options::Redacted.
|
|
1067
|
+
#
|
|
1068
|
+
# @api private
|
|
1069
|
+
def canonicalize_ruby_options(options)
|
|
1070
|
+
Options::Redacted.new(Hash[options.map do |k, v|
|
|
1071
|
+
if k == :auth_mech_properties || k == 'auth_mech_properties'
|
|
1072
|
+
if v
|
|
1073
|
+
v = Hash[v.map { |pk, pv| [pk.downcase, pv] }]
|
|
1074
|
+
end
|
|
1075
|
+
end
|
|
1076
|
+
[k, v]
|
|
1077
|
+
end])
|
|
1078
|
+
end
|
|
1079
|
+
end
|
|
1080
|
+
|
|
1081
|
+
private
|
|
1082
|
+
|
|
1083
|
+
# Create a new encrypter object using the client's auto encryption options
|
|
1084
|
+
def build_encrypter
|
|
1085
|
+
@encrypter = Crypt::AutoEncrypter.new(
|
|
1086
|
+
@options[:auto_encryption_options].merge(client: self)
|
|
1087
|
+
)
|
|
1088
|
+
end
|
|
1089
|
+
|
|
1090
|
+
# Generate default client options based on the URI and options
|
|
1091
|
+
# passed into the Client constructor.
|
|
1092
|
+
def default_options(options)
|
|
1093
|
+
Database::DEFAULT_OPTIONS.dup.tap do |default_options|
|
|
1094
|
+
if options[:auth_mech] || options[:user]
|
|
1095
|
+
default_options[:auth_source] = Auth::User.default_auth_source(options)
|
|
1096
|
+
end
|
|
1097
|
+
|
|
1098
|
+
if options[:auth_mech] == :gssapi
|
|
1099
|
+
default_options[:auth_mech_properties] = { service_name: 'mongodb' }
|
|
1100
|
+
end
|
|
1101
|
+
|
|
1102
|
+
default_options[:retry_reads] = true
|
|
1103
|
+
default_options[:retry_writes] = true
|
|
1104
|
+
end
|
|
1105
|
+
end
|
|
1106
|
+
|
|
1107
|
+
# Implementation for #close, assumes the connect lock is already acquired.
|
|
1108
|
+
def do_close
|
|
1109
|
+
@cluster.disconnect!
|
|
1110
|
+
close_encrypter
|
|
1111
|
+
end
|
|
1112
|
+
|
|
1113
|
+
# Returns a session to use for operations.
|
|
1114
|
+
#
|
|
1115
|
+
# If :session option is set, validates that session and returns it.
|
|
1116
|
+
# Otherwise, if deployment supports sessions, creates a new session and
|
|
1117
|
+
# returns it. When a new session is created, the session will be implicit
|
|
1118
|
+
# (lifecycle is managed by the driver) if the :implicit option is given,
|
|
1119
|
+
# otherwise the session will be explicit (lifecycle managed by the
|
|
1120
|
+
# application). If deployment does not support session, raises
|
|
1121
|
+
# Error::InvalidSession.
|
|
1122
|
+
#
|
|
1123
|
+
# @option options [ true | false ] :implicit When no session is passed in,
|
|
1124
|
+
# whether to create an implicit session.
|
|
1125
|
+
# @option options [ Session ] :session The session to validate and return.
|
|
1126
|
+
#
|
|
1127
|
+
# @return [ Session ] A session object.
|
|
1128
|
+
#
|
|
1129
|
+
# @raise Error::SessionsNotSupported if sessions are not supported by
|
|
1130
|
+
# the deployment.
|
|
1131
|
+
#
|
|
1132
|
+
# @api private
|
|
1133
|
+
def get_session!(options = {})
|
|
1134
|
+
if options[:session]
|
|
1135
|
+
return options[:session].validate!(self)
|
|
1136
|
+
end
|
|
1137
|
+
|
|
1138
|
+
cluster.validate_session_support!
|
|
1139
|
+
|
|
1140
|
+
Session.new(cluster.session_pool.checkout, self, { implicit: true }.merge(options))
|
|
814
1141
|
end
|
|
815
1142
|
|
|
816
1143
|
def initialize_copy(original)
|
|
@@ -834,8 +1161,42 @@ module Mongo
|
|
|
834
1161
|
# The argument may contain a subset of options that the client will
|
|
835
1162
|
# eventually have; this method validates each of the provided options
|
|
836
1163
|
# but does not check for interactions between combinations of options.
|
|
837
|
-
def validate_new_options!(opts
|
|
1164
|
+
def validate_new_options!(opts)
|
|
838
1165
|
return Options::Redacted.new unless opts
|
|
1166
|
+
if opts[:read_concern]
|
|
1167
|
+
# Raise an error for non user-settable options
|
|
1168
|
+
if opts[:read_concern][:after_cluster_time]
|
|
1169
|
+
raise Mongo::Error::InvalidReadConcern.new(
|
|
1170
|
+
'The after_cluster_time read_concern option cannot be specified by the user'
|
|
1171
|
+
)
|
|
1172
|
+
end
|
|
1173
|
+
|
|
1174
|
+
given_keys = opts[:read_concern].keys.map(&:to_s)
|
|
1175
|
+
allowed_keys = ['level']
|
|
1176
|
+
invalid_keys = given_keys - allowed_keys
|
|
1177
|
+
# Warn that options are invalid but keep it and forward to the server
|
|
1178
|
+
unless invalid_keys.empty?
|
|
1179
|
+
log_warn("Read concern has invalid keys: #{invalid_keys.join(',')}.")
|
|
1180
|
+
end
|
|
1181
|
+
end
|
|
1182
|
+
|
|
1183
|
+
if server_api = opts[:server_api]
|
|
1184
|
+
unless server_api.is_a?(Hash)
|
|
1185
|
+
raise ArgumentError, ":server_api value must be a hash: #{server_api}"
|
|
1186
|
+
end
|
|
1187
|
+
|
|
1188
|
+
extra_keys = server_api.keys - %w(version strict deprecation_errors)
|
|
1189
|
+
unless extra_keys.empty?
|
|
1190
|
+
raise ArgumentError, "Unknown keys under :server_api: #{extra_keys.map(&:inspect).join(', ')}"
|
|
1191
|
+
end
|
|
1192
|
+
|
|
1193
|
+
if version = server_api[:version]
|
|
1194
|
+
unless VALID_SERVER_API_VERSIONS.include?(version)
|
|
1195
|
+
raise ArgumentError, "Unknown server API version: #{version}"
|
|
1196
|
+
end
|
|
1197
|
+
end
|
|
1198
|
+
end
|
|
1199
|
+
|
|
839
1200
|
Lint.validate_underscore_read_preference(opts[:read])
|
|
840
1201
|
Lint.validate_read_concern_option(opts[:read_concern])
|
|
841
1202
|
opts.each.inject(Options::Redacted.new) do |_options, (k, v)|
|
|
@@ -845,6 +1206,15 @@ module Mongo
|
|
|
845
1206
|
validate_read!(key, opts)
|
|
846
1207
|
if key == :compressors
|
|
847
1208
|
compressors = valid_compressors(v)
|
|
1209
|
+
|
|
1210
|
+
if compressors.include?('snappy')
|
|
1211
|
+
validate_snappy_compression!
|
|
1212
|
+
end
|
|
1213
|
+
|
|
1214
|
+
if compressors.include?('zstd')
|
|
1215
|
+
validate_zstd_compression!
|
|
1216
|
+
end
|
|
1217
|
+
|
|
848
1218
|
_options[key] = compressors unless compressors.empty?
|
|
849
1219
|
else
|
|
850
1220
|
_options[key] = v
|
|
@@ -857,12 +1227,141 @@ module Mongo
|
|
|
857
1227
|
end
|
|
858
1228
|
|
|
859
1229
|
# Validates all options after they are set on the client.
|
|
860
|
-
# This method is intended to catch combinations of options which
|
|
1230
|
+
# This method is intended to catch combinations of options which are
|
|
861
1231
|
# not allowed.
|
|
862
|
-
def validate_options!
|
|
1232
|
+
def validate_options!(addresses = nil)
|
|
863
1233
|
if options[:write] && options[:write_concern] && options[:write] != options[:write_concern]
|
|
864
1234
|
raise ArgumentError, "If :write and :write_concern are both given, they must be identical: #{options.inspect}"
|
|
865
1235
|
end
|
|
1236
|
+
|
|
1237
|
+
if options[:direct_connection]
|
|
1238
|
+
if options[:connect] && options[:connect].to_sym != :direct
|
|
1239
|
+
raise ArgumentError, "Conflicting client options: direct_connection=true and connect=#{options[:connect]}"
|
|
1240
|
+
end
|
|
1241
|
+
# When a new client is created, we get the list of seed addresses
|
|
1242
|
+
if addresses && addresses.length > 1
|
|
1243
|
+
raise ArgumentError, "direct_connection=true cannot be used with multiple seeds"
|
|
1244
|
+
end
|
|
1245
|
+
# When a client is copied using #with, we have a cluster
|
|
1246
|
+
if cluster && !cluster.topology.is_a?(Mongo::Cluster::Topology::Single)
|
|
1247
|
+
raise ArgumentError, "direct_connection=true cannot be used with topologies other than Single (this client is #{cluster.topology.class.name.sub(/.*::/, '')})"
|
|
1248
|
+
end
|
|
1249
|
+
end
|
|
1250
|
+
|
|
1251
|
+
if options[:direct_connection] == false && options[:connect] && options[:connect].to_sym == :direct
|
|
1252
|
+
raise ArgumentError, "Conflicting client options: direct_connection=false and connect=#{options[:connect]}"
|
|
1253
|
+
end
|
|
1254
|
+
|
|
1255
|
+
%i(connect_timeout socket_timeout).each do |key|
|
|
1256
|
+
if value = options[key]
|
|
1257
|
+
unless Numeric === value
|
|
1258
|
+
raise ArgumentError, "#{key} must be a non-negative number: #{value}"
|
|
1259
|
+
end
|
|
1260
|
+
if value < 0
|
|
1261
|
+
raise ArgumentError, "#{key} must be a non-negative number: #{value}"
|
|
1262
|
+
end
|
|
1263
|
+
end
|
|
1264
|
+
end
|
|
1265
|
+
|
|
1266
|
+
if value = options[:bg_error_backtrace]
|
|
1267
|
+
case value
|
|
1268
|
+
when Integer
|
|
1269
|
+
if value <= 0
|
|
1270
|
+
raise ArgumentError, ":bg_error_backtrace option value must be true, false, nil or a positive integer: #{value}"
|
|
1271
|
+
end
|
|
1272
|
+
when true
|
|
1273
|
+
# OK
|
|
1274
|
+
else
|
|
1275
|
+
raise ArgumentError, ":bg_error_backtrace option value must be true, false, nil or a positive integer: #{value}"
|
|
1276
|
+
end
|
|
1277
|
+
end
|
|
1278
|
+
|
|
1279
|
+
if libraries = options[:wrapping_libraries]
|
|
1280
|
+
unless Array === libraries
|
|
1281
|
+
raise ArgumentError, ":wrapping_libraries must be an array of hashes: #{libraries}"
|
|
1282
|
+
end
|
|
1283
|
+
|
|
1284
|
+
libraries = libraries.map do |library|
|
|
1285
|
+
Utils.shallow_symbolize_keys(library)
|
|
1286
|
+
end
|
|
1287
|
+
|
|
1288
|
+
libraries.each do |library|
|
|
1289
|
+
unless Hash === library
|
|
1290
|
+
raise ArgumentError, ":wrapping_libraries element is not a hash: #{library}"
|
|
1291
|
+
end
|
|
1292
|
+
|
|
1293
|
+
if library.empty?
|
|
1294
|
+
raise ArgumentError, ":wrapping_libraries element is empty"
|
|
1295
|
+
end
|
|
1296
|
+
|
|
1297
|
+
unless (library.keys - %i(name platform version)).empty?
|
|
1298
|
+
raise ArgumentError, ":wrapping_libraries element has invalid keys (allowed keys: :name, :platform, :version): #{library}"
|
|
1299
|
+
end
|
|
1300
|
+
|
|
1301
|
+
library.each do |key, value|
|
|
1302
|
+
if value.include?('|')
|
|
1303
|
+
raise ArgumentError, ":wrapping_libraries element value cannot include '|': #{value}"
|
|
1304
|
+
end
|
|
1305
|
+
end
|
|
1306
|
+
end
|
|
1307
|
+
end
|
|
1308
|
+
end
|
|
1309
|
+
|
|
1310
|
+
# Validates all authentication-related options after they are set on the client
|
|
1311
|
+
# This method is intended to catch combinations of options which are not allowed
|
|
1312
|
+
def validate_authentication_options!
|
|
1313
|
+
auth_mech = options[:auth_mech]
|
|
1314
|
+
user = options[:user]
|
|
1315
|
+
password = options[:password]
|
|
1316
|
+
auth_source = options[:auth_source]
|
|
1317
|
+
mech_properties = options[:auth_mech_properties]
|
|
1318
|
+
|
|
1319
|
+
if auth_mech.nil?
|
|
1320
|
+
if user && user.empty?
|
|
1321
|
+
raise Mongo::Auth::InvalidConfiguration, 'Empty username is not supported for default auth mechanism'
|
|
1322
|
+
end
|
|
1323
|
+
|
|
1324
|
+
if auth_source == ''
|
|
1325
|
+
raise Mongo::Auth::InvalidConfiguration, 'Auth source cannot be empty for default auth mechanism'
|
|
1326
|
+
end
|
|
1327
|
+
|
|
1328
|
+
return
|
|
1329
|
+
end
|
|
1330
|
+
|
|
1331
|
+
if !Mongo::Auth::SOURCES.key?(auth_mech)
|
|
1332
|
+
raise Mongo::Auth::InvalidMechanism.new(auth_mech)
|
|
1333
|
+
end
|
|
1334
|
+
|
|
1335
|
+
if user.nil? && !%i(aws mongodb_x509).include?(auth_mech)
|
|
1336
|
+
raise Mongo::Auth::InvalidConfiguration, "Username is required for auth mechanism #{auth_mech}"
|
|
1337
|
+
end
|
|
1338
|
+
|
|
1339
|
+
if password.nil? && !%i(aws gssapi mongodb_x509).include?(auth_mech)
|
|
1340
|
+
raise Mongo::Auth::InvalidConfiguration, "Password is required for auth mechanism #{auth_mech}"
|
|
1341
|
+
end
|
|
1342
|
+
|
|
1343
|
+
if password && auth_mech == :mongodb_x509
|
|
1344
|
+
raise Mongo::Auth::InvalidConfiguration, 'Password is not supported for :mongodb_x509 auth mechanism'
|
|
1345
|
+
end
|
|
1346
|
+
|
|
1347
|
+
if auth_mech == :aws && user && !password
|
|
1348
|
+
raise Mongo::Auth::InvalidConfiguration, 'Username is provided but password is not provided for :aws auth mechanism'
|
|
1349
|
+
end
|
|
1350
|
+
|
|
1351
|
+
if %i(aws gssapi mongodb_x509).include?(auth_mech)
|
|
1352
|
+
if !['$external', nil].include?(auth_source)
|
|
1353
|
+
raise Mongo::Auth::InvalidConfiguration, "#{auth_source} is an invalid auth source for #{auth_mech}; valid options are $external and nil"
|
|
1354
|
+
end
|
|
1355
|
+
else
|
|
1356
|
+
# Auth source is the database name, and thus cannot be the empty string.
|
|
1357
|
+
if auth_source == ''
|
|
1358
|
+
raise Mongo::Auth::InvalidConfiguration, "Auth source cannot be empty for auth mechanism #{auth_mech}"
|
|
1359
|
+
end
|
|
1360
|
+
end
|
|
1361
|
+
|
|
1362
|
+
if mech_properties && !%i(aws gssapi).include?(auth_mech)
|
|
1363
|
+
raise Mongo::Auth::InvalidConfiguration, ":mechanism_properties are not supported for auth mechanism #{auth_mech}"
|
|
1364
|
+
end
|
|
866
1365
|
end
|
|
867
1366
|
|
|
868
1367
|
def valid_compressors(compressors)
|
|
@@ -872,11 +1371,30 @@ module Mongo
|
|
|
872
1371
|
"This compressor will not be used.")
|
|
873
1372
|
false
|
|
874
1373
|
else
|
|
1374
|
+
|
|
875
1375
|
true
|
|
876
1376
|
end
|
|
877
1377
|
end
|
|
878
1378
|
end
|
|
879
1379
|
|
|
1380
|
+
def validate_snappy_compression!
|
|
1381
|
+
return if defined?(Snappy)
|
|
1382
|
+
require 'snappy'
|
|
1383
|
+
rescue LoadError => e
|
|
1384
|
+
raise Error::UnmetDependency, "Cannot enable snappy compression because the snappy gem " \
|
|
1385
|
+
"has not been installed. Add \"gem 'snappy'\" to your Gemfile and run " \
|
|
1386
|
+
"\"bundle install\" to install the gem. (#{e.class}: #{e})"
|
|
1387
|
+
end
|
|
1388
|
+
|
|
1389
|
+
def validate_zstd_compression!
|
|
1390
|
+
return if defined?(Zstd)
|
|
1391
|
+
require 'zstd-ruby'
|
|
1392
|
+
rescue LoadError => e
|
|
1393
|
+
raise Error::UnmetDependency, "Cannot enable zstd compression because the zstd-ruby gem " \
|
|
1394
|
+
"has not been installed. Add \"gem 'zstd-ruby'\" to your Gemfile and run " \
|
|
1395
|
+
"\"bundle install\" to install the gem. (#{e.class}: #{e})"
|
|
1396
|
+
end
|
|
1397
|
+
|
|
880
1398
|
def validate_max_min_pool_size!(option, opts)
|
|
881
1399
|
if option == :min_pool_size && opts[:min_pool_size]
|
|
882
1400
|
max = opts[:max_pool_size] || Server::ConnectionPool::DEFAULT_MAX_SIZE
|