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
data/spec/mongo/client_spec.rb
CHANGED
@@ -1,89 +1,29 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
after do
|
6
|
-
begin; client.close; rescue; end
|
7
|
-
end
|
8
|
-
|
9
|
-
describe '.new' do
|
10
|
-
describe 'options' do
|
11
|
-
describe 'read' do
|
12
|
-
[
|
13
|
-
:primary, :primary_preferred, :secondary, :secondary_preferred, :nearest
|
14
|
-
].each do |sym|
|
15
|
-
it "accepts #{sym} as symbol" do
|
16
|
-
client = described_class.new(['127.0.0.1:27017'],
|
17
|
-
:read => {:mode => sym})
|
18
|
-
# the key got converted to a string here
|
19
|
-
expect(client.read_preference).to eq({'mode' => sym})
|
20
|
-
end
|
21
|
-
|
22
|
-
# string keys are not documented as being allowed
|
23
|
-
# but the code accepts them
|
24
|
-
it "accepts #{sym} as string" do
|
25
|
-
client = described_class.new(['127.0.0.1:27017'],
|
26
|
-
:read => {:mode => sym.to_s})
|
27
|
-
# the key got converted to a string here
|
28
|
-
# the value remains a string
|
29
|
-
expect(client.read_preference).to eq({'mode' => sym.to_s})
|
30
|
-
end
|
31
|
-
end
|
3
|
+
# NB: tests for .new, #initialize, #use, #with and #dup are in
|
4
|
+
# client_construction_spec.rb.
|
32
5
|
|
33
|
-
|
34
|
-
expect do
|
35
|
-
client = described_class.new(['127.0.0.1:27017'],
|
36
|
-
:read => {:mode => :bogus})
|
37
|
-
end.to raise_error(Mongo::Error::InvalidReadOption, 'Invalid read option: {"mode"=>:bogus}: mode bogus is not one of recognized modes')
|
38
|
-
end
|
39
|
-
|
40
|
-
it 'rejects bogus read preference as string' do
|
41
|
-
expect do
|
42
|
-
client = described_class.new(['127.0.0.1:27017'],
|
43
|
-
:read => {:mode => 'bogus'})
|
44
|
-
end.to raise_error(Mongo::Error::InvalidReadOption, 'Invalid read option: {"mode"=>"bogus"}: mode bogus is not one of recognized modes')
|
45
|
-
end
|
46
|
-
|
47
|
-
it 'rejects read option specified as a string' do
|
48
|
-
expect do
|
49
|
-
client = described_class.new(['127.0.0.1:27017'],
|
50
|
-
:read => 'primary')
|
51
|
-
end.to raise_error(Mongo::Error::InvalidReadOption, 'Invalid read option: primary: must be a hash')
|
52
|
-
end
|
53
|
-
|
54
|
-
it 'rejects read option specified as a symbol' do
|
55
|
-
expect do
|
56
|
-
client = described_class.new(['127.0.0.1:27017'],
|
57
|
-
:read => :primary)
|
58
|
-
end.to raise_error(Mongo::Error::InvalidReadOption, 'Invalid read option: primary: must be a hash')
|
59
|
-
end
|
60
|
-
end
|
61
|
-
end
|
62
|
-
end
|
6
|
+
describe Mongo::Client do
|
63
7
|
|
64
8
|
describe '#==' do
|
65
9
|
|
66
10
|
let(:client) do
|
67
|
-
|
11
|
+
new_local_client(
|
68
12
|
['127.0.0.1:27017'],
|
69
13
|
:read => { :mode => :primary },
|
70
|
-
:database =>
|
14
|
+
:database => SpecConfig.instance.test_db
|
71
15
|
)
|
72
16
|
end
|
73
17
|
|
74
18
|
context 'when the other is a client' do
|
75
19
|
|
76
|
-
after do
|
77
|
-
other.close
|
78
|
-
end
|
79
|
-
|
80
20
|
context 'when the options and cluster are equal' do
|
81
21
|
|
82
22
|
let(:other) do
|
83
|
-
|
23
|
+
new_local_client(
|
84
24
|
['127.0.0.1:27017'],
|
85
25
|
:read => { :mode => :primary },
|
86
|
-
:database =>
|
26
|
+
:database => SpecConfig.instance.test_db
|
87
27
|
)
|
88
28
|
end
|
89
29
|
|
@@ -95,10 +35,10 @@ describe Mongo::Client do
|
|
95
35
|
context 'when the options are not equal' do
|
96
36
|
|
97
37
|
let(:other) do
|
98
|
-
|
38
|
+
new_local_client(
|
99
39
|
['127.0.0.1:27017'],
|
100
40
|
:read => { :mode => :secondary },
|
101
|
-
:database =>
|
41
|
+
:database => SpecConfig.instance.test_db
|
102
42
|
)
|
103
43
|
end
|
104
44
|
|
@@ -110,10 +50,10 @@ describe Mongo::Client do
|
|
110
50
|
context 'when cluster is not equal' do
|
111
51
|
|
112
52
|
let(:other) do
|
113
|
-
|
53
|
+
new_local_client(
|
114
54
|
['127.0.0.1:27010'],
|
115
55
|
:read => { :mode => :primary },
|
116
|
-
:database =>
|
56
|
+
:database => SpecConfig.instance.test_db
|
117
57
|
)
|
118
58
|
end
|
119
59
|
|
@@ -134,7 +74,7 @@ describe Mongo::Client do
|
|
134
74
|
describe '#[]' do
|
135
75
|
|
136
76
|
let(:client) do
|
137
|
-
|
77
|
+
new_local_client(['127.0.0.1:27017'], :database => SpecConfig.instance.test_db)
|
138
78
|
end
|
139
79
|
|
140
80
|
shared_examples_for 'a collection switching object' do
|
@@ -170,26 +110,22 @@ describe Mongo::Client do
|
|
170
110
|
describe '#eql' do
|
171
111
|
|
172
112
|
let(:client) do
|
173
|
-
|
113
|
+
new_local_client(
|
174
114
|
['127.0.0.1:27017'],
|
175
115
|
:read => { :mode => :primary },
|
176
|
-
:database =>
|
116
|
+
:database => SpecConfig.instance.test_db
|
177
117
|
)
|
178
118
|
end
|
179
119
|
|
180
120
|
context 'when the other is a client' do
|
181
121
|
|
182
|
-
after do
|
183
|
-
other.close
|
184
|
-
end
|
185
|
-
|
186
122
|
context 'when the options and cluster are equal' do
|
187
123
|
|
188
124
|
let(:other) do
|
189
|
-
|
125
|
+
new_local_client(
|
190
126
|
['127.0.0.1:27017'],
|
191
127
|
:read => { :mode => :primary },
|
192
|
-
:database =>
|
128
|
+
:database => SpecConfig.instance.test_db
|
193
129
|
)
|
194
130
|
end
|
195
131
|
|
@@ -201,10 +137,10 @@ describe Mongo::Client do
|
|
201
137
|
context 'when the options are not equal' do
|
202
138
|
|
203
139
|
let(:other) do
|
204
|
-
|
140
|
+
new_local_client(
|
205
141
|
['127.0.0.1:27017'],
|
206
142
|
:read => { :mode => :secondary },
|
207
|
-
:database =>
|
143
|
+
:database => SpecConfig.instance.test_db
|
208
144
|
)
|
209
145
|
end
|
210
146
|
|
@@ -216,10 +152,10 @@ describe Mongo::Client do
|
|
216
152
|
context 'when the cluster is not equal' do
|
217
153
|
|
218
154
|
let(:other) do
|
219
|
-
|
155
|
+
new_local_client(
|
220
156
|
['127.0.0.1:27010'],
|
221
157
|
:read => { :mode => :primary },
|
222
|
-
:database =>
|
158
|
+
:database => SpecConfig.instance.test_db
|
223
159
|
)
|
224
160
|
end
|
225
161
|
|
@@ -232,10 +168,10 @@ describe Mongo::Client do
|
|
232
168
|
context 'when the other is not a client' do
|
233
169
|
|
234
170
|
let(:client) do
|
235
|
-
|
171
|
+
new_local_client(
|
236
172
|
['127.0.0.1:27017'],
|
237
173
|
:read => { :mode => :primary },
|
238
|
-
:database =>
|
174
|
+
:database => SpecConfig.instance.test_db
|
239
175
|
)
|
240
176
|
end
|
241
177
|
|
@@ -248,12 +184,12 @@ describe Mongo::Client do
|
|
248
184
|
describe '#hash' do
|
249
185
|
|
250
186
|
let(:client) do
|
251
|
-
|
187
|
+
new_local_client(
|
252
188
|
['127.0.0.1:27017'],
|
253
189
|
:read => { :mode => :primary },
|
254
190
|
:local_threshold => 0.010,
|
255
191
|
:server_selection_timeout => 10000,
|
256
|
-
:database =>
|
192
|
+
:database => SpecConfig.instance.test_db
|
257
193
|
)
|
258
194
|
end
|
259
195
|
|
@@ -261,7 +197,7 @@ describe Mongo::Client do
|
|
261
197
|
Mongo::Options::Redacted.new(:read => { :mode => :primary },
|
262
198
|
:local_threshold => 0.010,
|
263
199
|
:server_selection_timeout => 10000,
|
264
|
-
:database =>
|
200
|
+
:database => SpecConfig.instance.test_db)
|
265
201
|
end
|
266
202
|
|
267
203
|
let(:expected) do
|
@@ -276,26 +212,24 @@ describe Mongo::Client do
|
|
276
212
|
describe '#inspect' do
|
277
213
|
|
278
214
|
let(:client) do
|
279
|
-
|
215
|
+
new_local_client(
|
280
216
|
['127.0.0.1:27017'],
|
281
217
|
:read => { :mode => :primary },
|
282
|
-
:database =>
|
218
|
+
:database => SpecConfig.instance.test_db
|
283
219
|
)
|
284
220
|
end
|
285
221
|
|
286
222
|
it 'returns the cluster information' do
|
287
|
-
expect(client.inspect).to
|
288
|
-
"<Mongo::Client:0x#{client.object_id} cluster=127.0.0.1:27017"
|
289
|
-
)
|
223
|
+
expect(client.inspect).to match(/Cluster(.|\n)*topology=(.|\n)*servers=/)
|
290
224
|
end
|
291
225
|
|
292
226
|
context 'when there is sensitive data in the options' do
|
293
227
|
|
294
228
|
let(:client) do
|
295
|
-
|
229
|
+
new_local_client(
|
296
230
|
['127.0.0.1:27017'],
|
297
231
|
:read => { :mode => :primary },
|
298
|
-
:database =>
|
232
|
+
:database => SpecConfig.instance.test_db,
|
299
233
|
:password => 'some_password',
|
300
234
|
:user => 'emily'
|
301
235
|
)
|
@@ -307,644 +241,13 @@ describe Mongo::Client do
|
|
307
241
|
end
|
308
242
|
end
|
309
243
|
|
310
|
-
describe '#initialize' do
|
311
|
-
|
312
|
-
context 'when providing options' do
|
313
|
-
|
314
|
-
context 'when retry_writes is defined' do
|
315
|
-
|
316
|
-
let(:options) do
|
317
|
-
{ retry_writes: true }
|
318
|
-
end
|
319
|
-
|
320
|
-
let(:client) do
|
321
|
-
described_class.new([default_address.seed], authorized_client.options.merge(options))
|
322
|
-
end
|
323
|
-
|
324
|
-
it 'sets the option' do
|
325
|
-
expect(client.options['retry_writes']).to eq(options[:retry_writes])
|
326
|
-
end
|
327
|
-
end
|
328
|
-
|
329
|
-
context 'when compressors are provided' do
|
330
|
-
|
331
|
-
let(:client) do
|
332
|
-
described_class.new([default_address.seed], authorized_client.options.merge(options))
|
333
|
-
end
|
334
|
-
|
335
|
-
context 'when the compressor is supported' do
|
336
|
-
|
337
|
-
let(:options) do
|
338
|
-
{ compressors: ['zlib'] }
|
339
|
-
end
|
340
|
-
|
341
|
-
it 'sets the compressor' do
|
342
|
-
expect(client.options['compressors']).to eq(options[:compressors])
|
343
|
-
end
|
344
|
-
|
345
|
-
it 'sends the compressor in the compression key of the handshake document' do
|
346
|
-
expect(client.cluster.app_metadata.send(:document)[:compression]).to eq(options[:compressors])
|
347
|
-
end
|
348
|
-
|
349
|
-
it 'uses compression for messages', if: testing_compression? do
|
350
|
-
expect(Mongo::Protocol::Compressed).to receive(:new).and_call_original
|
351
|
-
client[TEST_COLL].find({}, limit: 1).first
|
352
|
-
end
|
353
|
-
|
354
|
-
it 'does not use compression for authentication messages' do
|
355
|
-
expect(Mongo::Protocol::Compressed).not_to receive(:new)
|
356
|
-
client.cluster.next_primary.send(:with_connection) do |conn|
|
357
|
-
conn.send(:authenticate!)
|
358
|
-
end
|
359
|
-
end
|
360
|
-
end
|
361
|
-
|
362
|
-
context 'when the compressor is not supported by the driver' do
|
363
|
-
|
364
|
-
let(:options) do
|
365
|
-
{ compressors: ['snoopy'] }
|
366
|
-
end
|
367
|
-
|
368
|
-
it 'does not set the compressor and warns' do
|
369
|
-
expect(Mongo::Logger.logger).to receive(:warn)
|
370
|
-
expect(client.options['compressors']).to be_nil
|
371
|
-
end
|
372
|
-
|
373
|
-
it 'sets the compression key of the handshake document to an empty array' do
|
374
|
-
expect(client.cluster.app_metadata.send(:document)[:compression]).to eq([])
|
375
|
-
end
|
376
|
-
|
377
|
-
context 'when one supported compressor and one unsupported compressor are provided', if: compression_enabled? do
|
378
|
-
|
379
|
-
let(:options) do
|
380
|
-
{ compressors: ['zlib', 'snoopy'] }
|
381
|
-
end
|
382
|
-
|
383
|
-
it 'does not set the unsupported compressor and warns' do
|
384
|
-
expect(Mongo::Logger.logger).to receive(:warn).at_least(:once)
|
385
|
-
expect(client.options['compressors']).to eq(['zlib'])
|
386
|
-
end
|
387
|
-
|
388
|
-
it 'sets the compression key of the handshake document to the list of supported compressors' do
|
389
|
-
expect(client.cluster.app_metadata.send(:document)[:compression]).to eq(['zlib'])
|
390
|
-
end
|
391
|
-
end
|
392
|
-
end
|
393
|
-
|
394
|
-
context 'when the compressor is not supported by the server', unless: collation_enabled? do
|
395
|
-
|
396
|
-
let(:options) do
|
397
|
-
{ compressors: ['zlib'] }
|
398
|
-
end
|
399
|
-
|
400
|
-
it 'does not set the compressor and warns' do
|
401
|
-
expect(Mongo::Logger.logger).to receive(:warn).at_least(:once)
|
402
|
-
expect(client.cluster.next_primary.monitor.compressor).to be_nil
|
403
|
-
end
|
404
|
-
end
|
405
|
-
end
|
406
|
-
|
407
|
-
context 'when compressors are not provided', unless: compression_enabled? do
|
408
|
-
|
409
|
-
let(:client) do
|
410
|
-
authorized_client
|
411
|
-
end
|
412
|
-
|
413
|
-
it 'does not set the compressor' do
|
414
|
-
expect(client.options['compressors']).to be_nil
|
415
|
-
end
|
416
|
-
|
417
|
-
it 'sets the compression key of the handshake document to an empty array' do
|
418
|
-
expect(client.cluster.app_metadata.send(:document)[:compression]).to eq([])
|
419
|
-
end
|
420
|
-
|
421
|
-
it 'does not use compression for messages' do
|
422
|
-
client[TEST_COLL].find({}, limit: 1).first
|
423
|
-
expect(Mongo::Protocol::Compressed).not_to receive(:new)
|
424
|
-
end
|
425
|
-
end
|
426
|
-
|
427
|
-
context 'when a zlib_compression_level option is provided', if: testing_compression? do
|
428
|
-
|
429
|
-
let(:client) do
|
430
|
-
described_class.new([default_address.seed], TEST_OPTIONS.merge(zlib_compression_level: 1))
|
431
|
-
end
|
432
|
-
|
433
|
-
it 'sets the option on the client' do
|
434
|
-
expect(client.options[:zlib_compression_level]).to eq(1)
|
435
|
-
end
|
436
|
-
end
|
437
|
-
|
438
|
-
context 'when ssl options are provided' do
|
439
|
-
|
440
|
-
let(:options) do
|
441
|
-
{
|
442
|
-
:ssl => true,
|
443
|
-
:ssl_ca_cert => CA_PEM,
|
444
|
-
:ssl_ca_cert_string => 'ca cert string',
|
445
|
-
:ssl_ca_cert_object => 'ca cert object',
|
446
|
-
:ssl_cert => CLIENT_CERT_PEM,
|
447
|
-
:ssl_cert_string => 'cert string',
|
448
|
-
:ssl_cert_object => 'cert object',
|
449
|
-
:ssl_key => CLIENT_KEY_PEM,
|
450
|
-
:ssl_key_string => 'key string',
|
451
|
-
:ssl_key_object => 'key object',
|
452
|
-
:ssl_key_pass_phrase => 'passphrase',
|
453
|
-
:ssl_verify => true
|
454
|
-
}
|
455
|
-
end
|
456
|
-
|
457
|
-
let(:client) do
|
458
|
-
described_class.new(['127.0.0.1:27017'], TEST_OPTIONS.merge(options))
|
459
|
-
end
|
460
|
-
|
461
|
-
it 'sets the ssl option' do
|
462
|
-
expect(client.options[:ssl]).to eq(options[:ssl])
|
463
|
-
end
|
464
|
-
|
465
|
-
it 'sets the ssl_ca_cert option' do
|
466
|
-
expect(client.options[:ssl_ca_cert]).to eq(options[:ssl_ca_cert])
|
467
|
-
end
|
468
|
-
|
469
|
-
it 'sets the ssl_ca_cert_string option' do
|
470
|
-
expect(client.options[:ssl_ca_cert_string]).to eq(options[:ssl_ca_cert_string])
|
471
|
-
end
|
472
|
-
|
473
|
-
it 'sets the ssl_ca_cert_object option' do
|
474
|
-
expect(client.options[:ssl_ca_cert_object]).to eq(options[:ssl_ca_cert_object])
|
475
|
-
end
|
476
|
-
|
477
|
-
it 'sets the ssl_cert option' do
|
478
|
-
expect(client.options[:ssl_cert]).to eq(options[:ssl_cert])
|
479
|
-
end
|
480
|
-
|
481
|
-
it 'sets the ssl_cert_string option' do
|
482
|
-
expect(client.options[:ssl_cert_string]).to eq(options[:ssl_cert_string])
|
483
|
-
end
|
484
|
-
|
485
|
-
it 'sets the ssl_cert_object option' do
|
486
|
-
expect(client.options[:ssl_cert_object]).to eq(options[:ssl_cert_object])
|
487
|
-
end
|
488
|
-
|
489
|
-
it 'sets the ssl_key option' do
|
490
|
-
expect(client.options[:ssl_key]).to eq(options[:ssl_key])
|
491
|
-
end
|
492
|
-
|
493
|
-
it 'sets the ssl_key_string option' do
|
494
|
-
expect(client.options[:ssl_key_string]).to eq(options[:ssl_key_string])
|
495
|
-
end
|
496
|
-
|
497
|
-
it 'sets the ssl_key_object option' do
|
498
|
-
expect(client.options[:ssl_key_object]).to eq(options[:ssl_key_object])
|
499
|
-
end
|
500
|
-
|
501
|
-
it 'sets the ssl_key_pass_phrase option' do
|
502
|
-
expect(client.options[:ssl_key_pass_phrase]).to eq(options[:ssl_key_pass_phrase])
|
503
|
-
end
|
504
|
-
|
505
|
-
it 'sets the ssl_verify option' do
|
506
|
-
expect(client.options[:ssl_verify]).to eq(options[:ssl_verify])
|
507
|
-
end
|
508
|
-
end
|
509
|
-
|
510
|
-
context 'when no database is provided' do
|
511
|
-
|
512
|
-
let(:client) do
|
513
|
-
described_class.new(['127.0.0.1:27017'], :read => { :mode => :secondary })
|
514
|
-
end
|
515
|
-
|
516
|
-
it 'defaults the database to admin' do
|
517
|
-
expect(client.database.name).to eq('admin')
|
518
|
-
end
|
519
|
-
end
|
520
|
-
|
521
|
-
context 'when a database is provided' do
|
522
|
-
|
523
|
-
let(:client) do
|
524
|
-
described_class.new(['127.0.0.1:27017'], :database => :testdb)
|
525
|
-
end
|
526
|
-
|
527
|
-
it 'sets the current database' do
|
528
|
-
expect(client[:users].name).to eq('users')
|
529
|
-
end
|
530
|
-
end
|
531
|
-
|
532
|
-
context 'when providing a custom logger' do
|
533
|
-
|
534
|
-
let(:logger) do
|
535
|
-
Logger.new($stdout).tap do |l|
|
536
|
-
l.level = Logger::FATAL
|
537
|
-
end
|
538
|
-
end
|
539
|
-
|
540
|
-
let(:client) do
|
541
|
-
authorized_client.with(logger: logger)
|
542
|
-
end
|
543
|
-
|
544
|
-
it 'does not use the global logger' do
|
545
|
-
expect(client.cluster.logger).to_not eq(Mongo::Logger.logger)
|
546
|
-
end
|
547
|
-
end
|
548
|
-
|
549
|
-
context 'when providing a heartbeat_frequency' do
|
550
|
-
|
551
|
-
let(:client) do
|
552
|
-
described_class.new(['127.0.0.1:27017'], :heartbeat_frequency => 2)
|
553
|
-
end
|
554
|
-
|
555
|
-
it 'sets the heartbeat frequency' do
|
556
|
-
expect(client.cluster.options[:heartbeat_frequency]).to eq(client.options[:heartbeat_frequency])
|
557
|
-
end
|
558
|
-
end
|
559
|
-
|
560
|
-
context 'when min_pool_size is provided' do
|
561
|
-
|
562
|
-
let(:client) do
|
563
|
-
described_class.new(['127.0.0.1:27017'], options)
|
564
|
-
end
|
565
|
-
|
566
|
-
context 'when max_pool_size is provided' do
|
567
|
-
|
568
|
-
context 'when the min_pool_size is greater than the max_pool_size' do
|
569
|
-
|
570
|
-
let(:options) do
|
571
|
-
{
|
572
|
-
:min_pool_size => 20,
|
573
|
-
:max_pool_size => 10
|
574
|
-
}
|
575
|
-
end
|
576
|
-
|
577
|
-
it 'raises an Exception' do
|
578
|
-
expect {
|
579
|
-
client
|
580
|
-
}.to raise_exception(Mongo::Error::InvalidMinPoolSize)
|
581
|
-
end
|
582
|
-
end
|
583
|
-
|
584
|
-
context 'when the min_pool_size is less than the max_pool_size' do
|
585
|
-
|
586
|
-
let(:options) do
|
587
|
-
{
|
588
|
-
:min_pool_size => 10,
|
589
|
-
:max_pool_size => 20
|
590
|
-
}
|
591
|
-
end
|
592
|
-
|
593
|
-
it 'sets the option' do
|
594
|
-
expect(client.options[:min_pool_size]).to eq(options[:min_pool_size])
|
595
|
-
expect(client.options[:max_pool_size]).to eq(options[:max_pool_size])
|
596
|
-
end
|
597
|
-
end
|
598
|
-
|
599
|
-
context 'when the min_pool_size is equal to the max_pool_size' do
|
600
|
-
|
601
|
-
let(:options) do
|
602
|
-
{
|
603
|
-
:min_pool_size => 10,
|
604
|
-
:max_pool_size => 10
|
605
|
-
}
|
606
|
-
end
|
607
|
-
|
608
|
-
it 'sets the option' do
|
609
|
-
expect(client.options[:min_pool_size]).to eq(options[:min_pool_size])
|
610
|
-
expect(client.options[:max_pool_size]).to eq(options[:max_pool_size])
|
611
|
-
end
|
612
|
-
end
|
613
|
-
end
|
614
|
-
|
615
|
-
context 'when max_pool_size is not provided' do
|
616
|
-
|
617
|
-
context 'when the min_pool_size is greater than the default max_pool_size' do
|
618
|
-
|
619
|
-
let(:options) do
|
620
|
-
{
|
621
|
-
:min_pool_size => 10
|
622
|
-
}
|
623
|
-
end
|
624
|
-
|
625
|
-
it 'raises an Exception' do
|
626
|
-
expect {
|
627
|
-
client
|
628
|
-
}.to raise_exception(Mongo::Error::InvalidMinPoolSize)
|
629
|
-
end
|
630
|
-
end
|
631
|
-
|
632
|
-
context 'when the min_pool_size is less than the default max_pool_size' do
|
633
|
-
|
634
|
-
let(:options) do
|
635
|
-
{
|
636
|
-
:min_pool_size => 3
|
637
|
-
}
|
638
|
-
end
|
639
|
-
|
640
|
-
it 'sets the option' do
|
641
|
-
expect(client.options[:min_pool_size]).to eq(options[:min_pool_size])
|
642
|
-
end
|
643
|
-
end
|
644
|
-
|
645
|
-
context 'when the min_pool_size is equal to the max_pool_size' do
|
646
|
-
|
647
|
-
let(:options) do
|
648
|
-
{
|
649
|
-
:min_pool_size => Mongo::Server::ConnectionPool::Queue::MAX_SIZE
|
650
|
-
}
|
651
|
-
end
|
652
|
-
|
653
|
-
it 'sets the option' do
|
654
|
-
expect(client.options[:min_pool_size]).to eq(options[:min_pool_size])
|
655
|
-
end
|
656
|
-
end
|
657
|
-
end
|
658
|
-
end
|
659
|
-
|
660
|
-
context 'when max_pool_size and min_pool_size are both nil' do
|
661
|
-
|
662
|
-
let(:client) do
|
663
|
-
described_class.new(['127.0.0.1:27017'], options)
|
664
|
-
end
|
665
|
-
|
666
|
-
let(:options) do
|
667
|
-
{
|
668
|
-
:min_pool_size => nil,
|
669
|
-
:max_pool_size => nil
|
670
|
-
}
|
671
|
-
end
|
672
|
-
|
673
|
-
it 'does not set either option' do
|
674
|
-
expect(client.options[:max_pool_size]).to be_nil
|
675
|
-
expect(client.options[:min_pool_size]).to be_nil
|
676
|
-
end
|
677
|
-
end
|
678
|
-
|
679
|
-
context 'when platform details are specified' do
|
680
|
-
|
681
|
-
let(:app_metadata) do
|
682
|
-
client.cluster.app_metadata
|
683
|
-
end
|
684
|
-
|
685
|
-
let(:client) do
|
686
|
-
described_class.new(['127.0.0.1:27017'], :platform => 'mongoid-6.0.2')
|
687
|
-
end
|
688
|
-
|
689
|
-
it 'includes the platform info in the app metadata' do
|
690
|
-
expect(app_metadata.send(:full_client_document)[:platform]).to match(/mongoid-6\.0\.2/)
|
691
|
-
end
|
692
|
-
end
|
693
|
-
|
694
|
-
context 'when platform details are not specified' do
|
695
|
-
|
696
|
-
let(:app_metadata) do
|
697
|
-
client.cluster.app_metadata
|
698
|
-
end
|
699
|
-
|
700
|
-
let(:client) do
|
701
|
-
described_class.new(['127.0.0.1:27017'])
|
702
|
-
end
|
703
|
-
|
704
|
-
let(:platform_string) do
|
705
|
-
[
|
706
|
-
RUBY_VERSION,
|
707
|
-
RUBY_PLATFORM,
|
708
|
-
RbConfig::CONFIG['build']
|
709
|
-
].join(', ')
|
710
|
-
end
|
711
|
-
|
712
|
-
it 'does not include the platform info in the app metadata' do
|
713
|
-
expect(app_metadata.send(:full_client_document)[:platform]).to eq(platform_string)
|
714
|
-
end
|
715
|
-
end
|
716
|
-
end
|
717
|
-
|
718
|
-
context 'when providing a connection string' do
|
719
|
-
|
720
|
-
context 'when the string uses the SRV Protocol' do
|
721
|
-
require_external_connectivity
|
722
|
-
|
723
|
-
let!(:uri) do
|
724
|
-
'mongodb+srv://test5.test.build.10gen.cc/testdb'
|
725
|
-
end
|
726
|
-
|
727
|
-
let(:client) do
|
728
|
-
described_class.new(uri)
|
729
|
-
end
|
730
|
-
|
731
|
-
it 'sets the database' do
|
732
|
-
expect(client.options[:database]).to eq('testdb')
|
733
|
-
end
|
734
|
-
end
|
735
|
-
|
736
|
-
context 'when a database is provided' do
|
737
|
-
|
738
|
-
let!(:uri) do
|
739
|
-
'mongodb://127.0.0.1:27017/testdb'
|
740
|
-
end
|
741
|
-
|
742
|
-
let(:client) do
|
743
|
-
described_class.new(uri)
|
744
|
-
end
|
745
|
-
|
746
|
-
it 'sets the database' do
|
747
|
-
expect { client[:users] }.to_not raise_error
|
748
|
-
end
|
749
|
-
end
|
750
|
-
|
751
|
-
context 'when a database is not provided' do
|
752
|
-
|
753
|
-
let!(:uri) do
|
754
|
-
'mongodb://127.0.0.1:27017'
|
755
|
-
end
|
756
|
-
|
757
|
-
let(:client) do
|
758
|
-
described_class.new(uri)
|
759
|
-
end
|
760
|
-
|
761
|
-
it 'defaults the database to admin' do
|
762
|
-
expect(client.database.name).to eq('admin')
|
763
|
-
end
|
764
|
-
end
|
765
|
-
|
766
|
-
context 'when options are provided' do
|
767
|
-
|
768
|
-
let!(:uri) do
|
769
|
-
'mongodb://127.0.0.1:27017/testdb?w=3'
|
770
|
-
end
|
771
|
-
|
772
|
-
let(:client) do
|
773
|
-
described_class.new(uri)
|
774
|
-
end
|
775
|
-
|
776
|
-
let(:expected_options) do
|
777
|
-
Mongo::Options::Redacted.new(:write => { :w => 3 }, :database => 'testdb')
|
778
|
-
end
|
779
|
-
|
780
|
-
it 'sets the options' do
|
781
|
-
expect(client.options).to eq(expected_options)
|
782
|
-
end
|
783
|
-
|
784
|
-
context 'when min_pool_size is provided' do
|
785
|
-
|
786
|
-
context 'when max_pool_size is provided' do
|
787
|
-
|
788
|
-
context 'when the min_pool_size is greater than the max_pool_size' do
|
789
|
-
|
790
|
-
let(:uri) do
|
791
|
-
'mongodb://127.0.0.1:27017/?minPoolSize=20&maxPoolSize=10'
|
792
|
-
end
|
793
|
-
|
794
|
-
it 'raises an Exception' do
|
795
|
-
expect {
|
796
|
-
client
|
797
|
-
}.to raise_exception(Mongo::Error::InvalidMinPoolSize)
|
798
|
-
end
|
799
|
-
end
|
800
|
-
|
801
|
-
context 'when the min_pool_size is less than the max_pool_size' do
|
802
|
-
|
803
|
-
let(:uri) do
|
804
|
-
'mongodb://127.0.0.1:27017/?minPoolSize=10&maxPoolSize=20'
|
805
|
-
end
|
806
|
-
|
807
|
-
it 'sets the option' do
|
808
|
-
expect(client.options[:min_pool_size]).to eq(10)
|
809
|
-
expect(client.options[:max_pool_size]).to eq(20)
|
810
|
-
end
|
811
|
-
end
|
812
|
-
|
813
|
-
context 'when the min_pool_size is equal to the max_pool_size' do
|
814
|
-
|
815
|
-
let(:uri) do
|
816
|
-
'mongodb://127.0.0.1:27017/?minPoolSize=10&maxPoolSize=10'
|
817
|
-
end
|
818
|
-
|
819
|
-
it 'sets the option' do
|
820
|
-
expect(client.options[:min_pool_size]).to eq(10)
|
821
|
-
expect(client.options[:max_pool_size]).to eq(10)
|
822
|
-
end
|
823
|
-
end
|
824
|
-
end
|
825
|
-
|
826
|
-
context 'when max_pool_size is not provided' do
|
827
|
-
|
828
|
-
context 'when the min_pool_size is greater than the default max_pool_size' do
|
829
|
-
|
830
|
-
let(:uri) do
|
831
|
-
'mongodb://127.0.0.1:27017/?minPoolSize=10'
|
832
|
-
end
|
833
|
-
|
834
|
-
it 'raises an Exception' do
|
835
|
-
expect {
|
836
|
-
client
|
837
|
-
}.to raise_exception(Mongo::Error::InvalidMinPoolSize)
|
838
|
-
end
|
839
|
-
end
|
840
|
-
|
841
|
-
context 'when the min_pool_size is less than the default max_pool_size' do
|
842
|
-
|
843
|
-
let(:uri) do
|
844
|
-
'mongodb://127.0.0.1:27017/?minPoolSize=3'
|
845
|
-
end
|
846
|
-
|
847
|
-
it 'sets the option' do
|
848
|
-
expect(client.options[:min_pool_size]).to eq(3)
|
849
|
-
end
|
850
|
-
end
|
851
|
-
|
852
|
-
context 'when the min_pool_size is equal to the max_pool_size' do
|
853
|
-
|
854
|
-
let(:uri) do
|
855
|
-
'mongodb://127.0.0.1:27017/?minPoolSize=5'
|
856
|
-
end
|
857
|
-
|
858
|
-
it 'sets the option' do
|
859
|
-
expect(client.options[:min_pool_size]).to eq(5)
|
860
|
-
end
|
861
|
-
end
|
862
|
-
end
|
863
|
-
end
|
864
|
-
end
|
865
|
-
|
866
|
-
context 'when options are provided not in the string' do
|
867
|
-
|
868
|
-
let!(:uri) do
|
869
|
-
'mongodb://127.0.0.1:27017/testdb'
|
870
|
-
end
|
871
|
-
|
872
|
-
let(:client) do
|
873
|
-
described_class.new(uri, :write => { :w => 3 })
|
874
|
-
end
|
875
|
-
|
876
|
-
let(:expected_options) do
|
877
|
-
Mongo::Options::Redacted.new(:write => { :w => 3 }, :database => 'testdb')
|
878
|
-
end
|
879
|
-
|
880
|
-
it 'sets the options' do
|
881
|
-
expect(client.options).to eq(expected_options)
|
882
|
-
end
|
883
|
-
end
|
884
|
-
|
885
|
-
context 'when options are provided in the string and explicitly' do
|
886
|
-
|
887
|
-
let!(:uri) do
|
888
|
-
'mongodb://127.0.0.1:27017/testdb?w=3'
|
889
|
-
end
|
890
|
-
|
891
|
-
let(:client) do
|
892
|
-
described_class.new(uri, :write => { :w => 4 })
|
893
|
-
end
|
894
|
-
|
895
|
-
let(:expected_options) do
|
896
|
-
Mongo::Options::Redacted.new(:write => { :w => 4 }, :database => 'testdb')
|
897
|
-
end
|
898
|
-
|
899
|
-
it 'allows explicit options to take preference' do
|
900
|
-
expect(client.options).to eq(expected_options)
|
901
|
-
end
|
902
|
-
end
|
903
|
-
|
904
|
-
context 'when a replica set name is provided' do
|
905
|
-
|
906
|
-
let!(:uri) do
|
907
|
-
'mongodb://127.0.0.1:27017/testdb?replicaSet=testing'
|
908
|
-
end
|
909
|
-
|
910
|
-
let(:client) do
|
911
|
-
described_class.new(uri)
|
912
|
-
end
|
913
|
-
|
914
|
-
it 'sets the correct cluster topology' do
|
915
|
-
expect(client.cluster.topology).to be_a(Mongo::Cluster::Topology::ReplicaSet)
|
916
|
-
end
|
917
|
-
end
|
918
|
-
|
919
|
-
context 'when an invalid option is provided' do
|
920
|
-
|
921
|
-
let(:client) do
|
922
|
-
described_class.new(['127.0.0.1:27017'], :ssl => false, :invalid => :test)
|
923
|
-
end
|
924
|
-
|
925
|
-
it 'does not set the option' do
|
926
|
-
expect(client.options.keys).not_to include('invalid')
|
927
|
-
end
|
928
|
-
|
929
|
-
it 'sets the valid options' do
|
930
|
-
expect(client.options.keys).to include('ssl')
|
931
|
-
end
|
932
|
-
|
933
|
-
it 'warns that an invalid option has been specified' do
|
934
|
-
expect(Mongo::Logger.logger).to receive(:warn)
|
935
|
-
expect(client.options.keys).not_to include('invalid')
|
936
|
-
end
|
937
|
-
end
|
938
|
-
end
|
939
|
-
end
|
940
|
-
|
941
244
|
describe '#server_selector' do
|
942
245
|
|
943
246
|
context 'when there is a read preference set' do
|
944
247
|
|
945
248
|
let(:client) do
|
946
|
-
|
947
|
-
:database =>
|
249
|
+
new_local_client(['127.0.0.1:27017'],
|
250
|
+
:database => SpecConfig.instance.test_db,
|
948
251
|
:read => mode,
|
949
252
|
:server_selection_timeout => 2)
|
950
253
|
end
|
@@ -1015,8 +318,8 @@ describe Mongo::Client do
|
|
1015
318
|
context 'when no mode provided' do
|
1016
319
|
|
1017
320
|
let(:client) do
|
1018
|
-
|
1019
|
-
:database =>
|
321
|
+
new_local_client(['127.0.0.1:27017'],
|
322
|
+
:database => SpecConfig.instance.test_db,
|
1020
323
|
:server_selection_timeout => 2)
|
1021
324
|
end
|
1022
325
|
|
@@ -1028,7 +331,7 @@ describe Mongo::Client do
|
|
1028
331
|
context 'when the read preference is printed' do
|
1029
332
|
|
1030
333
|
let(:client) do
|
1031
|
-
|
334
|
+
new_local_client(SpecConfig.instance.addresses, options)
|
1032
335
|
end
|
1033
336
|
|
1034
337
|
let(:options) do
|
@@ -1057,8 +360,8 @@ describe Mongo::Client do
|
|
1057
360
|
describe '#read_preference' do
|
1058
361
|
|
1059
362
|
let(:client) do
|
1060
|
-
|
1061
|
-
:database =>
|
363
|
+
new_local_client(['127.0.0.1:27017'],
|
364
|
+
:database => SpecConfig.instance.test_db,
|
1062
365
|
:read => mode,
|
1063
366
|
:server_selection_timeout => 2)
|
1064
367
|
end
|
@@ -1125,8 +428,8 @@ describe Mongo::Client do
|
|
1125
428
|
context 'when no mode provided' do
|
1126
429
|
|
1127
430
|
let(:client) do
|
1128
|
-
|
1129
|
-
:database =>
|
431
|
+
new_local_client(['127.0.0.1:27017'],
|
432
|
+
:database => SpecConfig.instance.test_db,
|
1130
433
|
:server_selection_timeout => 2)
|
1131
434
|
end
|
1132
435
|
|
@@ -1136,234 +439,13 @@ describe Mongo::Client do
|
|
1136
439
|
end
|
1137
440
|
end
|
1138
441
|
|
1139
|
-
describe '#use' do
|
1140
|
-
|
1141
|
-
let(:client) do
|
1142
|
-
described_class.new(['127.0.0.1:27017'], :database => TEST_DB)
|
1143
|
-
end
|
1144
|
-
|
1145
|
-
shared_examples_for 'a database switching object' do
|
1146
|
-
|
1147
|
-
it 'returns the new client' do
|
1148
|
-
expect(client.send(:database).name).to eq('ruby-driver')
|
1149
|
-
end
|
1150
|
-
|
1151
|
-
it 'keeps the same cluster' do
|
1152
|
-
expect(database.cluster).to equal(client.cluster)
|
1153
|
-
end
|
1154
|
-
end
|
1155
|
-
|
1156
|
-
context 'when provided a string' do
|
1157
|
-
|
1158
|
-
let(:database) do
|
1159
|
-
client.use('testdb')
|
1160
|
-
end
|
1161
|
-
|
1162
|
-
it_behaves_like 'a database switching object'
|
1163
|
-
end
|
1164
|
-
|
1165
|
-
context 'when provided a symbol' do
|
1166
|
-
|
1167
|
-
let(:database) do
|
1168
|
-
client.use(:testdb)
|
1169
|
-
end
|
1170
|
-
|
1171
|
-
it_behaves_like 'a database switching object'
|
1172
|
-
end
|
1173
|
-
|
1174
|
-
context 'when providing nil' do
|
1175
|
-
|
1176
|
-
it 'raises an exception' do
|
1177
|
-
expect {
|
1178
|
-
client.use(nil)
|
1179
|
-
}.to raise_error(Mongo::Error::InvalidDatabaseName)
|
1180
|
-
end
|
1181
|
-
end
|
1182
|
-
end
|
1183
|
-
|
1184
|
-
describe '#with' do
|
1185
|
-
|
1186
|
-
let(:client) do
|
1187
|
-
described_class.new(['127.0.0.1:27017'], :database => TEST_DB)
|
1188
|
-
end
|
1189
|
-
|
1190
|
-
context 'when providing nil' do
|
1191
|
-
|
1192
|
-
it 'returns the cloned client' do
|
1193
|
-
expect(client.with(nil)).to eq(client)
|
1194
|
-
end
|
1195
|
-
end
|
1196
|
-
|
1197
|
-
context 'when the app_name is changed' do
|
1198
|
-
|
1199
|
-
let(:client) do
|
1200
|
-
authorized_client
|
1201
|
-
end
|
1202
|
-
|
1203
|
-
let!(:original_options) do
|
1204
|
-
client.options
|
1205
|
-
end
|
1206
|
-
|
1207
|
-
let(:new_options) do
|
1208
|
-
{ app_name: 'client_test' }
|
1209
|
-
end
|
1210
|
-
|
1211
|
-
let!(:new_client) do
|
1212
|
-
authorized_client.with(new_options)
|
1213
|
-
end
|
1214
|
-
|
1215
|
-
it 'returns a new client' do
|
1216
|
-
expect(new_client).not_to equal(client)
|
1217
|
-
end
|
1218
|
-
|
1219
|
-
it 'replaces the existing options' do
|
1220
|
-
expect(new_client.options).to eq(client.options.merge(new_options))
|
1221
|
-
end
|
1222
|
-
|
1223
|
-
it 'does not modify the original client' do
|
1224
|
-
expect(client.options).to eq(original_options)
|
1225
|
-
end
|
1226
|
-
|
1227
|
-
it 'does not keep the same cluster' do
|
1228
|
-
expect(new_client.cluster).not_to be(client.cluster)
|
1229
|
-
end
|
1230
|
-
end
|
1231
|
-
|
1232
|
-
context 'when the write concern is not changed' do
|
1233
|
-
|
1234
|
-
let(:client) do
|
1235
|
-
described_class.new(
|
1236
|
-
['127.0.0.1:27017'],
|
1237
|
-
:read => { :mode => :secondary }, :write => { :w => 1 }, :database => TEST_DB
|
1238
|
-
)
|
1239
|
-
end
|
1240
|
-
|
1241
|
-
let!(:new_client) do
|
1242
|
-
client.with(:read => { :mode => :primary })
|
1243
|
-
end
|
1244
|
-
|
1245
|
-
let(:new_options) do
|
1246
|
-
Mongo::Options::Redacted.new(:read => { :mode => :primary },
|
1247
|
-
:write => { :w => 1 },
|
1248
|
-
:database => TEST_DB)
|
1249
|
-
end
|
1250
|
-
|
1251
|
-
let(:original_options) do
|
1252
|
-
Mongo::Options::Redacted.new(:read => { :mode => :secondary },
|
1253
|
-
:write => { :w => 1 },
|
1254
|
-
:database => TEST_DB)
|
1255
|
-
end
|
1256
|
-
|
1257
|
-
it 'returns a new client' do
|
1258
|
-
expect(new_client).not_to equal(client)
|
1259
|
-
end
|
1260
|
-
|
1261
|
-
it 'replaces the existing options' do
|
1262
|
-
expect(new_client.options).to eq(new_options)
|
1263
|
-
end
|
1264
|
-
|
1265
|
-
it 'does not modify the original client' do
|
1266
|
-
expect(client.options).to eq(original_options)
|
1267
|
-
end
|
1268
|
-
|
1269
|
-
it 'keeps the same cluster' do
|
1270
|
-
expect(new_client.cluster).to be(client.cluster)
|
1271
|
-
end
|
1272
|
-
end
|
1273
|
-
|
1274
|
-
context 'when the write concern is changed' do
|
1275
|
-
|
1276
|
-
let(:client) do
|
1277
|
-
described_class.new(['127.0.0.1:27017'], :write => { :w => 1 }, :database => TEST_DB)
|
1278
|
-
end
|
1279
|
-
|
1280
|
-
context 'when the write concern has not been accessed' do
|
1281
|
-
|
1282
|
-
let!(:new_client) do
|
1283
|
-
client.with(:write => { :w => 0 })
|
1284
|
-
end
|
1285
|
-
|
1286
|
-
let(:get_last_error) do
|
1287
|
-
new_client.write_concern.get_last_error
|
1288
|
-
end
|
1289
|
-
|
1290
|
-
it 'returns the correct write concern' do
|
1291
|
-
expect(get_last_error).to be_nil
|
1292
|
-
end
|
1293
|
-
end
|
1294
|
-
|
1295
|
-
context 'when the write concern has been accessed' do
|
1296
|
-
|
1297
|
-
let!(:new_client) do
|
1298
|
-
client.write_concern
|
1299
|
-
client.with(:write => { :w => 0 })
|
1300
|
-
end
|
1301
|
-
|
1302
|
-
let(:get_last_error) do
|
1303
|
-
new_client.write_concern.get_last_error
|
1304
|
-
end
|
1305
|
-
|
1306
|
-
it 'returns the correct write concern' do
|
1307
|
-
expect(get_last_error).to be_nil
|
1308
|
-
end
|
1309
|
-
end
|
1310
|
-
end
|
1311
|
-
|
1312
|
-
context 'when an invalid option is provided' do
|
1313
|
-
|
1314
|
-
let(:new_client) do
|
1315
|
-
client.with(invalid: :option, ssl: false)
|
1316
|
-
end
|
1317
|
-
|
1318
|
-
it 'does not set the invalid option' do
|
1319
|
-
expect(new_client.options.keys).not_to include('invalid')
|
1320
|
-
end
|
1321
|
-
|
1322
|
-
it 'sets the valid options' do
|
1323
|
-
expect(new_client.options.keys).to include('ssl')
|
1324
|
-
end
|
1325
|
-
|
1326
|
-
it 'warns that an invalid option has been specified' do
|
1327
|
-
expect(Mongo::Logger.logger).to receive(:warn)
|
1328
|
-
expect(new_client.options.keys).not_to include('invalid')
|
1329
|
-
end
|
1330
|
-
end
|
1331
|
-
|
1332
|
-
context 'when client is created with ipv6 address' do
|
1333
|
-
let(:client) do
|
1334
|
-
described_class.new(['[::1]:27017'], :database => TEST_DB)
|
1335
|
-
end
|
1336
|
-
|
1337
|
-
context 'when providing nil' do
|
1338
|
-
|
1339
|
-
it 'returns the cloned client' do
|
1340
|
-
expect(client.with(nil)).to eq(client)
|
1341
|
-
end
|
1342
|
-
end
|
1343
|
-
|
1344
|
-
context 'when changing options' do
|
1345
|
-
let(:new_options) do
|
1346
|
-
{ app_name: 'client_test' }
|
1347
|
-
end
|
1348
|
-
|
1349
|
-
let!(:new_client) do
|
1350
|
-
client.with(new_options)
|
1351
|
-
end
|
1352
|
-
|
1353
|
-
it 'returns a new client' do
|
1354
|
-
expect(new_client).not_to equal(client)
|
1355
|
-
end
|
1356
|
-
end
|
1357
|
-
end
|
1358
|
-
end
|
1359
|
-
|
1360
442
|
describe '#write_concern' do
|
1361
443
|
|
1362
444
|
let(:concern) { client.write_concern }
|
1363
445
|
|
1364
446
|
context 'when no option was provided to the client' do
|
1365
447
|
|
1366
|
-
let(:client) {
|
448
|
+
let(:client) { new_local_client(['127.0.0.1:27017'], :database => SpecConfig.instance.test_db) }
|
1367
449
|
|
1368
450
|
it 'does not set the write concern' do
|
1369
451
|
expect(concern).to be_nil
|
@@ -1375,7 +457,7 @@ describe Mongo::Client do
|
|
1375
457
|
context 'when the option is acknowledged' do
|
1376
458
|
|
1377
459
|
let(:client) do
|
1378
|
-
|
460
|
+
new_local_client(['127.0.0.1:27017'], :write => { :j => true }, :database => SpecConfig.instance.test_db)
|
1379
461
|
end
|
1380
462
|
|
1381
463
|
it 'returns a acknowledged write concern' do
|
@@ -1388,7 +470,7 @@ describe Mongo::Client do
|
|
1388
470
|
context 'when the w is 0' do
|
1389
471
|
|
1390
472
|
let(:client) do
|
1391
|
-
|
473
|
+
new_local_client(['127.0.0.1:27017'], :write => { :w => 0 }, :database => SpecConfig.instance.test_db)
|
1392
474
|
end
|
1393
475
|
|
1394
476
|
it 'returns an unacknowledged write concern' do
|
@@ -1399,7 +481,7 @@ describe Mongo::Client do
|
|
1399
481
|
context 'when the w is -1' do
|
1400
482
|
|
1401
483
|
let(:client) do
|
1402
|
-
|
484
|
+
new_local_client(['127.0.0.1:27017'], :write => { :w => -1 }, :database => SpecConfig.instance.test_db)
|
1403
485
|
end
|
1404
486
|
|
1405
487
|
it 'raises an error' do
|
@@ -1427,7 +509,7 @@ describe Mongo::Client do
|
|
1427
509
|
end
|
1428
510
|
|
1429
511
|
let(:filter) do
|
1430
|
-
{ name:
|
512
|
+
{ name: SpecConfig.instance.test_db }
|
1431
513
|
end
|
1432
514
|
|
1433
515
|
it 'returns a filtered list of database names' do
|
@@ -1453,7 +535,7 @@ describe Mongo::Client do
|
|
1453
535
|
end
|
1454
536
|
|
1455
537
|
let(:filter) do
|
1456
|
-
{ name:
|
538
|
+
{ name: SpecConfig.instance.test_db }
|
1457
539
|
end
|
1458
540
|
|
1459
541
|
it 'returns a filtered list of database info documents' do
|
@@ -1469,7 +551,7 @@ describe Mongo::Client do
|
|
1469
551
|
end
|
1470
552
|
|
1471
553
|
let(:client) do
|
1472
|
-
|
554
|
+
ClientRegistry.instance.new_local_client(SpecConfig.instance.addresses, client_options).tap do |cl|
|
1473
555
|
cl.subscribe(Mongo::Monitoring::COMMAND, EventSubscriber.clear_events!)
|
1474
556
|
end
|
1475
557
|
end
|
@@ -1482,10 +564,6 @@ describe Mongo::Client do
|
|
1482
564
|
client.list_databases({}, true)
|
1483
565
|
end
|
1484
566
|
|
1485
|
-
after do
|
1486
|
-
client.close
|
1487
|
-
end
|
1488
|
-
|
1489
567
|
it 'sends the command with the nameOnly flag set to true' do
|
1490
568
|
expect(command[:nameOnly]).to be(true)
|
1491
569
|
end
|
@@ -1521,7 +599,7 @@ describe Mongo::Client do
|
|
1521
599
|
end
|
1522
600
|
|
1523
601
|
let(:filter) do
|
1524
|
-
{ name:
|
602
|
+
{ name: SpecConfig.instance.test_db }
|
1525
603
|
end
|
1526
604
|
|
1527
605
|
it 'returns a filtered list of Mongo::Database objects' do
|
@@ -1532,17 +610,13 @@ describe Mongo::Client do
|
|
1532
610
|
end
|
1533
611
|
|
1534
612
|
describe '#close' do
|
1535
|
-
|
1536
613
|
let(:client) do
|
1537
|
-
|
1538
|
-
end
|
1539
|
-
|
1540
|
-
before do
|
1541
|
-
# note that disconnect! is called also in the after block
|
1542
|
-
expect(client.cluster).to receive(:disconnect!).twice.and_call_original
|
614
|
+
Mongo::Client.new(['127.0.0.1:27017'], monitoring_io: false)
|
1543
615
|
end
|
1544
616
|
|
1545
617
|
it 'disconnects the cluster and returns true' do
|
618
|
+
# note that disconnect! is called also in the after block
|
619
|
+
expect(client.cluster).to receive(:disconnect!).and_call_original
|
1546
620
|
expect(client.close).to be(true)
|
1547
621
|
end
|
1548
622
|
end
|
@@ -1550,7 +624,7 @@ describe Mongo::Client do
|
|
1550
624
|
describe '#reconnect' do
|
1551
625
|
|
1552
626
|
let(:client) do
|
1553
|
-
|
627
|
+
new_local_client(['127.0.0.1:27017'])
|
1554
628
|
end
|
1555
629
|
|
1556
630
|
it 'replaces the cluster' do
|
@@ -1565,29 +639,11 @@ describe Mongo::Client do
|
|
1565
639
|
end
|
1566
640
|
end
|
1567
641
|
|
1568
|
-
describe '#dup' do
|
1569
|
-
|
1570
|
-
let(:client) do
|
1571
|
-
described_class.new(
|
1572
|
-
['127.0.0.1:27017'],
|
1573
|
-
:read => { :mode => :primary },
|
1574
|
-
:database => TEST_DB
|
1575
|
-
)
|
1576
|
-
end
|
1577
|
-
|
1578
|
-
it 'creates a client with Redacted options' do
|
1579
|
-
expect(client.dup.options).to be_a(Mongo::Options::Redacted)
|
1580
|
-
end
|
1581
|
-
end
|
1582
|
-
|
1583
642
|
describe '#collections' do
|
1584
643
|
|
1585
644
|
before do
|
1586
|
-
authorized_client.database[:users].create
|
1587
|
-
end
|
1588
|
-
|
1589
|
-
after do
|
1590
645
|
authorized_client.database[:users].drop
|
646
|
+
authorized_client.database[:users].create
|
1591
647
|
end
|
1592
648
|
|
1593
649
|
let(:collection) do
|
@@ -1606,7 +662,9 @@ describe Mongo::Client do
|
|
1606
662
|
authorized_client.start_session
|
1607
663
|
end
|
1608
664
|
|
1609
|
-
context 'when sessions are supported'
|
665
|
+
context 'when sessions are supported' do
|
666
|
+
min_server_version '3.6'
|
667
|
+
require_topology :replica_set, :sharded
|
1610
668
|
|
1611
669
|
it 'creates a session' do
|
1612
670
|
expect(session).to be_a(Mongo::Session)
|
@@ -1697,7 +755,9 @@ describe Mongo::Client do
|
|
1697
755
|
end
|
1698
756
|
end
|
1699
757
|
|
1700
|
-
context 'when two clients have the same cluster'
|
758
|
+
context 'when two clients have the same cluster' do
|
759
|
+
min_server_version '3.6'
|
760
|
+
require_topology :replica_set, :sharded
|
1701
761
|
|
1702
762
|
let(:client) do
|
1703
763
|
authorized_client.with(read: { mode: :secondary })
|
@@ -1712,10 +772,12 @@ describe Mongo::Client do
|
|
1712
772
|
end
|
1713
773
|
end
|
1714
774
|
|
1715
|
-
context 'when two clients have different clusters'
|
775
|
+
context 'when two clients have different clusters' do
|
776
|
+
min_server_version '3.6'
|
777
|
+
require_topology :replica_set, :sharded
|
1716
778
|
|
1717
779
|
let(:client) do
|
1718
|
-
|
780
|
+
another_authorized_client
|
1719
781
|
end
|
1720
782
|
|
1721
783
|
let(:session) do
|