mongo 2.15.0 → 2.16.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data/README.md +1 -1
- data/lib/mongo/bulk_write.rb +2 -2
- data/lib/mongo/client.rb +45 -5
- data/lib/mongo/cluster/periodic_executor.rb +4 -3
- data/lib/mongo/cluster/reapers/cursor_reaper.rb +76 -43
- data/lib/mongo/cluster/sdam_flow.rb +9 -3
- data/lib/mongo/cluster/topology/base.rb +13 -9
- data/lib/mongo/cluster/topology/load_balanced.rb +102 -0
- data/lib/mongo/cluster/topology.rb +28 -8
- data/lib/mongo/cluster.rb +136 -51
- data/lib/mongo/collection/view/aggregation.rb +5 -10
- data/lib/mongo/collection/view/builder/aggregation.rb +6 -5
- data/lib/mongo/collection/view/builder/map_reduce.rb +12 -49
- data/lib/mongo/collection/view/builder.rb +0 -4
- data/lib/mongo/collection/view/iterable.rb +58 -24
- data/lib/mongo/collection/view/map_reduce.rb +39 -15
- data/lib/mongo/collection/view/readable.rb +60 -51
- data/lib/mongo/collection/view/writable.rb +178 -175
- data/lib/mongo/collection/view.rb +15 -21
- data/lib/mongo/collection.rb +13 -13
- data/lib/mongo/cursor/kill_spec.rb +38 -0
- data/lib/mongo/cursor.rb +72 -31
- data/lib/mongo/database/view.rb +1 -1
- data/lib/mongo/error/bad_load_balancer_target.rb +26 -0
- data/lib/mongo/error/missing_service_id.rb +26 -0
- data/lib/mongo/error/no_service_connection_available.rb +49 -0
- data/lib/mongo/error/notable.rb +7 -0
- data/lib/mongo/error.rb +3 -0
- data/lib/mongo/grid/fs_bucket.rb +21 -2
- data/lib/mongo/id.rb +7 -5
- data/lib/mongo/index/view.rb +22 -41
- data/lib/mongo/monitoring/event/cmap/pool_cleared.rb +7 -4
- data/lib/mongo/monitoring/event/command_failed.rb +1 -1
- data/lib/mongo/monitoring/event/command_started.rb +2 -0
- data/lib/mongo/monitoring/publishable.rb +2 -2
- data/lib/mongo/operation/aggregate/command.rb +8 -0
- data/lib/mongo/operation/context.rb +19 -1
- data/lib/mongo/operation/count/command.rb +6 -0
- data/lib/mongo/operation/count/op_msg.rb +6 -0
- data/lib/mongo/operation/create/command.rb +7 -1
- data/lib/mongo/operation/create/op_msg.rb +7 -0
- data/lib/mongo/operation/create_index/command.rb +17 -1
- data/lib/mongo/operation/create_index/op_msg.rb +17 -4
- data/lib/mongo/operation/delete/command.rb +6 -3
- data/lib/mongo/operation/delete/legacy.rb +9 -2
- data/lib/mongo/operation/delete/op_msg.rb +8 -1
- data/lib/mongo/operation/distinct/command.rb +6 -0
- data/lib/mongo/operation/distinct/op_msg.rb +7 -0
- data/lib/mongo/operation/explain/command.rb +13 -1
- data/lib/mongo/operation/explain/legacy.rb +12 -5
- data/lib/mongo/operation/explain/op_msg.rb +9 -1
- data/lib/mongo/operation/find/builder/command.rb +110 -0
- data/lib/mongo/{collection/view → operation/find}/builder/flags.rb +10 -14
- data/lib/mongo/operation/find/builder/legacy.rb +123 -0
- data/lib/mongo/{collection/view → operation/find}/builder/modifiers.rb +31 -25
- data/lib/mongo/{cursor → operation/find}/builder.rb +4 -4
- data/lib/mongo/operation/find/command.rb +9 -0
- data/lib/mongo/operation/find/legacy.rb +10 -1
- data/lib/mongo/operation/find/op_msg.rb +12 -0
- data/lib/mongo/operation/find.rb +1 -0
- data/lib/mongo/operation/get_more/command.rb +1 -0
- data/lib/mongo/operation/get_more/command_builder.rb +38 -0
- data/lib/mongo/operation/get_more/op_msg.rb +1 -0
- data/lib/mongo/operation/get_more.rb +1 -0
- data/lib/mongo/operation/kill_cursors/command.rb +8 -0
- data/lib/mongo/operation/kill_cursors/command_builder.rb +35 -0
- data/lib/mongo/operation/kill_cursors/legacy.rb +2 -1
- data/lib/mongo/operation/kill_cursors/op_msg.rb +10 -0
- data/lib/mongo/operation/kill_cursors.rb +1 -0
- data/lib/mongo/operation/map_reduce/command.rb +8 -0
- data/lib/mongo/operation/map_reduce/op_msg.rb +1 -1
- data/lib/mongo/operation/shared/executable.rb +15 -1
- data/lib/mongo/operation/shared/polymorphic_operation.rb +1 -1
- data/lib/mongo/operation/shared/read_preference_supported.rb +3 -1
- data/lib/mongo/operation/shared/response_handling.rb +1 -0
- data/lib/mongo/operation/shared/sessions_supported.rb +12 -12
- data/lib/mongo/operation/shared/specifiable.rb +11 -29
- data/lib/mongo/operation/shared/validatable.rb +87 -0
- data/lib/mongo/operation/shared/write.rb +1 -1
- data/lib/mongo/operation/update/command.rb +6 -3
- data/lib/mongo/operation/update/legacy.rb +19 -11
- data/lib/mongo/operation/update/op_msg.rb +7 -4
- data/lib/mongo/operation/write_command/command.rb +51 -0
- data/lib/mongo/operation/write_command/op_msg.rb +43 -0
- data/lib/mongo/operation/write_command.rb +32 -0
- data/lib/mongo/operation.rb +10 -0
- data/lib/mongo/protocol/query.rb +35 -18
- data/lib/mongo/server/connection.rb +25 -3
- data/lib/mongo/server/connection_base.rb +12 -1
- data/lib/mongo/server/connection_common.rb +38 -1
- data/lib/mongo/server/connection_pool/generation_manager.rb +71 -0
- data/lib/mongo/server/connection_pool.rb +100 -27
- data/lib/mongo/server/description/features.rb +17 -16
- data/lib/mongo/server/description/load_balancer.rb +33 -0
- data/lib/mongo/server/description.rb +85 -6
- data/lib/mongo/server/monitor/connection.rb +5 -6
- data/lib/mongo/server/monitor.rb +2 -1
- data/lib/mongo/server/pending_connection.rb +47 -31
- data/lib/mongo/server/push_monitor.rb +10 -1
- data/lib/mongo/server.rb +73 -26
- data/lib/mongo/server_selector/base.rb +5 -1
- data/lib/mongo/session/session_pool.rb +11 -0
- data/lib/mongo/session.rb +21 -1
- data/lib/mongo/socket/ocsp_verifier.rb +6 -37
- data/lib/mongo/uri/options_mapper.rb +1 -0
- data/lib/mongo/uri/srv_protocol.rb +6 -8
- data/lib/mongo/uri.rb +18 -0
- data/lib/mongo/utils.rb +0 -7
- data/lib/mongo/version.rb +1 -1
- data/mongo.gemspec +1 -1
- data/spec/integration/auth_spec.rb +31 -1
- data/spec/integration/awaited_ismaster_spec.rb +1 -1
- data/spec/integration/bulk_write_spec.rb +1 -1
- data/spec/integration/change_stream_spec.rb +3 -3
- data/spec/integration/client_construction_spec.rb +54 -0
- data/spec/integration/client_side_encryption/auto_encryption_bulk_writes_spec.rb +1 -1
- data/spec/integration/client_side_encryption/auto_encryption_command_monitoring_spec.rb +1 -1
- data/spec/integration/client_side_encryption/bson_size_limit_spec.rb +1 -1
- data/spec/integration/client_side_encryption/data_key_spec.rb +1 -1
- data/spec/integration/client_spec.rb +2 -0
- data/spec/integration/command_monitoring_spec.rb +1 -1
- data/spec/integration/command_spec.rb +1 -1
- data/spec/integration/connection_spec.rb +52 -35
- data/spec/integration/crud_spec.rb +174 -1
- data/spec/integration/cursor_pinning_spec.rb +121 -0
- data/spec/integration/cursor_reaping_spec.rb +8 -4
- data/spec/integration/fork_reconnect_spec.rb +1 -5
- data/spec/integration/get_more_spec.rb +1 -1
- data/spec/integration/heartbeat_events_spec.rb +1 -1
- data/spec/integration/map_reduce_spec.rb +77 -0
- data/spec/integration/query_cache_spec.rb +47 -2
- data/spec/integration/query_cache_transactions_spec.rb +1 -1
- data/spec/integration/read_concern_spec.rb +1 -1
- data/spec/integration/read_preference_spec.rb +1 -1
- data/spec/integration/reconnect_spec.rb +30 -12
- data/spec/integration/retryable_errors_spec.rb +1 -1
- data/spec/integration/retryable_writes/retryable_writes_36_and_older_spec.rb +1 -1
- data/spec/integration/retryable_writes/retryable_writes_40_and_newer_spec.rb +1 -1
- data/spec/integration/sdam_error_handling_spec.rb +5 -3
- data/spec/integration/sdam_events_spec.rb +35 -19
- data/spec/integration/sdam_prose_spec.rb +1 -1
- data/spec/integration/server_monitor_spec.rb +1 -0
- data/spec/integration/server_selector_spec.rb +22 -5
- data/spec/integration/server_spec.rb +2 -0
- data/spec/integration/srv_monitoring_spec.rb +1 -1
- data/spec/integration/step_down_spec.rb +1 -1
- data/spec/integration/transaction_pinning_spec.rb +120 -0
- data/spec/integration/versioned_api_examples_spec.rb +45 -0
- data/spec/integration/x509_auth_spec.rb +1 -1
- data/spec/lite_spec_helper.rb +1 -2
- data/spec/mongo/address/unix_spec.rb +1 -0
- data/spec/mongo/auth/cr_spec.rb +2 -3
- data/spec/mongo/auth/ldap_spec.rb +2 -3
- data/spec/mongo/auth/scram_spec.rb +2 -3
- data/spec/mongo/auth/user/view_spec.rb +1 -1
- data/spec/mongo/auth/x509_spec.rb +2 -3
- data/spec/mongo/bulk_write_spec.rb +3 -3
- data/spec/mongo/client_construction_spec.rb +259 -28
- data/spec/mongo/client_spec.rb +6 -4
- data/spec/mongo/cluster/cursor_reaper_spec.rb +36 -21
- data/spec/mongo/cluster/periodic_executor_spec.rb +3 -1
- data/spec/mongo/cluster_spec.rb +44 -3
- data/spec/mongo/collection/view/aggregation_spec.rb +1 -1
- data/spec/mongo/collection/view/builder/find_command_spec.rb +4 -0
- data/spec/mongo/collection/view/builder/op_query_spec.rb +4 -0
- data/spec/mongo/collection/view/map_reduce_spec.rb +1 -1
- data/spec/mongo/collection_crud_spec.rb +7 -2
- data/spec/mongo/collection_ddl_spec.rb +1 -1
- data/spec/mongo/collection_spec.rb +1 -1
- data/spec/mongo/cursor/builder/get_more_command_spec.rb +4 -0
- data/spec/mongo/cursor/builder/op_get_more_spec.rb +4 -0
- data/spec/mongo/cursor_spec.rb +15 -5
- data/spec/mongo/database_spec.rb +15 -15
- data/spec/mongo/error/operation_failure_heavy_spec.rb +1 -1
- data/spec/mongo/grid/fs_bucket_spec.rb +18 -12
- data/spec/mongo/grid/stream/write_spec.rb +3 -9
- data/spec/mongo/grid/stream_spec.rb +1 -1
- data/spec/mongo/index/view_spec.rb +2 -2
- data/spec/mongo/operation/delete/op_msg_spec.rb +1 -1
- data/spec/mongo/{collection/view → operation/find}/builder/flags_spec.rb +2 -2
- data/spec/mongo/{collection/view → operation/find}/builder/modifiers_spec.rb +2 -2
- data/spec/mongo/operation/find/legacy_spec.rb +1 -0
- data/spec/mongo/operation/insert/bulk_spec.rb +1 -1
- data/spec/mongo/operation/insert/op_msg_spec.rb +1 -1
- data/spec/mongo/operation/kill_cursors_spec.rb +4 -1
- data/spec/mongo/operation/read_preference_legacy_spec.rb +4 -0
- data/spec/mongo/operation/read_preference_op_msg_spec.rb +2 -0
- data/spec/mongo/operation/update/bulk_spec.rb +1 -1
- data/spec/mongo/operation/update/op_msg_spec.rb +1 -1
- data/spec/mongo/query_cache_spec.rb +6 -2
- data/spec/mongo/server/connection_common_spec.rb +62 -11
- data/spec/mongo/server/connection_pool_spec.rb +73 -7
- data/spec/mongo/server/connection_spec.rb +138 -43
- data/spec/mongo/server/description_spec.rb +1 -1
- data/spec/mongo/server/monitor/connection_spec.rb +22 -0
- data/spec/mongo/server/monitor_spec.rb +4 -3
- data/spec/mongo/server/push_monitor_spec.rb +101 -0
- data/spec/mongo/session/session_pool_spec.rb +42 -10
- data/spec/mongo/session_transaction_spec.rb +15 -30
- data/spec/mongo/socket/unix_spec.rb +1 -0
- data/spec/mongo/uri_option_parsing_spec.rb +38 -5
- data/spec/runners/change_streams/test.rb +1 -1
- data/spec/runners/cmap.rb +1 -1
- data/spec/runners/connection_string.rb +7 -3
- data/spec/runners/crud/operation.rb +5 -3
- data/spec/runners/crud/requirement.rb +1 -0
- data/spec/runners/crud.rb +1 -1
- data/spec/runners/sdam.rb +2 -1
- data/spec/runners/transactions/test.rb +2 -2
- data/spec/runners/unified/assertions.rb +2 -3
- data/spec/runners/unified/event_subscriber.rb +2 -2
- data/spec/runners/unified/support_operations.rb +10 -2
- data/spec/runners/unified/test.rb +3 -0
- data/spec/runners/unified.rb +1 -1
- data/spec/shared/lib/mrss/cluster_config.rb +6 -1
- data/spec/shared/lib/mrss/constraints.rb +11 -5
- data/spec/shared/lib/mrss/event_subscriber.rb +200 -0
- data/spec/shared/lib/mrss/server_version_registry.rb +17 -12
- data/spec/shared/share/Dockerfile.erb +5 -4
- data/spec/shared/shlib/server.sh +70 -20
- data/spec/spec_tests/change_streams_spec.rb +1 -1
- data/spec/spec_tests/cmap_spec.rb +4 -1
- data/spec/spec_tests/command_monitoring_spec.rb +2 -2
- data/spec/spec_tests/data/command_monitoring/find.yml +9 -9
- data/spec/spec_tests/data/crud/read/aggregate-collation.yml +2 -1
- data/spec/spec_tests/data/crud/read/aggregate-out.yml +1 -0
- data/spec/spec_tests/data/crud/read/count-collation.yml +2 -1
- data/spec/spec_tests/data/crud/read/distinct-collation.yml +2 -1
- data/spec/spec_tests/data/crud/read/find-collation.yml +2 -1
- data/spec/spec_tests/data/crud/write/bulkWrite-collation.yml +2 -1
- data/spec/spec_tests/data/crud/write/deleteMany-collation.yml +2 -1
- data/spec/spec_tests/data/crud/write/deleteOne-collation.yml +2 -1
- data/spec/spec_tests/data/crud/write/findOneAndDelete-collation.yml +3 -2
- data/spec/spec_tests/data/crud/write/findOneAndReplace-collation.yml +2 -1
- data/spec/spec_tests/data/crud/write/findOneAndUpdate-collation.yml +3 -2
- data/spec/spec_tests/data/crud/write/replaceOne-collation.yml +3 -2
- data/spec/spec_tests/data/crud/write/updateMany-collation.yml +2 -1
- data/spec/spec_tests/data/crud/write/updateOne-collation.yml +2 -1
- data/spec/spec_tests/data/load_balancers/event-monitoring.yml +99 -0
- data/spec/spec_tests/data/load_balancers/lb-connection-establishment.yml +36 -0
- data/spec/spec_tests/data/load_balancers/non-lb-connection-establishment.yml +56 -0
- data/spec/spec_tests/data/load_balancers/server-selection.yml +50 -0
- data/spec/spec_tests/data/retryable_reads/changeStreams-client.watch-serverErrors.yml +1 -1
- data/spec/spec_tests/data/retryable_reads/changeStreams-client.watch.yml +1 -1
- data/spec/spec_tests/data/retryable_reads/changeStreams-db.coll.watch-serverErrors.yml +1 -1
- data/spec/spec_tests/data/retryable_reads/changeStreams-db.coll.watch.yml +1 -1
- data/spec/spec_tests/data/retryable_reads/changeStreams-db.watch-serverErrors.yml +1 -1
- data/spec/spec_tests/data/retryable_reads/changeStreams-db.watch.yml +1 -1
- data/spec/spec_tests/data/retryable_reads/mapReduce.yml +3 -1
- data/spec/spec_tests/data/sdam/load-balanced/discover_load_balancer.yml +25 -0
- data/spec/spec_tests/data/sdam_integration/find-network-error.yml +2 -0
- data/spec/spec_tests/data/sdam_integration/find-shutdown-error.yml +2 -0
- data/spec/spec_tests/data/sdam_integration/hello-command-error.yml +3 -1
- data/spec/spec_tests/data/sdam_integration/hello-network-error.yml +3 -1
- data/spec/spec_tests/data/sdam_integration/hello-timeout.yml +2 -0
- data/spec/spec_tests/data/sdam_integration/insert-network-error.yml +2 -0
- data/spec/spec_tests/data/sdam_integration/insert-shutdown-error.yml +2 -0
- data/spec/spec_tests/data/sdam_monitoring/load_balancer.yml +65 -0
- data/spec/spec_tests/data/seed_list_discovery/load-balanced/loadBalanced-directConnection.yml +13 -0
- data/spec/spec_tests/data/seed_list_discovery/load-balanced/loadBalanced-replicaSet-errors.yml +6 -0
- data/spec/spec_tests/data/seed_list_discovery/load-balanced/loadBalanced-true-multiple-hosts.yml +5 -0
- data/spec/spec_tests/data/seed_list_discovery/load-balanced/loadBalanced-true-txt.yml +10 -0
- data/spec/spec_tests/data/{dns_seedlist_discovery → seed_list_discovery/replica-set}/direct-connection-false.yml +0 -0
- data/spec/spec_tests/data/{dns_seedlist_discovery → seed_list_discovery/replica-set}/direct-connection-true.yml +0 -0
- data/spec/spec_tests/data/seed_list_discovery/replica-set/encoded-userinfo-and-db.yml +15 -0
- data/spec/spec_tests/data/seed_list_discovery/replica-set/loadBalanced-false-txt.yml +10 -0
- data/spec/spec_tests/data/{dns_seedlist_discovery → seed_list_discovery/replica-set}/longer-parent-in-return.yml +0 -0
- data/spec/spec_tests/data/{dns_seedlist_discovery → seed_list_discovery/replica-set}/misformatted-option.yml +0 -0
- data/spec/spec_tests/data/{dns_seedlist_discovery → seed_list_discovery/replica-set}/no-results.yml +0 -0
- data/spec/spec_tests/data/{dns_seedlist_discovery → seed_list_discovery/replica-set}/not-enough-parts.yml +0 -0
- data/spec/spec_tests/data/{dns_seedlist_discovery → seed_list_discovery/replica-set}/one-result-default-port.yml +0 -0
- data/spec/spec_tests/data/{dns_seedlist_discovery → seed_list_discovery/replica-set}/one-txt-record-multiple-strings.yml +0 -0
- data/spec/spec_tests/data/{dns_seedlist_discovery → seed_list_discovery/replica-set}/one-txt-record.yml +0 -0
- data/spec/spec_tests/data/{dns_seedlist_discovery → seed_list_discovery/replica-set}/parent-part-mismatch1.yml +0 -0
- data/spec/spec_tests/data/{dns_seedlist_discovery → seed_list_discovery/replica-set}/parent-part-mismatch2.yml +0 -0
- data/spec/spec_tests/data/{dns_seedlist_discovery → seed_list_discovery/replica-set}/parent-part-mismatch3.yml +0 -0
- data/spec/spec_tests/data/{dns_seedlist_discovery → seed_list_discovery/replica-set}/parent-part-mismatch4.yml +0 -0
- data/spec/spec_tests/data/{dns_seedlist_discovery → seed_list_discovery/replica-set}/parent-part-mismatch5.yml +0 -0
- data/spec/spec_tests/data/{dns_seedlist_discovery → seed_list_discovery/replica-set}/returned-parent-too-short.yml +0 -0
- data/spec/spec_tests/data/{dns_seedlist_discovery → seed_list_discovery/replica-set}/returned-parent-wrong.yml +0 -0
- data/spec/spec_tests/data/{dns_seedlist_discovery → seed_list_discovery/replica-set}/two-results-default-port.yml +0 -0
- data/spec/spec_tests/data/{dns_seedlist_discovery → seed_list_discovery/replica-set}/two-results-nonstandard-port.yml +0 -0
- data/spec/spec_tests/data/{dns_seedlist_discovery → seed_list_discovery/replica-set}/two-txt-records.yml +0 -0
- data/spec/spec_tests/data/{dns_seedlist_discovery → seed_list_discovery/replica-set}/txt-record-not-allowed-option.yml +0 -0
- data/spec/spec_tests/data/{dns_seedlist_discovery → seed_list_discovery/replica-set}/txt-record-with-overridden-ssl-option.yml +0 -0
- data/spec/spec_tests/data/{dns_seedlist_discovery → seed_list_discovery/replica-set}/txt-record-with-overridden-uri-option.yml +0 -0
- data/spec/spec_tests/data/{dns_seedlist_discovery → seed_list_discovery/replica-set}/txt-record-with-unallowed-option.yml +0 -0
- data/spec/spec_tests/data/seed_list_discovery/replica-set/uri-with-admin-database.yml +13 -0
- data/spec/spec_tests/data/seed_list_discovery/replica-set/uri-with-auth.yml +12 -0
- data/spec/spec_tests/data/{dns_seedlist_discovery → seed_list_discovery/replica-set}/uri-with-port.yml +0 -0
- data/spec/spec_tests/data/{dns_seedlist_discovery → seed_list_discovery/replica-set}/uri-with-two-hosts.yml +0 -0
- data/spec/spec_tests/data/transactions/retryable-abort-errorLabels.yml +2 -0
- data/spec/spec_tests/data/transactions/retryable-abort.yml +2 -0
- data/spec/spec_tests/data/transactions/retryable-commit-errorLabels.yml +2 -0
- data/spec/spec_tests/data/transactions/retryable-commit.yml +2 -0
- data/spec/spec_tests/data/transactions/retryable-writes.yml +2 -0
- data/spec/spec_tests/data/uri_options/connection-options.yml +60 -0
- data/spec/spec_tests/load_balancers_spec.rb +15 -0
- data/spec/spec_tests/retryable_reads_spec.rb +2 -2
- data/spec/spec_tests/retryable_writes_spec.rb +1 -1
- data/spec/spec_tests/sdam_integration_spec.rb +1 -1
- data/spec/spec_tests/sdam_monitoring_spec.rb +10 -5
- data/spec/spec_tests/sdam_spec.rb +1 -1
- data/spec/spec_tests/seed_list_discovery_spec.rb +118 -0
- data/spec/spec_tests/uri_options_spec.rb +4 -4
- data/spec/stress/fork_reconnect_stress_spec.rb +1 -5
- data/spec/stress/push_monitor_close_spec.rb +44 -0
- data/spec/support/certificates/atlas-ocsp-ca.crt +82 -90
- data/spec/support/certificates/atlas-ocsp.crt +127 -122
- data/spec/support/common_shortcuts.rb +2 -3
- data/spec/support/matchers.rb +13 -0
- data/spec/support/shared/auth_context.rb +16 -0
- data/spec/support/shared/session.rb +2 -2
- data/spec/support/spec_config.rb +10 -11
- data/spec/support/using_hash.rb +31 -0
- data/spec/support/utils.rb +1 -1
- data.tar.gz.sig +0 -0
- metadata +1077 -1029
- metadata.gz.sig +0 -0
- data/lib/mongo/collection/view/builder/find_command.rb +0 -173
- data/lib/mongo/collection/view/builder/op_query.rb +0 -94
- data/lib/mongo/cursor/builder/get_more_command.rb +0 -80
- data/lib/mongo/cursor/builder/kill_cursors_command.rb +0 -111
- data/lib/mongo/cursor/builder/op_get_more.rb +0 -64
- data/lib/mongo/cursor/builder/op_kill_cursors.rb +0 -106
- data/lib/mongo/server/context.rb +0 -72
- data/spec/mongo/cursor/builder/op_kill_cursors_spec.rb +0 -66
- data/spec/runners/unified/using_hash.rb +0 -34
- data/spec/spec_tests/dns_seedlist_discovery_spec.rb +0 -79
- data/spec/support/event_subscriber.rb +0 -221
@@ -1,24 +1,75 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
# encoding: utf-8
|
3
3
|
|
4
|
-
require '
|
4
|
+
require 'lite_spec_helper'
|
5
5
|
|
6
6
|
describe Mongo::Server::ConnectionCommon do
|
7
7
|
let(:subject) { described_class.new }
|
8
8
|
|
9
|
+
let(:metadata) do
|
10
|
+
Mongo::Server::AppMetadata.new({})
|
11
|
+
end
|
12
|
+
|
9
13
|
describe '#handshake_document' do
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
14
|
+
let(:document) do
|
15
|
+
subject.handshake_document(metadata)
|
16
|
+
end
|
17
|
+
|
18
|
+
context 'with api version' do
|
19
|
+
let(:metadata) do
|
20
|
+
Mongo::Server::AppMetadata.new({
|
21
|
+
server_api: { version: '1' }
|
22
|
+
})
|
23
|
+
end
|
24
|
+
|
25
|
+
it 'returns hello document with API version' do
|
26
|
+
expect(document['hello']).to eq(1)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
context 'without api version' do
|
31
|
+
it 'returns legacy hello document without API version' do
|
32
|
+
expect(document['isMaster']).to eq(1)
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
context 'when connecting to load balancer' do
|
37
|
+
|
38
|
+
let(:document) do
|
39
|
+
subject.handshake_document(metadata, load_balancer: true)
|
40
|
+
end
|
41
|
+
|
42
|
+
it 'includes loadBalanced: true' do
|
43
|
+
document['loadBalanced'].should be true
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
describe '#handshake_command' do
|
49
|
+
let(:document) do
|
50
|
+
subject.handshake_document(metadata)
|
51
|
+
end
|
52
|
+
|
53
|
+
context 'with api version' do
|
54
|
+
let(:metadata) do
|
55
|
+
Mongo::Server::AppMetadata.new({
|
56
|
+
server_api: { version: '1' }
|
57
|
+
})
|
58
|
+
end
|
59
|
+
|
60
|
+
it 'returns OP_MSG command' do
|
61
|
+
expect(
|
62
|
+
subject.handshake_command(document)
|
63
|
+
).to be_a(Mongo::Protocol::Msg)
|
64
|
+
end
|
16
65
|
end
|
17
66
|
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
67
|
+
context 'without api version' do
|
68
|
+
it 'returns OP_QUERY command' do
|
69
|
+
expect(
|
70
|
+
subject.handshake_command(document)
|
71
|
+
).to be_a(Mongo::Protocol::Query)
|
72
|
+
end
|
22
73
|
end
|
23
74
|
end
|
24
75
|
end
|
@@ -317,6 +317,11 @@ describe Mongo::Server::ConnectionPool do
|
|
317
317
|
end
|
318
318
|
|
319
319
|
context 'connection of the same generation as pool' do
|
320
|
+
# These tests are also applicable to load balancers, but
|
321
|
+
# require different setup and assertions because load balancers
|
322
|
+
# do not have a single global generation.
|
323
|
+
require_topology :single, :replica_set, :sharded
|
324
|
+
|
320
325
|
before do
|
321
326
|
expect(pool.generation).to eq(connection.generation)
|
322
327
|
end
|
@@ -349,6 +354,11 @@ describe Mongo::Server::ConnectionPool do
|
|
349
354
|
end
|
350
355
|
|
351
356
|
context 'connection of earlier generation than pool' do
|
357
|
+
# These tests are also applicable to load balancers, but
|
358
|
+
# require different setup and assertions because load balancers
|
359
|
+
# do not have a single global generation.
|
360
|
+
require_topology :single, :replica_set, :sharded
|
361
|
+
|
352
362
|
let(:connection) do
|
353
363
|
pool.check_out.tap do |connection|
|
354
364
|
expect(connection).to receive(:generation).at_least(:once).and_return(0)
|
@@ -364,6 +374,11 @@ describe Mongo::Server::ConnectionPool do
|
|
364
374
|
end
|
365
375
|
|
366
376
|
context 'connection of later generation than pool' do
|
377
|
+
# These tests are also applicable to load balancers, but
|
378
|
+
# require different setup and assertions because load balancers
|
379
|
+
# do not have a single global generation.
|
380
|
+
require_topology :single, :replica_set, :sharded
|
381
|
+
|
367
382
|
let(:connection) do
|
368
383
|
pool.check_out.tap do |connection|
|
369
384
|
expect(connection).to receive(:generation).at_least(:once).and_return(7)
|
@@ -449,6 +464,11 @@ describe Mongo::Server::ConnectionPool do
|
|
449
464
|
end
|
450
465
|
|
451
466
|
context 'when there is an available connection which is stale' do
|
467
|
+
# These tests are also applicable to load balancers, but
|
468
|
+
# require different setup and assertions because load balancers
|
469
|
+
# do not have a single global generation.
|
470
|
+
require_topology :single, :replica_set, :sharded
|
471
|
+
|
452
472
|
let(:options) do
|
453
473
|
{ max_pool_size: 2, max_idle_time: 0.1 }
|
454
474
|
end
|
@@ -489,13 +509,54 @@ describe Mongo::Server::ConnectionPool do
|
|
489
509
|
|
490
510
|
context 'when the max size is reached' do
|
491
511
|
|
492
|
-
|
493
|
-
|
494
|
-
|
495
|
-
pool.check_out
|
512
|
+
context 'without service_id' do
|
513
|
+
it 'raises a timeout error' do
|
514
|
+
expect(Mongo::Server::Connection).to receive(:new).once.and_call_original
|
496
515
|
pool.check_out
|
497
|
-
|
498
|
-
|
516
|
+
expect {
|
517
|
+
pool.check_out
|
518
|
+
}.to raise_error(::Timeout::Error)
|
519
|
+
expect(pool.size).to eq(1)
|
520
|
+
end
|
521
|
+
end
|
522
|
+
|
523
|
+
context 'with service_id' do
|
524
|
+
require_topology :load_balanced
|
525
|
+
|
526
|
+
let(:service_id) do
|
527
|
+
pool.with_connection do |connection|
|
528
|
+
connection.service_id.should_not be nil
|
529
|
+
connection.service_id
|
530
|
+
end
|
531
|
+
end
|
532
|
+
|
533
|
+
it 'raises a timeout error' do
|
534
|
+
expect(Mongo::Server::Connection).to receive(:new).once.and_call_original
|
535
|
+
service_id
|
536
|
+
|
537
|
+
pool.check_out(service_id: service_id)
|
538
|
+
|
539
|
+
expect {
|
540
|
+
pool.check_out(service_id: service_id)
|
541
|
+
}.to raise_error(Mongo::Error::ConnectionCheckOutTimeout)
|
542
|
+
|
543
|
+
expect(pool.size).to eq(1)
|
544
|
+
end
|
545
|
+
|
546
|
+
it 'waits for the timeout' do
|
547
|
+
expect(Mongo::Server::Connection).to receive(:new).once.and_call_original
|
548
|
+
service_id
|
549
|
+
|
550
|
+
pool.check_out(service_id: service_id)
|
551
|
+
|
552
|
+
start_time = Mongo::Utils.monotonic_time
|
553
|
+
expect {
|
554
|
+
pool.check_out(service_id: service_id)
|
555
|
+
}.to raise_error(Mongo::Error::ConnectionCheckOutTimeout)
|
556
|
+
elapsed_time = Mongo::Utils.monotonic_time - start_time
|
557
|
+
|
558
|
+
elapsed_time.should > 1
|
559
|
+
end
|
499
560
|
end
|
500
561
|
end
|
501
562
|
end
|
@@ -541,7 +602,7 @@ describe Mongo::Server::ConnectionPool do
|
|
541
602
|
it 'raises an error and emits ConnectionCheckOutFailedEvent' do
|
542
603
|
pool
|
543
604
|
|
544
|
-
subscriber = EventSubscriber.new
|
605
|
+
subscriber = Mrss::EventSubscriber.new
|
545
606
|
client.subscribe(Mongo::Monitoring::CONNECTION_POOL, subscriber)
|
546
607
|
|
547
608
|
subscriber.clear_events!
|
@@ -579,6 +640,11 @@ describe Mongo::Server::ConnectionPool do
|
|
579
640
|
end
|
580
641
|
|
581
642
|
shared_examples_for 'disconnects and removes all connections in the pool and bumps generation' do
|
643
|
+
# These tests are also applicable to load balancers, but
|
644
|
+
# require different setup and assertions because load balancers
|
645
|
+
# do not have a single global generation.
|
646
|
+
require_topology :single, :replica_set, :sharded
|
647
|
+
|
582
648
|
it 'disconnects and removes and bumps' do
|
583
649
|
old_connections = []
|
584
650
|
pool.instance_variable_get('@available_connections').each do |connection|
|
@@ -9,6 +9,10 @@ describe Mongo::Server::Connection do
|
|
9
9
|
|
10
10
|
clean_slate_for_all
|
11
11
|
|
12
|
+
let(:generation_manager) do
|
13
|
+
Mongo::Server::ConnectionPool::GenerationManager.new(server: server)
|
14
|
+
end
|
15
|
+
|
12
16
|
let!(:address) do
|
13
17
|
default_address
|
14
18
|
end
|
@@ -41,7 +45,10 @@ describe Mongo::Server::Connection do
|
|
41
45
|
let(:server_options) { SpecConfig.instance.test_options.merge(monitoring_io: false) }
|
42
46
|
let(:server) do
|
43
47
|
register_server(
|
44
|
-
Mongo::Server.new(address, cluster, monitoring, listeners, server_options
|
48
|
+
Mongo::Server.new(address, cluster, monitoring, listeners, server_options.merge(
|
49
|
+
# Normally the load_balancer option is set by the cluster
|
50
|
+
load_balancer: ClusterConfig.instance.topology == :load_balanced,
|
51
|
+
))
|
45
52
|
)
|
46
53
|
end
|
47
54
|
|
@@ -59,6 +66,7 @@ describe Mongo::Server::Connection do
|
|
59
66
|
let(:pool) do
|
60
67
|
double('pool').tap do |pool|
|
61
68
|
allow(pool).to receive(:close)
|
69
|
+
allow(pool).to receive(:generation_manager).and_return(generation_manager)
|
62
70
|
end
|
63
71
|
end
|
64
72
|
|
@@ -81,7 +89,7 @@ describe Mongo::Server::Connection do
|
|
81
89
|
context 'when no socket exists' do
|
82
90
|
|
83
91
|
let(:connection) do
|
84
|
-
described_class.new(server, server.options)
|
92
|
+
described_class.new(server, server.options.merge(connection_pool: pool))
|
85
93
|
end
|
86
94
|
|
87
95
|
let(:result) do
|
@@ -226,12 +234,15 @@ describe Mongo::Server::Connection do
|
|
226
234
|
|
227
235
|
context 'when #handshake! dependency raises a network exception' do
|
228
236
|
let(:exception) do
|
229
|
-
Mongo::Error::SocketError.new
|
237
|
+
Mongo::Error::SocketError.new.tap do |exc|
|
238
|
+
allow(exc).to receive(:service_id).and_return('fake')
|
239
|
+
end
|
230
240
|
end
|
231
241
|
|
232
242
|
let(:error) do
|
233
243
|
# The exception is mutated when notes are added to it
|
234
|
-
expect_any_instance_of(Mongo::Socket).to receive(:write).and_raise(exception
|
244
|
+
expect_any_instance_of(Mongo::Socket).to receive(:write).and_raise(exception)
|
245
|
+
allow(connection).to receive(:service_id).and_return('fake')
|
235
246
|
begin
|
236
247
|
connection.connect!
|
237
248
|
rescue Exception => e
|
@@ -310,7 +321,7 @@ describe Mongo::Server::Connection do
|
|
310
321
|
context 'when a socket exists' do
|
311
322
|
|
312
323
|
let(:connection) do
|
313
|
-
described_class.new(server, server.options)
|
324
|
+
described_class.new(server, server.options.merge(connection_pool: pool))
|
314
325
|
end
|
315
326
|
|
316
327
|
let(:socket) do
|
@@ -369,10 +380,12 @@ describe Mongo::Server::Connection do
|
|
369
380
|
described_class.new(
|
370
381
|
server,
|
371
382
|
SpecConfig.instance.test_options.merge(
|
372
|
-
:
|
373
|
-
:
|
374
|
-
:
|
375
|
-
:
|
383
|
+
user: 'notauser',
|
384
|
+
password: 'password',
|
385
|
+
database: SpecConfig.instance.test_db,
|
386
|
+
heartbeat_frequency: 30,
|
387
|
+
connection_pool: pool,
|
388
|
+
)
|
376
389
|
)
|
377
390
|
end
|
378
391
|
|
@@ -448,8 +461,16 @@ describe Mongo::Server::Connection do
|
|
448
461
|
)
|
449
462
|
end
|
450
463
|
|
464
|
+
let(:exception) do
|
465
|
+
Mongo::Error::SocketError.new.tap do |exc|
|
466
|
+
if server.load_balancer?
|
467
|
+
allow(exc).to receive(:service_id).and_return('fake')
|
468
|
+
end
|
469
|
+
end
|
470
|
+
end
|
471
|
+
|
451
472
|
let(:error) do
|
452
|
-
expect_any_instance_of(auth_mechanism).to receive(:login).and_raise(
|
473
|
+
expect_any_instance_of(auth_mechanism).to receive(:login).and_raise(exception)
|
453
474
|
begin
|
454
475
|
connection.send(:connect!)
|
455
476
|
rescue => ex
|
@@ -473,9 +494,11 @@ describe Mongo::Server::Connection do
|
|
473
494
|
described_class.new(
|
474
495
|
server,
|
475
496
|
SpecConfig.instance.test_options.merge(
|
476
|
-
:
|
477
|
-
:
|
478
|
-
:
|
497
|
+
user: SpecConfig.instance.test_user.name,
|
498
|
+
password: SpecConfig.instance.test_user.password,
|
499
|
+
database: SpecConfig.instance.test_user.database,
|
500
|
+
connection_pool: pool,
|
501
|
+
)
|
479
502
|
)
|
480
503
|
end
|
481
504
|
|
@@ -563,7 +586,7 @@ describe Mongo::Server::Connection do
|
|
563
586
|
context 'when a socket is not connected' do
|
564
587
|
|
565
588
|
let(:connection) do
|
566
|
-
described_class.new(server, server.options)
|
589
|
+
described_class.new(server, server.options.merge(connection_pool: pool))
|
567
590
|
end
|
568
591
|
|
569
592
|
it 'does not raise an error' do
|
@@ -574,7 +597,7 @@ describe Mongo::Server::Connection do
|
|
574
597
|
context 'when a socket is connected' do
|
575
598
|
|
576
599
|
let(:connection) do
|
577
|
-
described_class.new(server, server.options)
|
600
|
+
described_class.new(server, server.options.merge(connection_pool: pool))
|
578
601
|
end
|
579
602
|
|
580
603
|
before do
|
@@ -598,7 +621,8 @@ describe Mongo::Server::Connection do
|
|
598
621
|
described_class.new(
|
599
622
|
server,
|
600
623
|
SpecConfig.instance.test_options.merge(
|
601
|
-
:
|
624
|
+
database: SpecConfig.instance.test_user.database,
|
625
|
+
connection_pool: pool,
|
602
626
|
).merge(Mongo::Utils.shallow_symbolize_keys(Mongo::Client.canonicalize_ruby_options(
|
603
627
|
SpecConfig.instance.credentials_or_external_user(
|
604
628
|
user: SpecConfig.instance.test_user.name,
|
@@ -817,8 +841,10 @@ describe Mongo::Server::Connection do
|
|
817
841
|
# of the test, i.e. to avoid racing with the monitor thread
|
818
842
|
# which may put the server back into non-unknown state before
|
819
843
|
# we can verify that the server was marked unknown, kill off
|
820
|
-
# the monitor thread
|
821
|
-
|
844
|
+
# the monitor thread.
|
845
|
+
unless ClusterConfig.instance.topology == :load_balanced
|
846
|
+
server.monitor.instance_variable_get('@thread').kill
|
847
|
+
end
|
822
848
|
end
|
823
849
|
end
|
824
850
|
|
@@ -844,27 +870,44 @@ describe Mongo::Server::Connection do
|
|
844
870
|
expect(connection).to be_error
|
845
871
|
end
|
846
872
|
|
847
|
-
|
848
|
-
|
849
|
-
|
873
|
+
context 'in load-balanced topology' do
|
874
|
+
require_topology :load_balanced
|
875
|
+
|
876
|
+
it 'disconnects connection pool for service id' do
|
877
|
+
connection.service_id.should_not be nil
|
878
|
+
|
879
|
+
RSpec::Mocks.with_temporary_scope do
|
880
|
+
expect(server.pool).to receive(:disconnect!).with(service_id: connection.service_id)
|
881
|
+
result
|
882
|
+
end
|
883
|
+
end
|
884
|
+
|
885
|
+
it 'does not mark server unknown' do
|
886
|
+
expect(server).not_to be_unknown
|
887
|
+
result
|
888
|
+
expect(server).not_to be_unknown
|
889
|
+
end
|
850
890
|
end
|
851
891
|
|
852
|
-
|
853
|
-
|
854
|
-
|
855
|
-
|
892
|
+
context 'in non-lb topologies' do
|
893
|
+
require_topology :single, :replica_set, :sharded
|
894
|
+
|
895
|
+
it 'disconnects connection pool' do
|
896
|
+
expect(server.pool).to receive(:disconnect!)
|
897
|
+
result
|
898
|
+
end
|
899
|
+
|
900
|
+
it 'marks server unknown' do
|
901
|
+
expect(server).not_to be_unknown
|
902
|
+
result
|
903
|
+
expect(server).to be_unknown
|
904
|
+
end
|
856
905
|
end
|
857
906
|
|
858
907
|
it 'does not request server scan' do
|
859
908
|
expect(server.scan_semaphore).not_to receive(:signal)
|
860
909
|
result
|
861
910
|
end
|
862
|
-
|
863
|
-
it 'marks server unknown' do
|
864
|
-
expect(server).not_to be_unknown
|
865
|
-
result
|
866
|
-
expect(server).to be_unknown
|
867
|
-
end
|
868
911
|
end
|
869
912
|
|
870
913
|
context 'when a socket timeout occurs' do
|
@@ -943,7 +986,7 @@ describe Mongo::Server::Connection do
|
|
943
986
|
context 'when the socket_timeout is negative' do
|
944
987
|
|
945
988
|
let(:connection) do
|
946
|
-
described_class.new(server, server.options).tap do |connection|
|
989
|
+
described_class.new(server, server.options.merge(connection_pool: pool)).tap do |connection|
|
947
990
|
connection.connect!
|
948
991
|
end
|
949
992
|
end
|
@@ -1002,7 +1045,7 @@ describe Mongo::Server::Connection do
|
|
1002
1045
|
context 'when host and port are provided' do
|
1003
1046
|
|
1004
1047
|
let(:connection) do
|
1005
|
-
described_class.new(server, server.options)
|
1048
|
+
described_class.new(server, server.options.merge(connection_pool: pool))
|
1006
1049
|
end
|
1007
1050
|
|
1008
1051
|
it 'sets the address' do
|
@@ -1017,7 +1060,7 @@ describe Mongo::Server::Connection do
|
|
1017
1060
|
it 'use incrementing ids' do
|
1018
1061
|
expect(connection.id).to eq(1)
|
1019
1062
|
|
1020
|
-
second_connection = described_class.new(server, server.options)
|
1063
|
+
second_connection = described_class.new(server, server.options.merge(connection_pool: pool))
|
1021
1064
|
expect(second_connection.id).to eq(2)
|
1022
1065
|
end
|
1023
1066
|
end
|
@@ -1025,7 +1068,11 @@ describe Mongo::Server::Connection do
|
|
1025
1068
|
context 'two pools for different servers' do
|
1026
1069
|
let(:server2) do
|
1027
1070
|
register_server(
|
1028
|
-
Mongo::Server.new(address, cluster, monitoring, listeners,
|
1071
|
+
Mongo::Server.new(address, cluster, monitoring, listeners,
|
1072
|
+
server_options.merge(
|
1073
|
+
load_balancer: ClusterConfig.instance.topology == :load_balanced,
|
1074
|
+
)
|
1075
|
+
)
|
1029
1076
|
)
|
1030
1077
|
end
|
1031
1078
|
|
@@ -1119,10 +1166,11 @@ describe Mongo::Server::Connection do
|
|
1119
1166
|
let(:connection) do
|
1120
1167
|
described_class.new(
|
1121
1168
|
server,
|
1122
|
-
:
|
1123
|
-
:
|
1124
|
-
:
|
1125
|
-
:
|
1169
|
+
user: SpecConfig.instance.test_user.name,
|
1170
|
+
password: SpecConfig.instance.test_user.password,
|
1171
|
+
database: SpecConfig.instance.test_db,
|
1172
|
+
auth_mech: :mongodb_cr,
|
1173
|
+
connection_pool: pool,
|
1126
1174
|
)
|
1127
1175
|
end
|
1128
1176
|
|
@@ -1155,7 +1203,7 @@ describe Mongo::Server::Connection do
|
|
1155
1203
|
end
|
1156
1204
|
|
1157
1205
|
let(:connection) do
|
1158
|
-
described_class.new(server, server.options)
|
1206
|
+
described_class.new(server, server.options.merge(connection_pool: pool))
|
1159
1207
|
end
|
1160
1208
|
|
1161
1209
|
context 'when a connect_timeout is in the options' do
|
@@ -1244,7 +1292,7 @@ describe Mongo::Server::Connection do
|
|
1244
1292
|
describe '#app_metadata' do
|
1245
1293
|
context 'when all options are identical to server' do
|
1246
1294
|
let(:connection) do
|
1247
|
-
described_class.new(server, server.options)
|
1295
|
+
described_class.new(server, server.options.merge(connection_pool: pool))
|
1248
1296
|
end
|
1249
1297
|
|
1250
1298
|
it 'is the same object as server app_metadata' do
|
@@ -1255,7 +1303,7 @@ describe Mongo::Server::Connection do
|
|
1255
1303
|
|
1256
1304
|
context 'when auth options are identical to server' do
|
1257
1305
|
let(:connection) do
|
1258
|
-
described_class.new(server, server.options.merge(socket_timeout: 2))
|
1306
|
+
described_class.new(server, server.options.merge(socket_timeout: 2, connection_pool: pool))
|
1259
1307
|
end
|
1260
1308
|
|
1261
1309
|
it 'is the same object as server app_metadata' do
|
@@ -1268,7 +1316,7 @@ describe Mongo::Server::Connection do
|
|
1268
1316
|
require_no_external_user
|
1269
1317
|
|
1270
1318
|
let(:connection) do
|
1271
|
-
described_class.new(server, server.options.merge(user: 'foo'))
|
1319
|
+
described_class.new(server, server.options.merge(user: 'foo', connection_pool: pool))
|
1272
1320
|
end
|
1273
1321
|
|
1274
1322
|
it 'is different object from server app_metadata' do
|
@@ -1282,4 +1330,51 @@ describe Mongo::Server::Connection do
|
|
1282
1330
|
end
|
1283
1331
|
end
|
1284
1332
|
end
|
1333
|
+
|
1334
|
+
describe '#generation' do
|
1335
|
+
|
1336
|
+
context 'non-lb' do
|
1337
|
+
require_topology :single, :replica_set, :sharded
|
1338
|
+
|
1339
|
+
it 'is set' do
|
1340
|
+
server.with_connection do |conn|
|
1341
|
+
conn.service_id.should be nil
|
1342
|
+
conn.generation.should be_a(Integer)
|
1343
|
+
end
|
1344
|
+
end
|
1345
|
+
|
1346
|
+
context 'clean slate' do
|
1347
|
+
clean_slate
|
1348
|
+
|
1349
|
+
it 'starts from 1' do
|
1350
|
+
server.with_connection do |conn|
|
1351
|
+
conn.service_id.should be nil
|
1352
|
+
conn.generation.should == 1
|
1353
|
+
end
|
1354
|
+
end
|
1355
|
+
end
|
1356
|
+
end
|
1357
|
+
|
1358
|
+
context 'lb' do
|
1359
|
+
require_topology :load_balanced
|
1360
|
+
|
1361
|
+
it 'is set' do
|
1362
|
+
server.with_connection do |conn|
|
1363
|
+
conn.service_id.should_not be nil
|
1364
|
+
conn.generation.should be_a(Integer)
|
1365
|
+
end
|
1366
|
+
end
|
1367
|
+
|
1368
|
+
context 'clean slate' do
|
1369
|
+
clean_slate
|
1370
|
+
|
1371
|
+
it 'starts from 1' do
|
1372
|
+
server.with_connection do |conn|
|
1373
|
+
conn.service_id.should_not be nil
|
1374
|
+
conn.generation.should == 1
|
1375
|
+
end
|
1376
|
+
end
|
1377
|
+
end
|
1378
|
+
end
|
1379
|
+
end
|
1285
1380
|
end
|
@@ -331,7 +331,7 @@ describe Mongo::Server::Description do
|
|
331
331
|
describe '#average_round_trip_time' do
|
332
332
|
|
333
333
|
let(:description) do
|
334
|
-
described_class.new(address, { 'secondary' => false }, 4.5)
|
334
|
+
described_class.new(address, { 'secondary' => false }, average_round_trip_time: 4.5)
|
335
335
|
end
|
336
336
|
|
337
337
|
it 'defaults to nil' do
|
@@ -136,6 +136,28 @@ describe Mongo::Server::Monitor::Connection do
|
|
136
136
|
end
|
137
137
|
end
|
138
138
|
|
139
|
+
describe '#connect!' do
|
140
|
+
|
141
|
+
let(:options) do
|
142
|
+
SpecConfig.instance.test_options.merge(
|
143
|
+
app_metadata: monitor_app_metadata,
|
144
|
+
)
|
145
|
+
end
|
146
|
+
|
147
|
+
context 'when address resolution fails' do
|
148
|
+
let(:connection) { described_class.new(server.address, options) }
|
149
|
+
|
150
|
+
it 'propagates the exception' do
|
151
|
+
connection
|
152
|
+
|
153
|
+
expect(Socket).to receive(:getaddrinfo).and_raise(SocketError.new('Test exception'))
|
154
|
+
lambda do
|
155
|
+
connection.connect!
|
156
|
+
end.should raise_error(SocketError, 'Test exception')
|
157
|
+
end
|
158
|
+
end
|
159
|
+
end
|
160
|
+
|
139
161
|
describe '#check_document' do
|
140
162
|
context 'with API version' do
|
141
163
|
let(:meta) do
|
@@ -186,16 +186,17 @@ describe Mongo::Server::Monitor do
|
|
186
186
|
context 'when running after a stop' do
|
187
187
|
it 'starts the thread' do
|
188
188
|
ClientRegistry.instance.close_all_clients
|
189
|
+
sleep 1
|
189
190
|
thread
|
190
|
-
sleep
|
191
|
+
sleep 1
|
191
192
|
|
192
193
|
RSpec::Mocks.with_temporary_scope do
|
193
194
|
expect(monitor.connection).to receive(:disconnect!).and_call_original
|
194
195
|
monitor.stop!
|
195
|
-
sleep
|
196
|
+
sleep 1
|
196
197
|
expect(thread.alive?).to be false
|
197
198
|
new_thread = monitor.run!
|
198
|
-
sleep
|
199
|
+
sleep 1
|
199
200
|
expect(new_thread.alive?).to be(true)
|
200
201
|
end
|
201
202
|
end
|