mongo 2.3.1 → 2.16.0
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 +5 -5
- checksums.yaml.gz.sig +0 -0
- data/CONTRIBUTING.md +12 -54
- data/LICENSE +1 -1
- data/README.md +74 -44
- data/Rakefile +110 -22
- data/lib/mongo/active_support.rb +20 -0
- data/lib/mongo/address/ipv4.rb +41 -8
- data/lib/mongo/address/ipv6.rb +64 -12
- data/lib/mongo/address/unix.rb +12 -6
- data/lib/mongo/address/validator.rb +102 -0
- data/lib/mongo/address.rb +163 -59
- 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 +29 -73
- data/lib/mongo/auth/cr.rb +17 -35
- 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 +14 -53
- data/lib/mongo/auth/ldap.rb +14 -33
- 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 +13 -411
- data/lib/mongo/auth/scram.rb +45 -37
- 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 +77 -0
- data/lib/mongo/auth/stringprep/tables.rb +3236 -0
- data/lib/mongo/auth/stringprep/unicode_normalize/normalize.rb +175 -0
- data/lib/mongo/auth/stringprep/unicode_normalize/tables.rb +1171 -0
- data/lib/mongo/auth/stringprep.rb +118 -0
- data/lib/mongo/auth/user/view.rb +62 -24
- data/lib/mongo/auth/user.rb +76 -10
- data/lib/mongo/auth/x509/conversation.rb +28 -50
- data/lib/mongo/auth/x509.rb +29 -31
- data/lib/mongo/auth.rb +96 -17
- data/lib/mongo/background_thread.rb +173 -0
- data/lib/mongo/bson.rb +4 -1
- data/lib/mongo/bulk_write/combineable.rb +26 -2
- data/lib/mongo/bulk_write/ordered_combiner.rb +4 -1
- data/lib/mongo/bulk_write/result.rb +5 -2
- data/lib/mongo/bulk_write/result_combiner.rb +21 -8
- data/lib/mongo/bulk_write/transformable.rb +36 -12
- data/lib/mongo/bulk_write/unordered_combiner.rb +4 -1
- data/lib/mongo/bulk_write/validatable.rb +16 -2
- data/lib/mongo/bulk_write.rb +146 -51
- data/lib/mongo/caching_cursor.rb +77 -0
- data/lib/mongo/client.rb +1181 -92
- data/lib/mongo/client_encryption.rb +106 -0
- data/lib/mongo/cluster/periodic_executor.rb +105 -0
- data/lib/mongo/cluster/reapers/cursor_reaper.rb +192 -0
- data/lib/mongo/cluster/reapers/socket_reaper.rb +65 -0
- data/lib/mongo/cluster/sdam_flow.rb +626 -0
- data/lib/mongo/cluster/topology/base.rb +225 -0
- data/lib/mongo/cluster/topology/load_balanced.rb +102 -0
- data/lib/mongo/cluster/topology/no_replica_set_options.rb +37 -0
- data/lib/mongo/cluster/topology/replica_set_no_primary.rb +172 -0
- data/lib/mongo/cluster/topology/replica_set_with_primary.rb +30 -0
- data/lib/mongo/cluster/topology/sharded.rb +38 -92
- data/lib/mongo/cluster/topology/single.rb +46 -86
- data/lib/mongo/cluster/topology/unknown.rb +39 -121
- data/lib/mongo/cluster/topology.rb +92 -20
- data/lib/mongo/cluster.rb +889 -228
- data/lib/mongo/cluster_time.rb +142 -0
- data/lib/mongo/collection/view/aggregation.rb +52 -14
- data/lib/mongo/collection/view/builder/aggregation.rb +52 -7
- data/lib/mongo/collection/view/builder/map_reduce.rb +39 -37
- data/lib/mongo/collection/view/builder.rb +4 -5
- data/lib/mongo/collection/view/change_stream/retryable.rb +43 -0
- data/lib/mongo/collection/view/change_stream.rb +372 -0
- data/lib/mongo/collection/view/explainable.rb +32 -10
- data/lib/mongo/collection/view/immutable.rb +5 -2
- data/lib/mongo/collection/view/iterable.rb +145 -24
- data/lib/mongo/collection/view/map_reduce.rb +101 -38
- data/lib/mongo/collection/view/readable.rb +292 -70
- data/lib/mongo/collection/view/writable.rb +327 -65
- data/lib/mongo/collection/view.rb +74 -30
- data/lib/mongo/collection.rb +387 -63
- 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/kill_spec.rb +38 -0
- data/lib/mongo/cursor.rb +290 -63
- data/lib/mongo/database/view.rb +107 -26
- data/lib/mongo/database.rb +242 -31
- data/lib/mongo/dbref.rb +13 -3
- data/lib/mongo/distinguishing_semaphore.rb +58 -0
- data/lib/mongo/error/auth_error.rb +32 -0
- data/lib/mongo/error/bad_load_balancer_target.rb +26 -0
- data/lib/mongo/error/bulk_write_error.rb +38 -3
- data/lib/mongo/error/change_stream_resumable.rb +40 -0
- data/lib/mongo/error/closed_stream.rb +5 -2
- data/lib/mongo/error/connection_check_out_timeout.rb +51 -0
- 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_string_prep_validation.rb +41 -0
- data/lib/mongo/error/file_not_found.rb +4 -1
- data/lib/mongo/error/handshake_error.rb +27 -0
- data/lib/mongo/error/insufficient_iteration_count.rb +41 -0
- 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 +41 -0
- 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 +38 -0
- 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 +38 -0
- 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 +37 -5
- data/lib/mongo/error/invalid_session.rb +40 -0
- data/lib/mongo/error/invalid_signature.rb +4 -1
- data/lib/mongo/error/invalid_transaction_operation.rb +85 -0
- data/lib/mongo/error/invalid_txt_record.rb +30 -0
- data/lib/mongo/error/invalid_update_document.rb +4 -1
- data/lib/mongo/error/invalid_uri.rb +11 -7
- data/lib/mongo/error/invalid_write_concern.rb +6 -3
- data/lib/mongo/error/kms_error.rb +25 -0
- data/lib/mongo/error/lint_error.rb +38 -0
- 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 +30 -0
- data/lib/mongo/error/missing_file_chunk.rb +4 -1
- data/lib/mongo/error/missing_password.rb +32 -0
- data/lib/mongo/error/missing_resume_token.rb +42 -0
- data/lib/mongo/error/missing_scram_server_signature.rb +30 -0
- data/lib/mongo/error/missing_service_id.rb +26 -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 +17 -5
- data/lib/mongo/error/no_service_connection_available.rb +49 -0
- data/lib/mongo/error/no_srv_records.rb +29 -0
- data/lib/mongo/error/notable.rb +90 -0
- data/lib/mongo/error/operation_failure.rb +266 -13
- data/lib/mongo/error/parser.rb +220 -15
- data/lib/mongo/error/pool_closed_error.rb +53 -0
- data/lib/mongo/error/raise_original_error.rb +32 -0
- data/lib/mongo/error/sdam_error_detection.rb +83 -0
- 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 +30 -0
- data/lib/mongo/error/sessions_not_supported.rb +38 -0
- data/lib/mongo/error/socket_error.rb +8 -2
- data/lib/mongo/error/socket_timeout_error.rb +8 -2
- 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 +44 -0
- data/lib/mongo/error/unmet_dependency.rb +24 -0
- data/lib/mongo/error/unsupported_array_filters.rb +59 -0
- data/lib/mongo/error/unsupported_collation.rb +59 -0
- data/lib/mongo/error/unsupported_features.rb +4 -19
- data/lib/mongo/error/unsupported_message_type.rb +26 -0
- data/lib/mongo/error/unsupported_option.rb +104 -0
- data/lib/mongo/error/write_retryable.rb +30 -0
- data/lib/mongo/error.rb +147 -2
- data/lib/mongo/event/base.rb +45 -0
- 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 +18 -8
- data/lib/mongo/grid/file/chunk.rb +10 -7
- data/lib/mongo/grid/file/info.rb +38 -5
- data/lib/mongo/grid/file.rb +9 -1
- data/lib/mongo/grid/fs_bucket.rb +147 -65
- data/lib/mongo/grid/stream/read.rb +68 -30
- data/lib/mongo/grid/stream/write.rb +37 -12
- data/lib/mongo/grid/stream.rb +4 -1
- data/lib/mongo/grid.rb +4 -1
- data/lib/mongo/id.rb +69 -0
- data/lib/mongo/index/view.rb +112 -38
- data/lib/mongo/index.rb +5 -1
- data/lib/mongo/lint.rb +105 -0
- data/lib/mongo/loggable.rb +9 -2
- data/lib/mongo/logger.rb +7 -6
- data/lib/mongo/monitoring/cmap_log_subscriber.rb +56 -0
- data/lib/mongo/monitoring/command_log_subscriber.rb +25 -5
- data/lib/mongo/monitoring/event/cmap/base.rb +31 -0
- data/lib/mongo/monitoring/event/cmap/connection_check_out_failed.rb +88 -0
- data/lib/mongo/monitoring/event/cmap/connection_check_out_started.rb +59 -0
- data/lib/mongo/monitoring/event/cmap/connection_checked_in.rb +74 -0
- data/lib/mongo/monitoring/event/cmap/connection_checked_out.rb +75 -0
- data/lib/mongo/monitoring/event/cmap/connection_closed.rb +106 -0
- data/lib/mongo/monitoring/event/cmap/connection_created.rb +67 -0
- data/lib/mongo/monitoring/event/cmap/connection_ready.rb +67 -0
- data/lib/mongo/monitoring/event/cmap/pool_cleared.rb +63 -0
- data/lib/mongo/monitoring/event/cmap/pool_closed.rb +68 -0
- data/lib/mongo/monitoring/event/cmap/pool_created.rb +75 -0
- data/lib/mongo/monitoring/event/cmap.rb +28 -0
- data/lib/mongo/monitoring/event/command_failed.rb +59 -8
- data/lib/mongo/monitoring/event/command_started.rb +102 -6
- data/lib/mongo/monitoring/event/command_succeeded.rb +45 -6
- data/lib/mongo/monitoring/event/secure.rb +59 -5
- data/lib/mongo/monitoring/event/server_closed.rb +62 -0
- data/lib/mongo/monitoring/event/server_description_changed.rb +99 -0
- data/lib/mongo/monitoring/event/server_heartbeat_failed.rb +92 -0
- data/lib/mongo/monitoring/event/server_heartbeat_started.rb +65 -0
- data/lib/mongo/monitoring/event/server_heartbeat_succeeded.rb +84 -0
- data/lib/mongo/monitoring/event/server_opening.rb +62 -0
- data/lib/mongo/monitoring/event/topology_changed.rb +63 -0
- data/lib/mongo/monitoring/event/topology_closed.rb +57 -0
- data/lib/mongo/monitoring/event/topology_opening.rb +57 -0
- data/lib/mongo/monitoring/event.rb +15 -1
- data/lib/mongo/monitoring/publishable.rb +60 -44
- data/lib/mongo/monitoring/sdam_log_subscriber.rb +57 -0
- data/lib/mongo/monitoring/server_closed_log_subscriber.rb +33 -0
- data/lib/mongo/monitoring/server_description_changed_log_subscriber.rb +44 -0
- data/lib/mongo/monitoring/server_opening_log_subscriber.rb +33 -0
- data/lib/mongo/monitoring/topology_changed_log_subscriber.rb +43 -0
- data/lib/mongo/monitoring/topology_closed_log_subscriber.rb +33 -0
- data/lib/mongo/monitoring/topology_opening_log_subscriber.rb +33 -0
- data/lib/mongo/monitoring/unified_sdam_log_subscriber.rb +65 -0
- data/lib/mongo/monitoring.rb +245 -61
- data/lib/mongo/operation/aggregate/command.rb +55 -0
- data/lib/mongo/operation/aggregate/op_msg.rb +34 -0
- data/lib/mongo/operation/aggregate/result.rb +104 -0
- data/lib/mongo/operation/aggregate.rb +39 -0
- data/lib/mongo/operation/collections_info/command.rb +48 -0
- data/lib/mongo/operation/collections_info/result.rb +59 -0
- data/lib/mongo/operation/collections_info.rb +51 -0
- data/lib/mongo/operation/command/command.rb +41 -0
- data/lib/mongo/operation/command/op_msg.rb +31 -0
- data/lib/mongo/operation/command.rb +34 -0
- data/lib/mongo/operation/context.rb +120 -0
- data/lib/mongo/operation/count/command.rb +47 -0
- data/lib/mongo/operation/count/op_msg.rb +38 -0
- data/lib/mongo/operation/count.rb +34 -0
- data/lib/mongo/operation/create/command.rb +47 -0
- data/lib/mongo/operation/create/op_msg.rb +39 -0
- data/lib/mongo/operation/create.rb +34 -0
- data/lib/mongo/operation/create_index/command.rb +61 -0
- data/lib/mongo/operation/create_index/op_msg.rb +54 -0
- data/lib/mongo/operation/create_index.rb +34 -0
- data/lib/mongo/operation/create_user/command.rb +46 -0
- data/lib/mongo/operation/create_user/op_msg.rb +38 -0
- data/lib/mongo/operation/create_user.rb +34 -0
- data/lib/mongo/operation/delete/bulk_result.rb +51 -0
- data/lib/mongo/operation/delete/command.rb +52 -0
- data/lib/mongo/operation/delete/legacy.rb +64 -0
- data/lib/mongo/operation/delete/op_msg.rb +55 -0
- data/lib/mongo/operation/delete/result.rb +48 -0
- data/lib/mongo/operation/delete.rb +41 -0
- data/lib/mongo/operation/distinct/command.rb +47 -0
- data/lib/mongo/operation/distinct/op_msg.rb +40 -0
- data/lib/mongo/operation/distinct.rb +34 -0
- data/lib/mongo/operation/drop/command.rb +41 -0
- data/lib/mongo/operation/drop/op_msg.rb +32 -0
- data/lib/mongo/operation/drop.rb +34 -0
- data/lib/mongo/operation/drop_database/command.rb +41 -0
- data/lib/mongo/operation/drop_database/op_msg.rb +32 -0
- data/lib/mongo/operation/drop_database.rb +34 -0
- data/lib/mongo/operation/drop_index/command.rb +45 -0
- data/lib/mongo/operation/drop_index/op_msg.rb +38 -0
- data/lib/mongo/operation/drop_index.rb +34 -0
- data/lib/mongo/operation/explain/command.rb +58 -0
- data/lib/mongo/operation/explain/legacy.rb +52 -0
- data/lib/mongo/operation/explain/op_msg.rb +48 -0
- data/lib/mongo/operation/explain/result.rb +56 -0
- data/lib/mongo/operation/explain.rb +36 -0
- data/lib/mongo/operation/find/builder/command.rb +110 -0
- data/lib/mongo/operation/find/builder/flags.rb +61 -0
- data/lib/mongo/operation/find/builder/legacy.rb +123 -0
- data/lib/mongo/operation/find/builder/modifiers.rb +89 -0
- data/lib/mongo/operation/find/builder.rb +21 -0
- data/lib/mongo/operation/find/command.rb +51 -0
- data/lib/mongo/operation/find/legacy/result.rb +46 -0
- data/lib/mongo/operation/find/legacy.rb +52 -0
- data/lib/mongo/operation/find/op_msg.rb +46 -0
- data/lib/mongo/operation/find/result.rb +76 -0
- data/lib/mongo/operation/find.rb +37 -0
- data/lib/mongo/operation/get_more/command.rb +43 -0
- data/lib/mongo/operation/get_more/command_builder.rb +38 -0
- data/lib/mongo/operation/get_more/legacy.rb +39 -0
- data/lib/mongo/operation/get_more/op_msg.rb +34 -0
- data/lib/mongo/operation/get_more/result.rb +75 -0
- data/lib/mongo/operation/get_more.rb +37 -0
- data/lib/mongo/operation/indexes/command.rb +42 -0
- data/lib/mongo/operation/indexes/legacy.rb +48 -0
- data/lib/mongo/operation/indexes/op_msg.rb +34 -0
- data/lib/mongo/operation/indexes/result.rb +105 -0
- data/lib/mongo/operation/indexes.rb +50 -0
- data/lib/mongo/operation/insert/bulk_result.rb +112 -0
- data/lib/mongo/operation/insert/command.rb +59 -0
- data/lib/mongo/operation/insert/legacy.rb +68 -0
- data/lib/mongo/operation/insert/op_msg.rb +54 -0
- data/lib/mongo/operation/insert/result.rb +75 -0
- data/lib/mongo/operation/insert.rb +44 -0
- data/lib/mongo/operation/kill_cursors/command.rb +48 -0
- data/lib/mongo/operation/kill_cursors/command_builder.rb +35 -0
- data/lib/mongo/operation/kill_cursors/legacy.rb +41 -0
- data/lib/mongo/operation/kill_cursors/op_msg.rb +42 -0
- data/lib/mongo/operation/kill_cursors.rb +12 -16
- data/lib/mongo/operation/list_collections/command.rb +46 -0
- data/lib/mongo/operation/list_collections/op_msg.rb +39 -0
- data/lib/mongo/operation/list_collections/result.rb +113 -0
- data/lib/mongo/operation/list_collections.rb +35 -0
- data/lib/mongo/operation/map_reduce/command.rb +51 -0
- data/lib/mongo/operation/map_reduce/op_msg.rb +34 -0
- data/lib/mongo/operation/map_reduce/result.rb +142 -0
- data/lib/mongo/operation/map_reduce.rb +35 -0
- data/lib/mongo/operation/op_msg_base.rb +33 -0
- data/lib/mongo/operation/parallel_scan/command.rb +57 -0
- data/lib/mongo/operation/parallel_scan/op_msg.rb +46 -0
- data/lib/mongo/operation/parallel_scan/result.rb +68 -0
- data/lib/mongo/operation/parallel_scan.rb +35 -0
- data/lib/mongo/operation/remove_user/command.rb +46 -0
- data/lib/mongo/operation/remove_user/op_msg.rb +38 -0
- data/lib/mongo/operation/remove_user.rb +34 -0
- data/lib/mongo/operation/result.rb +195 -39
- data/lib/mongo/operation/shared/bypass_document_validation.rb +46 -0
- data/lib/mongo/operation/shared/causal_consistency_supported.rb +45 -0
- data/lib/mongo/operation/shared/executable.rb +130 -0
- data/lib/mongo/operation/shared/executable_no_validate.rb +32 -0
- data/lib/mongo/operation/shared/executable_transaction_label.rb +30 -0
- data/lib/mongo/operation/shared/idable.rb +68 -0
- data/lib/mongo/operation/shared/limited.rb +42 -0
- data/lib/mongo/operation/shared/object_id_generator.rb +40 -0
- data/lib/mongo/operation/shared/op_msg_or_command.rb +41 -0
- data/lib/mongo/operation/shared/op_msg_or_find_command.rb +44 -0
- data/lib/mongo/operation/shared/polymorphic_lookup.rb +36 -0
- data/lib/mongo/operation/shared/polymorphic_operation.rb +42 -0
- data/lib/mongo/operation/shared/polymorphic_result.rb +50 -0
- data/lib/mongo/operation/shared/read_preference_supported.rb +116 -0
- data/lib/mongo/operation/shared/response_handling.rb +173 -0
- data/lib/mongo/operation/shared/result/aggregatable.rb +74 -0
- data/lib/mongo/operation/shared/result/use_legacy_error_parser.rb +32 -0
- data/lib/mongo/operation/shared/sessions_supported.rb +254 -0
- data/lib/mongo/operation/shared/specifiable.rb +567 -0
- data/lib/mongo/operation/shared/validatable.rb +87 -0
- data/lib/mongo/operation/shared/write.rb +90 -0
- data/lib/mongo/operation/shared/write_concern_supported.rb +43 -0
- data/lib/mongo/operation/update/bulk_result.rb +129 -0
- data/lib/mongo/operation/update/command.rb +53 -0
- data/lib/mongo/operation/update/legacy/result.rb +112 -0
- data/lib/mongo/operation/update/legacy.rb +76 -0
- data/lib/mongo/operation/update/op_msg.rb +51 -0
- data/lib/mongo/operation/update/result.rb +113 -0
- data/lib/mongo/operation/update.rb +41 -0
- data/lib/mongo/operation/update_user/command.rb +45 -0
- data/lib/mongo/operation/update_user/op_msg.rb +38 -0
- data/lib/mongo/operation/update_user.rb +34 -0
- data/lib/mongo/operation/users_info/command.rb +46 -0
- data/lib/mongo/operation/users_info/op_msg.rb +39 -0
- data/lib/mongo/operation/users_info/result.rb +48 -0
- data/lib/mongo/operation/users_info.rb +35 -0
- data/lib/mongo/operation/write_command/command.rb +51 -0
- data/lib/mongo/operation/write_command/op_msg.rb +43 -0
- data/lib/mongo/operation/write_command.rb +32 -0
- data/lib/mongo/operation.rb +83 -21
- data/lib/mongo/options/mapper.rb +13 -3
- data/lib/mongo/options/redacted.rb +4 -1
- data/lib/mongo/options.rb +4 -1
- data/lib/mongo/protocol/bit_vector.rb +8 -4
- data/lib/mongo/protocol/compressed.rb +184 -0
- data/lib/mongo/protocol/delete.rb +16 -8
- data/lib/mongo/protocol/get_more.rb +24 -15
- data/lib/mongo/protocol/insert.rb +20 -10
- data/lib/mongo/protocol/kill_cursors.rb +22 -21
- data/lib/mongo/protocol/message.rb +187 -23
- data/lib/mongo/protocol/msg.rb +404 -0
- data/lib/mongo/protocol/query.rb +120 -41
- data/lib/mongo/protocol/registry.rb +79 -0
- data/lib/mongo/protocol/reply.rb +23 -15
- data/lib/mongo/protocol/serializers.rb +283 -12
- data/lib/mongo/protocol/update.rb +22 -10
- data/lib/mongo/protocol.rb +6 -0
- data/lib/mongo/query_cache.rb +275 -0
- data/lib/mongo/retryable.rb +414 -47
- data/lib/mongo/semaphore.rb +49 -0
- data/lib/mongo/server/app_metadata.rb +267 -0
- data/lib/mongo/server/connection.rb +251 -101
- data/lib/mongo/server/connection_base.rb +276 -0
- data/lib/mongo/server/connection_common.rb +205 -0
- data/lib/mongo/server/connection_pool/generation_manager.rb +71 -0
- data/lib/mongo/server/connection_pool/populator.rb +61 -0
- data/lib/mongo/server/connection_pool.rb +796 -57
- data/lib/mongo/server/description/features.rb +84 -20
- data/lib/mongo/server/description/load_balancer.rb +33 -0
- data/lib/mongo/server/description.rb +398 -73
- data/lib/mongo/server/monitor/app_metadata.rb +37 -0
- data/lib/mongo/server/monitor/connection.rb +192 -61
- data/lib/mongo/server/monitor.rb +251 -92
- data/lib/mongo/server/pending_connection.rb +288 -0
- 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 +76 -0
- data/lib/mongo/server.rb +454 -76
- data/lib/mongo/server_selector/base.rb +629 -0
- data/lib/mongo/server_selector/nearest.rb +44 -28
- data/lib/mongo/server_selector/primary.rb +40 -18
- data/lib/mongo/server_selector/primary_preferred.rb +47 -26
- data/lib/mongo/server_selector/secondary.rb +41 -23
- data/lib/mongo/server_selector/secondary_preferred.rb +42 -25
- data/lib/mongo/server_selector.rb +27 -8
- data/lib/mongo/session/server_session.rb +122 -0
- data/lib/mongo/session/session_pool.rb +166 -0
- data/lib/mongo/session.rb +1094 -0
- data/lib/mongo/socket/ocsp_cache.rb +100 -0
- data/lib/mongo/socket/ocsp_verifier.rb +345 -0
- data/lib/mongo/socket/ssl.rb +299 -61
- data/lib/mongo/socket/tcp.rb +48 -32
- data/lib/mongo/socket/unix.rb +24 -34
- data/lib/mongo/socket.rb +310 -48
- 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 +624 -0
- data/lib/mongo/uri/srv_protocol.rb +239 -0
- data/lib/mongo/uri.rb +291 -316
- data/lib/mongo/utils.rb +111 -0
- data/lib/mongo/version.rb +5 -2
- data/lib/mongo/write_concern/acknowledged.rb +17 -4
- data/lib/mongo/write_concern/base.rb +70 -0
- data/lib/mongo/write_concern/unacknowledged.rb +17 -4
- data/lib/mongo/write_concern.rb +19 -34
- data/lib/mongo.rb +69 -5
- data/mongo.gemspec +14 -6
- data/spec/NOTES.aws-auth.md +296 -0
- data/spec/README.aws-auth.md +318 -0
- data/spec/README.md +715 -0
- data/spec/USERS.md +72 -0
- data/spec/atlas/atlas_connectivity_spec.rb +27 -0
- data/spec/atlas/operations_spec.rb +28 -0
- data/spec/integration/auth_spec.rb +309 -0
- 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 +39 -0
- data/spec/integration/bulk_insert_spec.rb +83 -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 +208 -0
- data/spec/integration/change_stream_spec.rb +808 -0
- 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 +41 -0
- data/spec/integration/client_construction_aws_auth_spec.rb +194 -0
- data/spec/integration/client_construction_spec.rb +293 -0
- 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 +49 -0
- 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 +184 -0
- data/spec/integration/command_spec.rb +179 -0
- data/spec/integration/connect_single_rs_name_spec.rb +75 -0
- data/spec/integration/connection_pool_populator_spec.rb +305 -0
- data/spec/integration/connection_spec.rb +353 -0
- data/spec/integration/crud_spec.rb +366 -0
- data/spec/integration/cursor_pinning_spec.rb +121 -0
- data/spec/integration/cursor_reaping_spec.rb +143 -0
- data/spec/integration/docs_examples_spec.rb +207 -0
- data/spec/integration/error_detection_spec.rb +42 -0
- data/spec/integration/fork_reconnect_spec.rb +200 -0
- data/spec/integration/get_more_spec.rb +42 -0
- data/spec/integration/grid_fs_bucket_spec.rb +51 -0
- data/spec/integration/heartbeat_events_spec.rb +102 -0
- data/spec/integration/map_reduce_spec.rb +77 -0
- data/spec/integration/mmapv1_spec.rb +31 -0
- data/spec/integration/mongos_pinning_spec.rb +37 -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 +29 -0
- 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 +92 -0
- data/spec/integration/read_preference_spec.rb +544 -0
- data/spec/integration/reconnect_spec.rb +195 -0
- data/spec/integration/retryable_errors_spec.rb +286 -0
- data/spec/integration/retryable_writes/retryable_writes_36_and_older_spec.rb +764 -0
- 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 +34 -0
- data/spec/integration/sdam_error_handling_spec.rb +426 -0
- data/spec/integration/sdam_events_spec.rb +138 -0
- 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 +48 -0
- data/spec/integration/server_monitor_spec.rb +56 -0
- data/spec/integration/server_selection_spec.rb +39 -0
- data/spec/integration/server_selector_spec.rb +105 -0
- data/spec/integration/server_spec.rb +69 -0
- data/spec/integration/shell_examples_spec.rb +984 -0
- data/spec/integration/size_limit_spec.rb +115 -0
- 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 +28 -0
- data/spec/integration/step_down_spec.rb +207 -0
- data/spec/integration/time_zone_querying_spec.rb +55 -0
- data/spec/integration/transaction_pinning_spec.rb +120 -0
- data/spec/integration/transactions_api_examples_spec.rb +62 -0
- data/spec/integration/transactions_examples_spec.rb +235 -0
- data/spec/integration/truncated_utf8_spec.rb +26 -0
- data/spec/integration/versioned_api_examples_spec.rb +114 -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 +167 -0
- data/spec/mongo/address/ipv4_spec.rb +8 -1
- data/spec/mongo/address/ipv6_spec.rb +36 -1
- data/spec/mongo/address/unix_spec.rb +5 -1
- data/spec/mongo/address/validator_spec.rb +54 -0
- data/spec/mongo/address_spec.rb +120 -7
- 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 +34 -23
- data/spec/mongo/auth/gssapi/conversation_spec.rb +124 -0
- data/spec/mongo/auth/invalid_mechanism_spec.rb +14 -0
- data/spec/mongo/auth/ldap/conversation_spec.rb +6 -3
- data/spec/mongo/auth/ldap_spec.rb +19 -21
- data/spec/mongo/auth/scram/conversation_spec.rb +66 -58
- data/spec/mongo/auth/scram256/conversation_spec.rb +174 -0
- data/spec/mongo/auth/scram_negotiation_spec.rb +531 -0
- data/spec/mongo/auth/scram_spec.rb +97 -39
- data/spec/mongo/auth/stringprep/profiles/sasl_spec.rb +116 -0
- data/spec/mongo/auth/stringprep_spec.rb +191 -0
- data/spec/mongo/auth/user/view_spec.rb +404 -70
- data/spec/mongo/auth/user_spec.rb +165 -12
- data/spec/mongo/auth/x509/conversation_spec.rb +72 -0
- data/spec/mongo/auth/x509_spec.rb +46 -22
- 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 +9 -6
- data/spec/mongo/bulk_write/result_spec.rb +127 -0
- data/spec/mongo/bulk_write/unordered_combiner_spec.rb +7 -4
- data/spec/mongo/bulk_write_spec.rb +1534 -254
- data/spec/mongo/caching_cursor_spec.rb +73 -0
- data/spec/mongo/client_construction_spec.rb +2620 -0
- data/spec/mongo/client_encryption_spec.rb +414 -0
- data/spec/mongo/client_spec.rb +525 -358
- data/spec/mongo/cluster/cursor_reaper_spec.rb +77 -88
- data/spec/mongo/cluster/periodic_executor_spec.rb +21 -0
- data/spec/mongo/cluster/socket_reaper_spec.rb +46 -0
- data/spec/mongo/cluster/topology/replica_set_spec.rb +414 -175
- data/spec/mongo/cluster/topology/sharded_spec.rb +72 -47
- data/spec/mongo/cluster/topology/single_spec.rb +112 -28
- data/spec/mongo/cluster/topology/unknown_spec.rb +44 -108
- data/spec/mongo/cluster/topology_spec.rb +139 -19
- data/spec/mongo/cluster_spec.rb +509 -144
- data/spec/mongo/cluster_time_spec.rb +151 -0
- data/spec/mongo/collection/view/aggregation_spec.rb +308 -20
- data/spec/mongo/collection/view/builder/find_command_spec.rb +88 -10
- data/spec/mongo/collection/view/builder/op_query_spec.rb +7 -0
- data/spec/mongo/collection/view/change_stream_resume_spec.rb +397 -0
- data/spec/mongo/collection/view/change_stream_spec.rb +547 -0
- data/spec/mongo/collection/view/explainable_spec.rb +91 -5
- data/spec/mongo/collection/view/immutable_spec.rb +4 -1
- data/spec/mongo/collection/view/iterable_spec.rb +41 -0
- data/spec/mongo/collection/view/map_reduce_spec.rb +462 -23
- data/spec/mongo/collection/view/readable_spec.rb +461 -48
- data/spec/mongo/collection/view/writable_spec.rb +1232 -47
- data/spec/mongo/collection/view_spec.rb +81 -7
- data/spec/mongo/collection_crud_spec.rb +4365 -0
- data/spec/mongo/collection_ddl_spec.rb +537 -0
- data/spec/mongo/collection_spec.rb +485 -1982
- 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 +46 -11
- data/spec/mongo/cursor/builder/op_get_more_spec.rb +20 -4
- data/spec/mongo/cursor_spec.rb +395 -47
- data/spec/mongo/database_spec.rb +905 -68
- 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 +35 -0
- 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 +553 -0
- data/spec/mongo/error/parser_spec.rb +432 -11
- 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 +6 -3
- data/spec/mongo/grid/file_spec.rb +4 -1
- data/spec/mongo/grid/fs_bucket_spec.rb +336 -205
- data/spec/mongo/grid/stream/read_spec.rb +44 -27
- data/spec/mongo/grid/stream/write_spec.rb +93 -36
- data/spec/mongo/grid/stream_spec.rb +4 -1
- data/spec/mongo/id_spec.rb +38 -0
- data/spec/mongo/index/view_spec.rb +832 -70
- data/spec/mongo/lint_spec.rb +231 -0
- data/spec/mongo/logger_spec.rb +17 -12
- data/spec/mongo/monitoring/command_log_subscriber_spec.rb +3 -0
- data/spec/mongo/monitoring/event/cmap/connection_check_out_failed_spec.rb +26 -0
- data/spec/mongo/monitoring/event/cmap/connection_check_out_started_spec.rb +22 -0
- data/spec/mongo/monitoring/event/cmap/connection_checked_in_spec.rb +33 -0
- data/spec/mongo/monitoring/event/cmap/connection_checked_out_spec.rb +33 -0
- data/spec/mongo/monitoring/event/cmap/connection_closed_spec.rb +30 -0
- data/spec/mongo/monitoring/event/cmap/connection_created_spec.rb +27 -0
- data/spec/mongo/monitoring/event/cmap/connection_ready_spec.rb +27 -0
- data/spec/mongo/monitoring/event/cmap/pool_cleared_spec.rb +22 -0
- data/spec/mongo/monitoring/event/cmap/pool_closed_spec.rb +29 -0
- data/spec/mongo/monitoring/event/cmap/pool_created_spec.rb +36 -0
- data/spec/mongo/monitoring/event/command_failed_spec.rb +87 -0
- data/spec/mongo/monitoring/event/command_started_spec.rb +30 -5
- data/spec/mongo/monitoring/event/command_succeeded_spec.rb +71 -9
- data/spec/mongo/monitoring/event/secure_spec.rb +71 -5
- data/spec/mongo/monitoring/event/server_closed_spec.rb +38 -0
- data/spec/mongo/monitoring/event/server_description_changed_spec.rb +38 -0
- data/spec/mongo/monitoring/event/server_heartbeat_failed_spec.rb +34 -0
- data/spec/mongo/monitoring/event/server_heartbeat_started_spec.rb +34 -0
- data/spec/mongo/monitoring/event/server_heartbeat_succeeded_spec.rb +34 -0
- data/spec/mongo/monitoring/event/server_opening_spec.rb +38 -0
- data/spec/mongo/monitoring/event/topology_changed_spec.rb +44 -0
- data/spec/mongo/monitoring/event/topology_closed_spec.rb +38 -0
- data/spec/mongo/monitoring/event/topology_opening_spec.rb +38 -0
- data/spec/mongo/monitoring_spec.rb +33 -5
- data/spec/mongo/operation/aggregate/result_spec.rb +90 -0
- data/spec/mongo/operation/aggregate_spec.rb +76 -0
- data/spec/mongo/operation/collections_info_spec.rb +48 -0
- data/spec/mongo/operation/command_spec.rb +86 -0
- data/spec/mongo/operation/create_index_spec.rb +62 -0
- data/spec/mongo/operation/create_user_spec.rb +53 -0
- data/spec/mongo/operation/delete/bulk_spec.rb +245 -0
- data/spec/mongo/operation/delete/command_spec.rb +115 -0
- data/spec/mongo/operation/delete/op_msg_spec.rb +257 -0
- data/spec/mongo/operation/delete_spec.rb +233 -0
- data/spec/mongo/operation/drop_index_spec.rb +61 -0
- data/spec/mongo/operation/find/builder/flags_spec.rb +109 -0
- data/spec/mongo/operation/find/builder/modifiers_spec.rb +213 -0
- data/spec/mongo/operation/find/legacy_spec.rb +131 -0
- data/spec/mongo/operation/get_more_spec.rb +63 -0
- data/spec/mongo/operation/indexes_spec.rb +41 -0
- data/spec/mongo/operation/insert/bulk_spec.rb +273 -0
- data/spec/mongo/operation/insert/command_spec.rb +118 -0
- data/spec/mongo/operation/insert/op_msg_spec.rb +288 -0
- data/spec/mongo/operation/insert_spec.rb +290 -0
- data/spec/mongo/operation/kill_cursors_spec.rb +10 -4
- data/spec/mongo/operation/limited_spec.rb +8 -3
- data/spec/mongo/operation/map_reduce_spec.rb +131 -0
- data/spec/mongo/operation/read_preference_legacy_spec.rb +360 -0
- data/spec/mongo/operation/read_preference_op_msg_spec.rb +309 -0
- data/spec/mongo/operation/remove_user_spec.rb +52 -0
- data/spec/mongo/operation/result_spec.rb +46 -6
- data/spec/mongo/operation/specifiable_spec.rb +5 -2
- data/spec/mongo/operation/update/bulk_spec.rb +239 -0
- data/spec/mongo/operation/update/command_spec.rb +122 -0
- data/spec/mongo/operation/update/op_msg_spec.rb +263 -0
- data/spec/mongo/operation/update_spec.rb +264 -0
- data/spec/mongo/operation/update_user_spec.rb +52 -0
- data/spec/mongo/options/redacted_spec.rb +3 -0
- data/spec/mongo/protocol/compressed_spec.rb +83 -0
- data/spec/mongo/protocol/delete_spec.rb +27 -9
- data/spec/mongo/protocol/get_more_spec.rb +29 -11
- data/spec/mongo/protocol/insert_spec.rb +27 -9
- data/spec/mongo/protocol/kill_cursors_spec.rb +24 -6
- data/spec/mongo/protocol/msg_spec.rb +528 -0
- data/spec/mongo/protocol/query_spec.rb +62 -14
- data/spec/mongo/protocol/registry_spec.rb +34 -0
- data/spec/mongo/protocol/reply_spec.rb +18 -1
- data/spec/mongo/protocol/update_spec.rb +28 -10
- data/spec/mongo/query_cache_middleware_spec.rb +55 -0
- data/spec/mongo/query_cache_spec.rb +287 -0
- data/spec/mongo/retryable_spec.rb +468 -97
- data/spec/mongo/semaphore_spec.rb +54 -0
- data/spec/mongo/server/app_metadata_spec.rb +170 -0
- data/spec/mongo/server/connection_auth_spec.rb +136 -0
- data/spec/mongo/server/connection_common_spec.rb +75 -0
- data/spec/mongo/server/connection_pool/populator_spec.rb +106 -0
- data/spec/mongo/server/connection_pool_spec.rb +970 -88
- data/spec/mongo/server/connection_spec.rb +939 -172
- data/spec/mongo/server/description/features_spec.rb +96 -29
- data/spec/mongo/server/description_query_methods_spec.rb +291 -0
- data/spec/mongo/server/description_spec.rb +627 -575
- data/spec/mongo/server/monitor/app_metadata_spec.rb +25 -0
- data/spec/mongo/server/monitor/connection_spec.rb +175 -0
- data/spec/mongo/server/monitor_spec.rb +180 -103
- data/spec/mongo/server/round_trip_time_averager_spec.rb +48 -0
- data/spec/mongo/server_selector/nearest_spec.rb +107 -27
- data/spec/mongo/server_selector/primary_preferred_spec.rb +110 -30
- data/spec/mongo/server_selector/primary_spec.rb +73 -13
- data/spec/mongo/server_selector/secondary_preferred_spec.rb +125 -29
- data/spec/mongo/server_selector/secondary_spec.rb +102 -22
- data/spec/mongo/server_selector_spec.rb +325 -4
- data/spec/mongo/server_spec.rb +315 -76
- data/spec/mongo/session/server_session_spec.rb +62 -0
- data/spec/mongo/session/session_pool_spec.rb +272 -0
- data/spec/mongo/session_spec.rb +348 -0
- data/spec/mongo/session_transaction_spec.rb +206 -0
- data/spec/mongo/socket/ssl_spec.rb +742 -72
- data/spec/mongo/socket/tcp_spec.rb +17 -0
- data/spec/mongo/socket/unix_spec.rb +13 -9
- data/spec/mongo/socket_spec.rb +119 -0
- 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 +1108 -0
- data/spec/mongo/uri_option_parsing_spec.rb +625 -0
- data/spec/mongo/uri_spec.rb +514 -82
- data/spec/mongo/utils_spec.rb +56 -0
- data/spec/mongo/write_concern/acknowledged_spec.rb +14 -0
- data/spec/mongo/write_concern/unacknowledged_spec.rb +14 -0
- data/spec/mongo/write_concern_spec.rb +90 -4
- 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/runners/cmap/verifier.rb +48 -0
- data/spec/runners/cmap.rb +373 -0
- data/spec/runners/command_monitoring.rb +346 -0
- data/spec/runners/connection_string.rb +385 -0
- data/spec/runners/crud/context.rb +30 -0
- data/spec/runners/crud/operation.rb +471 -0
- data/spec/runners/crud/outcome.rb +56 -0
- data/spec/runners/crud/requirement.rb +134 -0
- data/spec/runners/crud/spec.rb +73 -0
- data/spec/runners/crud/test.rb +123 -0
- data/spec/runners/crud/test_base.rb +53 -0
- data/spec/runners/crud/verifier.rb +217 -0
- data/spec/runners/crud.rb +257 -0
- data/spec/runners/gridfs.rb +641 -0
- data/spec/runners/read_write_concern_document.rb +70 -0
- data/spec/runners/sdam/verifier.rb +112 -0
- data/spec/runners/sdam.rb +279 -0
- data/spec/runners/server_selection.rb +365 -0
- data/spec/runners/server_selection_rtt.rb +41 -0
- data/spec/runners/transactions/operation.rb +328 -0
- data/spec/runners/transactions/spec.rb +29 -0
- data/spec/runners/transactions/test.rb +326 -0
- data/spec/runners/transactions.rb +104 -0
- data/spec/runners/unified/assertions.rb +281 -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 +261 -0
- data/spec/runners/unified/test.rb +426 -0
- data/spec/runners/unified/test_group.rb +31 -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 +231 -0
- data/spec/shared/lib/mrss/constraints.rb +385 -0
- data/spec/shared/lib/mrss/docker_runner.rb +271 -0
- data/spec/shared/lib/mrss/event_subscriber.rb +200 -0
- data/spec/shared/lib/mrss/lite_constraints.rb +191 -0
- data/spec/shared/lib/mrss/server_version_registry.rb +120 -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 +323 -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 +367 -0
- data/spec/shared/shlib/set_env.sh +131 -0
- data/spec/solo/clean_exit_spec.rb +24 -0
- data/spec/spec_helper.rb +20 -175
- data/spec/spec_tests/auth_spec.rb +58 -0
- data/spec/spec_tests/change_streams_spec.rb +93 -0
- 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 +112 -0
- data/spec/spec_tests/collection_management_spec.rb +13 -0
- data/spec/spec_tests/command_monitoring_spec.rb +71 -0
- data/spec/spec_tests/command_monitoring_unified_spec.rb +13 -0
- data/spec/spec_tests/connection_string_spec.rb +10 -0
- data/spec/spec_tests/crud_spec.rb +22 -0
- 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 +101 -0
- 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 +535 -0
- 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 +27 -0
- data/spec/spec_tests/data/cmap/connection-must-order-ids.yml +27 -0
- data/spec/spec_tests/data/cmap/pool-checkin-destroy-closed.yml +27 -0
- data/spec/spec_tests/data/cmap/pool-checkin-destroy-stale.yml +27 -0
- data/spec/spec_tests/data/cmap/pool-checkin-make-available.yml +24 -0
- data/spec/spec_tests/data/cmap/pool-checkin.yml +19 -0
- data/spec/spec_tests/data/cmap/pool-checkout-connection.yml +19 -0
- data/spec/spec_tests/data/cmap/pool-checkout-error-closed.yml +36 -0
- data/spec/spec_tests/data/cmap/pool-checkout-multiple.yml +37 -0
- data/spec/spec_tests/data/cmap/pool-checkout-no-idle.yml +35 -0
- data/spec/spec_tests/data/cmap/pool-checkout-no-stale.yml +33 -0
- data/spec/spec_tests/data/cmap/pool-close-destroy-conns.yml +28 -0
- data/spec/spec_tests/data/cmap/pool-close.yml +11 -0
- data/spec/spec_tests/data/cmap/pool-create-max-size.yml +71 -0
- data/spec/spec_tests/data/cmap/pool-create-min-size.yml +34 -0
- data/spec/spec_tests/data/cmap/pool-create-with-options.yml +21 -0
- data/spec/spec_tests/data/cmap/pool-create.yml +12 -0
- data/spec/spec_tests/data/cmap/wait-queue-fairness.yml +124 -0
- data/spec/spec_tests/data/cmap/wait-queue-timeout.yml +46 -0
- data/spec/spec_tests/data/collection_management/timeseries-collection.yml +129 -0
- data/spec/spec_tests/data/command_monitoring/bulkWrite.yml +49 -0
- data/spec/spec_tests/data/command_monitoring/command.yml +61 -0
- data/spec/{support → spec_tests/data}/command_monitoring/deleteMany.yml +0 -0
- data/spec/{support → spec_tests/data}/command_monitoring/deleteOne.yml +0 -0
- data/spec/spec_tests/data/command_monitoring/find.yml +266 -0
- data/spec/spec_tests/data/command_monitoring/insertMany.yml +75 -0
- data/spec/{support → spec_tests/data}/command_monitoring/insertOne.yml +0 -0
- data/spec/spec_tests/data/command_monitoring/unacknowledgedBulkWrite.yml +34 -0
- data/spec/spec_tests/data/command_monitoring/updateMany.yml +65 -0
- data/spec/spec_tests/data/command_monitoring/updateOne.yml +90 -0
- data/spec/spec_tests/data/command_monitoring_unified/redacted-commands.yml +340 -0
- data/spec/spec_tests/data/connection_string/invalid-uris.yml +261 -0
- data/spec/spec_tests/data/connection_string/valid-auth.yml +257 -0
- data/spec/spec_tests/data/connection_string/valid-db-with-dotted-name.yml +77 -0
- data/spec/{support/connection_string_tests → spec_tests/data/connection_string}/valid-host_identifiers.yml +0 -0
- data/spec/spec_tests/data/connection_string/valid-options.yml +17 -0
- data/spec/spec_tests/data/connection_string/valid-unix_socket-absolute.yml +197 -0
- data/spec/spec_tests/data/connection_string/valid-unix_socket-relative.yml +213 -0
- data/spec/spec_tests/data/connection_string/valid-warnings.yml +75 -0
- data/spec/spec_tests/data/crud/read/aggregate-collation.yml +18 -0
- data/spec/spec_tests/data/crud/read/aggregate-out.yml +44 -0
- data/spec/spec_tests/data/crud/read/aggregate.yml +21 -0
- data/spec/spec_tests/data/crud/read/count-collation.yml +26 -0
- data/spec/spec_tests/data/crud/read/count-empty.yml +29 -0
- data/spec/spec_tests/data/crud/read/count.yml +74 -0
- data/spec/spec_tests/data/crud/read/distinct-collation.yml +18 -0
- data/spec/spec_tests/data/crud/read/distinct.yml +32 -0
- data/spec/spec_tests/data/crud/read/find-collation.yml +16 -0
- data/spec/spec_tests/data/crud/read/find.yml +49 -0
- data/spec/spec_tests/data/crud/write/bulkWrite-arrayFilters.yml +45 -0
- data/spec/spec_tests/data/crud/write/bulkWrite-collation.yml +102 -0
- data/spec/spec_tests/data/crud/write/bulkWrite.yml +405 -0
- data/spec/spec_tests/data/crud/write/deleteMany-collation.yml +23 -0
- data/spec/spec_tests/data/crud/write/deleteMany.yml +35 -0
- data/spec/spec_tests/data/crud/write/deleteOne-collation.yml +23 -0
- data/spec/spec_tests/data/crud/write/deleteOne.yml +48 -0
- data/spec/spec_tests/data/crud/write/findOneAndDelete-collation.yml +24 -0
- data/spec/spec_tests/data/crud/write/findOneAndDelete.yml +53 -0
- data/spec/spec_tests/data/crud/write/findOneAndReplace-collation.yml +25 -0
- data/spec/spec_tests/data/crud/write/findOneAndReplace-upsert.yml +91 -0
- data/spec/spec_tests/data/crud/write/findOneAndReplace-upsert_pre_2.6.yml +88 -0
- data/spec/spec_tests/data/crud/write/findOneAndReplace.yml +113 -0
- data/spec/spec_tests/data/crud/write/findOneAndUpdate-arrayFilters.yml +69 -0
- data/spec/spec_tests/data/crud/write/findOneAndUpdate-collation.yml +28 -0
- data/spec/spec_tests/data/crud/write/findOneAndUpdate.yml +163 -0
- data/spec/spec_tests/data/crud/write/insertMany.yml +81 -0
- data/spec/spec_tests/data/crud/write/insertOne.yml +18 -0
- data/spec/spec_tests/data/crud/write/replaceOne-collation.yml +25 -0
- data/spec/spec_tests/data/crud/write/replaceOne-pre_2.6.yml +98 -0
- data/spec/spec_tests/data/crud/write/replaceOne-upsert.yml +48 -0
- data/spec/spec_tests/data/crud/write/replaceOne.yml +102 -0
- data/spec/spec_tests/data/crud/write/updateMany-arrayFilters.yml +66 -0
- data/spec/spec_tests/data/crud/write/updateMany-collation.yml +29 -0
- data/spec/spec_tests/data/crud/write/updateMany-pre_2.6.yml +86 -0
- data/spec/spec_tests/data/crud/write/updateMany.yml +87 -0
- data/spec/spec_tests/data/crud/write/updateOne-arrayFilters.yml +114 -0
- data/spec/spec_tests/data/crud/write/updateOne-collation.yml +26 -0
- data/spec/spec_tests/data/crud/write/updateOne-pre_2.6.yml +83 -0
- data/spec/spec_tests/data/crud/write/updateOne.yml +84 -0
- 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 +103 -0
- data/spec/spec_tests/data/crud_v2/aggregate-out-readConcern.yml +111 -0
- data/spec/spec_tests/data/crud_v2/bulkWrite-arrayFilters.yml +103 -0
- 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 +39 -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 +157 -0
- data/spec/spec_tests/data/gridfs/delete.yml +123 -0
- data/spec/spec_tests/data/gridfs/download.yml +192 -0
- data/spec/{support/gridfs_tests → spec_tests/data/gridfs}/download_by_name.yml +0 -0
- data/spec/{support/gridfs_tests → spec_tests/data/gridfs}/upload.yml +0 -0
- data/spec/spec_tests/data/load_balancers/event-monitoring.yml +99 -0
- data/spec/spec_tests/data/load_balancers/lb-connection-establishment.yml +36 -0
- data/spec/spec_tests/data/load_balancers/non-lb-connection-establishment.yml +56 -0
- data/spec/spec_tests/data/load_balancers/server-selection.yml +50 -0
- data/spec/spec_tests/data/max_staleness/ReplicaSetNoPrimary/DefaultNoMaxStaleness.yml +26 -0
- data/spec/spec_tests/data/max_staleness/ReplicaSetNoPrimary/Incompatible.yml +25 -0
- data/spec/spec_tests/data/max_staleness/ReplicaSetNoPrimary/LastUpdateTime.yml +33 -0
- data/spec/spec_tests/data/max_staleness/ReplicaSetNoPrimary/MaxStalenessTooSmall.yml +15 -0
- data/spec/spec_tests/data/max_staleness/ReplicaSetNoPrimary/Nearest.yml +33 -0
- data/spec/spec_tests/data/max_staleness/ReplicaSetNoPrimary/Nearest2.yml +33 -0
- data/spec/spec_tests/data/max_staleness/ReplicaSetNoPrimary/NoKnownServers.yml +16 -0
- data/spec/spec_tests/data/max_staleness/ReplicaSetNoPrimary/PrimaryPreferred.yml +27 -0
- data/spec/spec_tests/data/max_staleness/ReplicaSetNoPrimary/PrimaryPreferred_tags.yml +36 -0
- data/spec/spec_tests/data/max_staleness/ReplicaSetNoPrimary/Secondary.yml +51 -0
- data/spec/spec_tests/data/max_staleness/ReplicaSetNoPrimary/SecondaryPreferred.yml +26 -0
- data/spec/spec_tests/data/max_staleness/ReplicaSetNoPrimary/SecondaryPreferred_tags.yml +51 -0
- data/spec/spec_tests/data/max_staleness/ReplicaSetNoPrimary/ZeroMaxStaleness.yml +23 -0
- data/spec/spec_tests/data/max_staleness/ReplicaSetWithPrimary/DefaultNoMaxStaleness.yml +26 -0
- data/spec/spec_tests/data/max_staleness/ReplicaSetWithPrimary/Incompatible.yml +25 -0
- data/spec/spec_tests/data/max_staleness/ReplicaSetWithPrimary/LastUpdateTime.yml +35 -0
- data/spec/spec_tests/data/max_staleness/ReplicaSetWithPrimary/LongHeartbeat.yml +29 -0
- data/spec/spec_tests/data/max_staleness/ReplicaSetWithPrimary/LongHeartbeat2.yml +25 -0
- data/spec/spec_tests/data/max_staleness/ReplicaSetWithPrimary/MaxStalenessTooSmall.yml +26 -0
- data/spec/spec_tests/data/max_staleness/ReplicaSetWithPrimary/MaxStalenessWithModePrimary.yml +23 -0
- data/spec/spec_tests/data/max_staleness/ReplicaSetWithPrimary/Nearest.yml +33 -0
- data/spec/spec_tests/data/max_staleness/ReplicaSetWithPrimary/Nearest2.yml +33 -0
- data/spec/spec_tests/data/max_staleness/ReplicaSetWithPrimary/Nearest_tags.yml +36 -0
- data/spec/spec_tests/data/max_staleness/ReplicaSetWithPrimary/PrimaryPreferred.yml +27 -0
- data/spec/spec_tests/data/max_staleness/ReplicaSetWithPrimary/PrimaryPreferred_incompatible.yml +27 -0
- data/spec/spec_tests/data/max_staleness/ReplicaSetWithPrimary/SecondaryPreferred.yml +26 -0
- data/spec/spec_tests/data/max_staleness/ReplicaSetWithPrimary/SecondaryPreferred_tags.yml +59 -0
- data/spec/spec_tests/data/max_staleness/ReplicaSetWithPrimary/SecondaryPreferred_tags2.yml +43 -0
- data/spec/spec_tests/data/max_staleness/ReplicaSetWithPrimary/Secondary_tags.yml +59 -0
- data/spec/spec_tests/data/max_staleness/ReplicaSetWithPrimary/Secondary_tags2.yml +43 -0
- data/spec/spec_tests/data/max_staleness/ReplicaSetWithPrimary/ZeroMaxStaleness.yml +23 -0
- data/spec/spec_tests/data/max_staleness/Sharded/Incompatible.yml +25 -0
- data/spec/spec_tests/data/max_staleness/Sharded/SmallMaxStaleness.yml +28 -0
- data/spec/spec_tests/data/max_staleness/Single/Incompatible.yml +18 -0
- data/spec/spec_tests/data/max_staleness/Single/SmallMaxStaleness.yml +20 -0
- data/spec/spec_tests/data/max_staleness/Unknown/SmallMaxStaleness.yml +15 -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 +157 -0
- data/spec/spec_tests/data/retryable_reads/aggregate.yml +87 -0
- data/spec/spec_tests/data/retryable_reads/changeStreams-client.watch-serverErrors.yml +150 -0
- data/spec/spec_tests/data/retryable_reads/changeStreams-client.watch.yml +62 -0
- data/spec/spec_tests/data/retryable_reads/changeStreams-db.coll.watch-serverErrors.yml +150 -0
- data/spec/spec_tests/data/retryable_reads/changeStreams-db.coll.watch.yml +66 -0
- data/spec/spec_tests/data/retryable_reads/changeStreams-db.watch-serverErrors.yml +154 -0
- data/spec/spec_tests/data/retryable_reads/changeStreams-db.watch.yml +62 -0
- data/spec/spec_tests/data/retryable_reads/count-serverErrors.yml +150 -0
- data/spec/spec_tests/data/retryable_reads/count.yml +64 -0
- data/spec/spec_tests/data/retryable_reads/countDocuments-serverErrors.yml +150 -0
- data/spec/spec_tests/data/retryable_reads/countDocuments.yml +64 -0
- data/spec/spec_tests/data/retryable_reads/distinct-serverErrors.yml +156 -0
- data/spec/spec_tests/data/retryable_reads/distinct.yml +71 -0
- data/spec/spec_tests/data/retryable_reads/estimatedDocumentCount-4.9.yml +60 -0
- data/spec/spec_tests/data/retryable_reads/estimatedDocumentCount-pre4.9.yml +64 -0
- data/spec/spec_tests/data/retryable_reads/estimatedDocumentCount-serverErrors-4.9.yml +146 -0
- data/spec/spec_tests/data/retryable_reads/estimatedDocumentCount-serverErrors-pre4.9.yml +150 -0
- data/spec/spec_tests/data/retryable_reads/find-serverErrors.yml +160 -0
- data/spec/spec_tests/data/retryable_reads/find.yml +86 -0
- data/spec/spec_tests/data/retryable_reads/findOne-serverErrors.yml +154 -0
- data/spec/spec_tests/data/retryable_reads/findOne.yml +68 -0
- data/spec/spec_tests/data/retryable_reads/gridfs-download-serverErrors.yml +173 -0
- data/spec/spec_tests/data/retryable_reads/gridfs-download.yml +79 -0
- data/spec/spec_tests/data/retryable_reads/gridfs-downloadByName-serverErrors.yml +174 -0
- data/spec/spec_tests/data/retryable_reads/gridfs-downloadByName.yml +79 -0
- data/spec/spec_tests/data/retryable_reads/listCollectionNames-serverErrors.yml +143 -0
- data/spec/spec_tests/data/retryable_reads/listCollectionNames.yml +59 -0
- data/spec/spec_tests/data/retryable_reads/listCollectionObjects-serverErrors.yml +144 -0
- data/spec/spec_tests/data/retryable_reads/listCollectionObjects.yml +59 -0
- data/spec/spec_tests/data/retryable_reads/listCollections-serverErrors.yml +143 -0
- data/spec/spec_tests/data/retryable_reads/listCollections.yml +59 -0
- data/spec/spec_tests/data/retryable_reads/listDatabaseNames-serverErrors.yml +143 -0
- data/spec/spec_tests/data/retryable_reads/listDatabaseNames.yml +59 -0
- data/spec/spec_tests/data/retryable_reads/listDatabaseObjects-serverErrors.yml +144 -0
- data/spec/spec_tests/data/retryable_reads/listDatabaseObjects.yml +59 -0
- data/spec/spec_tests/data/retryable_reads/listDatabases-serverErrors.yml +144 -0
- data/spec/spec_tests/data/retryable_reads/listDatabases.yml +59 -0
- data/spec/spec_tests/data/retryable_reads/listIndexNames-serverErrors.yml +144 -0
- data/spec/spec_tests/data/retryable_reads/listIndexNames.yml +60 -0
- data/spec/spec_tests/data/retryable_reads/listIndexes-serverErrors.yml +145 -0
- data/spec/spec_tests/data/retryable_reads/listIndexes.yml +60 -0
- data/spec/spec_tests/data/retryable_reads/mapReduce.yml +62 -0
- data/spec/spec_tests/data/retryable_writes/bulkWrite-errorLabels.yml +77 -0
- data/spec/spec_tests/data/retryable_writes/bulkWrite-serverErrors.yml +130 -0
- data/spec/spec_tests/data/retryable_writes/bulkWrite.yml +402 -0
- data/spec/spec_tests/data/retryable_writes/deleteMany.yml +22 -0
- data/spec/spec_tests/data/retryable_writes/deleteOne-errorLabels.yml +48 -0
- data/spec/spec_tests/data/retryable_writes/deleteOne-serverErrors.yml +73 -0
- data/spec/spec_tests/data/retryable_writes/deleteOne.yml +57 -0
- data/spec/spec_tests/data/retryable_writes/findOneAndDelete-errorLabels.yml +49 -0
- data/spec/spec_tests/data/retryable_writes/findOneAndDelete-serverErrors.yml +74 -0
- data/spec/spec_tests/data/retryable_writes/findOneAndDelete.yml +58 -0
- data/spec/spec_tests/data/retryable_writes/findOneAndReplace-errorLabels.yml +52 -0
- data/spec/spec_tests/data/retryable_writes/findOneAndReplace-serverErrors.yml +80 -0
- data/spec/spec_tests/data/retryable_writes/findOneAndReplace.yml +63 -0
- data/spec/spec_tests/data/retryable_writes/findOneAndUpdate-errorLabels.yml +52 -0
- data/spec/spec_tests/data/retryable_writes/findOneAndUpdate-serverErrors.yml +79 -0
- data/spec/spec_tests/data/retryable_writes/findOneAndUpdate.yml +62 -0
- data/spec/spec_tests/data/retryable_writes/insertMany-errorLabels.yml +54 -0
- data/spec/spec_tests/data/retryable_writes/insertMany-serverErrors.yml +84 -0
- data/spec/spec_tests/data/retryable_writes/insertMany.yml +74 -0
- data/spec/spec_tests/data/retryable_writes/insertOne-errorLabels.yml +44 -0
- data/spec/spec_tests/data/retryable_writes/insertOne-serverErrors.yml +527 -0
- data/spec/spec_tests/data/retryable_writes/insertOne.yml +61 -0
- data/spec/spec_tests/data/retryable_writes/replaceOne-errorLabels.yml +53 -0
- data/spec/spec_tests/data/retryable_writes/replaceOne-serverErrors.yml +82 -0
- data/spec/spec_tests/data/retryable_writes/replaceOne.yml +66 -0
- data/spec/spec_tests/data/retryable_writes/updateMany.yml +27 -0
- data/spec/spec_tests/data/retryable_writes/updateOne-errorLabels.yml +53 -0
- data/spec/spec_tests/data/retryable_writes/updateOne-serverErrors.yml +82 -0
- data/spec/spec_tests/data/retryable_writes/updateOne.yml +129 -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/load-balanced/discover_load_balancer.yml +25 -0
- data/spec/spec_tests/data/sdam/rs/compatible.yml +45 -0
- data/spec/spec_tests/data/sdam/rs/compatible_unknown.yml +34 -0
- data/spec/spec_tests/data/sdam/rs/discover_arbiters.yml +44 -0
- 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/discover_ghost_replicaset.yml +42 -0
- 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 +83 -0
- data/spec/spec_tests/data/sdam/rs/discover_passives_replicaset.yml +83 -0
- data/spec/spec_tests/data/sdam/rs/discover_primary.yml +43 -0
- 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/discover_rsother_replicaset.yml +68 -0
- data/spec/spec_tests/data/sdam/rs/discover_secondary.yml +44 -0
- data/spec/spec_tests/data/sdam/rs/discover_secondary_replicaset.yml +44 -0
- data/spec/spec_tests/data/sdam/rs/discovery.yml +207 -0
- data/spec/spec_tests/data/sdam/rs/equal_electionids.yml +57 -0
- data/spec/spec_tests/data/sdam/rs/hosts_differ_from_seeds.yml +37 -0
- data/spec/spec_tests/data/sdam/rs/incompatible_arbiter.yml +36 -0
- data/spec/spec_tests/data/sdam/rs/incompatible_ghost.yml +34 -0
- data/spec/spec_tests/data/sdam/rs/incompatible_other.yml +36 -0
- data/spec/spec_tests/data/sdam/rs/ls_timeout.yml +249 -0
- data/spec/spec_tests/data/sdam/rs/member_reconfig.yml +74 -0
- data/spec/spec_tests/data/sdam/rs/member_standalone.yml +66 -0
- data/spec/spec_tests/data/sdam/rs/new_primary.yml +80 -0
- data/spec/spec_tests/data/sdam/rs/new_primary_new_electionid.yml +119 -0
- data/spec/spec_tests/data/sdam/rs/new_primary_new_setversion.yml +119 -0
- data/spec/spec_tests/data/sdam/rs/new_primary_wrong_set_name.yml +77 -0
- data/spec/spec_tests/data/sdam/rs/non_rs_member.yml +33 -0
- data/spec/spec_tests/data/sdam/rs/normalize_case.yml +52 -0
- data/spec/spec_tests/data/sdam/rs/normalize_case_me.yml +102 -0
- data/spec/spec_tests/data/sdam/rs/null_election_id.yml +175 -0
- data/spec/spec_tests/data/sdam/rs/primary_becomes_ghost.yml +65 -0
- data/spec/spec_tests/data/sdam/rs/primary_becomes_mongos.yml +58 -0
- data/spec/spec_tests/data/sdam/rs/primary_becomes_standalone.yml +55 -0
- data/spec/spec_tests/data/sdam/rs/primary_changes_set_name.yml +63 -0
- data/spec/spec_tests/data/sdam/rs/primary_disconnect.yml +59 -0
- data/spec/spec_tests/data/sdam/rs/primary_disconnect_electionid.yml +189 -0
- data/spec/spec_tests/data/sdam/rs/primary_disconnect_setversion.yml +189 -0
- data/spec/spec_tests/data/sdam/rs/primary_hint_from_secondary_with_mismatched_me.yml +64 -0
- data/spec/spec_tests/data/sdam/rs/primary_mismatched_me.yml +27 -0
- 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 +175 -0
- data/spec/spec_tests/data/sdam/rs/primary_to_no_primary_mismatched_me.yml +81 -0
- data/spec/spec_tests/data/sdam/rs/primary_wrong_set_name.yml +30 -0
- 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 +69 -0
- data/spec/spec_tests/data/sdam/rs/ruby_primary_address_change.yml +31 -0
- data/spec/spec_tests/data/sdam/rs/ruby_secondary_wrong_set_name_with_primary_second.yml +73 -0
- data/spec/spec_tests/data/sdam/rs/sec_not_auth.yml +55 -0
- data/spec/spec_tests/data/sdam/rs/secondary_ignore_ok_0.yml +87 -0
- data/spec/spec_tests/data/sdam/rs/secondary_mismatched_me.yml +28 -0
- data/spec/spec_tests/data/sdam/rs/secondary_wrong_set_name.yml +31 -0
- data/spec/spec_tests/data/sdam/rs/secondary_wrong_set_name_with_primary.yml +75 -0
- data/spec/spec_tests/data/sdam/rs/setversion_without_electionid.yml +79 -0
- data/spec/spec_tests/data/sdam/rs/stepdown_change_set_name.yml +65 -0
- data/spec/spec_tests/data/sdam/rs/too_new.yml +45 -0
- data/spec/spec_tests/data/sdam/rs/too_old.yml +41 -0
- 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 +29 -0
- data/spec/spec_tests/data/sdam/rs/use_setversion_without_electionid.yml +117 -0
- data/spec/spec_tests/data/sdam/rs/wrong_set_name.yml +38 -0
- data/spec/spec_tests/data/sdam/sharded/compatible.yml +40 -0
- data/spec/spec_tests/data/sdam/sharded/discover_single_mongos.yml +24 -0
- data/spec/spec_tests/data/sdam/sharded/ls_timeout_mongos.yml +101 -0
- data/spec/spec_tests/data/sdam/sharded/mongos_disconnect.yml +113 -0
- data/spec/spec_tests/data/sdam/sharded/multiple_mongoses.yml +52 -0
- data/spec/spec_tests/data/sdam/sharded/non_mongos_removed.yml +47 -0
- data/spec/spec_tests/data/sdam/sharded/normalize_uri_case.yml +32 -0
- 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 +38 -0
- data/spec/spec_tests/data/sdam/sharded/too_old.yml +38 -0
- data/spec/spec_tests/data/sdam/single/compatible.yml +27 -0
- data/spec/spec_tests/data/sdam/single/direct_connection_external_ip.yml +37 -0
- data/spec/spec_tests/data/sdam/single/direct_connection_mongos.yml +36 -0
- data/spec/spec_tests/data/sdam/single/direct_connection_replicaset.yml +23 -0
- data/spec/spec_tests/data/sdam/single/direct_connection_rsarbiter.yml +38 -0
- data/spec/spec_tests/data/sdam/single/direct_connection_rsprimary.yml +37 -0
- data/spec/spec_tests/data/sdam/single/direct_connection_rssecondary.yml +38 -0
- data/spec/spec_tests/data/sdam/single/direct_connection_standalone.yml +35 -0
- data/spec/spec_tests/data/sdam/single/direct_connection_unavailable_seed.yml +28 -0
- 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 +36 -0
- data/spec/spec_tests/data/sdam/single/not_ok_response.yml +44 -0
- 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 +35 -0
- data/spec/spec_tests/data/sdam/single/standalone_using_legacy_hello.yml +34 -0
- data/spec/spec_tests/data/sdam/single/too_new.yml +27 -0
- data/spec/spec_tests/data/sdam/single/too_old.yml +25 -0
- 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 +85 -0
- data/spec/spec_tests/data/sdam_integration/find-shutdown-error.yml +118 -0
- data/spec/spec_tests/data/sdam_integration/hello-command-error.yml +160 -0
- data/spec/spec_tests/data/sdam_integration/hello-network-error.yml +158 -0
- data/spec/spec_tests/data/sdam_integration/hello-timeout.yml +225 -0
- data/spec/spec_tests/data/sdam_integration/insert-network-error.yml +88 -0
- data/spec/spec_tests/data/sdam_integration/insert-shutdown-error.yml +117 -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 +70 -0
- data/spec/spec_tests/data/sdam_monitoring/load_balancer.yml +65 -0
- data/spec/spec_tests/data/sdam_monitoring/replica_set_other_chain.yml +222 -0
- data/spec/spec_tests/data/sdam_monitoring/replica_set_other_change.yml +225 -0
- data/spec/spec_tests/data/sdam_monitoring/replica_set_primary_address_change.yml +251 -0
- 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 +113 -0
- data/spec/spec_tests/data/sdam_monitoring/replica_set_with_primary.yml +112 -0
- data/spec/spec_tests/data/sdam_monitoring/replica_set_with_primary_and_secondary.yml +198 -0
- data/spec/spec_tests/data/sdam_monitoring/replica_set_with_primary_removal.yml +175 -0
- data/spec/spec_tests/data/sdam_monitoring/replica_set_with_removal.yml +111 -0
- data/spec/spec_tests/data/sdam_monitoring/replica_set_with_second_seed_removal.yml +106 -0
- data/spec/spec_tests/data/sdam_monitoring/required_replica_set.yml +108 -0
- data/spec/spec_tests/data/sdam_monitoring/standalone.yml +70 -0
- data/spec/spec_tests/data/sdam_monitoring/standalone_repeated.yml +86 -0
- 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/seed_list_discovery/load-balanced/loadBalanced-directConnection.yml +13 -0
- data/spec/spec_tests/data/seed_list_discovery/load-balanced/loadBalanced-replicaSet-errors.yml +6 -0
- data/spec/spec_tests/data/seed_list_discovery/load-balanced/loadBalanced-true-multiple-hosts.yml +5 -0
- data/spec/spec_tests/data/seed_list_discovery/load-balanced/loadBalanced-true-txt.yml +10 -0
- data/spec/spec_tests/data/seed_list_discovery/replica-set/direct-connection-false.yml +10 -0
- data/spec/spec_tests/data/seed_list_discovery/replica-set/direct-connection-true.yml +5 -0
- data/spec/spec_tests/data/seed_list_discovery/replica-set/encoded-userinfo-and-db.yml +15 -0
- data/spec/spec_tests/data/seed_list_discovery/replica-set/loadBalanced-false-txt.yml +10 -0
- data/spec/spec_tests/data/seed_list_discovery/replica-set/longer-parent-in-return.yml +11 -0
- data/spec/spec_tests/data/seed_list_discovery/replica-set/misformatted-option.yml +5 -0
- data/spec/spec_tests/data/seed_list_discovery/replica-set/no-results.yml +5 -0
- data/spec/spec_tests/data/seed_list_discovery/replica-set/not-enough-parts.yml +5 -0
- data/spec/spec_tests/data/seed_list_discovery/replica-set/one-result-default-port.yml +10 -0
- data/spec/spec_tests/data/seed_list_discovery/replica-set/one-txt-record-multiple-strings.yml +10 -0
- data/spec/spec_tests/data/seed_list_discovery/replica-set/one-txt-record.yml +11 -0
- data/spec/spec_tests/data/seed_list_discovery/replica-set/parent-part-mismatch1.yml +5 -0
- data/spec/spec_tests/data/seed_list_discovery/replica-set/parent-part-mismatch2.yml +5 -0
- data/spec/spec_tests/data/seed_list_discovery/replica-set/parent-part-mismatch3.yml +5 -0
- data/spec/spec_tests/data/seed_list_discovery/replica-set/parent-part-mismatch4.yml +5 -0
- data/spec/spec_tests/data/seed_list_discovery/replica-set/parent-part-mismatch5.yml +5 -0
- data/spec/spec_tests/data/seed_list_discovery/replica-set/returned-parent-too-short.yml +5 -0
- data/spec/spec_tests/data/seed_list_discovery/replica-set/returned-parent-wrong.yml +5 -0
- data/spec/spec_tests/data/seed_list_discovery/replica-set/two-results-default-port.yml +11 -0
- data/spec/spec_tests/data/seed_list_discovery/replica-set/two-results-nonstandard-port.yml +11 -0
- data/spec/spec_tests/data/seed_list_discovery/replica-set/two-txt-records.yml +5 -0
- data/spec/spec_tests/data/seed_list_discovery/replica-set/txt-record-not-allowed-option.yml +5 -0
- data/spec/spec_tests/data/seed_list_discovery/replica-set/txt-record-with-overridden-ssl-option.yml +11 -0
- data/spec/spec_tests/data/seed_list_discovery/replica-set/txt-record-with-overridden-uri-option.yml +11 -0
- data/spec/spec_tests/data/seed_list_discovery/replica-set/txt-record-with-unallowed-option.yml +5 -0
- data/spec/spec_tests/data/seed_list_discovery/replica-set/uri-with-admin-database.yml +13 -0
- data/spec/spec_tests/data/seed_list_discovery/replica-set/uri-with-auth.yml +12 -0
- data/spec/spec_tests/data/seed_list_discovery/replica-set/uri-with-port.yml +5 -0
- data/spec/spec_tests/data/seed_list_discovery/replica-set/uri-with-two-hosts.yml +5 -0
- data/spec/spec_tests/data/server_selection/ReplicaSetNoPrimary/read/Nearest.yml +25 -0
- data/spec/spec_tests/data/server_selection/ReplicaSetNoPrimary/read/Nearest_multiple.yml +26 -0
- data/spec/spec_tests/data/server_selection/ReplicaSetNoPrimary/read/Nearest_non_matching.yml +20 -0
- data/spec/spec_tests/data/server_selection/ReplicaSetNoPrimary/read/PossiblePrimary.yml +15 -0
- data/spec/spec_tests/data/server_selection/ReplicaSetNoPrimary/read/PossiblePrimaryNearest.yml +15 -0
- data/spec/spec_tests/data/server_selection/ReplicaSetNoPrimary/read/Primary.yml +18 -0
- data/spec/spec_tests/data/server_selection/ReplicaSetNoPrimary/read/PrimaryPreferred.yml +25 -0
- data/spec/spec_tests/data/server_selection/ReplicaSetNoPrimary/read/PrimaryPreferred_non_matching.yml +20 -0
- data/spec/spec_tests/data/server_selection/ReplicaSetNoPrimary/read/Secondary.yml +25 -0
- data/spec/spec_tests/data/server_selection/ReplicaSetNoPrimary/read/SecondaryPreferred.yml +25 -0
- data/spec/spec_tests/data/server_selection/ReplicaSetNoPrimary/read/SecondaryPreferred_non_matching.yml +20 -0
- data/spec/spec_tests/data/server_selection/ReplicaSetNoPrimary/read/Secondary_multi_tags.yml +31 -0
- data/spec/spec_tests/data/server_selection/ReplicaSetNoPrimary/read/Secondary_multi_tags2.yml +31 -0
- data/spec/spec_tests/data/server_selection/ReplicaSetNoPrimary/read/Secondary_non_matching.yml +20 -0
- data/spec/spec_tests/data/server_selection/ReplicaSetWithPrimary/read/Nearest.yml +32 -0
- data/spec/spec_tests/data/server_selection/ReplicaSetWithPrimary/read/Nearest_multiple.yml +33 -0
- data/spec/spec_tests/data/server_selection/ReplicaSetWithPrimary/read/Nearest_non_matching.yml +25 -0
- data/spec/spec_tests/data/server_selection/ReplicaSetWithPrimary/read/Primary.yml +26 -0
- data/spec/spec_tests/data/server_selection/ReplicaSetWithPrimary/read/PrimaryPreferred.yml +28 -0
- data/spec/spec_tests/data/server_selection/ReplicaSetWithPrimary/read/PrimaryPreferred_non_matching.yml +28 -0
- data/spec/spec_tests/data/server_selection/ReplicaSetWithPrimary/read/Secondary.yml +30 -0
- data/spec/spec_tests/data/server_selection/ReplicaSetWithPrimary/read/SecondaryPreferred.yml +30 -0
- data/spec/spec_tests/data/server_selection/ReplicaSetWithPrimary/read/SecondaryPreferred_non_matching.yml +28 -0
- data/spec/spec_tests/data/server_selection/ReplicaSetWithPrimary/read/SecondaryPreferred_tags.yml +28 -0
- data/spec/spec_tests/data/server_selection/ReplicaSetWithPrimary/read/Secondary_non_matching.yml +25 -0
- data/spec/spec_tests/data/server_selection/Sharded/read/Nearest.yml +21 -0
- data/spec/spec_tests/data/server_selection/Sharded/read/Primary.yml +19 -0
- data/spec/spec_tests/data/server_selection/Sharded/read/PrimaryPreferred.yml +21 -0
- data/spec/spec_tests/data/server_selection/Sharded/read/Secondary.yml +21 -0
- data/spec/spec_tests/data/server_selection/Sharded/read/SecondaryPreferred.yml +21 -0
- data/spec/spec_tests/data/server_selection/Single/read/SecondaryPreferred.yml +18 -0
- data/spec/spec_tests/data/server_selection/Unknown/read/SecondaryPreferred.yml +10 -0
- data/spec/{support/server_selection/rtt → spec_tests/data/server_selection_rtt}/first_value.yml +0 -0
- data/spec/{support/server_selection/rtt → spec_tests/data/server_selection_rtt}/first_value_zero.yml +0 -0
- data/spec/{support/server_selection/rtt → spec_tests/data/server_selection_rtt}/value_test_1.yml +0 -0
- data/spec/{support/server_selection/rtt → spec_tests/data/server_selection_rtt}/value_test_2.yml +0 -0
- data/spec/{support/server_selection/rtt → spec_tests/data/server_selection_rtt}/value_test_3.yml +0 -0
- data/spec/{support/server_selection/rtt → spec_tests/data/server_selection_rtt}/value_test_4.yml +0 -0
- data/spec/{support/server_selection/rtt → spec_tests/data/server_selection_rtt}/value_test_5.yml +0 -0
- data/spec/spec_tests/data/transactions/abort.yml +413 -0
- data/spec/spec_tests/data/transactions/bulk.yml +267 -0
- data/spec/spec_tests/data/transactions/causal-consistency.yml +175 -0
- data/spec/spec_tests/data/transactions/commit.yml +603 -0
- data/spec/spec_tests/data/transactions/count.yml +67 -0
- 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/delete.yml +192 -0
- data/spec/spec_tests/data/transactions/error-labels.yml +1030 -0
- data/spec/spec_tests/data/transactions/errors-client.yml +56 -0
- data/spec/spec_tests/data/transactions/errors.yml +133 -0
- data/spec/spec_tests/data/transactions/findOneAndDelete.yml +134 -0
- data/spec/spec_tests/data/transactions/findOneAndReplace.yml +148 -0
- data/spec/spec_tests/data/transactions/findOneAndUpdate.yml +236 -0
- data/spec/spec_tests/data/transactions/insert.yml +390 -0
- data/spec/spec_tests/data/transactions/isolation.yml +133 -0
- data/spec/spec_tests/data/transactions/mongos-pin-auto.yml +1674 -0
- data/spec/spec_tests/data/transactions/mongos-recovery-token.yml +350 -0
- data/spec/spec_tests/data/transactions/pin-mongos.yml +559 -0
- data/spec/spec_tests/data/transactions/read-concern.yml +623 -0
- data/spec/spec_tests/data/transactions/read-pref.yml +348 -0
- data/spec/spec_tests/data/transactions/reads.yml +261 -0
- data/spec/spec_tests/data/transactions/retryable-abort-errorLabels.yml +126 -0
- data/spec/spec_tests/data/transactions/retryable-abort.yml +1317 -0
- data/spec/spec_tests/data/transactions/retryable-commit-errorLabels.yml +134 -0
- data/spec/spec_tests/data/transactions/retryable-commit.yml +1462 -0
- data/spec/spec_tests/data/transactions/retryable-writes.yml +218 -0
- data/spec/spec_tests/data/transactions/run-command.yml +197 -0
- data/spec/spec_tests/data/transactions/transaction-options-repl.yml +117 -0
- data/spec/spec_tests/data/transactions/transaction-options.yml +781 -0
- data/spec/spec_tests/data/transactions/update.yml +246 -0
- data/spec/spec_tests/data/transactions/write-concern.yml +554 -0
- data/spec/spec_tests/data/transactions_api/callback-aborts.yml +170 -0
- data/spec/spec_tests/data/transactions_api/callback-commits.yml +204 -0
- data/spec/spec_tests/data/transactions_api/callback-retry.yml +215 -0
- data/spec/spec_tests/data/transactions_api/commit-retry.yml +324 -0
- data/spec/spec_tests/data/transactions_api/commit-transienttransactionerror-4.2.yml +139 -0
- data/spec/spec_tests/data/transactions_api/commit-transienttransactionerror.yml +175 -0
- data/spec/spec_tests/data/transactions_api/commit-writeconcernerror.yml +216 -0
- data/spec/spec_tests/data/transactions_api/commit.yml +193 -0
- data/spec/spec_tests/data/transactions_api/transaction-options.yml +274 -0
- 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 +49 -0
- data/spec/spec_tests/data/uri_options/compression-options.yml +51 -0
- data/spec/spec_tests/data/uri_options/concern-options.yml +55 -0
- data/spec/spec_tests/data/uri_options/connection-options.yml +209 -0
- data/spec/spec_tests/data/uri_options/connection-pool-options.yml +26 -0
- data/spec/spec_tests/data/uri_options/read-preference-options.yml +66 -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 +364 -0
- 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/gridfs_spec.rb +55 -0
- data/spec/spec_tests/load_balancers_spec.rb +15 -0
- data/spec/spec_tests/max_staleness_spec.rb +12 -0
- 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 +50 -0
- data/spec/spec_tests/retryable_writes_spec.rb +22 -0
- data/spec/spec_tests/sdam_integration_spec.rb +16 -0
- data/spec/spec_tests/sdam_monitoring_spec.rb +101 -0
- data/spec/spec_tests/sdam_spec.rb +242 -0
- data/spec/spec_tests/seed_list_discovery_spec.rb +118 -0
- data/spec/spec_tests/server_selection_rtt_spec.rb +33 -0
- data/spec/spec_tests/server_selection_spec.rb +12 -0
- data/spec/spec_tests/transactions_api_spec.rb +13 -0
- data/spec/spec_tests/transactions_spec.rb +13 -0
- 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 +93 -0
- 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 +108 -0
- data/spec/stress/push_monitor_close_spec.rb +44 -0
- data/spec/support/authorization.rb +61 -153
- 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 +106 -0
- data/spec/support/certificates/atlas-ocsp-ca.crt +110 -0
- data/spec/support/certificates/atlas-ocsp.crt +157 -0
- data/spec/support/certificates/ca.crt +76 -0
- data/spec/support/certificates/client-encrypted.key +30 -0
- data/spec/support/certificates/client-int.crt +78 -0
- data/spec/support/certificates/client-second-level-bundle.pem +179 -0
- data/spec/support/certificates/client-second-level.crt +74 -0
- data/spec/support/certificates/client-second-level.key +27 -0
- data/spec/support/certificates/client-second-level.pem +101 -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/client.crt +74 -0
- data/spec/support/certificates/client.key +27 -0
- data/spec/support/certificates/client.pem +90 -90
- data/spec/support/certificates/crl.pem +10 -8
- data/spec/support/certificates/crl_client_revoked.pem +11 -10
- data/spec/support/certificates/multi-ca.crt +152 -0
- data/spec/support/certificates/python-ca.crt +76 -0
- data/spec/support/certificates/server-int.crt +78 -0
- data/spec/support/certificates/server-second-level-bundle.pem +179 -0
- data/spec/support/certificates/server-second-level.crt +74 -0
- data/spec/support/certificates/server-second-level.key +27 -0
- data/spec/support/certificates/server-second-level.pem +101 -0
- data/spec/support/certificates/server.pem +99 -32
- data/spec/support/client_registry.rb +254 -0
- data/spec/support/client_registry_macros.rb +26 -0
- data/spec/support/cluster_tools.rb +379 -0
- data/spec/support/common_shortcuts.rb +374 -0
- data/spec/support/constraints.rb +19 -0
- 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/json_ext_formatter.rb +16 -0
- data/spec/support/keyword_struct.rb +29 -0
- data/spec/support/local_resource_registry.rb +37 -0
- data/spec/support/matchers.rb +52 -1
- data/spec/support/monitoring_ext.rb +19 -0
- data/spec/support/ocsp +1 -0
- data/spec/support/primary_socket.rb +24 -0
- data/spec/support/sdam_formatter_integration.rb +119 -0
- data/spec/support/session_registry.rb +55 -0
- data/spec/support/shared/app_metadata.rb +167 -0
- data/spec/support/shared/auth_context.rb +16 -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 +119 -63
- data/spec/support/shared/session.rb +910 -0
- data/spec/support/spec_config.rb +636 -0
- data/spec/support/spec_setup.rb +83 -0
- data/spec/support/using_hash.rb +31 -0
- data/spec/support/utils.rb +598 -0
- data.tar.gz.sig +0 -0
- metadata +2470 -519
- metadata.gz.sig +2 -2
- data/lib/csasl/csasl.bundle +0 -0
- data/lib/mongo/cluster/cursor_reaper.rb +0 -174
- data/lib/mongo/cluster/topology/replica_set.rb +0 -271
- data/lib/mongo/collection/view/builder/find_command.rb +0 -136
- data/lib/mongo/collection/view/builder/flags.rb +0 -62
- data/lib/mongo/collection/view/builder/modifiers.rb +0 -80
- data/lib/mongo/collection/view/builder/op_query.rb +0 -83
- data/lib/mongo/cursor/builder/get_more_command.rb +0 -72
- data/lib/mongo/cursor/builder/kill_cursors_command.rb +0 -90
- data/lib/mongo/cursor/builder/op_get_more.rb +0 -61
- data/lib/mongo/cursor/builder/op_kill_cursors.rb +0 -84
- data/lib/mongo/cursor/builder.rb +0 -18
- data/lib/mongo/event/description_changed.rb +0 -54
- data/lib/mongo/event/primary_elected.rb +0 -53
- data/lib/mongo/event/standalone_discovered.rb +0 -53
- data/lib/mongo/operation/commands/aggregate/result.rb +0 -89
- data/lib/mongo/operation/commands/aggregate.rb +0 -64
- data/lib/mongo/operation/commands/collections_info/result.rb +0 -41
- data/lib/mongo/operation/commands/collections_info.rb +0 -71
- data/lib/mongo/operation/commands/command.rb +0 -47
- data/lib/mongo/operation/commands/find/result.rb +0 -62
- data/lib/mongo/operation/commands/find.rb +0 -27
- data/lib/mongo/operation/commands/get_more/result.rb +0 -62
- data/lib/mongo/operation/commands/get_more.rb +0 -27
- data/lib/mongo/operation/commands/indexes.rb +0 -73
- data/lib/mongo/operation/commands/list_collections/result.rb +0 -94
- data/lib/mongo/operation/commands/list_collections.rb +0 -48
- data/lib/mongo/operation/commands/list_indexes/result.rb +0 -98
- data/lib/mongo/operation/commands/list_indexes.rb +0 -48
- data/lib/mongo/operation/commands/map_reduce/result.rb +0 -119
- data/lib/mongo/operation/commands/map_reduce.rb +0 -49
- data/lib/mongo/operation/commands/parallel_scan/result.rb +0 -64
- data/lib/mongo/operation/commands/parallel_scan.rb +0 -52
- data/lib/mongo/operation/commands/user_query.rb +0 -72
- data/lib/mongo/operation/commands/users_info/result.rb +0 -44
- data/lib/mongo/operation/commands/users_info.rb +0 -48
- data/lib/mongo/operation/commands.rb +0 -26
- data/lib/mongo/operation/executable.rb +0 -42
- data/lib/mongo/operation/limited.rb +0 -37
- data/lib/mongo/operation/object_id_generator.rb +0 -36
- data/lib/mongo/operation/read/get_more.rb +0 -52
- data/lib/mongo/operation/read/query/result.rb +0 -40
- data/lib/mongo/operation/read/query.rb +0 -55
- data/lib/mongo/operation/read.rb +0 -16
- data/lib/mongo/operation/read_preference.rb +0 -61
- data/lib/mongo/operation/specifiable.rb +0 -473
- data/lib/mongo/operation/write/bulk/bulkable.rb +0 -83
- data/lib/mongo/operation/write/bulk/delete/result.rb +0 -71
- data/lib/mongo/operation/write/bulk/delete.rb +0 -71
- data/lib/mongo/operation/write/bulk/insert/result.rb +0 -129
- data/lib/mongo/operation/write/bulk/insert.rb +0 -96
- data/lib/mongo/operation/write/bulk/legacy_mergable.rb +0 -87
- data/lib/mongo/operation/write/bulk/mergable.rb +0 -71
- data/lib/mongo/operation/write/bulk/update/result.rb +0 -205
- data/lib/mongo/operation/write/bulk/update.rb +0 -81
- data/lib/mongo/operation/write/bulk.rb +0 -20
- data/lib/mongo/operation/write/command/create_index.rb +0 -49
- data/lib/mongo/operation/write/command/create_user.rb +0 -42
- data/lib/mongo/operation/write/command/delete.rb +0 -56
- data/lib/mongo/operation/write/command/drop_index.rb +0 -50
- data/lib/mongo/operation/write/command/insert.rb +0 -66
- data/lib/mongo/operation/write/command/remove_user.rb +0 -41
- data/lib/mongo/operation/write/command/update.rb +0 -62
- data/lib/mongo/operation/write/command/update_user.rb +0 -42
- data/lib/mongo/operation/write/command/writable.rb +0 -57
- data/lib/mongo/operation/write/command.rb +0 -23
- data/lib/mongo/operation/write/create_index.rb +0 -67
- data/lib/mongo/operation/write/create_user.rb +0 -50
- data/lib/mongo/operation/write/delete/result.rb +0 -40
- data/lib/mongo/operation/write/delete.rb +0 -71
- data/lib/mongo/operation/write/drop_index.rb +0 -63
- data/lib/mongo/operation/write/gle.rb +0 -49
- data/lib/mongo/operation/write/idable.rb +0 -63
- data/lib/mongo/operation/write/insert/result.rb +0 -62
- data/lib/mongo/operation/write/insert.rb +0 -71
- data/lib/mongo/operation/write/remove_user.rb +0 -48
- data/lib/mongo/operation/write/update/result.rb +0 -160
- data/lib/mongo/operation/write/update.rb +0 -81
- data/lib/mongo/operation/write/update_user.rb +0 -50
- data/lib/mongo/operation/write/write_command_enabled.rb +0 -54
- data/lib/mongo/operation/write.rb +0 -27
- data/lib/mongo/server/connectable.rb +0 -113
- data/lib/mongo/server/connection_pool/queue.rb +0 -197
- data/lib/mongo/server/context.rb +0 -69
- data/lib/mongo/server/description/inspector/description_changed.rb +0 -57
- data/lib/mongo/server/description/inspector/primary_elected.rb +0 -58
- data/lib/mongo/server/description/inspector/standalone_discovered.rb +0 -56
- data/lib/mongo/server/description/inspector.rb +0 -79
- data/lib/mongo/server_selector/selectable.rb +0 -222
- data/lib/mongo/write_concern/normalizable.rb +0 -52
- data/spec/mongo/collection/view/builder/flags_spec.rb +0 -106
- data/spec/mongo/collection/view/builder/modifiers_spec.rb +0 -210
- data/spec/mongo/command_monitoring_spec.rb +0 -64
- data/spec/mongo/connection_string_spec.rb +0 -115
- data/spec/mongo/crud_spec.rb +0 -42
- data/spec/mongo/gridfs_spec.rb +0 -50
- data/spec/mongo/operation/commands/aggregate/result_spec.rb +0 -80
- data/spec/mongo/operation/commands/aggregate_spec.rb +0 -72
- data/spec/mongo/operation/commands/collections_info_spec.rb +0 -40
- data/spec/mongo/operation/commands/command_spec.rb +0 -80
- data/spec/mongo/operation/commands/indexes_spec.rb +0 -31
- data/spec/mongo/operation/commands/map_reduce_spec.rb +0 -125
- data/spec/mongo/operation/read/get_more_spec.rb +0 -53
- data/spec/mongo/operation/read/query_spec.rb +0 -102
- data/spec/mongo/operation/read_preference_spec.rb +0 -245
- data/spec/mongo/operation/write/bulk/delete_spec.rb +0 -223
- data/spec/mongo/operation/write/bulk/insert_spec.rb +0 -250
- data/spec/mongo/operation/write/bulk/update_spec.rb +0 -220
- data/spec/mongo/operation/write/command/delete_spec.rb +0 -106
- data/spec/mongo/operation/write/command/insert_spec.rb +0 -105
- data/spec/mongo/operation/write/command/update_spec.rb +0 -110
- data/spec/mongo/operation/write/create_index_spec.rb +0 -63
- data/spec/mongo/operation/write/create_user_spec.rb +0 -44
- data/spec/mongo/operation/write/delete_spec.rb +0 -215
- data/spec/mongo/operation/write/drop_index_spec.rb +0 -51
- data/spec/mongo/operation/write/insert_spec.rb +0 -291
- data/spec/mongo/operation/write/remove_user_spec.rb +0 -46
- data/spec/mongo/operation/write/update_spec.rb +0 -256
- data/spec/mongo/operation/write/update_user_spec.rb +0 -46
- data/spec/mongo/server/connection_pool/queue_spec.rb +0 -190
- data/spec/mongo/server/description/inspector/description_changed_spec.rb +0 -78
- data/spec/mongo/server/description/inspector/primary_elected_spec.rb +0 -94
- data/spec/mongo/server_discovery_and_monitoring_spec.rb +0 -115
- data/spec/mongo/server_selection_rtt_spec.rb +0 -85
- data/spec/mongo/server_selection_spec.rb +0 -90
- data/spec/support/certificates/ca.pem +0 -17
- data/spec/support/certificates/password_protected.pem +0 -51
- data/spec/support/command_monitoring/bulkWrite.yml +0 -73
- data/spec/support/command_monitoring/command.yml +0 -42
- data/spec/support/command_monitoring/find.yml +0 -268
- data/spec/support/command_monitoring/insertMany.yml +0 -81
- data/spec/support/command_monitoring/updateMany.yml +0 -67
- data/spec/support/command_monitoring/updateOne.yml +0 -95
- data/spec/support/command_monitoring.rb +0 -376
- data/spec/support/connection_string.rb +0 -228
- data/spec/support/connection_string_tests/invalid-uris.yml +0 -193
- data/spec/support/connection_string_tests/valid-auth.yml +0 -256
- data/spec/support/connection_string_tests/valid-options.yml +0 -30
- data/spec/support/connection_string_tests/valid-unix_socket-absolute.yml +0 -197
- data/spec/support/connection_string_tests/valid-unix_socket-relative.yml +0 -213
- data/spec/support/connection_string_tests/valid-warnings.yml +0 -55
- data/spec/support/crud/read.rb +0 -164
- data/spec/support/crud/write.rb +0 -243
- data/spec/support/crud.rb +0 -211
- data/spec/support/crud_tests/read/aggregate.yml +0 -43
- data/spec/support/crud_tests/read/count.yml +0 -37
- data/spec/support/crud_tests/read/distinct.yml +0 -33
- data/spec/support/crud_tests/read/find.yml +0 -50
- data/spec/support/crud_tests/write/deleteMany.yml +0 -36
- data/spec/support/crud_tests/write/deleteOne.yml +0 -49
- data/spec/support/crud_tests/write/findOneAndDelete.yml +0 -54
- data/spec/support/crud_tests/write/findOneAndReplace.yml +0 -153
- data/spec/support/crud_tests/write/findOneAndUpdate.yml +0 -161
- data/spec/support/crud_tests/write/insertMany.yml +0 -24
- data/spec/support/crud_tests/write/insertOne.yml +0 -19
- data/spec/support/crud_tests/write/replaceOne.yml +0 -96
- data/spec/support/crud_tests/write/updateMany.yml +0 -83
- data/spec/support/crud_tests/write/updateOne.yml +0 -80
- data/spec/support/gridfs.rb +0 -637
- data/spec/support/gridfs_tests/delete.yml +0 -157
- data/spec/support/gridfs_tests/download.yml +0 -210
- data/spec/support/helpers.rb +0 -140
- data/spec/support/sdam/rs/discover_arbiters.yml +0 -41
- data/spec/support/sdam/rs/discover_passives.yml +0 -77
- data/spec/support/sdam/rs/discover_primary.yml +0 -40
- data/spec/support/sdam/rs/discover_secondary.yml +0 -41
- data/spec/support/sdam/rs/discovery.yml +0 -195
- data/spec/support/sdam/rs/equal_electionids.yml +0 -48
- data/spec/support/sdam/rs/ghost_discovered.yml +0 -39
- data/spec/support/sdam/rs/hosts_differ_from_seeds.yml +0 -34
- data/spec/support/sdam/rs/member_reconfig.yml +0 -68
- data/spec/support/sdam/rs/member_standalone.yml +0 -60
- data/spec/support/sdam/rs/new_primary.yml +0 -74
- data/spec/support/sdam/rs/new_primary_new_electionid.yml +0 -101
- data/spec/support/sdam/rs/new_primary_new_setversion.yml +0 -101
- data/spec/support/sdam/rs/new_primary_wrong_set_name.yml +0 -71
- data/spec/support/sdam/rs/non_rs_member.yml +0 -31
- data/spec/support/sdam/rs/normalize_case.yml +0 -49
- data/spec/support/sdam/rs/null_election_id.yml +0 -151
- data/spec/support/sdam/rs/primary_becomes_standalone.yml +0 -52
- data/spec/support/sdam/rs/primary_changes_set_name.yml +0 -57
- data/spec/support/sdam/rs/primary_disconnect.yml +0 -56
- data/spec/support/sdam/rs/primary_disconnect_electionid.yml +0 -160
- data/spec/support/sdam/rs/primary_disconnect_setversion.yml +0 -160
- data/spec/support/sdam/rs/primary_mismatched_me.yml +0 -37
- data/spec/support/sdam/rs/primary_reports_new_member.yml +0 -163
- data/spec/support/sdam/rs/primary_to_no_primary_mismatched_me.yml +0 -75
- data/spec/support/sdam/rs/primary_wrong_set_name.yml +0 -27
- data/spec/support/sdam/rs/response_from_removed.yml +0 -63
- data/spec/support/sdam/rs/rsother_discovered.yml +0 -62
- data/spec/support/sdam/rs/sec_not_auth.yml +0 -49
- data/spec/support/sdam/rs/secondary_mismatched_me.yml +0 -37
- data/spec/support/sdam/rs/secondary_wrong_set_name.yml +0 -28
- data/spec/support/sdam/rs/secondary_wrong_set_name_with_primary.yml +0 -69
- data/spec/support/sdam/rs/set_version_without_electionid.yml +0 -69
- data/spec/support/sdam/rs/setversion_without_electionid.yml +0 -69
- data/spec/support/sdam/rs/stepdown_change_set_name.yml +0 -59
- data/spec/support/sdam/rs/unexpected_mongos.yml +0 -26
- data/spec/support/sdam/rs/use_setversion_without_electionid.yml +0 -99
- data/spec/support/sdam/rs/wrong_set_name.yml +0 -35
- data/spec/support/sdam/sharded/mongos_disconnect.yml +0 -104
- data/spec/support/sdam/sharded/multiple_mongoses.yml +0 -46
- data/spec/support/sdam/sharded/non_mongos_removed.yml +0 -41
- data/spec/support/sdam/sharded/normalize_uri_case.yml +0 -32
- data/spec/support/sdam/sharded/single_mongos.yml +0 -33
- data/spec/support/sdam/single/direct_connection_external_ip.yml +0 -34
- data/spec/support/sdam/single/direct_connection_mongos.yml +0 -33
- data/spec/support/sdam/single/direct_connection_rsarbiter.yml +0 -35
- data/spec/support/sdam/single/direct_connection_rsprimary.yml +0 -34
- data/spec/support/sdam/single/direct_connection_rssecondary.yml +0 -35
- data/spec/support/sdam/single/direct_connection_slave.yml +0 -32
- data/spec/support/sdam/single/direct_connection_standalone.yml +0 -32
- data/spec/support/sdam/single/not_ok_response.yml +0 -38
- data/spec/support/sdam/single/standalone_removed.yml +0 -32
- data/spec/support/sdam/single/unavailable_seed.yml +0 -28
- data/spec/support/server_discovery_and_monitoring.rb +0 -186
- data/spec/support/server_selection/selection/ReplicaSetNoPrimary/read/Nearest.yml +0 -26
- data/spec/support/server_selection/selection/ReplicaSetNoPrimary/read/Nearest_non_matching.yml +0 -21
- data/spec/support/server_selection/selection/ReplicaSetNoPrimary/read/Primary.yml +0 -21
- data/spec/support/server_selection/selection/ReplicaSetNoPrimary/read/PrimaryPreferred.yml +0 -26
- data/spec/support/server_selection/selection/ReplicaSetNoPrimary/read/PrimaryPreferred_non_matching.yml +0 -21
- data/spec/support/server_selection/selection/ReplicaSetNoPrimary/read/Secondary.yml +0 -26
- data/spec/support/server_selection/selection/ReplicaSetNoPrimary/read/SecondaryPreferred.yml +0 -26
- data/spec/support/server_selection/selection/ReplicaSetNoPrimary/read/SecondaryPreferred_non_matching.yml +0 -21
- data/spec/support/server_selection/selection/ReplicaSetNoPrimary/read/Secondary_non_matching.yml +0 -21
- data/spec/support/server_selection/selection/ReplicaSetWithPrimary/read/Nearest.yml +0 -33
- data/spec/support/server_selection/selection/ReplicaSetWithPrimary/read/Nearest_non_matching.yml +0 -26
- data/spec/support/server_selection/selection/ReplicaSetWithPrimary/read/Primary.yml +0 -29
- data/spec/support/server_selection/selection/ReplicaSetWithPrimary/read/PrimaryPreferred.yml +0 -29
- data/spec/support/server_selection/selection/ReplicaSetWithPrimary/read/PrimaryPreferred_non_matching.yml +0 -29
- data/spec/support/server_selection/selection/ReplicaSetWithPrimary/read/Secondary.yml +0 -31
- data/spec/support/server_selection/selection/ReplicaSetWithPrimary/read/SecondaryPreferred.yml +0 -31
- data/spec/support/server_selection/selection/ReplicaSetWithPrimary/read/SecondaryPreferred_non_matching.yml +0 -29
- data/spec/support/server_selection/selection/ReplicaSetWithPrimary/read/Secondary_non_matching.yml +0 -26
- data/spec/support/server_selection/selection/Sharded/read/SecondaryPreferred.yml +0 -26
- data/spec/support/server_selection/selection/Single/read/SecondaryPreferred.yml +0 -19
- data/spec/support/server_selection/selection/Unknown/read/SecondaryPreferred.yml +0 -11
- data/spec/support/server_selection.rb +0 -135
- data/spec/support/server_selection_rtt.rb +0 -41
- data/spec/support/travis.rb +0 -14
|
@@ -1,22 +1,24 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
# encoding: utf-8
|
|
3
|
+
|
|
1
4
|
require 'spec_helper'
|
|
2
5
|
|
|
3
6
|
describe Mongo::Collection do
|
|
4
7
|
|
|
5
|
-
|
|
6
|
-
authorized_collection.delete_many
|
|
7
|
-
collection_with_validator.drop()
|
|
8
|
-
end
|
|
8
|
+
let(:subscriber) { Mrss::EventSubscriber.new }
|
|
9
9
|
|
|
10
|
-
let(:
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
let(:collection_with_validator) do
|
|
14
|
-
authorized_client[:validating,
|
|
15
|
-
:validator => { :a => { '$exists' => true } }].tap do |c|
|
|
16
|
-
c.create
|
|
10
|
+
let(:client) do
|
|
11
|
+
authorized_client.tap do |client|
|
|
12
|
+
client.subscribe(Mongo::Monitoring::COMMAND, subscriber)
|
|
17
13
|
end
|
|
18
14
|
end
|
|
19
15
|
|
|
16
|
+
let(:authorized_collection) { client['collection_spec'] }
|
|
17
|
+
|
|
18
|
+
before do
|
|
19
|
+
authorized_client['collection_spec'].drop
|
|
20
|
+
end
|
|
21
|
+
|
|
20
22
|
describe '#==' do
|
|
21
23
|
|
|
22
24
|
let(:database) do
|
|
@@ -97,18 +99,116 @@ describe Mongo::Collection do
|
|
|
97
99
|
end
|
|
98
100
|
end
|
|
99
101
|
|
|
102
|
+
describe '#initialize' do
|
|
103
|
+
|
|
104
|
+
let(:client) do
|
|
105
|
+
new_local_client(SpecConfig.instance.addresses,
|
|
106
|
+
SpecConfig.instance.test_options.merge(monitoring_io: false))
|
|
107
|
+
end
|
|
108
|
+
|
|
109
|
+
let(:database) { client.database }
|
|
110
|
+
|
|
111
|
+
context 'write concern given in :write option' do
|
|
112
|
+
let(:collection) do
|
|
113
|
+
Mongo::Collection.new(database, 'foo', write: {w: 1})
|
|
114
|
+
end
|
|
115
|
+
|
|
116
|
+
it 'stores write concern' do
|
|
117
|
+
expect(collection.write_concern).to be_a(Mongo::WriteConcern::Acknowledged)
|
|
118
|
+
expect(collection.write_concern.options).to eq(w: 1)
|
|
119
|
+
end
|
|
120
|
+
|
|
121
|
+
it 'stores write concern under :write' do
|
|
122
|
+
expect(collection.options[:write]).to eq(w: 1)
|
|
123
|
+
expect(collection.options[:write_concern]).to be nil
|
|
124
|
+
end
|
|
125
|
+
end
|
|
126
|
+
|
|
127
|
+
context 'write concern given in :write_concern option' do
|
|
128
|
+
let(:collection) do
|
|
129
|
+
Mongo::Collection.new(database, 'foo', write_concern: {w: 1})
|
|
130
|
+
end
|
|
131
|
+
|
|
132
|
+
it 'stores write concern' do
|
|
133
|
+
expect(collection.write_concern).to be_a(Mongo::WriteConcern::Acknowledged)
|
|
134
|
+
expect(collection.write_concern.options).to eq(w: 1)
|
|
135
|
+
end
|
|
136
|
+
|
|
137
|
+
it 'stores write concern under :write_concern' do
|
|
138
|
+
expect(collection.options[:write_concern]).to eq(w: 1)
|
|
139
|
+
expect(collection.options[:write]).to be nil
|
|
140
|
+
end
|
|
141
|
+
end
|
|
142
|
+
|
|
143
|
+
context 'write concern given in both :write and :write_concern options' do
|
|
144
|
+
context 'identical values' do
|
|
145
|
+
|
|
146
|
+
let(:collection) do
|
|
147
|
+
Mongo::Collection.new(database, 'foo',
|
|
148
|
+
write: {w: 1}, write_concern: {w: 1})
|
|
149
|
+
end
|
|
150
|
+
|
|
151
|
+
it 'stores write concern' do
|
|
152
|
+
expect(collection.write_concern).to be_a(Mongo::WriteConcern::Acknowledged)
|
|
153
|
+
expect(collection.write_concern.options).to eq(w: 1)
|
|
154
|
+
end
|
|
155
|
+
|
|
156
|
+
it 'stores write concern under both options' do
|
|
157
|
+
expect(collection.options[:write]).to eq(w: 1)
|
|
158
|
+
expect(collection.options[:write_concern]).to eq(w: 1)
|
|
159
|
+
end
|
|
160
|
+
end
|
|
161
|
+
|
|
162
|
+
context 'different values' do
|
|
163
|
+
|
|
164
|
+
let(:collection) do
|
|
165
|
+
Mongo::Collection.new(database, 'foo',
|
|
166
|
+
write: {w: 1}, write_concern: {w: 2})
|
|
167
|
+
end
|
|
168
|
+
|
|
169
|
+
it 'raises an exception' do
|
|
170
|
+
expect do
|
|
171
|
+
collection
|
|
172
|
+
end.to raise_error(ArgumentError, /If :write and :write_concern are both given, they must be identical/)
|
|
173
|
+
end
|
|
174
|
+
end
|
|
175
|
+
end
|
|
176
|
+
|
|
177
|
+
=begin WriteConcern object support
|
|
178
|
+
context 'when write concern is provided via a WriteConcern object' do
|
|
179
|
+
|
|
180
|
+
let(:collection) do
|
|
181
|
+
Mongo::Collection.new(database, 'foo', write_concern: wc)
|
|
182
|
+
end
|
|
183
|
+
|
|
184
|
+
let(:wc) { Mongo::WriteConcern.get(w: 2) }
|
|
185
|
+
|
|
186
|
+
it 'stores write concern options in collection options' do
|
|
187
|
+
expect(collection.options[:write_concern]).to eq(w: 2)
|
|
188
|
+
end
|
|
189
|
+
|
|
190
|
+
it 'caches write concern object' do
|
|
191
|
+
expect(collection.write_concern).to be wc
|
|
192
|
+
end
|
|
193
|
+
end
|
|
194
|
+
=end
|
|
195
|
+
end
|
|
196
|
+
|
|
100
197
|
describe '#with' do
|
|
101
198
|
|
|
102
199
|
let(:client) do
|
|
103
|
-
|
|
200
|
+
new_local_client_nmio(SpecConfig.instance.addresses,
|
|
201
|
+
SpecConfig.instance.test_options.merge(
|
|
202
|
+
SpecConfig.instance.auth_options
|
|
203
|
+
))
|
|
104
204
|
end
|
|
105
205
|
|
|
106
206
|
let(:database) do
|
|
107
|
-
Mongo::Database.new(client,
|
|
207
|
+
Mongo::Database.new(client, SpecConfig.instance.test_db)
|
|
108
208
|
end
|
|
109
209
|
|
|
110
210
|
let(:collection) do
|
|
111
|
-
database.collection(
|
|
211
|
+
database.collection('test-collection')
|
|
112
212
|
end
|
|
113
213
|
|
|
114
214
|
let(:new_collection) do
|
|
@@ -126,13 +226,14 @@ describe Mongo::Collection do
|
|
|
126
226
|
end
|
|
127
227
|
|
|
128
228
|
it 'sets the new read options on the new collection' do
|
|
129
|
-
expect(new_collection.read_preference).to eq(
|
|
229
|
+
expect(new_collection.read_preference).to eq(new_options[:read])
|
|
130
230
|
end
|
|
131
231
|
|
|
132
232
|
context 'when the client has a server selection timeout setting' do
|
|
133
233
|
|
|
134
234
|
let(:client) do
|
|
135
|
-
|
|
235
|
+
new_local_client(SpecConfig.instance.addresses,
|
|
236
|
+
SpecConfig.instance.test_options.merge(server_selection_timeout: 2, monitoring_io: false))
|
|
136
237
|
end
|
|
137
238
|
|
|
138
239
|
it 'passes the the server_selection_timeout to the cluster' do
|
|
@@ -143,23 +244,105 @@ describe Mongo::Collection do
|
|
|
143
244
|
context 'when the client has a read preference set' do
|
|
144
245
|
|
|
145
246
|
let(:client) do
|
|
146
|
-
|
|
247
|
+
authorized_client.with(client_options).tap do |client|
|
|
248
|
+
expect(client.options[:read]).to eq(Mongo::Options::Redacted.new(
|
|
249
|
+
mode: :primary_preferred))
|
|
250
|
+
client.subscribe(Mongo::Monitoring::COMMAND, subscriber)
|
|
251
|
+
end
|
|
252
|
+
end
|
|
253
|
+
|
|
254
|
+
let(:client_options) do
|
|
255
|
+
{
|
|
256
|
+
read: { mode: :primary_preferred },
|
|
257
|
+
monitoring_io: false,
|
|
258
|
+
}
|
|
259
|
+
end
|
|
260
|
+
|
|
261
|
+
let(:new_options) do
|
|
262
|
+
{ read: { mode: :secondary } }
|
|
147
263
|
end
|
|
148
264
|
|
|
149
265
|
it 'sets the new read options on the new collection' do
|
|
150
|
-
|
|
151
|
-
|
|
266
|
+
# This is strictly a Hash, not a BSON::Document like the client's
|
|
267
|
+
# read preference.
|
|
268
|
+
expect(new_collection.read_preference).to eq(mode: :secondary)
|
|
269
|
+
end
|
|
270
|
+
|
|
271
|
+
it 'duplicates the read option' do
|
|
272
|
+
expect(new_collection.read_preference).not_to eql(client.read_preference)
|
|
273
|
+
end
|
|
274
|
+
|
|
275
|
+
context 'when reading from collection' do
|
|
276
|
+
# Since we are requesting a secondary read, we need a replica set.
|
|
277
|
+
require_topology :replica_set
|
|
278
|
+
|
|
279
|
+
let(:client_options) do
|
|
280
|
+
{read: { mode: :primary_preferred }}
|
|
281
|
+
end
|
|
282
|
+
|
|
283
|
+
shared_examples_for "uses collection's read preference when reading" do
|
|
284
|
+
it "uses collection's read preference when reading" do
|
|
285
|
+
expect do
|
|
286
|
+
new_collection.find.to_a.count
|
|
287
|
+
end.not_to raise_error
|
|
288
|
+
|
|
289
|
+
event = subscriber.started_events.detect do |event|
|
|
290
|
+
event.command['find']
|
|
291
|
+
end
|
|
292
|
+
actual_rp = event.command['$readPreference']
|
|
293
|
+
expect(actual_rp).to eq(expected_read_preference)
|
|
294
|
+
end
|
|
295
|
+
end
|
|
296
|
+
|
|
297
|
+
context 'post-OP_MSG server' do
|
|
298
|
+
min_server_fcv '3.6'
|
|
299
|
+
|
|
300
|
+
context 'standalone' do
|
|
301
|
+
require_topology :single
|
|
302
|
+
|
|
303
|
+
let(:expected_read_preference) do
|
|
304
|
+
nil
|
|
305
|
+
end
|
|
306
|
+
|
|
307
|
+
it_behaves_like "uses collection's read preference when reading"
|
|
308
|
+
end
|
|
309
|
+
|
|
310
|
+
context 'RS, sharded' do
|
|
311
|
+
require_topology :replica_set, :sharded
|
|
312
|
+
|
|
313
|
+
let(:expected_read_preference) do
|
|
314
|
+
{'mode' => 'secondary'}
|
|
315
|
+
end
|
|
316
|
+
|
|
317
|
+
it_behaves_like "uses collection's read preference when reading"
|
|
318
|
+
end
|
|
319
|
+
end
|
|
320
|
+
|
|
321
|
+
context 'pre-OP-MSG server' do
|
|
322
|
+
max_server_version '3.4'
|
|
323
|
+
|
|
324
|
+
let(:expected_read_preference) do
|
|
325
|
+
nil
|
|
326
|
+
end
|
|
327
|
+
|
|
328
|
+
it_behaves_like "uses collection's read preference when reading"
|
|
329
|
+
end
|
|
152
330
|
end
|
|
153
331
|
end
|
|
154
332
|
|
|
155
333
|
context 'when the client has a read preference and server selection timeout set' do
|
|
156
334
|
|
|
157
335
|
let(:client) do
|
|
158
|
-
|
|
336
|
+
new_local_client(SpecConfig.instance.addresses,
|
|
337
|
+
SpecConfig.instance.test_options.merge(
|
|
338
|
+
read: { mode: :primary_preferred },
|
|
339
|
+
server_selection_timeout: 2,
|
|
340
|
+
monitoring_io: false
|
|
341
|
+
))
|
|
159
342
|
end
|
|
160
343
|
|
|
161
344
|
it 'sets the new read options on the new collection' do
|
|
162
|
-
expect(new_collection.read_preference).to eq(
|
|
345
|
+
expect(new_collection.read_preference).to eq(new_options[:read])
|
|
163
346
|
end
|
|
164
347
|
|
|
165
348
|
it 'passes the server_selection_timeout setting to the cluster' do
|
|
@@ -185,12 +368,116 @@ describe Mongo::Collection do
|
|
|
185
368
|
context 'when the client has a write concern set' do
|
|
186
369
|
|
|
187
370
|
let(:client) do
|
|
188
|
-
|
|
371
|
+
new_local_client(SpecConfig.instance.addresses,
|
|
372
|
+
SpecConfig.instance.test_options.merge(
|
|
373
|
+
write: INVALID_WRITE_CONCERN,
|
|
374
|
+
monitoring_io: false,
|
|
375
|
+
))
|
|
189
376
|
end
|
|
190
377
|
|
|
191
378
|
it 'sets the new write options on the new collection' do
|
|
192
379
|
expect(new_collection.write_concern.options).to eq(Mongo::WriteConcern.get(new_options[:write]).options)
|
|
193
380
|
end
|
|
381
|
+
|
|
382
|
+
context 'when client uses :write_concern and collection uses :write' do
|
|
383
|
+
|
|
384
|
+
let(:client) do
|
|
385
|
+
new_local_client(SpecConfig.instance.addresses,
|
|
386
|
+
SpecConfig.instance.test_options.merge(
|
|
387
|
+
write_concern: {w: 1},
|
|
388
|
+
monitoring_io: false,
|
|
389
|
+
))
|
|
390
|
+
end
|
|
391
|
+
|
|
392
|
+
it 'uses :write from collection options only' do
|
|
393
|
+
expect(new_collection.options[:write]).to eq(w: 5)
|
|
394
|
+
expect(new_collection.options[:write_concern]).to be nil
|
|
395
|
+
end
|
|
396
|
+
end
|
|
397
|
+
|
|
398
|
+
context 'when client uses :write and collection uses :write_concern' do
|
|
399
|
+
|
|
400
|
+
let(:client) do
|
|
401
|
+
new_local_client(SpecConfig.instance.addresses,
|
|
402
|
+
SpecConfig.instance.test_options.merge(
|
|
403
|
+
write: {w: 1},
|
|
404
|
+
monitoring_io: false,
|
|
405
|
+
))
|
|
406
|
+
end
|
|
407
|
+
|
|
408
|
+
let(:new_options) do
|
|
409
|
+
{ write_concern: { w: 5 } }
|
|
410
|
+
end
|
|
411
|
+
|
|
412
|
+
it 'uses :write_concern from collection options only' do
|
|
413
|
+
expect(new_collection.options[:write_concern]).to eq(w: 5)
|
|
414
|
+
expect(new_collection.options[:write]).to be nil
|
|
415
|
+
end
|
|
416
|
+
end
|
|
417
|
+
|
|
418
|
+
context 'when collection previously had :wrte_concern and :write is used with a different value' do
|
|
419
|
+
|
|
420
|
+
let(:collection) do
|
|
421
|
+
database.collection(:users, write_concern: {w: 2})
|
|
422
|
+
end
|
|
423
|
+
|
|
424
|
+
let(:new_options) do
|
|
425
|
+
{ write: { w: 5 } }
|
|
426
|
+
end
|
|
427
|
+
|
|
428
|
+
it 'uses the new option' do
|
|
429
|
+
expect(new_collection.options[:write]).to eq(w: 5)
|
|
430
|
+
expect(new_collection.options[:write_concern]).to be nil
|
|
431
|
+
end
|
|
432
|
+
end
|
|
433
|
+
|
|
434
|
+
context 'when collection previously had :wrte and :write_concern is used with a different value' do
|
|
435
|
+
|
|
436
|
+
let(:collection) do
|
|
437
|
+
database.collection(:users, write: {w: 2})
|
|
438
|
+
end
|
|
439
|
+
|
|
440
|
+
let(:new_options) do
|
|
441
|
+
{ write_concern: { w: 5 } }
|
|
442
|
+
end
|
|
443
|
+
|
|
444
|
+
it 'uses the new option' do
|
|
445
|
+
expect(new_collection.options[:write_concern]).to eq(w: 5)
|
|
446
|
+
expect(new_collection.options[:write]).to be nil
|
|
447
|
+
end
|
|
448
|
+
end
|
|
449
|
+
|
|
450
|
+
context 'when collection previously had :wrte_concern and :write is used with the same value' do
|
|
451
|
+
|
|
452
|
+
let(:collection) do
|
|
453
|
+
database.collection(:users, write_concern: {w: 2})
|
|
454
|
+
end
|
|
455
|
+
|
|
456
|
+
let(:new_options) do
|
|
457
|
+
{ write: { w: 2 } }
|
|
458
|
+
end
|
|
459
|
+
|
|
460
|
+
it 'uses the new option' do
|
|
461
|
+
expect(new_collection.options[:write]).to eq(w: 2)
|
|
462
|
+
expect(new_collection.options[:write_concern]).to be nil
|
|
463
|
+
end
|
|
464
|
+
end
|
|
465
|
+
|
|
466
|
+
context 'when collection previously had :wrte and :write_concern is used with the same value' do
|
|
467
|
+
|
|
468
|
+
let(:collection) do
|
|
469
|
+
database.collection(:users, write: {w: 2})
|
|
470
|
+
end
|
|
471
|
+
|
|
472
|
+
let(:new_options) do
|
|
473
|
+
{ write_concern: { w: 2 } }
|
|
474
|
+
end
|
|
475
|
+
|
|
476
|
+
it 'uses the new option' do
|
|
477
|
+
expect(new_collection.options[:write]).to be nil
|
|
478
|
+
expect(new_collection.options[:write_concern]).to eq(w: 2)
|
|
479
|
+
end
|
|
480
|
+
end
|
|
194
481
|
end
|
|
195
482
|
end
|
|
196
483
|
|
|
@@ -208,7 +495,7 @@ describe Mongo::Collection do
|
|
|
208
495
|
end
|
|
209
496
|
|
|
210
497
|
it 'sets the new read options on the new collection' do
|
|
211
|
-
expect(new_collection.read_preference).to eq(
|
|
498
|
+
expect(new_collection.read_preference).to eq(new_options[:read])
|
|
212
499
|
end
|
|
213
500
|
|
|
214
501
|
it 'sets the new write options on the new collection' do
|
|
@@ -218,7 +505,11 @@ describe Mongo::Collection do
|
|
|
218
505
|
context 'when the client has a server selection timeout setting' do
|
|
219
506
|
|
|
220
507
|
let(:client) do
|
|
221
|
-
|
|
508
|
+
new_local_client(SpecConfig.instance.addresses,
|
|
509
|
+
SpecConfig.instance.test_options.merge(
|
|
510
|
+
server_selection_timeout: 2,
|
|
511
|
+
monitoring_io: false,
|
|
512
|
+
))
|
|
222
513
|
end
|
|
223
514
|
|
|
224
515
|
it 'passes the server_selection_timeout setting to the cluster' do
|
|
@@ -229,11 +520,15 @@ describe Mongo::Collection do
|
|
|
229
520
|
context 'when the client has a read preference set' do
|
|
230
521
|
|
|
231
522
|
let(:client) do
|
|
232
|
-
|
|
523
|
+
new_local_client(SpecConfig.instance.addresses,
|
|
524
|
+
SpecConfig.instance.test_options.merge(
|
|
525
|
+
read: { mode: :primary_preferred },
|
|
526
|
+
monitoring_io: false,
|
|
527
|
+
))
|
|
233
528
|
end
|
|
234
529
|
|
|
235
530
|
it 'sets the new read options on the new collection' do
|
|
236
|
-
expect(new_collection.read_preference).to eq(
|
|
531
|
+
expect(new_collection.read_preference).to eq(new_options[:read])
|
|
237
532
|
expect(new_collection.read_preference).not_to be(client.read_preference)
|
|
238
533
|
end
|
|
239
534
|
end
|
|
@@ -253,6 +548,96 @@ describe Mongo::Collection do
|
|
|
253
548
|
end
|
|
254
549
|
end
|
|
255
550
|
|
|
551
|
+
describe '#read_preference' do
|
|
552
|
+
|
|
553
|
+
let(:collection) do
|
|
554
|
+
described_class.new(authorized_client.database, :users, options)
|
|
555
|
+
end
|
|
556
|
+
|
|
557
|
+
let(:options) { {} }
|
|
558
|
+
|
|
559
|
+
context 'when a read preference is set in the options' do
|
|
560
|
+
|
|
561
|
+
let(:options) do
|
|
562
|
+
{ read: { mode: :secondary } }
|
|
563
|
+
end
|
|
564
|
+
|
|
565
|
+
it 'returns the read preference' do
|
|
566
|
+
expect(collection.read_preference).to eq(options[:read])
|
|
567
|
+
end
|
|
568
|
+
end
|
|
569
|
+
|
|
570
|
+
context 'when a read preference is not set in the options' do
|
|
571
|
+
|
|
572
|
+
context 'when the database has a read preference set' do
|
|
573
|
+
|
|
574
|
+
let(:client) do
|
|
575
|
+
authorized_client.with(read: { mode: :secondary_preferred })
|
|
576
|
+
end
|
|
577
|
+
|
|
578
|
+
let(:collection) do
|
|
579
|
+
described_class.new(client.database, :users, options)
|
|
580
|
+
end
|
|
581
|
+
|
|
582
|
+
it 'returns the database read preference' do
|
|
583
|
+
expect(collection.read_preference).to eq(BSON::Document.new({ mode: :secondary_preferred }))
|
|
584
|
+
end
|
|
585
|
+
end
|
|
586
|
+
|
|
587
|
+
context 'when the database does not have a read preference' do
|
|
588
|
+
|
|
589
|
+
it 'returns nil' do
|
|
590
|
+
expect(collection.read_preference).to be_nil
|
|
591
|
+
end
|
|
592
|
+
end
|
|
593
|
+
end
|
|
594
|
+
end
|
|
595
|
+
|
|
596
|
+
describe '#server_selector' do
|
|
597
|
+
|
|
598
|
+
let(:collection) do
|
|
599
|
+
described_class.new(authorized_client.database, :users, options)
|
|
600
|
+
end
|
|
601
|
+
|
|
602
|
+
let(:options) { {} }
|
|
603
|
+
|
|
604
|
+
context 'when a read preference is set in the options' do
|
|
605
|
+
|
|
606
|
+
let(:options) do
|
|
607
|
+
{ read: { mode: :secondary } }
|
|
608
|
+
end
|
|
609
|
+
|
|
610
|
+
it 'returns the server selector for that read preference' do
|
|
611
|
+
expect(collection.server_selector).to be_a(Mongo::ServerSelector::Secondary)
|
|
612
|
+
end
|
|
613
|
+
end
|
|
614
|
+
|
|
615
|
+
context 'when a read preference is not set in the options' do
|
|
616
|
+
|
|
617
|
+
context 'when the database has a read preference set' do
|
|
618
|
+
|
|
619
|
+
let(:client) do
|
|
620
|
+
authorized_client.with(read: { mode: :secondary_preferred })
|
|
621
|
+
end
|
|
622
|
+
|
|
623
|
+
let(:collection) do
|
|
624
|
+
described_class.new(client.database, :users, options)
|
|
625
|
+
end
|
|
626
|
+
|
|
627
|
+
it 'returns the server selector for that read preference' do
|
|
628
|
+
expect(collection.server_selector).to be_a(Mongo::ServerSelector::SecondaryPreferred)
|
|
629
|
+
end
|
|
630
|
+
end
|
|
631
|
+
|
|
632
|
+
context 'when the database does not have a read preference' do
|
|
633
|
+
|
|
634
|
+
it 'returns a primary server selector' do
|
|
635
|
+
expect(collection.server_selector).to be_a(Mongo::ServerSelector::Primary)
|
|
636
|
+
end
|
|
637
|
+
end
|
|
638
|
+
end
|
|
639
|
+
end
|
|
640
|
+
|
|
256
641
|
describe '#capped?' do
|
|
257
642
|
|
|
258
643
|
let(:database) do
|
|
@@ -266,13 +651,10 @@ describe Mongo::Collection do
|
|
|
266
651
|
end
|
|
267
652
|
|
|
268
653
|
before do
|
|
654
|
+
authorized_client[:specs].drop
|
|
269
655
|
collection.create
|
|
270
656
|
end
|
|
271
657
|
|
|
272
|
-
after do
|
|
273
|
-
collection.drop
|
|
274
|
-
end
|
|
275
|
-
|
|
276
658
|
it 'returns true' do
|
|
277
659
|
expect(collection).to be_capped
|
|
278
660
|
end
|
|
@@ -285,2017 +667,138 @@ describe Mongo::Collection do
|
|
|
285
667
|
end
|
|
286
668
|
|
|
287
669
|
before do
|
|
670
|
+
authorized_client[:specs].drop
|
|
288
671
|
collection.create
|
|
289
672
|
end
|
|
290
673
|
|
|
291
|
-
after do
|
|
292
|
-
collection.drop
|
|
293
|
-
end
|
|
294
|
-
|
|
295
674
|
it 'returns false' do
|
|
296
675
|
expect(collection).to_not be_capped
|
|
297
676
|
end
|
|
298
677
|
end
|
|
299
678
|
end
|
|
300
679
|
|
|
301
|
-
describe '#
|
|
680
|
+
describe '#inspect' do
|
|
302
681
|
|
|
303
|
-
|
|
304
|
-
|
|
682
|
+
it 'includes the object id' do
|
|
683
|
+
expect(authorized_collection.inspect).to include(authorized_collection.object_id.to_s)
|
|
305
684
|
end
|
|
306
685
|
|
|
307
|
-
|
|
686
|
+
it 'includes the namespace' do
|
|
687
|
+
expect(authorized_collection.inspect).to include(authorized_collection.namespace)
|
|
688
|
+
end
|
|
689
|
+
end
|
|
308
690
|
|
|
309
|
-
|
|
310
|
-
described_class.new(database, :specs)
|
|
311
|
-
end
|
|
691
|
+
describe '#watch' do
|
|
312
692
|
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
693
|
+
context 'when change streams can be tested' do
|
|
694
|
+
require_wired_tiger
|
|
695
|
+
min_server_fcv '3.6'
|
|
696
|
+
require_topology :replica_set
|
|
316
697
|
|
|
317
|
-
|
|
318
|
-
|
|
698
|
+
let(:change_stream) do
|
|
699
|
+
authorized_collection.watch
|
|
319
700
|
end
|
|
320
701
|
|
|
321
|
-
|
|
322
|
-
|
|
702
|
+
let(:enum) do
|
|
703
|
+
change_stream.to_enum
|
|
323
704
|
end
|
|
324
705
|
|
|
325
|
-
|
|
326
|
-
|
|
706
|
+
before do
|
|
707
|
+
change_stream
|
|
708
|
+
authorized_collection.insert_one(a: 1)
|
|
327
709
|
end
|
|
328
|
-
end
|
|
329
|
-
|
|
330
|
-
context 'when the collection has options' do
|
|
331
710
|
|
|
332
|
-
context 'when
|
|
333
|
-
|
|
334
|
-
shared_examples 'a capped collection command' do
|
|
711
|
+
context 'when no options are provided' do
|
|
335
712
|
|
|
336
|
-
|
|
337
|
-
collection.create
|
|
338
|
-
end
|
|
713
|
+
context 'when the operation type is an insert' do
|
|
339
714
|
|
|
340
|
-
|
|
341
|
-
|
|
715
|
+
it 'returns the change' do
|
|
716
|
+
expect(enum.next[:fullDocument][:a]).to eq(1)
|
|
342
717
|
end
|
|
718
|
+
end
|
|
343
719
|
|
|
344
|
-
|
|
345
|
-
collection.drop
|
|
346
|
-
end
|
|
720
|
+
context 'when the operation type is an update' do
|
|
347
721
|
|
|
348
|
-
|
|
349
|
-
|
|
722
|
+
before do
|
|
723
|
+
authorized_collection.update_one({ a: 1 }, { '$set' => { a: 2 } })
|
|
350
724
|
end
|
|
351
725
|
|
|
352
|
-
|
|
353
|
-
|
|
726
|
+
let(:change_doc) do
|
|
727
|
+
enum.next
|
|
728
|
+
enum.next
|
|
354
729
|
end
|
|
355
730
|
|
|
356
|
-
it '
|
|
357
|
-
expect(
|
|
731
|
+
it 'returns the change' do
|
|
732
|
+
expect(change_doc[:operationType]).to eq('update')
|
|
733
|
+
expect(change_doc[:updateDescription][:updatedFields]).to eq('a' => 2)
|
|
358
734
|
end
|
|
359
735
|
end
|
|
736
|
+
end
|
|
737
|
+
|
|
738
|
+
context 'when options are provided' do
|
|
360
739
|
|
|
361
|
-
|
|
740
|
+
context 'when full_document is updateLookup' do
|
|
362
741
|
|
|
363
|
-
let
|
|
364
|
-
|
|
742
|
+
let(:change_stream) do
|
|
743
|
+
authorized_collection.watch([], full_document: 'updateLookup').to_enum
|
|
365
744
|
end
|
|
366
745
|
|
|
367
|
-
|
|
368
|
-
{ :
|
|
369
|
-
:validationLevel => 'strict' }
|
|
746
|
+
before do
|
|
747
|
+
authorized_collection.update_one({ a: 1 }, { '$set' => { a: 2 } })
|
|
370
748
|
end
|
|
371
749
|
|
|
372
|
-
let(:
|
|
373
|
-
|
|
750
|
+
let(:change_doc) do
|
|
751
|
+
enum.next
|
|
752
|
+
enum.next
|
|
374
753
|
end
|
|
375
754
|
|
|
376
|
-
|
|
377
|
-
|
|
755
|
+
it 'returns the change' do
|
|
756
|
+
expect(change_doc[:operationType]).to eq('update')
|
|
757
|
+
expect(change_doc[:fullDocument][:a]).to eq(2)
|
|
378
758
|
end
|
|
759
|
+
end
|
|
379
760
|
|
|
380
|
-
|
|
381
|
-
|
|
761
|
+
context 'when batch_size is provided' do
|
|
762
|
+
|
|
763
|
+
before do
|
|
764
|
+
Thread.new do
|
|
765
|
+
sleep 1
|
|
766
|
+
authorized_collection.insert_one(a: 2)
|
|
767
|
+
authorized_collection.insert_one(a: 3)
|
|
768
|
+
end
|
|
382
769
|
end
|
|
383
770
|
|
|
384
|
-
|
|
385
|
-
|
|
771
|
+
let(:change_stream) do
|
|
772
|
+
authorized_collection.watch([], batch_size: 2)
|
|
386
773
|
end
|
|
387
774
|
|
|
388
|
-
it '
|
|
389
|
-
expect(
|
|
775
|
+
it 'returns the documents in the batch size specified' do
|
|
776
|
+
expect(change_stream.instance_variable_get(:@cursor)).to receive(:get_more).once.and_call_original
|
|
777
|
+
enum.next
|
|
390
778
|
end
|
|
391
779
|
end
|
|
392
780
|
|
|
393
|
-
context 'when
|
|
781
|
+
context 'when collation is provided' do
|
|
394
782
|
|
|
395
|
-
|
|
396
|
-
|
|
783
|
+
before do
|
|
784
|
+
authorized_collection.update_one({ a: 1 }, { '$set' => { a: 2 } })
|
|
397
785
|
end
|
|
398
786
|
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
context 'when validators can be set', if: find_command_enabled? do
|
|
402
|
-
it_behaves_like 'a validated collection command'
|
|
787
|
+
let(:change_doc) do
|
|
788
|
+
enum.next
|
|
403
789
|
end
|
|
404
|
-
end
|
|
405
|
-
|
|
406
|
-
context 'when instantiating a collection through the database' do
|
|
407
790
|
|
|
408
|
-
let(:
|
|
409
|
-
|
|
791
|
+
let(:change_stream) do
|
|
792
|
+
authorized_collection.watch([ { '$match' => { operationType: 'UPDATE'}}],
|
|
793
|
+
collation: { locale: 'en_US', strength: 2 } ).to_enum
|
|
410
794
|
end
|
|
411
795
|
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
it_behaves_like 'a validated collection command'
|
|
796
|
+
it 'returns the change' do
|
|
797
|
+
expect(change_doc['operationType']).to eq('update')
|
|
798
|
+
expect(change_doc['updateDescription']['updatedFields']['a']).to eq(2)
|
|
416
799
|
end
|
|
417
800
|
end
|
|
418
801
|
end
|
|
419
802
|
end
|
|
420
803
|
end
|
|
421
|
-
|
|
422
|
-
describe '#drop' do
|
|
423
|
-
|
|
424
|
-
let(:database) do
|
|
425
|
-
authorized_client.database
|
|
426
|
-
end
|
|
427
|
-
|
|
428
|
-
let(:collection) do
|
|
429
|
-
described_class.new(database, :specs)
|
|
430
|
-
end
|
|
431
|
-
|
|
432
|
-
before do
|
|
433
|
-
collection.create
|
|
434
|
-
end
|
|
435
|
-
|
|
436
|
-
let!(:response) do
|
|
437
|
-
collection.drop
|
|
438
|
-
end
|
|
439
|
-
|
|
440
|
-
it 'executes the command' do
|
|
441
|
-
expect(response).to be_successful
|
|
442
|
-
end
|
|
443
|
-
|
|
444
|
-
it 'drops the collection from the database' do
|
|
445
|
-
expect(database.collection_names).to_not include('specs')
|
|
446
|
-
end
|
|
447
|
-
|
|
448
|
-
context 'when the collection does not exist' do
|
|
449
|
-
|
|
450
|
-
it 'does not raise an error' do
|
|
451
|
-
expect(database['non-existent-coll'].drop).to be(false)
|
|
452
|
-
end
|
|
453
|
-
end
|
|
454
|
-
end
|
|
455
|
-
|
|
456
|
-
describe '#find' do
|
|
457
|
-
|
|
458
|
-
context 'when provided a filter' do
|
|
459
|
-
|
|
460
|
-
let(:view) do
|
|
461
|
-
authorized_collection.find(name: 1)
|
|
462
|
-
end
|
|
463
|
-
|
|
464
|
-
it 'returns a authorized_collection view for the filter' do
|
|
465
|
-
expect(view.filter).to eq('name' => 1)
|
|
466
|
-
end
|
|
467
|
-
end
|
|
468
|
-
|
|
469
|
-
context 'when provided no filter' do
|
|
470
|
-
|
|
471
|
-
let(:view) do
|
|
472
|
-
authorized_collection.find
|
|
473
|
-
end
|
|
474
|
-
|
|
475
|
-
it 'returns a authorized_collection view with an empty filter' do
|
|
476
|
-
expect(view.filter).to be_empty
|
|
477
|
-
end
|
|
478
|
-
end
|
|
479
|
-
|
|
480
|
-
context 'when providing a bad filter' do
|
|
481
|
-
|
|
482
|
-
let(:view) do
|
|
483
|
-
authorized_collection.find('$or' => [])
|
|
484
|
-
end
|
|
485
|
-
|
|
486
|
-
it 'raises an exception when iterating' do
|
|
487
|
-
expect {
|
|
488
|
-
view.to_a
|
|
489
|
-
}.to raise_exception(Mongo::Error::OperationFailure)
|
|
490
|
-
end
|
|
491
|
-
end
|
|
492
|
-
|
|
493
|
-
context 'when iterating the authorized_collection view' do
|
|
494
|
-
|
|
495
|
-
before do
|
|
496
|
-
authorized_collection.insert_many([{ field: 'test1' }, { field: 'test2' }])
|
|
497
|
-
end
|
|
498
|
-
|
|
499
|
-
after do
|
|
500
|
-
authorized_collection.delete_many
|
|
501
|
-
end
|
|
502
|
-
|
|
503
|
-
let(:view) do
|
|
504
|
-
authorized_collection.find
|
|
505
|
-
end
|
|
506
|
-
|
|
507
|
-
it 'iterates over the documents' do
|
|
508
|
-
view.each do |document|
|
|
509
|
-
expect(document).to_not be_nil
|
|
510
|
-
end
|
|
511
|
-
end
|
|
512
|
-
end
|
|
513
|
-
|
|
514
|
-
context 'when the user is not authorized', if: auth_enabled? do
|
|
515
|
-
|
|
516
|
-
let(:view) do
|
|
517
|
-
unauthorized_collection.find
|
|
518
|
-
end
|
|
519
|
-
|
|
520
|
-
it 'iterates over the documents' do
|
|
521
|
-
expect {
|
|
522
|
-
view.each{ |document| document }
|
|
523
|
-
}.to raise_error(Mongo::Error::OperationFailure)
|
|
524
|
-
end
|
|
525
|
-
end
|
|
526
|
-
|
|
527
|
-
context 'when documents contain potential error message fields' do
|
|
528
|
-
|
|
529
|
-
[ Mongo::Error::ERRMSG, Mongo::Error::ERROR, Mongo::Operation::Result::OK ].each do |field|
|
|
530
|
-
|
|
531
|
-
context "when the document contains a '#{field}' field" do
|
|
532
|
-
|
|
533
|
-
let(:value) do
|
|
534
|
-
'testing'
|
|
535
|
-
end
|
|
536
|
-
|
|
537
|
-
let(:view) do
|
|
538
|
-
authorized_collection.find
|
|
539
|
-
end
|
|
540
|
-
|
|
541
|
-
before do
|
|
542
|
-
authorized_collection.insert_one({ field => value })
|
|
543
|
-
end
|
|
544
|
-
|
|
545
|
-
after do
|
|
546
|
-
authorized_collection.delete_many
|
|
547
|
-
end
|
|
548
|
-
|
|
549
|
-
it 'iterates over the documents' do
|
|
550
|
-
view.each do |document|
|
|
551
|
-
expect(document[field]).to eq(value)
|
|
552
|
-
end
|
|
553
|
-
end
|
|
554
|
-
end
|
|
555
|
-
end
|
|
556
|
-
end
|
|
557
|
-
|
|
558
|
-
context 'when provided options' do
|
|
559
|
-
|
|
560
|
-
let(:view) do
|
|
561
|
-
authorized_collection.find({}, options)
|
|
562
|
-
end
|
|
563
|
-
|
|
564
|
-
context 'when provided :allow_partial_results' do
|
|
565
|
-
|
|
566
|
-
let(:options) do
|
|
567
|
-
{ allow_partial_results: true }
|
|
568
|
-
end
|
|
569
|
-
|
|
570
|
-
it 'returns a view with :allow_partial_results set' do
|
|
571
|
-
expect(view.options[:allow_partial_results]).to be(options[:allow_partial_results])
|
|
572
|
-
end
|
|
573
|
-
end
|
|
574
|
-
|
|
575
|
-
context 'when provided :batch_size' do
|
|
576
|
-
|
|
577
|
-
let(:options) do
|
|
578
|
-
{ batch_size: 100 }
|
|
579
|
-
end
|
|
580
|
-
|
|
581
|
-
it 'returns a view with :batch_size set' do
|
|
582
|
-
expect(view.options[:batch_size]).to eq(options[:batch_size])
|
|
583
|
-
end
|
|
584
|
-
end
|
|
585
|
-
|
|
586
|
-
context 'when provided :comment' do
|
|
587
|
-
|
|
588
|
-
let(:options) do
|
|
589
|
-
{ comment: 'slow query' }
|
|
590
|
-
end
|
|
591
|
-
|
|
592
|
-
it 'returns a view with :comment set' do
|
|
593
|
-
expect(view.modifiers[:$comment]).to eq(options[:comment])
|
|
594
|
-
end
|
|
595
|
-
end
|
|
596
|
-
|
|
597
|
-
context 'when provided :cursor_type' do
|
|
598
|
-
|
|
599
|
-
let(:options) do
|
|
600
|
-
{ cursor_type: :tailable }
|
|
601
|
-
end
|
|
602
|
-
|
|
603
|
-
it 'returns a view with :cursor_type set' do
|
|
604
|
-
expect(view.options[:cursor_type]).to eq(options[:cursor_type])
|
|
605
|
-
end
|
|
606
|
-
end
|
|
607
|
-
|
|
608
|
-
#limit
|
|
609
|
-
|
|
610
|
-
context 'when provided :max_time_ms' do
|
|
611
|
-
|
|
612
|
-
let(:options) do
|
|
613
|
-
{ max_time_ms: 500 }
|
|
614
|
-
end
|
|
615
|
-
|
|
616
|
-
it 'returns a view with :max_time_ms set' do
|
|
617
|
-
expect(view.modifiers[:$maxTimeMS]).to eq(options[:max_time_ms])
|
|
618
|
-
end
|
|
619
|
-
end
|
|
620
|
-
|
|
621
|
-
context 'when provided :modifiers' do
|
|
622
|
-
|
|
623
|
-
let(:options) do
|
|
624
|
-
{ modifiers: { '$orderby' => Mongo::Index::ASCENDING } }
|
|
625
|
-
end
|
|
626
|
-
|
|
627
|
-
it 'returns a view with modifiers set' do
|
|
628
|
-
expect(view.modifiers).to eq(options[:modifiers])
|
|
629
|
-
end
|
|
630
|
-
|
|
631
|
-
it 'dups the modifiers hash' do
|
|
632
|
-
expect(view.modifiers).not_to be(options[:modifiers])
|
|
633
|
-
end
|
|
634
|
-
end
|
|
635
|
-
|
|
636
|
-
context 'when provided :no_cursor_timeout' do
|
|
637
|
-
|
|
638
|
-
let(:options) do
|
|
639
|
-
{ no_cursor_timeout: true }
|
|
640
|
-
end
|
|
641
|
-
|
|
642
|
-
it 'returns a view with :no_cursor_timeout set' do
|
|
643
|
-
expect(view.options[:no_cursor_timeout]).to eq(options[:no_cursor_timeout])
|
|
644
|
-
end
|
|
645
|
-
end
|
|
646
|
-
|
|
647
|
-
context 'when provided :oplog_replay' do
|
|
648
|
-
|
|
649
|
-
let(:options) do
|
|
650
|
-
{ oplog_replay: false }
|
|
651
|
-
end
|
|
652
|
-
|
|
653
|
-
it 'returns a view with :oplog_replay set' do
|
|
654
|
-
expect(view.options[:oplog_replay]).to eq(options[:oplog_replay])
|
|
655
|
-
end
|
|
656
|
-
end
|
|
657
|
-
|
|
658
|
-
context 'when provided :projection' do
|
|
659
|
-
|
|
660
|
-
let(:options) do
|
|
661
|
-
{ projection: { 'x' => 1 } }
|
|
662
|
-
end
|
|
663
|
-
|
|
664
|
-
it 'returns a view with :projection set' do
|
|
665
|
-
expect(view.options[:projection]).to eq(options[:projection])
|
|
666
|
-
end
|
|
667
|
-
end
|
|
668
|
-
|
|
669
|
-
context 'when provided :skip' do
|
|
670
|
-
|
|
671
|
-
let(:options) do
|
|
672
|
-
{ skip: 5 }
|
|
673
|
-
end
|
|
674
|
-
|
|
675
|
-
it 'returns a view with :skip set' do
|
|
676
|
-
expect(view.options[:skip]).to eq(options[:skip])
|
|
677
|
-
end
|
|
678
|
-
end
|
|
679
|
-
|
|
680
|
-
context 'when provided :sort' do
|
|
681
|
-
|
|
682
|
-
let(:options) do
|
|
683
|
-
{ sort: { 'x' => Mongo::Index::ASCENDING } }
|
|
684
|
-
end
|
|
685
|
-
|
|
686
|
-
it 'returns a view with :sort set' do
|
|
687
|
-
expect(view.modifiers[:$orderby]).to eq(options[:sort])
|
|
688
|
-
end
|
|
689
|
-
end
|
|
690
|
-
end
|
|
691
|
-
end
|
|
692
|
-
|
|
693
|
-
describe '#insert_many' do
|
|
694
|
-
|
|
695
|
-
after do
|
|
696
|
-
authorized_collection.delete_many
|
|
697
|
-
collection_with_validator.delete_many
|
|
698
|
-
end
|
|
699
|
-
|
|
700
|
-
let(:result) do
|
|
701
|
-
authorized_collection.insert_many([{ name: 'test1' }, { name: 'test2' }])
|
|
702
|
-
end
|
|
703
|
-
|
|
704
|
-
it 'inserts the documents into the collection' do
|
|
705
|
-
expect(result.inserted_count).to eq(2)
|
|
706
|
-
end
|
|
707
|
-
|
|
708
|
-
it 'contains the ids in the result' do
|
|
709
|
-
expect(result.inserted_ids.size).to eq(2)
|
|
710
|
-
end
|
|
711
|
-
|
|
712
|
-
context 'when a document contains invalid keys' do
|
|
713
|
-
|
|
714
|
-
let(:docs) do
|
|
715
|
-
[ { 'first.name' => 'test1' }, { name: 'test2' } ]
|
|
716
|
-
end
|
|
717
|
-
|
|
718
|
-
it 'raises a BSON::String::IllegalKey exception' do
|
|
719
|
-
expect {
|
|
720
|
-
authorized_collection.insert_many(docs)
|
|
721
|
-
}.to raise_exception(BSON::String::IllegalKey)
|
|
722
|
-
end
|
|
723
|
-
end
|
|
724
|
-
|
|
725
|
-
context 'when the client has a custom id generator' do
|
|
726
|
-
|
|
727
|
-
let(:generator) do
|
|
728
|
-
Class.new do
|
|
729
|
-
def generate
|
|
730
|
-
1
|
|
731
|
-
end
|
|
732
|
-
end.new
|
|
733
|
-
end
|
|
734
|
-
|
|
735
|
-
let(:custom_client) do
|
|
736
|
-
authorized_client.with(id_generator: generator)
|
|
737
|
-
end
|
|
738
|
-
|
|
739
|
-
let(:custom_collection) do
|
|
740
|
-
custom_client[TEST_COLL]
|
|
741
|
-
end
|
|
742
|
-
|
|
743
|
-
before do
|
|
744
|
-
custom_collection.insert_many([{ name: 'testing' }])
|
|
745
|
-
end
|
|
746
|
-
|
|
747
|
-
after do
|
|
748
|
-
custom_client.close
|
|
749
|
-
end
|
|
750
|
-
|
|
751
|
-
it 'inserts with the custom id' do
|
|
752
|
-
expect(custom_collection.find.first[:_id]).to eq(1)
|
|
753
|
-
end
|
|
754
|
-
end
|
|
755
|
-
|
|
756
|
-
context 'when the inserts fail' do
|
|
757
|
-
|
|
758
|
-
let(:result) do
|
|
759
|
-
authorized_collection.insert_many([{ _id: 1 }, { _id: 1 }])
|
|
760
|
-
end
|
|
761
|
-
|
|
762
|
-
it 'raises an BulkWriteError' do
|
|
763
|
-
expect {
|
|
764
|
-
result
|
|
765
|
-
}.to raise_exception(Mongo::Error::BulkWriteError)
|
|
766
|
-
end
|
|
767
|
-
end
|
|
768
|
-
|
|
769
|
-
context "when the documents exceed the max bson size" do
|
|
770
|
-
|
|
771
|
-
let(:documents) do
|
|
772
|
-
[{ '_id' => 1, 'name' => '1'*17000000 }]
|
|
773
|
-
end
|
|
774
|
-
|
|
775
|
-
it 'raises a MaxBSONSize error' do
|
|
776
|
-
expect {
|
|
777
|
-
authorized_collection.insert_many(documents)
|
|
778
|
-
}.to raise_error(Mongo::Error::MaxBSONSize)
|
|
779
|
-
end
|
|
780
|
-
end
|
|
781
|
-
|
|
782
|
-
context 'when collection has a validator', if: find_command_enabled? do
|
|
783
|
-
|
|
784
|
-
context 'when the document is valid' do
|
|
785
|
-
|
|
786
|
-
let(:result) do
|
|
787
|
-
collection_with_validator.insert_many([{ a: 1 }, { a: 2 }])
|
|
788
|
-
end
|
|
789
|
-
|
|
790
|
-
it 'inserts successfully' do
|
|
791
|
-
expect(result.inserted_count).to eq(2)
|
|
792
|
-
end
|
|
793
|
-
end
|
|
794
|
-
|
|
795
|
-
context 'when the document is invalid' do
|
|
796
|
-
|
|
797
|
-
context 'when bypass_document_validation is not set' do
|
|
798
|
-
|
|
799
|
-
let(:result2) do
|
|
800
|
-
collection_with_validator.insert_many([{ x: 1 }, { x: 2 }])
|
|
801
|
-
end
|
|
802
|
-
|
|
803
|
-
it 'raises a BulkWriteError' do
|
|
804
|
-
expect {
|
|
805
|
-
result2
|
|
806
|
-
}.to raise_exception(Mongo::Error::BulkWriteError)
|
|
807
|
-
end
|
|
808
|
-
end
|
|
809
|
-
|
|
810
|
-
context 'when bypass_document_validation is true' do
|
|
811
|
-
|
|
812
|
-
let(:result3) do
|
|
813
|
-
collection_with_validator.insert_many(
|
|
814
|
-
[{ x: 1 }, { x: 2 }], :bypass_document_validation => true)
|
|
815
|
-
end
|
|
816
|
-
|
|
817
|
-
it 'inserts successfully' do
|
|
818
|
-
expect(result3.inserted_count).to eq(2)
|
|
819
|
-
end
|
|
820
|
-
end
|
|
821
|
-
end
|
|
822
|
-
end
|
|
823
|
-
end
|
|
824
|
-
|
|
825
|
-
describe '#insert_one' do
|
|
826
|
-
|
|
827
|
-
after do
|
|
828
|
-
authorized_collection.delete_many
|
|
829
|
-
collection_with_validator.delete_many
|
|
830
|
-
end
|
|
831
|
-
|
|
832
|
-
let(:result) do
|
|
833
|
-
authorized_collection.insert_one({ name: 'testing' })
|
|
834
|
-
end
|
|
835
|
-
|
|
836
|
-
it 'inserts the document into the collection', if: write_command_enabled? do
|
|
837
|
-
expect(result.written_count).to eq(1)
|
|
838
|
-
end
|
|
839
|
-
|
|
840
|
-
it 'inserts the document into the collection', unless: write_command_enabled? do
|
|
841
|
-
expect(result.written_count).to eq(0)
|
|
842
|
-
end
|
|
843
|
-
|
|
844
|
-
it 'contains the id in the result' do
|
|
845
|
-
expect(result.inserted_id).to_not be_nil
|
|
846
|
-
end
|
|
847
|
-
|
|
848
|
-
context 'when the document contains invalid keys' do
|
|
849
|
-
|
|
850
|
-
let(:doc) do
|
|
851
|
-
{ 'testing.test' => 'value' }
|
|
852
|
-
end
|
|
853
|
-
|
|
854
|
-
it 'raises a BSON::String::IllegalKey exception' do
|
|
855
|
-
expect {
|
|
856
|
-
authorized_collection.insert_one(doc)
|
|
857
|
-
}.to raise_exception(BSON::String::IllegalKey)
|
|
858
|
-
end
|
|
859
|
-
end
|
|
860
|
-
|
|
861
|
-
context 'when the insert fails' do
|
|
862
|
-
|
|
863
|
-
let(:result) do
|
|
864
|
-
authorized_collection.insert_one(_id: 1)
|
|
865
|
-
authorized_collection.insert_one(_id: 1)
|
|
866
|
-
end
|
|
867
|
-
|
|
868
|
-
it 'raises an OperationFailure' do
|
|
869
|
-
expect {
|
|
870
|
-
result
|
|
871
|
-
}.to raise_exception(Mongo::Error::OperationFailure)
|
|
872
|
-
end
|
|
873
|
-
end
|
|
874
|
-
|
|
875
|
-
context 'when the client has a custom id generator' do
|
|
876
|
-
|
|
877
|
-
let(:generator) do
|
|
878
|
-
Class.new do
|
|
879
|
-
def generate
|
|
880
|
-
1
|
|
881
|
-
end
|
|
882
|
-
end.new
|
|
883
|
-
end
|
|
884
|
-
|
|
885
|
-
let(:custom_client) do
|
|
886
|
-
authorized_client.with(id_generator: generator)
|
|
887
|
-
end
|
|
888
|
-
|
|
889
|
-
let(:custom_collection) do
|
|
890
|
-
custom_client[TEST_COLL]
|
|
891
|
-
end
|
|
892
|
-
|
|
893
|
-
before do
|
|
894
|
-
custom_collection.insert_one({ name: 'testing' })
|
|
895
|
-
end
|
|
896
|
-
|
|
897
|
-
after do
|
|
898
|
-
custom_client.close
|
|
899
|
-
end
|
|
900
|
-
|
|
901
|
-
it 'inserts with the custom id' do
|
|
902
|
-
expect(custom_collection.find.first[:_id]).to eq(1)
|
|
903
|
-
end
|
|
904
|
-
end
|
|
905
|
-
|
|
906
|
-
context 'when collection has a validator', if: find_command_enabled? do
|
|
907
|
-
|
|
908
|
-
context 'when the document is valid' do
|
|
909
|
-
|
|
910
|
-
let(:result) do
|
|
911
|
-
collection_with_validator.insert_one({ a: 1 })
|
|
912
|
-
end
|
|
913
|
-
|
|
914
|
-
it 'inserts successfully' do
|
|
915
|
-
expect(result.written_count).to eq(1)
|
|
916
|
-
end
|
|
917
|
-
end
|
|
918
|
-
|
|
919
|
-
context 'when the document is invalid' do
|
|
920
|
-
|
|
921
|
-
context 'when bypass_document_validation is not set' do
|
|
922
|
-
|
|
923
|
-
let(:result2) do
|
|
924
|
-
collection_with_validator.insert_one({ x: 1 })
|
|
925
|
-
end
|
|
926
|
-
|
|
927
|
-
it 'raises a OperationFailure' do
|
|
928
|
-
expect {
|
|
929
|
-
result2
|
|
930
|
-
}.to raise_exception(Mongo::Error::OperationFailure)
|
|
931
|
-
end
|
|
932
|
-
end
|
|
933
|
-
|
|
934
|
-
context 'when bypass_document_validation is true' do
|
|
935
|
-
|
|
936
|
-
let(:result3) do
|
|
937
|
-
collection_with_validator.insert_one(
|
|
938
|
-
{ x: 1 }, :bypass_document_validation => true)
|
|
939
|
-
end
|
|
940
|
-
|
|
941
|
-
it 'inserts successfully' do
|
|
942
|
-
expect(result3.written_count).to eq(1)
|
|
943
|
-
end
|
|
944
|
-
end
|
|
945
|
-
end
|
|
946
|
-
end
|
|
947
|
-
end
|
|
948
|
-
|
|
949
|
-
describe '#inspect' do
|
|
950
|
-
|
|
951
|
-
it 'includes the object id' do
|
|
952
|
-
expect(authorized_collection.inspect).to include(authorized_collection.object_id.to_s)
|
|
953
|
-
end
|
|
954
|
-
|
|
955
|
-
it 'includes the namespace' do
|
|
956
|
-
expect(authorized_collection.inspect).to include(authorized_collection.namespace)
|
|
957
|
-
end
|
|
958
|
-
end
|
|
959
|
-
|
|
960
|
-
describe '#indexes' do
|
|
961
|
-
|
|
962
|
-
let(:index_spec) do
|
|
963
|
-
{ name: 1 }
|
|
964
|
-
end
|
|
965
|
-
|
|
966
|
-
let(:batch_size) { nil }
|
|
967
|
-
|
|
968
|
-
let(:index_names) do
|
|
969
|
-
authorized_collection.indexes(batch_size: batch_size).collect { |i| i['name'] }
|
|
970
|
-
end
|
|
971
|
-
|
|
972
|
-
before do
|
|
973
|
-
authorized_collection.indexes.create_one(index_spec, unique: true)
|
|
974
|
-
end
|
|
975
|
-
|
|
976
|
-
after do
|
|
977
|
-
authorized_collection.indexes.drop_one('name_1')
|
|
978
|
-
end
|
|
979
|
-
|
|
980
|
-
it 'returns a list of indexes' do
|
|
981
|
-
expect(index_names).to include(*'name_1', '_id_')
|
|
982
|
-
end
|
|
983
|
-
|
|
984
|
-
context 'when batch size is specified' do
|
|
985
|
-
|
|
986
|
-
let(:batch_size) { 1 }
|
|
987
|
-
|
|
988
|
-
it 'returns a list of indexes' do
|
|
989
|
-
expect(index_names).to include(*'name_1', '_id_')
|
|
990
|
-
end
|
|
991
|
-
end
|
|
992
|
-
end
|
|
993
|
-
|
|
994
|
-
describe '#aggregate' do
|
|
995
|
-
|
|
996
|
-
it 'returns an Aggregation object' do
|
|
997
|
-
expect(authorized_collection.aggregate([])).to be_a(Mongo::Collection::View::Aggregation)
|
|
998
|
-
end
|
|
999
|
-
|
|
1000
|
-
context 'when options are provided' do
|
|
1001
|
-
|
|
1002
|
-
let(:options) do
|
|
1003
|
-
{ :allow_disk_use => true, :bypass_document_validation => true }
|
|
1004
|
-
end
|
|
1005
|
-
|
|
1006
|
-
it 'sets the options on the Aggregation object' do
|
|
1007
|
-
expect(authorized_collection.aggregate([], options).options).to eq(options)
|
|
1008
|
-
end
|
|
1009
|
-
end
|
|
1010
|
-
end
|
|
1011
|
-
|
|
1012
|
-
describe '#count' do
|
|
1013
|
-
|
|
1014
|
-
let(:documents) do
|
|
1015
|
-
(1..10).map{ |i| { field: "test#{i}" }}
|
|
1016
|
-
end
|
|
1017
|
-
|
|
1018
|
-
before do
|
|
1019
|
-
authorized_collection.insert_many(documents)
|
|
1020
|
-
end
|
|
1021
|
-
|
|
1022
|
-
after do
|
|
1023
|
-
authorized_collection.delete_many
|
|
1024
|
-
end
|
|
1025
|
-
|
|
1026
|
-
it 'returns an integer count' do
|
|
1027
|
-
expect(authorized_collection.count).to eq(10)
|
|
1028
|
-
end
|
|
1029
|
-
|
|
1030
|
-
context 'when options are provided' do
|
|
1031
|
-
|
|
1032
|
-
it 'passes the options to the count' do
|
|
1033
|
-
expect(authorized_collection.count({}, limit: 5)).to eq(5)
|
|
1034
|
-
end
|
|
1035
|
-
end
|
|
1036
|
-
end
|
|
1037
|
-
|
|
1038
|
-
describe '#distinct' do
|
|
1039
|
-
|
|
1040
|
-
let(:documents) do
|
|
1041
|
-
(1..3).map{ |i| { field: "test#{i}" }}
|
|
1042
|
-
end
|
|
1043
|
-
|
|
1044
|
-
before do
|
|
1045
|
-
authorized_collection.insert_many(documents)
|
|
1046
|
-
end
|
|
1047
|
-
|
|
1048
|
-
after do
|
|
1049
|
-
authorized_collection.delete_many
|
|
1050
|
-
end
|
|
1051
|
-
|
|
1052
|
-
it 'returns the distinct values' do
|
|
1053
|
-
expect(authorized_collection.distinct(:field).sort).to eq([ 'test1', 'test2', 'test3' ])
|
|
1054
|
-
end
|
|
1055
|
-
|
|
1056
|
-
context 'when a selector is provided' do
|
|
1057
|
-
|
|
1058
|
-
it 'returns the distinct values' do
|
|
1059
|
-
expect(authorized_collection.distinct(:field, field: 'test1')).to eq([ 'test1' ])
|
|
1060
|
-
end
|
|
1061
|
-
end
|
|
1062
|
-
|
|
1063
|
-
context 'when options are provided' do
|
|
1064
|
-
|
|
1065
|
-
it 'passes the options to the distinct command' do
|
|
1066
|
-
expect(authorized_collection.distinct(:field, {}, max_time_ms: 100).sort).to eq([ 'test1', 'test2', 'test3' ])
|
|
1067
|
-
end
|
|
1068
|
-
end
|
|
1069
|
-
end
|
|
1070
|
-
|
|
1071
|
-
describe '#delete_one' do
|
|
1072
|
-
|
|
1073
|
-
context 'when a selector was provided' do
|
|
1074
|
-
|
|
1075
|
-
let(:selector) do
|
|
1076
|
-
{ field: 'test1' }
|
|
1077
|
-
end
|
|
1078
|
-
|
|
1079
|
-
before do
|
|
1080
|
-
authorized_collection.insert_many([
|
|
1081
|
-
{ field: 'test1' },
|
|
1082
|
-
{ field: 'test1' },
|
|
1083
|
-
{ field: 'test1' }
|
|
1084
|
-
])
|
|
1085
|
-
end
|
|
1086
|
-
|
|
1087
|
-
after do
|
|
1088
|
-
authorized_collection.delete_many
|
|
1089
|
-
end
|
|
1090
|
-
|
|
1091
|
-
let(:response) do
|
|
1092
|
-
authorized_collection.delete_one(selector)
|
|
1093
|
-
end
|
|
1094
|
-
|
|
1095
|
-
it 'deletes the first matching document in the collection' do
|
|
1096
|
-
expect(response.deleted_count).to eq(1)
|
|
1097
|
-
end
|
|
1098
|
-
end
|
|
1099
|
-
|
|
1100
|
-
context 'when no selector was provided' do
|
|
1101
|
-
|
|
1102
|
-
before do
|
|
1103
|
-
authorized_collection.insert_many([{ field: 'test1' }, { field: 'test2' }])
|
|
1104
|
-
end
|
|
1105
|
-
|
|
1106
|
-
let(:response) do
|
|
1107
|
-
authorized_collection.delete_one
|
|
1108
|
-
end
|
|
1109
|
-
|
|
1110
|
-
it 'deletes the first document in the collection' do
|
|
1111
|
-
expect(response.deleted_count).to eq(1)
|
|
1112
|
-
end
|
|
1113
|
-
end
|
|
1114
|
-
|
|
1115
|
-
context 'when the delete fails', if: standalone? do
|
|
1116
|
-
|
|
1117
|
-
let(:result) do
|
|
1118
|
-
collection_invalid_write_concern.delete_one
|
|
1119
|
-
end
|
|
1120
|
-
|
|
1121
|
-
it 'raises an OperationFailure' do
|
|
1122
|
-
expect {
|
|
1123
|
-
result
|
|
1124
|
-
}.to raise_exception(Mongo::Error::OperationFailure)
|
|
1125
|
-
end
|
|
1126
|
-
end
|
|
1127
|
-
end
|
|
1128
|
-
|
|
1129
|
-
describe '#delete_many' do
|
|
1130
|
-
|
|
1131
|
-
before do
|
|
1132
|
-
authorized_collection.insert_many([{ field: 'test1' }, { field: 'test2' }])
|
|
1133
|
-
end
|
|
1134
|
-
|
|
1135
|
-
after do
|
|
1136
|
-
authorized_collection.delete_many
|
|
1137
|
-
end
|
|
1138
|
-
|
|
1139
|
-
context 'when a selector was provided' do
|
|
1140
|
-
|
|
1141
|
-
let(:selector) do
|
|
1142
|
-
{ field: 'test1' }
|
|
1143
|
-
end
|
|
1144
|
-
|
|
1145
|
-
it 'deletes the matching documents in the collection' do
|
|
1146
|
-
expect(authorized_collection.delete_many(selector).deleted_count).to eq(1)
|
|
1147
|
-
end
|
|
1148
|
-
end
|
|
1149
|
-
|
|
1150
|
-
context 'when no selector was provided' do
|
|
1151
|
-
|
|
1152
|
-
it 'deletes all the documents in the collection' do
|
|
1153
|
-
expect(authorized_collection.delete_many.deleted_count).to eq(2)
|
|
1154
|
-
end
|
|
1155
|
-
end
|
|
1156
|
-
|
|
1157
|
-
context 'when the deletes fail', if: standalone? do
|
|
1158
|
-
|
|
1159
|
-
let(:result) do
|
|
1160
|
-
collection_invalid_write_concern.delete_many
|
|
1161
|
-
end
|
|
1162
|
-
|
|
1163
|
-
it 'raises an OperationFailure' do
|
|
1164
|
-
expect {
|
|
1165
|
-
result
|
|
1166
|
-
}.to raise_exception(Mongo::Error::OperationFailure)
|
|
1167
|
-
end
|
|
1168
|
-
end
|
|
1169
|
-
end
|
|
1170
|
-
|
|
1171
|
-
describe '#parallel_scan', unless: sharded? do
|
|
1172
|
-
|
|
1173
|
-
let(:documents) do
|
|
1174
|
-
(1..200).map do |i|
|
|
1175
|
-
{ name: "testing-scan-#{i}" }
|
|
1176
|
-
end
|
|
1177
|
-
end
|
|
1178
|
-
|
|
1179
|
-
before do
|
|
1180
|
-
authorized_collection.insert_many(documents)
|
|
1181
|
-
end
|
|
1182
|
-
|
|
1183
|
-
let(:cursors) do
|
|
1184
|
-
authorized_collection.parallel_scan(2)
|
|
1185
|
-
end
|
|
1186
|
-
|
|
1187
|
-
it 'returns an array of cursors', if: write_command_enabled? do
|
|
1188
|
-
cursors.each do |cursor|
|
|
1189
|
-
expect(cursor.class).to be(Mongo::Cursor)
|
|
1190
|
-
end
|
|
1191
|
-
end
|
|
1192
|
-
|
|
1193
|
-
it 'returns the correct number of documents', if: write_command_enabled? do
|
|
1194
|
-
expect(
|
|
1195
|
-
cursors.reduce(0) { |total, cursor| total + cursor.to_a.size }
|
|
1196
|
-
).to eq(200)
|
|
1197
|
-
end
|
|
1198
|
-
|
|
1199
|
-
it 'raises an error', unless: write_command_enabled? do
|
|
1200
|
-
expect {
|
|
1201
|
-
cursors
|
|
1202
|
-
}.to raise_error(Mongo::Error::OperationFailure)
|
|
1203
|
-
end
|
|
1204
|
-
|
|
1205
|
-
context 'when a read concern is provided', if: find_command_enabled? do
|
|
1206
|
-
|
|
1207
|
-
let(:result) do
|
|
1208
|
-
authorized_collection.with(options).parallel_scan(2)
|
|
1209
|
-
end
|
|
1210
|
-
|
|
1211
|
-
context 'when the read concern is valid' do
|
|
1212
|
-
|
|
1213
|
-
let(:options) do
|
|
1214
|
-
{ read_concern: { level: 'local' }}
|
|
1215
|
-
end
|
|
1216
|
-
|
|
1217
|
-
it 'sends the read concern' do
|
|
1218
|
-
expect { result }.to_not raise_error
|
|
1219
|
-
end
|
|
1220
|
-
end
|
|
1221
|
-
|
|
1222
|
-
context 'when the read concern is not valid' do
|
|
1223
|
-
|
|
1224
|
-
let(:options) do
|
|
1225
|
-
{ read_concern: { level: 'idontknow' }}
|
|
1226
|
-
end
|
|
1227
|
-
|
|
1228
|
-
it 'raises an exception' do
|
|
1229
|
-
expect {
|
|
1230
|
-
result
|
|
1231
|
-
}.to raise_error(Mongo::Error::OperationFailure)
|
|
1232
|
-
end
|
|
1233
|
-
end
|
|
1234
|
-
end
|
|
1235
|
-
|
|
1236
|
-
context 'when the collection has a read preference', unless: sharded? do
|
|
1237
|
-
|
|
1238
|
-
before do
|
|
1239
|
-
allow(collection.client.cluster).to receive(:single?).and_return(false)
|
|
1240
|
-
end
|
|
1241
|
-
|
|
1242
|
-
after do
|
|
1243
|
-
client.close
|
|
1244
|
-
end
|
|
1245
|
-
|
|
1246
|
-
let(:client) do
|
|
1247
|
-
authorized_client.with(server_selection_timeout: 0.2)
|
|
1248
|
-
end
|
|
1249
|
-
|
|
1250
|
-
let(:collection) do
|
|
1251
|
-
client[authorized_collection.name,
|
|
1252
|
-
read: { :mode => :secondary, :tag_sets => [{ 'non' => 'existent' }] }]
|
|
1253
|
-
end
|
|
1254
|
-
|
|
1255
|
-
let(:result) do
|
|
1256
|
-
collection.parallel_scan(2)
|
|
1257
|
-
end
|
|
1258
|
-
|
|
1259
|
-
it 'uses that read preference' do
|
|
1260
|
-
expect {
|
|
1261
|
-
result
|
|
1262
|
-
}.to raise_exception(Mongo::Error::NoServerAvailable)
|
|
1263
|
-
end
|
|
1264
|
-
end
|
|
1265
|
-
end
|
|
1266
|
-
|
|
1267
|
-
describe '#replace_one' do
|
|
1268
|
-
|
|
1269
|
-
let(:selector) do
|
|
1270
|
-
{ field: 'test1' }
|
|
1271
|
-
end
|
|
1272
|
-
|
|
1273
|
-
context 'when a selector was provided' do
|
|
1274
|
-
|
|
1275
|
-
before do
|
|
1276
|
-
authorized_collection.insert_many([{ field: 'test1' }, { field: 'test1' }])
|
|
1277
|
-
end
|
|
1278
|
-
|
|
1279
|
-
after do
|
|
1280
|
-
authorized_collection.delete_many
|
|
1281
|
-
end
|
|
1282
|
-
|
|
1283
|
-
let!(:response) do
|
|
1284
|
-
authorized_collection.replace_one(selector, { field: 'testing' })
|
|
1285
|
-
end
|
|
1286
|
-
|
|
1287
|
-
let(:updated) do
|
|
1288
|
-
authorized_collection.find(field: 'testing').first
|
|
1289
|
-
end
|
|
1290
|
-
|
|
1291
|
-
it 'updates the first matching document in the collection' do
|
|
1292
|
-
expect(response.modified_count).to eq(1)
|
|
1293
|
-
end
|
|
1294
|
-
|
|
1295
|
-
it 'updates the documents in the collection' do
|
|
1296
|
-
expect(updated[:field]).to eq('testing')
|
|
1297
|
-
end
|
|
1298
|
-
end
|
|
1299
|
-
|
|
1300
|
-
context 'when upsert is false' do
|
|
1301
|
-
|
|
1302
|
-
let!(:response) do
|
|
1303
|
-
authorized_collection.replace_one(selector, { field: 'test1' }, upsert: false)
|
|
1304
|
-
end
|
|
1305
|
-
|
|
1306
|
-
let(:updated) do
|
|
1307
|
-
authorized_collection.find(field: 'test1').to_a
|
|
1308
|
-
end
|
|
1309
|
-
|
|
1310
|
-
it 'reports that no documents were written' do
|
|
1311
|
-
expect(response.modified_count).to eq(0)
|
|
1312
|
-
end
|
|
1313
|
-
|
|
1314
|
-
it 'does not insert the document' do
|
|
1315
|
-
expect(updated).to be_empty
|
|
1316
|
-
end
|
|
1317
|
-
end
|
|
1318
|
-
|
|
1319
|
-
context 'when upsert is true' do
|
|
1320
|
-
|
|
1321
|
-
let!(:response) do
|
|
1322
|
-
authorized_collection.replace_one(selector, { field: 'test1' }, upsert: true)
|
|
1323
|
-
end
|
|
1324
|
-
|
|
1325
|
-
let(:updated) do
|
|
1326
|
-
authorized_collection.find(field: 'test1').first
|
|
1327
|
-
end
|
|
1328
|
-
|
|
1329
|
-
after do
|
|
1330
|
-
authorized_collection.delete_many
|
|
1331
|
-
end
|
|
1332
|
-
|
|
1333
|
-
it 'reports that a document was written' do
|
|
1334
|
-
expect(response.written_count).to eq(1)
|
|
1335
|
-
end
|
|
1336
|
-
|
|
1337
|
-
it 'inserts the document' do
|
|
1338
|
-
expect(updated[:field]).to eq('test1')
|
|
1339
|
-
end
|
|
1340
|
-
end
|
|
1341
|
-
|
|
1342
|
-
context 'when upsert is not specified' do
|
|
1343
|
-
|
|
1344
|
-
let!(:response) do
|
|
1345
|
-
authorized_collection.replace_one(selector, { field: 'test1' })
|
|
1346
|
-
end
|
|
1347
|
-
|
|
1348
|
-
let(:updated) do
|
|
1349
|
-
authorized_collection.find(field: 'test1').to_a
|
|
1350
|
-
end
|
|
1351
|
-
|
|
1352
|
-
it 'reports that no documents were written' do
|
|
1353
|
-
expect(response.modified_count).to eq(0)
|
|
1354
|
-
end
|
|
1355
|
-
|
|
1356
|
-
it 'does not insert the document' do
|
|
1357
|
-
expect(updated).to be_empty
|
|
1358
|
-
end
|
|
1359
|
-
end
|
|
1360
|
-
|
|
1361
|
-
context 'when the replace fails' do
|
|
1362
|
-
|
|
1363
|
-
let(:result) do
|
|
1364
|
-
authorized_collection.replace_one(selector, { '$s' => 'test1' })
|
|
1365
|
-
end
|
|
1366
|
-
|
|
1367
|
-
it 'raises an OperationFailure' do
|
|
1368
|
-
expect {
|
|
1369
|
-
result
|
|
1370
|
-
}.to raise_exception(Mongo::Error::OperationFailure)
|
|
1371
|
-
end
|
|
1372
|
-
end
|
|
1373
|
-
|
|
1374
|
-
context 'when collection has a validator', if: find_command_enabled? do
|
|
1375
|
-
|
|
1376
|
-
before do
|
|
1377
|
-
collection_with_validator.insert_one({ a: 1 })
|
|
1378
|
-
end
|
|
1379
|
-
|
|
1380
|
-
after do
|
|
1381
|
-
collection_with_validator.delete_many
|
|
1382
|
-
end
|
|
1383
|
-
|
|
1384
|
-
context 'when the document is valid' do
|
|
1385
|
-
|
|
1386
|
-
let(:result) do
|
|
1387
|
-
collection_with_validator.replace_one({ a: 1 }, { a: 5 })
|
|
1388
|
-
end
|
|
1389
|
-
|
|
1390
|
-
it 'replaces successfully' do
|
|
1391
|
-
expect(result.modified_count).to eq(1)
|
|
1392
|
-
end
|
|
1393
|
-
end
|
|
1394
|
-
|
|
1395
|
-
context 'when the document is invalid' do
|
|
1396
|
-
|
|
1397
|
-
context 'when bypass_document_validation is not set' do
|
|
1398
|
-
|
|
1399
|
-
let(:result2) do
|
|
1400
|
-
collection_with_validator.replace_one({ a: 1 }, { x: 5 })
|
|
1401
|
-
end
|
|
1402
|
-
|
|
1403
|
-
it 'raises OperationFailure' do
|
|
1404
|
-
expect {
|
|
1405
|
-
result2
|
|
1406
|
-
}.to raise_exception(Mongo::Error::OperationFailure)
|
|
1407
|
-
end
|
|
1408
|
-
end
|
|
1409
|
-
|
|
1410
|
-
context 'when bypass_document_validation is true' do
|
|
1411
|
-
|
|
1412
|
-
let(:result3) do
|
|
1413
|
-
collection_with_validator.replace_one(
|
|
1414
|
-
{ a: 1 }, { x: 1 }, :bypass_document_validation => true)
|
|
1415
|
-
end
|
|
1416
|
-
|
|
1417
|
-
it 'replaces successfully' do
|
|
1418
|
-
expect(result3.written_count).to eq(1)
|
|
1419
|
-
end
|
|
1420
|
-
end
|
|
1421
|
-
end
|
|
1422
|
-
end
|
|
1423
|
-
end
|
|
1424
|
-
|
|
1425
|
-
describe '#update_many' do
|
|
1426
|
-
|
|
1427
|
-
let(:selector) do
|
|
1428
|
-
{ field: 'test' }
|
|
1429
|
-
end
|
|
1430
|
-
|
|
1431
|
-
after do
|
|
1432
|
-
authorized_collection.delete_many
|
|
1433
|
-
end
|
|
1434
|
-
|
|
1435
|
-
context 'when a selector was provided' do
|
|
1436
|
-
|
|
1437
|
-
before do
|
|
1438
|
-
authorized_collection.insert_many([{ field: 'test' }, { field: 'test' }])
|
|
1439
|
-
end
|
|
1440
|
-
|
|
1441
|
-
let!(:response) do
|
|
1442
|
-
authorized_collection.update_many(selector, '$set'=> { field: 'testing' })
|
|
1443
|
-
end
|
|
1444
|
-
|
|
1445
|
-
let(:updated) do
|
|
1446
|
-
authorized_collection.find(field: 'testing').to_a.last
|
|
1447
|
-
end
|
|
1448
|
-
|
|
1449
|
-
it 'returns the number updated' do
|
|
1450
|
-
expect(response.modified_count).to eq(2)
|
|
1451
|
-
end
|
|
1452
|
-
|
|
1453
|
-
it 'updates the documents in the collection' do
|
|
1454
|
-
expect(updated[:field]).to eq('testing')
|
|
1455
|
-
end
|
|
1456
|
-
end
|
|
1457
|
-
|
|
1458
|
-
context 'when upsert is false' do
|
|
1459
|
-
|
|
1460
|
-
let(:response) do
|
|
1461
|
-
authorized_collection.update_many(selector, { '$set'=> { field: 'testing' } },
|
|
1462
|
-
upsert: false)
|
|
1463
|
-
end
|
|
1464
|
-
|
|
1465
|
-
let(:updated) do
|
|
1466
|
-
authorized_collection.find.to_a
|
|
1467
|
-
end
|
|
1468
|
-
|
|
1469
|
-
it 'reports that no documents were updated' do
|
|
1470
|
-
expect(response.modified_count).to eq(0)
|
|
1471
|
-
end
|
|
1472
|
-
|
|
1473
|
-
it 'updates no documents in the collection' do
|
|
1474
|
-
expect(updated).to be_empty
|
|
1475
|
-
end
|
|
1476
|
-
end
|
|
1477
|
-
|
|
1478
|
-
context 'when upsert is true' do
|
|
1479
|
-
|
|
1480
|
-
let!(:response) do
|
|
1481
|
-
authorized_collection.update_many(selector, { '$set'=> { field: 'testing' } },
|
|
1482
|
-
upsert: true)
|
|
1483
|
-
end
|
|
1484
|
-
|
|
1485
|
-
let(:updated) do
|
|
1486
|
-
authorized_collection.find.to_a.last
|
|
1487
|
-
end
|
|
1488
|
-
|
|
1489
|
-
it 'reports that a document was written' do
|
|
1490
|
-
expect(response.written_count).to eq(1)
|
|
1491
|
-
end
|
|
1492
|
-
|
|
1493
|
-
it 'inserts a document into the collection' do
|
|
1494
|
-
expect(updated[:field]).to eq('testing')
|
|
1495
|
-
end
|
|
1496
|
-
end
|
|
1497
|
-
|
|
1498
|
-
context 'when upsert is not specified' do
|
|
1499
|
-
|
|
1500
|
-
let(:response) do
|
|
1501
|
-
authorized_collection.update_many(selector, { '$set'=> { field: 'testing' } })
|
|
1502
|
-
end
|
|
1503
|
-
|
|
1504
|
-
let(:updated) do
|
|
1505
|
-
authorized_collection.find.to_a
|
|
1506
|
-
end
|
|
1507
|
-
|
|
1508
|
-
it 'reports that no documents were updated' do
|
|
1509
|
-
expect(response.modified_count).to eq(0)
|
|
1510
|
-
end
|
|
1511
|
-
|
|
1512
|
-
it 'updates no documents in the collection' do
|
|
1513
|
-
expect(updated).to be_empty
|
|
1514
|
-
end
|
|
1515
|
-
end
|
|
1516
|
-
|
|
1517
|
-
context 'when the updates fail' do
|
|
1518
|
-
|
|
1519
|
-
let(:result) do
|
|
1520
|
-
authorized_collection.update_many(selector, { '$s'=> { field: 'testing' } })
|
|
1521
|
-
end
|
|
1522
|
-
|
|
1523
|
-
it 'raises an OperationFailure' do
|
|
1524
|
-
expect {
|
|
1525
|
-
result
|
|
1526
|
-
}.to raise_exception(Mongo::Error::OperationFailure)
|
|
1527
|
-
end
|
|
1528
|
-
end
|
|
1529
|
-
|
|
1530
|
-
context 'when collection has a validator', if: find_command_enabled? do
|
|
1531
|
-
|
|
1532
|
-
before do
|
|
1533
|
-
collection_with_validator.insert_many([{ a: 1 }, { a: 2 }])
|
|
1534
|
-
end
|
|
1535
|
-
|
|
1536
|
-
after do
|
|
1537
|
-
collection_with_validator.delete_many
|
|
1538
|
-
end
|
|
1539
|
-
|
|
1540
|
-
context 'when the document is valid' do
|
|
1541
|
-
|
|
1542
|
-
let(:result) do
|
|
1543
|
-
collection_with_validator.update_many(
|
|
1544
|
-
{ :a => { '$gt' => 0 } }, '$inc' => { :a => 1 } )
|
|
1545
|
-
end
|
|
1546
|
-
|
|
1547
|
-
it 'updates successfully' do
|
|
1548
|
-
expect(result.modified_count).to eq(2)
|
|
1549
|
-
end
|
|
1550
|
-
end
|
|
1551
|
-
|
|
1552
|
-
context 'when the document is invalid' do
|
|
1553
|
-
|
|
1554
|
-
context 'when bypass_document_validation is not set' do
|
|
1555
|
-
|
|
1556
|
-
let(:result2) do
|
|
1557
|
-
collection_with_validator.update_many(
|
|
1558
|
-
{ :a => { '$gt' => 0 } }, '$unset' => { :a => '' })
|
|
1559
|
-
end
|
|
1560
|
-
|
|
1561
|
-
it 'raises OperationFailure' do
|
|
1562
|
-
expect {
|
|
1563
|
-
result2
|
|
1564
|
-
}.to raise_exception(Mongo::Error::OperationFailure)
|
|
1565
|
-
end
|
|
1566
|
-
end
|
|
1567
|
-
|
|
1568
|
-
context 'when bypass_document_validation is true' do
|
|
1569
|
-
|
|
1570
|
-
let(:result3) do
|
|
1571
|
-
collection_with_validator.update_many(
|
|
1572
|
-
{ :a => { '$gt' => 0 } }, { '$unset' => { :a => '' } },
|
|
1573
|
-
:bypass_document_validation => true)
|
|
1574
|
-
end
|
|
1575
|
-
|
|
1576
|
-
it 'updates successfully' do
|
|
1577
|
-
expect(result3.written_count).to eq(2)
|
|
1578
|
-
end
|
|
1579
|
-
end
|
|
1580
|
-
end
|
|
1581
|
-
end
|
|
1582
|
-
end
|
|
1583
|
-
|
|
1584
|
-
describe '#update_one' do
|
|
1585
|
-
|
|
1586
|
-
let(:selector) do
|
|
1587
|
-
{ field: 'test1' }
|
|
1588
|
-
end
|
|
1589
|
-
|
|
1590
|
-
context 'when a selector was provided' do
|
|
1591
|
-
|
|
1592
|
-
before do
|
|
1593
|
-
authorized_collection.insert_many([{ field: 'test1' }, { field: 'test1' }])
|
|
1594
|
-
end
|
|
1595
|
-
|
|
1596
|
-
let!(:response) do
|
|
1597
|
-
authorized_collection.update_one(selector, '$set'=> { field: 'testing' })
|
|
1598
|
-
end
|
|
1599
|
-
|
|
1600
|
-
let(:updated) do
|
|
1601
|
-
authorized_collection.find(field: 'testing').first
|
|
1602
|
-
end
|
|
1603
|
-
|
|
1604
|
-
it 'updates the first matching document in the collection' do
|
|
1605
|
-
expect(response.modified_count).to eq(1)
|
|
1606
|
-
end
|
|
1607
|
-
|
|
1608
|
-
it 'updates the documents in the collection' do
|
|
1609
|
-
expect(updated[:field]).to eq('testing')
|
|
1610
|
-
end
|
|
1611
|
-
end
|
|
1612
|
-
|
|
1613
|
-
context 'when upsert is false' do
|
|
1614
|
-
|
|
1615
|
-
let(:response) do
|
|
1616
|
-
authorized_collection.update_one(selector, { '$set'=> { field: 'testing' } },
|
|
1617
|
-
upsert: false)
|
|
1618
|
-
end
|
|
1619
|
-
|
|
1620
|
-
let(:updated) do
|
|
1621
|
-
authorized_collection.find.to_a
|
|
1622
|
-
end
|
|
1623
|
-
|
|
1624
|
-
it 'reports that no documents were updated' do
|
|
1625
|
-
expect(response.modified_count).to eq(0)
|
|
1626
|
-
end
|
|
1627
|
-
|
|
1628
|
-
it 'updates no documents in the collection' do
|
|
1629
|
-
expect(updated).to be_empty
|
|
1630
|
-
end
|
|
1631
|
-
end
|
|
1632
|
-
|
|
1633
|
-
context 'when upsert is true' do
|
|
1634
|
-
|
|
1635
|
-
let!(:response) do
|
|
1636
|
-
authorized_collection.update_one(selector, { '$set'=> { field: 'testing' } },
|
|
1637
|
-
upsert: true)
|
|
1638
|
-
end
|
|
1639
|
-
|
|
1640
|
-
let(:updated) do
|
|
1641
|
-
authorized_collection.find.first
|
|
1642
|
-
end
|
|
1643
|
-
|
|
1644
|
-
it 'reports that a document was written' do
|
|
1645
|
-
expect(response.written_count).to eq(1)
|
|
1646
|
-
end
|
|
1647
|
-
|
|
1648
|
-
it 'inserts a document into the collection' do
|
|
1649
|
-
expect(updated[:field]).to eq('testing')
|
|
1650
|
-
end
|
|
1651
|
-
end
|
|
1652
|
-
|
|
1653
|
-
context 'when upsert is not specified' do
|
|
1654
|
-
|
|
1655
|
-
let(:response) do
|
|
1656
|
-
authorized_collection.update_one(selector, { '$set'=> { field: 'testing' } })
|
|
1657
|
-
end
|
|
1658
|
-
|
|
1659
|
-
let(:updated) do
|
|
1660
|
-
authorized_collection.find.to_a
|
|
1661
|
-
end
|
|
1662
|
-
|
|
1663
|
-
it 'reports that no documents were updated' do
|
|
1664
|
-
expect(response.modified_count).to eq(0)
|
|
1665
|
-
end
|
|
1666
|
-
|
|
1667
|
-
it 'updates no documents in the collection' do
|
|
1668
|
-
expect(updated).to be_empty
|
|
1669
|
-
end
|
|
1670
|
-
end
|
|
1671
|
-
|
|
1672
|
-
context 'when the update fails' do
|
|
1673
|
-
|
|
1674
|
-
let(:result) do
|
|
1675
|
-
authorized_collection.update_one(selector, { '$s'=> { field: 'testing' } })
|
|
1676
|
-
end
|
|
1677
|
-
|
|
1678
|
-
it 'raises an OperationFailure' do
|
|
1679
|
-
expect {
|
|
1680
|
-
result
|
|
1681
|
-
}.to raise_exception(Mongo::Error::OperationFailure)
|
|
1682
|
-
end
|
|
1683
|
-
end
|
|
1684
|
-
|
|
1685
|
-
context 'when collection has a validator', if: find_command_enabled? do
|
|
1686
|
-
|
|
1687
|
-
before do
|
|
1688
|
-
collection_with_validator.insert_one({ a: 1 })
|
|
1689
|
-
end
|
|
1690
|
-
|
|
1691
|
-
after do
|
|
1692
|
-
collection_with_validator.delete_many
|
|
1693
|
-
end
|
|
1694
|
-
|
|
1695
|
-
context 'when the document is valid' do
|
|
1696
|
-
|
|
1697
|
-
let(:result) do
|
|
1698
|
-
collection_with_validator.update_one(
|
|
1699
|
-
{ :a => { '$gt' => 0 } }, '$inc' => { :a => 1 } )
|
|
1700
|
-
end
|
|
1701
|
-
|
|
1702
|
-
it 'updates successfully' do
|
|
1703
|
-
expect(result.modified_count).to eq(1)
|
|
1704
|
-
end
|
|
1705
|
-
end
|
|
1706
|
-
|
|
1707
|
-
context 'when the document is invalid' do
|
|
1708
|
-
|
|
1709
|
-
context 'when bypass_document_validation is not set' do
|
|
1710
|
-
|
|
1711
|
-
let(:result2) do
|
|
1712
|
-
collection_with_validator.update_one(
|
|
1713
|
-
{ :a => { '$gt' => 0 } }, '$unset' => { :a => '' })
|
|
1714
|
-
end
|
|
1715
|
-
|
|
1716
|
-
it 'raises OperationFailure' do
|
|
1717
|
-
expect {
|
|
1718
|
-
result2
|
|
1719
|
-
}.to raise_exception(Mongo::Error::OperationFailure)
|
|
1720
|
-
end
|
|
1721
|
-
end
|
|
1722
|
-
|
|
1723
|
-
context 'when bypass_document_validation is true' do
|
|
1724
|
-
|
|
1725
|
-
let(:result3) do
|
|
1726
|
-
collection_with_validator.update_one(
|
|
1727
|
-
{ :a => { '$gt' => 0 } }, { '$unset' => { :a => '' } },
|
|
1728
|
-
:bypass_document_validation => true)
|
|
1729
|
-
end
|
|
1730
|
-
|
|
1731
|
-
it 'updates successfully' do
|
|
1732
|
-
expect(result3.written_count).to eq(1)
|
|
1733
|
-
end
|
|
1734
|
-
end
|
|
1735
|
-
end
|
|
1736
|
-
end
|
|
1737
|
-
end
|
|
1738
|
-
|
|
1739
|
-
describe '#find_one_and_delete' do
|
|
1740
|
-
|
|
1741
|
-
before do
|
|
1742
|
-
authorized_collection.insert_many([{ field: 'test1' }])
|
|
1743
|
-
end
|
|
1744
|
-
|
|
1745
|
-
let(:selector) do
|
|
1746
|
-
{ field: 'test1' }
|
|
1747
|
-
end
|
|
1748
|
-
|
|
1749
|
-
context 'when a matching document is found' do
|
|
1750
|
-
|
|
1751
|
-
context 'when no options are provided' do
|
|
1752
|
-
|
|
1753
|
-
let!(:document) do
|
|
1754
|
-
authorized_collection.find_one_and_delete(selector)
|
|
1755
|
-
end
|
|
1756
|
-
|
|
1757
|
-
it 'deletes the document from the database' do
|
|
1758
|
-
expect(authorized_collection.find.to_a).to be_empty
|
|
1759
|
-
end
|
|
1760
|
-
|
|
1761
|
-
it 'returns the document' do
|
|
1762
|
-
expect(document['field']).to eq('test1')
|
|
1763
|
-
end
|
|
1764
|
-
end
|
|
1765
|
-
|
|
1766
|
-
context 'when a projection is provided' do
|
|
1767
|
-
|
|
1768
|
-
let!(:document) do
|
|
1769
|
-
authorized_collection.find_one_and_delete(selector, projection: { _id: 1 })
|
|
1770
|
-
end
|
|
1771
|
-
|
|
1772
|
-
it 'deletes the document from the database' do
|
|
1773
|
-
expect(authorized_collection.find.to_a).to be_empty
|
|
1774
|
-
end
|
|
1775
|
-
|
|
1776
|
-
it 'returns the document with limited fields' do
|
|
1777
|
-
expect(document['field']).to be_nil
|
|
1778
|
-
expect(document['_id']).to_not be_nil
|
|
1779
|
-
end
|
|
1780
|
-
end
|
|
1781
|
-
|
|
1782
|
-
context 'when a sort is provided' do
|
|
1783
|
-
|
|
1784
|
-
let!(:document) do
|
|
1785
|
-
authorized_collection.find_one_and_delete(selector, sort: { field: 1 })
|
|
1786
|
-
end
|
|
1787
|
-
|
|
1788
|
-
it 'deletes the document from the database' do
|
|
1789
|
-
expect(authorized_collection.find.to_a).to be_empty
|
|
1790
|
-
end
|
|
1791
|
-
|
|
1792
|
-
it 'returns the document with limited fields' do
|
|
1793
|
-
expect(document['field']).to eq('test1')
|
|
1794
|
-
end
|
|
1795
|
-
end
|
|
1796
|
-
|
|
1797
|
-
context 'when max_time_ms is provided', if: write_command_enabled? do
|
|
1798
|
-
|
|
1799
|
-
it 'includes the max_time_ms value in the command' do
|
|
1800
|
-
expect {
|
|
1801
|
-
authorized_collection.find_one_and_delete(selector, max_time_ms: 0.1)
|
|
1802
|
-
}.to raise_error(Mongo::Error::OperationFailure)
|
|
1803
|
-
end
|
|
1804
|
-
end
|
|
1805
|
-
end
|
|
1806
|
-
|
|
1807
|
-
context 'when no matching document is found' do
|
|
1808
|
-
|
|
1809
|
-
let(:selector) do
|
|
1810
|
-
{ field: 'test5' }
|
|
1811
|
-
end
|
|
1812
|
-
|
|
1813
|
-
let!(:document) do
|
|
1814
|
-
authorized_collection.find_one_and_delete(selector)
|
|
1815
|
-
end
|
|
1816
|
-
|
|
1817
|
-
it 'returns nil' do
|
|
1818
|
-
expect(document).to be_nil
|
|
1819
|
-
end
|
|
1820
|
-
end
|
|
1821
|
-
|
|
1822
|
-
context 'when the operation fails', if: write_command_enabled? do
|
|
1823
|
-
|
|
1824
|
-
let(:result) do
|
|
1825
|
-
authorized_collection.find_one_and_delete(selector, max_time_ms: 0.1)
|
|
1826
|
-
end
|
|
1827
|
-
|
|
1828
|
-
it 'raises an OperationFailure' do
|
|
1829
|
-
expect {
|
|
1830
|
-
result
|
|
1831
|
-
}.to raise_exception(Mongo::Error::OperationFailure)
|
|
1832
|
-
end
|
|
1833
|
-
end
|
|
1834
|
-
|
|
1835
|
-
context 'when write_concern is provided', if: find_command_enabled? && standalone? do
|
|
1836
|
-
|
|
1837
|
-
it 'uses the write concern' do
|
|
1838
|
-
expect {
|
|
1839
|
-
authorized_collection.find_one_and_delete(selector,
|
|
1840
|
-
write_concern: { w: 2 })
|
|
1841
|
-
}.to raise_error(Mongo::Error::OperationFailure)
|
|
1842
|
-
end
|
|
1843
|
-
end
|
|
1844
|
-
|
|
1845
|
-
context 'when the collection has a write concern', if: find_command_enabled? && standalone? do
|
|
1846
|
-
|
|
1847
|
-
let(:collection) do
|
|
1848
|
-
authorized_collection.with(write: { w: 2 })
|
|
1849
|
-
end
|
|
1850
|
-
|
|
1851
|
-
it 'uses the write concern' do
|
|
1852
|
-
expect {
|
|
1853
|
-
collection.find_one_and_delete(selector,
|
|
1854
|
-
write_concern: { w: 2 })
|
|
1855
|
-
}.to raise_error(Mongo::Error::OperationFailure)
|
|
1856
|
-
end
|
|
1857
|
-
end
|
|
1858
|
-
end
|
|
1859
|
-
|
|
1860
|
-
describe '#find_one_and_update' do
|
|
1861
|
-
|
|
1862
|
-
let(:selector) do
|
|
1863
|
-
{ field: 'test1' }
|
|
1864
|
-
end
|
|
1865
|
-
|
|
1866
|
-
before do
|
|
1867
|
-
authorized_collection.insert_many([{ field: 'test1' }])
|
|
1868
|
-
end
|
|
1869
|
-
|
|
1870
|
-
context 'when a matching document is found' do
|
|
1871
|
-
|
|
1872
|
-
context 'when no options are provided' do
|
|
1873
|
-
|
|
1874
|
-
let(:document) do
|
|
1875
|
-
authorized_collection.find_one_and_update(selector, { '$set' => { field: 'testing' }})
|
|
1876
|
-
end
|
|
1877
|
-
|
|
1878
|
-
it 'returns the original document' do
|
|
1879
|
-
expect(document['field']).to eq('test1')
|
|
1880
|
-
end
|
|
1881
|
-
end
|
|
1882
|
-
|
|
1883
|
-
context 'when no options are provided' do
|
|
1884
|
-
|
|
1885
|
-
let(:document) do
|
|
1886
|
-
authorized_collection.find_one_and_update(selector, { '$set' => { field: 'testing' }})
|
|
1887
|
-
end
|
|
1888
|
-
|
|
1889
|
-
it 'returns the original document' do
|
|
1890
|
-
expect(document['field']).to eq('test1')
|
|
1891
|
-
end
|
|
1892
|
-
end
|
|
1893
|
-
|
|
1894
|
-
context 'when return_document options are provided' do
|
|
1895
|
-
|
|
1896
|
-
context 'when return_document is :after' do
|
|
1897
|
-
|
|
1898
|
-
let(:document) do
|
|
1899
|
-
authorized_collection.find_one_and_update(selector, { '$set' => { field: 'testing' }}, :return_document => :after)
|
|
1900
|
-
end
|
|
1901
|
-
|
|
1902
|
-
it 'returns the new document' do
|
|
1903
|
-
expect(document['field']).to eq('testing')
|
|
1904
|
-
end
|
|
1905
|
-
end
|
|
1906
|
-
|
|
1907
|
-
context 'when return_document is :before' do
|
|
1908
|
-
|
|
1909
|
-
let(:document) do
|
|
1910
|
-
authorized_collection.find_one_and_update(selector, { '$set' => { field: 'testing' }}, :return_document => :before)
|
|
1911
|
-
end
|
|
1912
|
-
|
|
1913
|
-
it 'returns the original document' do
|
|
1914
|
-
expect(document['field']).to eq('test1')
|
|
1915
|
-
end
|
|
1916
|
-
end
|
|
1917
|
-
end
|
|
1918
|
-
|
|
1919
|
-
context 'when a projection is provided' do
|
|
1920
|
-
|
|
1921
|
-
let(:document) do
|
|
1922
|
-
authorized_collection.find_one_and_update(selector, { '$set' => { field: 'testing' }}, projection: { _id: 1 })
|
|
1923
|
-
end
|
|
1924
|
-
|
|
1925
|
-
it 'returns the document with limited fields' do
|
|
1926
|
-
expect(document['field']).to be_nil
|
|
1927
|
-
expect(document['_id']).to_not be_nil
|
|
1928
|
-
end
|
|
1929
|
-
end
|
|
1930
|
-
|
|
1931
|
-
context 'when a sort is provided' do
|
|
1932
|
-
|
|
1933
|
-
let(:document) do
|
|
1934
|
-
authorized_collection.find_one_and_update(selector, { '$set' => { field: 'testing' }}, sort: { field: 1 })
|
|
1935
|
-
end
|
|
1936
|
-
|
|
1937
|
-
it 'returns the original document' do
|
|
1938
|
-
expect(document['field']).to eq('test1')
|
|
1939
|
-
end
|
|
1940
|
-
end
|
|
1941
|
-
end
|
|
1942
|
-
|
|
1943
|
-
context 'when max_time_ms is provided' do
|
|
1944
|
-
|
|
1945
|
-
it 'includes the max_time_ms value in the command', if: write_command_enabled? do
|
|
1946
|
-
expect {
|
|
1947
|
-
authorized_collection.find_one_and_update(selector, { '$set' => { field: 'testing' }}, max_time_ms: 0.1)
|
|
1948
|
-
}.to raise_error(Mongo::Error::OperationFailure)
|
|
1949
|
-
end
|
|
1950
|
-
end
|
|
1951
|
-
|
|
1952
|
-
context 'when no matching document is found' do
|
|
1953
|
-
|
|
1954
|
-
let(:selector) do
|
|
1955
|
-
{ field: 'test5' }
|
|
1956
|
-
end
|
|
1957
|
-
|
|
1958
|
-
let(:document) do
|
|
1959
|
-
authorized_collection.find_one_and_update(selector, { '$set' => { field: 'testing' }})
|
|
1960
|
-
end
|
|
1961
|
-
|
|
1962
|
-
it 'returns nil' do
|
|
1963
|
-
expect(document).to be_nil
|
|
1964
|
-
end
|
|
1965
|
-
end
|
|
1966
|
-
|
|
1967
|
-
context 'when no matching document is found' do
|
|
1968
|
-
|
|
1969
|
-
context 'when no upsert options are provided' do
|
|
1970
|
-
|
|
1971
|
-
let(:selector) do
|
|
1972
|
-
{ field: 'test5' }
|
|
1973
|
-
end
|
|
1974
|
-
|
|
1975
|
-
let(:document) do
|
|
1976
|
-
authorized_collection.find_one_and_update(selector, { '$set' => { field: 'testing' }})
|
|
1977
|
-
end
|
|
1978
|
-
|
|
1979
|
-
it 'returns nil' do
|
|
1980
|
-
expect(document).to be_nil
|
|
1981
|
-
end
|
|
1982
|
-
end
|
|
1983
|
-
|
|
1984
|
-
context 'when upsert options are provided' do
|
|
1985
|
-
|
|
1986
|
-
let(:selector) do
|
|
1987
|
-
{ field: 'test5' }
|
|
1988
|
-
end
|
|
1989
|
-
|
|
1990
|
-
let(:document) do
|
|
1991
|
-
authorized_collection.find_one_and_update(selector, { '$set' => { field: 'testing' }}, :upsert => true, :return_document => :after)
|
|
1992
|
-
end
|
|
1993
|
-
|
|
1994
|
-
it 'returns the new document' do
|
|
1995
|
-
expect(document['field']).to eq('testing')
|
|
1996
|
-
end
|
|
1997
|
-
end
|
|
1998
|
-
end
|
|
1999
|
-
|
|
2000
|
-
context 'when the operation fails', if: write_command_enabled? do
|
|
2001
|
-
|
|
2002
|
-
let(:result) do
|
|
2003
|
-
authorized_collection.find_one_and_update(selector, { '$set' => { field: 'testing' }}, max_time_ms: 0.1)
|
|
2004
|
-
end
|
|
2005
|
-
|
|
2006
|
-
it 'raises an OperationFailure' do
|
|
2007
|
-
expect {
|
|
2008
|
-
result
|
|
2009
|
-
}.to raise_exception(Mongo::Error::OperationFailure)
|
|
2010
|
-
end
|
|
2011
|
-
end
|
|
2012
|
-
|
|
2013
|
-
context 'when collection has a validator', if: find_command_enabled? do
|
|
2014
|
-
|
|
2015
|
-
before do
|
|
2016
|
-
collection_with_validator.insert_one({ a: 1 })
|
|
2017
|
-
end
|
|
2018
|
-
|
|
2019
|
-
after do
|
|
2020
|
-
collection_with_validator.delete_many
|
|
2021
|
-
end
|
|
2022
|
-
|
|
2023
|
-
context 'when the document is valid' do
|
|
2024
|
-
|
|
2025
|
-
let(:result) do
|
|
2026
|
-
collection_with_validator.find_one_and_update(
|
|
2027
|
-
{ a: 1 }, { '$inc' => { :a => 1 } }, :return_document => :after)
|
|
2028
|
-
end
|
|
2029
|
-
|
|
2030
|
-
it 'updates successfully' do
|
|
2031
|
-
expect(result['a']).to eq(2)
|
|
2032
|
-
end
|
|
2033
|
-
end
|
|
2034
|
-
|
|
2035
|
-
context 'when the document is invalid' do
|
|
2036
|
-
|
|
2037
|
-
context 'when bypass_document_validation is not set' do
|
|
2038
|
-
|
|
2039
|
-
let(:result2) do
|
|
2040
|
-
collection_with_validator.find_one_and_update(
|
|
2041
|
-
{ a: 1 }, { '$unset' => { :a => '' } }, :return_document => :after)
|
|
2042
|
-
end
|
|
2043
|
-
|
|
2044
|
-
it 'raises OperationFailure' do
|
|
2045
|
-
expect {
|
|
2046
|
-
result2
|
|
2047
|
-
}.to raise_exception(Mongo::Error::OperationFailure)
|
|
2048
|
-
end
|
|
2049
|
-
end
|
|
2050
|
-
|
|
2051
|
-
context 'when bypass_document_validation is true' do
|
|
2052
|
-
|
|
2053
|
-
let(:result3) do
|
|
2054
|
-
collection_with_validator.find_one_and_update(
|
|
2055
|
-
{ a: 1 }, { '$unset' => { :a => '' } },
|
|
2056
|
-
:bypass_document_validation => true,
|
|
2057
|
-
:return_document => :after)
|
|
2058
|
-
end
|
|
2059
|
-
|
|
2060
|
-
it 'updates successfully' do
|
|
2061
|
-
expect(result3['a']).to be_nil
|
|
2062
|
-
end
|
|
2063
|
-
end
|
|
2064
|
-
end
|
|
2065
|
-
end
|
|
2066
|
-
|
|
2067
|
-
context 'when write_concern is provided', if: find_command_enabled? && standalone? do
|
|
2068
|
-
|
|
2069
|
-
it 'uses the write concern' do
|
|
2070
|
-
expect {
|
|
2071
|
-
authorized_collection.find_one_and_update(selector,
|
|
2072
|
-
{ '$set' => { field: 'testing' }},
|
|
2073
|
-
write_concern: { w: 2 })
|
|
2074
|
-
}.to raise_error(Mongo::Error::OperationFailure)
|
|
2075
|
-
end
|
|
2076
|
-
end
|
|
2077
|
-
|
|
2078
|
-
context 'when the collection has a write concern', if: find_command_enabled? && standalone? do
|
|
2079
|
-
|
|
2080
|
-
let(:collection) do
|
|
2081
|
-
authorized_collection.with(write: { w: 2 })
|
|
2082
|
-
end
|
|
2083
|
-
|
|
2084
|
-
it 'uses the write concern' do
|
|
2085
|
-
expect {
|
|
2086
|
-
collection.find_one_and_update(selector,
|
|
2087
|
-
{ '$set' => { field: 'testing' }},
|
|
2088
|
-
write_concern: { w: 2 })
|
|
2089
|
-
}.to raise_error(Mongo::Error::OperationFailure)
|
|
2090
|
-
end
|
|
2091
|
-
end
|
|
2092
|
-
end
|
|
2093
|
-
|
|
2094
|
-
describe '#find_one_and_replace' do
|
|
2095
|
-
|
|
2096
|
-
before do
|
|
2097
|
-
authorized_collection.insert_many([{ field: 'test1', other: 'sth' }])
|
|
2098
|
-
end
|
|
2099
|
-
|
|
2100
|
-
let(:selector) do
|
|
2101
|
-
{ field: 'test1' }
|
|
2102
|
-
end
|
|
2103
|
-
|
|
2104
|
-
context 'when a matching document is found' do
|
|
2105
|
-
|
|
2106
|
-
context 'when no options are provided' do
|
|
2107
|
-
|
|
2108
|
-
let(:document) do
|
|
2109
|
-
authorized_collection.find_one_and_replace(selector, { field: 'testing' })
|
|
2110
|
-
end
|
|
2111
|
-
|
|
2112
|
-
it 'returns the original document' do
|
|
2113
|
-
expect(document['field']).to eq('test1')
|
|
2114
|
-
end
|
|
2115
|
-
end
|
|
2116
|
-
|
|
2117
|
-
context 'when return_document options are provided' do
|
|
2118
|
-
|
|
2119
|
-
context 'when return_document is :after' do
|
|
2120
|
-
|
|
2121
|
-
let(:document) do
|
|
2122
|
-
authorized_collection.find_one_and_replace(selector, { field: 'testing' }, :return_document => :after)
|
|
2123
|
-
end
|
|
2124
|
-
|
|
2125
|
-
it 'returns the new document' do
|
|
2126
|
-
expect(document['field']).to eq('testing')
|
|
2127
|
-
end
|
|
2128
|
-
end
|
|
2129
|
-
|
|
2130
|
-
context 'when return_document is :before' do
|
|
2131
|
-
|
|
2132
|
-
let(:document) do
|
|
2133
|
-
authorized_collection.find_one_and_replace(selector, { field: 'testing' }, :return_document => :before)
|
|
2134
|
-
end
|
|
2135
|
-
|
|
2136
|
-
it 'returns the original document' do
|
|
2137
|
-
expect(document['field']).to eq('test1')
|
|
2138
|
-
end
|
|
2139
|
-
end
|
|
2140
|
-
end
|
|
2141
|
-
|
|
2142
|
-
context 'when a projection is provided' do
|
|
2143
|
-
|
|
2144
|
-
let(:document) do
|
|
2145
|
-
authorized_collection.find_one_and_replace(selector, { field: 'testing' }, projection: { _id: 1 })
|
|
2146
|
-
end
|
|
2147
|
-
|
|
2148
|
-
it 'returns the document with limited fields' do
|
|
2149
|
-
expect(document['field']).to be_nil
|
|
2150
|
-
expect(document['_id']).to_not be_nil
|
|
2151
|
-
end
|
|
2152
|
-
end
|
|
2153
|
-
|
|
2154
|
-
context 'when a sort is provided' do
|
|
2155
|
-
|
|
2156
|
-
let(:document) do
|
|
2157
|
-
authorized_collection.find_one_and_replace(selector, { field: 'testing' }, :sort => { field: 1 })
|
|
2158
|
-
end
|
|
2159
|
-
|
|
2160
|
-
it 'returns the original document' do
|
|
2161
|
-
expect(document['field']).to eq('test1')
|
|
2162
|
-
end
|
|
2163
|
-
end
|
|
2164
|
-
end
|
|
2165
|
-
|
|
2166
|
-
context 'when no matching document is found' do
|
|
2167
|
-
|
|
2168
|
-
context 'when no upsert options are provided' do
|
|
2169
|
-
|
|
2170
|
-
let(:selector) do
|
|
2171
|
-
{ field: 'test5' }
|
|
2172
|
-
end
|
|
2173
|
-
|
|
2174
|
-
let(:document) do
|
|
2175
|
-
authorized_collection.find_one_and_replace(selector, { field: 'testing' })
|
|
2176
|
-
end
|
|
2177
|
-
|
|
2178
|
-
it 'returns nil' do
|
|
2179
|
-
expect(document).to be_nil
|
|
2180
|
-
end
|
|
2181
|
-
end
|
|
2182
|
-
|
|
2183
|
-
context 'when upsert options are provided' do
|
|
2184
|
-
|
|
2185
|
-
let(:selector) do
|
|
2186
|
-
{ field: 'test5' }
|
|
2187
|
-
end
|
|
2188
|
-
|
|
2189
|
-
let(:document) do
|
|
2190
|
-
authorized_collection.find_one_and_replace(selector, { field: 'testing' }, :upsert => true, :return_document => :after)
|
|
2191
|
-
end
|
|
2192
|
-
|
|
2193
|
-
it 'returns the new document' do
|
|
2194
|
-
expect(document['field']).to eq('testing')
|
|
2195
|
-
end
|
|
2196
|
-
end
|
|
2197
|
-
end
|
|
2198
|
-
|
|
2199
|
-
context 'when max_time_ms is provided', if: write_command_enabled? do
|
|
2200
|
-
|
|
2201
|
-
it 'includes the max_time_ms value in the command' do
|
|
2202
|
-
expect {
|
|
2203
|
-
authorized_collection.find_one_and_replace(selector, { field: 'testing' }, max_time_ms: 0.1)
|
|
2204
|
-
}.to raise_error(Mongo::Error::OperationFailure)
|
|
2205
|
-
end
|
|
2206
|
-
end
|
|
2207
|
-
|
|
2208
|
-
context 'when the operation fails', if: write_command_enabled? do
|
|
2209
|
-
|
|
2210
|
-
let(:result) do
|
|
2211
|
-
authorized_collection.find_one_and_replace(selector, { field: 'testing' }, max_time_ms: 0.1)
|
|
2212
|
-
end
|
|
2213
|
-
|
|
2214
|
-
it 'raises an OperationFailure' do
|
|
2215
|
-
expect {
|
|
2216
|
-
result
|
|
2217
|
-
}.to raise_exception(Mongo::Error::OperationFailure)
|
|
2218
|
-
end
|
|
2219
|
-
end
|
|
2220
|
-
|
|
2221
|
-
context 'when collection has a validator', if: find_command_enabled? do
|
|
2222
|
-
|
|
2223
|
-
before do
|
|
2224
|
-
collection_with_validator.insert_one({ a: 1 })
|
|
2225
|
-
end
|
|
2226
|
-
|
|
2227
|
-
after do
|
|
2228
|
-
collection_with_validator.delete_many
|
|
2229
|
-
end
|
|
2230
|
-
|
|
2231
|
-
context 'when the document is valid' do
|
|
2232
|
-
|
|
2233
|
-
let(:result) do
|
|
2234
|
-
collection_with_validator.find_one_and_replace(
|
|
2235
|
-
{ a: 1 }, { a: 5 }, :return_document => :after)
|
|
2236
|
-
end
|
|
2237
|
-
|
|
2238
|
-
it 'replaces successfully when document is valid' do
|
|
2239
|
-
expect(result[:a]).to eq(5)
|
|
2240
|
-
end
|
|
2241
|
-
end
|
|
2242
|
-
|
|
2243
|
-
context 'when the document is invalid' do
|
|
2244
|
-
|
|
2245
|
-
context 'when bypass_document_validation is not set' do
|
|
2246
|
-
|
|
2247
|
-
let(:result2) do
|
|
2248
|
-
collection_with_validator.find_one_and_replace(
|
|
2249
|
-
{ a: 1 }, { x: 5 }, :return_document => :after)
|
|
2250
|
-
end
|
|
2251
|
-
|
|
2252
|
-
it 'raises OperationFailure' do
|
|
2253
|
-
expect {
|
|
2254
|
-
result2
|
|
2255
|
-
}.to raise_exception(Mongo::Error::OperationFailure)
|
|
2256
|
-
end
|
|
2257
|
-
end
|
|
2258
|
-
|
|
2259
|
-
context 'when bypass_document_validation is true' do
|
|
2260
|
-
|
|
2261
|
-
let(:result3) do
|
|
2262
|
-
collection_with_validator.find_one_and_replace(
|
|
2263
|
-
{ a: 1 }, { x: 1 }, :bypass_document_validation => true,
|
|
2264
|
-
:return_document => :after)
|
|
2265
|
-
end
|
|
2266
|
-
|
|
2267
|
-
it 'replaces successfully' do
|
|
2268
|
-
expect(result3[:x]).to eq(1)
|
|
2269
|
-
expect(result3[:a]).to be_nil
|
|
2270
|
-
end
|
|
2271
|
-
end
|
|
2272
|
-
end
|
|
2273
|
-
end
|
|
2274
|
-
|
|
2275
|
-
context 'when write_concern is provided', if: find_command_enabled? && standalone? do
|
|
2276
|
-
|
|
2277
|
-
it 'uses the write concern' do
|
|
2278
|
-
expect {
|
|
2279
|
-
authorized_collection.find_one_and_replace(selector,
|
|
2280
|
-
{ field: 'testing' },
|
|
2281
|
-
write_concern: { w: 2 })
|
|
2282
|
-
}.to raise_error(Mongo::Error::OperationFailure)
|
|
2283
|
-
end
|
|
2284
|
-
end
|
|
2285
|
-
|
|
2286
|
-
context 'when the collection has a write concern', if: find_command_enabled? && standalone? do
|
|
2287
|
-
|
|
2288
|
-
let(:collection) do
|
|
2289
|
-
authorized_collection.with(write: { w: 2 })
|
|
2290
|
-
end
|
|
2291
|
-
|
|
2292
|
-
it 'uses the write concern' do
|
|
2293
|
-
expect {
|
|
2294
|
-
collection.find_one_and_replace(selector,
|
|
2295
|
-
{ field: 'testing' },
|
|
2296
|
-
write_concern: { w: 2 })
|
|
2297
|
-
}.to raise_error(Mongo::Error::OperationFailure)
|
|
2298
|
-
end
|
|
2299
|
-
end
|
|
2300
|
-
end
|
|
2301
804
|
end
|