mongo 2.8.0 → 2.9.0.rc0
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.tar.gz.sig +0 -0
- data/Rakefile +12 -0
- data/lib/mongo.rb +15 -1
- data/lib/mongo/address/ipv6.rb +0 -2
- data/lib/mongo/auth/scram/conversation.rb +0 -3
- data/lib/mongo/bulk_write/result_combiner.rb +12 -2
- data/lib/mongo/client.rb +59 -6
- data/lib/mongo/cluster.rb +19 -8
- data/lib/mongo/cluster/reapers/cursor_reaper.rb +0 -2
- data/lib/mongo/cluster/reapers/socket_reaper.rb +12 -9
- data/lib/mongo/collection.rb +1 -1
- data/lib/mongo/collection/view/aggregation.rb +5 -1
- data/lib/mongo/collection/view/builder/map_reduce.rb +1 -1
- data/lib/mongo/collection/view/change_stream.rb +30 -10
- data/lib/mongo/collection/view/iterable.rb +13 -6
- data/lib/mongo/collection/view/map_reduce.rb +12 -10
- data/lib/mongo/collection/view/readable.rb +19 -14
- data/lib/mongo/cursor.rb +12 -8
- data/lib/mongo/database.rb +10 -7
- data/lib/mongo/database/view.rb +18 -11
- data/lib/mongo/error.rb +2 -2
- data/lib/mongo/error/connection_check_out_timeout.rb +49 -0
- data/lib/mongo/error/operation_failure.rb +9 -9
- data/lib/mongo/error/parser.rb +25 -3
- data/lib/mongo/error/pool_closed_error.rb +43 -0
- data/lib/mongo/error/sdam_error_detection.rb +18 -0
- data/lib/mongo/grid/file/chunk.rb +0 -2
- data/lib/mongo/grid/fs_bucket.rb +26 -12
- data/lib/mongo/grid/stream/read.rb +36 -21
- data/lib/mongo/index/view.rb +11 -7
- data/lib/mongo/logger.rb +0 -2
- data/lib/mongo/monitoring.rb +31 -0
- data/lib/mongo/monitoring/cmap_log_subscriber.rb +53 -0
- data/lib/mongo/monitoring/event.rb +1 -0
- data/lib/mongo/monitoring/event/cmap.rb +25 -0
- data/lib/mongo/monitoring/event/cmap/base.rb +28 -0
- data/lib/mongo/monitoring/event/cmap/connection_check_out_failed.rb +78 -0
- data/lib/mongo/monitoring/event/cmap/connection_check_out_started.rb +56 -0
- data/lib/mongo/monitoring/event/cmap/connection_checked_in.rb +63 -0
- data/lib/mongo/monitoring/event/cmap/connection_checked_out.rb +64 -0
- data/lib/mongo/monitoring/event/cmap/connection_closed.rb +103 -0
- data/lib/mongo/monitoring/event/cmap/connection_created.rb +64 -0
- data/lib/mongo/monitoring/event/cmap/connection_ready.rb +64 -0
- data/lib/mongo/monitoring/event/cmap/pool_cleared.rb +57 -0
- data/lib/mongo/monitoring/event/cmap/pool_closed.rb +57 -0
- data/lib/mongo/monitoring/event/cmap/pool_created.rb +63 -0
- data/lib/mongo/monitoring/event/command_started.rb +12 -3
- data/lib/mongo/monitoring/publishable.rb +10 -2
- data/lib/mongo/operation.rb +0 -1
- data/lib/mongo/operation/find/legacy/result.rb +1 -0
- data/lib/mongo/operation/list_collections/result.rb +7 -1
- data/lib/mongo/operation/result.rb +10 -1
- data/lib/mongo/operation/shared/executable.rb +15 -0
- data/lib/mongo/operation/shared/result/use_legacy_error_parser.rb +29 -0
- data/lib/mongo/operation/shared/specifiable.rb +0 -16
- data/lib/mongo/operation/update/legacy/result.rb +1 -0
- data/lib/mongo/protocol/compressed.rb +0 -2
- data/lib/mongo/protocol/msg.rb +25 -2
- data/lib/mongo/retryable.rb +171 -33
- data/lib/mongo/server.rb +26 -7
- data/lib/mongo/server/app_metadata.rb +0 -2
- data/lib/mongo/server/connectable.rb +8 -2
- data/lib/mongo/server/connection.rb +83 -13
- data/lib/mongo/server/connection_base.rb +1 -1
- data/lib/mongo/server/connection_pool.rb +439 -43
- data/lib/mongo/server/monitor/connection.rb +4 -1
- data/lib/mongo/session.rb +37 -5
- data/lib/mongo/session/session_pool.rb +2 -2
- data/lib/mongo/socket.rb +0 -2
- data/lib/mongo/socket/ssl.rb +0 -2
- data/lib/mongo/uri.rb +127 -66
- data/lib/mongo/uri/srv_protocol.rb +35 -13
- data/lib/mongo/version.rb +1 -1
- data/spec/README.md +190 -63
- data/spec/integration/change_stream_spec.rb +64 -0
- data/spec/integration/command_spec.rb +0 -7
- data/spec/integration/error_detection_spec.rb +39 -0
- data/spec/integration/read_concern.rb +83 -0
- data/spec/integration/retryable_writes_spec.rb +6 -50
- data/spec/integration/sdam_error_handling_spec.rb +60 -7
- data/spec/integration/ssl_uri_options_spec.rb +24 -0
- data/spec/integration/step_down_spec.rb +197 -0
- data/spec/lite_spec_helper.rb +4 -0
- data/spec/mongo/client_construction_spec.rb +42 -17
- data/spec/mongo/client_spec.rb +32 -1
- data/spec/mongo/cluster/socket_reaper_spec.rb +2 -2
- data/spec/mongo/cluster_spec.rb +36 -2
- data/spec/mongo/collection/view/aggregation_spec.rb +2 -0
- data/spec/mongo/collection/view/change_stream_spec.rb +28 -28
- data/spec/mongo/collection/view/readable_spec.rb +1 -1
- data/spec/mongo/collection/view_spec.rb +3 -1
- data/spec/mongo/cursor_spec.rb +5 -5
- data/spec/mongo/error/parser_spec.rb +61 -1
- data/spec/mongo/grid/stream/read_spec.rb +2 -2
- data/spec/mongo/monitoring/event/cmap/connection_check_out_failed_spec.rb +23 -0
- data/spec/mongo/monitoring/event/cmap/connection_check_out_started_spec.rb +19 -0
- data/spec/mongo/monitoring/event/cmap/connection_checked_in_spec.rb +23 -0
- data/spec/mongo/monitoring/event/cmap/connection_checked_out_spec.rb +23 -0
- data/spec/mongo/monitoring/event/cmap/connection_closed_spec.rb +27 -0
- data/spec/mongo/monitoring/event/cmap/connection_created_spec.rb +24 -0
- data/spec/mongo/monitoring/event/cmap/connection_ready_spec.rb +24 -0
- data/spec/mongo/monitoring/event/cmap/pool_cleared_spec.rb +19 -0
- data/spec/mongo/monitoring/event/cmap/pool_closed_spec.rb +19 -0
- data/spec/mongo/monitoring/event/cmap/pool_created_spec.rb +26 -0
- data/spec/mongo/operation/delete/bulk_spec.rb +1 -6
- data/spec/mongo/operation/delete/command_spec.rb +1 -1
- data/spec/mongo/operation/delete/op_msg_spec.rb +1 -1
- data/spec/mongo/operation/delete_spec.rb +4 -4
- data/spec/mongo/operation/insert/bulk_spec.rb +1 -1
- data/spec/mongo/operation/insert/command_spec.rb +1 -1
- data/spec/mongo/operation/insert/op_msg_spec.rb +1 -1
- data/spec/mongo/operation/update/bulk_spec.rb +1 -1
- data/spec/mongo/operation/update/command_spec.rb +2 -2
- data/spec/mongo/operation/update/op_msg_spec.rb +2 -2
- data/spec/mongo/protocol/msg_spec.rb +11 -0
- data/spec/mongo/retryable_spec.rb +78 -25
- data/spec/mongo/server/connection_pool_spec.rb +661 -126
- data/spec/mongo/server/connection_spec.rb +55 -7
- data/spec/mongo/server_spec.rb +5 -0
- data/spec/mongo/uri/srv_protocol_spec.rb +135 -2
- data/spec/mongo/uri_option_parsing_spec.rb +511 -0
- data/spec/mongo/uri_spec.rb +42 -6
- data/spec/spec_helper.rb +1 -84
- data/spec/spec_tests/cmap_spec.rb +50 -0
- data/spec/spec_tests/command_monitoring_spec.rb +7 -18
- data/spec/spec_tests/crud_spec.rb +3 -49
- data/spec/spec_tests/data/cmap/connection-must-have-id.yml +21 -0
- data/spec/spec_tests/data/cmap/connection-must-order-ids.yml +21 -0
- data/spec/spec_tests/data/cmap/pool-checkin-destroy-closed.yml +24 -0
- data/spec/spec_tests/data/cmap/pool-checkin-destroy-stale.yml +24 -0
- data/spec/spec_tests/data/cmap/pool-checkin-make-available.yml +21 -0
- data/spec/spec_tests/data/cmap/pool-checkin.yml +18 -0
- data/spec/spec_tests/data/cmap/pool-checkout-connection.yml +13 -0
- data/spec/spec_tests/data/cmap/pool-checkout-error-closed.yml +28 -0
- data/spec/spec_tests/data/cmap/pool-checkout-multiple.yml +34 -0
- data/spec/spec_tests/data/cmap/pool-checkout-no-idle.yml +31 -0
- data/spec/spec_tests/data/cmap/pool-checkout-no-stale.yml +29 -0
- data/spec/spec_tests/data/cmap/pool-close-destroy-conns.yml +26 -0
- data/spec/spec_tests/data/cmap/pool-close.yml +11 -0
- data/spec/spec_tests/data/cmap/pool-create-max-size.yml +56 -0
- data/spec/spec_tests/data/cmap/pool-create-min-size.yml +27 -0
- data/spec/spec_tests/data/cmap/pool-create-with-options.yml +20 -0
- data/spec/spec_tests/data/cmap/pool-create.yml +12 -0
- data/spec/spec_tests/data/cmap/wait-queue-fairness.yml +94 -0
- data/spec/spec_tests/data/cmap/wait-queue-timeout.yml +41 -0
- data/spec/spec_tests/data/retryable_reads/aggregate-serverErrors.yml +157 -0
- data/spec/spec_tests/data/retryable_reads/aggregate.yml +87 -0
- data/spec/spec_tests/data/retryable_reads/changeStreams-client.watch-serverErrors.yml +149 -0
- data/spec/spec_tests/data/retryable_reads/changeStreams-client.watch.yml +61 -0
- data/spec/spec_tests/data/retryable_reads/changeStreams-db.coll.watch-serverErrors.yml +149 -0
- data/spec/spec_tests/data/retryable_reads/changeStreams-db.coll.watch.yml +65 -0
- data/spec/spec_tests/data/retryable_reads/changeStreams-db.watch-serverErrors.yml +153 -0
- data/spec/spec_tests/data/retryable_reads/changeStreams-db.watch.yml +61 -0
- data/spec/spec_tests/data/retryable_reads/count-serverErrors.yml +150 -0
- data/spec/spec_tests/data/retryable_reads/count.yml +64 -0
- data/spec/spec_tests/data/retryable_reads/countDocuments-serverErrors.yml +150 -0
- data/spec/spec_tests/data/retryable_reads/countDocuments.yml +64 -0
- data/spec/spec_tests/data/retryable_reads/distinct-serverErrors.yml +156 -0
- data/spec/spec_tests/data/retryable_reads/distinct.yml +71 -0
- data/spec/spec_tests/data/retryable_reads/estimatedDocumentCount-serverErrors.yml +148 -0
- data/spec/spec_tests/data/retryable_reads/estimatedDocumentCount.yml +62 -0
- data/spec/spec_tests/data/retryable_reads/find-serverErrors.yml +160 -0
- data/spec/spec_tests/data/retryable_reads/find.yml +86 -0
- data/spec/spec_tests/data/retryable_reads/findOne-serverErrors.yml +154 -0
- data/spec/spec_tests/data/retryable_reads/findOne.yml +68 -0
- data/spec/spec_tests/data/retryable_reads/gridfs-download-serverErrors.yml +173 -0
- data/spec/spec_tests/data/retryable_reads/gridfs-download.yml +79 -0
- data/spec/spec_tests/data/retryable_reads/gridfs-downloadByName-serverErrors.yml +174 -0
- data/spec/spec_tests/data/retryable_reads/gridfs-downloadByName.yml +79 -0
- data/spec/spec_tests/data/retryable_reads/listCollectionNames-serverErrors.yml +143 -0
- data/spec/spec_tests/data/retryable_reads/listCollectionNames.yml +59 -0
- data/spec/spec_tests/data/retryable_reads/listCollectionObjects-serverErrors.yml +144 -0
- data/spec/spec_tests/data/retryable_reads/listCollectionObjects.yml +59 -0
- data/spec/spec_tests/data/retryable_reads/listCollections-serverErrors.yml +143 -0
- data/spec/spec_tests/data/retryable_reads/listCollections.yml +59 -0
- data/spec/spec_tests/data/retryable_reads/listDatabaseNames-serverErrors.yml +143 -0
- data/spec/spec_tests/data/retryable_reads/listDatabaseNames.yml +59 -0
- data/spec/spec_tests/data/retryable_reads/listDatabaseObjects-serverErrors.yml +144 -0
- data/spec/spec_tests/data/retryable_reads/listDatabaseObjects.yml +59 -0
- data/spec/spec_tests/data/retryable_reads/listDatabases-serverErrors.yml +144 -0
- data/spec/spec_tests/data/retryable_reads/listDatabases.yml +59 -0
- data/spec/spec_tests/data/retryable_reads/listIndexNames-serverErrors.yml +144 -0
- data/spec/spec_tests/data/retryable_reads/listIndexNames.yml +60 -0
- data/spec/spec_tests/data/retryable_reads/listIndexes-serverErrors.yml +145 -0
- data/spec/spec_tests/data/retryable_reads/listIndexes.yml +60 -0
- data/spec/spec_tests/data/retryable_reads/mapReduce.yml +60 -0
- data/spec/spec_tests/data/retryable_writes/bulkWrite-serverErrors.yml +10 -7
- data/spec/spec_tests/data/retryable_writes/bulkWrite.yml +15 -22
- data/spec/spec_tests/data/retryable_writes/deleteMany.yml +22 -0
- data/spec/spec_tests/data/retryable_writes/deleteOne-serverErrors.yml +8 -7
- data/spec/spec_tests/data/retryable_writes/deleteOne.yml +5 -8
- data/spec/spec_tests/data/retryable_writes/findOneAndDelete-serverErrors.yml +8 -7
- data/spec/spec_tests/data/retryable_writes/findOneAndDelete.yml +5 -8
- data/spec/spec_tests/data/retryable_writes/findOneAndReplace-serverErrors.yml +8 -7
- data/spec/spec_tests/data/retryable_writes/findOneAndReplace.yml +5 -8
- data/spec/spec_tests/data/retryable_writes/findOneAndUpdate-serverErrors.yml +8 -7
- data/spec/spec_tests/data/retryable_writes/findOneAndUpdate.yml +5 -8
- data/spec/spec_tests/data/retryable_writes/insertMany-serverErrors.yml +8 -7
- data/spec/spec_tests/data/retryable_writes/insertMany.yml +5 -8
- data/spec/spec_tests/data/retryable_writes/insertOne-serverErrors.yml +10 -45
- data/spec/spec_tests/data/retryable_writes/insertOne.yml +5 -8
- data/spec/spec_tests/data/retryable_writes/replaceOne-serverErrors.yml +8 -7
- data/spec/spec_tests/data/retryable_writes/replaceOne.yml +5 -8
- data/spec/spec_tests/data/retryable_writes/updateMany.yml +27 -0
- data/spec/spec_tests/data/retryable_writes/updateOne-serverErrors.yml +8 -7
- data/spec/spec_tests/data/retryable_writes/updateOne.yml +5 -14
- data/spec/spec_tests/data/transactions/abort.yml +7 -2
- data/spec/spec_tests/data/transactions/bulk.yml +7 -2
- data/spec/spec_tests/data/transactions/causal-consistency.yml +11 -4
- data/spec/spec_tests/data/transactions/commit.yml +11 -4
- data/spec/spec_tests/data/transactions/count.yml +64 -0
- data/spec/spec_tests/data/transactions/delete.yml +7 -2
- data/spec/spec_tests/data/transactions/error-labels.yml +8 -2
- data/spec/spec_tests/data/transactions/errors.yml +7 -2
- data/spec/spec_tests/data/transactions/findOneAndDelete.yml +7 -2
- data/spec/spec_tests/data/transactions/findOneAndReplace.yml +7 -2
- data/spec/spec_tests/data/transactions/findOneAndUpdate.yml +7 -2
- data/spec/spec_tests/data/transactions/insert.yml +9 -2
- data/spec/spec_tests/data/transactions/isolation.yml +7 -2
- data/spec/spec_tests/data/transactions/read-concern.yml +15 -6
- data/spec/spec_tests/data/transactions/read-pref.yml +7 -2
- data/spec/spec_tests/data/transactions/reads.yml +8 -48
- data/spec/spec_tests/data/transactions/retryable-abort.yml +7 -2
- data/spec/spec_tests/data/transactions/retryable-commit.yml +7 -2
- data/spec/spec_tests/data/transactions/retryable-writes.yml +7 -2
- data/spec/spec_tests/data/transactions/run-command.yml +7 -2
- data/spec/spec_tests/data/transactions/transaction-options.yml +7 -2
- data/spec/spec_tests/data/transactions/update.yml +7 -2
- data/spec/spec_tests/data/transactions/write-concern.yml +7 -2
- data/spec/spec_tests/data/transactions_api/callback-aborts.yml +6 -1
- data/spec/spec_tests/data/transactions_api/callback-commits.yml +6 -1
- data/spec/spec_tests/data/transactions_api/callback-retry.yml +6 -1
- data/spec/spec_tests/data/transactions_api/commit-retry.yml +6 -1
- data/spec/spec_tests/data/transactions_api/commit-transienttransactionerror-4.2.yml +6 -3
- data/spec/spec_tests/data/transactions_api/commit-transienttransactionerror.yml +6 -1
- data/spec/spec_tests/data/transactions_api/commit-writeconcernerror.yml +6 -1
- data/spec/spec_tests/data/transactions_api/commit.yml +6 -1
- data/spec/spec_tests/data/transactions_api/transaction-options.yml +6 -1
- data/spec/spec_tests/retryable_reads_spec.rb +11 -0
- data/spec/spec_tests/retryable_writes_spec.rb +4 -69
- data/spec/spec_tests/transactions_api_spec.rb +42 -37
- data/spec/spec_tests/transactions_spec.rb +42 -33
- data/spec/support/authorization.rb +12 -0
- data/spec/support/change_streams/operation.rb +1 -1
- data/spec/support/client_registry.rb +20 -0
- data/spec/support/cluster_config.rb +16 -15
- data/spec/support/cluster_tools.rb +346 -0
- data/spec/support/cmap.rb +367 -0
- data/spec/support/cmap/verifier.rb +46 -0
- data/spec/support/command_monitoring.rb +4 -6
- data/spec/support/common_shortcuts.rb +6 -0
- data/spec/support/connection_string.rb +2 -2
- data/spec/support/crud.rb +171 -184
- data/spec/support/crud/operation.rb +43 -0
- data/spec/support/crud/outcome.rb +53 -0
- data/spec/support/crud/read.rb +102 -12
- data/spec/support/crud/requirement.rb +69 -0
- data/spec/support/crud/spec.rb +68 -0
- data/spec/support/crud/test.rb +141 -0
- data/spec/support/crud/verifier.rb +96 -18
- data/spec/support/crud/write.rb +18 -3
- data/spec/support/event_subscriber.rb +15 -0
- data/spec/support/primary_socket.rb +2 -2
- data/spec/support/spec_config.rb +89 -20
- data/spec/support/transactions.rb +2 -306
- data/spec/support/transactions/operation.rb +7 -7
- data/spec/support/transactions/spec.rb +28 -0
- data/spec/support/transactions/test.rb +191 -0
- data/spec/support/utils.rb +123 -0
- metadata +202 -9
- metadata.gz.sig +0 -0
- data/lib/mongo/server/connection_pool/queue.rb +0 -359
- data/spec/mongo/server/connection_pool/queue_spec.rb +0 -353
- data/spec/support/transactions/verifier.rb +0 -97
@@ -155,18 +155,42 @@ describe Mongo::Client do
|
|
155
155
|
|
156
156
|
context 'when providing options' do
|
157
157
|
|
158
|
-
context '
|
158
|
+
context 'retry_writes option' do
|
159
|
+
let(:client) do
|
160
|
+
new_local_client_nmio(SpecConfig.instance.addresses, options)
|
161
|
+
end
|
159
162
|
|
160
|
-
|
161
|
-
|
163
|
+
context 'when retry_writes is true' do
|
164
|
+
|
165
|
+
let(:options) do
|
166
|
+
{ retry_writes: true }
|
167
|
+
end
|
168
|
+
|
169
|
+
it 'sets retry_writes to true' do
|
170
|
+
expect(client.options['retry_writes']).to be true
|
171
|
+
end
|
162
172
|
end
|
163
173
|
|
164
|
-
|
165
|
-
|
174
|
+
context 'when retry_writes is false' do
|
175
|
+
|
176
|
+
let(:options) do
|
177
|
+
{ retry_writes: false }
|
178
|
+
end
|
179
|
+
|
180
|
+
it 'sets retry_writes to false' do
|
181
|
+
expect(client.options['retry_writes']).to be false
|
182
|
+
end
|
166
183
|
end
|
167
184
|
|
168
|
-
|
169
|
-
|
185
|
+
context 'when retry_writes is not given' do
|
186
|
+
|
187
|
+
let(:options) do
|
188
|
+
{ }
|
189
|
+
end
|
190
|
+
|
191
|
+
it 'sets retry_writes to true' do
|
192
|
+
expect(client.options['retry_writes']).to be true
|
193
|
+
end
|
170
194
|
end
|
171
195
|
end
|
172
196
|
|
@@ -501,7 +525,7 @@ describe Mongo::Client do
|
|
501
525
|
|
502
526
|
let(:options) do
|
503
527
|
{
|
504
|
-
:min_pool_size => Mongo::Server::ConnectionPool::
|
528
|
+
:min_pool_size => Mongo::Server::ConnectionPool::DEFAULT_MAX_SIZE
|
505
529
|
}
|
506
530
|
end
|
507
531
|
|
@@ -630,7 +654,8 @@ describe Mongo::Client do
|
|
630
654
|
|
631
655
|
let(:expected_options) do
|
632
656
|
Mongo::Options::Redacted.new(:write => { :w => 3 },
|
633
|
-
monitoring_io: false, :database => 'testdb'
|
657
|
+
monitoring_io: false, :database => 'testdb', retry_writes: true,
|
658
|
+
retry_reads: true)
|
634
659
|
end
|
635
660
|
|
636
661
|
it 'sets the options' do
|
@@ -731,7 +756,8 @@ describe Mongo::Client do
|
|
731
756
|
|
732
757
|
let(:expected_options) do
|
733
758
|
Mongo::Options::Redacted.new(:write => { :w => 3 },
|
734
|
-
monitoring_io: false, :database => 'testdb'
|
759
|
+
monitoring_io: false, :database => 'testdb', retry_writes: true,
|
760
|
+
retry_reads: true)
|
735
761
|
end
|
736
762
|
|
737
763
|
it 'sets the options' do
|
@@ -751,7 +777,8 @@ describe Mongo::Client do
|
|
751
777
|
|
752
778
|
let(:expected_options) do
|
753
779
|
Mongo::Options::Redacted.new(:write => { :w => 4 },
|
754
|
-
monitoring_io: false, :database => 'testdb'
|
780
|
+
monitoring_io: false, :database => 'testdb', retry_writes: true,
|
781
|
+
retry_reads: true)
|
755
782
|
end
|
756
783
|
|
757
784
|
it 'allows explicit options to take preference' do
|
@@ -987,16 +1014,14 @@ describe Mongo::Client do
|
|
987
1014
|
|
988
1015
|
let(:new_options) do
|
989
1016
|
Mongo::Options::Redacted.new(:read => { :mode => :primary },
|
990
|
-
|
991
|
-
|
992
|
-
:database => SpecConfig.instance.test_db)
|
1017
|
+
:write => { :w => 1 }, monitoring_io: false,
|
1018
|
+
:database => SpecConfig.instance.test_db, retry_writes: true, retry_reads: true)
|
993
1019
|
end
|
994
1020
|
|
995
1021
|
let(:original_options) do
|
996
1022
|
Mongo::Options::Redacted.new(:read => { :mode => :secondary },
|
997
|
-
|
998
|
-
|
999
|
-
:database => SpecConfig.instance.test_db)
|
1023
|
+
:write => { :w => 1 }, monitoring_io: false,
|
1024
|
+
:database => SpecConfig.instance.test_db, retry_writes: true, retry_reads: true)
|
1000
1025
|
end
|
1001
1026
|
|
1002
1027
|
it 'returns a new client' do
|
data/spec/mongo/client_spec.rb
CHANGED
@@ -193,6 +193,8 @@ describe Mongo::Client do
|
|
193
193
|
)
|
194
194
|
end
|
195
195
|
|
196
|
+
let(:default_options) { Mongo::Options::Redacted.new(retry_writes: true, retry_reads: true) }
|
197
|
+
|
196
198
|
let(:options) do
|
197
199
|
Mongo::Options::Redacted.new(:read => { :mode => :primary },
|
198
200
|
:local_threshold => 0.010,
|
@@ -201,7 +203,7 @@ describe Mongo::Client do
|
|
201
203
|
end
|
202
204
|
|
203
205
|
let(:expected) do
|
204
|
-
[client.cluster, options].hash
|
206
|
+
[client.cluster, default_options.merge(options)].hash
|
205
207
|
end
|
206
208
|
|
207
209
|
it 'returns a hash of the cluster and options' do
|
@@ -494,6 +496,35 @@ describe Mongo::Client do
|
|
494
496
|
end
|
495
497
|
end
|
496
498
|
|
499
|
+
[
|
500
|
+
[:max_read_retries, 1],
|
501
|
+
[:read_retry_interval, 5],
|
502
|
+
[:max_write_retries, 1],
|
503
|
+
].each do |opt, default|
|
504
|
+
describe "##{opt}" do
|
505
|
+
let(:client_options) { {} }
|
506
|
+
|
507
|
+
let(:client) do
|
508
|
+
Mongo::Client.new(['127.0.0.1:27017'], {monitoring_io: false}.update(client_options))
|
509
|
+
end
|
510
|
+
|
511
|
+
it "defaults to #{default}" do
|
512
|
+
expect(default).not_to be nil
|
513
|
+
expect(client.options[opt]).to be nil
|
514
|
+
expect(client.send(opt)).to eq(default)
|
515
|
+
end
|
516
|
+
|
517
|
+
context 'specified on client' do
|
518
|
+
let(:client_options) { {opt => 2} }
|
519
|
+
|
520
|
+
it 'inherits from client' do
|
521
|
+
expect(client.options[opt]).to eq(2)
|
522
|
+
expect(client.send(opt)).to eq(2)
|
523
|
+
end
|
524
|
+
end
|
525
|
+
end
|
526
|
+
end
|
527
|
+
|
497
528
|
describe '#database_names' do
|
498
529
|
|
499
530
|
it 'returns a list of database names' do
|
@@ -21,11 +21,11 @@ describe Mongo::Cluster::SocketReaper do
|
|
21
21
|
|
22
22
|
before do
|
23
23
|
cluster.servers.each do |s|
|
24
|
-
expect(s.pool).to receive(:
|
24
|
+
expect(s.pool).to receive(:close_idle_sockets).and_call_original
|
25
25
|
end
|
26
26
|
end
|
27
27
|
|
28
|
-
it 'calls
|
28
|
+
it 'calls close_idle_sockets on each connection pool in the cluster' do
|
29
29
|
reaper.execute
|
30
30
|
end
|
31
31
|
end
|
data/spec/mongo/cluster_spec.rb
CHANGED
@@ -640,14 +640,48 @@ describe Mongo::Cluster do
|
|
640
640
|
end
|
641
641
|
end
|
642
642
|
|
643
|
+
[
|
644
|
+
[:max_read_retries, 1],
|
645
|
+
[:read_retry_interval, 5],
|
646
|
+
].each do |opt, default|
|
647
|
+
describe "##{opt}" do
|
648
|
+
let(:client_options) { {} }
|
649
|
+
|
650
|
+
let(:client) do
|
651
|
+
Mongo::Client.new(['127.0.0.1:27017'], {monitoring_io: false}.update(client_options))
|
652
|
+
end
|
653
|
+
|
654
|
+
let(:cluster) do
|
655
|
+
client.cluster
|
656
|
+
end
|
657
|
+
|
658
|
+
it "defaults to #{default}" do
|
659
|
+
expect(default).not_to be nil
|
660
|
+
expect(client.options[opt]).to be nil
|
661
|
+
expect(cluster.send(opt)).to eq(default)
|
662
|
+
end
|
663
|
+
|
664
|
+
context 'specified on client' do
|
665
|
+
let(:client_options) { {opt => 2} }
|
666
|
+
|
667
|
+
it 'inherits from client' do
|
668
|
+
expect(client.options[opt]).to eq(2)
|
669
|
+
expect(cluster.send(opt)).to eq(2)
|
670
|
+
end
|
671
|
+
end
|
672
|
+
end
|
673
|
+
end
|
674
|
+
|
643
675
|
describe '#summary' do
|
676
|
+
let(:default_address) { SpecConfig.instance.addresses.first }
|
677
|
+
|
644
678
|
context 'cluster has unknown servers' do
|
645
679
|
it 'includes unknown servers' do
|
646
680
|
cluster.servers_list.each do |server|
|
647
681
|
expect(server).to be_unknown
|
648
682
|
end
|
649
683
|
|
650
|
-
expect(cluster.summary).to match(/Server address
|
684
|
+
expect(cluster.summary).to match(/Server address=#{default_address}/)
|
651
685
|
end
|
652
686
|
end
|
653
687
|
|
@@ -664,7 +698,7 @@ describe Mongo::Cluster do
|
|
664
698
|
expect(server).not_to be_unknown
|
665
699
|
end
|
666
700
|
|
667
|
-
expect(cluster.summary).to match(/Server address
|
701
|
+
expect(cluster.summary).to match(/Server address=#{default_address}/)
|
668
702
|
end
|
669
703
|
end
|
670
704
|
end
|
@@ -219,6 +219,8 @@ describe Mongo::Collection::View::Aggregation do
|
|
219
219
|
end
|
220
220
|
|
221
221
|
describe '#explain' do
|
222
|
+
# Broken on 4.2 - https://jira.mongodb.org/browse/RUBY-1788
|
223
|
+
max_server_version '4.0'
|
222
224
|
|
223
225
|
it 'executes an explain' do
|
224
226
|
expect(aggregation.explain).to_not be_empty
|
@@ -3,6 +3,7 @@ require 'spec_helper'
|
|
3
3
|
describe Mongo::Collection::View::ChangeStream do
|
4
4
|
min_server_fcv '3.6'
|
5
5
|
require_topology :replica_set
|
6
|
+
max_example_run_time 7
|
6
7
|
|
7
8
|
let(:pipeline) do
|
8
9
|
[]
|
@@ -16,8 +17,16 @@ describe Mongo::Collection::View::ChangeStream do
|
|
16
17
|
{}
|
17
18
|
end
|
18
19
|
|
20
|
+
let(:client) do
|
21
|
+
authorized_client_without_any_retry_reads
|
22
|
+
end
|
23
|
+
|
24
|
+
let(:collection) do
|
25
|
+
client['mcv-change-stream']
|
26
|
+
end
|
27
|
+
|
19
28
|
let(:view) do
|
20
|
-
Mongo::Collection::View.new(
|
29
|
+
Mongo::Collection::View.new(collection, {}, view_options)
|
21
30
|
end
|
22
31
|
|
23
32
|
let(:change_stream) do
|
@@ -30,8 +39,8 @@ describe Mongo::Collection::View::ChangeStream do
|
|
30
39
|
end
|
31
40
|
|
32
41
|
let!(:sample_resume_token) do
|
33
|
-
stream =
|
34
|
-
|
42
|
+
stream = collection.watch
|
43
|
+
collection.insert_one(a: 1)
|
35
44
|
doc = stream.to_enum.next
|
36
45
|
stream.close
|
37
46
|
doc[:_id]
|
@@ -61,7 +70,7 @@ describe Mongo::Collection::View::ChangeStream do
|
|
61
70
|
end
|
62
71
|
|
63
72
|
before do
|
64
|
-
|
73
|
+
collection.delete_many
|
65
74
|
end
|
66
75
|
|
67
76
|
after do
|
@@ -172,7 +181,8 @@ describe Mongo::Collection::View::ChangeStream do
|
|
172
181
|
context 'when the collection has a readConcern' do
|
173
182
|
|
174
183
|
let(:collection) do
|
175
|
-
|
184
|
+
client['mcv-change-stream'].with(
|
185
|
+
read_concern: { level: 'majority' })
|
176
186
|
end
|
177
187
|
|
178
188
|
let(:view) do
|
@@ -242,10 +252,6 @@ describe Mongo::Collection::View::ChangeStream do
|
|
242
252
|
client.start_session
|
243
253
|
end
|
244
254
|
|
245
|
-
let(:client) do
|
246
|
-
authorized_client
|
247
|
-
end
|
248
|
-
|
249
255
|
it 'raises an error' do
|
250
256
|
expect(operation_result.class).to eq(Mongo::Error::OperationFailure)
|
251
257
|
end
|
@@ -281,14 +287,10 @@ describe Mongo::Collection::View::ChangeStream do
|
|
281
287
|
|
282
288
|
let(:operation) do
|
283
289
|
change_stream
|
284
|
-
|
290
|
+
collection.insert_one(a: 1)
|
285
291
|
change_stream.to_enum.next
|
286
292
|
end
|
287
293
|
|
288
|
-
let(:client) do
|
289
|
-
authorized_client
|
290
|
-
end
|
291
|
-
|
292
294
|
context 'when the session is created from the same client used for the operation' do
|
293
295
|
|
294
296
|
let(:session) do
|
@@ -327,7 +329,7 @@ describe Mongo::Collection::View::ChangeStream do
|
|
327
329
|
context 'when a session from another client is provided' do
|
328
330
|
|
329
331
|
let(:session) do
|
330
|
-
another_authorized_client.start_session
|
332
|
+
another_authorized_client.with(retry_reads: false).start_session
|
331
333
|
end
|
332
334
|
|
333
335
|
let(:operation_result) do
|
@@ -390,7 +392,7 @@ describe Mongo::Collection::View::ChangeStream do
|
|
390
392
|
|
391
393
|
before do
|
392
394
|
change_stream
|
393
|
-
|
395
|
+
collection.insert_one(a: 1)
|
394
396
|
enum.next
|
395
397
|
change_stream.close
|
396
398
|
end
|
@@ -438,7 +440,7 @@ describe Mongo::Collection::View::ChangeStream do
|
|
438
440
|
|
439
441
|
before do
|
440
442
|
change_stream
|
441
|
-
|
443
|
+
collection.insert_one(a: 1)
|
442
444
|
end
|
443
445
|
|
444
446
|
context 'pre-4.1 server' do
|
@@ -467,8 +469,6 @@ describe Mongo::Collection::View::ChangeStream do
|
|
467
469
|
context 'when an error is encountered the first time the command is run' do
|
468
470
|
include PrimarySocket
|
469
471
|
|
470
|
-
let(:client) { authorized_collection.client }
|
471
|
-
|
472
472
|
before do
|
473
473
|
expect(primary_socket).to receive(:write).and_raise(error).once
|
474
474
|
end
|
@@ -482,7 +482,7 @@ describe Mongo::Collection::View::ChangeStream do
|
|
482
482
|
before do
|
483
483
|
expect(view.send(:server_selector)).to receive(:select_server).twice.and_call_original
|
484
484
|
change_stream
|
485
|
-
|
485
|
+
collection.insert_one(a: 1)
|
486
486
|
end
|
487
487
|
|
488
488
|
it 'runs the command again while using the same read preference and caches the resume token' do
|
@@ -497,7 +497,7 @@ describe Mongo::Collection::View::ChangeStream do
|
|
497
497
|
end
|
498
498
|
|
499
499
|
let(:session) do
|
500
|
-
|
500
|
+
client.start_session
|
501
501
|
end
|
502
502
|
|
503
503
|
before do
|
@@ -576,7 +576,7 @@ describe Mongo::Collection::View::ChangeStream do
|
|
576
576
|
end
|
577
577
|
|
578
578
|
let(:session) do
|
579
|
-
|
579
|
+
client.start_session
|
580
580
|
end
|
581
581
|
|
582
582
|
before do
|
@@ -601,9 +601,9 @@ describe Mongo::Collection::View::ChangeStream do
|
|
601
601
|
|
602
602
|
before do
|
603
603
|
change_stream
|
604
|
-
|
604
|
+
collection.insert_one(a: 1)
|
605
605
|
enum.next
|
606
|
-
|
606
|
+
collection.insert_one(a: 2)
|
607
607
|
expect(cursor).to receive(:get_more).once.and_raise(error)
|
608
608
|
expect(cursor).to receive(:kill_cursors).and_call_original
|
609
609
|
expect(Mongo::Operation::Aggregate).to receive(:new).and_call_original
|
@@ -629,7 +629,7 @@ describe Mongo::Collection::View::ChangeStream do
|
|
629
629
|
end
|
630
630
|
|
631
631
|
let(:session) do
|
632
|
-
|
632
|
+
client.start_session
|
633
633
|
end
|
634
634
|
|
635
635
|
before do
|
@@ -685,9 +685,9 @@ describe Mongo::Collection::View::ChangeStream do
|
|
685
685
|
|
686
686
|
before do
|
687
687
|
change_stream
|
688
|
-
|
688
|
+
collection.insert_one(a: 1)
|
689
689
|
enum.next
|
690
|
-
|
690
|
+
collection.insert_one(a: 2)
|
691
691
|
expect(cursor).to receive(:get_more).and_raise(Mongo::Error::MissingResumeToken)
|
692
692
|
expect(cursor).to receive(:kill_cursors).and_call_original
|
693
693
|
expect(Mongo::Operation::Aggregate).not_to receive(:new)
|
@@ -710,7 +710,7 @@ describe Mongo::Collection::View::ChangeStream do
|
|
710
710
|
end
|
711
711
|
|
712
712
|
let(:session) do
|
713
|
-
|
713
|
+
client.start_session
|
714
714
|
end
|
715
715
|
|
716
716
|
before do
|
@@ -192,7 +192,7 @@ describe Mongo::Collection::View::Readable do
|
|
192
192
|
|
193
193
|
let(:command) do
|
194
194
|
operation
|
195
|
-
EventSubscriber.started_events.find { |cmd| cmd.command_name == '
|
195
|
+
EventSubscriber.started_events.find { |cmd| cmd.command_name == 'mapReduce' }.command
|
196
196
|
end
|
197
197
|
|
198
198
|
it_behaves_like 'an operation supporting causally consistent reads'
|
@@ -141,7 +141,9 @@ describe Mongo::Collection::View do
|
|
141
141
|
|
142
142
|
before do
|
143
143
|
view.to_enum.next
|
144
|
-
|
144
|
+
if ClusterConfig.instance.fcv_ish < '3.2'
|
145
|
+
cursor.instance_variable_set(:@cursor_id, 1)
|
146
|
+
end
|
145
147
|
end
|
146
148
|
|
147
149
|
it 'sends a kill cursors command for the cursor' do
|
data/spec/mongo/cursor_spec.rb
CHANGED
@@ -110,13 +110,13 @@ describe Mongo::Cursor do
|
|
110
110
|
before do
|
111
111
|
expect(cursor).to receive(:get_more_operation).and_return(op).ordered
|
112
112
|
expect(op).to receive(:execute).and_raise(Mongo::Error::SocketError).ordered
|
113
|
-
expect(cursor).to receive(:get_more_operation).and_call_original.ordered
|
114
113
|
end
|
115
114
|
|
116
|
-
it '
|
117
|
-
|
118
|
-
|
119
|
-
|
115
|
+
it 'raises the error' do
|
116
|
+
expect do
|
117
|
+
cursor.each do |doc|
|
118
|
+
end
|
119
|
+
end.to raise_error(Mongo::Error::SocketError)
|
120
120
|
end
|
121
121
|
end
|
122
122
|
|