mongo 2.1.0.beta → 2.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data/README.md +10 -3
- data/Rakefile +1 -7
- data/lib/mongo/address/ipv4.rb +6 -1
- data/lib/mongo/address/unix.rb +2 -2
- data/lib/mongo/address.rb +32 -10
- data/lib/mongo/auth/cr/conversation.rb +1 -1
- data/lib/mongo/auth/ldap/conversation.rb +7 -3
- data/lib/mongo/auth/scram/conversation.rb +9 -3
- data/lib/mongo/auth/user/view.rb +23 -2
- data/lib/mongo/auth/x509/conversation.rb +1 -1
- data/lib/mongo/bulk_write/combineable.rb +51 -0
- data/lib/mongo/bulk_write/ordered_combiner.rb +55 -0
- data/lib/mongo/bulk_write/result.rb +61 -8
- data/lib/mongo/bulk_write/result_combiner.rb +117 -0
- data/lib/mongo/bulk_write/transformable.rb +132 -0
- data/lib/mongo/bulk_write/unordered_combiner.rb +52 -0
- data/lib/mongo/bulk_write/validatable.rb +62 -0
- data/lib/mongo/bulk_write.rb +164 -23
- data/lib/mongo/client.rb +75 -18
- data/lib/mongo/cluster/topology/replica_set.rb +8 -6
- data/lib/mongo/cluster/topology/unknown.rb +5 -2
- data/lib/mongo/cluster.rb +85 -5
- data/lib/mongo/collection/view/aggregation.rb +19 -45
- data/lib/mongo/collection/view/builder/aggregation.rb +98 -0
- data/lib/mongo/collection/view/builder/find_command.rb +111 -0
- data/lib/mongo/collection/view/builder/flags.rb +62 -0
- data/lib/mongo/collection/view/builder/map_reduce.rb +134 -0
- data/lib/mongo/collection/view/builder/modifiers.rb +80 -0
- data/lib/mongo/collection/view/builder/op_query.rb +83 -0
- data/lib/mongo/collection/view/builder.rb +20 -0
- data/lib/mongo/collection/view/explainable.rb +15 -0
- data/lib/mongo/collection/view/immutable.rb +4 -11
- data/lib/mongo/collection/view/iterable.rb +40 -5
- data/lib/mongo/collection/view/map_reduce.rb +67 -37
- data/lib/mongo/collection/view/readable.rb +114 -100
- data/lib/mongo/collection/view/writable.rb +46 -22
- data/lib/mongo/collection/view.rb +25 -22
- data/lib/mongo/collection.rb +130 -12
- data/lib/mongo/cursor/builder/get_more_command.rb +71 -0
- data/lib/mongo/cursor/builder/kill_cursors_command.rb +62 -0
- data/lib/mongo/cursor/builder/op_get_more.rb +61 -0
- data/lib/mongo/cursor/builder/op_kill_cursors.rb +56 -0
- data/lib/mongo/cursor/builder.rb +18 -0
- data/lib/mongo/cursor.rb +76 -21
- data/lib/mongo/database/view.rb +11 -6
- data/lib/mongo/database.rb +16 -6
- data/lib/mongo/dbref.rb +9 -9
- data/lib/mongo/{bulk_write/unordered_bulk_write.rb → error/closed_stream.rb} +12 -21
- data/lib/mongo/{bulk_write/ordered_bulk_write.rb → error/extra_file_chunk.rb} +13 -27
- data/lib/mongo/error/file_not_found.rb +37 -0
- data/lib/mongo/error/invalid_file.rb +2 -2
- data/lib/mongo/error/invalid_file_revision.rb +37 -0
- data/lib/mongo/error/invalid_uri.rb +5 -4
- data/lib/mongo/error/invalid_write_concern.rb +35 -0
- data/lib/mongo/error/missing_file_chunk.rb +38 -0
- data/lib/mongo/error/operation_failure.rb +33 -2
- data/lib/mongo/error/unchangeable_collection_option.rb +38 -0
- data/lib/mongo/error/unexpected_chunk_length.rb +39 -0
- data/lib/mongo/error.rb +8 -0
- data/lib/mongo/grid/file/chunk.rb +9 -9
- data/lib/mongo/grid/file/{metadata.rb → info.rb} +41 -39
- data/lib/mongo/grid/file.rb +12 -9
- data/lib/mongo/grid/fs_bucket.rb +448 -0
- data/lib/mongo/grid/stream/read.rb +208 -0
- data/lib/mongo/grid/stream/write.rb +187 -0
- data/lib/mongo/grid/stream.rb +64 -0
- data/lib/mongo/grid.rb +2 -1
- data/lib/mongo/index/view.rb +7 -4
- data/lib/mongo/index.rb +5 -0
- data/lib/mongo/loggable.rb +34 -57
- data/lib/mongo/logger.rb +16 -78
- data/lib/mongo/monitoring/command_log_subscriber.rb +38 -14
- data/lib/mongo/monitoring/event/command_started.rb +2 -1
- data/lib/mongo/monitoring/event/command_succeeded.rb +24 -2
- data/lib/mongo/monitoring/event/secure.rb +58 -0
- data/lib/mongo/monitoring/event.rb +1 -0
- data/lib/mongo/monitoring/publishable.rb +22 -12
- data/lib/mongo/monitoring.rb +1 -5
- data/lib/mongo/operation/commands/aggregate/result.rb +89 -0
- data/lib/mongo/operation/commands/aggregate.rb +64 -0
- data/lib/mongo/operation/commands/collections_info/result.rb +41 -0
- data/lib/mongo/operation/{read → commands}/collections_info.rb +5 -3
- data/lib/mongo/operation/commands/command.rb +47 -0
- data/lib/mongo/operation/commands/find/result.rb +62 -0
- data/lib/mongo/operation/commands/find.rb +27 -0
- data/lib/mongo/operation/commands/get_more/result.rb +62 -0
- data/lib/mongo/operation/commands/get_more.rb +27 -0
- data/lib/mongo/operation/{read → commands}/indexes.rb +9 -6
- data/lib/mongo/operation/{list_collections → commands/list_collections}/result.rb +1 -21
- data/lib/mongo/operation/{read → commands}/list_collections.rb +4 -32
- data/lib/mongo/operation/{list_indexes → commands/list_indexes}/result.rb +1 -21
- data/lib/mongo/operation/{read → commands}/list_indexes.rb +3 -33
- data/lib/mongo/operation/commands/map_reduce/result.rb +119 -0
- data/lib/mongo/operation/commands/map_reduce.rb +49 -0
- data/lib/mongo/operation/commands/parallel_scan/result.rb +64 -0
- data/lib/mongo/operation/commands/parallel_scan.rb +52 -0
- data/lib/mongo/operation/commands/user_query.rb +71 -0
- data/lib/mongo/operation/commands/users_info/result.rb +38 -0
- data/lib/mongo/operation/commands/users_info.rb +48 -0
- data/lib/mongo/operation/commands.rb +26 -0
- data/lib/mongo/operation/executable.rb +4 -68
- data/lib/mongo/operation/kill_cursors.rb +3 -3
- data/lib/mongo/operation/object_id_generator.rb +36 -0
- data/lib/mongo/operation/read/get_more.rb +2 -22
- data/lib/mongo/operation/read/query/result.rb +40 -0
- data/lib/mongo/operation/read/query.rb +4 -21
- data/lib/mongo/operation/read.rb +0 -4
- data/lib/mongo/operation/{read_preferrable.rb → read_preference.rb} +3 -2
- data/lib/mongo/operation/result.rb +43 -1
- data/lib/mongo/operation/specifiable.rb +59 -1
- data/lib/mongo/operation/write/bulk/bulkable.rb +83 -0
- data/lib/mongo/operation/write/bulk/delete/result.rb +67 -0
- data/lib/mongo/operation/write/bulk/delete.rb +71 -0
- data/lib/mongo/operation/write/bulk/insert/result.rb +129 -0
- data/lib/mongo/operation/write/bulk/insert.rb +96 -0
- data/lib/mongo/operation/write/bulk/legacy_mergable.rb +87 -0
- data/lib/mongo/operation/write/bulk/mergable.rb +71 -0
- data/lib/mongo/operation/write/bulk/update/result.rb +174 -0
- data/lib/mongo/operation/write/bulk/update.rb +81 -0
- data/lib/mongo/operation/write/bulk.rb +6 -3
- data/lib/mongo/operation/write/command/create_index.rb +0 -1
- data/lib/mongo/operation/write/command/create_user.rb +0 -1
- data/lib/mongo/operation/write/command/delete.rb +3 -3
- data/lib/mongo/operation/write/command/drop_index.rb +0 -1
- data/lib/mongo/operation/write/command/insert.rb +4 -3
- data/lib/mongo/operation/write/command/remove_user.rb +0 -1
- data/lib/mongo/operation/write/command/update.rb +6 -4
- data/lib/mongo/operation/write/command/update_user.rb +0 -1
- data/lib/mongo/operation/write/command/writable.rb +13 -18
- data/lib/mongo/operation/write/create_index.rb +4 -27
- data/lib/mongo/operation/write/create_user.rb +4 -30
- data/lib/mongo/operation/write/delete.rb +6 -29
- data/lib/mongo/operation/write/drop_index.rb +3 -3
- data/lib/mongo/operation/write/gle.rb +49 -0
- data/lib/mongo/operation/write/idable.rb +24 -2
- data/lib/mongo/operation/write/insert.rb +2 -24
- data/lib/mongo/operation/write/remove_user.rb +4 -27
- data/lib/mongo/operation/write/update.rb +13 -36
- data/lib/mongo/operation/write/update_user.rb +4 -30
- data/lib/mongo/operation/write/write_command_enabled.rb +53 -0
- data/lib/mongo/operation/write.rb +2 -0
- data/lib/mongo/operation.rb +33 -5
- data/lib/mongo/options/mapper.rb +26 -2
- data/lib/mongo/options/redacted.rb +156 -0
- data/lib/mongo/options.rb +1 -0
- data/lib/mongo/protocol/bit_vector.rb +11 -9
- data/lib/mongo/protocol/delete.rb +78 -3
- data/lib/mongo/protocol/get_more.rb +59 -2
- data/lib/mongo/protocol/insert.rb +73 -1
- data/lib/mongo/protocol/kill_cursors.rb +66 -4
- data/lib/mongo/protocol/message.rb +44 -20
- data/lib/mongo/protocol/query.rb +153 -65
- data/lib/mongo/protocol/reply.rb +92 -1
- data/lib/mongo/protocol/serializers.rb +49 -40
- data/lib/mongo/protocol/update.rb +93 -1
- data/lib/mongo/retryable.rb +101 -0
- data/lib/mongo/server/connectable.rb +28 -8
- data/lib/mongo/server/connection.rb +52 -10
- data/lib/mongo/server/connection_pool/queue.rb +15 -0
- data/lib/mongo/server/connection_pool.rb +12 -15
- data/lib/mongo/server/description/features.rb +4 -2
- data/lib/mongo/server/description.rb +39 -3
- data/lib/mongo/server/monitor/connection.rb +49 -28
- data/lib/mongo/server/monitor.rb +3 -14
- data/lib/mongo/server.rb +31 -4
- data/lib/mongo/server_selector/selectable.rb +58 -32
- data/lib/mongo/server_selector.rb +19 -10
- data/lib/mongo/socket/ssl.rb +4 -1
- data/lib/mongo/socket/tcp.rb +2 -2
- data/lib/mongo/socket/unix.rb +5 -8
- data/lib/mongo/socket.rb +11 -4
- data/lib/mongo/uri.rb +245 -139
- data/lib/mongo/version.rb +1 -1
- data/lib/mongo/write_concern.rb +21 -6
- data/lib/mongo.rb +4 -4
- data/mongo.gemspec +1 -2
- data/spec/mongo/address/unix_spec.rb +1 -1
- data/spec/mongo/address_spec.rb +25 -0
- data/spec/mongo/auth/ldap/conversation_spec.rb +43 -0
- data/spec/mongo/auth/user/view_spec.rb +26 -1
- data/spec/mongo/bulk_write/ordered_combiner_spec.rb +284 -0
- data/spec/mongo/bulk_write/unordered_combiner_spec.rb +239 -0
- data/spec/mongo/bulk_write_spec.rb +385 -161
- data/spec/mongo/client_spec.rb +193 -23
- data/spec/mongo/cluster/topology/replica_set_spec.rb +2 -0
- data/spec/mongo/collection/view/aggregation_spec.rb +65 -0
- data/spec/mongo/collection/view/builder/find_command_spec.rb +167 -0
- data/spec/mongo/collection/view/builder/flags_spec.rb +106 -0
- data/spec/mongo/collection/view/builder/modifiers_spec.rb +210 -0
- data/spec/mongo/collection/view/builder/op_query_spec.rb +154 -0
- data/spec/mongo/collection/view/explainable_spec.rb +1 -2
- data/spec/mongo/collection/view/immutable_spec.rb +54 -0
- data/spec/mongo/collection/view/map_reduce_spec.rb +104 -9
- data/spec/mongo/collection/view/readable_spec.rb +109 -112
- data/spec/mongo/collection/view_spec.rb +119 -487
- data/spec/mongo/collection_spec.rb +1002 -33
- data/spec/mongo/command_monitoring_spec.rb +64 -0
- data/spec/mongo/connection_string_spec.rb +115 -0
- data/spec/mongo/cursor/builder/get_more_command_spec.rb +160 -0
- data/spec/mongo/cursor/builder/op_get_more_spec.rb +52 -0
- data/spec/mongo/cursor_spec.rb +10 -60
- data/spec/mongo/database_spec.rb +81 -12
- data/spec/mongo/dbref_spec.rb +4 -4
- data/spec/mongo/grid/file/chunk_spec.rb +6 -6
- data/spec/mongo/grid/file/{metadata_spec.rb → info_spec.rb} +29 -17
- data/spec/mongo/grid/file_spec.rb +8 -8
- data/spec/mongo/grid/fs_bucket_spec.rb +1020 -0
- data/spec/mongo/grid/stream/read_spec.rb +275 -0
- data/spec/mongo/grid/stream/write_spec.rb +440 -0
- data/spec/mongo/grid/stream_spec.rb +48 -0
- data/spec/mongo/gridfs_spec.rb +50 -0
- data/spec/mongo/index/view_spec.rb +41 -0
- data/spec/mongo/logger_spec.rb +0 -40
- data/spec/mongo/monitoring/command_log_subscriber_spec.rb +76 -0
- data/spec/mongo/monitoring/event/command_started_spec.rb +26 -0
- data/spec/mongo/monitoring/event/command_succeeded_spec.rb +26 -0
- data/spec/mongo/monitoring/event/secure_spec.rb +57 -0
- data/spec/mongo/operation/{aggregate → commands/aggregate}/result_spec.rb +1 -1
- data/spec/mongo/operation/commands/aggregate_spec.rb +69 -0
- data/spec/mongo/operation/{read → commands}/collections_info_spec.rb +1 -1
- data/spec/mongo/operation/{command_spec.rb → commands/command_spec.rb} +1 -19
- data/spec/mongo/operation/{read → commands}/indexes_spec.rb +1 -1
- data/spec/mongo/operation/{map_reduce_spec.rb → commands/map_reduce_spec.rb} +1 -19
- data/spec/mongo/operation/kill_cursors_spec.rb +1 -17
- data/spec/mongo/operation/read/get_more_spec.rb +0 -16
- data/spec/mongo/operation/read/query_spec.rb +19 -16
- data/spec/mongo/operation/{read_preferrable_spec.rb → read_preference_spec.rb} +11 -11
- data/spec/mongo/operation/result_spec.rb +19 -0
- data/spec/mongo/operation/write/bulk/{bulk_delete_spec.rb → delete_spec.rb} +17 -28
- data/spec/mongo/operation/write/bulk/{bulk_insert_spec.rb → insert_spec.rb} +1 -12
- data/spec/mongo/operation/write/bulk/{bulk_update_spec.rb → update_spec.rb} +7 -18
- data/spec/mongo/operation/write/command/delete_spec.rb +18 -9
- data/spec/mongo/operation/write/command/insert_spec.rb +18 -9
- data/spec/mongo/operation/write/command/update_spec.rb +18 -9
- data/spec/mongo/operation/write/delete_spec.rb +3 -3
- data/spec/mongo/operation/write/insert_spec.rb +0 -11
- data/spec/mongo/operation/write/update_spec.rb +6 -6
- data/spec/mongo/options/redacted_spec.rb +350 -0
- data/spec/mongo/protocol/delete_spec.rb +4 -4
- data/spec/mongo/protocol/get_more_spec.rb +4 -4
- data/spec/mongo/protocol/insert_spec.rb +3 -3
- data/spec/mongo/protocol/kill_cursors_spec.rb +8 -6
- data/spec/mongo/protocol/query_spec.rb +21 -7
- data/spec/mongo/protocol/update_spec.rb +5 -5
- data/spec/mongo/retryable_spec.rb +221 -0
- data/spec/mongo/server/connection_pool/queue_spec.rb +16 -0
- data/spec/mongo/server/connection_pool_spec.rb +42 -6
- data/spec/mongo/server/connection_spec.rb +86 -1
- data/spec/mongo/server/description/features_spec.rb +25 -0
- data/spec/mongo/server/description_spec.rb +42 -0
- data/spec/mongo/server/monitor_spec.rb +44 -0
- data/spec/mongo/server_discovery_and_monitoring_spec.rb +25 -59
- data/spec/mongo/server_selection_rtt_spec.rb +37 -57
- data/spec/mongo/server_selection_spec.rb +5 -3
- data/spec/mongo/server_selector/nearest_spec.rb +35 -27
- data/spec/mongo/server_selector/primary_preferred_spec.rb +32 -30
- data/spec/mongo/server_selector/primary_spec.rb +21 -14
- data/spec/mongo/server_selector/secondary_preferred_spec.rb +28 -26
- data/spec/mongo/server_selector/secondary_spec.rb +24 -22
- data/spec/mongo/server_selector_spec.rb +87 -24
- data/spec/mongo/server_spec.rb +78 -15
- data/spec/mongo/socket/ssl_spec.rb +101 -57
- data/spec/mongo/socket/unix_spec.rb +52 -0
- data/spec/mongo/uri_spec.rb +271 -59
- data/spec/mongo/write_concern_spec.rb +126 -0
- data/spec/spec_helper.rb +29 -23
- data/spec/support/authorization.rb +4 -5
- data/spec/support/command_monitoring/bulkWrite.yml +73 -0
- data/spec/support/command_monitoring/command.yml +42 -0
- data/spec/support/command_monitoring/deleteMany.yml +55 -0
- data/spec/support/command_monitoring/deleteOne.yml +55 -0
- data/spec/support/command_monitoring/find.yml +268 -0
- data/spec/support/command_monitoring/insertMany.yml +81 -0
- data/spec/support/command_monitoring/insertOne.yml +51 -0
- data/spec/support/command_monitoring/updateMany.yml +67 -0
- data/spec/support/command_monitoring/updateOne.yml +95 -0
- data/spec/support/command_monitoring.rb +373 -0
- data/spec/support/connection_string.rb +228 -0
- data/spec/support/connection_string_tests/invalid-uris.yml +193 -0
- data/spec/support/connection_string_tests/valid-auth.yml +256 -0
- data/spec/support/connection_string_tests/valid-host_identifiers.yml +121 -0
- data/spec/support/connection_string_tests/valid-options.yml +30 -0
- data/spec/support/connection_string_tests/valid-unix_socket-absolute.yml +197 -0
- data/spec/support/connection_string_tests/valid-unix_socket-relative.yml +213 -0
- data/spec/support/connection_string_tests/valid-warnings.yml +55 -0
- data/spec/support/crud/read.rb +14 -10
- data/spec/support/crud/write.rb +36 -9
- data/spec/support/crud.rb +10 -2
- data/spec/support/gridfs.rb +637 -0
- data/spec/support/gridfs_tests/delete.yml +157 -0
- data/spec/support/gridfs_tests/download.yml +210 -0
- data/spec/support/gridfs_tests/download_by_name.yml +113 -0
- data/spec/support/gridfs_tests/upload.yml +158 -0
- data/spec/support/matchers.rb +2 -2
- data/spec/support/sdam/rs/equal_electionids.yml +1 -2
- data/spec/support/sdam/rs/new_primary_new_electionid.yml +0 -3
- data/spec/support/sdam/rs/primary_mismatched_me.yml +37 -0
- data/spec/support/sdam/rs/primary_to_no_primary_mismatched_me.yml +75 -0
- data/spec/support/sdam/rs/rsother_discovered.yml +24 -3
- data/spec/support/sdam/rs/secondary_mismatched_me.yml +37 -0
- data/spec/support/sdam/rs/stepdown_change_set_name.yml +59 -0
- data/spec/support/sdam/single/direct_connection_rsarbiter.yml +1 -1
- data/spec/support/sdam/single/direct_connection_rsprimary.yml +1 -1
- data/spec/support/sdam/single/direct_connection_rssecondary.yml +1 -1
- data/spec/support/sdam/single/direct_connection_slave.yml +1 -1
- data/spec/support/sdam/single/direct_connection_standalone.yml +1 -1
- data/spec/support/sdam/single/not_ok_response.yml +0 -1
- data/spec/support/server_discovery_and_monitoring.rb +3 -1
- data/spec/support/server_selection.rb +3 -1
- data/spec/support/shared/bulk_write.rb +192 -0
- data/spec/support/shared/protocol.rb +5 -5
- data/spec/support/shared/server_selector.rb +78 -13
- data/spec/support/travis.rb +1 -1
- data.tar.gz.sig +0 -0
- metadata +211 -72
- metadata.gz.sig +0 -0
- data/lib/mongo/bulk_write/bulk_writable.rb +0 -252
- data/lib/mongo/bulk_write/deletable.rb +0 -57
- data/lib/mongo/bulk_write/insertable.rb +0 -49
- data/lib/mongo/bulk_write/replacable.rb +0 -58
- data/lib/mongo/bulk_write/updatable.rb +0 -69
- data/lib/mongo/grid/fs.rb +0 -146
- data/lib/mongo/operation/aggregate/result.rb +0 -103
- data/lib/mongo/operation/aggregate.rb +0 -108
- data/lib/mongo/operation/command.rb +0 -61
- data/lib/mongo/operation/map_reduce/result.rb +0 -122
- data/lib/mongo/operation/map_reduce.rb +0 -95
- data/lib/mongo/operation/parallel_scan/result.rb +0 -72
- data/lib/mongo/operation/parallel_scan.rb +0 -76
- data/lib/mongo/operation/write/bulk/bulk_delete/result.rb +0 -75
- data/lib/mongo/operation/write/bulk/bulk_delete.rb +0 -145
- data/lib/mongo/operation/write/bulk/bulk_insert/result.rb +0 -130
- data/lib/mongo/operation/write/bulk/bulk_insert.rb +0 -132
- data/lib/mongo/operation/write/bulk/bulk_mergable.rb +0 -67
- data/lib/mongo/operation/write/bulk/bulk_update/result.rb +0 -174
- data/lib/mongo/operation/write/bulk/bulk_update.rb +0 -154
- data/lib/mongo/operation/write/bulk/legacy_bulk_mergable.rb +0 -83
- data/spec/mongo/grid/fs_spec.rb +0 -160
- data/spec/mongo/loggable_spec.rb +0 -63
- data/spec/mongo/operation/aggregate_spec.rb +0 -127
@@ -8,80 +8,60 @@ describe 'Server Selection moving average round trip time calculation' do
|
|
8
8
|
|
9
9
|
spec = Mongo::ServerSelection::RTT::Spec.new(file)
|
10
10
|
|
11
|
-
|
12
|
-
|
13
|
-
module Mongo
|
14
|
-
class Server
|
15
|
-
|
16
|
-
# We monkey-patch the monitor here, so the last average rtt can be controlled.
|
17
|
-
# We keep the API of Monitor#initialize but add in an extra option and set the last rtt.
|
18
|
-
#
|
19
|
-
# @since 2.0.0
|
20
|
-
class Monitor
|
21
|
-
|
22
|
-
def initialize(address, listeners, options = {})
|
23
|
-
@description = Mongo::Server::Description.new(address, {})
|
24
|
-
@inspector = Mongo::Server::Description::Inspector.new(listeners)
|
25
|
-
@options = options.freeze
|
26
|
-
@connection = Connection.new(address, options)
|
27
|
-
@last_round_trip_time = options[:avg_rtt_ms]
|
28
|
-
@mutex = Mutex.new
|
29
|
-
end
|
11
|
+
context(spec.description) do
|
30
12
|
|
31
|
-
|
13
|
+
before(:all) do
|
32
14
|
|
33
|
-
|
15
|
+
module Mongo
|
16
|
+
class Server
|
17
|
+
|
18
|
+
# We monkey-patch the monitor here, so the last average rtt can be controlled.
|
19
|
+
# We keep the API of Monitor#initialize but add in an extra option and set the last rtt.
|
34
20
|
#
|
35
21
|
# @since 2.0.0
|
36
|
-
|
37
|
-
|
38
|
-
|
22
|
+
class Monitor
|
23
|
+
|
24
|
+
alias :original_initialize :initialize
|
25
|
+
def initialize(address, listeners, options = {})
|
26
|
+
@description = Mongo::Server::Description.new(address, {})
|
27
|
+
@inspector = Mongo::Server::Description::Inspector.new(listeners)
|
28
|
+
@options = options.freeze
|
29
|
+
@connection = Connection.new(address, options)
|
30
|
+
@last_round_trip_time = options[:avg_rtt_ms]
|
31
|
+
@mutex = Mutex.new
|
32
|
+
end
|
33
|
+
|
34
|
+
# We monkey patch this method to use an instance variable instead of calculating time elapsed.
|
35
|
+
#
|
36
|
+
# @since 2.0.0
|
37
|
+
alias :original_average_round_trip_time :average_round_trip_time
|
38
|
+
def average_round_trip_time(start)
|
39
|
+
new_rtt = @new_rtt_ms
|
40
|
+
RTT_WEIGHT_FACTOR * new_rtt + (1 - RTT_WEIGHT_FACTOR) * (@last_round_trip_time || new_rtt)
|
41
|
+
end
|
39
42
|
end
|
40
43
|
end
|
41
44
|
end
|
42
45
|
end
|
43
|
-
end
|
44
46
|
|
45
|
-
|
47
|
+
after(:all) do
|
46
48
|
|
47
|
-
|
48
|
-
|
49
|
+
module Mongo
|
50
|
+
class Server
|
49
51
|
|
50
|
-
|
51
|
-
|
52
|
-
|
52
|
+
# Return the monitor implementation to its original for the other
|
53
|
+
# tests in the suite.
|
54
|
+
class Monitor
|
53
55
|
|
54
|
-
|
55
|
-
|
56
|
-
# @example Create the server monitor.
|
57
|
-
# Mongo::Server::Monitor.new(address, listeners)
|
58
|
-
#
|
59
|
-
# @param [ Address ] address The address to monitor.
|
60
|
-
# @param [ Event::Listeners ] listeners The event listeners.
|
61
|
-
# @param [ Hash ] options The options.
|
62
|
-
#
|
63
|
-
# @since 2.0.0
|
64
|
-
def initialize(address, listeners, options = {})
|
65
|
-
@description = Description.new(address, {})
|
66
|
-
@inspector = Description::Inspector.new(listeners)
|
67
|
-
@options = options.freeze
|
68
|
-
@connection = Connection.new(address, options)
|
69
|
-
@last_round_trip_time = nil
|
70
|
-
@mutex = Mutex.new
|
71
|
-
end
|
72
|
-
|
73
|
-
private
|
56
|
+
alias :initialize :original_initialize
|
57
|
+
remove_method(:original_initialize)
|
74
58
|
|
75
|
-
|
76
|
-
|
77
|
-
RTT_WEIGHT_FACTOR * new_rtt + (1 - RTT_WEIGHT_FACTOR) * (@last_round_trip_time || new_rtt)
|
59
|
+
alias :average_round_trip_time :original_average_round_trip_time
|
60
|
+
remove_method(:original_average_round_trip_time)
|
78
61
|
end
|
79
62
|
end
|
80
63
|
end
|
81
64
|
end
|
82
|
-
end
|
83
|
-
|
84
|
-
context(spec.description) do
|
85
65
|
|
86
66
|
let(:address) do
|
87
67
|
Mongo::Address.new('127.0.0.1:27017')
|
@@ -39,6 +39,7 @@ describe 'Server Selection' do
|
|
39
39
|
allow(s).to receive(:tags).and_return(server['tags'])
|
40
40
|
allow(s).to receive(:secondary?).and_return(server['type'] == 'RSSecondary')
|
41
41
|
allow(s).to receive(:primary?).and_return(server['type'] == 'RSPrimary')
|
42
|
+
allow(s).to receive(:connectable?).and_return(true)
|
42
43
|
end
|
43
44
|
end
|
44
45
|
end
|
@@ -49,14 +50,15 @@ describe 'Server Selection' do
|
|
49
50
|
Mongo::Server.new(address, double('cluster'), monitoring, listeners, TEST_OPTIONS).tap do |s|
|
50
51
|
allow(s).to receive(:average_round_trip_time).and_return(server['avg_rtt_ms'])
|
51
52
|
allow(s).to receive(:tags).and_return(server['tags'])
|
53
|
+
allow(s).to receive(:connectable?).and_return(true)
|
52
54
|
end
|
53
55
|
end
|
54
56
|
end
|
55
57
|
|
56
58
|
let(:server_selector) do
|
57
|
-
Mongo::ServerSelector.get(
|
58
|
-
|
59
|
-
|
59
|
+
Mongo::ServerSelector.get(:mode => spec.read_preference['mode'],
|
60
|
+
:tag_sets => spec.read_preference['tag_sets'],
|
61
|
+
:server_selection_timeout => 1)
|
60
62
|
end
|
61
63
|
|
62
64
|
before do
|
@@ -2,30 +2,38 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
describe Mongo::ServerSelector::Nearest do
|
4
4
|
|
5
|
+
let(:name) { :nearest }
|
6
|
+
|
5
7
|
include_context 'server selector'
|
6
8
|
|
7
|
-
it_behaves_like 'a
|
8
|
-
let(:name) { :nearest }
|
9
|
+
it_behaves_like 'a server selector mode' do
|
9
10
|
let(:slave_ok) { true }
|
10
11
|
end
|
11
12
|
|
12
|
-
it_behaves_like 'a
|
13
|
+
it_behaves_like 'a server selector accepting tag sets'
|
14
|
+
it_behaves_like 'a server selector with sensitive data in its options'
|
13
15
|
|
14
16
|
describe '#to_mongos' do
|
15
17
|
|
16
18
|
context 'tag set not provided' do
|
19
|
+
|
20
|
+
let(:expected) do
|
21
|
+
{ :mode => 'nearest' }
|
22
|
+
end
|
23
|
+
|
17
24
|
it 'returns a read preference formatted for mongos' do
|
18
|
-
expect(
|
25
|
+
expect(selector.to_mongos).to eq(expected)
|
19
26
|
end
|
20
27
|
end
|
21
28
|
|
22
29
|
context 'tag set provided' do
|
30
|
+
|
23
31
|
let(:tag_sets) do
|
24
32
|
[tag_set]
|
25
33
|
end
|
26
34
|
|
27
35
|
it 'returns a read preference formatted for mongos' do
|
28
|
-
expect(
|
36
|
+
expect(selector.to_mongos).to eq(
|
29
37
|
{ :mode => 'nearest', :tags => tag_sets }
|
30
38
|
)
|
31
39
|
end
|
@@ -38,7 +46,7 @@ describe Mongo::ServerSelector::Nearest do
|
|
38
46
|
let(:candidates) { [] }
|
39
47
|
|
40
48
|
it 'returns an empty array' do
|
41
|
-
expect(
|
49
|
+
expect(selector.send(:select, candidates)).to be_empty
|
42
50
|
end
|
43
51
|
end
|
44
52
|
|
@@ -46,7 +54,7 @@ describe Mongo::ServerSelector::Nearest do
|
|
46
54
|
let(:candidates) { [primary] }
|
47
55
|
|
48
56
|
it 'returns an array with the primary' do
|
49
|
-
expect(
|
57
|
+
expect(selector.send(:select, candidates)).to eq([primary])
|
50
58
|
end
|
51
59
|
end
|
52
60
|
|
@@ -54,7 +62,7 @@ describe Mongo::ServerSelector::Nearest do
|
|
54
62
|
let(:candidates) { [secondary] }
|
55
63
|
|
56
64
|
it 'returns an array with the secondary' do
|
57
|
-
expect(
|
65
|
+
expect(selector.send(:select, candidates)).to eq([secondary])
|
58
66
|
end
|
59
67
|
end
|
60
68
|
|
@@ -62,7 +70,7 @@ describe Mongo::ServerSelector::Nearest do
|
|
62
70
|
let(:candidates) { [primary, secondary] }
|
63
71
|
|
64
72
|
it 'returns an array with the primary and secondary' do
|
65
|
-
expect(
|
73
|
+
expect(selector.send(:select, candidates)).to match_array([primary, secondary])
|
66
74
|
end
|
67
75
|
end
|
68
76
|
|
@@ -70,7 +78,7 @@ describe Mongo::ServerSelector::Nearest do
|
|
70
78
|
let(:candidates) { [secondary, secondary] }
|
71
79
|
|
72
80
|
it 'returns an array with the secondaries' do
|
73
|
-
expect(
|
81
|
+
expect(selector.send(:select, candidates)).to match_array([secondary, secondary])
|
74
82
|
end
|
75
83
|
end
|
76
84
|
|
@@ -89,7 +97,7 @@ describe Mongo::ServerSelector::Nearest do
|
|
89
97
|
let(:candidates) { [primary] }
|
90
98
|
|
91
99
|
it 'returns an empty array' do
|
92
|
-
expect(
|
100
|
+
expect(selector.send(:select, candidates)).to be_empty
|
93
101
|
end
|
94
102
|
end
|
95
103
|
|
@@ -97,7 +105,7 @@ describe Mongo::ServerSelector::Nearest do
|
|
97
105
|
let(:candidates) { [matching_primary] }
|
98
106
|
|
99
107
|
it 'returns an array with the primary' do
|
100
|
-
expect(
|
108
|
+
expect(selector.send(:select, candidates)).to eq([matching_primary])
|
101
109
|
end
|
102
110
|
end
|
103
111
|
|
@@ -105,7 +113,7 @@ describe Mongo::ServerSelector::Nearest do
|
|
105
113
|
let(:candidates) { [secondary] }
|
106
114
|
|
107
115
|
it 'returns an empty array' do
|
108
|
-
expect(
|
116
|
+
expect(selector.send(:select, candidates)).to be_empty
|
109
117
|
end
|
110
118
|
end
|
111
119
|
|
@@ -113,7 +121,7 @@ describe Mongo::ServerSelector::Nearest do
|
|
113
121
|
let(:candidates) { [matching_secondary] }
|
114
122
|
|
115
123
|
it 'returns an array with the matching secondary' do
|
116
|
-
expect(
|
124
|
+
expect(selector.send(:select, candidates)).to eq([matching_secondary])
|
117
125
|
end
|
118
126
|
end
|
119
127
|
end
|
@@ -124,7 +132,7 @@ describe Mongo::ServerSelector::Nearest do
|
|
124
132
|
let(:candidates) { [primary, secondary, secondary] }
|
125
133
|
|
126
134
|
it 'returns an empty array' do
|
127
|
-
expect(
|
135
|
+
expect(selector.send(:select, candidates)).to be_empty
|
128
136
|
end
|
129
137
|
end
|
130
138
|
|
@@ -132,7 +140,7 @@ describe Mongo::ServerSelector::Nearest do
|
|
132
140
|
let(:candidates) { [matching_primary, secondary, secondary] }
|
133
141
|
|
134
142
|
it 'returns an array with the matching primary' do
|
135
|
-
expect(
|
143
|
+
expect(selector.send(:select, candidates)).to eq([matching_primary])
|
136
144
|
end
|
137
145
|
end
|
138
146
|
|
@@ -140,7 +148,7 @@ describe Mongo::ServerSelector::Nearest do
|
|
140
148
|
let(:candidates) { [primary, matching_secondary, secondary] }
|
141
149
|
|
142
150
|
it 'returns an array with the matching secondary' do
|
143
|
-
expect(
|
151
|
+
expect(selector.send(:select, candidates)).to eq([matching_secondary])
|
144
152
|
end
|
145
153
|
end
|
146
154
|
|
@@ -149,7 +157,7 @@ describe Mongo::ServerSelector::Nearest do
|
|
149
157
|
let(:expected) { [matching_secondary, matching_secondary] }
|
150
158
|
|
151
159
|
it 'returns an array with the matching secondaries' do
|
152
|
-
expect(
|
160
|
+
expect(selector.send(:select, candidates)).to eq(expected)
|
153
161
|
end
|
154
162
|
end
|
155
163
|
|
@@ -158,7 +166,7 @@ describe Mongo::ServerSelector::Nearest do
|
|
158
166
|
let(:expected) { [matching_primary, matching_secondary] }
|
159
167
|
|
160
168
|
it 'returns an array with the matching primary and secondary' do
|
161
|
-
expect(
|
169
|
+
expect(selector.send(:select, candidates)).to match_array(expected)
|
162
170
|
end
|
163
171
|
end
|
164
172
|
end
|
@@ -174,7 +182,7 @@ describe Mongo::ServerSelector::Nearest do
|
|
174
182
|
let(:candidates) { [far_primary] }
|
175
183
|
|
176
184
|
it 'returns array with far primary' do
|
177
|
-
expect(
|
185
|
+
expect(selector.send(:select, candidates)).to eq([far_primary])
|
178
186
|
end
|
179
187
|
end
|
180
188
|
|
@@ -182,7 +190,7 @@ describe Mongo::ServerSelector::Nearest do
|
|
182
190
|
let(:candidates) { [far_secondary] }
|
183
191
|
|
184
192
|
it 'returns array with far primary' do
|
185
|
-
expect(
|
193
|
+
expect(selector.send(:select, candidates)).to eq([far_secondary])
|
186
194
|
end
|
187
195
|
end
|
188
196
|
end
|
@@ -193,7 +201,7 @@ describe Mongo::ServerSelector::Nearest do
|
|
193
201
|
let(:candidates) { [primary, secondary] }
|
194
202
|
|
195
203
|
it 'returns array with primary and secondary' do
|
196
|
-
expect(
|
204
|
+
expect(selector.send(:select, candidates)).to match_array(
|
197
205
|
[primary, secondary]
|
198
206
|
)
|
199
207
|
end
|
@@ -203,7 +211,7 @@ describe Mongo::ServerSelector::Nearest do
|
|
203
211
|
let(:candidates) { [primary, far_secondary] }
|
204
212
|
|
205
213
|
it 'returns array with local primary' do
|
206
|
-
expect(
|
214
|
+
expect(selector.send(:select, candidates)).to eq([primary])
|
207
215
|
end
|
208
216
|
end
|
209
217
|
|
@@ -211,7 +219,7 @@ describe Mongo::ServerSelector::Nearest do
|
|
211
219
|
let(:candidates) { [far_primary, secondary] }
|
212
220
|
|
213
221
|
it 'returns array with local secondary' do
|
214
|
-
expect(
|
222
|
+
expect(selector.send(:select, candidates)).to eq([secondary])
|
215
223
|
end
|
216
224
|
end
|
217
225
|
|
@@ -220,7 +228,7 @@ describe Mongo::ServerSelector::Nearest do
|
|
220
228
|
let(:expected) { [far_primary, far_secondary] }
|
221
229
|
|
222
230
|
it 'returns array with both servers' do
|
223
|
-
expect(
|
231
|
+
expect(selector.send(:select, candidates)).to match_array(expected)
|
224
232
|
end
|
225
233
|
end
|
226
234
|
|
@@ -231,7 +239,7 @@ describe Mongo::ServerSelector::Nearest do
|
|
231
239
|
let(:expected) { [primary, secondary] }
|
232
240
|
|
233
241
|
it 'returns array with local primary and local secondary' do
|
234
|
-
expect(
|
242
|
+
expect(selector.send(:select, candidates)).to match_array(expected)
|
235
243
|
end
|
236
244
|
end
|
237
245
|
|
@@ -240,7 +248,7 @@ describe Mongo::ServerSelector::Nearest do
|
|
240
248
|
let(:expected) { [secondary, secondary] }
|
241
249
|
|
242
250
|
it 'returns array with the two local secondaries' do
|
243
|
-
expect(
|
251
|
+
expect(selector.send(:select, candidates)).to match_array(expected)
|
244
252
|
end
|
245
253
|
end
|
246
254
|
end
|
@@ -2,21 +2,23 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
describe Mongo::ServerSelector::PrimaryPreferred do
|
4
4
|
|
5
|
+
let(:name) { :primary_preferred }
|
6
|
+
|
5
7
|
include_context 'server selector'
|
6
8
|
|
7
|
-
it_behaves_like 'a
|
8
|
-
let(:name) { :primary_preferred }
|
9
|
+
it_behaves_like 'a server selector mode' do
|
9
10
|
let(:slave_ok) { true }
|
10
11
|
end
|
11
12
|
|
12
|
-
it_behaves_like 'a
|
13
|
+
it_behaves_like 'a server selector accepting tag sets'
|
14
|
+
it_behaves_like 'a server selector with sensitive data in its options'
|
13
15
|
|
14
16
|
describe '#to_mongos' do
|
15
17
|
|
16
18
|
context 'tag sets not provided' do
|
17
19
|
|
18
20
|
it 'returns a read preference formatted for mongos' do
|
19
|
-
expect(
|
21
|
+
expect(selector.to_mongos).to eq({ :mode => 'primaryPreferred' })
|
20
22
|
end
|
21
23
|
end
|
22
24
|
|
@@ -24,7 +26,7 @@ describe Mongo::ServerSelector::PrimaryPreferred do
|
|
24
26
|
let(:tag_sets) { [tag_set] }
|
25
27
|
|
26
28
|
it 'returns a read preference formatted for mongos' do
|
27
|
-
expect(
|
29
|
+
expect(selector.to_mongos).to eq(
|
28
30
|
{ :mode => 'primaryPreferred', :tags => tag_sets}
|
29
31
|
)
|
30
32
|
end
|
@@ -37,7 +39,7 @@ describe Mongo::ServerSelector::PrimaryPreferred do
|
|
37
39
|
let(:candidates) { [] }
|
38
40
|
|
39
41
|
it 'returns an empty array' do
|
40
|
-
expect(
|
42
|
+
expect(selector.send(:select, candidates)).to be_empty
|
41
43
|
end
|
42
44
|
end
|
43
45
|
|
@@ -45,7 +47,7 @@ describe Mongo::ServerSelector::PrimaryPreferred do
|
|
45
47
|
let(:candidates) { [primary] }
|
46
48
|
|
47
49
|
it 'returns an array with the primary' do
|
48
|
-
expect(
|
50
|
+
expect(selector.send(:select, candidates)).to eq( [primary] )
|
49
51
|
end
|
50
52
|
end
|
51
53
|
|
@@ -53,7 +55,7 @@ describe Mongo::ServerSelector::PrimaryPreferred do
|
|
53
55
|
let(:candidates) { [secondary] }
|
54
56
|
|
55
57
|
it 'returns an array with the secondary' do
|
56
|
-
expect(
|
58
|
+
expect(selector.send(:select, candidates)).to eq( [secondary] )
|
57
59
|
end
|
58
60
|
end
|
59
61
|
|
@@ -62,7 +64,7 @@ describe Mongo::ServerSelector::PrimaryPreferred do
|
|
62
64
|
let(:expected) { [primary] }
|
63
65
|
|
64
66
|
it 'returns an array with the primary' do
|
65
|
-
expect(
|
67
|
+
expect(selector.send(:select, candidates)).to eq(expected)
|
66
68
|
end
|
67
69
|
end
|
68
70
|
|
@@ -71,7 +73,7 @@ describe Mongo::ServerSelector::PrimaryPreferred do
|
|
71
73
|
let(:expected) { [primary] }
|
72
74
|
|
73
75
|
it 'returns an array with the primary' do
|
74
|
-
expect(
|
76
|
+
expect(selector.send(:select, candidates)).to eq(expected)
|
75
77
|
end
|
76
78
|
end
|
77
79
|
|
@@ -92,7 +94,7 @@ describe Mongo::ServerSelector::PrimaryPreferred do
|
|
92
94
|
let(:candidates) { [primary] }
|
93
95
|
|
94
96
|
it 'returns array with primary' do
|
95
|
-
expect(
|
97
|
+
expect(selector.send(:select, candidates)).to eq([primary])
|
96
98
|
end
|
97
99
|
end
|
98
100
|
|
@@ -100,7 +102,7 @@ describe Mongo::ServerSelector::PrimaryPreferred do
|
|
100
102
|
let(:candidates) { [matching_primary] }
|
101
103
|
|
102
104
|
it 'returns array with matching primary' do
|
103
|
-
expect(
|
105
|
+
expect(selector.send(:select, candidates)).to eq([matching_primary])
|
104
106
|
end
|
105
107
|
end
|
106
108
|
|
@@ -108,7 +110,7 @@ describe Mongo::ServerSelector::PrimaryPreferred do
|
|
108
110
|
let(:candidates) { [matching_secondary] }
|
109
111
|
|
110
112
|
it 'returns array with matching secondary' do
|
111
|
-
expect(
|
113
|
+
expect(selector.send(:select, candidates)).to eq([matching_secondary])
|
112
114
|
end
|
113
115
|
end
|
114
116
|
|
@@ -116,7 +118,7 @@ describe Mongo::ServerSelector::PrimaryPreferred do
|
|
116
118
|
let(:candidates) { [secondary] }
|
117
119
|
|
118
120
|
it 'returns an empty array' do
|
119
|
-
expect(
|
121
|
+
expect(selector.send(:select, candidates)).to be_empty
|
120
122
|
end
|
121
123
|
end
|
122
124
|
end
|
@@ -127,7 +129,7 @@ describe Mongo::ServerSelector::PrimaryPreferred do
|
|
127
129
|
let(:candidates) { [primary, secondary, secondary] }
|
128
130
|
|
129
131
|
it 'returns an array with the primary' do
|
130
|
-
expect(
|
132
|
+
expect(selector.send(:select, candidates)).to eq([primary])
|
131
133
|
end
|
132
134
|
end
|
133
135
|
|
@@ -135,7 +137,7 @@ describe Mongo::ServerSelector::PrimaryPreferred do
|
|
135
137
|
let(:candidates) { [matching_primary, secondary, secondary] }
|
136
138
|
|
137
139
|
it 'returns an array of the primary' do
|
138
|
-
expect(
|
140
|
+
expect(selector.send(:select, candidates)).to eq([matching_primary])
|
139
141
|
end
|
140
142
|
end
|
141
143
|
|
@@ -144,7 +146,7 @@ describe Mongo::ServerSelector::PrimaryPreferred do
|
|
144
146
|
let(:expected) { [primary] }
|
145
147
|
|
146
148
|
it 'returns an array of the primary' do
|
147
|
-
expect(
|
149
|
+
expect(selector.send(:select, candidates)).to eq(expected)
|
148
150
|
end
|
149
151
|
end
|
150
152
|
|
@@ -153,7 +155,7 @@ describe Mongo::ServerSelector::PrimaryPreferred do
|
|
153
155
|
let(:expected) { [primary] }
|
154
156
|
|
155
157
|
it 'returns an array of the primary ' do
|
156
|
-
expect(
|
158
|
+
expect(selector.send(:select, candidates)).to eq(expected)
|
157
159
|
end
|
158
160
|
end
|
159
161
|
|
@@ -162,7 +164,7 @@ describe Mongo::ServerSelector::PrimaryPreferred do
|
|
162
164
|
let(:expected) { [primary] }
|
163
165
|
|
164
166
|
it 'returns an array of the primary' do
|
165
|
-
expect(
|
167
|
+
expect(selector.send(:select, candidates)).to eq(expected)
|
166
168
|
end
|
167
169
|
end
|
168
170
|
end
|
@@ -178,7 +180,7 @@ describe Mongo::ServerSelector::PrimaryPreferred do
|
|
178
180
|
let(:candidates) { [far_primary] }
|
179
181
|
|
180
182
|
it 'returns array with far primary' do
|
181
|
-
expect(
|
183
|
+
expect(selector.send(:select, candidates)).to eq([far_primary])
|
182
184
|
end
|
183
185
|
end
|
184
186
|
|
@@ -186,7 +188,7 @@ describe Mongo::ServerSelector::PrimaryPreferred do
|
|
186
188
|
let(:candidates) { [far_secondary] }
|
187
189
|
|
188
190
|
it 'returns array with far primary' do
|
189
|
-
expect(
|
191
|
+
expect(selector.send(:select, candidates)).to eq([far_secondary])
|
190
192
|
end
|
191
193
|
|
192
194
|
end
|
@@ -201,7 +203,7 @@ describe Mongo::ServerSelector::PrimaryPreferred do
|
|
201
203
|
let(:expected) { [primary] }
|
202
204
|
|
203
205
|
it 'returns an array of the primary' do
|
204
|
-
expect(
|
206
|
+
expect(selector.send(:select, candidates)).to eq(expected)
|
205
207
|
end
|
206
208
|
end
|
207
209
|
|
@@ -210,7 +212,7 @@ describe Mongo::ServerSelector::PrimaryPreferred do
|
|
210
212
|
let(:expected) { [primary] }
|
211
213
|
|
212
214
|
it 'returns an array of the primary' do
|
213
|
-
expect(
|
215
|
+
expect(selector.send(:select, candidates)).to eq(expected)
|
214
216
|
end
|
215
217
|
end
|
216
218
|
|
@@ -219,7 +221,7 @@ describe Mongo::ServerSelector::PrimaryPreferred do
|
|
219
221
|
let(:expected) { [far_primary] }
|
220
222
|
|
221
223
|
it 'returns an array of the far primary' do
|
222
|
-
expect(
|
224
|
+
expect(selector.send(:select, candidates)).to eq(expected)
|
223
225
|
end
|
224
226
|
end
|
225
227
|
|
@@ -228,7 +230,7 @@ describe Mongo::ServerSelector::PrimaryPreferred do
|
|
228
230
|
let(:expected) { [far_primary] }
|
229
231
|
|
230
232
|
it 'returns an array of the far primary' do
|
231
|
-
expect(
|
233
|
+
expect(selector.send(:select, candidates)).to eq(expected)
|
232
234
|
end
|
233
235
|
end
|
234
236
|
|
@@ -239,7 +241,7 @@ describe Mongo::ServerSelector::PrimaryPreferred do
|
|
239
241
|
let(:expected) { [primary] }
|
240
242
|
|
241
243
|
it 'returns an array of the primary' do
|
242
|
-
expect(
|
244
|
+
expect(selector.send(:select, candidates)).to eq(expected)
|
243
245
|
end
|
244
246
|
end
|
245
247
|
|
@@ -248,7 +250,7 @@ describe Mongo::ServerSelector::PrimaryPreferred do
|
|
248
250
|
let(:expected) { [far_primary] }
|
249
251
|
|
250
252
|
it 'returns an array with primary' do
|
251
|
-
expect(
|
253
|
+
expect(selector.send(:select, candidates)).to eq(expected)
|
252
254
|
end
|
253
255
|
end
|
254
256
|
end
|
@@ -261,7 +263,7 @@ describe Mongo::ServerSelector::PrimaryPreferred do
|
|
261
263
|
let(:expected) { [secondary] }
|
262
264
|
|
263
265
|
it 'returns an array with the secondary' do
|
264
|
-
expect(
|
266
|
+
expect(selector.send(:select, candidates)).to eq(expected)
|
265
267
|
end
|
266
268
|
end
|
267
269
|
|
@@ -270,7 +272,7 @@ describe Mongo::ServerSelector::PrimaryPreferred do
|
|
270
272
|
let(:expected) { [secondary] }
|
271
273
|
|
272
274
|
it 'returns an array of the secondary' do
|
273
|
-
expect(
|
275
|
+
expect(selector.send(:select, candidates)).to eq(expected)
|
274
276
|
end
|
275
277
|
end
|
276
278
|
|
@@ -279,7 +281,7 @@ describe Mongo::ServerSelector::PrimaryPreferred do
|
|
279
281
|
let(:expected) { [secondary, secondary] }
|
280
282
|
|
281
283
|
it 'returns an array of the secondary' do
|
282
|
-
expect(
|
284
|
+
expect(selector.send(:select, candidates)).to eq(expected)
|
283
285
|
end
|
284
286
|
end
|
285
287
|
end
|