mongo 2.6.4 → 2.7.0.rc0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +0 -0
- data/LICENSE +1 -1
- data/README.md +1 -1
- data/Rakefile +10 -11
- data/lib/mongo.rb +3 -1
- data/lib/mongo/active_support.rb +17 -0
- data/lib/mongo/address.rb +47 -39
- data/lib/mongo/address/ipv4.rb +1 -1
- data/lib/mongo/address/ipv6.rb +1 -1
- data/lib/mongo/address/unix.rb +1 -1
- data/lib/mongo/auth.rb +3 -8
- data/lib/mongo/auth/cr.rb +2 -2
- data/lib/mongo/auth/cr/conversation.rb +4 -4
- data/lib/mongo/auth/ldap.rb +2 -2
- data/lib/mongo/auth/ldap/conversation.rb +3 -3
- data/lib/mongo/auth/roles.rb +1 -1
- data/lib/mongo/auth/scram.rb +2 -2
- data/lib/mongo/auth/scram/conversation.rb +5 -5
- data/lib/mongo/auth/stringprep.rb +1 -1
- data/lib/mongo/auth/stringprep/profiles/sasl.rb +1 -1
- data/lib/mongo/auth/stringprep/tables.rb +1 -1
- data/lib/mongo/auth/user.rb +1 -1
- data/lib/mongo/auth/user/view.rb +2 -2
- data/lib/mongo/auth/x509.rb +2 -2
- data/lib/mongo/auth/x509/conversation.rb +3 -3
- data/lib/mongo/bson.rb +1 -1
- data/lib/mongo/bulk_write.rb +1 -1
- data/lib/mongo/bulk_write/combineable.rb +2 -2
- data/lib/mongo/bulk_write/ordered_combiner.rb +1 -1
- data/lib/mongo/bulk_write/result.rb +1 -1
- data/lib/mongo/bulk_write/result_combiner.rb +1 -1
- data/lib/mongo/bulk_write/transformable.rb +2 -2
- data/lib/mongo/bulk_write/unordered_combiner.rb +1 -1
- data/lib/mongo/bulk_write/validatable.rb +2 -2
- data/lib/mongo/client.rb +194 -82
- data/lib/mongo/cluster.rb +418 -298
- data/lib/mongo/cluster/periodic_executor.rb +10 -3
- data/lib/mongo/cluster/reapers/socket_reaper.rb +1 -1
- data/lib/mongo/cluster/sdam_flow.rb +481 -0
- data/lib/mongo/cluster/topology.rb +37 -16
- data/lib/mongo/cluster/topology/base.rb +218 -0
- data/lib/mongo/cluster/topology/no_replica_set_options.rb +34 -0
- data/lib/mongo/cluster/topology/replica_set_no_primary.rb +168 -0
- data/lib/mongo/cluster/topology/replica_set_with_primary.rb +27 -0
- data/lib/mongo/cluster/topology/sharded.rb +12 -115
- data/lib/mongo/cluster/topology/single.rb +18 -112
- data/lib/mongo/cluster/topology/unknown.rb +11 -152
- data/lib/mongo/collection.rb +2 -2
- data/lib/mongo/collection/view.rb +1 -1
- data/lib/mongo/collection/view/aggregation.rb +2 -2
- data/lib/mongo/collection/view/builder.rb +1 -1
- data/lib/mongo/collection/view/builder/aggregation.rb +1 -1
- data/lib/mongo/collection/view/builder/find_command.rb +1 -1
- data/lib/mongo/collection/view/builder/flags.rb +2 -2
- data/lib/mongo/collection/view/builder/map_reduce.rb +1 -1
- data/lib/mongo/collection/view/builder/modifiers.rb +2 -2
- data/lib/mongo/collection/view/builder/op_query.rb +1 -1
- data/lib/mongo/collection/view/change_stream.rb +4 -3
- data/lib/mongo/collection/view/change_stream/retryable.rb +1 -1
- data/lib/mongo/collection/view/explainable.rb +2 -2
- data/lib/mongo/collection/view/immutable.rb +2 -2
- data/lib/mongo/collection/view/iterable.rb +2 -2
- data/lib/mongo/collection/view/map_reduce.rb +2 -2
- data/lib/mongo/collection/view/readable.rb +3 -3
- data/lib/mongo/collection/view/writable.rb +2 -2
- data/lib/mongo/cursor.rb +8 -6
- data/lib/mongo/cursor/builder.rb +1 -1
- data/lib/mongo/cursor/builder/get_more_command.rb +1 -1
- data/lib/mongo/cursor/builder/kill_cursors_command.rb +1 -1
- data/lib/mongo/cursor/builder/op_get_more.rb +2 -2
- data/lib/mongo/cursor/builder/op_kill_cursors.rb +2 -2
- data/lib/mongo/database.rb +9 -4
- data/lib/mongo/database/view.rb +1 -1
- data/lib/mongo/dbref.rb +1 -1
- data/lib/mongo/error.rb +15 -2
- data/lib/mongo/error/bulk_write_error.rb +17 -1
- data/lib/mongo/error/change_stream_resumable.rb +1 -1
- data/lib/mongo/error/closed_stream.rb +1 -1
- data/lib/mongo/error/extra_file_chunk.rb +1 -1
- data/lib/mongo/error/file_not_found.rb +1 -1
- data/lib/mongo/error/handshake_error.rb +24 -0
- data/lib/mongo/error/insufficient_iteration_count.rb +1 -1
- data/lib/mongo/error/invalid_application_name.rb +1 -1
- data/lib/mongo/error/invalid_bulk_operation.rb +1 -1
- data/lib/mongo/error/invalid_bulk_operation_type.rb +1 -1
- data/lib/mongo/error/invalid_collection_name.rb +1 -1
- data/lib/mongo/error/invalid_database_name.rb +1 -1
- data/lib/mongo/error/invalid_document.rb +1 -1
- data/lib/mongo/error/invalid_file.rb +1 -1
- data/lib/mongo/error/invalid_file_revision.rb +1 -1
- data/lib/mongo/error/invalid_min_pool_size.rb +1 -1
- data/lib/mongo/error/invalid_nonce.rb +1 -1
- data/lib/mongo/error/invalid_read_option.rb +1 -1
- data/lib/mongo/error/invalid_replacement_document.rb +1 -1
- data/lib/mongo/error/invalid_server_preference.rb +1 -1
- data/lib/mongo/error/invalid_session.rb +1 -1
- data/lib/mongo/error/invalid_signature.rb +1 -1
- data/lib/mongo/error/invalid_transaction_operation.rb +2 -2
- data/lib/mongo/error/invalid_txt_record.rb +1 -1
- data/lib/mongo/error/invalid_update_document.rb +1 -1
- data/lib/mongo/error/invalid_uri.rb +1 -1
- data/lib/mongo/error/invalid_write_concern.rb +1 -1
- data/lib/mongo/error/lint_error.rb +1 -1
- data/lib/mongo/error/max_bson_size.rb +1 -1
- data/lib/mongo/error/max_message_size.rb +1 -1
- data/lib/mongo/error/mismatched_domain.rb +1 -1
- data/lib/mongo/error/missing_file_chunk.rb +1 -1
- data/lib/mongo/error/missing_resume_token.rb +1 -1
- data/lib/mongo/error/multi_index_drop.rb +1 -1
- data/lib/mongo/error/need_primary_server.rb +1 -1
- data/lib/mongo/error/no_server_available.rb +9 -5
- data/lib/mongo/error/no_srv_records.rb +1 -1
- data/lib/mongo/error/operation_failure.rb +2 -1
- data/lib/mongo/error/parser.rb +10 -1
- data/lib/mongo/error/session_ended.rb +27 -0
- data/lib/mongo/error/socket_error.rb +1 -1
- data/lib/mongo/error/socket_timeout_error.rb +1 -1
- data/lib/mongo/error/unchangeable_collection_option.rb +1 -1
- data/lib/mongo/error/unexpected_chunk_length.rb +1 -1
- data/lib/mongo/error/unexpected_response.rb +1 -1
- data/lib/mongo/error/unknown_payload_type.rb +1 -1
- data/lib/mongo/error/unsupported_array_filters.rb +1 -1
- data/lib/mongo/error/unsupported_collation.rb +1 -1
- data/lib/mongo/error/unsupported_features.rb +1 -1
- data/lib/mongo/error/unsupported_message_type.rb +1 -1
- data/lib/mongo/error/write_retryable.rb +1 -1
- data/lib/mongo/event.rb +3 -4
- data/lib/mongo/event/base.rb +6 -3
- data/lib/mongo/event/description_changed.rb +7 -27
- data/lib/mongo/event/listeners.rb +1 -1
- data/lib/mongo/event/publisher.rb +1 -1
- data/lib/mongo/event/subscriber.rb +1 -1
- data/lib/mongo/grid.rb +1 -1
- data/lib/mongo/grid/file.rb +1 -1
- data/lib/mongo/grid/file/chunk.rb +2 -2
- data/lib/mongo/grid/file/info.rb +8 -2
- data/lib/mongo/grid/fs_bucket.rb +1 -1
- data/lib/mongo/grid/stream.rb +1 -1
- data/lib/mongo/grid/stream/read.rb +1 -1
- data/lib/mongo/grid/stream/write.rb +1 -1
- data/lib/mongo/id.rb +64 -0
- data/lib/mongo/index.rb +1 -1
- data/lib/mongo/index/view.rb +1 -1
- data/lib/mongo/lint.rb +44 -5
- data/lib/mongo/loggable.rb +1 -1
- data/lib/mongo/logger.rb +1 -1
- data/lib/mongo/monitoring.rb +34 -10
- data/lib/mongo/monitoring/command_log_subscriber.rb +1 -1
- data/lib/mongo/monitoring/event.rb +4 -1
- data/lib/mongo/monitoring/event/command_failed.rb +1 -1
- data/lib/mongo/monitoring/event/command_started.rb +2 -2
- data/lib/mongo/monitoring/event/command_succeeded.rb +1 -1
- data/lib/mongo/monitoring/event/secure.rb +2 -2
- data/lib/mongo/monitoring/event/server_closed.rb +14 -1
- data/lib/mongo/monitoring/event/server_description_changed.rb +16 -1
- data/lib/mongo/monitoring/event/server_heartbeat_failed.rb +71 -0
- data/lib/mongo/monitoring/event/server_heartbeat_started.rb +55 -0
- data/lib/mongo/monitoring/event/server_heartbeat_succeeded.rb +63 -0
- data/lib/mongo/monitoring/event/server_opening.rb +8 -4
- data/lib/mongo/monitoring/event/topology_changed.rb +9 -6
- data/lib/mongo/monitoring/event/topology_closed.rb +14 -1
- data/lib/mongo/monitoring/event/topology_opening.rb +8 -4
- data/lib/mongo/monitoring/publishable.rb +3 -35
- data/lib/mongo/monitoring/sdam_log_subscriber.rb +1 -1
- data/lib/mongo/monitoring/server_closed_log_subscriber.rb +1 -1
- data/lib/mongo/monitoring/server_description_changed_log_subscriber.rb +1 -1
- data/lib/mongo/monitoring/server_opening_log_subscriber.rb +1 -1
- data/lib/mongo/monitoring/topology_changed_log_subscriber.rb +4 -4
- data/lib/mongo/monitoring/topology_closed_log_subscriber.rb +30 -0
- data/lib/mongo/monitoring/topology_opening_log_subscriber.rb +2 -2
- data/lib/mongo/operation.rb +8 -0
- data/lib/mongo/operation/aggregate.rb +3 -20
- data/lib/mongo/operation/aggregate/command.rb +1 -1
- data/lib/mongo/operation/aggregate/op_msg.rb +4 -30
- data/lib/mongo/operation/aggregate/result.rb +2 -2
- data/lib/mongo/operation/collections_info.rb +1 -1
- data/lib/mongo/operation/collections_info/result.rb +2 -2
- data/lib/mongo/operation/command.rb +2 -19
- data/lib/mongo/operation/command/command.rb +1 -1
- data/lib/mongo/operation/command/op_msg.rb +2 -27
- data/lib/mongo/operation/count.rb +2 -19
- data/lib/mongo/operation/count/command.rb +1 -1
- data/lib/mongo/operation/count/op_msg.rb +2 -11
- data/lib/mongo/operation/create.rb +2 -19
- data/lib/mongo/operation/create/command.rb +1 -1
- data/lib/mongo/operation/create/op_msg.rb +3 -20
- data/lib/mongo/operation/create_index.rb +2 -19
- data/lib/mongo/operation/create_index/command.rb +1 -1
- data/lib/mongo/operation/create_index/op_msg.rb +3 -18
- data/lib/mongo/operation/create_user.rb +2 -19
- data/lib/mongo/operation/create_user/command.rb +1 -1
- data/lib/mongo/operation/create_user/op_msg.rb +3 -18
- data/lib/mongo/operation/delete.rb +1 -1
- data/lib/mongo/operation/delete/bulk_result.rb +2 -2
- data/lib/mongo/operation/delete/command.rb +1 -1
- data/lib/mongo/operation/delete/legacy.rb +1 -1
- data/lib/mongo/operation/delete/op_msg.rb +5 -23
- data/lib/mongo/operation/delete/result.rb +2 -2
- data/lib/mongo/operation/distinct.rb +2 -19
- data/lib/mongo/operation/distinct/command.rb +1 -1
- data/lib/mongo/operation/distinct/op_msg.rb +3 -20
- data/lib/mongo/operation/drop.rb +2 -19
- data/lib/mongo/operation/drop/command.rb +1 -1
- data/lib/mongo/operation/drop/op_msg.rb +3 -20
- data/lib/mongo/operation/drop_database.rb +2 -19
- data/lib/mongo/operation/drop_database/command.rb +1 -1
- data/lib/mongo/operation/drop_database/op_msg.rb +3 -20
- data/lib/mongo/operation/drop_index.rb +2 -19
- data/lib/mongo/operation/drop_index/command.rb +1 -1
- data/lib/mongo/operation/drop_index/op_msg.rb +3 -18
- data/lib/mongo/operation/explain.rb +2 -21
- data/lib/mongo/operation/explain/command.rb +1 -1
- data/lib/mongo/operation/explain/legacy.rb +1 -1
- data/lib/mongo/operation/explain/op_msg.rb +4 -30
- data/lib/mongo/operation/explain/result.rb +2 -2
- data/lib/mongo/operation/find.rb +2 -21
- data/lib/mongo/operation/find/command.rb +1 -1
- data/lib/mongo/operation/find/legacy.rb +1 -1
- data/lib/mongo/operation/find/legacy/result.rb +2 -2
- data/lib/mongo/operation/find/op_msg.rb +6 -30
- data/lib/mongo/operation/find/result.rb +2 -2
- data/lib/mongo/operation/get_more.rb +2 -11
- data/lib/mongo/operation/get_more/command.rb +1 -1
- data/lib/mongo/operation/get_more/legacy.rb +1 -1
- data/lib/mongo/operation/get_more/op_msg.rb +6 -30
- data/lib/mongo/operation/get_more/result.rb +2 -2
- data/lib/mongo/operation/indexes.rb +2 -21
- data/lib/mongo/operation/indexes/command.rb +1 -1
- data/lib/mongo/operation/indexes/legacy.rb +1 -1
- data/lib/mongo/operation/indexes/op_msg.rb +4 -30
- data/lib/mongo/operation/indexes/result.rb +2 -2
- data/lib/mongo/operation/insert.rb +1 -1
- data/lib/mongo/operation/insert/bulk_result.rb +2 -2
- data/lib/mongo/operation/insert/command.rb +1 -1
- data/lib/mongo/operation/insert/legacy.rb +1 -1
- data/lib/mongo/operation/insert/op_msg.rb +10 -23
- data/lib/mongo/operation/insert/result.rb +2 -2
- data/lib/mongo/operation/kill_cursors.rb +2 -21
- data/lib/mongo/operation/kill_cursors/command.rb +1 -1
- data/lib/mongo/operation/kill_cursors/legacy.rb +1 -1
- data/lib/mongo/operation/kill_cursors/op_msg.rb +3 -20
- data/lib/mongo/operation/list_collections.rb +2 -19
- data/lib/mongo/operation/list_collections/command.rb +1 -1
- data/lib/mongo/operation/list_collections/op_msg.rb +4 -28
- data/lib/mongo/operation/list_collections/result.rb +2 -2
- data/lib/mongo/operation/map_reduce.rb +2 -19
- data/lib/mongo/operation/map_reduce/command.rb +1 -1
- data/lib/mongo/operation/map_reduce/op_msg.rb +4 -30
- data/lib/mongo/operation/map_reduce/result.rb +2 -2
- data/lib/mongo/operation/op_msg_base.rb +30 -0
- data/lib/mongo/operation/parallel_scan.rb +2 -19
- data/lib/mongo/operation/parallel_scan/command.rb +1 -1
- data/lib/mongo/operation/parallel_scan/op_msg.rb +4 -28
- data/lib/mongo/operation/parallel_scan/result.rb +2 -2
- data/lib/mongo/operation/remove_user.rb +2 -19
- data/lib/mongo/operation/remove_user/command.rb +1 -1
- data/lib/mongo/operation/remove_user/op_msg.rb +3 -18
- data/lib/mongo/operation/result.rb +14 -2
- data/lib/mongo/operation/shared/bypass_document_validation.rb +1 -1
- data/lib/mongo/operation/shared/causal_consistency_supported.rb +14 -6
- data/lib/mongo/operation/shared/executable.rb +10 -3
- data/lib/mongo/operation/shared/executable_no_validate.rb +30 -0
- data/lib/mongo/operation/shared/executable_transaction_label.rb +34 -0
- data/lib/mongo/operation/shared/idable.rb +1 -1
- data/lib/mongo/operation/shared/limited.rb +1 -1
- data/lib/mongo/operation/shared/object_id_generator.rb +1 -1
- data/lib/mongo/operation/shared/op_msg_or_command.rb +42 -0
- data/lib/mongo/operation/shared/op_msg_or_find_command.rb +45 -0
- data/lib/mongo/operation/shared/op_msg_or_list_indexes_command.rb +45 -0
- data/lib/mongo/operation/shared/polymorphic_lookup.rb +33 -0
- data/lib/mongo/operation/shared/polymorphic_result.rb +32 -0
- data/lib/mongo/operation/shared/read_preference_supported.rb +1 -1
- data/lib/mongo/operation/shared/result/aggregatable.rb +2 -2
- data/lib/mongo/operation/shared/sessions_supported.rb +24 -4
- data/lib/mongo/operation/shared/specifiable.rb +5 -3
- data/lib/mongo/operation/shared/write.rb +1 -1
- data/lib/mongo/operation/shared/write_concern_supported.rb +1 -1
- data/lib/mongo/operation/update.rb +1 -1
- data/lib/mongo/operation/update/bulk_result.rb +2 -2
- data/lib/mongo/operation/update/command.rb +1 -1
- data/lib/mongo/operation/update/legacy.rb +1 -1
- data/lib/mongo/operation/update/legacy/result.rb +2 -2
- data/lib/mongo/operation/update/op_msg.rb +5 -23
- data/lib/mongo/operation/update/result.rb +2 -2
- data/lib/mongo/operation/update_user.rb +2 -19
- data/lib/mongo/operation/update_user/command.rb +1 -1
- data/lib/mongo/operation/update_user/op_msg.rb +3 -18
- data/lib/mongo/operation/users_info.rb +2 -19
- data/lib/mongo/operation/users_info/command.rb +1 -1
- data/lib/mongo/operation/users_info/op_msg.rb +4 -28
- data/lib/mongo/operation/users_info/result.rb +2 -2
- data/lib/mongo/options.rb +1 -1
- data/lib/mongo/options/mapper.rb +10 -3
- data/lib/mongo/options/redacted.rb +1 -1
- data/lib/mongo/protocol/bit_vector.rb +1 -1
- data/lib/mongo/protocol/compressed.rb +2 -2
- data/lib/mongo/protocol/delete.rb +1 -1
- data/lib/mongo/protocol/get_more.rb +1 -1
- data/lib/mongo/protocol/insert.rb +1 -1
- data/lib/mongo/protocol/kill_cursors.rb +1 -1
- data/lib/mongo/protocol/message.rb +4 -9
- data/lib/mongo/protocol/msg.rb +2 -2
- data/lib/mongo/protocol/query.rb +1 -1
- data/lib/mongo/protocol/registry.rb +1 -1
- data/lib/mongo/protocol/reply.rb +1 -1
- data/lib/mongo/protocol/serializers.rb +1 -1
- data/lib/mongo/protocol/update.rb +1 -1
- data/lib/mongo/retryable.rb +40 -14
- data/lib/mongo/semaphore.rb +46 -0
- data/lib/mongo/server.rb +159 -44
- data/lib/mongo/{cluster → server}/app_metadata.rb +26 -13
- data/lib/mongo/server/connectable.rb +9 -13
- data/lib/mongo/server/connection.rb +143 -71
- data/lib/mongo/server/connection_pool.rb +25 -20
- data/lib/mongo/server/connection_pool/queue.rb +163 -46
- data/lib/mongo/server/context.rb +13 -13
- data/lib/mongo/server/description.rb +93 -48
- data/lib/mongo/server/description/features.rb +22 -3
- data/lib/mongo/server/monitor.rb +143 -74
- data/lib/mongo/server/monitor/app_metadata.rb +34 -0
- data/lib/mongo/server/monitor/connection.rb +42 -26
- data/lib/mongo/server/round_trip_time_averager.rb +64 -0
- data/lib/mongo/server_selector.rb +1 -1
- data/lib/mongo/server_selector/nearest.rb +1 -1
- data/lib/mongo/server_selector/primary.rb +1 -1
- data/lib/mongo/server_selector/primary_preferred.rb +1 -1
- data/lib/mongo/server_selector/secondary.rb +1 -1
- data/lib/mongo/server_selector/secondary_preferred.rb +1 -1
- data/lib/mongo/server_selector/selectable.rb +38 -13
- data/lib/mongo/session.rb +189 -40
- data/lib/mongo/session/server_session.rb +18 -7
- data/lib/mongo/session/session_pool.rb +1 -1
- data/lib/mongo/socket.rb +1 -1
- data/lib/mongo/socket/ssl.rb +46 -7
- data/lib/mongo/socket/tcp.rb +1 -1
- data/lib/mongo/socket/unix.rb +1 -1
- data/lib/mongo/uri.rb +304 -18
- data/lib/mongo/uri/srv_protocol.rb +1 -1
- data/lib/mongo/version.rb +2 -2
- data/lib/mongo/write_concern.rb +6 -6
- data/lib/mongo/write_concern/acknowledged.rb +2 -4
- data/lib/mongo/write_concern/{normalizable.rb → base.rb} +5 -6
- data/lib/mongo/write_concern/unacknowledged.rb +2 -4
- data/mongo.gemspec +1 -1
- data/spec/enterprise_auth/kerberos_spec.rb +57 -0
- data/spec/integration/bulk_insert_spec.rb +4 -2
- data/spec/integration/change_stream_examples_spec.rb +5 -6
- data/spec/integration/change_stream_spec.rb +17 -14
- data/spec/integration/client_connectivity_spec.rb +38 -0
- data/spec/integration/client_construction_spec.rb +94 -0
- data/spec/integration/command_monitoring_spec.rb +18 -30
- data/spec/integration/connect_single_rs_name_spec.rb +67 -0
- data/spec/integration/connection_spec.rb +209 -0
- data/spec/integration/cursor_reaping_spec.rb +95 -0
- data/spec/integration/docs_examples_spec.rb +6 -5
- data/spec/integration/heartbeat_events_spec.rb +116 -0
- data/spec/integration/retryable_writes_spec.rb +18 -8
- data/spec/integration/sdam_events_spec.rb +47 -0
- data/spec/integration/server_description_spec.rb +48 -0
- data/spec/integration/time_zone_querying_spec.rb +52 -0
- data/spec/lite_spec_helper.rb +74 -19
- data/spec/mongo/address_spec.rb +17 -7
- data/spec/mongo/auth/cr_spec.rb +8 -5
- data/spec/mongo/auth/ldap_spec.rb +9 -6
- data/spec/mongo/auth/scram/conversation_spec.rb +4 -1
- data/spec/mongo/auth/scram/negotiation_spec.rb +68 -110
- data/spec/mongo/auth/scram_spec.rb +8 -5
- data/spec/mongo/auth/user/view_spec.rb +5 -5
- data/spec/mongo/auth/x509_spec.rb +9 -6
- data/spec/mongo/bulk_write_spec.rb +32 -22
- data/spec/mongo/client_construction_spec.rb +1164 -0
- data/spec/mongo/client_spec.rb +62 -1000
- data/spec/mongo/cluster/cursor_reaper_spec.rb +2 -2
- data/spec/mongo/cluster/topology/replica_set_spec.rb +186 -251
- data/spec/mongo/cluster/topology/sharded_spec.rb +48 -50
- data/spec/mongo/cluster/topology/single_spec.rb +62 -22
- data/spec/mongo/cluster/topology/unknown_spec.rb +30 -115
- data/spec/mongo/cluster/topology_spec.rb +111 -13
- data/spec/mongo/cluster_spec.rb +195 -246
- data/spec/mongo/collection/view/aggregation_spec.rb +7 -8
- data/spec/mongo/collection/view/change_stream_spec.rb +18 -7
- data/spec/mongo/collection/view/explainable_spec.rb +1 -1
- data/spec/mongo/collection/view/immutable_spec.rb +1 -1
- data/spec/mongo/collection/view/map_reduce_spec.rb +7 -8
- data/spec/mongo/collection/view/readable_spec.rb +7 -8
- data/spec/mongo/collection/view/writable_spec.rb +1 -1
- data/spec/mongo/collection/view_spec.rb +2 -5
- data/spec/mongo/collection_spec.rb +41 -48
- data/spec/mongo/cursor/builder/get_more_command_spec.rb +1 -1
- data/spec/mongo/cursor/builder/op_get_more_spec.rb +1 -1
- data/spec/mongo/cursor_spec.rb +51 -25
- data/spec/mongo/database_spec.rb +25 -37
- data/spec/mongo/error/no_server_available_spec.rb +22 -0
- data/spec/mongo/error/operation_failure_spec.rb +70 -0
- data/spec/mongo/error/parser_spec.rb +44 -10
- data/spec/mongo/grid/file/info_spec.rb +3 -3
- data/spec/mongo/grid/fs_bucket_spec.rb +18 -53
- data/spec/mongo/grid/stream/read_spec.rb +9 -15
- data/spec/mongo/grid/stream/write_spec.rb +11 -23
- data/spec/mongo/id_spec.rb +35 -0
- data/spec/mongo/index/view_spec.rb +11 -72
- data/spec/mongo/lint_spec.rb +76 -0
- data/spec/mongo/monitoring/event/command_failed_spec.rb +1 -1
- data/spec/mongo/monitoring/event/command_started_spec.rb +1 -1
- data/spec/mongo/monitoring/event/command_succeeded_spec.rb +1 -1
- data/spec/mongo/monitoring/event/secure_spec.rb +1 -1
- data/spec/mongo/monitoring/event/server_closed_spec.rb +35 -0
- data/spec/mongo/monitoring/event/server_description_changed_spec.rb +38 -0
- data/spec/mongo/monitoring/event/server_heartbeat_failed_spec.rb +31 -0
- data/spec/mongo/monitoring/event/server_heartbeat_started_spec.rb +31 -0
- data/spec/mongo/monitoring/event/server_heartbeat_succeeded_spec.rb +31 -0
- data/spec/mongo/monitoring/event/server_opening_spec.rb +35 -0
- data/spec/mongo/monitoring/event/topology_changed_spec.rb +41 -0
- data/spec/mongo/monitoring/event/topology_closed_spec.rb +35 -0
- data/spec/mongo/monitoring/event/topology_opening_spec.rb +35 -0
- data/spec/mongo/monitoring_spec.rb +2 -2
- data/spec/mongo/operation/aggregate_spec.rb +2 -2
- data/spec/mongo/operation/collections_info_spec.rb +2 -2
- data/spec/mongo/operation/command_spec.rb +1 -1
- data/spec/mongo/operation/create_index_spec.rb +8 -11
- data/spec/mongo/operation/create_user_spec.rb +6 -3
- data/spec/mongo/operation/delete/bulk_spec.rb +21 -12
- data/spec/mongo/operation/delete/command_spec.rb +3 -2
- data/spec/mongo/operation/delete/op_msg_spec.rb +32 -17
- data/spec/mongo/operation/delete_spec.rb +21 -10
- data/spec/mongo/operation/drop_index_spec.rb +5 -2
- data/spec/mongo/operation/find/legacy_spec.rb +3 -2
- data/spec/mongo/operation/get_more_spec.rb +2 -2
- data/spec/mongo/operation/indexes_spec.rb +3 -2
- data/spec/mongo/operation/insert/bulk_spec.rb +13 -3
- data/spec/mongo/operation/insert/command_spec.rb +3 -2
- data/spec/mongo/operation/insert/op_msg_spec.rb +34 -18
- data/spec/mongo/operation/insert_spec.rb +7 -6
- data/spec/mongo/operation/kill_cursors_spec.rb +2 -2
- data/spec/mongo/operation/map_reduce_spec.rb +2 -2
- data/spec/mongo/operation/remove_user_spec.rb +6 -2
- data/spec/mongo/operation/result_spec.rb +6 -3
- data/spec/mongo/operation/update/bulk_spec.rb +3 -3
- data/spec/mongo/operation/update/command_spec.rb +8 -7
- data/spec/mongo/operation/update/op_msg_spec.rb +36 -21
- data/spec/mongo/operation/update_spec.rb +8 -6
- data/spec/mongo/operation/update_user_spec.rb +6 -6
- data/spec/mongo/protocol/compressed_spec.rb +3 -2
- data/spec/mongo/protocol/delete_spec.rb +1 -1
- data/spec/mongo/protocol/get_more_spec.rb +1 -1
- data/spec/mongo/protocol/insert_spec.rb +1 -1
- data/spec/mongo/protocol/kill_cursors_spec.rb +1 -1
- data/spec/mongo/protocol/msg_spec.rb +14 -13
- data/spec/mongo/protocol/query_spec.rb +1 -1
- data/spec/mongo/protocol/update_spec.rb +1 -1
- data/spec/mongo/retryable_spec.rb +84 -0
- data/spec/mongo/{cluster → server}/app_metadata_spec.rb +15 -3
- data/spec/mongo/server/connection_auth_spec.rb +114 -0
- data/spec/mongo/server/connection_pool/queue_spec.rb +146 -30
- data/spec/mongo/server/connection_pool_spec.rb +11 -12
- data/spec/mongo/server/connection_spec.rb +339 -152
- data/spec/mongo/server/description_query_methods_spec.rb +288 -0
- data/spec/mongo/server/description_spec.rb +63 -240
- data/spec/mongo/server/monitor/app_metadata_spec.rb +16 -0
- data/spec/mongo/server/monitor/connection_spec.rb +31 -28
- data/spec/mongo/server/monitor_spec.rb +61 -32
- data/spec/mongo/server/round_trip_time_averager_spec.rb +43 -0
- data/spec/mongo/server_selector_spec.rb +106 -1
- data/spec/mongo/server_spec.rb +31 -12
- data/spec/mongo/session/session_pool_spec.rb +3 -1
- data/spec/mongo/session_spec.rb +64 -2
- data/spec/mongo/session_transaction_spec.rb +64 -0
- data/spec/mongo/socket/ssl_spec.rb +86 -10
- data/spec/mongo/uri/srv_protocol_spec.rb +40 -40
- data/spec/mongo/uri_spec.rb +74 -38
- data/spec/spec_helper.rb +39 -64
- data/spec/spec_tests/connection_string_spec.rb +4 -32
- data/spec/spec_tests/crud_spec.rb +12 -2
- data/spec/{support/change_streams_tests → spec_tests/data/change_streams}/change-streams-errors.yml +0 -0
- data/spec/{support/change_streams_tests → spec_tests/data/change_streams}/change-streams.yml +0 -0
- data/spec/{support → spec_tests/data}/command_monitoring/bulkWrite.yml +0 -0
- data/spec/{support → spec_tests/data}/command_monitoring/command.yml +0 -0
- data/spec/{support → spec_tests/data}/command_monitoring/deleteMany.yml +0 -0
- data/spec/{support → spec_tests/data}/command_monitoring/deleteOne.yml +0 -0
- data/spec/{support → spec_tests/data}/command_monitoring/find.yml +0 -0
- data/spec/{support → spec_tests/data}/command_monitoring/insertMany.yml +0 -0
- data/spec/{support → spec_tests/data}/command_monitoring/insertOne.yml +0 -0
- data/spec/{support → spec_tests/data}/command_monitoring/unacknowledgedBulkWrite.yml +0 -0
- data/spec/{support → spec_tests/data}/command_monitoring/updateMany.yml +0 -0
- data/spec/{support → spec_tests/data}/command_monitoring/updateOne.yml +0 -0
- data/spec/{support/connection_string_tests → spec_tests/data/connection_string}/invalid-uris.yml +0 -0
- data/spec/{support/connection_string_tests → spec_tests/data/connection_string}/valid-auth.yml +0 -0
- data/spec/{support/connection_string_tests → spec_tests/data/connection_string}/valid-db-with-dotted-name.yml +0 -0
- data/spec/{support/connection_string_tests → spec_tests/data/connection_string}/valid-host_identifiers.yml +0 -0
- data/spec/{support/connection_string_tests → spec_tests/data/connection_string}/valid-options.yml +0 -0
- data/spec/{support/connection_string_tests → spec_tests/data/connection_string}/valid-unix_socket-absolute.yml +0 -0
- data/spec/{support/connection_string_tests → spec_tests/data/connection_string}/valid-unix_socket-relative.yml +0 -0
- data/spec/{support/connection_string_tests → spec_tests/data/connection_string}/valid-warnings.yml +0 -0
- data/spec/{support/crud_tests → spec_tests/data/crud}/read/aggregate-collation.yml +0 -0
- data/spec/{support/crud_tests → spec_tests/data/crud}/read/aggregate-out.yml +6 -6
- data/spec/{support/crud_tests → spec_tests/data/crud}/read/aggregate.yml +0 -0
- data/spec/{support/crud_tests → spec_tests/data/crud}/read/count-collation.yml +0 -0
- data/spec/{support/crud_tests → spec_tests/data/crud}/read/count.yml +0 -0
- data/spec/{support/crud_tests → spec_tests/data/crud}/read/distinct-collation.yml +0 -0
- data/spec/{support/crud_tests → spec_tests/data/crud}/read/distinct.yml +0 -0
- data/spec/{support/crud_tests → spec_tests/data/crud}/read/find-collation.yml +0 -0
- data/spec/{support/crud_tests → spec_tests/data/crud}/read/find.yml +0 -0
- data/spec/{support/crud_tests → spec_tests/data/crud}/write/bulkWrite-arrayFilters.yml +0 -0
- data/spec/{support/crud_tests → spec_tests/data/crud}/write/deleteMany-collation.yml +0 -0
- data/spec/{support/crud_tests → spec_tests/data/crud}/write/deleteMany.yml +0 -0
- data/spec/{support/crud_tests → spec_tests/data/crud}/write/deleteOne-collation.yml +0 -0
- data/spec/{support/crud_tests → spec_tests/data/crud}/write/deleteOne.yml +0 -0
- data/spec/{support/crud_tests → spec_tests/data/crud}/write/findOneAndDelete-collation.yml +0 -0
- data/spec/{support/crud_tests → spec_tests/data/crud}/write/findOneAndDelete.yml +0 -0
- data/spec/{support/crud_tests → spec_tests/data/crud}/write/findOneAndReplace-collation.yml +0 -0
- data/spec/{support/crud_tests → spec_tests/data/crud}/write/findOneAndReplace-upsert.yml +0 -0
- data/spec/{support/crud_tests → spec_tests/data/crud}/write/findOneAndReplace-upsert_pre_2.6.yml +0 -0
- data/spec/{support/crud_tests → spec_tests/data/crud}/write/findOneAndReplace.yml +0 -0
- data/spec/{support/crud_tests → spec_tests/data/crud}/write/findOneAndUpdate-arrayFilters.yml +0 -0
- data/spec/{support/crud_tests → spec_tests/data/crud}/write/findOneAndUpdate-collation.yml +0 -0
- data/spec/{support/crud_tests → spec_tests/data/crud}/write/findOneAndUpdate.yml +0 -0
- data/spec/{support/crud_tests → spec_tests/data/crud}/write/insertMany.yml +0 -0
- data/spec/{support/crud_tests → spec_tests/data/crud}/write/insertOne.yml +0 -0
- data/spec/{support/crud_tests → spec_tests/data/crud}/write/replaceOne-collation.yml +0 -0
- data/spec/{support/crud_tests → spec_tests/data/crud}/write/replaceOne-pre_2.6.yml +0 -0
- data/spec/{support/crud_tests → spec_tests/data/crud}/write/replaceOne-upsert.yml +0 -0
- data/spec/{support/crud_tests → spec_tests/data/crud}/write/replaceOne.yml +0 -0
- data/spec/{support/crud_tests → spec_tests/data/crud}/write/updateMany-arrayFilters.yml +0 -0
- data/spec/{support/crud_tests → spec_tests/data/crud}/write/updateMany-collation.yml +0 -0
- data/spec/{support/crud_tests → spec_tests/data/crud}/write/updateMany-pre_2.6.yml +0 -0
- data/spec/{support/crud_tests → spec_tests/data/crud}/write/updateMany.yml +0 -0
- data/spec/{support/crud_tests → spec_tests/data/crud}/write/updateOne-arrayFilters.yml +0 -0
- data/spec/{support/crud_tests → spec_tests/data/crud}/write/updateOne-collation.yml +0 -0
- data/spec/{support/crud_tests → spec_tests/data/crud}/write/updateOne-pre_2.6.yml +0 -0
- data/spec/{support/crud_tests → spec_tests/data/crud}/write/updateOne.yml +0 -0
- data/spec/{support/dns_seedlist_discovery_tests → spec_tests/data/dns_seedlist_discovery}/longer-parent-in-return.yml +0 -0
- data/spec/{support/dns_seedlist_discovery_tests → spec_tests/data/dns_seedlist_discovery}/misformatted-option.yml +0 -0
- data/spec/{support/dns_seedlist_discovery_tests → spec_tests/data/dns_seedlist_discovery}/no-results.yml +0 -0
- data/spec/{support/dns_seedlist_discovery_tests → spec_tests/data/dns_seedlist_discovery}/not-enough-parts.yml +0 -0
- data/spec/{support/dns_seedlist_discovery_tests → spec_tests/data/dns_seedlist_discovery}/one-result-default-port.yml +0 -0
- data/spec/{support/dns_seedlist_discovery_tests → spec_tests/data/dns_seedlist_discovery}/one-txt-record-multiple-strings.yml +0 -0
- data/spec/{support/dns_seedlist_discovery_tests → spec_tests/data/dns_seedlist_discovery}/one-txt-record.yml +0 -0
- data/spec/{support/dns_seedlist_discovery_tests → spec_tests/data/dns_seedlist_discovery}/parent-part-mismatch1.yml +0 -0
- data/spec/{support/dns_seedlist_discovery_tests → spec_tests/data/dns_seedlist_discovery}/parent-part-mismatch2.yml +0 -0
- data/spec/{support/dns_seedlist_discovery_tests → spec_tests/data/dns_seedlist_discovery}/parent-part-mismatch3.yml +0 -0
- data/spec/{support/dns_seedlist_discovery_tests → spec_tests/data/dns_seedlist_discovery}/parent-part-mismatch4.yml +0 -0
- data/spec/{support/dns_seedlist_discovery_tests → spec_tests/data/dns_seedlist_discovery}/parent-part-mismatch5.yml +0 -0
- data/spec/{support/dns_seedlist_discovery_tests → spec_tests/data/dns_seedlist_discovery}/returned-parent-too-short.yml +0 -0
- data/spec/{support/dns_seedlist_discovery_tests → spec_tests/data/dns_seedlist_discovery}/returned-parent-wrong.yml +0 -0
- data/spec/{support/dns_seedlist_discovery_tests → spec_tests/data/dns_seedlist_discovery}/two-results-default-port.yml +0 -0
- data/spec/{support/dns_seedlist_discovery_tests → spec_tests/data/dns_seedlist_discovery}/two-results-nonstandard-port.yml +0 -0
- data/spec/{support/dns_seedlist_discovery_tests → spec_tests/data/dns_seedlist_discovery}/two-txt-records.yml +0 -0
- data/spec/{support/dns_seedlist_discovery_tests → spec_tests/data/dns_seedlist_discovery}/txt-record-not-allowed-option.yml +0 -0
- data/spec/{support/dns_seedlist_discovery_tests → spec_tests/data/dns_seedlist_discovery}/txt-record-with-overridden-ssl-option.yml +0 -0
- data/spec/{support/dns_seedlist_discovery_tests → spec_tests/data/dns_seedlist_discovery}/txt-record-with-overridden-uri-option.yml +0 -0
- data/spec/{support/dns_seedlist_discovery_tests → spec_tests/data/dns_seedlist_discovery}/txt-record-with-unallowed-option.yml +0 -0
- data/spec/{support/dns_seedlist_discovery_tests → spec_tests/data/dns_seedlist_discovery}/uri-with-port.yml +0 -0
- data/spec/{support/dns_seedlist_discovery_tests → spec_tests/data/dns_seedlist_discovery}/uri-with-two-hosts.yml +0 -0
- data/spec/{support/gridfs_tests → spec_tests/data/gridfs}/delete.yml +0 -0
- data/spec/{support/gridfs_tests → spec_tests/data/gridfs}/download.yml +0 -0
- data/spec/{support/gridfs_tests → spec_tests/data/gridfs}/download_by_name.yml +0 -0
- data/spec/{support/gridfs_tests → spec_tests/data/gridfs}/upload.yml +0 -0
- data/spec/{support → spec_tests/data}/max_staleness/ReplicaSetNoPrimary/DefaultNoMaxStaleness.yml +0 -0
- data/spec/{support → spec_tests/data}/max_staleness/ReplicaSetNoPrimary/Incompatible.yml +0 -0
- data/spec/{support → spec_tests/data}/max_staleness/ReplicaSetNoPrimary/LastUpdateTime.yml +0 -0
- data/spec/{support → spec_tests/data}/max_staleness/ReplicaSetNoPrimary/Nearest.yml +0 -0
- data/spec/{support → spec_tests/data}/max_staleness/ReplicaSetNoPrimary/Nearest2.yml +0 -0
- data/spec/{support → spec_tests/data}/max_staleness/ReplicaSetNoPrimary/NoKnownServers.yml +0 -0
- data/spec/{support → spec_tests/data}/max_staleness/ReplicaSetNoPrimary/PrimaryPreferred.yml +0 -0
- data/spec/{support → spec_tests/data}/max_staleness/ReplicaSetNoPrimary/PrimaryPreferred_tags.yml +0 -0
- data/spec/{support → spec_tests/data}/max_staleness/ReplicaSetNoPrimary/Secondary.yml +0 -0
- data/spec/{support → spec_tests/data}/max_staleness/ReplicaSetNoPrimary/SecondaryPreferred.yml +0 -0
- data/spec/{support → spec_tests/data}/max_staleness/ReplicaSetNoPrimary/SecondaryPreferred_tags.yml +0 -0
- data/spec/{support → spec_tests/data}/max_staleness/ReplicaSetNoPrimary/ZeroMaxStaleness.yml +0 -0
- data/spec/{support → spec_tests/data}/max_staleness/ReplicaSetWithPrimary/DefaultNoMaxStaleness.yml +0 -0
- data/spec/{support → spec_tests/data}/max_staleness/ReplicaSetWithPrimary/Incompatible.yml +0 -0
- data/spec/{support → spec_tests/data}/max_staleness/ReplicaSetWithPrimary/LastUpdateTime.yml +0 -0
- data/spec/{support → spec_tests/data}/max_staleness/ReplicaSetWithPrimary/LongHeartbeat.yml +0 -0
- data/spec/{support → spec_tests/data}/max_staleness/ReplicaSetWithPrimary/LongHeartbeat2.yml +0 -0
- data/spec/{support → spec_tests/data}/max_staleness/ReplicaSetWithPrimary/MaxStalenessTooSmall.yml +0 -0
- data/spec/{support → spec_tests/data}/max_staleness/ReplicaSetWithPrimary/MaxStalenessWithModePrimary.yml +0 -0
- data/spec/{support → spec_tests/data}/max_staleness/ReplicaSetWithPrimary/Nearest.yml +0 -0
- data/spec/{support → spec_tests/data}/max_staleness/ReplicaSetWithPrimary/Nearest2.yml +0 -0
- data/spec/{support → spec_tests/data}/max_staleness/ReplicaSetWithPrimary/Nearest_tags.yml +0 -0
- data/spec/{support → spec_tests/data}/max_staleness/ReplicaSetWithPrimary/PrimaryPreferred.yml +0 -0
- data/spec/{support → spec_tests/data}/max_staleness/ReplicaSetWithPrimary/PrimaryPreferred_incompatible.yml +0 -0
- data/spec/{support → spec_tests/data}/max_staleness/ReplicaSetWithPrimary/SecondaryPreferred.yml +0 -0
- data/spec/{support → spec_tests/data}/max_staleness/ReplicaSetWithPrimary/SecondaryPreferred_tags.yml +0 -0
- data/spec/{support → spec_tests/data}/max_staleness/ReplicaSetWithPrimary/SecondaryPreferred_tags2.yml +0 -0
- data/spec/{support → spec_tests/data}/max_staleness/ReplicaSetWithPrimary/Secondary_tags.yml +0 -0
- data/spec/{support → spec_tests/data}/max_staleness/ReplicaSetWithPrimary/Secondary_tags2.yml +0 -0
- data/spec/{support → spec_tests/data}/max_staleness/ReplicaSetWithPrimary/ZeroMaxStaleness.yml +0 -0
- data/spec/{support → spec_tests/data}/max_staleness/Sharded/Incompatible.yml +0 -0
- data/spec/{support → spec_tests/data}/max_staleness/Sharded/SmallMaxStaleness.yml +0 -0
- data/spec/{support → spec_tests/data}/max_staleness/Single/Incompatible.yml +0 -0
- data/spec/{support → spec_tests/data}/max_staleness/Single/SmallMaxStaleness.yml +0 -0
- data/spec/{support → spec_tests/data}/max_staleness/Unknown/SmallMaxStaleness.yml +0 -0
- data/spec/{support/retryable_writes_tests → spec_tests/data/retryable_writes}/bulkWrite-serverErrors.yml +0 -0
- data/spec/{support/retryable_writes_tests → spec_tests/data/retryable_writes}/bulkWrite.yml +0 -0
- data/spec/{support/retryable_writes_tests → spec_tests/data/retryable_writes}/deleteOne-serverErrors.yml +0 -0
- data/spec/{support/retryable_writes_tests → spec_tests/data/retryable_writes}/deleteOne.yml +0 -0
- data/spec/{support/retryable_writes_tests → spec_tests/data/retryable_writes}/findOneAndDelete-serverErrors.yml +0 -0
- data/spec/{support/retryable_writes_tests → spec_tests/data/retryable_writes}/findOneAndDelete.yml +0 -0
- data/spec/{support/retryable_writes_tests → spec_tests/data/retryable_writes}/findOneAndReplace-serverErrors.yml +0 -0
- data/spec/{support/retryable_writes_tests → spec_tests/data/retryable_writes}/findOneAndReplace.yml +0 -0
- data/spec/{support/retryable_writes_tests → spec_tests/data/retryable_writes}/findOneAndUpdate-serverErrors.yml +0 -0
- data/spec/{support/retryable_writes_tests → spec_tests/data/retryable_writes}/findOneAndUpdate.yml +0 -0
- data/spec/{support/retryable_writes_tests → spec_tests/data/retryable_writes}/insertMany-serverErrors.yml +0 -0
- data/spec/{support/retryable_writes_tests → spec_tests/data/retryable_writes}/insertMany.yml +0 -0
- data/spec/{support/retryable_writes_tests → spec_tests/data/retryable_writes}/insertOne-serverErrors.yml +0 -0
- data/spec/{support/retryable_writes_tests → spec_tests/data/retryable_writes}/insertOne.yml +0 -0
- data/spec/{support/retryable_writes_tests → spec_tests/data/retryable_writes}/replaceOne-serverErrors.yml +0 -0
- data/spec/{support/retryable_writes_tests → spec_tests/data/retryable_writes}/replaceOne.yml +0 -0
- data/spec/{support/retryable_writes_tests → spec_tests/data/retryable_writes}/updateOne-serverErrors.yml +0 -0
- data/spec/{support/retryable_writes_tests → spec_tests/data/retryable_writes}/updateOne.yml +0 -0
- data/spec/{support → spec_tests/data}/sdam/rs/compatible.yml +0 -0
- data/spec/spec_tests/data/sdam/rs/compatible_unknown.yml +31 -0
- data/spec/{support → spec_tests/data}/sdam/rs/discover_arbiters.yml +0 -0
- data/spec/{support → spec_tests/data}/sdam/rs/discover_passives.yml +0 -0
- data/spec/{support → spec_tests/data}/sdam/rs/discover_primary.yml +0 -0
- data/spec/{support → spec_tests/data}/sdam/rs/discover_secondary.yml +0 -0
- data/spec/{support → spec_tests/data}/sdam/rs/discovery.yml +0 -0
- data/spec/{support → spec_tests/data}/sdam/rs/equal_electionids.yml +2 -0
- data/spec/{support → spec_tests/data}/sdam/rs/ghost_discovered.yml +0 -0
- data/spec/{support → spec_tests/data}/sdam/rs/hosts_differ_from_seeds.yml +0 -0
- data/spec/spec_tests/data/sdam/rs/incompatible_arbiter.yml +32 -0
- data/spec/spec_tests/data/sdam/rs/incompatible_ghost.yml +32 -0
- data/spec/spec_tests/data/sdam/rs/incompatible_other.yml +32 -0
- data/spec/{support → spec_tests/data}/sdam/rs/ls_timeout.yml +0 -0
- data/spec/{support → spec_tests/data}/sdam/rs/member_reconfig.yml +0 -0
- data/spec/{support → spec_tests/data}/sdam/rs/member_standalone.yml +0 -0
- data/spec/{support → spec_tests/data}/sdam/rs/new_primary.yml +0 -0
- data/spec/{support → spec_tests/data}/sdam/rs/new_primary_new_electionid.yml +6 -0
- data/spec/{support → spec_tests/data}/sdam/rs/new_primary_new_setversion.yml +6 -0
- data/spec/{support → spec_tests/data}/sdam/rs/new_primary_wrong_set_name.yml +0 -0
- data/spec/{support → spec_tests/data}/sdam/rs/non_rs_member.yml +0 -0
- data/spec/{support → spec_tests/data}/sdam/rs/normalize_case.yml +0 -0
- data/spec/{support → spec_tests/data}/sdam/rs/normalize_case_me.yml +0 -0
- data/spec/{support → spec_tests/data}/sdam/rs/null_election_id.yml +7 -0
- data/spec/spec_tests/data/sdam/rs/primary_becomes_ghost.yml +63 -0
- data/spec/spec_tests/data/sdam/rs/primary_becomes_mongos.yml +56 -0
- data/spec/{support → spec_tests/data}/sdam/rs/primary_becomes_standalone.yml +0 -0
- data/spec/{support → spec_tests/data}/sdam/rs/primary_changes_set_name.yml +0 -0
- data/spec/{support → spec_tests/data}/sdam/rs/primary_disconnect.yml +0 -0
- data/spec/{support → spec_tests/data}/sdam/rs/primary_disconnect_electionid.yml +10 -0
- data/spec/{support → spec_tests/data}/sdam/rs/primary_disconnect_setversion.yml +10 -0
- data/spec/{support → spec_tests/data}/sdam/rs/primary_hint_from_secondary_with_mismatched_me.yml +0 -0
- data/spec/{support → spec_tests/data}/sdam/rs/primary_mismatched_me.yml +0 -0
- data/spec/{support → spec_tests/data}/sdam/rs/primary_reports_new_member.yml +0 -0
- data/spec/{support → spec_tests/data}/sdam/rs/primary_to_no_primary_mismatched_me.yml +0 -0
- data/spec/{support → spec_tests/data}/sdam/rs/primary_wrong_set_name.yml +0 -0
- data/spec/{support → spec_tests/data}/sdam/rs/response_from_removed.yml +0 -0
- data/spec/{support → spec_tests/data}/sdam/rs/rsother_discovered.yml +0 -0
- data/spec/{support → spec_tests/data}/sdam/rs/sec_not_auth.yml +0 -0
- data/spec/{support → spec_tests/data}/sdam/rs/secondary_ignore_ok_0.yml +0 -0
- data/spec/{support → spec_tests/data}/sdam/rs/secondary_mismatched_me.yml +0 -0
- data/spec/{support → spec_tests/data}/sdam/rs/secondary_wrong_set_name.yml +0 -0
- data/spec/{support → spec_tests/data}/sdam/rs/secondary_wrong_set_name_with_primary.yml +0 -0
- data/spec/spec_tests/data/sdam/rs/secondary_wrong_set_name_with_primary_second.yml +73 -0
- data/spec/{support → spec_tests/data}/sdam/rs/setversion_without_electionid.yml +2 -0
- data/spec/{support → spec_tests/data}/sdam/rs/stepdown_change_set_name.yml +0 -0
- data/spec/{support → spec_tests/data}/sdam/rs/too_new.yml +0 -0
- data/spec/{support → spec_tests/data}/sdam/rs/too_old.yml +0 -0
- data/spec/{support → spec_tests/data}/sdam/rs/unexpected_mongos.yml +0 -0
- data/spec/{support → spec_tests/data}/sdam/rs/use_setversion_without_electionid.yml +6 -0
- data/spec/{support → spec_tests/data}/sdam/rs/wrong_set_name.yml +0 -0
- data/spec/{support → spec_tests/data}/sdam/sharded/compatible.yml +0 -0
- data/spec/{support → spec_tests/data}/sdam/sharded/ls_timeout_mongos.yml +0 -0
- data/spec/{support → spec_tests/data}/sdam/sharded/mongos_disconnect.yml +0 -0
- data/spec/{support → spec_tests/data}/sdam/sharded/multiple_mongoses.yml +0 -0
- data/spec/{support → spec_tests/data}/sdam/sharded/non_mongos_removed.yml +0 -0
- data/spec/{support → spec_tests/data}/sdam/sharded/normalize_uri_case.yml +0 -0
- data/spec/{support → spec_tests/data}/sdam/sharded/single_mongos.yml +0 -0
- data/spec/{support → spec_tests/data}/sdam/sharded/too_new.yml +0 -0
- data/spec/{support → spec_tests/data}/sdam/sharded/too_old.yml +0 -0
- data/spec/{support → spec_tests/data}/sdam/single/compatible.yml +0 -0
- data/spec/{support → spec_tests/data}/sdam/single/direct_connection_external_ip.yml +0 -0
- data/spec/{support → spec_tests/data}/sdam/single/direct_connection_mongos.yml +0 -0
- data/spec/{support → spec_tests/data}/sdam/single/direct_connection_rsarbiter.yml +0 -0
- data/spec/{support → spec_tests/data}/sdam/single/direct_connection_rsprimary.yml +0 -0
- data/spec/{support → spec_tests/data}/sdam/single/direct_connection_rssecondary.yml +0 -0
- data/spec/{support → spec_tests/data}/sdam/single/direct_connection_slave.yml +0 -0
- data/spec/{support → spec_tests/data}/sdam/single/direct_connection_standalone.yml +0 -0
- data/spec/{support → spec_tests/data}/sdam/single/ls_timeout_standalone.yml +0 -0
- data/spec/{support → spec_tests/data}/sdam/single/not_ok_response.yml +0 -0
- data/spec/{support → spec_tests/data}/sdam/single/standalone_removed.yml +0 -0
- data/spec/{support → spec_tests/data}/sdam/single/too_new.yml +0 -0
- data/spec/{support → spec_tests/data}/sdam/single/too_old.yml +0 -0
- data/spec/{support → spec_tests/data}/sdam/single/unavailable_seed.yml +0 -0
- data/spec/spec_tests/data/sdam_monitoring/discovered_standalone.yml +72 -0
- data/spec/spec_tests/data/sdam_monitoring/replica_set_other_chain.yml +222 -0
- data/spec/spec_tests/data/sdam_monitoring/replica_set_other_change.yml +225 -0
- data/spec/spec_tests/data/sdam_monitoring/replica_set_other_seed.yml +233 -0
- data/spec/{support → spec_tests/data}/sdam_monitoring/replica_set_with_no_primary.yml +0 -0
- data/spec/{support → spec_tests/data}/sdam_monitoring/replica_set_with_primary.yml +0 -0
- data/spec/spec_tests/data/sdam_monitoring/replica_set_with_primary_and_secondary.yml +198 -0
- data/spec/spec_tests/data/sdam_monitoring/replica_set_with_primary_removal.yml +171 -0
- data/spec/{support → spec_tests/data}/sdam_monitoring/replica_set_with_removal.yml +0 -0
- data/spec/spec_tests/data/sdam_monitoring/replica_set_with_second_seed_removal.yml +106 -0
- data/spec/{support → spec_tests/data}/sdam_monitoring/required_replica_set.yml +23 -0
- data/spec/{support → spec_tests/data}/sdam_monitoring/standalone.yml +2 -2
- data/spec/spec_tests/data/sdam_monitoring/standalone_repeated.yml +86 -0
- data/spec/{support/server_selection/selection → spec_tests/data/server_selection}/ReplicaSetNoPrimary/read/Nearest.yml +0 -0
- data/spec/{support/server_selection/selection → spec_tests/data/server_selection}/ReplicaSetNoPrimary/read/Nearest_multiple.yml +0 -0
- data/spec/{support/server_selection/selection → spec_tests/data/server_selection}/ReplicaSetNoPrimary/read/Nearest_non_matching.yml +0 -0
- data/spec/{support/server_selection/selection → spec_tests/data/server_selection}/ReplicaSetNoPrimary/read/PossiblePrimary.yml +0 -0
- data/spec/{support/server_selection/selection → spec_tests/data/server_selection}/ReplicaSetNoPrimary/read/PossiblePrimaryNearest.yml +0 -0
- data/spec/{support/server_selection/selection → spec_tests/data/server_selection}/ReplicaSetNoPrimary/read/Primary.yml +0 -0
- data/spec/{support/server_selection/selection → spec_tests/data/server_selection}/ReplicaSetNoPrimary/read/PrimaryPreferred.yml +0 -0
- data/spec/{support/server_selection/selection → spec_tests/data/server_selection}/ReplicaSetNoPrimary/read/PrimaryPreferred_non_matching.yml +0 -0
- data/spec/{support/server_selection/selection → spec_tests/data/server_selection}/ReplicaSetNoPrimary/read/Secondary.yml +0 -0
- data/spec/{support/server_selection/selection → spec_tests/data/server_selection}/ReplicaSetNoPrimary/read/SecondaryPreferred.yml +0 -0
- data/spec/{support/server_selection/selection → spec_tests/data/server_selection}/ReplicaSetNoPrimary/read/SecondaryPreferred_non_matching.yml +0 -0
- data/spec/{support/server_selection/selection → spec_tests/data/server_selection}/ReplicaSetNoPrimary/read/Secondary_multi_tags.yml +0 -0
- data/spec/{support/server_selection/selection → spec_tests/data/server_selection}/ReplicaSetNoPrimary/read/Secondary_multi_tags2.yml +0 -0
- data/spec/{support/server_selection/selection → spec_tests/data/server_selection}/ReplicaSetNoPrimary/read/Secondary_non_matching.yml +0 -0
- data/spec/{support/server_selection/selection → spec_tests/data/server_selection}/ReplicaSetWithPrimary/read/Nearest.yml +0 -0
- data/spec/{support/server_selection/selection → spec_tests/data/server_selection}/ReplicaSetWithPrimary/read/Nearest_multiple.yml +0 -0
- data/spec/{support/server_selection/selection → spec_tests/data/server_selection}/ReplicaSetWithPrimary/read/Nearest_non_matching.yml +0 -0
- data/spec/{support/server_selection/selection → spec_tests/data/server_selection}/ReplicaSetWithPrimary/read/Primary.yml +0 -0
- data/spec/{support/server_selection/selection → spec_tests/data/server_selection}/ReplicaSetWithPrimary/read/PrimaryPreferred.yml +0 -0
- data/spec/{support/server_selection/selection → spec_tests/data/server_selection}/ReplicaSetWithPrimary/read/PrimaryPreferred_non_matching.yml +0 -0
- data/spec/{support/server_selection/selection → spec_tests/data/server_selection}/ReplicaSetWithPrimary/read/Secondary.yml +0 -0
- data/spec/{support/server_selection/selection → spec_tests/data/server_selection}/ReplicaSetWithPrimary/read/SecondaryPreferred.yml +0 -0
- data/spec/{support/server_selection/selection → spec_tests/data/server_selection}/ReplicaSetWithPrimary/read/SecondaryPreferred_non_matching.yml +0 -0
- data/spec/{support/server_selection/selection → spec_tests/data/server_selection}/ReplicaSetWithPrimary/read/SecondaryPreferred_tags.yml +0 -0
- data/spec/{support/server_selection/selection → spec_tests/data/server_selection}/ReplicaSetWithPrimary/read/Secondary_non_matching.yml +0 -0
- data/spec/{support/server_selection/selection → spec_tests/data/server_selection}/Sharded/read/Nearest.yml +0 -0
- data/spec/{support/server_selection/selection → spec_tests/data/server_selection}/Sharded/read/Primary.yml +0 -0
- data/spec/{support/server_selection/selection → spec_tests/data/server_selection}/Sharded/read/PrimaryPreferred.yml +0 -0
- data/spec/{support/server_selection/selection → spec_tests/data/server_selection}/Sharded/read/Secondary.yml +0 -0
- data/spec/{support/server_selection/selection → spec_tests/data/server_selection}/Sharded/read/SecondaryPreferred.yml +0 -0
- data/spec/{support/server_selection/selection → spec_tests/data/server_selection}/Single/read/SecondaryPreferred.yml +0 -0
- data/spec/{support/server_selection/selection → spec_tests/data/server_selection}/Unknown/read/SecondaryPreferred.yml +0 -0
- data/spec/{support/server_selection/rtt → spec_tests/data/server_selection_rtt}/first_value.yml +0 -0
- data/spec/{support/server_selection/rtt → spec_tests/data/server_selection_rtt}/first_value_zero.yml +0 -0
- data/spec/{support/server_selection/rtt → spec_tests/data/server_selection_rtt}/value_test_1.yml +0 -0
- data/spec/{support/server_selection/rtt → spec_tests/data/server_selection_rtt}/value_test_2.yml +0 -0
- data/spec/{support/server_selection/rtt → spec_tests/data/server_selection_rtt}/value_test_3.yml +0 -0
- data/spec/{support/server_selection/rtt → spec_tests/data/server_selection_rtt}/value_test_4.yml +0 -0
- data/spec/{support/server_selection/rtt → spec_tests/data/server_selection_rtt}/value_test_5.yml +0 -0
- data/spec/{support/transactions_tests → spec_tests/data/transactions}/abort.yml +0 -0
- data/spec/{support/transactions_tests → spec_tests/data/transactions}/bulk.yml +0 -0
- data/spec/{support/transactions_tests → spec_tests/data/transactions}/causal-consistency.yml +0 -0
- data/spec/{support/transactions_tests → spec_tests/data/transactions}/commit.yml +0 -0
- data/spec/{support/transactions_tests → spec_tests/data/transactions}/delete.yml +0 -0
- data/spec/{support/transactions_tests → spec_tests/data/transactions}/error-labels.yml +0 -0
- data/spec/{support/transactions_tests → spec_tests/data/transactions}/errors.yml +0 -0
- data/spec/{support/transactions_tests → spec_tests/data/transactions}/findOneAndDelete.yml +0 -0
- data/spec/{support/transactions_tests → spec_tests/data/transactions}/findOneAndReplace.yml +0 -0
- data/spec/{support/transactions_tests → spec_tests/data/transactions}/findOneAndUpdate.yml +0 -0
- data/spec/{support/transactions_tests → spec_tests/data/transactions}/insert.yml +0 -0
- data/spec/{support/transactions_tests → spec_tests/data/transactions}/isolation.yml +0 -0
- data/spec/{support/transactions_tests → spec_tests/data/transactions}/read-pref.yml +0 -0
- data/spec/{support/transactions_tests → spec_tests/data/transactions}/reads.yml +0 -0
- data/spec/{support/transactions_tests → spec_tests/data/transactions}/retryable-abort.yml +0 -0
- data/spec/{support/transactions_tests → spec_tests/data/transactions}/retryable-commit.yml +0 -0
- data/spec/{support/transactions_tests → spec_tests/data/transactions}/retryable-writes.yml +0 -0
- data/spec/{support/transactions_tests → spec_tests/data/transactions}/run-command.yml +0 -0
- data/spec/{support/transactions_tests → spec_tests/data/transactions}/transaction-options.yml +0 -0
- data/spec/{support/transactions_tests → spec_tests/data/transactions}/update.yml +0 -0
- data/spec/{support/transactions_tests → spec_tests/data/transactions}/write-concern.yml +0 -0
- data/spec/spec_tests/data/transactions_api/callback-aborts.yml +156 -0
- data/spec/spec_tests/data/transactions_api/callback-commits.yml +192 -0
- data/spec/spec_tests/data/transactions_api/callback-retry.yml +203 -0
- data/spec/spec_tests/data/transactions_api/commit-retry.yml +261 -0
- data/spec/spec_tests/data/transactions_api/commit-transienttransactionerror-4.2.yml +132 -0
- data/spec/spec_tests/data/transactions_api/commit-transienttransactionerror.yml +178 -0
- data/spec/spec_tests/data/transactions_api/commit-writeconcernerror.yml +269 -0
- data/spec/spec_tests/data/transactions_api/commit.yml +181 -0
- data/spec/spec_tests/data/transactions_api/transaction-options.yml +258 -0
- data/spec/spec_tests/data/uri_options/auth-options.yml +14 -0
- data/spec/spec_tests/data/uri_options/compression-options.yml +48 -0
- data/spec/spec_tests/data/uri_options/concern-options.yml +55 -0
- data/spec/spec_tests/data/uri_options/connection-options.yml +106 -0
- data/spec/spec_tests/data/uri_options/connection-pool-options.yml +26 -0
- data/spec/spec_tests/data/uri_options/read-preference-options.yml +42 -0
- data/spec/spec_tests/data/uri_options/tls-options.yml +89 -0
- data/spec/spec_tests/dns_seedlist_discovery_spec.rb +0 -40
- data/spec/spec_tests/gridfs_spec.rb +1 -1
- data/spec/spec_tests/max_staleness_spec.rb +21 -8
- data/spec/spec_tests/retryable_writes_spec.rb +6 -6
- data/spec/spec_tests/sdam_monitoring_spec.rb +38 -20
- data/spec/spec_tests/sdam_spec.rb +80 -15
- data/spec/spec_tests/server_selection_rtt_spec.rb +6 -63
- data/spec/spec_tests/server_selection_spec.rb +18 -3
- data/spec/spec_tests/transactions_api_spec.rb +60 -0
- data/spec/spec_tests/transactions_spec.rb +20 -13
- data/spec/spec_tests/uri_options_spec.rb +94 -0
- data/spec/support/authorization.rb +28 -167
- data/spec/support/change_streams.rb +7 -7
- data/spec/support/change_streams/operation.rb +1 -1
- data/spec/support/client_registry.rb +170 -0
- data/spec/support/client_registry_macros.rb +14 -0
- data/spec/support/cluster_config.rb +49 -0
- data/spec/support/command_monitoring.rb +3 -3
- data/spec/support/common_shortcuts.rb +12 -0
- data/spec/support/connection_string.rb +99 -7
- data/spec/support/constraints.rb +24 -13
- data/spec/support/crud.rb +9 -97
- data/spec/support/crud/read.rb +2 -2
- data/spec/support/crud/verifier.rb +98 -0
- data/spec/support/crud/write.rb +2 -2
- data/spec/support/event_subscriber.rb +25 -13
- data/spec/support/gridfs.rb +8 -5
- data/spec/support/json_ext_formatter.rb +9 -0
- data/spec/support/lite_constraints.rb +27 -1
- data/spec/support/monitoring_ext.rb +16 -0
- data/spec/support/sdam_formatter_integration.rb +110 -0
- data/spec/support/sdam_monitoring.rb +77 -17
- data/spec/support/server_discovery_and_monitoring.rb +43 -20
- data/spec/support/server_selection.rb +3 -13
- data/spec/support/server_selection_rtt.rb +10 -10
- data/spec/support/shared/server_selector.rb +13 -41
- data/spec/support/shared/session.rb +44 -22
- data/spec/support/spec_config.rb +186 -11
- data/spec/support/spec_setup.rb +61 -0
- data/spec/support/transactions.rb +79 -145
- data/spec/support/transactions/operation.rb +53 -14
- data/spec/support/transactions/verifier.rb +94 -0
- metadata +712 -565
- metadata.gz.sig +0 -0
- data/lib/mongo/cluster/topology/replica_set.rb +0 -339
- data/lib/mongo/event/member_discovered.rb +0 -67
- data/lib/mongo/event/primary_elected.rb +0 -55
- data/lib/mongo/event/standalone_discovered.rb +0 -53
- data/lib/mongo/server/description/inspector.rb +0 -81
- data/lib/mongo/server/description/inspector/description_changed.rb +0 -57
- data/lib/mongo/server/description/inspector/member_discovered.rb +0 -59
- data/lib/mongo/server/description/inspector/primary_elected.rb +0 -60
- data/lib/mongo/server/description/inspector/standalone_discovered.rb +0 -56
- data/spec/mongo/server/description/inspector/description_changed_spec.rb +0 -78
- data/spec/mongo/server/description/inspector/primary_elected_spec.rb +0 -94
- data/spec/support/sdam/rs/set_version_without_electionid.yml +0 -69
- data/spec/support/travis.rb +0 -14
@@ -3,7 +3,7 @@ require 'spec_helper'
|
|
3
3
|
describe Mongo::Server::ConnectionPool do
|
4
4
|
|
5
5
|
let(:options) do
|
6
|
-
|
6
|
+
SpecConfig.instance.test_options.merge(max_pool_size: 2)
|
7
7
|
end
|
8
8
|
|
9
9
|
let(:address) do
|
@@ -18,14 +18,13 @@ describe Mongo::Server::ConnectionPool do
|
|
18
18
|
Mongo::Event::Listeners.new
|
19
19
|
end
|
20
20
|
|
21
|
-
|
22
|
-
double('topology')
|
23
|
-
end
|
21
|
+
declare_topology_double
|
24
22
|
|
25
23
|
let(:cluster) do
|
26
24
|
double('cluster').tap do |cl|
|
27
25
|
allow(cl).to receive(:topology).and_return(topology)
|
28
26
|
allow(cl).to receive(:app_metadata).and_return(app_metadata)
|
27
|
+
allow(cl).to receive(:options).and_return({})
|
29
28
|
end
|
30
29
|
end
|
31
30
|
|
@@ -222,13 +221,13 @@ describe Mongo::Server::ConnectionPool do
|
|
222
221
|
end
|
223
222
|
|
224
223
|
let(:options) do
|
225
|
-
{ user:
|
224
|
+
{ user: SpecConfig.instance.root_user.name, password: SpecConfig.instance.root_user.password }.merge(SpecConfig.instance.test_options).merge(max_pool_size: 1)
|
226
225
|
end
|
227
226
|
|
228
227
|
before do
|
229
228
|
t = Thread.new {
|
230
229
|
# Kill the thread when it's authenticating
|
231
|
-
allow(Mongo::Auth).to receive(:get) { t.kill
|
230
|
+
allow(Mongo::Auth).to receive(:get) { t.kill && !t.alive? }
|
232
231
|
pool.with_connection { |c| c.send(:ensure_connected) { |socket| socket } }
|
233
232
|
}
|
234
233
|
t.join
|
@@ -256,7 +255,7 @@ describe Mongo::Server::ConnectionPool do
|
|
256
255
|
context 'when there is a max_idle_time specified' do
|
257
256
|
|
258
257
|
let(:options) do
|
259
|
-
|
258
|
+
SpecConfig.instance.test_options.merge(max_pool_size: 2, max_idle_time: 0.5)
|
260
259
|
end
|
261
260
|
|
262
261
|
context 'when the connections have not been checked out' do
|
@@ -279,7 +278,7 @@ describe Mongo::Server::ConnectionPool do
|
|
279
278
|
context 'when min size is 0' do
|
280
279
|
|
281
280
|
let(:options) do
|
282
|
-
|
281
|
+
SpecConfig.instance.test_options.merge(max_pool_size: 2, min_pool_size: 0, max_idle_time: 0.5)
|
283
282
|
end
|
284
283
|
|
285
284
|
before do
|
@@ -302,7 +301,7 @@ describe Mongo::Server::ConnectionPool do
|
|
302
301
|
context 'when more than the number of min_size are checked out' do
|
303
302
|
|
304
303
|
let(:options) do
|
305
|
-
|
304
|
+
SpecConfig.instance.test_options.merge(max_pool_size: 5, min_pool_size: 3, max_idle_time: 0.5)
|
306
305
|
end
|
307
306
|
|
308
307
|
before do
|
@@ -330,7 +329,7 @@ describe Mongo::Server::ConnectionPool do
|
|
330
329
|
context 'when between 0 and min_size number of connections are checked out' do
|
331
330
|
|
332
331
|
let(:options) do
|
333
|
-
|
332
|
+
SpecConfig.instance.test_options.merge(max_pool_size: 5, min_pool_size: 3, max_idle_time: 0.5)
|
334
333
|
end
|
335
334
|
|
336
335
|
before do
|
@@ -369,7 +368,7 @@ describe Mongo::Server::ConnectionPool do
|
|
369
368
|
context 'when a stale connection is unsuccessfully reconnected' do
|
370
369
|
|
371
370
|
let(:options) do
|
372
|
-
|
371
|
+
SpecConfig.instance.test_options.merge(max_pool_size: 5, min_pool_size: 3, max_idle_time: 0.5)
|
373
372
|
end
|
374
373
|
|
375
374
|
before do
|
@@ -408,7 +407,7 @@ describe Mongo::Server::ConnectionPool do
|
|
408
407
|
context 'when exactly the min_size number of connections is checked out' do
|
409
408
|
|
410
409
|
let(:options) do
|
411
|
-
|
410
|
+
SpecConfig.instance.test_options.merge(max_pool_size: 5, min_pool_size: 3, max_idle_time: 0.5)
|
412
411
|
end
|
413
412
|
|
414
413
|
before do
|
@@ -1,6 +1,16 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
|
3
|
+
# fails intermittently in evergreen
|
4
|
+
describe Mongo::Server::Connection, retry: 3 do
|
5
|
+
class ConnectionSpecTestException < Exception; end
|
6
|
+
|
7
|
+
before(:all) do
|
8
|
+
ClientRegistry.instance.close_all_clients
|
9
|
+
end
|
10
|
+
|
11
|
+
after(:all) do
|
12
|
+
ClientRegistry.instance.close_all_clients
|
13
|
+
end
|
4
14
|
|
5
15
|
let(:address) do
|
6
16
|
default_address
|
@@ -15,45 +25,77 @@ describe Mongo::Server::Connection do
|
|
15
25
|
end
|
16
26
|
|
17
27
|
let(:app_metadata) do
|
18
|
-
Mongo::
|
28
|
+
Mongo::Server::AppMetadata.new(authorized_client.cluster.options)
|
19
29
|
end
|
20
30
|
|
21
31
|
let(:cluster) do
|
22
32
|
double('cluster').tap do |cl|
|
23
33
|
allow(cl).to receive(:topology).and_return(topology)
|
24
34
|
allow(cl).to receive(:app_metadata).and_return(app_metadata)
|
35
|
+
allow(cl).to receive(:options).and_return({})
|
25
36
|
allow(cl).to receive(:cluster_time).and_return(nil)
|
26
37
|
allow(cl).to receive(:update_cluster_time)
|
38
|
+
pool = double('pool')
|
39
|
+
allow(pool).to receive(:disconnect!)
|
40
|
+
allow(cl).to receive(:pool).and_return(pool)
|
27
41
|
end
|
28
42
|
end
|
29
43
|
|
30
|
-
|
31
|
-
double('topology')
|
32
|
-
end
|
44
|
+
declare_topology_double
|
33
45
|
|
34
46
|
let(:server) do
|
35
|
-
Mongo::Server.new(address, cluster, monitoring, listeners,
|
47
|
+
Mongo::Server.new(address, cluster, monitoring, listeners,
|
48
|
+
SpecConfig.instance.test_options.merge(monitoring_io: false),
|
49
|
+
)
|
36
50
|
end
|
37
51
|
|
38
|
-
let(:
|
39
|
-
|
52
|
+
let(:monitored_server) do
|
53
|
+
Mongo::Server.new(address, cluster, monitoring, listeners,
|
54
|
+
SpecConfig.instance.test_options
|
55
|
+
).tap do |server|
|
56
|
+
server.scan!
|
57
|
+
end
|
40
58
|
end
|
41
59
|
|
42
|
-
|
43
|
-
|
44
|
-
allow(pool).to receive(:disconnect!).and_return(true)
|
45
|
-
server.disconnect!
|
60
|
+
let(:pool) do
|
61
|
+
double('pool')
|
46
62
|
end
|
47
63
|
|
48
64
|
describe '#connect!' do
|
49
65
|
|
66
|
+
shared_examples_for 'keeps server type and topology' do
|
67
|
+
before do
|
68
|
+
# we want the server to not start in unknown state,
|
69
|
+
# hence scan it and transition to some other state here
|
70
|
+
server.scan!
|
71
|
+
end
|
72
|
+
|
73
|
+
it 'does not mark server unknown' do
|
74
|
+
expect(server).not_to receive(:unknown!)
|
75
|
+
error
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
shared_examples_for 'marks server unknown' do
|
80
|
+
before do
|
81
|
+
# we want the server to not start in unknown state,
|
82
|
+
# hence scan it and transition to some other state here
|
83
|
+
server.scan!
|
84
|
+
end
|
85
|
+
|
86
|
+
it 'marks server unknown' do
|
87
|
+
expect(server).to receive(:unknown!)
|
88
|
+
error
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
50
92
|
context 'when no socket exists' do
|
51
93
|
|
52
94
|
let(:connection) do
|
53
95
|
described_class.new(server, server.options)
|
54
96
|
end
|
55
97
|
|
56
|
-
let
|
98
|
+
let(:result) do
|
57
99
|
connection.connect!
|
58
100
|
end
|
59
101
|
|
@@ -66,12 +108,118 @@ describe Mongo::Server::Connection do
|
|
66
108
|
end
|
67
109
|
|
68
110
|
it 'creates a socket' do
|
111
|
+
result
|
69
112
|
expect(socket).to_not be_nil
|
70
113
|
end
|
71
114
|
|
72
115
|
it 'connects the socket' do
|
116
|
+
result
|
73
117
|
expect(socket).to be_alive
|
74
118
|
end
|
119
|
+
|
120
|
+
shared_examples_for 'failing connection' do
|
121
|
+
it 'raises an exception' do
|
122
|
+
expect(error).to be_a(Exception)
|
123
|
+
end
|
124
|
+
|
125
|
+
it 'clears socket' do
|
126
|
+
error
|
127
|
+
expect(connection.send(:socket)).to be nil
|
128
|
+
end
|
129
|
+
|
130
|
+
it 'attempts to reconnect after failure when asked' do
|
131
|
+
# for some reason referencing error here instead of
|
132
|
+
# copy pasting it like this doesn't work
|
133
|
+
expect(connection).to receive(:authenticate!).and_raise(exception)
|
134
|
+
expect do
|
135
|
+
connection.connect!
|
136
|
+
end.to raise_error(exception)
|
137
|
+
|
138
|
+
expect(connection).to receive(:authenticate!).and_raise(ConnectionSpecTestException)
|
139
|
+
expect do
|
140
|
+
connection.connect!
|
141
|
+
end.to raise_error(ConnectionSpecTestException)
|
142
|
+
end
|
143
|
+
end
|
144
|
+
|
145
|
+
context 'when #handshake! dependency raises a non-network exception' do
|
146
|
+
|
147
|
+
let(:exception) do
|
148
|
+
Mongo::Error::OperationFailure.new
|
149
|
+
end
|
150
|
+
|
151
|
+
let(:error) do
|
152
|
+
expect_any_instance_of(Mongo::Socket).to receive(:write).and_raise(exception)
|
153
|
+
begin
|
154
|
+
connection.connect!
|
155
|
+
rescue Exception => e
|
156
|
+
e
|
157
|
+
else
|
158
|
+
nil
|
159
|
+
end
|
160
|
+
end
|
161
|
+
|
162
|
+
it_behaves_like 'failing connection'
|
163
|
+
it_behaves_like 'keeps server type and topology'
|
164
|
+
end
|
165
|
+
|
166
|
+
context 'when #handshake! dependency raises a network exception' do
|
167
|
+
let(:exception) do
|
168
|
+
Mongo::Error::SocketError.new
|
169
|
+
end
|
170
|
+
|
171
|
+
let(:error) do
|
172
|
+
expect_any_instance_of(Mongo::Socket).to receive(:write).and_raise(exception)
|
173
|
+
begin
|
174
|
+
connection.connect!
|
175
|
+
rescue Exception => e
|
176
|
+
e
|
177
|
+
else
|
178
|
+
nil
|
179
|
+
end
|
180
|
+
end
|
181
|
+
|
182
|
+
it_behaves_like 'failing connection'
|
183
|
+
it_behaves_like 'marks server unknown'
|
184
|
+
end
|
185
|
+
|
186
|
+
context 'when #authenticate! raises an exception' do
|
187
|
+
let(:exception) do
|
188
|
+
Mongo::Error::OperationFailure.new
|
189
|
+
end
|
190
|
+
|
191
|
+
let(:error) do
|
192
|
+
expect(connection).to receive(:authenticate!).and_raise(exception)
|
193
|
+
begin
|
194
|
+
connection.connect!
|
195
|
+
rescue Exception => e
|
196
|
+
e
|
197
|
+
else
|
198
|
+
nil
|
199
|
+
end
|
200
|
+
end
|
201
|
+
|
202
|
+
it_behaves_like 'failing connection'
|
203
|
+
end
|
204
|
+
|
205
|
+
context 'when a non-Mongo exception is raised' do
|
206
|
+
let(:exception) do
|
207
|
+
SystemExit.new
|
208
|
+
end
|
209
|
+
|
210
|
+
let(:error) do
|
211
|
+
expect(connection).to receive(:authenticate!).and_raise(exception)
|
212
|
+
begin
|
213
|
+
connection.connect!
|
214
|
+
rescue Exception => e
|
215
|
+
e
|
216
|
+
else
|
217
|
+
nil
|
218
|
+
end
|
219
|
+
end
|
220
|
+
|
221
|
+
it_behaves_like 'failing connection'
|
222
|
+
end
|
75
223
|
end
|
76
224
|
|
77
225
|
context 'when a socket exists' do
|
@@ -80,50 +228,155 @@ describe Mongo::Server::Connection do
|
|
80
228
|
described_class.new(server, server.options)
|
81
229
|
end
|
82
230
|
|
83
|
-
before do
|
84
|
-
connection.connect!
|
85
|
-
connection.connect!
|
86
|
-
end
|
87
|
-
|
88
231
|
let(:socket) do
|
89
232
|
connection.send(:socket)
|
90
233
|
end
|
91
234
|
|
92
235
|
it 'keeps the socket alive' do
|
236
|
+
expect(connection.connect!).to be true
|
237
|
+
expect(connection.connect!).to be true
|
93
238
|
expect(socket).to be_alive
|
94
239
|
end
|
240
|
+
|
241
|
+
it 'retains socket object' do
|
242
|
+
expect(connection.connect!).to be true
|
243
|
+
socket_id = connection.send(:socket).object_id
|
244
|
+
expect(connection.connect!).to be true
|
245
|
+
new_socket_id = connection.send(:socket).object_id
|
246
|
+
expect(new_socket_id).to eq(socket_id)
|
247
|
+
end
|
248
|
+
end
|
249
|
+
|
250
|
+
shared_examples_for 'does not disconnect connection pool' do
|
251
|
+
it 'does not disconnect non-monitoring sockets' do
|
252
|
+
allow(cluster).to receive(:pool).with(server).and_return(pool)
|
253
|
+
expect(pool).not_to receive(:disconnect!)
|
254
|
+
error
|
255
|
+
end
|
256
|
+
end
|
257
|
+
|
258
|
+
shared_examples_for 'disconnects connection pool' do
|
259
|
+
it 'disconnects non-monitoring sockets' do
|
260
|
+
expect(cluster).to receive(:pool).with(server).and_return(pool)
|
261
|
+
expect(pool).to receive(:disconnect!).and_return(true)
|
262
|
+
error
|
263
|
+
end
|
264
|
+
end
|
265
|
+
|
266
|
+
let(:auth_mechanism) do
|
267
|
+
if ClusterConfig.instance.server_version >= '3'
|
268
|
+
Mongo::Auth::SCRAM
|
269
|
+
else
|
270
|
+
Mongo::Auth::CR
|
271
|
+
end
|
95
272
|
end
|
96
273
|
|
97
274
|
context 'when user credentials exist' do
|
98
275
|
|
276
|
+
let(:server) { monitored_server }
|
277
|
+
|
99
278
|
context 'when the user is not authorized' do
|
100
279
|
|
101
280
|
let(:connection) do
|
102
281
|
described_class.new(
|
103
282
|
server,
|
104
|
-
|
283
|
+
SpecConfig.instance.test_options.merge(
|
105
284
|
:user => 'notauser',
|
106
285
|
:password => 'password',
|
107
|
-
:database =>
|
286
|
+
:database => SpecConfig.instance.test_db,
|
108
287
|
:heartbeat_frequency => 30)
|
109
288
|
)
|
110
289
|
end
|
111
290
|
|
112
|
-
let
|
113
|
-
|
291
|
+
let(:error) do
|
292
|
+
begin
|
293
|
+
connection.send(:connect!)
|
294
|
+
rescue => ex
|
295
|
+
ex
|
296
|
+
else
|
297
|
+
nil
|
298
|
+
end
|
114
299
|
end
|
115
300
|
|
116
|
-
|
117
|
-
|
301
|
+
context 'not checking pool disconnection' do
|
302
|
+
before do
|
303
|
+
allow(cluster).to receive(:pool).with(server).and_return(pool)
|
304
|
+
allow(pool).to receive(:disconnect!).and_return(true)
|
305
|
+
end
|
306
|
+
|
307
|
+
it 'raises an error' do
|
308
|
+
expect(error).to be_a(Mongo::Auth::Unauthorized)
|
309
|
+
end
|
310
|
+
|
311
|
+
it_behaves_like 'disconnects connection pool'
|
312
|
+
it_behaves_like 'keeps server type and topology'
|
118
313
|
end
|
119
314
|
|
120
|
-
|
121
|
-
|
315
|
+
# need a separate context here, otherwise disconnect expectation
|
316
|
+
# is ignored due to allowing disconnects in the other context
|
317
|
+
context 'checking pool disconnection' do
|
318
|
+
it_behaves_like 'disconnects connection pool'
|
319
|
+
end
|
320
|
+
end
|
321
|
+
|
322
|
+
context 'socket timeout during auth' do
|
323
|
+
let(:connection) do
|
324
|
+
described_class.new(
|
325
|
+
server,
|
326
|
+
SpecConfig.instance.test_options.merge(
|
327
|
+
:user => SpecConfig.instance.test_user.name,
|
328
|
+
:password => SpecConfig.instance.test_user.password,
|
329
|
+
:database => SpecConfig.instance.test_user.database )
|
330
|
+
)
|
331
|
+
end
|
332
|
+
|
333
|
+
let(:error) do
|
334
|
+
expect_any_instance_of(auth_mechanism).to receive(:login).and_raise(Mongo::Error::SocketTimeoutError)
|
335
|
+
begin
|
336
|
+
connection.send(:connect!)
|
337
|
+
rescue => ex
|
338
|
+
ex
|
339
|
+
else
|
340
|
+
nil
|
341
|
+
end
|
342
|
+
end
|
343
|
+
|
344
|
+
it 'propagates the error' do
|
345
|
+
expect(error).to be_a(Mongo::Error::SocketTimeoutError)
|
346
|
+
end
|
347
|
+
|
348
|
+
it_behaves_like 'does not disconnect connection pool'
|
349
|
+
it_behaves_like 'keeps server type and topology'
|
350
|
+
end
|
351
|
+
|
352
|
+
context 'non-timeout socket exception during auth' do
|
353
|
+
let(:connection) do
|
354
|
+
described_class.new(
|
355
|
+
server,
|
356
|
+
SpecConfig.instance.test_options.merge(
|
357
|
+
:user => SpecConfig.instance.test_user.name,
|
358
|
+
:password => SpecConfig.instance.test_user.password,
|
359
|
+
:database => SpecConfig.instance.test_user.database )
|
360
|
+
)
|
122
361
|
end
|
123
362
|
|
124
|
-
|
125
|
-
|
363
|
+
let(:error) do
|
364
|
+
expect_any_instance_of(auth_mechanism).to receive(:login).and_raise(Mongo::Error::SocketError)
|
365
|
+
begin
|
366
|
+
connection.send(:connect!)
|
367
|
+
rescue => ex
|
368
|
+
ex
|
369
|
+
else
|
370
|
+
nil
|
371
|
+
end
|
372
|
+
end
|
373
|
+
|
374
|
+
it 'propagates the error' do
|
375
|
+
expect(error).to be_a(Mongo::Error::SocketError)
|
126
376
|
end
|
377
|
+
|
378
|
+
it_behaves_like 'disconnects connection pool'
|
379
|
+
it_behaves_like 'marks server unknown'
|
127
380
|
end
|
128
381
|
|
129
382
|
describe 'when the user is authorized' do
|
@@ -131,10 +384,10 @@ describe Mongo::Server::Connection do
|
|
131
384
|
let(:connection) do
|
132
385
|
described_class.new(
|
133
386
|
server,
|
134
|
-
|
135
|
-
:user =>
|
136
|
-
:password =>
|
137
|
-
:database =>
|
387
|
+
SpecConfig.instance.test_options.merge(
|
388
|
+
:user => SpecConfig.instance.test_user.name,
|
389
|
+
:password => SpecConfig.instance.test_user.password,
|
390
|
+
:database => SpecConfig.instance.test_user.database )
|
138
391
|
)
|
139
392
|
end
|
140
393
|
|
@@ -147,6 +400,7 @@ describe Mongo::Server::Connection do
|
|
147
400
|
end
|
148
401
|
end
|
149
402
|
end
|
403
|
+
|
150
404
|
end
|
151
405
|
|
152
406
|
describe '#disconnect!' do
|
@@ -181,13 +435,15 @@ describe Mongo::Server::Connection do
|
|
181
435
|
|
182
436
|
describe '#dispatch' do
|
183
437
|
|
438
|
+
let(:server) { monitored_server }
|
439
|
+
|
184
440
|
let!(:connection) do
|
185
441
|
described_class.new(
|
186
442
|
server,
|
187
|
-
|
188
|
-
:user =>
|
189
|
-
:password =>
|
190
|
-
:database =>
|
443
|
+
SpecConfig.instance.test_options.merge(
|
444
|
+
:user => SpecConfig.instance.test_user.name,
|
445
|
+
:password => SpecConfig.instance.test_user.password,
|
446
|
+
:database => SpecConfig.instance.test_user.database )
|
191
447
|
)
|
192
448
|
end
|
193
449
|
|
@@ -196,24 +452,25 @@ describe Mongo::Server::Connection do
|
|
196
452
|
end
|
197
453
|
|
198
454
|
let(:insert) do
|
199
|
-
Mongo::Protocol::Insert.new(
|
455
|
+
Mongo::Protocol::Insert.new(SpecConfig.instance.test_db, TEST_COLL, documents)
|
200
456
|
end
|
201
457
|
|
202
458
|
let(:query) do
|
203
|
-
Mongo::Protocol::Query.new(
|
459
|
+
Mongo::Protocol::Query.new(SpecConfig.instance.test_db, TEST_COLL, { 'name' => 'testing' })
|
204
460
|
end
|
205
461
|
|
206
462
|
context 'when providing a single message' do
|
207
463
|
|
208
464
|
let(:reply) do
|
209
|
-
connection.dispatch([
|
465
|
+
connection.dispatch([ query ])
|
210
466
|
end
|
211
467
|
|
212
|
-
|
468
|
+
before do
|
213
469
|
authorized_collection.delete_many
|
470
|
+
connection.dispatch([ insert ])
|
214
471
|
end
|
215
472
|
|
216
|
-
it 'it
|
473
|
+
it 'it dispatches the message to the socket' do
|
217
474
|
expect(reply.documents.first['name']).to eq('testing')
|
218
475
|
end
|
219
476
|
end
|
@@ -225,19 +482,21 @@ describe Mongo::Server::Connection do
|
|
225
482
|
end
|
226
483
|
|
227
484
|
let(:command) do
|
228
|
-
Mongo::Protocol::Query.new(
|
485
|
+
Mongo::Protocol::Query.new(SpecConfig.instance.test_db, '$cmd', selector, :limit => -1)
|
229
486
|
end
|
230
487
|
|
231
488
|
let(:reply) do
|
232
489
|
connection.dispatch([ insert, command ])
|
233
490
|
end
|
234
491
|
|
235
|
-
|
492
|
+
before do
|
236
493
|
authorized_collection.delete_many
|
237
494
|
end
|
238
495
|
|
239
|
-
it '
|
240
|
-
expect
|
496
|
+
it 'raises ArgumentError' do
|
497
|
+
expect do
|
498
|
+
reply
|
499
|
+
end.to raise_error(ArgumentError, 'Can only dispatch one message at a time')
|
241
500
|
end
|
242
501
|
end
|
243
502
|
|
@@ -248,25 +507,26 @@ describe Mongo::Server::Connection do
|
|
248
507
|
end
|
249
508
|
|
250
509
|
let(:insert) do
|
251
|
-
Mongo::Protocol::Insert.new(
|
510
|
+
Mongo::Protocol::Insert.new(SpecConfig.instance.test_db, TEST_COLL, documents)
|
252
511
|
end
|
253
512
|
|
254
513
|
let(:query_bob) do
|
255
|
-
Mongo::Protocol::Query.new(
|
514
|
+
Mongo::Protocol::Query.new(SpecConfig.instance.test_db, TEST_COLL, { name: 'bob' })
|
256
515
|
end
|
257
516
|
|
258
517
|
let(:query_alice) do
|
259
|
-
Mongo::Protocol::Query.new(
|
518
|
+
Mongo::Protocol::Query.new(SpecConfig.instance.test_db, TEST_COLL, { name: 'alice' })
|
260
519
|
end
|
261
520
|
|
262
|
-
|
521
|
+
before do
|
263
522
|
authorized_collection.delete_many
|
264
523
|
end
|
265
524
|
|
266
525
|
before do
|
526
|
+
connection.dispatch([ insert ])
|
267
527
|
# Fake a query for which we did not read the response. See RUBY-1117
|
268
528
|
allow(query_bob).to receive(:replyable?) { false }
|
269
|
-
connection.dispatch([
|
529
|
+
connection.dispatch([ query_bob ])
|
270
530
|
end
|
271
531
|
|
272
532
|
it 'raises an UnexpectedResponse error' do
|
@@ -281,7 +541,9 @@ describe Mongo::Server::Connection do
|
|
281
541
|
connection.dispatch([ query_alice ])
|
282
542
|
}.to raise_error(Mongo::Error::UnexpectedResponse)
|
283
543
|
|
284
|
-
|
544
|
+
docs = connection.dispatch([ query_alice ]).documents
|
545
|
+
expect(docs).to_not be_empty
|
546
|
+
expect(docs.first['name']).to eq('alice')
|
285
547
|
end
|
286
548
|
end
|
287
549
|
|
@@ -292,29 +554,26 @@ describe Mongo::Server::Connection do
|
|
292
554
|
end
|
293
555
|
|
294
556
|
let(:insert) do
|
295
|
-
Mongo::Protocol::Insert.new(
|
557
|
+
Mongo::Protocol::Insert.new(SpecConfig.instance.test_db, TEST_COLL, documents)
|
296
558
|
end
|
297
559
|
|
298
560
|
let(:query_bob) do
|
299
|
-
Mongo::Protocol::Query.new(
|
561
|
+
Mongo::Protocol::Query.new(SpecConfig.instance.test_db, TEST_COLL, { name: 'bob' })
|
300
562
|
end
|
301
563
|
|
302
564
|
let(:query_alice) do
|
303
|
-
Mongo::Protocol::Query.new(
|
565
|
+
Mongo::Protocol::Query.new(SpecConfig.instance.test_db, TEST_COLL, { name: 'alice' })
|
304
566
|
end
|
305
567
|
|
306
568
|
before do
|
307
|
-
connection.dispatch([ insert ])
|
308
|
-
end
|
309
|
-
|
310
|
-
after do
|
311
569
|
authorized_collection.delete_many
|
570
|
+
connection.dispatch([ insert ])
|
312
571
|
end
|
313
572
|
|
314
573
|
it 'closes the socket and does not use it for subsequent requests' do
|
315
574
|
t = Thread.new {
|
316
575
|
# Kill the thread just before the reply is read
|
317
|
-
allow(Mongo::Protocol::Reply).to receive(:deserialize_header) { t.kill
|
576
|
+
allow(Mongo::Protocol::Reply).to receive(:deserialize_header) { t.kill && !t.alive? }
|
318
577
|
connection.dispatch([ query_bob ])
|
319
578
|
}
|
320
579
|
t.join
|
@@ -357,7 +616,7 @@ describe Mongo::Server::Connection do
|
|
357
616
|
end
|
358
617
|
|
359
618
|
let(:command) do
|
360
|
-
Mongo::Protocol::Query.new(
|
619
|
+
Mongo::Protocol::Query.new(SpecConfig.instance.test_db, '$cmd', selector, :limit => -1)
|
361
620
|
end
|
362
621
|
|
363
622
|
let(:reply) do
|
@@ -406,13 +665,8 @@ describe Mongo::Server::Connection do
|
|
406
665
|
end
|
407
666
|
|
408
667
|
before do
|
409
|
-
authorized_collection.insert_one(a: 1)
|
410
|
-
end
|
411
|
-
|
412
|
-
after do
|
413
|
-
sleep(0.5)
|
414
668
|
authorized_collection.delete_many
|
415
|
-
|
669
|
+
authorized_collection.insert_one(a: 1)
|
416
670
|
end
|
417
671
|
|
418
672
|
it 'raises a timeout when it expires' do
|
@@ -436,17 +690,20 @@ describe Mongo::Server::Connection do
|
|
436
690
|
described_class.new(server, server.options)
|
437
691
|
end
|
438
692
|
|
439
|
-
let(:
|
440
|
-
|
693
|
+
let(:message) do
|
694
|
+
insert
|
441
695
|
end
|
442
696
|
|
443
697
|
before do
|
444
|
-
|
698
|
+
expect(message).to receive(:replyable?) { false }
|
699
|
+
connection.send(:deliver, message)
|
700
|
+
|
445
701
|
connection.send(:socket).instance_variable_set(:@timeout, -(Time.now.to_i))
|
446
702
|
end
|
447
703
|
|
448
704
|
let(:reply) do
|
449
|
-
connection.send(:
|
705
|
+
Mongo::Protocol::Message.deserialize(connection.send(:socket),
|
706
|
+
16*1024*1024, message.request_id)
|
450
707
|
end
|
451
708
|
|
452
709
|
it 'raises a timeout error' do
|
@@ -460,15 +717,12 @@ describe Mongo::Server::Connection do
|
|
460
717
|
context 'when the process is forked' do
|
461
718
|
|
462
719
|
let(:insert) do
|
463
|
-
Mongo::Protocol::Insert.new(
|
720
|
+
Mongo::Protocol::Insert.new(SpecConfig.instance.test_db, TEST_COLL, documents)
|
464
721
|
end
|
465
722
|
|
466
723
|
before do
|
467
|
-
expect(Process).to receive(:pid).at_least(:once).and_return(1)
|
468
|
-
end
|
469
|
-
|
470
|
-
after do
|
471
724
|
authorized_collection.delete_many
|
725
|
+
expect(Process).to receive(:pid).at_least(:once).and_return(1)
|
472
726
|
end
|
473
727
|
|
474
728
|
it 'disconnects the connection' do
|
@@ -568,18 +822,18 @@ describe Mongo::Server::Connection do
|
|
568
822
|
let(:connection) do
|
569
823
|
described_class.new(
|
570
824
|
server,
|
571
|
-
:user =>
|
572
|
-
:password =>
|
573
|
-
:database =>
|
825
|
+
:user => SpecConfig.instance.test_user.name,
|
826
|
+
:password => SpecConfig.instance.test_user.password,
|
827
|
+
:database => SpecConfig.instance.test_db,
|
574
828
|
:auth_mech => :mongodb_cr
|
575
829
|
)
|
576
830
|
end
|
577
831
|
|
578
832
|
let(:user) do
|
579
833
|
Mongo::Auth::User.new(
|
580
|
-
database:
|
581
|
-
user:
|
582
|
-
password:
|
834
|
+
database: SpecConfig.instance.test_db,
|
835
|
+
user: SpecConfig.instance.test_user.name,
|
836
|
+
password: SpecConfig.instance.test_user.password
|
583
837
|
)
|
584
838
|
end
|
585
839
|
|
@@ -589,73 +843,6 @@ describe Mongo::Server::Connection do
|
|
589
843
|
end
|
590
844
|
end
|
591
845
|
|
592
|
-
describe '#auth_mechanism' do
|
593
|
-
|
594
|
-
let(:connection) do
|
595
|
-
described_class.new(server, server.options)
|
596
|
-
end
|
597
|
-
|
598
|
-
let(:reply) do
|
599
|
-
double('reply').tap do |r|
|
600
|
-
allow(r).to receive(:documents).and_return([ ismaster ])
|
601
|
-
end
|
602
|
-
end
|
603
|
-
|
604
|
-
before do
|
605
|
-
connection.connect!
|
606
|
-
end
|
607
|
-
|
608
|
-
context 'when the ismaster response indicates the auth mechanism is :scram' do
|
609
|
-
|
610
|
-
let(:features) do
|
611
|
-
Mongo::Server::Description::Features.new(0..7)
|
612
|
-
end
|
613
|
-
|
614
|
-
context 'when the server auth mechanism is scram', if: scram_sha_1_enabled? && !scram_sha_256_enabled? do
|
615
|
-
|
616
|
-
it 'uses scram' do
|
617
|
-
allow(Mongo::Server::Description::Features).to receive(:new).and_return(features)
|
618
|
-
connection.send(:handshake!)
|
619
|
-
expect(connection.send(:default_mechanism)).to eq(:scram)
|
620
|
-
end
|
621
|
-
end
|
622
|
-
|
623
|
-
context 'when the server auth mechanism is the default (mongodb_cr)', unless: scram_sha_1_enabled? do
|
624
|
-
|
625
|
-
it 'uses scram' do
|
626
|
-
allow(Mongo::Server::Description::Features).to receive(:new).and_return(features)
|
627
|
-
connection.send(:handshake!)
|
628
|
-
expect(connection.send(:default_mechanism)).to eq(:scram)
|
629
|
-
end
|
630
|
-
end
|
631
|
-
end
|
632
|
-
|
633
|
-
context 'when the ismaster response indicates the auth mechanism is :mongodb_cr' do
|
634
|
-
|
635
|
-
let(:features) do
|
636
|
-
Mongo::Server::Description::Features.new(0..2)
|
637
|
-
end
|
638
|
-
|
639
|
-
context 'when the server auth mechanism is scram', if: scram_sha_1_enabled? && !scram_sha_256_enabled? do
|
640
|
-
|
641
|
-
it 'uses scram' do
|
642
|
-
allow(Mongo::Server::Description::Features).to receive(:new).and_return(features)
|
643
|
-
connection.send(:handshake!)
|
644
|
-
expect(connection.send(:default_mechanism)).to eq(:scram)
|
645
|
-
end
|
646
|
-
end
|
647
|
-
|
648
|
-
context 'when the server auth mechanism is the default (mongodb_cr)', unless: scram_sha_1_enabled? do
|
649
|
-
|
650
|
-
it 'uses mongodb_cr' do
|
651
|
-
allow(Mongo::Server::Description::Features).to receive(:new).and_return(features)
|
652
|
-
connection.send(:handshake!)
|
653
|
-
expect(connection.send(:default_mechanism)).to eq(:mongodb_cr)
|
654
|
-
end
|
655
|
-
end
|
656
|
-
end
|
657
|
-
end
|
658
|
-
|
659
846
|
context 'when different timeout options are set' do
|
660
847
|
|
661
848
|
let(:client) do
|
@@ -683,7 +870,7 @@ describe Mongo::Server::Connection do
|
|
683
870
|
context 'when a socket_timeout is in the options' do
|
684
871
|
|
685
872
|
let(:options) do
|
686
|
-
|
873
|
+
SpecConfig.instance.test_options.merge(connect_timeout: 3, socket_timeout: 5)
|
687
874
|
end
|
688
875
|
|
689
876
|
before do
|
@@ -702,7 +889,7 @@ describe Mongo::Server::Connection do
|
|
702
889
|
context 'when a socket_timeout is not in the options' do
|
703
890
|
|
704
891
|
let(:options) do
|
705
|
-
|
892
|
+
SpecConfig.instance.test_options.merge(connect_timeout: 3, socket_timeout: nil)
|
706
893
|
end
|
707
894
|
|
708
895
|
before do
|
@@ -724,7 +911,7 @@ describe Mongo::Server::Connection do
|
|
724
911
|
context 'when a socket_timeout is in the options' do
|
725
912
|
|
726
913
|
let(:options) do
|
727
|
-
|
914
|
+
SpecConfig.instance.test_options.merge(connect_timeout: nil, socket_timeout: 5)
|
728
915
|
end
|
729
916
|
|
730
917
|
before do
|
@@ -743,7 +930,7 @@ describe Mongo::Server::Connection do
|
|
743
930
|
context 'when a socket_timeout is not in the options' do
|
744
931
|
|
745
932
|
let(:options) do
|
746
|
-
|
933
|
+
SpecConfig.instance.test_options.merge(connect_timeout: nil, socket_timeout: nil)
|
747
934
|
end
|
748
935
|
|
749
936
|
before do
|