mongo 2.13.0.beta1 → 2.13.0.rc1
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.tar.gz.sig +1 -5
- data/Rakefile +15 -9
- data/lib/mongo.rb +4 -2
- data/lib/mongo/auth/aws/request.rb +4 -2
- data/lib/mongo/bulk_write.rb +1 -0
- data/lib/mongo/client.rb +143 -21
- data/lib/mongo/cluster.rb +53 -17
- data/lib/mongo/cluster/sdam_flow.rb +13 -10
- data/lib/mongo/cluster/topology/replica_set_no_primary.rb +3 -2
- data/lib/mongo/cluster/topology/sharded.rb +1 -1
- data/lib/mongo/cluster/topology/single.rb +1 -1
- data/lib/mongo/collection.rb +17 -13
- data/lib/mongo/collection/view/readable.rb +3 -1
- data/lib/mongo/collection/view/writable.rb +41 -5
- data/lib/mongo/database.rb +31 -4
- data/lib/mongo/database/view.rb +19 -4
- data/lib/mongo/distinguishing_semaphore.rb +55 -0
- data/lib/mongo/error.rb +1 -0
- data/lib/mongo/error/invalid_session.rb +2 -1
- data/lib/mongo/error/operation_failure.rb +6 -0
- data/lib/mongo/error/sessions_not_supported.rb +35 -0
- data/lib/mongo/event/base.rb +6 -0
- data/lib/mongo/grid/file.rb +5 -0
- data/lib/mongo/grid/file/chunk.rb +2 -0
- data/lib/mongo/grid/fs_bucket.rb +15 -13
- data/lib/mongo/grid/stream/write.rb +9 -3
- data/lib/mongo/monitoring.rb +38 -0
- data/lib/mongo/monitoring/command_log_subscriber.rb +10 -2
- data/lib/mongo/monitoring/event/command_failed.rb +11 -0
- data/lib/mongo/monitoring/event/command_started.rb +37 -2
- data/lib/mongo/monitoring/event/command_succeeded.rb +11 -0
- data/lib/mongo/monitoring/event/server_closed.rb +1 -1
- data/lib/mongo/monitoring/event/server_description_changed.rb +27 -4
- data/lib/mongo/monitoring/event/server_heartbeat_failed.rb +9 -2
- data/lib/mongo/monitoring/event/server_heartbeat_started.rb +9 -2
- data/lib/mongo/monitoring/event/server_heartbeat_succeeded.rb +9 -2
- data/lib/mongo/monitoring/event/server_opening.rb +1 -1
- data/lib/mongo/monitoring/event/topology_changed.rb +1 -1
- data/lib/mongo/monitoring/event/topology_closed.rb +1 -1
- data/lib/mongo/monitoring/event/topology_opening.rb +1 -1
- data/lib/mongo/monitoring/publishable.rb +6 -3
- data/lib/mongo/monitoring/server_description_changed_log_subscriber.rb +9 -1
- data/lib/mongo/monitoring/topology_changed_log_subscriber.rb +1 -1
- data/lib/mongo/protocol/message.rb +36 -8
- data/lib/mongo/protocol/msg.rb +14 -0
- data/lib/mongo/protocol/serializers.rb +5 -2
- data/lib/mongo/server.rb +10 -3
- data/lib/mongo/server/connection.rb +4 -4
- data/lib/mongo/server/connection_base.rb +3 -1
- data/lib/mongo/server/description.rb +5 -0
- data/lib/mongo/server/monitor.rb +76 -44
- data/lib/mongo/server/monitor/connection.rb +55 -7
- data/lib/mongo/server/pending_connection.rb +14 -4
- data/lib/mongo/server/push_monitor.rb +173 -0
- data/{spec/runners/transactions/context.rb → lib/mongo/server/push_monitor/connection.rb} +9 -14
- data/lib/mongo/server_selector.rb +0 -1
- data/lib/mongo/server_selector/base.rb +579 -1
- data/lib/mongo/server_selector/nearest.rb +1 -6
- data/lib/mongo/server_selector/primary.rb +1 -6
- data/lib/mongo/server_selector/primary_preferred.rb +7 -10
- data/lib/mongo/server_selector/secondary.rb +1 -6
- data/lib/mongo/server_selector/secondary_preferred.rb +1 -7
- data/lib/mongo/session.rb +2 -0
- data/lib/mongo/socket.rb +20 -8
- data/lib/mongo/socket/ssl.rb +1 -1
- data/lib/mongo/socket/tcp.rb +1 -1
- data/lib/mongo/topology_version.rb +9 -0
- data/lib/mongo/utils.rb +62 -0
- data/lib/mongo/version.rb +1 -1
- data/spec/README.aws-auth.md +2 -2
- data/spec/integration/awaited_ismaster_spec.rb +28 -0
- data/spec/integration/change_stream_examples_spec.rb +6 -2
- data/spec/integration/check_clean_slate_spec.rb +16 -0
- data/spec/integration/client_construction_spec.rb +1 -0
- data/spec/integration/connect_single_rs_name_spec.rb +5 -2
- data/spec/integration/connection_spec.rb +7 -4
- data/spec/integration/crud_spec.rb +4 -4
- data/spec/integration/docs_examples_spec.rb +6 -0
- data/spec/integration/grid_fs_bucket_spec.rb +48 -0
- data/spec/integration/heartbeat_events_spec.rb +4 -23
- data/spec/integration/read_concern_spec.rb +1 -1
- data/spec/integration/retryable_errors_spec.rb +1 -1
- data/spec/integration/retryable_writes/shared/performs_legacy_retries.rb +2 -2
- data/spec/integration/retryable_writes/shared/performs_modern_retries.rb +3 -3
- data/spec/integration/retryable_writes/shared/performs_no_retries.rb +2 -2
- data/spec/integration/sdam_error_handling_spec.rb +37 -15
- data/spec/integration/sdam_events_spec.rb +77 -6
- data/spec/integration/sdam_prose_spec.rb +64 -0
- data/spec/integration/server_monitor_spec.rb +25 -1
- data/spec/integration/size_limit_spec.rb +7 -3
- data/spec/integration/size_limit_spec.rb~12e1e9c4f... RUBY-2242 Fix zlib compression (#2021) +98 -0
- data/spec/integration/ssl_uri_options_spec.rb +2 -2
- data/spec/integration/zlib_compression_spec.rb +25 -0
- data/spec/lite_spec_helper.rb +12 -5
- data/spec/mongo/auth/aws/request_spec.rb +76 -0
- data/spec/mongo/auth/scram_spec.rb +1 -1
- data/spec/mongo/client_construction_spec.rb +207 -0
- data/spec/mongo/client_spec.rb +38 -3
- data/spec/mongo/cluster/topology/replica_set_spec.rb +52 -9
- data/spec/mongo/cluster/topology/single_spec.rb +4 -2
- data/spec/mongo/cluster_spec.rb +34 -35
- data/spec/mongo/collection/view/change_stream_resume_spec.rb +6 -6
- data/spec/mongo/collection_spec.rb +500 -0
- data/spec/mongo/database_spec.rb +245 -8
- data/spec/mongo/distinguishing_semaphore_spec.rb +63 -0
- data/spec/mongo/error/operation_failure_spec.rb +40 -0
- data/spec/mongo/index/view_spec.rb +2 -2
- data/spec/mongo/monitoring/event/server_description_changed_spec.rb +1 -4
- data/spec/mongo/protocol/msg_spec.rb +10 -0
- data/spec/mongo/semaphore_spec.rb +51 -0
- data/spec/mongo/server/connection_auth_spec.rb +2 -2
- data/spec/mongo/server_selector/nearest_spec.rb +23 -23
- data/spec/mongo/server_selector/primary_preferred_spec.rb +26 -26
- data/spec/mongo/server_selector/primary_spec.rb +9 -9
- data/spec/mongo/server_selector/secondary_preferred_spec.rb +22 -22
- data/spec/mongo/server_selector/secondary_spec.rb +18 -18
- data/spec/mongo/server_selector_spec.rb +4 -4
- data/spec/mongo/session_spec.rb +35 -0
- data/spec/runners/change_streams/test.rb +2 -2
- data/spec/runners/cmap.rb +1 -1
- data/spec/runners/command_monitoring.rb +3 -34
- data/spec/runners/crud/context.rb +9 -5
- data/spec/runners/crud/operation.rb +59 -27
- data/spec/runners/crud/spec.rb +0 -8
- data/spec/runners/crud/test.rb +1 -1
- data/spec/runners/sdam.rb +2 -2
- data/spec/runners/server_selection.rb +242 -28
- data/spec/runners/transactions.rb +12 -12
- data/spec/runners/transactions/operation.rb +151 -25
- data/spec/runners/transactions/test.rb +60 -16
- data/spec/spec_tests/command_monitoring_spec.rb +22 -12
- data/spec/spec_tests/crud_spec.rb +1 -1
- data/spec/spec_tests/data/change_streams/change-streams-errors.yml +4 -8
- data/spec/spec_tests/data/change_streams/change-streams-resume-whitelist.yml +66 -0
- data/spec/spec_tests/data/max_staleness/ReplicaSetNoPrimary/MaxStalenessTooSmall.yml +15 -0
- data/spec/spec_tests/data/max_staleness/ReplicaSetNoPrimary/NoKnownServers.yml +4 -3
- data/spec/spec_tests/data/max_staleness/Unknown/SmallMaxStaleness.yml +1 -0
- data/spec/spec_tests/data/sdam_integration/cancel-server-check.yml +96 -0
- data/spec/spec_tests/data/sdam_integration/connectTimeoutMS.yml +88 -0
- data/spec/spec_tests/data/sdam_integration/find-network-error.yml +83 -0
- data/spec/spec_tests/data/sdam_integration/find-shutdown-error.yml +116 -0
- data/spec/spec_tests/data/sdam_integration/insert-network-error.yml +86 -0
- data/spec/spec_tests/data/sdam_integration/insert-shutdown-error.yml +115 -0
- data/spec/spec_tests/data/sdam_integration/isMaster-command-error.yml +168 -0
- data/spec/spec_tests/data/sdam_integration/isMaster-network-error.yml +162 -0
- data/spec/spec_tests/data/sdam_integration/isMaster-timeout.yml +229 -0
- data/spec/spec_tests/data/sdam_integration/rediscover-quickly-after-step-down.yml +87 -0
- data/spec/spec_tests/max_staleness_spec.rb +4 -142
- data/spec/spec_tests/retryable_reads_spec.rb +2 -2
- data/spec/spec_tests/sdam_integration_spec.rb +13 -0
- data/spec/spec_tests/sdam_monitoring_spec.rb +1 -2
- data/spec/spec_tests/server_selection_spec.rb +4 -116
- data/spec/stress/cleanup_spec.rb +17 -2
- data/spec/stress/connection_pool_stress_spec.rb +10 -8
- data/spec/support/child_process_helper.rb +78 -0
- data/spec/support/client_registry.rb +1 -0
- data/spec/support/cluster_config.rb +4 -0
- data/spec/support/event_subscriber.rb +123 -33
- data/spec/support/keyword_struct.rb +26 -0
- data/spec/support/shared/server_selector.rb +13 -1
- data/spec/support/spec_config.rb +38 -13
- data/spec/support/spec_organizer.rb +129 -0
- data/spec/support/spec_setup.rb +1 -1
- data/spec/support/utils.rb +46 -0
- metadata +992 -942
- metadata.gz.sig +0 -0
- data/lib/mongo/server_selector/selectable.rb +0 -560
- data/spec/runners/sdam_monitoring.rb +0 -89
data/spec/mongo/database_spec.rb
CHANGED
@@ -92,8 +92,8 @@ describe Mongo::Database do
|
|
92
92
|
end
|
93
93
|
|
94
94
|
before do
|
95
|
-
database[
|
96
|
-
database[
|
95
|
+
database['users'].drop
|
96
|
+
database['users'].create
|
97
97
|
end
|
98
98
|
|
99
99
|
let(:actual) do
|
@@ -153,7 +153,80 @@ describe Mongo::Database do
|
|
153
153
|
expect(collection_names).to include('0_dalmatians')
|
154
154
|
expect(collection_names).to include('1_dalmatians')
|
155
155
|
end
|
156
|
+
end
|
157
|
+
|
158
|
+
context 'when provided a filter' do
|
159
|
+
min_server_fcv '3.0'
|
160
|
+
|
161
|
+
before do
|
162
|
+
database['users2'].drop
|
163
|
+
database['users2'].create
|
164
|
+
end
|
165
|
+
|
166
|
+
let(:result) do
|
167
|
+
database.collection_names(filter: { name: 'users2' })
|
168
|
+
end
|
156
169
|
|
170
|
+
it 'returns users2 collection' do
|
171
|
+
expect(result.length).to eq(1)
|
172
|
+
expect(result.first).to eq('users2')
|
173
|
+
end
|
174
|
+
end
|
175
|
+
|
176
|
+
context 'when provided authorized_collections or not' do
|
177
|
+
|
178
|
+
context 'on server versions >= 4.0' do
|
179
|
+
min_server_fcv '4.0'
|
180
|
+
|
181
|
+
let(:database) do
|
182
|
+
described_class.new(client, SpecConfig.instance.test_db)
|
183
|
+
end
|
184
|
+
|
185
|
+
let(:subscriber) { EventSubscriber.new }
|
186
|
+
|
187
|
+
let(:client) do
|
188
|
+
authorized_client.tap do |client|
|
189
|
+
client.subscribe(Mongo::Monitoring::COMMAND, subscriber)
|
190
|
+
end
|
191
|
+
end
|
192
|
+
|
193
|
+
context 'when authorized_collections is provided' do
|
194
|
+
let(:options) do
|
195
|
+
{ authorized_collections: true }
|
196
|
+
end
|
197
|
+
|
198
|
+
let!(:result) do
|
199
|
+
database.collections(options)
|
200
|
+
end
|
201
|
+
|
202
|
+
let(:events) do
|
203
|
+
subscriber.command_started_events('listCollections')
|
204
|
+
end
|
205
|
+
|
206
|
+
it 'passes authorized_collections to the server' do
|
207
|
+
expect(events.length).to eq(1)
|
208
|
+
command = events.first.command
|
209
|
+
expect(command['authorizedCollections']).to eq(true)
|
210
|
+
end
|
211
|
+
end
|
212
|
+
|
213
|
+
context 'when no options are provided' do
|
214
|
+
let!(:result) do
|
215
|
+
database.collection_names
|
216
|
+
end
|
217
|
+
|
218
|
+
let(:events) do
|
219
|
+
subscriber.command_started_events('listCollections')
|
220
|
+
end
|
221
|
+
|
222
|
+
it 'authorized_collections not passed to server' do
|
223
|
+
expect(events.length).to eq(1)
|
224
|
+
command = events.first.command
|
225
|
+
expect(command['nameOnly']).to eq(true)
|
226
|
+
expect(command['authorizedCollections']).to be_nil
|
227
|
+
end
|
228
|
+
end
|
229
|
+
end
|
157
230
|
end
|
158
231
|
end
|
159
232
|
|
@@ -170,8 +243,8 @@ describe Mongo::Database do
|
|
170
243
|
end
|
171
244
|
|
172
245
|
before do
|
173
|
-
database[
|
174
|
-
database[
|
246
|
+
database['acol'].drop
|
247
|
+
database['acol'].create
|
175
248
|
end
|
176
249
|
|
177
250
|
context 'server 3.0+' do
|
@@ -183,8 +256,8 @@ describe Mongo::Database do
|
|
183
256
|
|
184
257
|
context 'with more than one collection' do
|
185
258
|
before do
|
186
|
-
database[
|
187
|
-
database[
|
259
|
+
database['anothercol'].drop
|
260
|
+
database['anothercol'].create
|
188
261
|
|
189
262
|
expect(database.collections.length).to be > 1
|
190
263
|
end
|
@@ -239,6 +312,85 @@ describe Mongo::Database do
|
|
239
312
|
end
|
240
313
|
end
|
241
314
|
end
|
315
|
+
|
316
|
+
context 'when provided authorized_collections or name_only options or not' do
|
317
|
+
|
318
|
+
context 'on server versions >= 4.0' do
|
319
|
+
min_server_fcv '4.0'
|
320
|
+
|
321
|
+
let(:database) do
|
322
|
+
described_class.new(client, SpecConfig.instance.test_db)
|
323
|
+
end
|
324
|
+
|
325
|
+
let(:subscriber) { EventSubscriber.new }
|
326
|
+
|
327
|
+
let(:client) do
|
328
|
+
authorized_client.tap do |client|
|
329
|
+
client.subscribe(Mongo::Monitoring::COMMAND, subscriber)
|
330
|
+
end
|
331
|
+
end
|
332
|
+
|
333
|
+
context 'when both are provided' do
|
334
|
+
let(:options) do
|
335
|
+
{ name_only: true, authorized_collections: true }
|
336
|
+
end
|
337
|
+
|
338
|
+
let!(:result) do
|
339
|
+
database.list_collections(options)
|
340
|
+
end
|
341
|
+
|
342
|
+
let(:events) do
|
343
|
+
subscriber.command_started_events('listCollections')
|
344
|
+
end
|
345
|
+
|
346
|
+
it 'passes original options to the server' do
|
347
|
+
expect(events.length).to eq(1)
|
348
|
+
command = events.first.command
|
349
|
+
expect(command['nameOnly']).to eq(true)
|
350
|
+
expect(command['authorizedCollections']).to eq(true)
|
351
|
+
end
|
352
|
+
end
|
353
|
+
|
354
|
+
context 'when name_only is provided' do
|
355
|
+
let(:options) do
|
356
|
+
{ name_only: false }
|
357
|
+
end
|
358
|
+
|
359
|
+
let!(:result) do
|
360
|
+
database.list_collections(options)
|
361
|
+
end
|
362
|
+
|
363
|
+
let(:events) do
|
364
|
+
subscriber.command_started_events('listCollections')
|
365
|
+
end
|
366
|
+
|
367
|
+
it 'no options passed to server because false' do
|
368
|
+
expect(events.length).to eq(1)
|
369
|
+
command = events.first.command
|
370
|
+
expect(command['nameOnly']).to be_nil
|
371
|
+
expect(command['authorizedCollections']).to be_nil
|
372
|
+
end
|
373
|
+
end
|
374
|
+
|
375
|
+
context 'when no options provided' do
|
376
|
+
|
377
|
+
let!(:result) do
|
378
|
+
database.list_collections
|
379
|
+
end
|
380
|
+
|
381
|
+
let(:events) do
|
382
|
+
subscriber.command_started_events('listCollections')
|
383
|
+
end
|
384
|
+
|
385
|
+
it 'no options passed to server because none provided' do
|
386
|
+
expect(events.length).to eq(1)
|
387
|
+
command = events.first.command
|
388
|
+
expect(command['nameOnly']).to be_nil
|
389
|
+
expect(command['authorizedCollections']).to be_nil
|
390
|
+
end
|
391
|
+
end
|
392
|
+
end
|
393
|
+
end
|
242
394
|
end
|
243
395
|
|
244
396
|
describe '#collections' do
|
@@ -254,8 +406,8 @@ describe Mongo::Database do
|
|
254
406
|
end
|
255
407
|
|
256
408
|
before do
|
257
|
-
database[
|
258
|
-
database[
|
409
|
+
database['users'].drop
|
410
|
+
database['users'].create
|
259
411
|
end
|
260
412
|
|
261
413
|
it 'returns collection objects for each name' do
|
@@ -304,6 +456,91 @@ describe Mongo::Database do
|
|
304
456
|
}.to raise_error(Mongo::Error::OperationFailure)
|
305
457
|
end
|
306
458
|
end
|
459
|
+
|
460
|
+
context 'when provided a filter' do
|
461
|
+
min_server_fcv '3.0'
|
462
|
+
|
463
|
+
let(:database) do
|
464
|
+
described_class.new(authorized_client, SpecConfig.instance.test_db)
|
465
|
+
end
|
466
|
+
|
467
|
+
let(:collection2) do
|
468
|
+
Mongo::Collection.new(database, 'users2')
|
469
|
+
end
|
470
|
+
|
471
|
+
before do
|
472
|
+
database['users1'].drop
|
473
|
+
database['users1'].create
|
474
|
+
|
475
|
+
database['users2'].drop
|
476
|
+
database['users2'].create
|
477
|
+
end
|
478
|
+
|
479
|
+
let(:result) do
|
480
|
+
database.collections(filter: { name: 'users2' })
|
481
|
+
end
|
482
|
+
|
483
|
+
it 'returns users2 collection' do
|
484
|
+
expect(result.length).to eq(1)
|
485
|
+
expect(database.collections).to include(collection2)
|
486
|
+
end
|
487
|
+
end
|
488
|
+
|
489
|
+
context 'when provided authorized_collections or not' do
|
490
|
+
|
491
|
+
context 'on server versions >= 4.0' do
|
492
|
+
min_server_fcv '4.0'
|
493
|
+
|
494
|
+
let(:database) do
|
495
|
+
described_class.new(client, SpecConfig.instance.test_db)
|
496
|
+
end
|
497
|
+
|
498
|
+
let(:subscriber) { EventSubscriber.new }
|
499
|
+
|
500
|
+
let(:client) do
|
501
|
+
authorized_client.tap do |client|
|
502
|
+
client.subscribe(Mongo::Monitoring::COMMAND, subscriber)
|
503
|
+
end
|
504
|
+
end
|
505
|
+
|
506
|
+
context 'when authorized_collections are provided' do
|
507
|
+
let(:options) do
|
508
|
+
{ authorized_collections: false }
|
509
|
+
end
|
510
|
+
|
511
|
+
let!(:result) do
|
512
|
+
database.collections(options)
|
513
|
+
end
|
514
|
+
|
515
|
+
let(:events) do
|
516
|
+
subscriber.command_started_events('listCollections')
|
517
|
+
end
|
518
|
+
|
519
|
+
it 'authorized_collections not passed to server because false' do
|
520
|
+
expect(events.length).to eq(1)
|
521
|
+
command = events.first.command
|
522
|
+
expect(command['nameOnly']).to eq(true)
|
523
|
+
expect(command['authorizedCollections']).to be_nil
|
524
|
+
end
|
525
|
+
end
|
526
|
+
|
527
|
+
context 'when no options are provided' do
|
528
|
+
let!(:result) do
|
529
|
+
database.collections
|
530
|
+
end
|
531
|
+
|
532
|
+
let(:events) do
|
533
|
+
subscriber.command_started_events('listCollections')
|
534
|
+
end
|
535
|
+
|
536
|
+
it 'authorized_collections not passed to server because not provided' do
|
537
|
+
expect(events.length).to eq(1)
|
538
|
+
command = events.first.command
|
539
|
+
expect(command['authorizedCollections']).to be_nil
|
540
|
+
end
|
541
|
+
end
|
542
|
+
end
|
543
|
+
end
|
307
544
|
end
|
308
545
|
|
309
546
|
describe '#command' do
|
@@ -0,0 +1,63 @@
|
|
1
|
+
require 'lite_spec_helper'
|
2
|
+
|
3
|
+
describe Mongo::DistinguishingSemaphore do
|
4
|
+
let(:semaphore) do
|
5
|
+
described_class.new
|
6
|
+
end
|
7
|
+
|
8
|
+
it 'waits until signaled' do
|
9
|
+
result = nil
|
10
|
+
|
11
|
+
consumer = Thread.new do
|
12
|
+
result = semaphore.wait(3)
|
13
|
+
end
|
14
|
+
|
15
|
+
# Context switch to start the thread
|
16
|
+
sleep 0.1
|
17
|
+
|
18
|
+
start_time = Time.now
|
19
|
+
semaphore.signal
|
20
|
+
consumer.join
|
21
|
+
|
22
|
+
(Time.now - start_time).should < 1
|
23
|
+
|
24
|
+
result.should be true
|
25
|
+
end
|
26
|
+
|
27
|
+
it 'waits until broadcast' do
|
28
|
+
result = nil
|
29
|
+
|
30
|
+
consumer = Thread.new do
|
31
|
+
result = semaphore.wait(3)
|
32
|
+
end
|
33
|
+
|
34
|
+
# Context switch to start the thread
|
35
|
+
sleep 0.1
|
36
|
+
|
37
|
+
start_time = Time.now
|
38
|
+
semaphore.broadcast
|
39
|
+
consumer.join
|
40
|
+
|
41
|
+
(Time.now - start_time).should < 1
|
42
|
+
|
43
|
+
result.should be true
|
44
|
+
end
|
45
|
+
|
46
|
+
it 'times out' do
|
47
|
+
result = nil
|
48
|
+
|
49
|
+
consumer = Thread.new do
|
50
|
+
result = semaphore.wait(2)
|
51
|
+
end
|
52
|
+
|
53
|
+
# Context switch to start the thread
|
54
|
+
sleep 0.1
|
55
|
+
|
56
|
+
start_time = Time.now
|
57
|
+
consumer.join
|
58
|
+
|
59
|
+
(Time.now - start_time).should > 1
|
60
|
+
|
61
|
+
result.should be false
|
62
|
+
end
|
63
|
+
end
|
@@ -227,6 +227,46 @@ describe Mongo::Error::OperationFailure do
|
|
227
227
|
end
|
228
228
|
end
|
229
229
|
|
230
|
+
context 'when the error code is 43 (CursorNotFound)' do
|
231
|
+
let(:error) { Mongo::Error::OperationFailure.new(nil, result, code: 43, code_name: 'CursorNotFound') }
|
232
|
+
let(:result) do
|
233
|
+
Mongo::Operation::GetMore::Result.new(
|
234
|
+
Mongo::Protocol::Message.new, description)
|
235
|
+
end
|
236
|
+
|
237
|
+
context 'wire protocol < 9' do
|
238
|
+
let(:description) do
|
239
|
+
Mongo::Server::Description.new('',
|
240
|
+
'minWireVersion' => 0,
|
241
|
+
'maxWireVersion' => 8,
|
242
|
+
)
|
243
|
+
end
|
244
|
+
|
245
|
+
it 'returns true' do
|
246
|
+
# CursorNotFound exceptions are resumable even if they don't have
|
247
|
+
# a ResumableChangeStreamError label because the server is not aware
|
248
|
+
# of the cursor id, and thus cannot determine if it is a change stream.
|
249
|
+
expect(error.change_stream_resumable?).to be true
|
250
|
+
end
|
251
|
+
end
|
252
|
+
|
253
|
+
context 'wire protocol >= 9' do
|
254
|
+
let(:description) do
|
255
|
+
Mongo::Server::Description.new('',
|
256
|
+
'minWireVersion' => 0,
|
257
|
+
'maxWireVersion' => 9,
|
258
|
+
)
|
259
|
+
end
|
260
|
+
|
261
|
+
it 'returns true' do
|
262
|
+
# CursorNotFound exceptions are resumable even if they don't have
|
263
|
+
# a ResumableChangeStreamError label because the server is not aware
|
264
|
+
# of the cursor id, and thus cannot determine if it is a change stream.
|
265
|
+
expect(error.change_stream_resumable?).to be true
|
266
|
+
end
|
267
|
+
end
|
268
|
+
end
|
269
|
+
|
230
270
|
context 'not a getMore response' do
|
231
271
|
let(:result) do
|
232
272
|
Mongo::Operation::Result.new(
|
@@ -261,7 +261,7 @@ describe Mongo::Index::View do
|
|
261
261
|
context 'when commit quorum options are specified' do
|
262
262
|
require_topology :replica_set, :sharded
|
263
263
|
context 'on server versions >= 4.4' do
|
264
|
-
min_server_fcv '4.
|
264
|
+
min_server_fcv '4.4'
|
265
265
|
|
266
266
|
let(:subscriber) { EventSubscriber.new }
|
267
267
|
|
@@ -776,7 +776,7 @@ describe Mongo::Index::View do
|
|
776
776
|
context 'when providing commit_quorum option' do
|
777
777
|
require_topology :replica_set, :sharded
|
778
778
|
context 'on server versions >= 4.4' do
|
779
|
-
min_server_fcv '4.
|
779
|
+
min_server_fcv '4.4'
|
780
780
|
|
781
781
|
let(:subscriber) { EventSubscriber.new }
|
782
782
|
|
@@ -27,12 +27,9 @@ describe Mongo::Monitoring::Event::ServerDescriptionChanged do
|
|
27
27
|
end
|
28
28
|
|
29
29
|
describe '#summary' do
|
30
|
-
skip_if_linting
|
31
30
|
|
32
31
|
it 'renders correctly' do
|
33
|
-
expect(
|
34
|
-
'127.0.0.1:27017' => Mongo::Server::Description.new(Mongo::Address.new('127.0.0.1:27017'))})
|
35
|
-
expect(event.summary).to eq("#<ServerDescriptionChanged address=127.0.0.1:27017 topology=Unknown[127.0.0.1:27017] prev=#{previous_desc.inspect} new=#{updated_desc.inspect}>")
|
32
|
+
expect(event.summary).to eq("#<ServerDescriptionChanged address=127.0.0.1:27017 prev=UNKNOWN new=UNKNOWN>")
|
36
33
|
end
|
37
34
|
end
|
38
35
|
end
|
@@ -425,6 +425,16 @@ describe Mongo::Protocol::Msg do
|
|
425
425
|
expect(message.serialize).to be_a(BSON::ByteBuffer)
|
426
426
|
end
|
427
427
|
end
|
428
|
+
|
429
|
+
[:more_to_come, :exhaust_allowed].each do |flag|
|
430
|
+
context "with #{flag} flag" do
|
431
|
+
let(:flags) { [flag] }
|
432
|
+
|
433
|
+
it "round trips #{flag} flag" do
|
434
|
+
expect(deserialized.flags).to eq(flags)
|
435
|
+
end
|
436
|
+
end
|
437
|
+
end
|
428
438
|
end
|
429
439
|
|
430
440
|
describe '#deserialize' do
|