mongo 2.13.2 → 2.15.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 +4 -4
- checksums.yaml.gz.sig +1 -2
- data.tar.gz.sig +0 -0
- data/README.md +5 -2
- data/Rakefile +46 -18
- data/lib/mongo.rb +35 -0
- data/lib/mongo/active_support.rb +3 -0
- data/lib/mongo/address.rb +3 -0
- data/lib/mongo/address/ipv4.rb +4 -1
- data/lib/mongo/address/ipv6.rb +4 -1
- data/lib/mongo/address/unix.rb +3 -0
- data/lib/mongo/address/validator.rb +3 -0
- data/lib/mongo/auth.rb +4 -1
- data/lib/mongo/auth/aws.rb +3 -0
- data/lib/mongo/auth/aws/conversation.rb +4 -4
- data/lib/mongo/auth/aws/credentials_retriever.rb +3 -0
- data/lib/mongo/auth/aws/request.rb +3 -0
- data/lib/mongo/auth/base.rb +17 -8
- data/lib/mongo/auth/conversation_base.rb +35 -0
- data/lib/mongo/auth/cr.rb +3 -0
- data/lib/mongo/auth/cr/conversation.rb +9 -29
- data/lib/mongo/auth/credential_cache.rb +3 -0
- data/lib/mongo/auth/gssapi.rb +3 -0
- data/lib/mongo/auth/gssapi/conversation.rb +7 -15
- data/lib/mongo/auth/ldap.rb +3 -0
- data/lib/mongo/auth/ldap/conversation.rb +6 -14
- data/lib/mongo/auth/roles.rb +3 -0
- data/lib/mongo/auth/sasl_conversation_base.rb +4 -13
- data/lib/mongo/auth/scram.rb +5 -2
- data/lib/mongo/auth/scram/conversation.rb +3 -0
- data/lib/mongo/auth/scram256.rb +3 -0
- data/lib/mongo/auth/scram256/conversation.rb +3 -0
- data/lib/mongo/auth/scram_conversation_base.rb +10 -34
- data/lib/mongo/auth/stringprep.rb +4 -1
- data/lib/mongo/auth/stringprep/profiles/sasl.rb +3 -0
- data/lib/mongo/auth/stringprep/tables.rb +3 -0
- data/lib/mongo/auth/stringprep/unicode_normalize/normalize.rb +2 -2
- data/lib/mongo/auth/stringprep/unicode_normalize/tables.rb +1 -1
- data/lib/mongo/auth/user.rb +3 -0
- data/lib/mongo/auth/user/view.rb +19 -9
- data/lib/mongo/auth/x509.rb +3 -0
- data/lib/mongo/auth/x509/conversation.rb +7 -25
- data/lib/mongo/background_thread.rb +16 -2
- data/lib/mongo/bson.rb +3 -0
- data/lib/mongo/bulk_write.rb +41 -18
- data/lib/mongo/bulk_write/combineable.rb +3 -0
- data/lib/mongo/bulk_write/ordered_combiner.rb +3 -0
- data/lib/mongo/bulk_write/result.rb +3 -0
- data/lib/mongo/bulk_write/result_combiner.rb +3 -0
- data/lib/mongo/bulk_write/transformable.rb +3 -0
- data/lib/mongo/bulk_write/unordered_combiner.rb +3 -0
- data/lib/mongo/bulk_write/validatable.rb +3 -0
- data/lib/mongo/caching_cursor.rb +77 -0
- data/lib/mongo/client.rb +133 -15
- data/lib/mongo/client_encryption.rb +3 -0
- data/lib/mongo/cluster.rb +32 -38
- data/lib/mongo/cluster/periodic_executor.rb +3 -0
- data/lib/mongo/cluster/reapers/cursor_reaper.rb +9 -2
- data/lib/mongo/cluster/reapers/socket_reaper.rb +3 -0
- data/lib/mongo/cluster/sdam_flow.rb +17 -0
- data/lib/mongo/cluster/topology.rb +3 -0
- data/lib/mongo/cluster/topology/base.rb +3 -0
- data/lib/mongo/cluster/topology/no_replica_set_options.rb +3 -0
- data/lib/mongo/cluster/topology/replica_set_no_primary.rb +3 -0
- data/lib/mongo/cluster/topology/replica_set_with_primary.rb +3 -0
- data/lib/mongo/cluster/topology/sharded.rb +3 -0
- data/lib/mongo/cluster/topology/single.rb +4 -1
- data/lib/mongo/cluster/topology/unknown.rb +3 -0
- data/lib/mongo/cluster_time.rb +3 -0
- data/lib/mongo/collection.rb +74 -17
- data/lib/mongo/collection/view.rb +27 -20
- data/lib/mongo/collection/view/aggregation.rb +29 -5
- data/lib/mongo/collection/view/builder.rb +3 -0
- data/lib/mongo/collection/view/builder/aggregation.rb +3 -0
- data/lib/mongo/collection/view/builder/find_command.rb +41 -18
- data/lib/mongo/collection/view/builder/flags.rb +3 -0
- data/lib/mongo/collection/view/builder/map_reduce.rb +3 -0
- data/lib/mongo/collection/view/builder/modifiers.rb +3 -0
- data/lib/mongo/collection/view/builder/op_query.rb +3 -0
- data/lib/mongo/collection/view/change_stream.rb +5 -2
- data/lib/mongo/collection/view/change_stream/retryable.rb +3 -0
- data/lib/mongo/collection/view/explainable.rb +30 -8
- data/lib/mongo/collection/view/immutable.rb +3 -0
- data/lib/mongo/collection/view/iterable.rb +76 -13
- data/lib/mongo/collection/view/map_reduce.rb +5 -2
- data/lib/mongo/collection/view/readable.rb +68 -23
- data/lib/mongo/collection/view/writable.rb +32 -15
- data/lib/mongo/crypt.rb +3 -0
- data/lib/mongo/crypt/auto_decryption_context.rb +3 -0
- data/lib/mongo/crypt/auto_encrypter.rb +4 -1
- data/lib/mongo/crypt/auto_encryption_context.rb +3 -0
- data/lib/mongo/crypt/binary.rb +3 -0
- data/lib/mongo/crypt/binding.rb +4 -1
- data/lib/mongo/crypt/context.rb +3 -0
- data/lib/mongo/crypt/data_key_context.rb +3 -0
- data/lib/mongo/crypt/encryption_io.rb +9 -6
- data/lib/mongo/crypt/explicit_decryption_context.rb +3 -0
- data/lib/mongo/crypt/explicit_encrypter.rb +3 -0
- data/lib/mongo/crypt/explicit_encryption_context.rb +3 -0
- data/lib/mongo/crypt/handle.rb +3 -0
- data/lib/mongo/crypt/hooks.rb +3 -0
- data/lib/mongo/crypt/kms_context.rb +3 -0
- data/lib/mongo/crypt/status.rb +3 -0
- data/lib/mongo/cursor.rb +22 -5
- data/lib/mongo/cursor/builder.rb +3 -0
- data/lib/mongo/cursor/builder/get_more_command.rb +3 -0
- data/lib/mongo/cursor/builder/kill_cursors_command.rb +3 -0
- data/lib/mongo/cursor/builder/op_get_more.rb +3 -0
- data/lib/mongo/cursor/builder/op_kill_cursors.rb +3 -0
- data/lib/mongo/database.rb +32 -6
- data/lib/mongo/database/view.rb +4 -1
- data/lib/mongo/dbref.rb +3 -0
- data/lib/mongo/distinguishing_semaphore.rb +3 -0
- data/lib/mongo/error.rb +14 -1
- data/lib/mongo/error/auth_error.rb +3 -0
- data/lib/mongo/error/bulk_write_error.rb +20 -3
- data/lib/mongo/error/change_stream_resumable.rb +3 -0
- data/lib/mongo/error/closed_stream.rb +3 -0
- data/lib/mongo/error/connection_check_out_timeout.rb +3 -0
- data/lib/mongo/error/connection_perished.rb +3 -0
- data/lib/mongo/error/credential_check_error.rb +3 -0
- data/lib/mongo/error/crypt_error.rb +3 -0
- data/lib/mongo/error/extra_file_chunk.rb +3 -0
- data/lib/mongo/error/failed_string_prep_validation.rb +3 -0
- data/lib/mongo/error/file_not_found.rb +3 -0
- data/lib/mongo/error/handshake_error.rb +3 -0
- data/lib/mongo/error/insufficient_iteration_count.rb +3 -0
- data/lib/mongo/error/internal_driver_error.rb +25 -0
- data/lib/mongo/error/invalid_address.rb +3 -0
- data/lib/mongo/error/invalid_application_name.rb +3 -0
- data/lib/mongo/error/invalid_bulk_operation.rb +3 -0
- data/lib/mongo/error/invalid_bulk_operation_type.rb +3 -0
- data/lib/mongo/error/invalid_collection_name.rb +3 -0
- data/lib/mongo/error/invalid_cursor_operation.rb +3 -0
- data/lib/mongo/error/invalid_database_name.rb +3 -0
- data/lib/mongo/error/invalid_document.rb +3 -0
- data/lib/mongo/error/invalid_file.rb +3 -0
- data/lib/mongo/error/invalid_file_revision.rb +3 -0
- data/lib/mongo/error/invalid_min_pool_size.rb +3 -0
- data/lib/mongo/error/invalid_nonce.rb +3 -0
- data/lib/mongo/error/invalid_read_concern.rb +31 -0
- data/lib/mongo/error/invalid_read_option.rb +3 -0
- data/lib/mongo/error/invalid_replacement_document.rb +3 -0
- data/lib/mongo/error/invalid_server_auth_host.rb +3 -0
- data/lib/mongo/error/invalid_server_auth_response.rb +3 -0
- data/lib/mongo/error/invalid_server_preference.rb +3 -0
- data/lib/mongo/error/invalid_session.rb +3 -0
- data/lib/mongo/error/invalid_signature.rb +3 -0
- data/lib/mongo/error/invalid_transaction_operation.rb +3 -0
- data/lib/mongo/error/invalid_txt_record.rb +3 -0
- data/lib/mongo/error/invalid_update_document.rb +3 -0
- data/lib/mongo/error/invalid_uri.rb +3 -0
- data/lib/mongo/error/invalid_write_concern.rb +3 -0
- data/lib/mongo/error/kms_error.rb +3 -0
- data/lib/mongo/error/lint_error.rb +3 -0
- data/lib/mongo/error/max_bson_size.rb +3 -0
- data/lib/mongo/error/max_message_size.rb +3 -0
- data/lib/mongo/error/mismatched_domain.rb +3 -0
- data/lib/mongo/error/missing_file_chunk.rb +3 -0
- data/lib/mongo/error/missing_password.rb +3 -0
- data/lib/mongo/error/missing_resume_token.rb +3 -0
- data/lib/mongo/error/missing_scram_server_signature.rb +3 -0
- data/lib/mongo/error/mongocryptd_spawn_error.rb +3 -0
- data/lib/mongo/error/multi_index_drop.rb +3 -0
- data/lib/mongo/error/need_primary_server.rb +3 -0
- data/lib/mongo/error/no_server_available.rb +3 -0
- data/lib/mongo/error/no_srv_records.rb +3 -0
- data/lib/mongo/error/notable.rb +3 -0
- data/lib/mongo/error/operation_failure.rb +26 -4
- data/lib/mongo/error/parser.rb +69 -13
- data/lib/mongo/error/pool_closed_error.rb +3 -0
- data/lib/mongo/error/raise_original_error.rb +3 -0
- data/lib/mongo/error/sdam_error_detection.rb +16 -5
- data/lib/mongo/error/server_api_conflict.rb +26 -0
- data/lib/mongo/error/server_api_not_supported.rb +27 -0
- data/lib/mongo/error/server_certificate_revoked.rb +25 -0
- data/lib/mongo/error/session_ended.rb +3 -0
- data/lib/mongo/error/sessions_not_supported.rb +3 -0
- data/lib/mongo/error/socket_error.rb +3 -0
- data/lib/mongo/error/socket_timeout_error.rb +3 -0
- data/lib/mongo/error/unchangeable_collection_option.rb +3 -0
- data/lib/mongo/error/unexpected_chunk_length.rb +3 -0
- data/lib/mongo/error/unexpected_response.rb +3 -0
- data/lib/mongo/error/unknown_payload_type.rb +3 -0
- data/lib/mongo/error/unmet_dependency.rb +24 -0
- data/lib/mongo/error/unsupported_array_filters.rb +3 -0
- data/lib/mongo/error/unsupported_collation.rb +3 -0
- data/lib/mongo/error/unsupported_features.rb +3 -0
- data/lib/mongo/error/unsupported_message_type.rb +3 -0
- data/lib/mongo/error/unsupported_option.rb +17 -12
- data/lib/mongo/error/write_retryable.rb +3 -0
- data/lib/mongo/event.rb +3 -0
- data/lib/mongo/event/base.rb +3 -0
- data/lib/mongo/event/listeners.rb +3 -0
- data/lib/mongo/event/publisher.rb +3 -0
- data/lib/mongo/event/subscriber.rb +3 -0
- data/lib/mongo/grid.rb +3 -0
- data/lib/mongo/grid/file.rb +3 -0
- data/lib/mongo/grid/file/chunk.rb +4 -1
- data/lib/mongo/grid/file/info.rb +3 -0
- data/lib/mongo/grid/fs_bucket.rb +65 -44
- data/lib/mongo/grid/stream.rb +3 -0
- data/lib/mongo/grid/stream/read.rb +22 -7
- data/lib/mongo/grid/stream/write.rb +3 -0
- data/lib/mongo/id.rb +3 -0
- data/lib/mongo/index.rb +3 -0
- data/lib/mongo/index/view.rb +24 -11
- data/lib/mongo/lint.rb +5 -1
- data/lib/mongo/loggable.rb +3 -0
- data/lib/mongo/logger.rb +6 -3
- data/lib/mongo/monitoring.rb +20 -8
- data/lib/mongo/monitoring/cmap_log_subscriber.rb +3 -0
- data/lib/mongo/monitoring/command_log_subscriber.rb +3 -0
- data/lib/mongo/monitoring/event.rb +3 -0
- data/lib/mongo/monitoring/event/cmap.rb +3 -0
- data/lib/mongo/monitoring/event/cmap/base.rb +3 -0
- data/lib/mongo/monitoring/event/cmap/connection_check_out_failed.rb +3 -0
- data/lib/mongo/monitoring/event/cmap/connection_check_out_started.rb +3 -0
- data/lib/mongo/monitoring/event/cmap/connection_checked_in.rb +3 -0
- data/lib/mongo/monitoring/event/cmap/connection_checked_out.rb +3 -0
- data/lib/mongo/monitoring/event/cmap/connection_closed.rb +3 -0
- data/lib/mongo/monitoring/event/cmap/connection_created.rb +3 -0
- data/lib/mongo/monitoring/event/cmap/connection_ready.rb +3 -0
- data/lib/mongo/monitoring/event/cmap/pool_cleared.rb +3 -0
- data/lib/mongo/monitoring/event/cmap/pool_closed.rb +3 -0
- data/lib/mongo/monitoring/event/cmap/pool_created.rb +3 -0
- data/lib/mongo/monitoring/event/command_failed.rb +32 -5
- data/lib/mongo/monitoring/event/command_started.rb +20 -2
- data/lib/mongo/monitoring/event/command_succeeded.rb +29 -3
- data/lib/mongo/monitoring/event/secure.rb +39 -5
- data/lib/mongo/monitoring/event/server_closed.rb +3 -0
- data/lib/mongo/monitoring/event/server_description_changed.rb +4 -1
- data/lib/mongo/monitoring/event/server_heartbeat_failed.rb +32 -18
- data/lib/mongo/monitoring/event/server_heartbeat_started.rb +3 -0
- data/lib/mongo/monitoring/event/server_heartbeat_succeeded.rb +30 -16
- data/lib/mongo/monitoring/event/server_opening.rb +3 -0
- data/lib/mongo/monitoring/event/topology_changed.rb +3 -0
- data/lib/mongo/monitoring/event/topology_closed.rb +3 -0
- data/lib/mongo/monitoring/event/topology_opening.rb +3 -0
- data/lib/mongo/monitoring/publishable.rb +32 -10
- data/lib/mongo/monitoring/sdam_log_subscriber.rb +3 -0
- data/lib/mongo/monitoring/server_closed_log_subscriber.rb +3 -0
- data/lib/mongo/monitoring/server_description_changed_log_subscriber.rb +3 -0
- data/lib/mongo/monitoring/server_opening_log_subscriber.rb +3 -0
- data/lib/mongo/monitoring/topology_changed_log_subscriber.rb +3 -0
- data/lib/mongo/monitoring/topology_closed_log_subscriber.rb +3 -0
- data/lib/mongo/monitoring/topology_opening_log_subscriber.rb +3 -0
- data/lib/mongo/monitoring/unified_sdam_log_subscriber.rb +3 -0
- data/lib/mongo/operation.rb +7 -2
- data/lib/mongo/operation/aggregate.rb +3 -0
- data/lib/mongo/operation/aggregate/command.rb +3 -0
- data/lib/mongo/operation/aggregate/op_msg.rb +3 -0
- data/lib/mongo/operation/aggregate/result.rb +12 -8
- data/lib/mongo/operation/collections_info.rb +21 -1
- data/lib/mongo/operation/collections_info/command.rb +5 -2
- data/lib/mongo/operation/collections_info/result.rb +5 -0
- data/lib/mongo/operation/command.rb +3 -0
- data/lib/mongo/operation/command/command.rb +3 -0
- data/lib/mongo/operation/command/op_msg.rb +3 -0
- data/lib/mongo/operation/context.rb +102 -0
- data/lib/mongo/operation/count.rb +3 -0
- data/lib/mongo/operation/count/command.rb +3 -0
- data/lib/mongo/operation/count/op_msg.rb +3 -0
- data/lib/mongo/operation/create.rb +3 -0
- data/lib/mongo/operation/create/command.rb +3 -0
- data/lib/mongo/operation/create/op_msg.rb +3 -0
- data/lib/mongo/operation/create_index.rb +3 -0
- data/lib/mongo/operation/create_index/command.rb +3 -0
- data/lib/mongo/operation/create_index/op_msg.rb +3 -0
- data/lib/mongo/operation/create_user.rb +3 -0
- data/lib/mongo/operation/create_user/command.rb +3 -0
- data/lib/mongo/operation/create_user/op_msg.rb +3 -0
- data/lib/mongo/operation/delete.rb +3 -0
- data/lib/mongo/operation/delete/bulk_result.rb +5 -0
- data/lib/mongo/operation/delete/command.rb +3 -0
- data/lib/mongo/operation/delete/legacy.rb +3 -0
- data/lib/mongo/operation/delete/op_msg.rb +3 -0
- data/lib/mongo/operation/delete/result.rb +6 -0
- data/lib/mongo/operation/distinct.rb +3 -0
- data/lib/mongo/operation/distinct/command.rb +3 -0
- data/lib/mongo/operation/distinct/op_msg.rb +3 -0
- data/lib/mongo/operation/drop.rb +3 -0
- data/lib/mongo/operation/drop/command.rb +3 -0
- data/lib/mongo/operation/drop/op_msg.rb +3 -0
- data/lib/mongo/operation/drop_database.rb +3 -0
- data/lib/mongo/operation/drop_database/command.rb +3 -0
- data/lib/mongo/operation/drop_database/op_msg.rb +3 -0
- data/lib/mongo/operation/drop_index.rb +3 -0
- data/lib/mongo/operation/drop_index/command.rb +3 -0
- data/lib/mongo/operation/drop_index/op_msg.rb +3 -0
- data/lib/mongo/operation/explain.rb +3 -0
- data/lib/mongo/operation/explain/command.rb +7 -0
- data/lib/mongo/operation/explain/legacy.rb +7 -0
- data/lib/mongo/operation/explain/op_msg.rb +9 -0
- data/lib/mongo/operation/explain/result.rb +6 -0
- data/lib/mongo/operation/find.rb +3 -0
- data/lib/mongo/operation/find/command.rb +3 -0
- data/lib/mongo/operation/find/legacy.rb +3 -0
- data/lib/mongo/operation/find/legacy/result.rb +5 -0
- data/lib/mongo/operation/find/op_msg.rb +3 -0
- data/lib/mongo/operation/find/result.rb +16 -0
- data/lib/mongo/operation/get_more.rb +3 -0
- data/lib/mongo/operation/get_more/command.rb +3 -0
- data/lib/mongo/operation/get_more/legacy.rb +3 -0
- data/lib/mongo/operation/get_more/op_msg.rb +3 -0
- data/lib/mongo/operation/get_more/result.rb +6 -0
- data/lib/mongo/operation/indexes.rb +18 -1
- data/lib/mongo/operation/indexes/command.rb +3 -0
- data/lib/mongo/operation/indexes/legacy.rb +3 -0
- data/lib/mongo/operation/indexes/op_msg.rb +3 -0
- data/lib/mongo/operation/indexes/result.rb +8 -0
- data/lib/mongo/operation/insert.rb +3 -0
- data/lib/mongo/operation/insert/bulk_result.rb +8 -0
- data/lib/mongo/operation/insert/command.rb +5 -2
- data/lib/mongo/operation/insert/legacy.rb +5 -2
- data/lib/mongo/operation/insert/op_msg.rb +5 -2
- data/lib/mongo/operation/insert/result.rb +8 -0
- data/lib/mongo/operation/kill_cursors.rb +3 -0
- data/lib/mongo/operation/kill_cursors/command.rb +3 -0
- data/lib/mongo/operation/kill_cursors/legacy.rb +3 -0
- data/lib/mongo/operation/kill_cursors/op_msg.rb +3 -0
- data/lib/mongo/operation/list_collections.rb +3 -0
- data/lib/mongo/operation/list_collections/command.rb +3 -0
- data/lib/mongo/operation/list_collections/op_msg.rb +3 -0
- data/lib/mongo/operation/list_collections/result.rb +12 -1
- data/lib/mongo/operation/map_reduce.rb +3 -0
- data/lib/mongo/operation/map_reduce/command.rb +3 -0
- data/lib/mongo/operation/map_reduce/op_msg.rb +3 -0
- data/lib/mongo/operation/map_reduce/result.rb +13 -0
- data/lib/mongo/operation/op_msg_base.rb +3 -0
- data/lib/mongo/operation/parallel_scan.rb +3 -0
- data/lib/mongo/operation/parallel_scan/command.rb +4 -2
- data/lib/mongo/operation/parallel_scan/op_msg.rb +3 -0
- data/lib/mongo/operation/parallel_scan/result.rb +7 -0
- data/lib/mongo/operation/remove_user.rb +3 -0
- data/lib/mongo/operation/remove_user/command.rb +3 -0
- data/lib/mongo/operation/remove_user/op_msg.rb +3 -0
- data/lib/mongo/operation/result.rb +40 -6
- data/lib/mongo/operation/shared/bypass_document_validation.rb +4 -0
- data/lib/mongo/operation/shared/causal_consistency_supported.rb +4 -0
- data/lib/mongo/operation/shared/executable.rb +25 -14
- data/lib/mongo/operation/shared/executable_no_validate.rb +5 -2
- data/lib/mongo/operation/shared/executable_transaction_label.rb +3 -0
- data/lib/mongo/operation/shared/idable.rb +5 -1
- data/lib/mongo/operation/shared/limited.rb +4 -0
- data/lib/mongo/operation/shared/object_id_generator.rb +4 -0
- data/lib/mongo/operation/shared/op_msg_or_command.rb +4 -7
- data/lib/mongo/operation/shared/op_msg_or_find_command.rb +4 -7
- data/lib/mongo/operation/shared/polymorphic_lookup.rb +3 -0
- data/lib/mongo/operation/shared/polymorphic_operation.rb +42 -0
- data/lib/mongo/operation/shared/polymorphic_result.rb +3 -0
- data/lib/mongo/operation/shared/read_preference_supported.rb +41 -36
- data/lib/mongo/operation/shared/response_handling.rb +26 -23
- data/lib/mongo/operation/shared/result/aggregatable.rb +4 -0
- data/lib/mongo/operation/shared/result/use_legacy_error_parser.rb +3 -0
- data/lib/mongo/operation/shared/sessions_supported.rb +20 -4
- data/lib/mongo/operation/shared/specifiable.rb +4 -0
- data/lib/mongo/operation/shared/write.rb +12 -18
- data/lib/mongo/operation/shared/write_concern_supported.rb +4 -0
- data/lib/mongo/operation/update.rb +3 -0
- data/lib/mongo/operation/update/bulk_result.rb +3 -0
- data/lib/mongo/operation/update/command.rb +3 -0
- data/lib/mongo/operation/update/legacy.rb +3 -0
- data/lib/mongo/operation/update/legacy/result.rb +10 -0
- data/lib/mongo/operation/update/op_msg.rb +3 -0
- data/lib/mongo/operation/update/result.rb +11 -0
- data/lib/mongo/operation/update_user.rb +3 -0
- data/lib/mongo/operation/update_user/command.rb +3 -0
- data/lib/mongo/operation/update_user/op_msg.rb +3 -0
- data/lib/mongo/operation/users_info.rb +3 -0
- data/lib/mongo/operation/users_info/command.rb +3 -0
- data/lib/mongo/operation/users_info/op_msg.rb +3 -0
- data/lib/mongo/operation/users_info/result.rb +6 -0
- data/lib/mongo/options.rb +3 -0
- data/lib/mongo/options/mapper.rb +3 -0
- data/lib/mongo/options/redacted.rb +3 -0
- data/lib/mongo/protocol.rb +3 -0
- data/lib/mongo/protocol/bit_vector.rb +3 -0
- data/lib/mongo/protocol/compressed.rb +54 -5
- data/lib/mongo/protocol/delete.rb +3 -0
- data/lib/mongo/protocol/get_more.rb +3 -0
- data/lib/mongo/protocol/insert.rb +3 -0
- data/lib/mongo/protocol/kill_cursors.rb +3 -0
- data/lib/mongo/protocol/message.rb +23 -2
- data/lib/mongo/protocol/msg.rb +39 -16
- data/lib/mongo/protocol/query.rb +18 -14
- data/lib/mongo/protocol/registry.rb +3 -0
- data/lib/mongo/protocol/reply.rb +3 -0
- data/lib/mongo/protocol/serializers.rb +3 -0
- data/lib/mongo/protocol/update.rb +3 -0
- data/lib/mongo/query_cache.rb +275 -0
- data/lib/mongo/retryable.rb +12 -2
- data/lib/mongo/semaphore.rb +3 -0
- data/lib/mongo/server.rb +29 -16
- data/lib/mongo/server/app_metadata.rb +89 -33
- data/lib/mongo/server/connection.rb +9 -1
- data/lib/mongo/server/connection_base.rb +35 -20
- data/lib/mongo/server/connection_common.rb +36 -3
- data/lib/mongo/server/connection_pool.rb +14 -6
- data/lib/mongo/server/connection_pool/populator.rb +3 -0
- data/lib/mongo/server/context.rb +3 -0
- data/lib/mongo/server/description.rb +35 -11
- data/lib/mongo/server/description/features.rb +13 -9
- data/lib/mongo/server/monitor.rb +27 -14
- data/lib/mongo/server/monitor/app_metadata.rb +4 -1
- data/lib/mongo/server/monitor/connection.rb +60 -50
- data/lib/mongo/server/pending_connection.rb +39 -22
- data/lib/mongo/server/push_monitor.rb +33 -18
- data/lib/mongo/server/push_monitor/connection.rb +3 -0
- data/lib/mongo/server/round_trip_time_averager.rb +6 -3
- data/lib/mongo/server_selector.rb +3 -0
- data/lib/mongo/server_selector/base.rb +11 -4
- data/lib/mongo/server_selector/nearest.rb +6 -4
- data/lib/mongo/server_selector/primary.rb +6 -4
- data/lib/mongo/server_selector/primary_preferred.rb +6 -4
- data/lib/mongo/server_selector/secondary.rb +6 -4
- data/lib/mongo/server_selector/secondary_preferred.rb +8 -11
- data/lib/mongo/session.rb +23 -12
- data/lib/mongo/session/server_session.rb +3 -0
- data/lib/mongo/session/session_pool.rb +7 -2
- data/lib/mongo/socket.rb +42 -10
- data/lib/mongo/socket/ocsp_cache.rb +100 -0
- data/lib/mongo/socket/ocsp_verifier.rb +376 -0
- data/lib/mongo/socket/ssl.rb +56 -24
- data/lib/mongo/socket/tcp.rb +3 -0
- data/lib/mongo/socket/unix.rb +3 -0
- data/lib/mongo/srv.rb +3 -0
- data/lib/mongo/srv/monitor.rb +10 -24
- data/lib/mongo/srv/resolver.rb +17 -10
- data/lib/mongo/srv/result.rb +3 -0
- data/lib/mongo/timeout.rb +5 -0
- data/lib/mongo/topology_version.rb +4 -1
- data/lib/mongo/uri.rb +24 -390
- data/lib/mongo/uri/options_mapper.rb +623 -0
- data/lib/mongo/uri/srv_protocol.rb +6 -2
- data/lib/mongo/utils.rb +57 -1
- data/lib/mongo/version.rb +4 -1
- data/lib/mongo/write_concern.rb +3 -0
- data/lib/mongo/write_concern/acknowledged.rb +3 -0
- data/lib/mongo/write_concern/base.rb +3 -0
- data/lib/mongo/write_concern/unacknowledged.rb +3 -0
- data/spec/NOTES.aws-auth.md +12 -7
- data/spec/README.md +87 -2
- data/spec/atlas/atlas_connectivity_spec.rb +3 -0
- data/spec/atlas/operations_spec.rb +3 -0
- data/spec/integration/auth_spec.rb +28 -15
- data/spec/integration/awaited_ismaster_spec.rb +8 -5
- data/spec/integration/aws_auth_request_spec.rb +3 -0
- data/spec/integration/aws_credentials_retriever_spec.rb +3 -0
- data/spec/integration/bson_symbol_spec.rb +4 -1
- data/spec/integration/bulk_insert_spec.rb +3 -0
- data/spec/integration/bulk_write_error_message_spec.rb +41 -0
- data/spec/integration/bulk_write_spec.rb +51 -0
- data/spec/integration/change_stream_examples_spec.rb +3 -0
- data/spec/integration/change_stream_spec.rb +8 -5
- data/spec/integration/check_clean_slate_spec.rb +3 -0
- data/spec/integration/client_authentication_options_spec.rb +76 -36
- data/spec/integration/client_connectivity_spec.rb +4 -1
- data/spec/integration/client_construction_aws_auth_spec.rb +3 -0
- data/spec/integration/client_construction_spec.rb +3 -0
- data/spec/integration/client_side_encryption/auto_encryption_bulk_writes_spec.rb +3 -0
- data/spec/integration/client_side_encryption/auto_encryption_command_monitoring_spec.rb +3 -0
- data/spec/integration/client_side_encryption/auto_encryption_mongocryptd_spawn_spec.rb +3 -0
- data/spec/integration/client_side_encryption/auto_encryption_old_wire_version_spec.rb +3 -0
- data/spec/integration/client_side_encryption/auto_encryption_reconnect_spec.rb +3 -0
- data/spec/integration/client_side_encryption/auto_encryption_spec.rb +3 -0
- data/spec/integration/client_side_encryption/bson_size_limit_spec.rb +3 -0
- data/spec/integration/client_side_encryption/bypass_mongocryptd_spawn_spec.rb +4 -1
- data/spec/integration/client_side_encryption/client_close_spec.rb +3 -0
- data/spec/integration/client_side_encryption/corpus_spec.rb +3 -0
- data/spec/integration/client_side_encryption/custom_endpoint_spec.rb +3 -0
- data/spec/integration/client_side_encryption/data_key_spec.rb +3 -0
- data/spec/integration/client_side_encryption/explicit_encryption_spec.rb +3 -0
- data/spec/integration/client_side_encryption/external_key_vault_spec.rb +3 -0
- data/spec/integration/client_side_encryption/views_spec.rb +3 -0
- data/spec/integration/client_spec.rb +5 -2
- data/spec/integration/client_update_spec.rb +3 -0
- data/spec/integration/collection_indexes_prose_spec.rb +3 -0
- data/spec/integration/command_monitoring_spec.rb +63 -25
- data/spec/integration/command_spec.rb +3 -0
- data/spec/integration/connect_single_rs_name_spec.rb +6 -3
- data/spec/integration/connection_pool_populator_spec.rb +7 -2
- data/spec/integration/connection_spec.rb +12 -7
- data/spec/integration/crud_spec.rb +31 -0
- data/spec/integration/cursor_reaping_spec.rb +57 -18
- data/spec/integration/docs_examples_spec.rb +11 -1
- data/spec/integration/error_detection_spec.rb +3 -0
- data/spec/integration/fork_reconnect_spec.rb +64 -3
- data/spec/integration/get_more_spec.rb +3 -0
- data/spec/integration/grid_fs_bucket_spec.rb +4 -1
- data/spec/integration/heartbeat_events_spec.rb +7 -4
- data/spec/integration/mmapv1_spec.rb +3 -0
- data/spec/integration/mongos_pinning_spec.rb +3 -0
- data/spec/integration/ocsp_connectivity_spec.rb +29 -0
- data/spec/integration/ocsp_verifier_cache_spec.rb +191 -0
- data/spec/integration/ocsp_verifier_spec.rb +355 -0
- data/spec/integration/operation_failure_code_spec.rb +4 -1
- data/spec/integration/operation_failure_message_spec.rb +90 -0
- data/spec/integration/query_cache_spec.rb +1048 -0
- data/spec/integration/query_cache_transactions_spec.rb +193 -0
- data/spec/integration/read_concern_spec.rb +3 -0
- data/spec/integration/read_preference_spec.rb +3 -0
- data/spec/integration/reconnect_spec.rb +4 -1
- data/spec/integration/retryable_errors_spec.rb +3 -0
- data/spec/integration/retryable_writes/retryable_writes_36_and_older_spec.rb +3 -0
- data/spec/integration/retryable_writes/retryable_writes_40_and_newer_spec.rb +4 -0
- data/spec/integration/retryable_writes/shared/adds_diagnostics.rb +3 -0
- data/spec/integration/retryable_writes/shared/does_not_support_retries.rb +3 -0
- data/spec/integration/retryable_writes/shared/only_supports_legacy_retries.rb +3 -0
- data/spec/integration/retryable_writes/shared/performs_legacy_retries.rb +5 -0
- data/spec/integration/retryable_writes/shared/performs_modern_retries.rb +3 -0
- data/spec/integration/retryable_writes/shared/performs_no_retries.rb +3 -0
- data/spec/integration/retryable_writes/shared/supports_legacy_retries.rb +3 -0
- data/spec/integration/retryable_writes/shared/supports_modern_retries.rb +3 -0
- data/spec/integration/retryable_writes/shared/supports_retries.rb +3 -0
- data/spec/integration/retryable_writes_errors_spec.rb +3 -0
- data/spec/integration/sdam_error_handling_spec.rb +74 -3
- data/spec/integration/sdam_events_spec.rb +14 -10
- data/spec/integration/sdam_prose_spec.rb +4 -1
- data/spec/integration/secondary_reads_spec.rb +102 -0
- data/spec/integration/server_description_spec.rb +3 -0
- data/spec/integration/server_monitor_spec.rb +4 -1
- data/spec/integration/server_selection_spec.rb +39 -0
- data/spec/integration/server_selector_spec.rb +3 -0
- data/spec/integration/server_spec.rb +3 -0
- data/spec/integration/shell_examples_spec.rb +3 -0
- data/spec/integration/size_limit_spec.rb +3 -0
- data/spec/integration/snappy_compression_spec.rb +28 -0
- data/spec/integration/srv_monitoring_spec.rb +42 -4
- data/spec/integration/srv_spec.rb +59 -0
- data/spec/integration/ssl_uri_options_spec.rb +3 -0
- data/spec/integration/step_down_spec.rb +3 -0
- data/spec/integration/time_zone_querying_spec.rb +3 -0
- data/spec/integration/transactions_api_examples_spec.rb +3 -0
- data/spec/integration/transactions_examples_spec.rb +26 -7
- data/spec/integration/truncated_utf8_spec.rb +26 -0
- data/spec/integration/versioned_api_examples_spec.rb +69 -0
- data/spec/integration/x509_auth_spec.rb +4 -1
- data/spec/integration/zlib_compression_spec.rb +4 -1
- data/spec/integration/zstd_compression_spec.rb +29 -0
- data/spec/kerberos/kerberos_spec.rb +3 -0
- data/spec/lite_spec_helper.rb +18 -4
- data/spec/mongo/address/ipv4_spec.rb +3 -0
- data/spec/mongo/address/ipv6_spec.rb +3 -0
- data/spec/mongo/address/unix_spec.rb +3 -0
- data/spec/mongo/address/validator_spec.rb +3 -0
- data/spec/mongo/address_spec.rb +19 -12
- data/spec/mongo/auth/aws/request_region_spec.rb +3 -0
- data/spec/mongo/auth/aws/request_spec.rb +3 -0
- data/spec/mongo/auth/cr_spec.rb +3 -0
- data/spec/mongo/auth/gssapi/conversation_spec.rb +3 -0
- data/spec/mongo/auth/invalid_mechanism_spec.rb +3 -0
- data/spec/mongo/auth/ldap/conversation_spec.rb +4 -1
- data/spec/mongo/auth/ldap_spec.rb +8 -1
- data/spec/mongo/auth/scram/conversation_spec.rb +3 -0
- data/spec/mongo/auth/scram256/conversation_spec.rb +3 -0
- data/spec/mongo/auth/scram_negotiation_spec.rb +4 -1
- data/spec/mongo/auth/scram_spec.rb +4 -1
- data/spec/mongo/auth/stringprep/profiles/sasl_spec.rb +3 -0
- data/spec/mongo/auth/stringprep_spec.rb +3 -0
- data/spec/mongo/auth/user/view_spec.rb +3 -0
- data/spec/mongo/auth/user_spec.rb +4 -1
- data/spec/mongo/auth/x509/conversation_spec.rb +6 -3
- data/spec/mongo/auth/x509_spec.rb +3 -0
- data/spec/mongo/auth_spec.rb +3 -0
- data/spec/mongo/bson_spec.rb +3 -0
- data/spec/mongo/bulk_write/ordered_combiner_spec.rb +3 -0
- data/spec/mongo/bulk_write/result_spec.rb +3 -0
- data/spec/mongo/bulk_write/unordered_combiner_spec.rb +3 -0
- data/spec/mongo/bulk_write_spec.rb +5 -2
- data/spec/mongo/caching_cursor_spec.rb +73 -0
- data/spec/mongo/client_construction_spec.rb +268 -36
- data/spec/mongo/client_encryption_spec.rb +3 -0
- data/spec/mongo/client_spec.rb +67 -0
- data/spec/mongo/cluster/cursor_reaper_spec.rb +3 -0
- data/spec/mongo/cluster/periodic_executor_spec.rb +3 -0
- data/spec/mongo/cluster/socket_reaper_spec.rb +3 -0
- data/spec/mongo/cluster/topology/replica_set_spec.rb +13 -10
- data/spec/mongo/cluster/topology/sharded_spec.rb +6 -3
- data/spec/mongo/cluster/topology/single_spec.rb +20 -8
- data/spec/mongo/cluster/topology/unknown_spec.rb +4 -1
- data/spec/mongo/cluster/topology_spec.rb +4 -1
- data/spec/mongo/cluster_spec.rb +10 -18
- data/spec/mongo/cluster_time_spec.rb +3 -0
- data/spec/mongo/collection/view/aggregation_spec.rb +3 -0
- data/spec/mongo/collection/view/builder/find_command_spec.rb +3 -0
- data/spec/mongo/collection/view/builder/flags_spec.rb +3 -0
- data/spec/mongo/collection/view/builder/modifiers_spec.rb +3 -0
- data/spec/mongo/collection/view/builder/op_query_spec.rb +3 -0
- data/spec/mongo/collection/view/change_stream_resume_spec.rb +8 -3
- data/spec/mongo/collection/view/change_stream_spec.rb +16 -0
- data/spec/mongo/collection/view/explainable_spec.rb +90 -4
- data/spec/mongo/collection/view/immutable_spec.rb +3 -0
- data/spec/mongo/collection/view/iterable_spec.rb +3 -0
- data/spec/mongo/collection/view/map_reduce_spec.rb +5 -0
- data/spec/mongo/collection/view/readable_spec.rb +69 -0
- data/spec/mongo/collection/view/writable_spec.rb +3 -0
- data/spec/mongo/collection/view_spec.rb +3 -0
- data/spec/mongo/collection_crud_spec.rb +4360 -0
- data/spec/mongo/collection_ddl_spec.rb +537 -0
- data/spec/mongo/collection_spec.rb +8 -4787
- data/spec/mongo/crypt/auto_decryption_context_spec.rb +4 -1
- data/spec/mongo/crypt/auto_encrypter_spec.rb +3 -0
- data/spec/mongo/crypt/auto_encryption_context_spec.rb +4 -1
- data/spec/mongo/crypt/binary_spec.rb +3 -5
- data/spec/mongo/crypt/binding/binary_spec.rb +3 -5
- data/spec/mongo/crypt/binding/context_spec.rb +4 -6
- data/spec/mongo/crypt/binding/helpers_spec.rb +3 -5
- data/spec/mongo/crypt/binding/mongocrypt_spec.rb +4 -6
- data/spec/mongo/crypt/binding/status_spec.rb +3 -5
- data/spec/mongo/crypt/binding/version_spec.rb +3 -5
- data/spec/mongo/crypt/binding_unloaded_spec.rb +3 -0
- data/spec/mongo/crypt/data_key_context_spec.rb +3 -0
- data/spec/mongo/crypt/encryption_io_spec.rb +3 -0
- data/spec/mongo/crypt/explicit_decryption_context_spec.rb +4 -1
- data/spec/mongo/crypt/explicit_encryption_context_spec.rb +4 -1
- data/spec/mongo/crypt/handle_spec.rb +3 -0
- data/spec/mongo/crypt/helpers/mongo_crypt_spec_helper.rb +3 -0
- data/spec/mongo/crypt/status_spec.rb +3 -5
- data/spec/mongo/cursor/builder/get_more_command_spec.rb +7 -2
- data/spec/mongo/cursor/builder/op_get_more_spec.rb +7 -2
- data/spec/mongo/cursor/builder/op_kill_cursors_spec.rb +7 -2
- data/spec/mongo/cursor_spec.rb +74 -7
- data/spec/mongo/database_spec.rb +119 -10
- data/spec/mongo/dbref_spec.rb +3 -0
- data/spec/mongo/distinguishing_semaphore_spec.rb +3 -0
- data/spec/mongo/error/bulk_write_error_spec.rb +6 -3
- data/spec/mongo/error/crypt_error_spec.rb +3 -0
- data/spec/mongo/error/max_bson_size_spec.rb +3 -0
- data/spec/mongo/error/no_server_available_spec.rb +4 -1
- data/spec/mongo/error/notable_spec.rb +3 -0
- data/spec/mongo/error/operation_failure_heavy_spec.rb +3 -0
- data/spec/mongo/error/operation_failure_spec.rb +94 -31
- data/spec/mongo/error/parser_spec.rb +40 -6
- data/spec/mongo/error/unsupported_option_spec.rb +3 -0
- data/spec/mongo/event/publisher_spec.rb +3 -0
- data/spec/mongo/event/subscriber_spec.rb +3 -0
- data/spec/mongo/grid/file/chunk_spec.rb +7 -4
- data/spec/mongo/grid/file/info_spec.rb +3 -0
- data/spec/mongo/grid/file_spec.rb +4 -1
- data/spec/mongo/grid/fs_bucket_spec.rb +22 -5
- data/spec/mongo/grid/stream/read_spec.rb +33 -10
- data/spec/mongo/grid/stream/write_spec.rb +3 -0
- data/spec/mongo/grid/stream_spec.rb +3 -0
- data/spec/mongo/id_spec.rb +3 -0
- data/spec/mongo/index/view_spec.rb +11 -2
- data/spec/mongo/lint_spec.rb +3 -0
- data/spec/mongo/logger_spec.rb +16 -11
- data/spec/mongo/monitoring/command_log_subscriber_spec.rb +3 -0
- data/spec/mongo/monitoring/event/cmap/connection_check_out_failed_spec.rb +3 -0
- data/spec/mongo/monitoring/event/cmap/connection_check_out_started_spec.rb +3 -0
- data/spec/mongo/monitoring/event/cmap/connection_checked_in_spec.rb +3 -0
- data/spec/mongo/monitoring/event/cmap/connection_checked_out_spec.rb +3 -0
- data/spec/mongo/monitoring/event/cmap/connection_closed_spec.rb +3 -0
- data/spec/mongo/monitoring/event/cmap/connection_created_spec.rb +3 -0
- data/spec/mongo/monitoring/event/cmap/connection_ready_spec.rb +3 -0
- data/spec/mongo/monitoring/event/cmap/pool_cleared_spec.rb +3 -0
- data/spec/mongo/monitoring/event/cmap/pool_closed_spec.rb +3 -0
- data/spec/mongo/monitoring/event/cmap/pool_created_spec.rb +3 -0
- data/spec/mongo/monitoring/event/command_failed_spec.rb +59 -2
- data/spec/mongo/monitoring/event/command_started_spec.rb +3 -0
- data/spec/mongo/monitoring/event/command_succeeded_spec.rb +46 -6
- data/spec/mongo/monitoring/event/secure_spec.rb +28 -4
- data/spec/mongo/monitoring/event/server_closed_spec.rb +4 -1
- data/spec/mongo/monitoring/event/server_description_changed_spec.rb +3 -0
- data/spec/mongo/monitoring/event/server_heartbeat_failed_spec.rb +4 -1
- data/spec/mongo/monitoring/event/server_heartbeat_started_spec.rb +3 -0
- data/spec/mongo/monitoring/event/server_heartbeat_succeeded_spec.rb +4 -1
- data/spec/mongo/monitoring/event/server_opening_spec.rb +4 -1
- data/spec/mongo/monitoring/event/topology_changed_spec.rb +4 -1
- data/spec/mongo/monitoring/event/topology_closed_spec.rb +4 -1
- data/spec/mongo/monitoring/event/topology_opening_spec.rb +4 -1
- data/spec/mongo/monitoring_spec.rb +3 -0
- data/spec/mongo/operation/aggregate/result_spec.rb +7 -2
- data/spec/mongo/operation/aggregate_spec.rb +5 -1
- data/spec/mongo/operation/collections_info_spec.rb +7 -1
- data/spec/mongo/operation/command_spec.rb +11 -5
- data/spec/mongo/operation/create_index_spec.rb +9 -3
- data/spec/mongo/operation/create_user_spec.rb +9 -3
- data/spec/mongo/operation/delete/bulk_spec.rb +12 -6
- data/spec/mongo/operation/delete/command_spec.rb +3 -0
- data/spec/mongo/operation/delete/op_msg_spec.rb +6 -3
- data/spec/mongo/operation/delete_spec.rb +14 -7
- data/spec/mongo/operation/drop_index_spec.rb +9 -2
- data/spec/mongo/operation/find/legacy_spec.rb +7 -2
- data/spec/mongo/operation/get_more_spec.rb +6 -1
- data/spec/mongo/operation/indexes_spec.rb +8 -1
- data/spec/mongo/operation/insert/bulk_spec.rb +13 -7
- data/spec/mongo/operation/insert/command_spec.rb +5 -2
- data/spec/mongo/operation/insert/op_msg_spec.rb +6 -3
- data/spec/mongo/operation/insert_spec.rb +18 -12
- data/spec/mongo/operation/kill_cursors_spec.rb +3 -0
- data/spec/mongo/operation/limited_spec.rb +3 -0
- data/spec/mongo/operation/map_reduce_spec.rb +8 -2
- data/spec/mongo/operation/read_preference_legacy_spec.rb +35 -42
- data/spec/mongo/operation/read_preference_op_msg_spec.rb +7 -4
- data/spec/mongo/operation/remove_user_spec.rb +9 -3
- data/spec/mongo/operation/result_spec.rb +10 -5
- data/spec/mongo/operation/specifiable_spec.rb +3 -0
- data/spec/mongo/operation/update/bulk_spec.rb +12 -6
- data/spec/mongo/operation/update/command_spec.rb +5 -2
- data/spec/mongo/operation/update/op_msg_spec.rb +6 -3
- data/spec/mongo/operation/update_spec.rb +13 -7
- data/spec/mongo/operation/update_user_spec.rb +7 -1
- data/spec/mongo/options/redacted_spec.rb +3 -0
- data/spec/mongo/protocol/compressed_spec.rb +29 -12
- data/spec/mongo/protocol/delete_spec.rb +3 -0
- data/spec/mongo/protocol/get_more_spec.rb +3 -0
- data/spec/mongo/protocol/insert_spec.rb +3 -0
- data/spec/mongo/protocol/kill_cursors_spec.rb +3 -0
- data/spec/mongo/protocol/msg_spec.rb +4 -1
- data/spec/mongo/protocol/query_spec.rb +6 -3
- data/spec/mongo/protocol/registry_spec.rb +3 -0
- data/spec/mongo/protocol/reply_spec.rb +3 -0
- data/spec/mongo/protocol/update_spec.rb +3 -0
- data/spec/mongo/query_cache_middleware_spec.rb +55 -0
- data/spec/mongo/query_cache_spec.rb +283 -0
- data/spec/mongo/retryable_spec.rb +6 -2
- data/spec/mongo/semaphore_spec.rb +3 -0
- data/spec/mongo/server/app_metadata_spec.rb +46 -21
- data/spec/mongo/server/connection_auth_spec.rb +6 -9
- data/spec/mongo/server/connection_common_spec.rb +24 -0
- data/spec/mongo/server/connection_pool/populator_spec.rb +6 -1
- data/spec/mongo/server/connection_pool_spec.rb +11 -4
- data/spec/mongo/server/connection_spec.rb +48 -25
- data/spec/mongo/server/description/features_spec.rb +3 -0
- data/spec/mongo/server/description_query_methods_spec.rb +4 -1
- data/spec/mongo/server/description_spec.rb +625 -594
- data/spec/mongo/server/monitor/app_metadata_spec.rb +3 -1
- data/spec/mongo/server/monitor/connection_spec.rb +57 -7
- data/spec/mongo/server/monitor_spec.rb +22 -11
- data/spec/mongo/server/round_trip_time_averager_spec.rb +3 -0
- data/spec/mongo/server_selector/nearest_spec.rb +8 -2
- data/spec/mongo/server_selector/primary_preferred_spec.rb +8 -2
- data/spec/mongo/server_selector/primary_spec.rb +8 -2
- data/spec/mongo/server_selector/secondary_preferred_spec.rb +14 -8
- data/spec/mongo/server_selector/secondary_spec.rb +8 -2
- data/spec/mongo/server_selector_spec.rb +7 -3
- data/spec/mongo/server_spec.rb +18 -2
- data/spec/mongo/session/server_session_spec.rb +3 -0
- data/spec/mongo/session/session_pool_spec.rb +3 -0
- data/spec/mongo/session_spec.rb +3 -0
- data/spec/mongo/session_transaction_spec.rb +7 -12
- data/spec/mongo/socket/ssl_spec.rb +47 -4
- data/spec/mongo/socket/tcp_spec.rb +3 -0
- data/spec/mongo/socket/unix_spec.rb +3 -0
- data/spec/mongo/socket_spec.rb +5 -2
- data/spec/mongo/srv/monitor_spec.rb +3 -0
- data/spec/mongo/srv/result_spec.rb +3 -0
- data/spec/mongo/timeout_spec.rb +3 -0
- data/spec/mongo/tls_context_hooks_spec.rb +40 -0
- data/spec/mongo/uri/srv_protocol_spec.rb +68 -33
- data/spec/mongo/uri_option_parsing_spec.rb +14 -11
- data/spec/mongo/uri_spec.rb +71 -41
- data/spec/mongo/utils_spec.rb +56 -0
- data/spec/mongo/write_concern/acknowledged_spec.rb +3 -0
- data/spec/mongo/write_concern/unacknowledged_spec.rb +3 -0
- data/spec/mongo/write_concern_spec.rb +3 -0
- data/spec/runners/auth.rb +25 -1
- data/spec/runners/change_streams/outcome.rb +3 -0
- data/spec/runners/change_streams/spec.rb +3 -0
- data/spec/runners/change_streams/test.rb +4 -1
- data/spec/runners/cmap.rb +3 -0
- data/spec/runners/cmap/verifier.rb +3 -0
- data/spec/runners/command_monitoring.rb +3 -0
- data/spec/runners/connection_string.rb +34 -124
- data/spec/runners/crud.rb +22 -0
- data/spec/runners/crud/context.rb +3 -0
- data/spec/runners/crud/operation.rb +3 -0
- data/spec/runners/crud/outcome.rb +3 -0
- data/spec/runners/crud/requirement.rb +67 -3
- data/spec/runners/crud/spec.rb +3 -0
- data/spec/runners/crud/test.rb +3 -0
- data/spec/runners/crud/test_base.rb +3 -19
- data/spec/runners/crud/verifier.rb +11 -0
- data/spec/runners/gridfs.rb +3 -0
- data/spec/runners/read_write_concern_document.rb +3 -0
- data/spec/runners/sdam.rb +6 -3
- data/spec/runners/sdam/verifier.rb +3 -0
- data/spec/runners/server_selection.rb +4 -1
- data/spec/runners/server_selection_rtt.rb +4 -1
- data/spec/runners/transactions.rb +3 -0
- data/spec/runners/transactions/operation.rb +16 -2
- data/spec/runners/transactions/spec.rb +3 -0
- data/spec/runners/transactions/test.rb +6 -2
- data/spec/runners/unified.rb +99 -0
- data/spec/runners/unified/assertions.rb +282 -0
- data/spec/runners/unified/change_stream_operations.rb +29 -0
- data/spec/runners/unified/crud_operations.rb +206 -0
- data/spec/runners/unified/ddl_operations.rb +106 -0
- data/spec/runners/unified/entity_map.rb +42 -0
- data/spec/runners/unified/error.rb +28 -0
- data/spec/runners/unified/event_subscriber.rb +104 -0
- data/spec/runners/unified/exceptions.rb +24 -0
- data/spec/runners/unified/grid_fs_operations.rb +58 -0
- data/spec/runners/unified/support_operations.rb +253 -0
- data/spec/runners/unified/test.rb +423 -0
- data/spec/runners/unified/test_group.rb +31 -0
- data/spec/runners/unified/using_hash.rb +34 -0
- data/spec/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/cluster_config.rb +226 -0
- data/spec/shared/lib/mrss/constraints.rb +82 -6
- data/spec/shared/lib/mrss/docker_runner.rb +271 -0
- data/spec/shared/lib/mrss/lite_constraints.rb +16 -0
- data/spec/shared/lib/mrss/server_version_registry.rb +115 -0
- data/spec/shared/lib/mrss/spec_organizer.rb +32 -2
- data/spec/shared/lib/mrss/utils.rb +15 -0
- data/spec/shared/share/Dockerfile.erb +322 -0
- data/spec/shared/share/haproxy-1.conf +16 -0
- data/spec/shared/share/haproxy-2.conf +17 -0
- data/spec/shared/shlib/distro.sh +73 -0
- data/spec/shared/shlib/server.sh +317 -0
- data/spec/shared/shlib/set_env.sh +131 -0
- data/spec/solo/clean_exit_spec.rb +24 -0
- data/spec/spec_helper.rb +11 -4
- data/spec/spec_tests/auth_spec.rb +30 -13
- data/spec/spec_tests/change_streams_spec.rb +3 -0
- data/spec/spec_tests/change_streams_unified_spec.rb +13 -0
- data/spec/spec_tests/client_side_encryption_spec.rb +3 -0
- data/spec/spec_tests/cmap_spec.rb +10 -3
- data/spec/spec_tests/collection_management_spec.rb +13 -0
- data/spec/spec_tests/command_monitoring_spec.rb +31 -26
- data/spec/spec_tests/command_monitoring_unified_spec.rb +13 -0
- data/spec/spec_tests/connection_string_spec.rb +3 -0
- data/spec/spec_tests/crud_spec.rb +3 -0
- data/spec/spec_tests/crud_unified_spec.rb +13 -0
- data/spec/spec_tests/data/change_streams/change-streams-errors.yml +5 -6
- data/spec/spec_tests/data/change_streams/{change-streams-resume-whitelist.yml → change-streams-resume-allowlist.yml} +58 -58
- data/spec/spec_tests/data/change_streams/change-streams-resume-errorLabels.yml +46 -46
- data/spec/spec_tests/data/change_streams/change-streams.yml +0 -2
- data/spec/spec_tests/data/change_streams_unified/change-streams.yml +72 -0
- data/spec/spec_tests/data/cmap/pool-checkout-connection.yml +6 -2
- data/spec/spec_tests/data/cmap/pool-create-min-size.yml +3 -0
- data/spec/spec_tests/data/collection_management/timeseries-collection.yml +129 -0
- data/spec/spec_tests/data/command_monitoring_unified/redacted-commands.yml +340 -0
- data/spec/spec_tests/data/connection_string/valid-warnings.yml +24 -0
- data/spec/spec_tests/data/crud/write/bulkWrite.yml +26 -22
- data/spec/spec_tests/data/crud/write/insertMany.yml +26 -22
- data/spec/spec_tests/data/crud_unified/estimatedDocumentCount.yml +267 -0
- data/spec/spec_tests/data/crud_unified/updateWithPipelines.yml +305 -0
- data/spec/spec_tests/data/crud_v2/aggregate-out-readConcern.yml +1 -0
- data/spec/spec_tests/data/crud_v2/db-aggregate.yml +1 -0
- data/spec/spec_tests/data/retryable_reads/aggregate-serverErrors.yml +1 -1
- data/spec/spec_tests/data/retryable_reads/changeStreams-client.watch-serverErrors.yml +6 -5
- data/spec/spec_tests/data/retryable_reads/changeStreams-client.watch.yml +1 -0
- data/spec/spec_tests/data/retryable_reads/changeStreams-db.coll.watch-serverErrors.yml +6 -5
- data/spec/spec_tests/data/retryable_reads/changeStreams-db.coll.watch.yml +1 -0
- data/spec/spec_tests/data/retryable_reads/changeStreams-db.watch-serverErrors.yml +6 -5
- data/spec/spec_tests/data/retryable_reads/changeStreams-db.watch.yml +1 -0
- data/spec/spec_tests/data/retryable_reads/count-serverErrors.yml +1 -1
- data/spec/spec_tests/data/retryable_reads/countDocuments-serverErrors.yml +1 -1
- data/spec/spec_tests/data/retryable_reads/distinct-serverErrors.yml +1 -1
- data/spec/spec_tests/data/retryable_reads/estimatedDocumentCount-4.9.yml +60 -0
- data/spec/spec_tests/data/retryable_reads/{estimatedDocumentCount.yml → estimatedDocumentCount-pre4.9.yml} +2 -0
- data/spec/spec_tests/data/retryable_reads/estimatedDocumentCount-serverErrors-4.9.yml +146 -0
- data/spec/spec_tests/data/retryable_reads/{estimatedDocumentCount-serverErrors.yml → estimatedDocumentCount-serverErrors-pre4.9.yml} +3 -1
- data/spec/spec_tests/data/retryable_reads/find-serverErrors.yml +1 -1
- data/spec/spec_tests/data/retryable_reads/findOne-serverErrors.yml +1 -1
- data/spec/spec_tests/data/retryable_reads/gridfs-download-serverErrors.yml +1 -1
- data/spec/spec_tests/data/retryable_reads/gridfs-downloadByName-serverErrors.yml +1 -1
- data/spec/spec_tests/data/retryable_reads/listCollectionNames-serverErrors.yml +1 -1
- data/spec/spec_tests/data/retryable_reads/listCollectionObjects-serverErrors.yml +1 -1
- data/spec/spec_tests/data/retryable_reads/listCollections-serverErrors.yml +1 -1
- data/spec/spec_tests/data/retryable_reads/listDatabaseNames-serverErrors.yml +1 -1
- data/spec/spec_tests/data/retryable_reads/listDatabaseObjects-serverErrors.yml +1 -1
- data/spec/spec_tests/data/retryable_reads/listDatabases-serverErrors.yml +1 -1
- data/spec/spec_tests/data/retryable_reads/listIndexNames-serverErrors.yml +1 -1
- data/spec/spec_tests/data/retryable_reads/listIndexNames.yml +1 -1
- data/spec/spec_tests/data/retryable_reads/listIndexes-serverErrors.yml +1 -1
- data/spec/spec_tests/data/retryable_writes/bulkWrite.yml +30 -24
- data/spec/spec_tests/data/retryable_writes/insertOne-serverErrors.yml +5 -4
- data/spec/spec_tests/data/sdam/errors/error_handling_handshake.yml +2 -1
- data/spec/spec_tests/data/sdam/errors/non-stale-network-error.yml +2 -1
- data/spec/spec_tests/data/sdam/errors/non-stale-network-timeout-error.yml +2 -1
- data/spec/spec_tests/data/sdam/errors/non-stale-topologyVersion-greater-InterruptedAtShutdown.yml +2 -1
- data/spec/spec_tests/data/sdam/errors/non-stale-topologyVersion-greater-InterruptedDueToReplStateChange.yml +2 -1
- 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-NotMasterNoSlaveOk.yml → non-stale-topologyVersion-greater-NotPrimaryNoSecondaryOk.yml} +5 -4
- data/spec/spec_tests/data/sdam/errors/{non-stale-topologyVersion-greater-NotMasterOrSecondary.yml → non-stale-topologyVersion-greater-NotPrimaryOrSecondary.yml} +5 -4
- data/spec/spec_tests/data/sdam/errors/{non-stale-topologyVersion-greater-NotMaster.yml → non-stale-topologyVersion-greater-NotWritablePrimary.yml} +5 -4
- data/spec/spec_tests/data/sdam/errors/non-stale-topologyVersion-greater-PrimarySteppedDown.yml +2 -1
- data/spec/spec_tests/data/sdam/errors/non-stale-topologyVersion-greater-ShutdownInProgress.yml +2 -1
- data/spec/spec_tests/data/sdam/errors/non-stale-topologyVersion-missing-InterruptedAtShutdown.yml +2 -1
- data/spec/spec_tests/data/sdam/errors/non-stale-topologyVersion-missing-InterruptedDueToReplStateChange.yml +2 -1
- 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-NotMasterNoSlaveOk.yml → non-stale-topologyVersion-missing-NotPrimaryNoSecondaryOk.yml} +5 -4
- data/spec/spec_tests/data/sdam/errors/{non-stale-topologyVersion-missing-NotMasterOrSecondary.yml → non-stale-topologyVersion-missing-NotPrimaryOrSecondary.yml} +5 -4
- data/spec/spec_tests/data/sdam/errors/{non-stale-topologyVersion-missing-NotMaster.yml → non-stale-topologyVersion-missing-NotWritablePrimary.yml} +5 -4
- data/spec/spec_tests/data/sdam/errors/non-stale-topologyVersion-missing-PrimarySteppedDown.yml +2 -1
- data/spec/spec_tests/data/sdam/errors/non-stale-topologyVersion-missing-ShutdownInProgress.yml +2 -1
- data/spec/spec_tests/data/sdam/errors/non-stale-topologyVersion-proccessId-changed-InterruptedAtShutdown.yml +2 -1
- data/spec/spec_tests/data/sdam/errors/non-stale-topologyVersion-proccessId-changed-InterruptedDueToReplStateChange.yml +2 -1
- 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-NotMasterNoSlaveOk.yml → non-stale-topologyVersion-proccessId-changed-NotPrimaryNoSecondaryOk.yml} +5 -4
- data/spec/spec_tests/data/sdam/errors/{non-stale-topologyVersion-proccessId-changed-NotMasterOrSecondary.yml → non-stale-topologyVersion-proccessId-changed-NotPrimaryOrSecondary.yml} +5 -4
- data/spec/spec_tests/data/sdam/errors/{non-stale-topologyVersion-proccessId-changed-NotMaster.yml → non-stale-topologyVersion-proccessId-changed-NotWritablePrimary.yml} +5 -4
- data/spec/spec_tests/data/sdam/errors/non-stale-topologyVersion-proccessId-changed-PrimarySteppedDown.yml +2 -1
- data/spec/spec_tests/data/sdam/errors/non-stale-topologyVersion-proccessId-changed-ShutdownInProgress.yml +2 -1
- data/spec/spec_tests/data/sdam/errors/post-42-InterruptedAtShutdown.yml +2 -1
- data/spec/spec_tests/data/sdam/errors/post-42-InterruptedDueToReplStateChange.yml +2 -1
- data/spec/spec_tests/data/sdam/errors/post-42-LegacyNotPrimary.yml +47 -0
- data/spec/spec_tests/data/sdam/errors/{post-42-NotMasterNoSlaveOk.yml → post-42-NotPrimaryNoSecondaryOk.yml} +5 -4
- data/spec/spec_tests/data/sdam/errors/{post-42-NotMasterOrSecondary.yml → post-42-NotPrimaryOrSecondary.yml} +5 -4
- data/spec/spec_tests/data/sdam/errors/{post-42-NotMaster.yml → post-42-NotWritablePrimary.yml} +5 -4
- data/spec/spec_tests/data/sdam/errors/post-42-PrimarySteppedDown.yml +2 -1
- data/spec/spec_tests/data/sdam/errors/post-42-ShutdownInProgress.yml +2 -1
- data/spec/spec_tests/data/sdam/errors/pre-42-InterruptedAtShutdown.yml +2 -1
- data/spec/spec_tests/data/sdam/errors/pre-42-InterruptedDueToReplStateChange.yml +2 -1
- data/spec/spec_tests/data/sdam/errors/{pre-42-NotMaster.yml → pre-42-LegacyNotPrimary.yml} +6 -5
- data/spec/spec_tests/data/sdam/errors/pre-42-NotPrimaryNoSecondaryOk.yml +47 -0
- data/spec/spec_tests/data/sdam/errors/{pre-42-NotMasterOrSecondary.yml → pre-42-NotPrimaryOrSecondary.yml} +5 -4
- data/spec/spec_tests/data/sdam/errors/{pre-42-NotMasterNoSlaveOk.yml → pre-42-NotWritablePrimary.yml} +6 -5
- data/spec/spec_tests/data/sdam/errors/pre-42-PrimarySteppedDown.yml +2 -1
- data/spec/spec_tests/data/sdam/errors/pre-42-ShutdownInProgress.yml +2 -1
- data/spec/spec_tests/data/sdam/errors/prefer-error-code.yml +54 -0
- data/spec/spec_tests/data/sdam/errors/stale-generation-InterruptedAtShutdown.yml +4 -2
- data/spec/spec_tests/data/sdam/errors/stale-generation-InterruptedDueToReplStateChange.yml +4 -2
- data/spec/spec_tests/data/sdam/errors/{stale-generation-NotMasterNoSlaveOk.yml → stale-generation-NotPrimaryNoSecondaryOk.yml} +7 -5
- data/spec/spec_tests/data/sdam/errors/{stale-generation-NotMasterOrSecondary.yml → stale-generation-NotPrimaryOrSecondary.yml} +7 -5
- data/spec/spec_tests/data/sdam/errors/{stale-generation-NotMaster.yml → stale-generation-NotWritablePrimary.yml} +7 -5
- data/spec/spec_tests/data/sdam/errors/stale-generation-PrimarySteppedDown.yml +4 -2
- data/spec/spec_tests/data/sdam/errors/stale-generation-ShutdownInProgress.yml +4 -2
- data/spec/spec_tests/data/sdam/errors/stale-generation-afterHandshakeCompletes-InterruptedAtShutdown.yml +4 -2
- data/spec/spec_tests/data/sdam/errors/stale-generation-afterHandshakeCompletes-InterruptedDueToReplStateChange.yml +4 -2
- data/spec/spec_tests/data/sdam/errors/{stale-generation-afterHandshakeCompletes-NotMaster.yml → stale-generation-afterHandshakeCompletes-LegacyNotPrimary.yml} +8 -6
- data/spec/spec_tests/data/sdam/errors/stale-generation-afterHandshakeCompletes-NotPrimaryNoSecondaryOk.yml +91 -0
- data/spec/spec_tests/data/sdam/errors/{stale-generation-afterHandshakeCompletes-NotMasterOrSecondary.yml → stale-generation-afterHandshakeCompletes-NotPrimaryOrSecondary.yml} +7 -5
- data/spec/spec_tests/data/sdam/errors/{stale-generation-afterHandshakeCompletes-NotMasterNoSlaveOk.yml → stale-generation-afterHandshakeCompletes-NotWritablePrimary.yml} +8 -6
- data/spec/spec_tests/data/sdam/errors/stale-generation-afterHandshakeCompletes-PrimarySteppedDown.yml +4 -2
- data/spec/spec_tests/data/sdam/errors/stale-generation-afterHandshakeCompletes-ShutdownInProgress.yml +4 -2
- data/spec/spec_tests/data/sdam/errors/stale-generation-afterHandshakeCompletes-network.yml +6 -4
- data/spec/spec_tests/data/sdam/errors/stale-generation-afterHandshakeCompletes-timeout.yml +6 -4
- data/spec/spec_tests/data/sdam/errors/stale-generation-beforeHandshakeCompletes-InterruptedAtShutdown.yml +4 -2
- data/spec/spec_tests/data/sdam/errors/stale-generation-beforeHandshakeCompletes-InterruptedDueToReplStateChange.yml +4 -2
- data/spec/spec_tests/data/sdam/errors/{stale-generation-beforeHandshakeCompletes-NotMaster.yml → stale-generation-beforeHandshakeCompletes-LegacyNotPrimary.yml} +8 -6
- data/spec/spec_tests/data/sdam/errors/stale-generation-beforeHandshakeCompletes-NotPrimaryNoSecondaryOk.yml +91 -0
- data/spec/spec_tests/data/sdam/errors/{stale-generation-beforeHandshakeCompletes-NotMasterOrSecondary.yml → stale-generation-beforeHandshakeCompletes-NotPrimaryOrSecondary.yml} +7 -5
- data/spec/spec_tests/data/sdam/errors/{stale-generation-beforeHandshakeCompletes-NotMasterNoSlaveOk.yml → stale-generation-beforeHandshakeCompletes-NotWritablePrimary.yml} +8 -6
- data/spec/spec_tests/data/sdam/errors/stale-generation-beforeHandshakeCompletes-PrimarySteppedDown.yml +4 -2
- data/spec/spec_tests/data/sdam/errors/stale-generation-beforeHandshakeCompletes-ShutdownInProgress.yml +4 -2
- data/spec/spec_tests/data/sdam/errors/stale-generation-beforeHandshakeCompletes-network.yml +6 -4
- data/spec/spec_tests/data/sdam/errors/stale-generation-beforeHandshakeCompletes-timeout.yml +6 -4
- data/spec/spec_tests/data/sdam/errors/stale-topologyVersion-InterruptedAtShutdown.yml +2 -1
- data/spec/spec_tests/data/sdam/errors/stale-topologyVersion-InterruptedDueToReplStateChange.yml +2 -1
- data/spec/spec_tests/data/sdam/errors/stale-topologyVersion-LegacyNotPrimary.yml +65 -0
- data/spec/spec_tests/data/sdam/errors/{stale-topologyVersion-NotMasterNoSlaveOk.yml → stale-topologyVersion-NotPrimaryNoSecondaryOk.yml} +7 -6
- data/spec/spec_tests/data/sdam/errors/{stale-topologyVersion-NotMasterOrSecondary.yml → stale-topologyVersion-NotPrimaryOrSecondary.yml} +7 -6
- data/spec/spec_tests/data/sdam/errors/{stale-topologyVersion-NotMaster.yml → stale-topologyVersion-NotWritablePrimary.yml} +7 -6
- data/spec/spec_tests/data/sdam/errors/stale-topologyVersion-PrimarySteppedDown.yml +2 -1
- data/spec/spec_tests/data/sdam/errors/stale-topologyVersion-ShutdownInProgress.yml +2 -1
- data/spec/spec_tests/data/sdam/errors/write_errors_ignored.yml +42 -0
- data/spec/spec_tests/data/sdam/rs/compatible.yml +4 -2
- data/spec/spec_tests/data/sdam/rs/compatible_unknown.yml +2 -1
- data/spec/spec_tests/data/sdam/rs/discover_arbiters.yml +2 -1
- data/spec/spec_tests/data/sdam/rs/discover_arbiters_replicaset.yml +2 -1
- data/spec/spec_tests/data/sdam/rs/discover_ghost.yml +2 -1
- data/spec/spec_tests/data/sdam/rs/discover_ghost_replicaset.yml +2 -1
- data/spec/spec_tests/data/sdam/rs/discover_hidden.yml +2 -1
- data/spec/spec_tests/data/sdam/rs/discover_hidden_replicaset.yml +2 -1
- data/spec/spec_tests/data/sdam/rs/discover_passives.yml +4 -2
- data/spec/spec_tests/data/sdam/rs/discover_passives_replicaset.yml +4 -2
- data/spec/spec_tests/data/sdam/rs/discover_primary.yml +2 -1
- data/spec/spec_tests/data/sdam/rs/discover_primary_replicaset.yml +2 -1
- data/spec/spec_tests/data/sdam/rs/discover_rsother.yml +2 -1
- data/spec/spec_tests/data/sdam/rs/discover_rsother_replicaset.yml +4 -2
- data/spec/spec_tests/data/sdam/rs/discover_secondary.yml +2 -1
- data/spec/spec_tests/data/sdam/rs/discover_secondary_replicaset.yml +2 -1
- data/spec/spec_tests/data/sdam/rs/discovery.yml +8 -4
- data/spec/spec_tests/data/sdam/rs/equal_electionids.yml +4 -2
- data/spec/spec_tests/data/sdam/rs/hosts_differ_from_seeds.yml +2 -1
- data/spec/spec_tests/data/sdam/rs/incompatible_arbiter.yml +3 -1
- data/spec/spec_tests/data/sdam/rs/incompatible_ghost.yml +3 -1
- data/spec/spec_tests/data/sdam/rs/incompatible_other.yml +3 -1
- data/spec/spec_tests/data/sdam/rs/ls_timeout.yml +12 -6
- data/spec/spec_tests/data/sdam/rs/member_reconfig.yml +4 -2
- data/spec/spec_tests/data/sdam/rs/member_standalone.yml +4 -2
- data/spec/spec_tests/data/sdam/rs/new_primary.yml +4 -2
- data/spec/spec_tests/data/sdam/rs/new_primary_new_electionid.yml +6 -3
- data/spec/spec_tests/data/sdam/rs/new_primary_new_setversion.yml +6 -3
- data/spec/spec_tests/data/sdam/rs/new_primary_wrong_set_name.yml +4 -2
- data/spec/spec_tests/data/sdam/rs/non_rs_member.yml +1 -0
- data/spec/spec_tests/data/sdam/rs/normalize_case.yml +2 -1
- data/spec/spec_tests/data/sdam/rs/normalize_case_me.yml +4 -2
- data/spec/spec_tests/data/sdam/rs/null_election_id.yml +8 -4
- data/spec/spec_tests/data/sdam/rs/primary_becomes_ghost.yml +4 -2
- data/spec/spec_tests/data/sdam/rs/primary_becomes_mongos.yml +4 -2
- data/spec/spec_tests/data/sdam/rs/primary_becomes_standalone.yml +2 -1
- data/spec/spec_tests/data/sdam/rs/primary_changes_set_name.yml +4 -2
- data/spec/spec_tests/data/sdam/rs/primary_disconnect.yml +2 -1
- data/spec/spec_tests/data/sdam/rs/primary_disconnect_electionid.yml +10 -5
- data/spec/spec_tests/data/sdam/rs/primary_disconnect_setversion.yml +10 -5
- data/spec/spec_tests/data/sdam/rs/primary_hint_from_secondary_with_mismatched_me.yml +4 -2
- data/spec/spec_tests/data/sdam/rs/primary_mismatched_me.yml +2 -1
- data/spec/spec_tests/data/sdam/rs/primary_mismatched_me_not_removed.yml +5 -3
- data/spec/spec_tests/data/sdam/rs/primary_reports_new_member.yml +8 -4
- data/spec/spec_tests/data/sdam/rs/primary_to_no_primary_mismatched_me.yml +4 -2
- data/spec/spec_tests/data/sdam/rs/primary_wrong_set_name.yml +2 -1
- data/spec/spec_tests/data/sdam/rs/repeated.yml +9 -5
- data/spec/spec_tests/data/sdam/rs/replicaset_rsnp.yml +2 -1
- data/spec/spec_tests/data/sdam/rs/response_from_removed.yml +4 -2
- data/spec/spec_tests/data/sdam/rs/sec_not_auth.yml +4 -2
- data/spec/spec_tests/data/sdam/rs/secondary_ignore_ok_0.yml +4 -2
- data/spec/spec_tests/data/sdam/rs/secondary_mismatched_me.yml +2 -1
- data/spec/spec_tests/data/sdam/rs/secondary_wrong_set_name.yml +2 -1
- data/spec/spec_tests/data/sdam/rs/secondary_wrong_set_name_with_primary.yml +4 -2
- data/spec/spec_tests/data/sdam/rs/setversion_without_electionid.yml +4 -2
- data/spec/spec_tests/data/sdam/rs/stepdown_change_set_name.yml +4 -2
- data/spec/spec_tests/data/sdam/rs/too_new.yml +4 -2
- data/spec/spec_tests/data/sdam/rs/too_old.yml +4 -2
- data/spec/spec_tests/data/sdam/rs/topology_version_equal.yml +4 -2
- data/spec/spec_tests/data/sdam/rs/topology_version_greater.yml +10 -5
- data/spec/spec_tests/data/sdam/rs/topology_version_less.yml +4 -2
- data/spec/spec_tests/data/sdam/rs/unexpected_mongos.yml +2 -1
- data/spec/spec_tests/data/sdam/rs/use_setversion_without_electionid.yml +6 -3
- data/spec/spec_tests/data/sdam/rs/wrong_set_name.yml +2 -1
- data/spec/spec_tests/data/sdam/sharded/compatible.yml +4 -2
- data/spec/spec_tests/data/sdam/sharded/discover_single_mongos.yml +2 -1
- data/spec/spec_tests/data/sdam/sharded/ls_timeout_mongos.yml +9 -5
- data/spec/spec_tests/data/sdam/sharded/mongos_disconnect.yml +6 -3
- data/spec/spec_tests/data/sdam/sharded/multiple_mongoses.yml +4 -2
- data/spec/spec_tests/data/sdam/sharded/non_mongos_removed.yml +4 -2
- data/spec/spec_tests/data/sdam/sharded/too_new.yml +4 -2
- data/spec/spec_tests/data/sdam/sharded/too_old.yml +4 -2
- data/spec/spec_tests/data/sdam/single/compatible.yml +2 -1
- data/spec/spec_tests/data/sdam/single/direct_connection_external_ip.yml +2 -1
- data/spec/spec_tests/data/sdam/single/direct_connection_mongos.yml +2 -1
- data/spec/spec_tests/data/sdam/single/direct_connection_replicaset.yml +2 -1
- data/spec/spec_tests/data/sdam/single/direct_connection_rsarbiter.yml +2 -1
- data/spec/spec_tests/data/sdam/single/direct_connection_rsprimary.yml +2 -1
- data/spec/spec_tests/data/sdam/single/direct_connection_rssecondary.yml +2 -1
- data/spec/spec_tests/data/sdam/single/direct_connection_standalone.yml +2 -1
- data/spec/spec_tests/data/sdam/single/direct_connection_wrong_set_name.yml +4 -2
- data/spec/spec_tests/data/sdam/single/discover_standalone.yml +2 -1
- data/spec/spec_tests/data/sdam/single/ls_timeout_standalone.yml +2 -1
- data/spec/spec_tests/data/sdam/single/not_ok_response.yml +5 -3
- data/spec/spec_tests/data/sdam/single/standalone_removed.yml +2 -1
- data/spec/spec_tests/data/sdam/single/{direct_connection_slave.yml → standalone_using_legacy_hello.yml} +3 -3
- data/spec/spec_tests/data/sdam/single/too_new.yml +2 -1
- data/spec/spec_tests/data/sdam/single/too_old.yml +2 -1
- data/spec/spec_tests/data/sdam/single/too_old_then_upgraded.yml +4 -2
- data/spec/spec_tests/data/sdam_integration/cancel-server-check.yml +1 -1
- data/spec/spec_tests/data/sdam_integration/connectTimeoutMS.yml +2 -2
- data/spec/spec_tests/data/sdam_integration/{isMaster-command-error.yml → hello-command-error.yml} +19 -29
- data/spec/spec_tests/data/sdam_integration/{isMaster-network-error.yml → hello-network-error.yml} +9 -15
- data/spec/spec_tests/data/sdam_integration/{isMaster-timeout.yml → hello-timeout.yml} +7 -13
- data/spec/spec_tests/data/sdam_integration/rediscover-quickly-after-step-down.yml +14 -3
- data/spec/spec_tests/data/sdam_monitoring/discovered_standalone.yml +2 -4
- data/spec/spec_tests/data/sdam_monitoring/replica_set_with_no_primary.yml +2 -1
- data/spec/spec_tests/data/sdam_monitoring/replica_set_with_primary.yml +2 -1
- data/spec/spec_tests/data/sdam_monitoring/replica_set_with_removal.yml +3 -2
- data/spec/spec_tests/data/sdam_monitoring/required_replica_set.yml +2 -1
- data/spec/spec_tests/data/sdam_monitoring/standalone.yml +3 -3
- data/spec/spec_tests/data/sdam_monitoring/standalone_repeated.yml +2 -2
- data/spec/spec_tests/data/sdam_monitoring/standalone_suppress_equal_description_changes.yml +4 -4
- data/spec/spec_tests/data/sdam_monitoring/standalone_to_rs_with_me_mismatch.yml +2 -2
- data/spec/spec_tests/data/transactions/error-labels.yml +3 -0
- data/spec/spec_tests/data/transactions/mongos-pin-auto.yml +3 -0
- data/spec/spec_tests/data/transactions/mongos-recovery-token.yml +2 -0
- data/spec/spec_tests/data/transactions/pin-mongos.yml +6 -3
- 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 +25 -0
- data/spec/spec_tests/data/uri_options/compression-options.yml +7 -4
- data/spec/spec_tests/data/uri_options/read-preference-options.yml +24 -0
- data/spec/spec_tests/data/uri_options/ruby-connection-options.yml +1 -0
- data/spec/spec_tests/data/uri_options/tls-options.yml +160 -4
- data/spec/spec_tests/data/versioned_api/crud-api-version-1-strict.yml +417 -0
- data/spec/spec_tests/data/versioned_api/crud-api-version-1.yml +411 -0
- data/spec/spec_tests/data/versioned_api/runcommand-helper-no-api-version-declared.yml +75 -0
- data/spec/spec_tests/data/versioned_api/test-commands-deprecation-errors.yml +47 -0
- data/spec/spec_tests/data/versioned_api/test-commands-strict-mode.yml +46 -0
- data/spec/spec_tests/data/versioned_api/transaction-handling.yml +128 -0
- data/spec/spec_tests/dns_seedlist_discovery_spec.rb +12 -1
- data/spec/spec_tests/gridfs_spec.rb +3 -0
- data/spec/spec_tests/max_staleness_spec.rb +3 -0
- data/spec/spec_tests/read_write_concern_connection_string_spec.rb +3 -0
- data/spec/spec_tests/read_write_concern_document_spec.rb +3 -0
- data/spec/spec_tests/read_write_concern_operaton_spec.rb +3 -0
- data/spec/spec_tests/retryable_reads_spec.rb +3 -0
- data/spec/spec_tests/retryable_writes_spec.rb +9 -6
- data/spec/spec_tests/sdam_integration_spec.rb +3 -0
- data/spec/spec_tests/sdam_monitoring_spec.rb +4 -1
- data/spec/spec_tests/sdam_spec.rb +4 -1
- data/spec/spec_tests/server_selection_rtt_spec.rb +3 -0
- data/spec/spec_tests/server_selection_spec.rb +3 -0
- data/spec/spec_tests/transactions_api_spec.rb +3 -0
- data/spec/spec_tests/transactions_spec.rb +3 -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 +50 -33
- data/spec/spec_tests/versioned_api_spec.rb +13 -0
- data/spec/stress/cleanup_spec.rb +3 -0
- data/spec/stress/connection_pool_stress_spec.rb +3 -0
- data/spec/stress/connection_pool_timing_spec.rb +3 -0
- data/spec/stress/fork_reconnect_stress_spec.rb +7 -4
- data/spec/support/authorization.rb +3 -0
- data/spec/support/aws_utils.rb +3 -0
- data/spec/support/aws_utils/base.rb +3 -0
- data/spec/support/aws_utils/inspector.rb +3 -0
- data/spec/support/aws_utils/orchestrator.rb +3 -0
- data/spec/support/aws_utils/provisioner.rb +3 -0
- data/spec/support/background_thread_registry.rb +4 -1
- data/spec/support/certificates/README.md +3 -2
- data/spec/support/certificates/atlas-ocsp-ca.crt +118 -0
- data/spec/support/certificates/atlas-ocsp.crt +152 -0
- data/spec/support/client_registry.rb +12 -5
- data/spec/support/client_registry_macros.rb +17 -5
- data/spec/support/cluster_tools.rb +4 -1
- data/spec/support/common_shortcuts.rb +84 -6
- data/spec/support/constraints.rb +9 -253
- data/spec/support/crypt.rb +3 -0
- data/spec/support/dns.rb +3 -0
- data/spec/support/event_subscriber.rb +9 -0
- data/spec/support/json_ext_formatter.rb +3 -0
- data/spec/support/keyword_struct.rb +3 -0
- data/spec/support/local_resource_registry.rb +3 -0
- data/spec/support/matchers.rb +20 -1
- data/spec/support/monitoring_ext.rb +3 -0
- data/spec/support/ocsp +1 -0
- data/spec/support/primary_socket.rb +3 -0
- data/spec/support/sdam_formatter_integration.rb +3 -0
- data/spec/support/session_registry.rb +55 -0
- data/spec/{mongo/server/app_metadata_shared.rb → support/shared/app_metadata.rb} +39 -8
- data/spec/support/shared/protocol.rb +3 -0
- data/spec/support/shared/scram_conversation.rb +3 -0
- data/spec/support/shared/server_selector.rb +6 -3
- data/spec/support/shared/session.rb +5 -2
- data/spec/support/spec_config.rb +111 -12
- data/spec/support/spec_setup.rb +51 -38
- data/spec/support/utils.rb +106 -5
- metadata +1177 -982
- metadata.gz.sig +3 -2
- data/lib/mongo/operation/shared/collections_info_or_list_collections.rb +0 -56
- data/lib/mongo/operation/shared/op_msg_or_list_indexes_command.rb +0 -47
- data/spec/support/child_process_helper.rb +0 -78
- data/spec/support/cluster_config.rb +0 -207
- data/spec/support/lite_constraints.rb +0 -141
- data/spec/support/spec_organizer.rb +0 -129
|
@@ -0,0 +1,1048 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
# encoding: utf-8
|
|
3
|
+
|
|
4
|
+
require 'spec_helper'
|
|
5
|
+
|
|
6
|
+
describe 'QueryCache' do
|
|
7
|
+
around do |spec|
|
|
8
|
+
Mongo::QueryCache.clear
|
|
9
|
+
Mongo::QueryCache.cache { spec.run }
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
before do
|
|
13
|
+
authorized_collection.delete_many
|
|
14
|
+
subscriber.clear_events!
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
before(:all) do
|
|
18
|
+
# It is likely that there are other session leaks in the driver that are
|
|
19
|
+
# unrelated to the query cache. Clear the SessionRegistry at the start of
|
|
20
|
+
# these tests in order to detect leaks that occur only within the scope of
|
|
21
|
+
# these tests.
|
|
22
|
+
#
|
|
23
|
+
# Other session leaks will be detected and addressed as part of RUBY-2391.
|
|
24
|
+
SessionRegistry.instance.clear_registry
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
after do
|
|
28
|
+
SessionRegistry.instance.verify_sessions_ended!
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
let(:subscriber) { EventSubscriber.new }
|
|
32
|
+
|
|
33
|
+
let(:client) do
|
|
34
|
+
authorized_client.tap do |client|
|
|
35
|
+
client.subscribe(Mongo::Monitoring::COMMAND, subscriber)
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
let(:authorized_collection) { client['collection_spec'] }
|
|
40
|
+
|
|
41
|
+
let(:events) do
|
|
42
|
+
subscriber.command_started_events('find')
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
describe '#cache' do
|
|
46
|
+
|
|
47
|
+
before do
|
|
48
|
+
Mongo::QueryCache.enabled = false
|
|
49
|
+
authorized_collection.insert_one({ name: 'testing' })
|
|
50
|
+
authorized_collection.find(name: 'testing').to_a
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
it 'enables the query cache inside the block' do
|
|
54
|
+
Mongo::QueryCache.cache do
|
|
55
|
+
authorized_collection.find(name: 'testing').to_a
|
|
56
|
+
expect(Mongo::QueryCache.enabled?).to be(true)
|
|
57
|
+
expect(Mongo::QueryCache.send(:cache_table).length).to eq(1)
|
|
58
|
+
expect(events.length).to eq(2)
|
|
59
|
+
end
|
|
60
|
+
authorized_collection.find(name: 'testing').to_a
|
|
61
|
+
expect(Mongo::QueryCache.enabled?).to be(false)
|
|
62
|
+
expect(Mongo::QueryCache.send(:cache_table).length).to eq(1)
|
|
63
|
+
expect(events.length).to eq(2)
|
|
64
|
+
end
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
describe '#uncached' do
|
|
68
|
+
|
|
69
|
+
before do
|
|
70
|
+
authorized_collection.insert_one({ name: 'testing' })
|
|
71
|
+
authorized_collection.find(name: 'testing').to_a
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
it 'disables the query cache inside the block' do
|
|
75
|
+
expect(Mongo::QueryCache.send(:cache_table).length).to eq(1)
|
|
76
|
+
Mongo::QueryCache.uncached do
|
|
77
|
+
authorized_collection.find(name: 'testing').to_a
|
|
78
|
+
expect(Mongo::QueryCache.enabled?).to be(false)
|
|
79
|
+
expect(events.length).to eq(2)
|
|
80
|
+
end
|
|
81
|
+
authorized_collection.find(name: 'testing').to_a
|
|
82
|
+
expect(Mongo::QueryCache.enabled?).to be(true)
|
|
83
|
+
expect(Mongo::QueryCache.send(:cache_table).length).to eq(1)
|
|
84
|
+
expect(events.length).to eq(2)
|
|
85
|
+
end
|
|
86
|
+
end
|
|
87
|
+
|
|
88
|
+
describe 'query with multiple batches' do
|
|
89
|
+
min_server_fcv '3.2'
|
|
90
|
+
|
|
91
|
+
before do
|
|
92
|
+
102.times { |i| authorized_collection.insert_one(_id: i) }
|
|
93
|
+
end
|
|
94
|
+
|
|
95
|
+
let(:expected_results) { [*0..101].map { |id| { "_id" => id } } }
|
|
96
|
+
|
|
97
|
+
it 'returns the correct result' do
|
|
98
|
+
result = authorized_collection.find.to_a
|
|
99
|
+
expect(result.length).to eq(102)
|
|
100
|
+
expect(result).to eq(expected_results)
|
|
101
|
+
end
|
|
102
|
+
|
|
103
|
+
it 'returns the correct result multiple times' do
|
|
104
|
+
result1 = authorized_collection.find.to_a
|
|
105
|
+
result2 = authorized_collection.find.to_a
|
|
106
|
+
expect(result1).to eq(expected_results)
|
|
107
|
+
expect(result2).to eq(expected_results)
|
|
108
|
+
end
|
|
109
|
+
|
|
110
|
+
it 'caches the query' do
|
|
111
|
+
authorized_collection.find.to_a
|
|
112
|
+
authorized_collection.find.to_a
|
|
113
|
+
expect(subscriber.command_started_events('find').length).to eq(1)
|
|
114
|
+
expect(subscriber.command_started_events('getMore').length).to eq(1)
|
|
115
|
+
end
|
|
116
|
+
|
|
117
|
+
it 'uses cached cursor when limited' do
|
|
118
|
+
authorized_collection.find.to_a
|
|
119
|
+
result = authorized_collection.find({}, limit: 5).to_a
|
|
120
|
+
|
|
121
|
+
expect(result.length).to eq(5)
|
|
122
|
+
expect(result).to eq(expected_results.first(5))
|
|
123
|
+
|
|
124
|
+
expect(subscriber.command_started_events('find').length).to eq(1)
|
|
125
|
+
expect(subscriber.command_started_events('getMore').length).to eq(1)
|
|
126
|
+
end
|
|
127
|
+
|
|
128
|
+
it 'can be used with a block API' do
|
|
129
|
+
authorized_collection.find.to_a
|
|
130
|
+
|
|
131
|
+
result = []
|
|
132
|
+
authorized_collection.find.each do |doc|
|
|
133
|
+
result << doc
|
|
134
|
+
end
|
|
135
|
+
|
|
136
|
+
expect(result).to eq(expected_results)
|
|
137
|
+
|
|
138
|
+
expect(subscriber.command_started_events('find').length).to eq(1)
|
|
139
|
+
expect(subscriber.command_started_events('getMore').length).to eq(1)
|
|
140
|
+
end
|
|
141
|
+
|
|
142
|
+
context 'when the cursor isn\'t fully iterated the first time' do
|
|
143
|
+
it 'continues iterating' do
|
|
144
|
+
result1 = authorized_collection.find.first(5)
|
|
145
|
+
|
|
146
|
+
expect(result1.length).to eq(5)
|
|
147
|
+
expect(result1).to eq(expected_results.first(5))
|
|
148
|
+
|
|
149
|
+
expect(subscriber.command_started_events('find').length).to eq(1)
|
|
150
|
+
expect(subscriber.command_started_events('getMore').length).to eq(0)
|
|
151
|
+
|
|
152
|
+
result2 = authorized_collection.find.to_a
|
|
153
|
+
|
|
154
|
+
expect(result2.length).to eq(102)
|
|
155
|
+
expect(result2).to eq(expected_results)
|
|
156
|
+
|
|
157
|
+
expect(subscriber.command_started_events('find').length).to eq(1)
|
|
158
|
+
expect(subscriber.command_started_events('getMore').length).to eq(1)
|
|
159
|
+
end
|
|
160
|
+
|
|
161
|
+
it 'can be iterated multiple times' do
|
|
162
|
+
authorized_collection.find.first(5)
|
|
163
|
+
authorized_collection.find.to_a
|
|
164
|
+
|
|
165
|
+
result = authorized_collection.find.to_a
|
|
166
|
+
|
|
167
|
+
expect(result.length).to eq(102)
|
|
168
|
+
expect(result).to eq(expected_results)
|
|
169
|
+
|
|
170
|
+
expect(subscriber.command_started_events('find').length).to eq(1)
|
|
171
|
+
expect(subscriber.command_started_events('getMore').length).to eq(1)
|
|
172
|
+
end
|
|
173
|
+
|
|
174
|
+
it 'can be used with a block API' do
|
|
175
|
+
authorized_collection.find.first(5)
|
|
176
|
+
|
|
177
|
+
result = []
|
|
178
|
+
authorized_collection.find.each do |doc|
|
|
179
|
+
result << doc
|
|
180
|
+
end
|
|
181
|
+
|
|
182
|
+
expect(result.length).to eq(102)
|
|
183
|
+
expect(result).to eq(expected_results)
|
|
184
|
+
|
|
185
|
+
expect(subscriber.command_started_events('find').length).to eq(1)
|
|
186
|
+
expect(subscriber.command_started_events('getMore').length).to eq(1)
|
|
187
|
+
end
|
|
188
|
+
end
|
|
189
|
+
end
|
|
190
|
+
|
|
191
|
+
describe 'queries with read concern' do
|
|
192
|
+
require_wired_tiger
|
|
193
|
+
min_server_fcv '3.6'
|
|
194
|
+
|
|
195
|
+
before do
|
|
196
|
+
authorized_client['test'].drop
|
|
197
|
+
end
|
|
198
|
+
|
|
199
|
+
context 'when two queries have same read concern' do
|
|
200
|
+
before do
|
|
201
|
+
authorized_client['test', read_concern: { level: :majority }].find.to_a
|
|
202
|
+
authorized_client['test', read_concern: { level: :majority }].find.to_a
|
|
203
|
+
end
|
|
204
|
+
|
|
205
|
+
it 'executes one query' do
|
|
206
|
+
expect(events.length).to eq(1)
|
|
207
|
+
end
|
|
208
|
+
end
|
|
209
|
+
|
|
210
|
+
context 'when two queries have different read concerns' do
|
|
211
|
+
before do
|
|
212
|
+
authorized_client['test', read_concern: { level: :majority }].find.to_a
|
|
213
|
+
authorized_client['test', read_concern: { level: :local }].find.to_a
|
|
214
|
+
end
|
|
215
|
+
|
|
216
|
+
it 'executes two queries' do
|
|
217
|
+
expect(events.length).to eq(2)
|
|
218
|
+
end
|
|
219
|
+
end
|
|
220
|
+
end
|
|
221
|
+
|
|
222
|
+
describe 'queries with read preference' do
|
|
223
|
+
before do
|
|
224
|
+
subscriber.clear_events!
|
|
225
|
+
authorized_client['test'].drop
|
|
226
|
+
end
|
|
227
|
+
|
|
228
|
+
context 'when two queries have different read preferences' do
|
|
229
|
+
before do
|
|
230
|
+
authorized_client['test', read: { mode: :primary }].find.to_a
|
|
231
|
+
authorized_client['test', read: { mode: :primary_preferred }].find.to_a
|
|
232
|
+
end
|
|
233
|
+
|
|
234
|
+
it 'executes two queries' do
|
|
235
|
+
expect(events.length).to eq(2)
|
|
236
|
+
end
|
|
237
|
+
end
|
|
238
|
+
|
|
239
|
+
context 'when two queries have same read preference' do
|
|
240
|
+
before do
|
|
241
|
+
authorized_client['test', read: { mode: :primary }].find.to_a
|
|
242
|
+
authorized_client['test', read: { mode: :primary }].find.to_a
|
|
243
|
+
end
|
|
244
|
+
|
|
245
|
+
it 'executes one query' do
|
|
246
|
+
expect(events.length).to eq(1)
|
|
247
|
+
end
|
|
248
|
+
end
|
|
249
|
+
end
|
|
250
|
+
|
|
251
|
+
describe 'query fills up entire batch' do
|
|
252
|
+
before do
|
|
253
|
+
subscriber.clear_events!
|
|
254
|
+
authorized_client['test'].drop
|
|
255
|
+
|
|
256
|
+
2.times { |i| authorized_client['test'].insert_one(_id: i) }
|
|
257
|
+
end
|
|
258
|
+
|
|
259
|
+
let(:expected_result) do
|
|
260
|
+
[{ "_id" => 0 }, { "_id" => 1 }]
|
|
261
|
+
end
|
|
262
|
+
|
|
263
|
+
# When the last batch runs out, try_next will return nil instead of a
|
|
264
|
+
# document. This test checks that nil is not added to the list of cached
|
|
265
|
+
# documents or returned as a result.
|
|
266
|
+
it 'returns the correct response' do
|
|
267
|
+
expect(authorized_client['test'].find({}, batch_size: 2).to_a).to eq(expected_result)
|
|
268
|
+
expect(authorized_client['test'].find({}, batch_size: 2).to_a).to eq(expected_result)
|
|
269
|
+
end
|
|
270
|
+
end
|
|
271
|
+
|
|
272
|
+
context 'when querying in the same collection' do
|
|
273
|
+
|
|
274
|
+
before do
|
|
275
|
+
10.times do |i|
|
|
276
|
+
authorized_collection.insert_one(test: i)
|
|
277
|
+
end
|
|
278
|
+
end
|
|
279
|
+
|
|
280
|
+
context 'when query cache is disabled' do
|
|
281
|
+
|
|
282
|
+
before do
|
|
283
|
+
Mongo::QueryCache.enabled = false
|
|
284
|
+
authorized_collection.find(test: 1).to_a
|
|
285
|
+
end
|
|
286
|
+
|
|
287
|
+
it 'queries again' do
|
|
288
|
+
authorized_collection.find(test: 1).to_a
|
|
289
|
+
expect(events.length).to eq(2)
|
|
290
|
+
expect(Mongo::QueryCache.send(:cache_table).length).to eq(0)
|
|
291
|
+
end
|
|
292
|
+
end
|
|
293
|
+
|
|
294
|
+
context 'when query cache is enabled' do
|
|
295
|
+
|
|
296
|
+
before do
|
|
297
|
+
authorized_collection.find(test: 1).to_a
|
|
298
|
+
end
|
|
299
|
+
|
|
300
|
+
it 'does not query again' do
|
|
301
|
+
authorized_collection.find(test: 1).to_a
|
|
302
|
+
expect(events.length).to eq(1)
|
|
303
|
+
expect(Mongo::QueryCache.send(:cache_table).length).to eq(1)
|
|
304
|
+
end
|
|
305
|
+
end
|
|
306
|
+
|
|
307
|
+
context 'when query has collation' do
|
|
308
|
+
min_server_fcv '3.4'
|
|
309
|
+
|
|
310
|
+
let(:options1) do
|
|
311
|
+
{ :collation => { locale: 'fr' } }
|
|
312
|
+
end
|
|
313
|
+
|
|
314
|
+
let(:options2) do
|
|
315
|
+
{ collation: { locale: 'en_US' } }
|
|
316
|
+
end
|
|
317
|
+
|
|
318
|
+
before do
|
|
319
|
+
authorized_collection.find({ test: 3 }, options1).to_a
|
|
320
|
+
end
|
|
321
|
+
|
|
322
|
+
context 'when query has the same collation' do
|
|
323
|
+
|
|
324
|
+
it 'uses the cache' do
|
|
325
|
+
authorized_collection.find({ test: 3 }, options1).to_a
|
|
326
|
+
expect(events.length).to eq(1)
|
|
327
|
+
end
|
|
328
|
+
end
|
|
329
|
+
|
|
330
|
+
context 'when query has a different collation' do
|
|
331
|
+
|
|
332
|
+
it 'queries again' do
|
|
333
|
+
authorized_collection.find({ test: 3 }, options2).to_a
|
|
334
|
+
expect(events.length).to eq(2)
|
|
335
|
+
expect(Mongo::QueryCache.send(:cache_table)['ruby-driver.collection_spec'].length).to eq(2)
|
|
336
|
+
end
|
|
337
|
+
end
|
|
338
|
+
end
|
|
339
|
+
|
|
340
|
+
describe 'queries with limits' do
|
|
341
|
+
context 'when the first query has no limit and the second does' do
|
|
342
|
+
before do
|
|
343
|
+
authorized_collection.find.to_a.count
|
|
344
|
+
end
|
|
345
|
+
|
|
346
|
+
it 'uses the cache' do
|
|
347
|
+
results_limit_5 = authorized_collection.find.limit(5).to_a
|
|
348
|
+
results_limit_3 = authorized_collection.find.limit(3).to_a
|
|
349
|
+
results_no_limit = authorized_collection.find.to_a
|
|
350
|
+
|
|
351
|
+
expect(results_limit_5.length).to eq(5)
|
|
352
|
+
expect(results_limit_5.map { |r| r["test"] }).to eq([0, 1, 2, 3, 4])
|
|
353
|
+
|
|
354
|
+
expect(results_limit_3.length).to eq(3)
|
|
355
|
+
expect(results_limit_3.map { |r| r["test"] }).to eq([0, 1, 2])
|
|
356
|
+
|
|
357
|
+
expect(results_no_limit.length).to eq(10)
|
|
358
|
+
expect(results_no_limit.map { |r| r["test"] }).to eq([0, 1, 2, 3, 4, 5, 6, 7, 8, 9])
|
|
359
|
+
|
|
360
|
+
expect(events.length).to eq(1)
|
|
361
|
+
end
|
|
362
|
+
end
|
|
363
|
+
|
|
364
|
+
context 'when the first query has a limit' do
|
|
365
|
+
before do
|
|
366
|
+
authorized_collection.find.limit(2).to_a
|
|
367
|
+
end
|
|
368
|
+
|
|
369
|
+
context 'and the second query has a larger limit' do
|
|
370
|
+
let(:results) { authorized_collection.find.limit(3).to_a }
|
|
371
|
+
|
|
372
|
+
it 'queries again' do
|
|
373
|
+
expect(results.length).to eq(3)
|
|
374
|
+
expect(results.map { |result| result["test"] }).to eq([0, 1, 2])
|
|
375
|
+
expect(events.length).to eq(2)
|
|
376
|
+
end
|
|
377
|
+
end
|
|
378
|
+
|
|
379
|
+
context 'and two queries are performed with a larger limit' do
|
|
380
|
+
it 'uses the query cache for the third query' do
|
|
381
|
+
results1 = authorized_collection.find.limit(3).to_a
|
|
382
|
+
results2 = authorized_collection.find.limit(3).to_a
|
|
383
|
+
|
|
384
|
+
expect(results1.length).to eq(3)
|
|
385
|
+
expect(results1.map { |r| r["test"] }).to eq([0, 1, 2])
|
|
386
|
+
|
|
387
|
+
expect(results2.length).to eq(3)
|
|
388
|
+
expect(results2.map { |r| r["test"] }).to eq([0, 1, 2])
|
|
389
|
+
|
|
390
|
+
expect(events.length).to eq(2)
|
|
391
|
+
end
|
|
392
|
+
end
|
|
393
|
+
|
|
394
|
+
context 'and the second query has a smaller limit' do
|
|
395
|
+
let(:results) { authorized_collection.find.limit(1).to_a }
|
|
396
|
+
|
|
397
|
+
it 'uses the cached query' do
|
|
398
|
+
expect(results.count).to eq(1)
|
|
399
|
+
expect(results.first["test"]).to eq(0)
|
|
400
|
+
expect(events.length).to eq(1)
|
|
401
|
+
end
|
|
402
|
+
end
|
|
403
|
+
|
|
404
|
+
context 'and the second query has no limit' do
|
|
405
|
+
it 'queries again' do
|
|
406
|
+
expect(authorized_collection.find.to_a.count).to eq(10)
|
|
407
|
+
expect(events.length).to eq(2)
|
|
408
|
+
end
|
|
409
|
+
end
|
|
410
|
+
end
|
|
411
|
+
end
|
|
412
|
+
|
|
413
|
+
context 'when querying only the first' do
|
|
414
|
+
|
|
415
|
+
before do
|
|
416
|
+
5.times do |i|
|
|
417
|
+
authorized_collection.insert_one(test: 11)
|
|
418
|
+
end
|
|
419
|
+
end
|
|
420
|
+
|
|
421
|
+
before do
|
|
422
|
+
authorized_collection.find({test: 11}).to_a
|
|
423
|
+
end
|
|
424
|
+
|
|
425
|
+
it 'does not query again' do
|
|
426
|
+
expect(authorized_collection.find({test: 11}).count).to eq(5)
|
|
427
|
+
authorized_collection.find({test: 11}).first
|
|
428
|
+
expect(events.length).to eq(1)
|
|
429
|
+
end
|
|
430
|
+
|
|
431
|
+
context 'when limiting the result' do
|
|
432
|
+
|
|
433
|
+
it 'does not query again' do
|
|
434
|
+
authorized_collection.find({test: 11}, limit: 2).to_a
|
|
435
|
+
expect(authorized_collection.find({test: 11}, limit: 2).to_a.count).to eq(2)
|
|
436
|
+
expect(events.length).to eq(1)
|
|
437
|
+
end
|
|
438
|
+
end
|
|
439
|
+
end
|
|
440
|
+
|
|
441
|
+
context 'when specifying a different skip value' do
|
|
442
|
+
|
|
443
|
+
before do
|
|
444
|
+
authorized_collection.find({}, {limit: 2, skip: 3}).to_a
|
|
445
|
+
end
|
|
446
|
+
|
|
447
|
+
it 'queries again' do
|
|
448
|
+
results = authorized_collection.find({}, {limit: 2, skip: 5}).to_a
|
|
449
|
+
expect(results.count).to eq(2)
|
|
450
|
+
expect(events.length).to eq(2)
|
|
451
|
+
end
|
|
452
|
+
end
|
|
453
|
+
|
|
454
|
+
context 'when sorting documents' do
|
|
455
|
+
|
|
456
|
+
before do
|
|
457
|
+
authorized_collection.find({}, desc).to_a
|
|
458
|
+
end
|
|
459
|
+
|
|
460
|
+
let(:desc) do
|
|
461
|
+
{ sort: {test: -1} }
|
|
462
|
+
end
|
|
463
|
+
|
|
464
|
+
let(:asc) do
|
|
465
|
+
{ sort: {test: 1} }
|
|
466
|
+
end
|
|
467
|
+
|
|
468
|
+
context 'with different selector' do
|
|
469
|
+
|
|
470
|
+
it 'queries again' do
|
|
471
|
+
authorized_collection.find({}, asc).to_a
|
|
472
|
+
expect(events.length).to eq(2)
|
|
473
|
+
end
|
|
474
|
+
end
|
|
475
|
+
|
|
476
|
+
it 'does not query again' do
|
|
477
|
+
authorized_collection.find({}, desc).to_a
|
|
478
|
+
expect(events.length).to eq(1)
|
|
479
|
+
end
|
|
480
|
+
end
|
|
481
|
+
|
|
482
|
+
context 'when inserting new documents' do
|
|
483
|
+
context 'when inserting and querying from same collection' do
|
|
484
|
+
before do
|
|
485
|
+
authorized_collection.find.to_a
|
|
486
|
+
authorized_collection.insert_one({ name: "bob" })
|
|
487
|
+
end
|
|
488
|
+
|
|
489
|
+
it 'queries again' do
|
|
490
|
+
authorized_collection.find.to_a
|
|
491
|
+
expect(events.length).to eq(2)
|
|
492
|
+
end
|
|
493
|
+
end
|
|
494
|
+
|
|
495
|
+
context 'when inserting and querying from different collections' do
|
|
496
|
+
before do
|
|
497
|
+
authorized_collection.find.to_a
|
|
498
|
+
authorized_client['different_collection'].insert_one({ name: "bob" })
|
|
499
|
+
end
|
|
500
|
+
|
|
501
|
+
it 'uses the cached query' do
|
|
502
|
+
authorized_collection.find.to_a
|
|
503
|
+
expect(events.length).to eq(1)
|
|
504
|
+
end
|
|
505
|
+
end
|
|
506
|
+
end
|
|
507
|
+
|
|
508
|
+
[:delete_many, :delete_one].each do |method|
|
|
509
|
+
context "when deleting with #{method}" do
|
|
510
|
+
context 'when deleting and querying from same collection' do
|
|
511
|
+
before do
|
|
512
|
+
authorized_collection.find.to_a
|
|
513
|
+
authorized_collection.send(method)
|
|
514
|
+
end
|
|
515
|
+
|
|
516
|
+
it 'queries again' do
|
|
517
|
+
authorized_collection.find.to_a
|
|
518
|
+
expect(events.length).to eq(2)
|
|
519
|
+
end
|
|
520
|
+
end
|
|
521
|
+
|
|
522
|
+
context 'when deleting and querying from different collections' do
|
|
523
|
+
before do
|
|
524
|
+
authorized_collection.find.to_a
|
|
525
|
+
authorized_client['different_collection'].send(method)
|
|
526
|
+
end
|
|
527
|
+
|
|
528
|
+
it 'uses the cached query' do
|
|
529
|
+
authorized_collection.find.to_a
|
|
530
|
+
expect(events.length).to eq(1)
|
|
531
|
+
end
|
|
532
|
+
end
|
|
533
|
+
end
|
|
534
|
+
end
|
|
535
|
+
|
|
536
|
+
[:find_one_and_delete, :find_one_and_replace, :find_one_and_update,
|
|
537
|
+
:update_one, :replace_one].each do |method|
|
|
538
|
+
context "when updating with #{method}" do
|
|
539
|
+
context 'when updating and querying from same collection' do
|
|
540
|
+
before do
|
|
541
|
+
authorized_collection.find.to_a
|
|
542
|
+
authorized_collection.send(method, { field: 'value' }, { field: 'new value' })
|
|
543
|
+
end
|
|
544
|
+
|
|
545
|
+
it 'queries again' do
|
|
546
|
+
authorized_collection.find.to_a
|
|
547
|
+
expect(events.length).to eq(2)
|
|
548
|
+
end
|
|
549
|
+
end
|
|
550
|
+
|
|
551
|
+
context 'when updating and querying from different collections' do
|
|
552
|
+
before do
|
|
553
|
+
authorized_collection.find.to_a
|
|
554
|
+
authorized_client['different_collection'].send(method, { field: 'value' }, { field: 'new value' })
|
|
555
|
+
end
|
|
556
|
+
|
|
557
|
+
it 'uses the cached query' do
|
|
558
|
+
authorized_collection.find.to_a
|
|
559
|
+
expect(events.length).to eq(1)
|
|
560
|
+
end
|
|
561
|
+
end
|
|
562
|
+
end
|
|
563
|
+
end
|
|
564
|
+
|
|
565
|
+
context 'when updating with #update_many' do
|
|
566
|
+
context 'when updating and querying from same collection' do
|
|
567
|
+
before do
|
|
568
|
+
authorized_collection.find.to_a
|
|
569
|
+
authorized_collection.update_many({ field: 'value' }, { "$inc" => { :field => 1 } })
|
|
570
|
+
end
|
|
571
|
+
|
|
572
|
+
it 'queries again' do
|
|
573
|
+
authorized_collection.find.to_a
|
|
574
|
+
expect(events.length).to eq(2)
|
|
575
|
+
end
|
|
576
|
+
end
|
|
577
|
+
|
|
578
|
+
context 'when updating and querying from different collections' do
|
|
579
|
+
before do
|
|
580
|
+
authorized_collection.find.to_a
|
|
581
|
+
authorized_client['different_collection'].update_many({ field: 'value' }, { "$inc" => { :field => 1 } })
|
|
582
|
+
end
|
|
583
|
+
|
|
584
|
+
it 'uses the cached query' do
|
|
585
|
+
authorized_collection.find.to_a
|
|
586
|
+
expect(events.length).to eq(1)
|
|
587
|
+
end
|
|
588
|
+
end
|
|
589
|
+
end
|
|
590
|
+
|
|
591
|
+
context 'when performing bulk write' do
|
|
592
|
+
context 'with insert_one' do
|
|
593
|
+
context 'when inserting and querying from same collection' do
|
|
594
|
+
before do
|
|
595
|
+
authorized_collection.find.to_a
|
|
596
|
+
authorized_collection.bulk_write([ { insert_one: { name: 'bob' } } ])
|
|
597
|
+
end
|
|
598
|
+
|
|
599
|
+
it 'queries again' do
|
|
600
|
+
authorized_collection.find.to_a
|
|
601
|
+
expect(events.length).to eq(2)
|
|
602
|
+
end
|
|
603
|
+
end
|
|
604
|
+
|
|
605
|
+
context 'when inserting and querying from different collection' do
|
|
606
|
+
before do
|
|
607
|
+
authorized_collection.find.to_a
|
|
608
|
+
authorized_client['different_collection'].bulk_write(
|
|
609
|
+
[ { insert_one: { name: 'bob' } } ]
|
|
610
|
+
)
|
|
611
|
+
end
|
|
612
|
+
|
|
613
|
+
it 'uses the cached query' do
|
|
614
|
+
authorized_collection.find.to_a
|
|
615
|
+
expect(events.length).to eq(1)
|
|
616
|
+
end
|
|
617
|
+
end
|
|
618
|
+
end
|
|
619
|
+
|
|
620
|
+
[:update_one, :update_many].each do |method|
|
|
621
|
+
context "with #{method}" do
|
|
622
|
+
context 'when updating and querying from same collection' do
|
|
623
|
+
before do
|
|
624
|
+
authorized_collection.find.to_a
|
|
625
|
+
authorized_collection.bulk_write([
|
|
626
|
+
{
|
|
627
|
+
method => {
|
|
628
|
+
filter: { field: 'value' },
|
|
629
|
+
update: { '$set' => { field: 'new value' } }
|
|
630
|
+
}
|
|
631
|
+
}
|
|
632
|
+
])
|
|
633
|
+
end
|
|
634
|
+
|
|
635
|
+
it 'queries again' do
|
|
636
|
+
authorized_collection.find.to_a
|
|
637
|
+
expect(events.length).to eq(2)
|
|
638
|
+
end
|
|
639
|
+
end
|
|
640
|
+
|
|
641
|
+
context 'when updating and querying from different collection' do
|
|
642
|
+
before do
|
|
643
|
+
authorized_collection.find.to_a
|
|
644
|
+
authorized_client['different_collection'].bulk_write([
|
|
645
|
+
{
|
|
646
|
+
method => {
|
|
647
|
+
filter: { field: 'value' },
|
|
648
|
+
update: { '$set' => { field: 'new value' } }
|
|
649
|
+
}
|
|
650
|
+
}
|
|
651
|
+
])
|
|
652
|
+
end
|
|
653
|
+
|
|
654
|
+
it 'uses the cached query' do
|
|
655
|
+
authorized_collection.find.to_a
|
|
656
|
+
expect(events.length).to eq(1)
|
|
657
|
+
end
|
|
658
|
+
end
|
|
659
|
+
end
|
|
660
|
+
end
|
|
661
|
+
|
|
662
|
+
[:delete_one, :delete_many].each do |method|
|
|
663
|
+
context "with #{method}" do
|
|
664
|
+
context 'when delete and querying from same collection' do
|
|
665
|
+
before do
|
|
666
|
+
authorized_collection.find.to_a
|
|
667
|
+
authorized_collection.bulk_write([
|
|
668
|
+
{
|
|
669
|
+
method => {
|
|
670
|
+
filter: { field: 'value' },
|
|
671
|
+
}
|
|
672
|
+
}
|
|
673
|
+
])
|
|
674
|
+
end
|
|
675
|
+
|
|
676
|
+
it 'queries again' do
|
|
677
|
+
authorized_collection.find.to_a
|
|
678
|
+
expect(events.length).to eq(2)
|
|
679
|
+
end
|
|
680
|
+
end
|
|
681
|
+
|
|
682
|
+
context 'when delete and querying from different collection' do
|
|
683
|
+
before do
|
|
684
|
+
authorized_collection.find.to_a
|
|
685
|
+
authorized_client['different_collection'].bulk_write([
|
|
686
|
+
{
|
|
687
|
+
method => {
|
|
688
|
+
filter: { field: 'value' },
|
|
689
|
+
}
|
|
690
|
+
}
|
|
691
|
+
])
|
|
692
|
+
end
|
|
693
|
+
|
|
694
|
+
it 'uses the cached query' do
|
|
695
|
+
authorized_collection.find.to_a
|
|
696
|
+
expect(events.length).to eq(1)
|
|
697
|
+
end
|
|
698
|
+
end
|
|
699
|
+
end
|
|
700
|
+
end
|
|
701
|
+
|
|
702
|
+
context 'with replace_one' do
|
|
703
|
+
context 'when replacing and querying from same collection' do
|
|
704
|
+
before do
|
|
705
|
+
authorized_collection.find.to_a
|
|
706
|
+
authorized_collection.bulk_write([
|
|
707
|
+
{
|
|
708
|
+
replace_one: {
|
|
709
|
+
filter: { field: 'value' },
|
|
710
|
+
replacement: { field: 'new value' }
|
|
711
|
+
}
|
|
712
|
+
}
|
|
713
|
+
])
|
|
714
|
+
end
|
|
715
|
+
|
|
716
|
+
it 'queries again' do
|
|
717
|
+
authorized_collection.find.to_a
|
|
718
|
+
expect(events.length).to eq(2)
|
|
719
|
+
end
|
|
720
|
+
end
|
|
721
|
+
|
|
722
|
+
context 'when replacing and querying from different collection' do
|
|
723
|
+
before do
|
|
724
|
+
authorized_collection.find.to_a
|
|
725
|
+
authorized_client['different_collection'].bulk_write([
|
|
726
|
+
{
|
|
727
|
+
replace_one: {
|
|
728
|
+
filter: { field: 'value' },
|
|
729
|
+
replacement: { field: 'new value' }
|
|
730
|
+
}
|
|
731
|
+
}
|
|
732
|
+
])
|
|
733
|
+
end
|
|
734
|
+
|
|
735
|
+
it 'uses the cached query' do
|
|
736
|
+
authorized_collection.find.to_a
|
|
737
|
+
expect(events.length).to eq(1)
|
|
738
|
+
end
|
|
739
|
+
end
|
|
740
|
+
end
|
|
741
|
+
|
|
742
|
+
context 'when query occurs between bulk write creation and execution' do
|
|
743
|
+
before do
|
|
744
|
+
authorized_collection.delete_many
|
|
745
|
+
end
|
|
746
|
+
|
|
747
|
+
it 'queries again' do
|
|
748
|
+
bulk_write = Mongo::BulkWrite.new(
|
|
749
|
+
authorized_collection,
|
|
750
|
+
[{ insert_one: { test: 1 } }]
|
|
751
|
+
)
|
|
752
|
+
|
|
753
|
+
expect(authorized_collection.find(test: 1).to_a.length).to eq(0)
|
|
754
|
+
bulk_write.execute
|
|
755
|
+
expect(authorized_collection.find(test: 1).to_a.length).to eq(1)
|
|
756
|
+
expect(events.length).to eq(2)
|
|
757
|
+
end
|
|
758
|
+
end
|
|
759
|
+
end
|
|
760
|
+
|
|
761
|
+
context 'when aggregating with $out' do
|
|
762
|
+
before do
|
|
763
|
+
authorized_collection.find.to_a
|
|
764
|
+
authorized_collection.aggregate([
|
|
765
|
+
{ '$match' => { test: 1 } },
|
|
766
|
+
{ '$out' => { coll: 'new_coll' } }
|
|
767
|
+
])
|
|
768
|
+
end
|
|
769
|
+
|
|
770
|
+
it 'queries again' do
|
|
771
|
+
authorized_collection.find.to_a
|
|
772
|
+
expect(events.length).to eq(2)
|
|
773
|
+
end
|
|
774
|
+
|
|
775
|
+
it 'clears the cache' do
|
|
776
|
+
expect(Mongo::QueryCache.send(:cache_table)).to be_empty
|
|
777
|
+
end
|
|
778
|
+
end
|
|
779
|
+
|
|
780
|
+
context 'when aggregating with $merge' do
|
|
781
|
+
min_server_fcv '4.2'
|
|
782
|
+
|
|
783
|
+
before do
|
|
784
|
+
authorized_collection.delete_many
|
|
785
|
+
authorized_collection.find.to_a
|
|
786
|
+
authorized_collection.aggregate([
|
|
787
|
+
{ '$match' => { 'test' => 1 } },
|
|
788
|
+
{ '$merge' => {
|
|
789
|
+
into: {
|
|
790
|
+
db: SpecConfig.instance.test_db,
|
|
791
|
+
coll: 'new_coll',
|
|
792
|
+
},
|
|
793
|
+
on: "_id",
|
|
794
|
+
whenMatched: "replace",
|
|
795
|
+
whenNotMatched: "insert",
|
|
796
|
+
}
|
|
797
|
+
}
|
|
798
|
+
])
|
|
799
|
+
end
|
|
800
|
+
|
|
801
|
+
it 'queries again' do
|
|
802
|
+
authorized_collection.find.to_a
|
|
803
|
+
expect(events.length).to eq(2)
|
|
804
|
+
end
|
|
805
|
+
|
|
806
|
+
it 'clears the cache' do
|
|
807
|
+
expect(Mongo::QueryCache.send(:cache_table)).to be_empty
|
|
808
|
+
end
|
|
809
|
+
end
|
|
810
|
+
end
|
|
811
|
+
|
|
812
|
+
context 'when aggregating' do
|
|
813
|
+
before do
|
|
814
|
+
3.times { authorized_collection.insert_one(test: 1) }
|
|
815
|
+
end
|
|
816
|
+
|
|
817
|
+
let(:events) do
|
|
818
|
+
subscriber.command_started_events('aggregate')
|
|
819
|
+
end
|
|
820
|
+
|
|
821
|
+
let(:aggregation) do
|
|
822
|
+
authorized_collection.aggregate([ { '$match' => { test: 1 } } ])
|
|
823
|
+
end
|
|
824
|
+
|
|
825
|
+
it 'caches the aggregation' do
|
|
826
|
+
expect(aggregation.to_a.length).to eq(3)
|
|
827
|
+
expect(aggregation.to_a.length).to eq(3)
|
|
828
|
+
expect(events.length).to eq(1)
|
|
829
|
+
end
|
|
830
|
+
|
|
831
|
+
context 'with read concern' do
|
|
832
|
+
require_wired_tiger
|
|
833
|
+
min_server_fcv '3.6'
|
|
834
|
+
|
|
835
|
+
let(:aggregation_read_concern) do
|
|
836
|
+
authorized_client['collection_spec', { read_concern: { level: :local } }]
|
|
837
|
+
.aggregate([ { '$match' => { test: 1 } } ])
|
|
838
|
+
end
|
|
839
|
+
|
|
840
|
+
it 'queries twice' do
|
|
841
|
+
expect(aggregation.to_a.length).to eq(3)
|
|
842
|
+
expect(aggregation_read_concern.to_a.length).to eq(3)
|
|
843
|
+
expect(events.length).to eq(2)
|
|
844
|
+
end
|
|
845
|
+
end
|
|
846
|
+
|
|
847
|
+
context 'with read preference' do
|
|
848
|
+
let(:aggregation_read_preference) do
|
|
849
|
+
authorized_client['collection_spec', { read: { mode: :primary } }]
|
|
850
|
+
.aggregate([ { '$match' => { test: 1 } } ])
|
|
851
|
+
end
|
|
852
|
+
|
|
853
|
+
it 'queries twice' do
|
|
854
|
+
expect(aggregation.to_a.length).to eq(3)
|
|
855
|
+
expect(aggregation_read_preference.to_a.length).to eq(3)
|
|
856
|
+
expect(events.length).to eq(2)
|
|
857
|
+
end
|
|
858
|
+
end
|
|
859
|
+
|
|
860
|
+
context 'when collation is specified' do
|
|
861
|
+
min_server_fcv '3.4'
|
|
862
|
+
|
|
863
|
+
let(:aggregation_collation) do
|
|
864
|
+
authorized_collection.aggregate(
|
|
865
|
+
[ { '$match' => { test: 1 } } ],
|
|
866
|
+
{ collation: { locale: 'fr' } }
|
|
867
|
+
)
|
|
868
|
+
end
|
|
869
|
+
|
|
870
|
+
it 'queries twice' do
|
|
871
|
+
expect(aggregation.to_a.length).to eq(3)
|
|
872
|
+
expect(aggregation_collation.to_a.length).to eq(3)
|
|
873
|
+
expect(events.length).to eq(2)
|
|
874
|
+
end
|
|
875
|
+
end
|
|
876
|
+
|
|
877
|
+
context 'when insert_one is performed on another collection' do
|
|
878
|
+
before do
|
|
879
|
+
aggregation.to_a
|
|
880
|
+
authorized_client['different_collection'].insert_one(name: 'bob')
|
|
881
|
+
aggregation.to_a
|
|
882
|
+
end
|
|
883
|
+
|
|
884
|
+
it 'queries again' do
|
|
885
|
+
expect(events.length).to eq(2)
|
|
886
|
+
end
|
|
887
|
+
end
|
|
888
|
+
|
|
889
|
+
context 'when insert_many is performed on another collection' do
|
|
890
|
+
before do
|
|
891
|
+
aggregation.to_a
|
|
892
|
+
authorized_client['different_collection'].insert_many([name: 'bob'])
|
|
893
|
+
aggregation.to_a
|
|
894
|
+
end
|
|
895
|
+
|
|
896
|
+
it 'queries again' do
|
|
897
|
+
expect(events.length).to eq(2)
|
|
898
|
+
end
|
|
899
|
+
end
|
|
900
|
+
|
|
901
|
+
[:delete_many, :delete_one].each do |method|
|
|
902
|
+
context "when #{method} is performed on another collection" do
|
|
903
|
+
before do
|
|
904
|
+
aggregation.to_a
|
|
905
|
+
authorized_client['different_collection'].send(method)
|
|
906
|
+
aggregation.to_a
|
|
907
|
+
end
|
|
908
|
+
|
|
909
|
+
it 'queries again' do
|
|
910
|
+
expect(events.length).to eq(2)
|
|
911
|
+
end
|
|
912
|
+
end
|
|
913
|
+
end
|
|
914
|
+
|
|
915
|
+
[:find_one_and_delete, :find_one_and_replace, :find_one_and_update,
|
|
916
|
+
:update_one, :replace_one].each do |method|
|
|
917
|
+
context "when #{method} is performed on another collection" do
|
|
918
|
+
before do
|
|
919
|
+
aggregation.to_a
|
|
920
|
+
authorized_client['different_collection'].send(method, { field: 'value' }, { field: 'new value' })
|
|
921
|
+
aggregation.to_a
|
|
922
|
+
end
|
|
923
|
+
|
|
924
|
+
it 'queries again' do
|
|
925
|
+
expect(events.length).to eq(2)
|
|
926
|
+
end
|
|
927
|
+
end
|
|
928
|
+
end
|
|
929
|
+
|
|
930
|
+
context 'when update_many is performed on another collection' do
|
|
931
|
+
before do
|
|
932
|
+
aggregation.to_a
|
|
933
|
+
authorized_client['different_collection'].update_many({ field: 'value' }, { "$inc" => { :field => 1 } })
|
|
934
|
+
aggregation.to_a
|
|
935
|
+
end
|
|
936
|
+
|
|
937
|
+
it 'queries again' do
|
|
938
|
+
expect(events.length).to eq(2)
|
|
939
|
+
end
|
|
940
|
+
end
|
|
941
|
+
|
|
942
|
+
context '#count_documents' do
|
|
943
|
+
context 'on same collection' do
|
|
944
|
+
it 'caches the query' do
|
|
945
|
+
expect(authorized_collection.count_documents(test: 1)).to eq(3)
|
|
946
|
+
expect(authorized_collection.count_documents(test: 1)).to eq(3)
|
|
947
|
+
|
|
948
|
+
expect(events.length).to eq(1)
|
|
949
|
+
end
|
|
950
|
+
end
|
|
951
|
+
|
|
952
|
+
context 'on different collections' do
|
|
953
|
+
let(:other_collection) { authorized_client['other_collection'] }
|
|
954
|
+
|
|
955
|
+
before do
|
|
956
|
+
other_collection.drop
|
|
957
|
+
6.times { other_collection.insert_one(test: 1) }
|
|
958
|
+
end
|
|
959
|
+
|
|
960
|
+
it 'caches the query' do
|
|
961
|
+
expect(authorized_collection.count_documents(test: 1)).to eq(3)
|
|
962
|
+
expect(other_collection.count_documents(test: 1)).to eq(6)
|
|
963
|
+
|
|
964
|
+
expect(events.length).to eq(2)
|
|
965
|
+
end
|
|
966
|
+
end
|
|
967
|
+
end
|
|
968
|
+
end
|
|
969
|
+
|
|
970
|
+
context 'when find command fails and retries' do
|
|
971
|
+
require_fail_command
|
|
972
|
+
require_no_multi_shard
|
|
973
|
+
require_warning_clean
|
|
974
|
+
|
|
975
|
+
before do
|
|
976
|
+
5.times do |i|
|
|
977
|
+
authorized_collection.insert_one(test: i)
|
|
978
|
+
end
|
|
979
|
+
end
|
|
980
|
+
|
|
981
|
+
before do
|
|
982
|
+
client.use('admin').command(
|
|
983
|
+
configureFailPoint: 'failCommand',
|
|
984
|
+
mode: { times: 1 },
|
|
985
|
+
data: {
|
|
986
|
+
failCommands: ['find'],
|
|
987
|
+
closeConnection: true
|
|
988
|
+
}
|
|
989
|
+
)
|
|
990
|
+
end
|
|
991
|
+
|
|
992
|
+
let(:command_name) { 'find' }
|
|
993
|
+
|
|
994
|
+
it 'uses modern retryable reads when using query cache' do
|
|
995
|
+
expect(Mongo::QueryCache.enabled?).to be(true)
|
|
996
|
+
|
|
997
|
+
expect(Mongo::Logger.logger).to receive(:warn).once.with(/modern.*attempt 1/).and_call_original
|
|
998
|
+
authorized_collection.find(test: 1).to_a
|
|
999
|
+
expect(Mongo::QueryCache.send(:cache_table).length).to eq(1)
|
|
1000
|
+
expect(subscriber.command_started_events('find').length).to eq(2)
|
|
1001
|
+
|
|
1002
|
+
authorized_collection.find(test: 1).to_a
|
|
1003
|
+
expect(Mongo::QueryCache.send(:cache_table).length).to eq(1)
|
|
1004
|
+
expect(subscriber.command_started_events('find').length).to eq(2)
|
|
1005
|
+
end
|
|
1006
|
+
end
|
|
1007
|
+
|
|
1008
|
+
context 'when querying in a different collection' do
|
|
1009
|
+
|
|
1010
|
+
let(:database) { client.database }
|
|
1011
|
+
|
|
1012
|
+
let(:new_collection) do
|
|
1013
|
+
Mongo::Collection.new(database, 'foo')
|
|
1014
|
+
end
|
|
1015
|
+
|
|
1016
|
+
before do
|
|
1017
|
+
authorized_collection.find.to_a
|
|
1018
|
+
end
|
|
1019
|
+
|
|
1020
|
+
it 'queries again' do
|
|
1021
|
+
new_collection.find.to_a
|
|
1022
|
+
expect(Mongo::QueryCache.send(:cache_table).length).to eq(2)
|
|
1023
|
+
expect(events.length).to eq(2)
|
|
1024
|
+
end
|
|
1025
|
+
end
|
|
1026
|
+
|
|
1027
|
+
context 'with system collection' do
|
|
1028
|
+
let(:client) do
|
|
1029
|
+
ClientRegistry.instance.global_client('root_authorized').tap do |client|
|
|
1030
|
+
client.subscribe(Mongo::Monitoring::COMMAND, subscriber)
|
|
1031
|
+
end
|
|
1032
|
+
end
|
|
1033
|
+
|
|
1034
|
+
before do
|
|
1035
|
+
begin
|
|
1036
|
+
client.database.users.remove('alanturing')
|
|
1037
|
+
rescue Mongo::Error::OperationFailure
|
|
1038
|
+
# can be user not found, ignore
|
|
1039
|
+
end
|
|
1040
|
+
end
|
|
1041
|
+
|
|
1042
|
+
it 'does not use the query cache' do
|
|
1043
|
+
client['system.users'].find.to_a
|
|
1044
|
+
client['system.users'].find.to_a
|
|
1045
|
+
expect(events.length).to eq(2)
|
|
1046
|
+
end
|
|
1047
|
+
end
|
|
1048
|
+
end
|