mongo 2.5.3 → 2.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +5 -5
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +0 -0
- data/LICENSE +1 -1
- data/README.md +3 -2
- data/lib/mongo.rb +2 -2
- data/lib/mongo/address.rb +10 -2
- data/lib/mongo/address/ipv4.rb +1 -1
- data/lib/mongo/address/ipv6.rb +26 -5
- data/lib/mongo/address/unix.rb +1 -1
- data/lib/mongo/auth.rb +10 -3
- data/lib/mongo/auth/cr.rb +4 -1
- data/lib/mongo/auth/cr/conversation.rb +4 -1
- data/lib/mongo/auth/ldap.rb +1 -1
- data/lib/mongo/auth/ldap/conversation.rb +1 -1
- data/lib/mongo/auth/roles.rb +1 -1
- data/lib/mongo/auth/scram.rb +24 -7
- data/lib/mongo/auth/scram/conversation.rb +52 -19
- data/lib/mongo/auth/stringprep.rb +114 -0
- data/lib/mongo/auth/stringprep/profiles/sasl.rb +73 -0
- data/lib/mongo/auth/stringprep/tables.rb +3232 -0
- data/lib/mongo/auth/stringprep/unicode_normalize/normalize.rb +174 -0
- data/lib/mongo/auth/stringprep/unicode_normalize/tables.rb +1170 -0
- data/lib/mongo/auth/user.rb +14 -3
- data/lib/mongo/auth/user/view.rb +1 -1
- data/lib/mongo/auth/x509.rb +1 -1
- data/lib/mongo/auth/x509/conversation.rb +1 -1
- data/lib/mongo/bson.rb +1 -1
- data/lib/mongo/bulk_write.rb +8 -8
- data/lib/mongo/bulk_write/combineable.rb +1 -1
- 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 +4 -4
- data/lib/mongo/bulk_write/transformable.rb +1 -1
- data/lib/mongo/bulk_write/unordered_combiner.rb +1 -1
- data/lib/mongo/bulk_write/validatable.rb +1 -1
- data/lib/mongo/client.rb +115 -24
- data/lib/mongo/cluster.rb +17 -10
- data/lib/mongo/cluster/app_metadata.rb +7 -1
- data/lib/mongo/cluster/periodic_executor.rb +1 -1
- data/lib/mongo/cluster/reapers/socket_reaper.rb +1 -1
- data/lib/mongo/cluster/topology.rb +12 -2
- data/lib/mongo/cluster/topology/replica_set.rb +9 -1
- data/lib/mongo/cluster/topology/sharded.rb +1 -1
- data/lib/mongo/cluster/topology/single.rb +1 -1
- data/lib/mongo/cluster/topology/unknown.rb +1 -1
- data/lib/mongo/collection.rb +75 -19
- data/lib/mongo/collection/view.rb +1 -1
- data/lib/mongo/collection/view/aggregation.rb +1 -1
- data/lib/mongo/collection/view/builder.rb +1 -1
- data/lib/mongo/collection/view/builder/aggregation.rb +3 -3
- data/lib/mongo/collection/view/builder/find_command.rb +1 -1
- data/lib/mongo/collection/view/builder/flags.rb +1 -1
- data/lib/mongo/collection/view/builder/map_reduce.rb +1 -1
- data/lib/mongo/collection/view/builder/modifiers.rb +1 -1
- data/lib/mongo/collection/view/builder/op_query.rb +1 -1
- data/lib/mongo/collection/view/change_stream.rb +193 -17
- data/lib/mongo/collection/view/change_stream/retryable.rb +3 -20
- data/lib/mongo/collection/view/explainable.rb +1 -1
- data/lib/mongo/collection/view/immutable.rb +1 -1
- data/lib/mongo/collection/view/iterable.rb +2 -2
- data/lib/mongo/collection/view/map_reduce.rb +1 -1
- data/lib/mongo/collection/view/readable.rb +108 -29
- data/lib/mongo/collection/view/writable.rb +3 -3
- data/lib/mongo/cursor.rb +44 -4
- 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 +1 -1
- data/lib/mongo/cursor/builder/op_kill_cursors.rb +1 -1
- data/lib/mongo/database.rb +46 -3
- data/lib/mongo/database/view.rb +11 -11
- data/lib/mongo/dbref.rb +1 -1
- data/lib/mongo/error.rb +57 -1
- data/lib/mongo/error/bulk_write_error.rb +2 -2
- data/lib/mongo/error/change_stream_resumable.rb +37 -0
- data/lib/mongo/error/closed_stream.rb +1 -1
- data/lib/mongo/error/extra_file_chunk.rb +1 -1
- data/lib/mongo/error/failed_stringprep_validation.rb +38 -0
- data/lib/mongo/error/file_not_found.rb +1 -1
- data/lib/mongo/error/insufficient_iteration_count.rb +38 -0
- 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 +35 -0
- 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 +82 -0
- 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/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 +1 -1
- data/lib/mongo/error/no_srv_records.rb +1 -1
- data/lib/mongo/error/operation_failure.rb +108 -14
- data/lib/mongo/error/parser.rb +50 -1
- data/lib/mongo/error/socket_error.rb +5 -2
- data/lib/mongo/error/socket_timeout_error.rb +5 -2
- 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 +27 -0
- data/lib/mongo/event.rb +10 -9
- data/lib/mongo/event/base.rb +33 -0
- data/lib/mongo/event/description_changed.rb +2 -2
- data/lib/mongo/event/listeners.rb +1 -1
- data/lib/mongo/event/member_discovered.rb +4 -2
- data/lib/mongo/event/primary_elected.rb +2 -2
- data/lib/mongo/event/publisher.rb +1 -1
- data/lib/mongo/event/standalone_discovered.rb +2 -2
- 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 +3 -3
- data/lib/mongo/grid/file/info.rb +26 -3
- 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/index.rb +1 -1
- data/lib/mongo/index/view.rb +1 -1
- data/lib/mongo/loggable.rb +1 -1
- data/lib/mongo/logger.rb +1 -1
- data/lib/mongo/monitoring.rb +99 -62
- data/lib/mongo/monitoring/command_log_subscriber.rb +2 -2
- data/lib/mongo/monitoring/event.rb +2 -1
- data/lib/mongo/monitoring/event/command_failed.rb +19 -6
- data/lib/mongo/monitoring/event/command_started.rb +14 -3
- data/lib/mongo/monitoring/event/command_succeeded.rb +5 -3
- data/lib/mongo/monitoring/event/secure.rb +1 -1
- data/lib/mongo/monitoring/event/server_closed.rb +2 -2
- data/lib/mongo/monitoring/event/server_description_changed.rb +2 -2
- data/lib/mongo/monitoring/event/server_opening.rb +11 -2
- data/lib/mongo/monitoring/event/topology_changed.rb +13 -2
- data/lib/mongo/monitoring/event/topology_closed.rb +2 -2
- data/lib/mongo/monitoring/event/topology_opening.rb +11 -2
- data/lib/mongo/monitoring/publishable.rb +10 -6
- 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 +1 -1
- data/lib/mongo/monitoring/topology_opening_log_subscriber.rb +1 -1
- data/lib/mongo/operation/aggregate/op_msg.rb +3 -0
- data/lib/mongo/operation/create/op_msg.rb +9 -0
- data/lib/mongo/operation/create_index/op_msg.rb +9 -0
- data/lib/mongo/operation/create_user/command.rb +1 -1
- data/lib/mongo/operation/create_user/op_msg.rb +10 -1
- data/lib/mongo/operation/delete/op_msg.rb +3 -0
- data/lib/mongo/operation/distinct/op_msg.rb +9 -0
- data/lib/mongo/operation/drop/op_msg.rb +9 -0
- data/lib/mongo/operation/drop_database/op_msg.rb +9 -0
- data/lib/mongo/operation/drop_index/op_msg.rb +9 -0
- data/lib/mongo/operation/explain/op_msg.rb +3 -0
- data/lib/mongo/operation/find/op_msg.rb +3 -0
- data/lib/mongo/operation/get_more.rb +1 -1
- 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 +3 -0
- data/lib/mongo/operation/indexes/op_msg.rb +3 -0
- data/lib/mongo/operation/indexes/result.rb +1 -1
- data/lib/mongo/operation/insert/bulk_result.rb +32 -2
- data/lib/mongo/operation/insert/op_msg.rb +3 -0
- data/lib/mongo/operation/insert/result.rb +1 -1
- data/lib/mongo/operation/kill_cursors/op_msg.rb +9 -0
- data/lib/mongo/operation/list_collections/op_msg.rb +3 -0
- data/lib/mongo/operation/list_collections/result.rb +5 -1
- data/lib/mongo/operation/map_reduce/op_msg.rb +3 -0
- data/lib/mongo/operation/map_reduce/result.rb +1 -1
- data/lib/mongo/operation/parallel_scan/op_msg.rb +3 -0
- data/lib/mongo/operation/remove_user/op_msg.rb +9 -0
- data/lib/mongo/operation/result.rb +27 -14
- data/lib/mongo/operation/shared/executable.rb +1 -0
- data/lib/mongo/operation/shared/sessions_supported.rb +78 -7
- data/lib/mongo/operation/shared/specifiable.rb +18 -2
- data/lib/mongo/operation/shared/write_concern_supported.rb +1 -1
- data/lib/mongo/operation/update/op_msg.rb +3 -0
- data/lib/mongo/operation/update_user/command.rb +1 -1
- data/lib/mongo/operation/update_user/op_msg.rb +10 -1
- data/lib/mongo/operation/users_info/op_msg.rb +3 -0
- data/lib/mongo/options.rb +1 -1
- data/lib/mongo/options/mapper.rb +1 -1
- data/lib/mongo/options/redacted.rb +1 -1
- data/lib/mongo/protocol/bit_vector.rb +1 -1
- data/lib/mongo/protocol/compressed.rb +1 -1
- data/lib/mongo/protocol/delete.rb +1 -1
- data/lib/mongo/protocol/get_more.rb +7 -7
- data/lib/mongo/protocol/insert.rb +1 -1
- data/lib/mongo/protocol/kill_cursors.rb +1 -1
- data/lib/mongo/protocol/message.rb +5 -5
- data/lib/mongo/protocol/msg.rb +9 -7
- data/lib/mongo/protocol/query.rb +1 -1
- data/lib/mongo/protocol/registry.rb +1 -1
- data/lib/mongo/protocol/reply.rb +10 -10
- data/lib/mongo/protocol/serializers.rb +1 -1
- data/lib/mongo/protocol/update.rb +1 -1
- data/lib/mongo/retryable.rb +22 -14
- data/lib/mongo/server.rb +1 -1
- data/lib/mongo/server/connectable.rb +1 -1
- data/lib/mongo/server/connection.rb +16 -4
- data/lib/mongo/server/connection_pool.rb +1 -1
- data/lib/mongo/server/connection_pool/queue.rb +1 -1
- data/lib/mongo/server/context.rb +1 -1
- data/lib/mongo/server/description.rb +14 -2
- data/lib/mongo/server/description/features.rb +10 -9
- data/lib/mongo/server/description/inspector.rb +1 -1
- data/lib/mongo/server/description/inspector/description_changed.rb +1 -1
- data/lib/mongo/server/description/inspector/member_discovered.rb +1 -1
- data/lib/mongo/server/description/inspector/primary_elected.rb +1 -1
- data/lib/mongo/server/description/inspector/standalone_discovered.rb +1 -1
- data/lib/mongo/server/monitor.rb +15 -3
- data/lib/mongo/server/monitor/connection.rb +1 -1
- 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 +7 -2
- data/lib/mongo/session.rb +389 -12
- data/lib/mongo/session/server_session.rb +7 -2
- data/lib/mongo/session/session_pool.rb +1 -1
- data/lib/mongo/socket.rb +1 -1
- data/lib/mongo/socket/ssl.rb +1 -1
- data/lib/mongo/socket/tcp.rb +1 -1
- data/lib/mongo/socket/unix.rb +1 -1
- data/lib/mongo/uri.rb +6 -4
- data/lib/mongo/uri/srv_protocol.rb +1 -1
- data/lib/mongo/version.rb +2 -2
- data/lib/mongo/write_concern.rb +1 -1
- data/lib/mongo/write_concern/acknowledged.rb +1 -1
- data/lib/mongo/write_concern/normalizable.rb +1 -1
- data/lib/mongo/write_concern/unacknowledged.rb +1 -1
- data/mongo.gemspec +4 -1
- data/spec/atlas/atlas_connectivity_spec.rb +54 -0
- data/spec/integration/bulk_insert_spec.rb +78 -0
- data/spec/integration/change_stream_spec.rb +365 -0
- data/spec/integration/command_monitoring_spec.rb +92 -0
- data/spec/lite_spec_helper.rb +63 -0
- data/spec/mongo/address/ipv6_spec.rb +29 -1
- data/spec/mongo/address_spec.rb +34 -0
- data/spec/mongo/auth/scram/conversation_spec.rb +326 -120
- data/spec/mongo/auth/scram/negotiation_spec.rb +574 -0
- data/spec/mongo/auth/scram_spec.rb +107 -38
- data/spec/mongo/auth/stringprep/profiles/sasl_spec.rb +113 -0
- data/spec/mongo/auth/stringprep_spec.rb +188 -0
- data/spec/mongo/auth/user/view_spec.rb +5 -2
- data/spec/mongo/auth/user_spec.rb +1 -1
- data/spec/mongo/bulk_write/result_spec.rb +120 -0
- data/spec/mongo/bulk_write_spec.rb +42 -2
- data/spec/mongo/client_spec.rb +121 -9
- data/spec/mongo/cluster/app_metadata_spec.rb +14 -1
- data/spec/mongo/cluster/topology_spec.rb +1 -23
- data/spec/mongo/collection/view/change_stream_spec.rb +62 -180
- data/spec/mongo/collection_spec.rb +45 -12
- data/spec/mongo/cursor/builder/get_more_command_spec.rb +7 -7
- data/spec/mongo/cursor_spec.rb +2 -2
- data/spec/mongo/database_spec.rb +3 -3
- data/spec/mongo/docs_examples_spec.rb +194 -0
- data/spec/mongo/error/operation_failure_spec.rb +152 -0
- data/spec/mongo/error/parser_spec.rb +127 -0
- data/spec/mongo/grid/fs_bucket_spec.rb +32 -0
- data/spec/mongo/grid/stream/write_spec.rb +40 -1
- data/spec/mongo/monitoring/event/command_failed_spec.rb +30 -0
- data/spec/mongo/monitoring/event/command_started_spec.rb +26 -4
- data/spec/mongo/monitoring/event/command_succeeded_spec.rb +29 -7
- data/spec/mongo/monitoring_spec.rb +28 -3
- data/spec/mongo/protocol/get_more_spec.rb +2 -2
- data/spec/mongo/retryable_spec.rb +252 -34
- data/spec/mongo/retryable_writes_spec.rb +468 -544
- data/spec/mongo/server/connection_spec.rb +5 -5
- data/spec/mongo/server/description_spec.rb +23 -6
- data/spec/mongo/session/server_session_spec.rb +2 -2
- data/spec/mongo/session/session_pool_spec.rb +2 -2
- data/spec/mongo/transactions_examples_spec.rb +227 -0
- data/spec/mongo/transactions_spec.rb +44 -0
- data/spec/spec_helper.rb +135 -49
- data/spec/spec_tests/change_streams_spec.rb +42 -0
- data/spec/{mongo → spec_tests}/command_monitoring_spec.rb +8 -2
- data/spec/{mongo → spec_tests}/connection_string_spec.rb +1 -1
- data/spec/{mongo → spec_tests}/crud_spec.rb +5 -7
- data/spec/{mongo → spec_tests}/dns_seedlist_discovery_spec.rb +1 -1
- data/spec/{mongo → spec_tests}/gridfs_spec.rb +0 -0
- data/spec/{mongo → spec_tests}/max_staleness_spec.rb +0 -0
- data/spec/spec_tests/retryable_writes_spec.rb +78 -0
- data/spec/{mongo → spec_tests}/sdam_monitoring_spec.rb +4 -3
- data/spec/{mongo → spec_tests}/sdam_spec.rb +7 -7
- data/spec/{mongo → spec_tests}/server_selection_rtt_spec.rb +0 -0
- data/spec/{mongo → spec_tests}/server_selection_spec.rb +0 -0
- data/spec/support/authorization.rb +18 -6
- data/spec/support/change_streams.rb +265 -0
- data/spec/support/change_streams/operation.rb +62 -0
- data/spec/support/change_streams_tests/change-streams-errors.yml +53 -0
- data/spec/support/change_streams_tests/change-streams.yml +299 -0
- data/spec/support/command_monitoring.rb +1 -1
- data/spec/support/command_monitoring/bulkWrite.yml +4 -28
- data/spec/support/command_monitoring/command.yml +19 -0
- data/spec/support/command_monitoring/find.yml +17 -19
- data/spec/support/command_monitoring/insertMany.yml +2 -8
- data/spec/support/command_monitoring/unacknowledgedBulkWrite.yml +34 -0
- data/spec/support/connection_string.rb +1 -1
- data/spec/support/constraints.rb +56 -0
- data/spec/support/crud.rb +9 -4
- data/spec/support/crud/read.rb +24 -3
- data/spec/support/crud/write.rb +7 -2
- data/spec/support/crud_tests/read/count-collation.yml +12 -2
- data/spec/support/crud_tests/read/count.yml +43 -5
- data/spec/support/gridfs.rb +1 -1
- data/spec/support/primary_socket.rb +21 -0
- data/spec/support/retryable_writes_tests/bulkWrite-serverErrors.yml +90 -0
- data/spec/support/retryable_writes_tests/bulkWrite.yml +99 -1
- data/spec/support/retryable_writes_tests/deleteOne-serverErrors.yml +50 -0
- data/spec/support/retryable_writes_tests/deleteOne.yml +10 -1
- data/spec/support/retryable_writes_tests/findOneAndDelete-serverErrors.yml +50 -0
- data/spec/support/retryable_writes_tests/findOneAndDelete.yml +39 -30
- data/spec/support/retryable_writes_tests/findOneAndReplace-serverErrors.yml +54 -0
- data/spec/support/retryable_writes_tests/findOneAndReplace.yml +9 -0
- data/spec/support/retryable_writes_tests/findOneAndUpdate-serverErrors.yml +54 -0
- data/spec/support/retryable_writes_tests/findOneAndUpdate.yml +9 -0
- data/spec/support/retryable_writes_tests/insertMany-serverErrors.yml +59 -0
- data/spec/support/retryable_writes_tests/insertMany.yml +11 -6
- data/spec/support/retryable_writes_tests/insertOne-serverErrors.yml +471 -0
- data/spec/support/retryable_writes_tests/insertOne.yml +9 -0
- data/spec/support/retryable_writes_tests/replaceOne-serverErrors.yml +58 -0
- data/spec/support/retryable_writes_tests/replaceOne.yml +9 -0
- data/spec/support/retryable_writes_tests/updateOne-serverErrors.yml +58 -0
- data/spec/support/retryable_writes_tests/updateOne.yml +71 -53
- data/spec/support/sdam/rs/normalize_case_me.yml +100 -0
- data/spec/support/sdam/sharded/compatible.yml +38 -0
- data/spec/support/sdam/sharded/mongos_disconnect.yml +9 -3
- data/spec/support/sdam/sharded/multiple_mongoses.yml +6 -2
- data/spec/support/sdam/sharded/non_mongos_removed.yml +6 -2
- data/spec/support/sdam/sharded/too_new.yml +36 -0
- data/spec/support/sdam/sharded/too_old.yml +36 -0
- data/spec/support/sdam/single/compatible.yml +26 -0
- data/spec/support/sdam/single/direct_connection_external_ip.yml +3 -1
- data/spec/support/sdam/single/direct_connection_mongos.yml +3 -1
- data/spec/support/sdam/single/direct_connection_rsarbiter.yml +3 -1
- data/spec/support/sdam/single/direct_connection_rsprimary.yml +3 -1
- data/spec/support/sdam/single/direct_connection_rssecondary.yml +3 -1
- data/spec/support/sdam/single/direct_connection_slave.yml +3 -1
- data/spec/support/sdam/single/direct_connection_standalone.yml +3 -1
- data/spec/support/sdam/single/not_ok_response.yml +6 -2
- data/spec/support/sdam/single/standalone_removed.yml +3 -1
- data/spec/support/sdam/single/too_new.yml +26 -0
- data/spec/support/sdam/single/too_old.yml +24 -0
- data/spec/support/shared/session.rb +107 -0
- data/spec/support/transactions.rb +391 -0
- data/spec/support/transactions/operation.rb +373 -0
- data/spec/support/transactions_tests/abort.yml +403 -0
- data/spec/support/transactions_tests/bulk.yml +267 -0
- data/spec/support/transactions_tests/causal-consistency.yml +173 -0
- data/spec/support/transactions_tests/commit.yml +593 -0
- data/spec/support/transactions_tests/delete.yml +184 -0
- data/spec/support/transactions_tests/error-labels.yml +948 -0
- data/spec/support/transactions_tests/errors.yml +125 -0
- data/spec/support/transactions_tests/findOneAndDelete.yml +126 -0
- data/spec/support/transactions_tests/findOneAndReplace.yml +140 -0
- data/spec/support/transactions_tests/findOneAndUpdate.yml +228 -0
- data/spec/support/transactions_tests/insert.yml +264 -0
- data/spec/support/transactions_tests/isolation.yml +125 -0
- data/spec/support/transactions_tests/read-pref.yml +340 -0
- data/spec/support/transactions_tests/reads.yml +298 -0
- data/spec/support/transactions_tests/retryable-abort.yml +1292 -0
- data/spec/support/transactions_tests/retryable-commit.yml +1332 -0
- data/spec/support/transactions_tests/retryable-writes.yml +208 -0
- data/spec/support/transactions_tests/run-command.yml +189 -0
- data/spec/support/transactions_tests/transaction-options.yml +877 -0
- data/spec/support/transactions_tests/update.yml +246 -0
- data/spec/support/transactions_tests/write-concern.yml +236 -0
- metadata +494 -359
- metadata.gz.sig +0 -0
- data/lib/csasl/csasl.bundle +0 -0
@@ -16,8 +16,11 @@ describe Mongo::Auth::User::View do
|
|
16
16
|
|
17
17
|
let!(:response) do
|
18
18
|
view.create(
|
19
|
-
|
20
|
-
|
19
|
+
'durran',
|
20
|
+
{
|
21
|
+
password: 'password',
|
22
|
+
roles: [Mongo::Auth::Roles::READ_WRITE],
|
23
|
+
}
|
21
24
|
)
|
22
25
|
end
|
23
26
|
|
@@ -0,0 +1,120 @@
|
|
1
|
+
require 'lite_spec_helper'
|
2
|
+
|
3
|
+
describe Mongo::BulkWrite::Result do
|
4
|
+
let(:results_document) do
|
5
|
+
{'n_inserted' => 2, 'n' => 3, 'inserted_ids' => [1, 2]}
|
6
|
+
end
|
7
|
+
|
8
|
+
let(:subject) { described_class.new(results_document) }
|
9
|
+
|
10
|
+
describe 'construction' do
|
11
|
+
it 'works' do
|
12
|
+
expect(subject).to be_a(described_class)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
describe '#inserted_count' do
|
17
|
+
it 'is taken from results document' do
|
18
|
+
expect(subject.inserted_count).to eql(2)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
describe '#inserted_ids' do
|
23
|
+
it 'is taken from results document' do
|
24
|
+
expect(subject.inserted_ids).to eql([1, 2])
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
describe '#deleted_count' do
|
29
|
+
let(:results_document) do
|
30
|
+
{'n_removed' => 2, 'n' => 3}
|
31
|
+
end
|
32
|
+
|
33
|
+
it 'is taken from results document' do
|
34
|
+
expect(subject.deleted_count).to eql(2)
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
describe '#matched_count' do
|
39
|
+
let(:results_document) do
|
40
|
+
{'n_modified' => 1, 'n_matched' => 2, 'n' => 3}
|
41
|
+
end
|
42
|
+
|
43
|
+
it 'is taken from results document' do
|
44
|
+
expect(subject.matched_count).to eql(2)
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
describe '#modified_count' do
|
49
|
+
let(:results_document) do
|
50
|
+
{'n_modified' => 1, 'n_matched' => 2, 'n' => 3}
|
51
|
+
end
|
52
|
+
|
53
|
+
it 'is taken from results document' do
|
54
|
+
expect(subject.modified_count).to eql(1)
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
describe '#upserted_count' do
|
59
|
+
let(:results_document) do
|
60
|
+
{'n_upserted' => 2, 'n' => 3, 'upserted_ids' => [1, 2]}
|
61
|
+
end
|
62
|
+
|
63
|
+
it 'is taken from results document' do
|
64
|
+
expect(subject.upserted_count).to eql(2)
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
describe '#upserted_ids' do
|
69
|
+
let(:results_document) do
|
70
|
+
{'n_upserted' => 2, 'n' => 3, 'upserted_ids' => [1, 2]}
|
71
|
+
end
|
72
|
+
|
73
|
+
it 'is taken from results document' do
|
74
|
+
expect(subject.upserted_ids).to eql([1, 2])
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
describe '#validate!' do
|
79
|
+
context 'no errors' do
|
80
|
+
it 'returns self' do
|
81
|
+
expect(subject.validate!).to eql(subject)
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
context 'with top level error' do
|
86
|
+
let(:results_document) do
|
87
|
+
{'writeErrors' => {
|
88
|
+
'ok' => 0,
|
89
|
+
'errmsg' => 'not master',
|
90
|
+
'code' => 10107,
|
91
|
+
'codeName' => 'NotMaster',
|
92
|
+
}}
|
93
|
+
end
|
94
|
+
|
95
|
+
it 'raises BulkWriteError' do
|
96
|
+
expect do
|
97
|
+
subject.validate!
|
98
|
+
# BulkWriteErrors don't have any messages on them
|
99
|
+
end.to raise_error(Mongo::Error::BulkWriteError, nil)
|
100
|
+
end
|
101
|
+
end
|
102
|
+
|
103
|
+
context 'with write concern error' do
|
104
|
+
let(:results_document) do
|
105
|
+
{'n' => 1, 'writeConcernErrors' => {
|
106
|
+
'errmsg' => 'Not enough data-bearing nodes',
|
107
|
+
'code' => 100,
|
108
|
+
'codeName' => 'CannotSatisfyWriteConcern',
|
109
|
+
}}
|
110
|
+
end
|
111
|
+
|
112
|
+
it 'raises BulkWriteError' do
|
113
|
+
expect do
|
114
|
+
subject.validate!
|
115
|
+
# BulkWriteErrors don't have any messages on them
|
116
|
+
end.to raise_error(Mongo::Error::BulkWriteError, nil)
|
117
|
+
end
|
118
|
+
end
|
119
|
+
end
|
120
|
+
end
|
@@ -1246,6 +1246,38 @@ describe Mongo::BulkWrite do
|
|
1246
1246
|
}.to raise_error(Mongo::Error::OperationFailure)
|
1247
1247
|
end
|
1248
1248
|
end
|
1249
|
+
|
1250
|
+
context 'when write_concern is specified as an option' do
|
1251
|
+
|
1252
|
+
let(:extra_options) do
|
1253
|
+
{ write_concern: { w: 0 } }
|
1254
|
+
end
|
1255
|
+
|
1256
|
+
let(:result) do
|
1257
|
+
bulk_write.execute
|
1258
|
+
end
|
1259
|
+
|
1260
|
+
it 'updates the document' do
|
1261
|
+
result
|
1262
|
+
expect(authorized_collection.find(_id: 0).first[:name]).to eq('test')
|
1263
|
+
end
|
1264
|
+
|
1265
|
+
it 'does not report the upserted count' do
|
1266
|
+
expect(result.upserted_count).to eq(0)
|
1267
|
+
end
|
1268
|
+
|
1269
|
+
it 'does not report the modified_count count' do
|
1270
|
+
expect(result.modified_count).to eq(0)
|
1271
|
+
end
|
1272
|
+
|
1273
|
+
it 'does not report the matched count' do
|
1274
|
+
expect(result.matched_count).to eq(0)
|
1275
|
+
end
|
1276
|
+
|
1277
|
+
it 'does not report the upserted id' do
|
1278
|
+
expect(result.upserted_ids).to eq([])
|
1279
|
+
end
|
1280
|
+
end
|
1249
1281
|
end
|
1250
1282
|
|
1251
1283
|
context 'when the write has a collation specified' do
|
@@ -2074,8 +2106,12 @@ describe Mongo::BulkWrite do
|
|
2074
2106
|
|
2075
2107
|
context 'when the option is true' do
|
2076
2108
|
|
2109
|
+
let(:options) do
|
2110
|
+
{ ordered: true }
|
2111
|
+
end
|
2112
|
+
|
2077
2113
|
let(:bulk_write) do
|
2078
|
-
described_class.new(authorized_collection, [],
|
2114
|
+
described_class.new(authorized_collection, [], options)
|
2079
2115
|
end
|
2080
2116
|
|
2081
2117
|
it 'returns true' do
|
@@ -2085,8 +2121,12 @@ describe Mongo::BulkWrite do
|
|
2085
2121
|
|
2086
2122
|
context 'when the option is false' do
|
2087
2123
|
|
2124
|
+
let(:options) do
|
2125
|
+
{ ordered: false }
|
2126
|
+
end
|
2127
|
+
|
2088
2128
|
let(:bulk_write) do
|
2089
|
-
described_class.new(authorized_collection, [],
|
2129
|
+
described_class.new(authorized_collection, [], options)
|
2090
2130
|
end
|
2091
2131
|
|
2092
2132
|
it 'returns false' do
|
data/spec/mongo/client_spec.rb
CHANGED
@@ -6,6 +6,61 @@ describe Mongo::Client do
|
|
6
6
|
begin; client.close; rescue; end
|
7
7
|
end
|
8
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
|
32
|
+
|
33
|
+
it 'rejects bogus read preference as symbol' do
|
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
|
63
|
+
|
9
64
|
describe '#==' do
|
10
65
|
|
11
66
|
let(:client) do
|
@@ -37,7 +92,7 @@ describe Mongo::Client do
|
|
37
92
|
end
|
38
93
|
end
|
39
94
|
|
40
|
-
context 'when the options
|
95
|
+
context 'when the options are not equal' do
|
41
96
|
|
42
97
|
let(:other) do
|
43
98
|
described_class.new(
|
@@ -47,7 +102,22 @@ describe Mongo::Client do
|
|
47
102
|
)
|
48
103
|
end
|
49
104
|
|
50
|
-
it 'returns
|
105
|
+
it 'returns false' do
|
106
|
+
expect(client).not_to eq(other)
|
107
|
+
end
|
108
|
+
end
|
109
|
+
|
110
|
+
context 'when cluster is not equal' do
|
111
|
+
|
112
|
+
let(:other) do
|
113
|
+
described_class.new(
|
114
|
+
['127.0.0.1:27010'],
|
115
|
+
:read => { :mode => :primary },
|
116
|
+
:database => TEST_DB
|
117
|
+
)
|
118
|
+
end
|
119
|
+
|
120
|
+
it 'returns false' do
|
51
121
|
expect(client).not_to eq(other)
|
52
122
|
end
|
53
123
|
end
|
@@ -128,7 +198,7 @@ describe Mongo::Client do
|
|
128
198
|
end
|
129
199
|
end
|
130
200
|
|
131
|
-
context 'when the options
|
201
|
+
context 'when the options are not equal' do
|
132
202
|
|
133
203
|
let(:other) do
|
134
204
|
described_class.new(
|
@@ -138,7 +208,22 @@ describe Mongo::Client do
|
|
138
208
|
)
|
139
209
|
end
|
140
210
|
|
141
|
-
it 'returns
|
211
|
+
it 'returns false' do
|
212
|
+
expect(client).not_to eql(other)
|
213
|
+
end
|
214
|
+
end
|
215
|
+
|
216
|
+
context 'when the cluster is not equal' do
|
217
|
+
|
218
|
+
let(:other) do
|
219
|
+
described_class.new(
|
220
|
+
['127.0.0.1:27010'],
|
221
|
+
:read => { :mode => :primary },
|
222
|
+
:database => TEST_DB
|
223
|
+
)
|
224
|
+
end
|
225
|
+
|
226
|
+
it 'returns false' do
|
142
227
|
expect(client).not_to eql(other)
|
143
228
|
end
|
144
229
|
end
|
@@ -1242,6 +1327,33 @@ describe Mongo::Client do
|
|
1242
1327
|
expect(new_client.options.keys).not_to include('invalid')
|
1243
1328
|
end
|
1244
1329
|
end
|
1330
|
+
|
1331
|
+
context 'when client is created with ipv6 address' do
|
1332
|
+
let(:client) do
|
1333
|
+
described_class.new(['[::1]:27017'], :database => TEST_DB)
|
1334
|
+
end
|
1335
|
+
|
1336
|
+
context 'when providing nil' do
|
1337
|
+
|
1338
|
+
it 'returns the cloned client' do
|
1339
|
+
expect(client.with(nil)).to eq(client)
|
1340
|
+
end
|
1341
|
+
end
|
1342
|
+
|
1343
|
+
context 'when changing options' do
|
1344
|
+
let(:new_options) do
|
1345
|
+
{ app_name: 'client_test' }
|
1346
|
+
end
|
1347
|
+
|
1348
|
+
let!(:new_client) do
|
1349
|
+
client.with(new_options)
|
1350
|
+
end
|
1351
|
+
|
1352
|
+
it 'returns a new client' do
|
1353
|
+
expect(new_client).not_to equal(client)
|
1354
|
+
end
|
1355
|
+
end
|
1356
|
+
end
|
1245
1357
|
end
|
1246
1358
|
|
1247
1359
|
describe '#write_concern' do
|
@@ -1362,7 +1474,7 @@ describe Mongo::Client do
|
|
1362
1474
|
end
|
1363
1475
|
|
1364
1476
|
let(:command) do
|
1365
|
-
EventSubscriber.started_events.find { |c| c.command_name ==
|
1477
|
+
EventSubscriber.started_events.find { |c| c.command_name == 'listDatabases' }.command
|
1366
1478
|
end
|
1367
1479
|
|
1368
1480
|
before do
|
@@ -1492,8 +1604,8 @@ describe Mongo::Client do
|
|
1492
1604
|
expect(session).to be_a(Mongo::Session)
|
1493
1605
|
end
|
1494
1606
|
|
1495
|
-
it 'sets the last use field to the current time' do
|
1496
|
-
expect(session.instance_variable_get(:@server_session).last_use).to be_within(
|
1607
|
+
it 'sets the last use field to the current time', retry: 4 do
|
1608
|
+
expect(session.instance_variable_get(:@server_session).last_use).to be_within(1).of(Time.now)
|
1497
1609
|
end
|
1498
1610
|
|
1499
1611
|
context 'when options are provided' do
|
@@ -1551,8 +1663,8 @@ describe Mongo::Client do
|
|
1551
1663
|
end
|
1552
1664
|
|
1553
1665
|
it 'preserves the transaction numbers on the server sessions' do
|
1554
|
-
expect(authorized_client.start_session.next_txn_num).to be(
|
1555
|
-
expect(authorized_client.start_session.next_txn_num).to be(
|
1666
|
+
expect(authorized_client.start_session.next_txn_num).to be(3)
|
1667
|
+
expect(authorized_client.start_session.next_txn_num).to be(3)
|
1556
1668
|
end
|
1557
1669
|
end
|
1558
1670
|
|
@@ -112,7 +112,20 @@ describe Mongo::Cluster::AppMetadata do
|
|
112
112
|
end
|
113
113
|
|
114
114
|
it 'truncates the document to be just an ismaster command and the compressors', unless: compression_enabled? do
|
115
|
-
|
115
|
+
# Because we sometimes request that the server provide a list of valid auth mechanisms for
|
116
|
+
# the user, we need to conditionally add the length of that metadata to the expected
|
117
|
+
# length of the isMaster document.
|
118
|
+
sasl_supported_mechs_size = 0
|
119
|
+
sasl_supported_mechs = app_metadata.instance_variable_get(:@request_auth_mech)
|
120
|
+
|
121
|
+
if sasl_supported_mechs
|
122
|
+
sasl_supported_mechs_size += 1 # length of BSON type byte
|
123
|
+
sasl_supported_mechs_size += 'saslSupportedMechs'.length + 1 # length of BSON key
|
124
|
+
sasl_supported_mechs_size += 4 # length of BSON string length
|
125
|
+
sasl_supported_mechs_size += sasl_supported_mechs.length + 1 # length of BSON string
|
126
|
+
end
|
127
|
+
|
128
|
+
expect(app_metadata.ismaster_bytes.length).to eq(Mongo::Server::Monitor::Connection::ISMASTER_BYTES.length + sasl_supported_mechs_size + 26)
|
116
129
|
end
|
117
130
|
end
|
118
131
|
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
require '
|
1
|
+
require 'lite_spec_helper'
|
2
2
|
|
3
3
|
describe Mongo::Cluster::Topology do
|
4
4
|
|
@@ -105,28 +105,6 @@ describe Mongo::Cluster::Topology do
|
|
105
105
|
expect(topology).to be_a(Mongo::Cluster::Topology::Unknown)
|
106
106
|
end
|
107
107
|
end
|
108
|
-
|
109
|
-
context 'when provided a single mongos', if: single_mongos? do
|
110
|
-
|
111
|
-
let(:topology) do
|
112
|
-
described_class.initial(ADDRESSES, monitoring, TEST_OPTIONS)
|
113
|
-
end
|
114
|
-
|
115
|
-
it 'returns a sharded topology' do
|
116
|
-
expect(topology).to be_a(Mongo::Cluster::Topology::Sharded)
|
117
|
-
end
|
118
|
-
end
|
119
|
-
|
120
|
-
context 'when provided a single replica set member', if: single_rs_member? do
|
121
|
-
|
122
|
-
let(:topology) do
|
123
|
-
described_class.initial(ADDRESSES, monitoring, TEST_OPTIONS)
|
124
|
-
end
|
125
|
-
|
126
|
-
it 'returns a single topology' do
|
127
|
-
expect(topology).to be_a(Mongo::Cluster::Topology::Single)
|
128
|
-
end
|
129
|
-
end
|
130
108
|
end
|
131
109
|
end
|
132
110
|
end
|