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
@@ -1,4 +1,4 @@
|
|
1
|
-
# Copyright (C) 2017 MongoDB, Inc.
|
1
|
+
# Copyright (C) 2017-2018 MongoDB, Inc.
|
2
2
|
#
|
3
3
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
4
|
# you may not use this file except in compliance with the License.
|
@@ -38,6 +38,11 @@ module Mongo
|
|
38
38
|
# @since 2.5.0
|
39
39
|
attr_reader :last_use
|
40
40
|
|
41
|
+
# The current transactions number.
|
42
|
+
#
|
43
|
+
# @since 2.5.0
|
44
|
+
attr_reader :txn_num
|
45
|
+
|
41
46
|
# Initialize a ServerSession.
|
42
47
|
#
|
43
48
|
# @example
|
@@ -47,7 +52,7 @@ module Mongo
|
|
47
52
|
def initialize
|
48
53
|
set_last_use!
|
49
54
|
session_id
|
50
|
-
@txn_num =
|
55
|
+
@txn_num = 0
|
51
56
|
end
|
52
57
|
|
53
58
|
# Update the last_use attribute of the server session to now.
|
data/lib/mongo/socket.rb
CHANGED
data/lib/mongo/socket/ssl.rb
CHANGED
data/lib/mongo/socket/tcp.rb
CHANGED
data/lib/mongo/socket/unix.rb
CHANGED
data/lib/mongo/uri.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# Copyright (C) 2014-
|
1
|
+
# Copyright (C) 2014-2018 MongoDB, Inc.
|
2
2
|
#
|
3
3
|
# Licensed under the Apache License, Version 2.0 (the 'License');
|
4
4
|
# you may not use this file except in compliance with the License.
|
@@ -175,7 +175,7 @@ module Mongo
|
|
175
175
|
# @since 2.1.0
|
176
176
|
INVALID_PORT = "Invalid port. Port must be an integer greater than 0 and less than 65536".freeze
|
177
177
|
|
178
|
-
# Map of URI read preference modes to
|
178
|
+
# Map of URI read preference modes to Ruby driver read preference modes
|
179
179
|
#
|
180
180
|
# @since 2.0.0
|
181
181
|
READ_MODE_MAP = {
|
@@ -186,15 +186,17 @@ module Mongo
|
|
186
186
|
'nearest' => :nearest
|
187
187
|
}.freeze
|
188
188
|
|
189
|
-
# Map of URI authentication mechanisms to
|
189
|
+
# Map of URI authentication mechanisms to Ruby driver mechanisms
|
190
190
|
#
|
191
191
|
# @since 2.0.0
|
192
192
|
AUTH_MECH_MAP = {
|
193
193
|
'PLAIN' => :plain,
|
194
|
+
# MONGODB-CR is deprecated and will be removed in driver version 3.0
|
194
195
|
'MONGODB-CR' => :mongodb_cr,
|
195
196
|
'GSSAPI' => :gssapi,
|
196
197
|
'MONGODB-X509' => :mongodb_x509,
|
197
|
-
'SCRAM-SHA-1' => :scram
|
198
|
+
'SCRAM-SHA-1' => :scram,
|
199
|
+
'SCRAM-SHA-256' => :scram256
|
198
200
|
}.freeze
|
199
201
|
|
200
202
|
# Options that are allowed to appear more than once in the uri.
|
data/lib/mongo/version.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# Copyright (C) 2014-
|
1
|
+
# Copyright (C) 2014-2018 MongoDB, Inc.
|
2
2
|
#
|
3
3
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
4
|
# you may not use this file except in compliance with the License.
|
@@ -17,5 +17,5 @@ module Mongo
|
|
17
17
|
# The current version of the driver.
|
18
18
|
#
|
19
19
|
# @since 2.0.0
|
20
|
-
VERSION = '2.
|
20
|
+
VERSION = '2.6.0'.freeze
|
21
21
|
end
|
data/lib/mongo/write_concern.rb
CHANGED
data/mongo.gemspec
CHANGED
@@ -4,7 +4,10 @@ require 'mongo/version'
|
|
4
4
|
|
5
5
|
Gem::Specification.new do |s|
|
6
6
|
s.name = 'mongo'
|
7
|
-
|
7
|
+
# The dup call makes `bundle install` work on ruby 1.9.3.
|
8
|
+
# Without it rubygems tries to modify version which fails because
|
9
|
+
# Mongo::VERSION is frozen.
|
10
|
+
s.version = Mongo::VERSION.dup
|
8
11
|
s.platform = Gem::Platform::RUBY
|
9
12
|
|
10
13
|
s.authors = ['Tyler Brock', 'Emily Stolfo', 'Durran Jordan']
|
@@ -0,0 +1,54 @@
|
|
1
|
+
require 'lite_spec_helper'
|
2
|
+
|
3
|
+
describe 'Atlas connectivity' do
|
4
|
+
shared_examples 'connects to Atlas' do
|
5
|
+
let(:uri) { ENV[var] }
|
6
|
+
let(:client) { Mongo::Client.new(uri) }
|
7
|
+
|
8
|
+
before do
|
9
|
+
if uri.nil?
|
10
|
+
skip "#{var} not set in environment"
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
it 'runs ismaster successfully' do
|
15
|
+
result = client.database.command(:ismaster => 1)
|
16
|
+
expect(result.documents.first['ismaster']).to be true
|
17
|
+
end
|
18
|
+
|
19
|
+
it 'runs findOne successfully' do
|
20
|
+
result = client.use(:test)['test'].find.to_a
|
21
|
+
expect(result).to be_a(Array)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
context 'Atlas replica set' do
|
26
|
+
let(:var) { 'ATLAS_REPLICA_SET_URI' }
|
27
|
+
|
28
|
+
it_behaves_like 'connects to Atlas'
|
29
|
+
end
|
30
|
+
|
31
|
+
context 'Atlas sharded cluster' do
|
32
|
+
let(:var) { 'ATLAS_SHARDED_URI' }
|
33
|
+
|
34
|
+
it_behaves_like 'connects to Atlas'
|
35
|
+
end
|
36
|
+
|
37
|
+
context 'Atlas free tier replica set' do
|
38
|
+
let(:var) { 'ATLAS_FREE_TIER_URI' }
|
39
|
+
|
40
|
+
it_behaves_like 'connects to Atlas'
|
41
|
+
end
|
42
|
+
|
43
|
+
context 'Atlas TLS 1.1 only replica set' do
|
44
|
+
let(:var) { 'ATLAS_TLS11_URI' }
|
45
|
+
|
46
|
+
it_behaves_like 'connects to Atlas'
|
47
|
+
end
|
48
|
+
|
49
|
+
context 'Atlas TLS 1.2 only replica set' do
|
50
|
+
let(:var) { 'ATLAS_TLS12_URI' }
|
51
|
+
|
52
|
+
it_behaves_like 'connects to Atlas'
|
53
|
+
end
|
54
|
+
end
|
@@ -0,0 +1,78 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe 'Bulk insert' do
|
4
|
+
include PrimarySocket
|
5
|
+
|
6
|
+
FAIL_POINT_BASE_COMMAND = { 'configureFailPoint' => "failCommand" }
|
7
|
+
|
8
|
+
let(:collection_name) { 'bulk_insert_spec' }
|
9
|
+
let(:collection) { authorized_client[collection_name] }
|
10
|
+
|
11
|
+
describe 'inserted_ids' do
|
12
|
+
before do
|
13
|
+
collection.delete_many
|
14
|
+
end
|
15
|
+
|
16
|
+
context 'success' do
|
17
|
+
it 'returns one insert_id as array' do
|
18
|
+
result = collection.insert_many([
|
19
|
+
{:_id => 9},
|
20
|
+
])
|
21
|
+
expect(result.inserted_ids).to eql([9])
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
context 'error on first insert' do
|
26
|
+
it 'is an empty array' do
|
27
|
+
collection.insert_one(:_id => 9)
|
28
|
+
begin
|
29
|
+
result = collection.insert_many([
|
30
|
+
{:_id => 9},
|
31
|
+
])
|
32
|
+
fail 'Should have raised'
|
33
|
+
rescue Mongo::Error::BulkWriteError => e
|
34
|
+
expect(e.result['inserted_ids']).to eql([])
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
context 'error on third insert' do
|
40
|
+
it 'is an array of the first two ids' do
|
41
|
+
collection.insert_one(:_id => 9)
|
42
|
+
begin
|
43
|
+
result = collection.insert_many([
|
44
|
+
{:_id => 7},
|
45
|
+
{:_id => 8},
|
46
|
+
{:_id => 9},
|
47
|
+
])
|
48
|
+
fail 'Should have raised'
|
49
|
+
rescue Mongo::Error::BulkWriteError => e
|
50
|
+
expect(e.result['inserted_ids']).to eql([7, 8])
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
context 'entire operation fails' do
|
56
|
+
min_server_version '4.0'
|
57
|
+
require_topology :single, :replica_set
|
58
|
+
|
59
|
+
it 'is an empty array' do
|
60
|
+
collection.client.use(:admin).command(FAIL_POINT_BASE_COMMAND.merge(
|
61
|
+
:mode => {:times => 1},
|
62
|
+
:data => {:failCommands => ['insert'], errorCode: 100}))
|
63
|
+
begin
|
64
|
+
result = collection.insert_many([
|
65
|
+
{:_id => 7},
|
66
|
+
{:_id => 8},
|
67
|
+
{:_id => 9},
|
68
|
+
])
|
69
|
+
fail 'Should have raised'
|
70
|
+
rescue Mongo::Error => e
|
71
|
+
result = e.send(:instance_variable_get, '@result')
|
72
|
+
expect(result).to be_a(Mongo::Operation::Insert::BulkResult)
|
73
|
+
expect(result.inserted_ids).to eql([])
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
78
|
+
end
|
@@ -0,0 +1,365 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe 'Change stream integration' do
|
4
|
+
only_mri
|
5
|
+
max_example_run_time 7
|
6
|
+
|
7
|
+
FAIL_POINT_BASE_COMMAND = { 'configureFailPoint' => "failCommand" }
|
8
|
+
|
9
|
+
# There is value in not clearing fail points between tests because
|
10
|
+
# their triggering will distinguish fail points not being set vs
|
11
|
+
# them not being triggered
|
12
|
+
def clear_fail_point(collection)
|
13
|
+
collection.client.use(:admin).command(FAIL_POINT_BASE_COMMAND.merge(mode: "off"))
|
14
|
+
end
|
15
|
+
|
16
|
+
class << self
|
17
|
+
def clear_fail_point_before
|
18
|
+
before do
|
19
|
+
clear_fail_point(authorized_collection)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
before do
|
25
|
+
unless test_change_streams?
|
26
|
+
skip 'Not testing change streams'
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
describe 'watch+next' do
|
31
|
+
let(:change_stream) { authorized_collection.watch }
|
32
|
+
|
33
|
+
shared_context 'returns a change document' do
|
34
|
+
it 'returns a change document' do
|
35
|
+
change_stream
|
36
|
+
|
37
|
+
authorized_collection.insert_one(:a => 1)
|
38
|
+
sleep 0.5
|
39
|
+
|
40
|
+
change = change_stream.to_enum.next
|
41
|
+
expect(change).to be_a(BSON::Document)
|
42
|
+
expect(change['operationType']).to eql('insert')
|
43
|
+
doc = change['fullDocument']
|
44
|
+
expect(doc['_id']).to be_a(BSON::ObjectId)
|
45
|
+
doc.delete('_id')
|
46
|
+
expect(doc).to eql('a' => 1)
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
context 'no errors' do
|
51
|
+
it 'next returns changes' do
|
52
|
+
change_stream
|
53
|
+
|
54
|
+
authorized_collection.insert_one(:a => 1)
|
55
|
+
|
56
|
+
change = change_stream.to_enum.next
|
57
|
+
expect(change).to be_a(BSON::Document)
|
58
|
+
expect(change['operationType']).to eql('insert')
|
59
|
+
doc = change['fullDocument']
|
60
|
+
expect(doc['_id']).to be_a(BSON::ObjectId)
|
61
|
+
doc.delete('_id')
|
62
|
+
expect(doc).to eql('a' => 1)
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
context 'error on initial aggregation' do
|
67
|
+
min_server_version '4.0'
|
68
|
+
clear_fail_point_before
|
69
|
+
|
70
|
+
before do
|
71
|
+
authorized_collection.client.use(:admin).command(FAIL_POINT_BASE_COMMAND.merge(
|
72
|
+
:mode => {:times => 1},
|
73
|
+
:data => {:failCommands => ['aggregate'], errorCode: 100}))
|
74
|
+
end
|
75
|
+
|
76
|
+
it 'watch raises error' do
|
77
|
+
expect do
|
78
|
+
authorized_collection.watch
|
79
|
+
end.to raise_error(Mongo::Error::OperationFailure, "Failing command due to 'failCommand' failpoint (100)")
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
context 'one error on getMore' do
|
84
|
+
min_server_version '4.0'
|
85
|
+
clear_fail_point_before
|
86
|
+
|
87
|
+
context 'error on first getMore' do
|
88
|
+
before do
|
89
|
+
authorized_collection.client.use(:admin).command(FAIL_POINT_BASE_COMMAND.merge(
|
90
|
+
:mode => {:times => 1},
|
91
|
+
:data => {:failCommands => ['getMore'], errorCode: 100}))
|
92
|
+
end
|
93
|
+
|
94
|
+
it_behaves_like 'returns a change document'
|
95
|
+
end
|
96
|
+
|
97
|
+
context 'error on a getMore other than first' do
|
98
|
+
before do
|
99
|
+
# Need to retrieve a change stream document successfully prior to
|
100
|
+
# failing to have the resume token, otherwise the change stream
|
101
|
+
# ignores documents inserted after the first aggregation
|
102
|
+
# and the test gets stuck
|
103
|
+
change_stream
|
104
|
+
authorized_collection.insert_one(:a => 1)
|
105
|
+
change_stream.to_enum.next
|
106
|
+
authorized_collection.insert_one(:a => 1)
|
107
|
+
|
108
|
+
authorized_collection.client.use(:admin).command(FAIL_POINT_BASE_COMMAND.merge(
|
109
|
+
:mode => {:times => 1},
|
110
|
+
:data => {:failCommands => ['getMore'], errorCode: 100}))
|
111
|
+
end
|
112
|
+
|
113
|
+
it_behaves_like 'returns a change document'
|
114
|
+
end
|
115
|
+
end
|
116
|
+
|
117
|
+
context 'two errors on getMore' do
|
118
|
+
min_server_version '4.0'
|
119
|
+
clear_fail_point_before
|
120
|
+
|
121
|
+
context 'error of first getMores' do
|
122
|
+
before do
|
123
|
+
authorized_collection.client.use(:admin).command(FAIL_POINT_BASE_COMMAND.merge(
|
124
|
+
:mode => {:times => 2},
|
125
|
+
:data => {:failCommands => ['getMore'], errorCode: 100}))
|
126
|
+
end
|
127
|
+
|
128
|
+
# this retries twice because aggregation resets retry count,
|
129
|
+
# and ultimately succeeds and returns data
|
130
|
+
it_behaves_like 'returns a change document'
|
131
|
+
end
|
132
|
+
|
133
|
+
context 'error on a getMore other than first' do
|
134
|
+
before do
|
135
|
+
# Need to retrieve a change stream document successfully prior to
|
136
|
+
# failing to have the resume token, otherwise the change stream
|
137
|
+
# ignores documents inserted after the first aggregation
|
138
|
+
# and the test gets stuck
|
139
|
+
change_stream
|
140
|
+
authorized_collection.insert_one(:a => 1)
|
141
|
+
change_stream.to_enum.next
|
142
|
+
authorized_collection.insert_one(:a => 1)
|
143
|
+
|
144
|
+
authorized_collection.client.use(:admin).command(FAIL_POINT_BASE_COMMAND.merge(
|
145
|
+
:mode => {:times => 2},
|
146
|
+
:data => {:failCommands => ['getMore'], errorCode: 100}))
|
147
|
+
end
|
148
|
+
|
149
|
+
# this retries twice because aggregation resets retry count,
|
150
|
+
# and ultimately succeeds and returns data
|
151
|
+
it_behaves_like 'returns a change document'
|
152
|
+
end
|
153
|
+
end
|
154
|
+
|
155
|
+
context 'two errors on getMore followed by an error on aggregation' do
|
156
|
+
min_server_version '4.0'
|
157
|
+
clear_fail_point_before
|
158
|
+
|
159
|
+
it 'next raises error' do
|
160
|
+
change_stream
|
161
|
+
|
162
|
+
authorized_collection.insert_one(:a => 1)
|
163
|
+
sleep 0.5
|
164
|
+
|
165
|
+
enum = change_stream.to_enum
|
166
|
+
|
167
|
+
authorized_collection.client.use(:admin).command(FAIL_POINT_BASE_COMMAND.merge(
|
168
|
+
:mode => {:times => 2},
|
169
|
+
:data => {:failCommands => ['getMore', 'aggregate'], errorCode: 101}))
|
170
|
+
|
171
|
+
sleep 0.5
|
172
|
+
|
173
|
+
expect do
|
174
|
+
enum.next
|
175
|
+
end.to raise_error(Mongo::Error::OperationFailure, "Failing command due to 'failCommand' failpoint (101)")
|
176
|
+
end
|
177
|
+
end
|
178
|
+
end
|
179
|
+
|
180
|
+
describe 'try_next' do
|
181
|
+
let(:change_stream) { authorized_collection.watch }
|
182
|
+
|
183
|
+
shared_context 'returns a change document' do
|
184
|
+
it 'returns a change document' do
|
185
|
+
change_stream
|
186
|
+
|
187
|
+
sleep 0.5
|
188
|
+
authorized_collection.insert_one(:a => 1)
|
189
|
+
sleep 0.5
|
190
|
+
|
191
|
+
change = change_stream.to_enum.try_next
|
192
|
+
expect(change).to be_a(BSON::Document)
|
193
|
+
expect(change['operationType']).to eql('insert')
|
194
|
+
doc = change['fullDocument']
|
195
|
+
expect(doc['_id']).to be_a(BSON::ObjectId)
|
196
|
+
doc.delete('_id')
|
197
|
+
expect(doc).to eql('a' => 1)
|
198
|
+
end
|
199
|
+
end
|
200
|
+
|
201
|
+
context 'there are changes' do
|
202
|
+
it_behaves_like 'returns a change document'
|
203
|
+
end
|
204
|
+
|
205
|
+
context 'there are no changes' do
|
206
|
+
it 'returns nil' do
|
207
|
+
change_stream
|
208
|
+
|
209
|
+
change = change_stream.to_enum.try_next
|
210
|
+
expect(change).to be nil
|
211
|
+
end
|
212
|
+
end
|
213
|
+
|
214
|
+
context 'one error on getMore' do
|
215
|
+
min_server_version '4.0'
|
216
|
+
clear_fail_point_before
|
217
|
+
|
218
|
+
context 'error on first getMore' do
|
219
|
+
before do
|
220
|
+
authorized_collection.client.use(:admin).command(FAIL_POINT_BASE_COMMAND.merge(
|
221
|
+
:mode => {:times => 1},
|
222
|
+
:data => {:failCommands => ['getMore'], errorCode: 100}))
|
223
|
+
end
|
224
|
+
|
225
|
+
it_behaves_like 'returns a change document'
|
226
|
+
end
|
227
|
+
|
228
|
+
context 'error on a getMore other than first' do
|
229
|
+
before do
|
230
|
+
change_stream
|
231
|
+
authorized_collection.insert_one(:a => 1)
|
232
|
+
change_stream.to_enum.next
|
233
|
+
authorized_collection.insert_one(:a => 1)
|
234
|
+
|
235
|
+
authorized_collection.client.use(:admin).command(FAIL_POINT_BASE_COMMAND.merge(
|
236
|
+
:mode => {:times => 1},
|
237
|
+
:data => {:failCommands => ['getMore'], errorCode: 100}))
|
238
|
+
end
|
239
|
+
|
240
|
+
it_behaves_like 'returns a change document'
|
241
|
+
end
|
242
|
+
end
|
243
|
+
|
244
|
+
context 'two errors on getMore' do
|
245
|
+
min_server_version '4.0'
|
246
|
+
clear_fail_point_before
|
247
|
+
|
248
|
+
before do
|
249
|
+
authorized_collection.client.use(:admin).command(FAIL_POINT_BASE_COMMAND.merge(
|
250
|
+
:mode => {:times => 2},
|
251
|
+
:data => {:failCommands => ['getMore'], errorCode: 100}))
|
252
|
+
end
|
253
|
+
|
254
|
+
# this retries twice because aggregation resets retry count,
|
255
|
+
# and ultimately succeeds and returns data
|
256
|
+
it_behaves_like 'returns a change document'
|
257
|
+
end
|
258
|
+
|
259
|
+
context 'two errors on getMore followed by an error on aggregation' do
|
260
|
+
min_server_version '4.0'
|
261
|
+
clear_fail_point_before
|
262
|
+
|
263
|
+
context 'error on first getMore' do
|
264
|
+
it 'next raises error' do
|
265
|
+
change_stream
|
266
|
+
|
267
|
+
sleep 0.5
|
268
|
+
authorized_collection.insert_one(:a => 1)
|
269
|
+
sleep 0.5
|
270
|
+
|
271
|
+
enum = change_stream.to_enum
|
272
|
+
|
273
|
+
authorized_collection.client.use(:admin).command(FAIL_POINT_BASE_COMMAND.merge(
|
274
|
+
:mode => {:times => 3},
|
275
|
+
:data => {:failCommands => ['getMore', 'aggregate'], errorCode: 101}))
|
276
|
+
|
277
|
+
sleep 0.5
|
278
|
+
|
279
|
+
expect do
|
280
|
+
enum.try_next
|
281
|
+
end.to raise_error(Mongo::Error::OperationFailure, "Failing command due to 'failCommand' failpoint (101)")
|
282
|
+
end
|
283
|
+
end
|
284
|
+
|
285
|
+
context 'error on a getMore other than first' do
|
286
|
+
it 'next raises error' do
|
287
|
+
change_stream
|
288
|
+
|
289
|
+
authorized_collection.insert_one(:a => 1)
|
290
|
+
change_stream.to_enum.next
|
291
|
+
authorized_collection.insert_one(:a => 1)
|
292
|
+
sleep 0.5
|
293
|
+
|
294
|
+
enum = change_stream.to_enum
|
295
|
+
|
296
|
+
authorized_collection.client.use(:admin).command(FAIL_POINT_BASE_COMMAND.merge(
|
297
|
+
:mode => {:times => 3},
|
298
|
+
:data => {:failCommands => ['getMore', 'aggregate'], errorCode: 101}))
|
299
|
+
|
300
|
+
sleep 0.5
|
301
|
+
|
302
|
+
expect do
|
303
|
+
enum.try_next
|
304
|
+
end.to raise_error(Mongo::Error::OperationFailure, "Failing command due to 'failCommand' failpoint (101)")
|
305
|
+
end
|
306
|
+
end
|
307
|
+
end
|
308
|
+
end
|
309
|
+
|
310
|
+
describe ':start_at_operation_time option' do
|
311
|
+
min_server_version '4.0'
|
312
|
+
|
313
|
+
before do
|
314
|
+
authorized_collection.delete_many
|
315
|
+
end
|
316
|
+
|
317
|
+
it 'respects start time prior to beginning of aggregation' do
|
318
|
+
time = Time.now - 1
|
319
|
+
authorized_collection.insert_one(:a => 1)
|
320
|
+
sleep 0.5
|
321
|
+
|
322
|
+
cs = authorized_collection.watch([], start_at_operation_time: time)
|
323
|
+
|
324
|
+
document = cs.to_enum.next
|
325
|
+
expect(document).to be_a(BSON::Document)
|
326
|
+
end
|
327
|
+
|
328
|
+
it 'respects start time after beginning of aggregation' do
|
329
|
+
time = Time.now + 10
|
330
|
+
cs = authorized_collection.watch([], start_at_operation_time: time)
|
331
|
+
sleep 0.5
|
332
|
+
|
333
|
+
authorized_collection.insert_one(:a => 1)
|
334
|
+
|
335
|
+
sleep 0.5
|
336
|
+
|
337
|
+
document = cs.to_enum.try_next
|
338
|
+
expect(document).to be_nil
|
339
|
+
end
|
340
|
+
|
341
|
+
it 'accepts a Time' do
|
342
|
+
time = Time.now
|
343
|
+
cs = authorized_collection.watch([], start_at_operation_time: time)
|
344
|
+
end
|
345
|
+
|
346
|
+
it 'accepts a BSON::Timestamp' do
|
347
|
+
time = BSON::Timestamp.new(Time.now.to_i, 1)
|
348
|
+
cs = authorized_collection.watch([], start_at_operation_time: time)
|
349
|
+
end
|
350
|
+
|
351
|
+
it 'rejects a Date' do
|
352
|
+
time = Date.today
|
353
|
+
expect do
|
354
|
+
authorized_collection.watch([], start_at_operation_time: time)
|
355
|
+
end.to raise_error(ArgumentError, 'Time must be a Time or a BSON::Timestamp instance')
|
356
|
+
end
|
357
|
+
|
358
|
+
it 'rejects an integer' do
|
359
|
+
time = 1
|
360
|
+
expect do
|
361
|
+
authorized_collection.watch([], start_at_operation_time: time)
|
362
|
+
end.to raise_error(ArgumentError, 'Time must be a Time or a BSON::Timestamp instance')
|
363
|
+
end
|
364
|
+
end
|
365
|
+
end
|