mongo 2.5.0.beta → 2.5.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (172) hide show
  1. checksums.yaml +4 -4
  2. checksums.yaml.gz.sig +0 -0
  3. data.tar.gz.sig +0 -0
  4. data/lib/mongo/address.rb +1 -1
  5. data/lib/mongo/address/unix.rb +1 -1
  6. data/lib/mongo/auth/user.rb +0 -5
  7. data/lib/mongo/auth/user/view.rb +4 -4
  8. data/lib/mongo/bulk_write.rb +60 -32
  9. data/lib/mongo/client.rb +44 -8
  10. data/lib/mongo/cluster.rb +14 -12
  11. data/lib/mongo/cluster/periodic_executor.rb +106 -0
  12. data/lib/mongo/cluster/{cursor_reaper.rb → reapers/cursor_reaper.rb} +5 -37
  13. data/lib/mongo/cluster/reapers/socket_reaper.rb +59 -0
  14. data/lib/mongo/collection.rb +9 -6
  15. data/lib/mongo/collection/view.rb +2 -2
  16. data/lib/mongo/collection/view/builder/aggregation.rb +2 -1
  17. data/lib/mongo/collection/view/builder/find_command.rb +1 -1
  18. data/lib/mongo/collection/view/change_stream.rb +14 -1
  19. data/lib/mongo/collection/view/map_reduce.rb +30 -13
  20. data/lib/mongo/collection/view/readable.rb +5 -5
  21. data/lib/mongo/collection/view/writable.rb +98 -51
  22. data/lib/mongo/error.rb +3 -0
  23. data/lib/mongo/error/invalid_txt_record.rb +27 -0
  24. data/lib/mongo/error/invalid_uri.rb +7 -6
  25. data/lib/mongo/error/mismatched_domain.rb +27 -0
  26. data/lib/mongo/error/no_srv_records.rb +26 -0
  27. data/lib/mongo/error/unsupported_features.rb +0 -18
  28. data/lib/mongo/index/view.rb +2 -2
  29. data/lib/mongo/operation.rb +1 -0
  30. data/lib/mongo/operation/causally_consistent.rb +33 -0
  31. data/lib/mongo/operation/commands.rb +2 -1
  32. data/lib/mongo/operation/commands/aggregate.rb +2 -7
  33. data/lib/mongo/operation/commands/count.rb +27 -0
  34. data/lib/mongo/operation/commands/distinct.rb +27 -0
  35. data/lib/mongo/operation/commands/find.rb +3 -1
  36. data/lib/mongo/operation/commands/map_reduce.rb +1 -0
  37. data/lib/mongo/operation/commands/parallel_scan.rb +1 -0
  38. data/lib/mongo/operation/specifiable.rb +12 -0
  39. data/lib/mongo/operation/uses_command_op_msg.rb +36 -5
  40. data/lib/mongo/operation/write.rb +0 -5
  41. data/lib/mongo/operation/write/bulk/bulkable.rb +4 -8
  42. data/lib/mongo/operation/write/bulk/mergable.rb +2 -0
  43. data/lib/mongo/operation/write/command/create_index.rb +19 -0
  44. data/lib/mongo/operation/write/command/create_user.rb +19 -0
  45. data/lib/mongo/operation/write/command/delete.rb +1 -2
  46. data/lib/mongo/operation/write/command/drop_index.rb +19 -0
  47. data/lib/mongo/operation/write/command/insert.rb +1 -2
  48. data/lib/mongo/operation/write/command/remove_user.rb +19 -0
  49. data/lib/mongo/operation/write/command/update.rb +1 -2
  50. data/lib/mongo/operation/write/command/update_user.rb +19 -0
  51. data/lib/mongo/operation/write/write_command_enabled.rb +1 -3
  52. data/lib/mongo/protocol/compressed.rb +2 -1
  53. data/lib/mongo/protocol/serializers.rb +6 -6
  54. data/lib/mongo/retryable.rb +48 -5
  55. data/lib/mongo/server.rb +15 -0
  56. data/lib/mongo/server/connection.rb +21 -1
  57. data/lib/mongo/server/connection_pool.rb +3 -0
  58. data/lib/mongo/server/connection_pool/queue.rb +50 -5
  59. data/lib/mongo/server/description.rb +11 -3
  60. data/lib/mongo/server/description/features.rb +26 -7
  61. data/lib/mongo/session.rb +133 -6
  62. data/lib/mongo/session/server_session.rb +30 -0
  63. data/lib/mongo/session/session_pool.rb +20 -20
  64. data/lib/mongo/uri.rb +88 -44
  65. data/lib/mongo/uri/srv_protocol.rb +158 -0
  66. data/lib/mongo/version.rb +1 -1
  67. data/lib/mongo/write_concern/normalizable.rb +12 -0
  68. data/mongo.gemspec +1 -2
  69. data/spec/mongo/address_spec.rb +12 -0
  70. data/spec/mongo/auth/user/view_spec.rb +1 -5
  71. data/spec/mongo/bulk_write_spec.rb +232 -401
  72. data/spec/mongo/change_stream_examples_spec.rb +150 -0
  73. data/spec/mongo/client_spec.rb +142 -2
  74. data/spec/mongo/cluster/cursor_reaper_spec.rb +0 -70
  75. data/spec/mongo/cluster/socket_reaper_spec.rb +32 -0
  76. data/spec/mongo/cluster_spec.rb +11 -7
  77. data/spec/mongo/collection/view/aggregation_spec.rb +46 -1
  78. data/spec/mongo/collection/view/builder/find_command_spec.rb +15 -0
  79. data/spec/mongo/collection/view/change_stream_spec.rb +79 -12
  80. data/spec/mongo/collection/view/map_reduce_spec.rb +120 -4
  81. data/spec/mongo/collection/view/readable_spec.rb +23 -5
  82. data/spec/mongo/collection_spec.rb +292 -102
  83. data/spec/mongo/command_monitoring_spec.rb +26 -32
  84. data/spec/mongo/crud_spec.rb +1 -1
  85. data/spec/mongo/cursor_spec.rb +2 -3
  86. data/spec/mongo/database_spec.rb +30 -14
  87. data/spec/mongo/dns_seedlist_discovery_spec.rb +94 -0
  88. data/spec/mongo/grid/fs_bucket_spec.rb +1 -1
  89. data/spec/mongo/grid/stream/write_spec.rb +1 -1
  90. data/spec/mongo/index/view_spec.rb +8 -46
  91. data/spec/mongo/operation/write/bulk/delete_spec.rb +2 -2
  92. data/spec/mongo/operation/write/bulk/insert_spec.rb +2 -10
  93. data/spec/mongo/operation/write/{create_index_spec.rb → command/create_index_spec.rb} +2 -6
  94. data/spec/mongo/operation/write/command/delete_spec.rb +35 -7
  95. data/spec/mongo/operation/write/{drop_index_spec.rb → command/drop_index_spec.rb} +1 -1
  96. data/spec/mongo/operation/write/command/insert_spec.rb +37 -6
  97. data/spec/mongo/operation/write/{remove_user_spec.rb → command/remove_user_spec.rb} +2 -6
  98. data/spec/mongo/operation/write/command/update_spec.rb +34 -7
  99. data/spec/mongo/operation/write/{update_user_spec.rb → command/update_user_spec.rb} +1 -1
  100. data/spec/mongo/operation/write/create_user_spec.rb +1 -1
  101. data/spec/mongo/operation/write/delete_spec.rb +1 -1
  102. data/spec/mongo/operation/write/insert_spec.rb +2 -10
  103. data/spec/mongo/operation/write/update_spec.rb +3 -15
  104. data/spec/mongo/retryable_spec.rb +1 -1
  105. data/spec/mongo/retryable_writes_spec.rb +815 -0
  106. data/spec/mongo/server/connection_pool/queue_spec.rb +35 -2
  107. data/spec/mongo/server/connection_pool_spec.rb +234 -1
  108. data/spec/mongo/server/connection_spec.rb +10 -6
  109. data/spec/mongo/server/description/features_spec.rb +51 -37
  110. data/spec/mongo/server/description_spec.rb +6 -3
  111. data/spec/mongo/server_spec.rb +87 -0
  112. data/spec/mongo/session/server_session_spec.rb +43 -0
  113. data/spec/mongo/session/session_pool_spec.rb +63 -27
  114. data/spec/mongo/session_spec.rb +247 -0
  115. data/spec/mongo/shell_examples_spec.rb +2 -2
  116. data/spec/mongo/uri/srv_protocol_spec.rb +933 -0
  117. data/spec/mongo/uri_spec.rb +42 -3
  118. data/spec/mongo/write_concern/acknowledged_spec.rb +11 -0
  119. data/spec/mongo/write_concern/unacknowledged_spec.rb +11 -0
  120. data/spec/spec_helper.rb +11 -25
  121. data/spec/support/authorization.rb +2 -1
  122. data/spec/support/connection_string.rb +8 -4
  123. data/spec/support/crud.rb +38 -24
  124. data/spec/support/crud/write.rb +30 -3
  125. data/spec/support/crud_tests/read/aggregate-out.yml +21 -0
  126. data/spec/support/crud_tests/write/bulkWrite-arrayFilters.yml +44 -0
  127. data/spec/support/crud_tests/write/findOneAndUpdate-arrayFilters.yml +1 -1
  128. data/spec/support/crud_tests/write/insertMany.yml +1 -3
  129. data/spec/support/crud_tests/write/replaceOne.yml +1 -1
  130. data/spec/support/crud_tests/write/updateMany-arrayFilters.yml +1 -1
  131. data/spec/support/crud_tests/write/updateOne-arrayFilters.yml +1 -1
  132. data/spec/support/dns_seedlist_discovery_tests/longer-parent-in-return.yml +11 -0
  133. data/spec/support/dns_seedlist_discovery_tests/misformatted-option.yml +5 -0
  134. data/spec/support/dns_seedlist_discovery_tests/no-results.yml +5 -0
  135. data/spec/support/dns_seedlist_discovery_tests/not-enough-parts.yml +5 -0
  136. data/spec/support/dns_seedlist_discovery_tests/one-result-default-port.yml +10 -0
  137. data/spec/support/dns_seedlist_discovery_tests/one-txt-record-multiple-strings.yml +10 -0
  138. data/spec/support/dns_seedlist_discovery_tests/one-txt-record.yml +11 -0
  139. data/spec/support/dns_seedlist_discovery_tests/parent-part-mismatch1.yml +5 -0
  140. data/spec/support/dns_seedlist_discovery_tests/parent-part-mismatch2.yml +5 -0
  141. data/spec/support/dns_seedlist_discovery_tests/parent-part-mismatch3.yml +5 -0
  142. data/spec/support/dns_seedlist_discovery_tests/parent-part-mismatch4.yml +5 -0
  143. data/spec/support/dns_seedlist_discovery_tests/parent-part-mismatch5.yml +5 -0
  144. data/spec/support/dns_seedlist_discovery_tests/returned-parent-too-short.yml +5 -0
  145. data/spec/support/dns_seedlist_discovery_tests/returned-parent-wrong.yml +5 -0
  146. data/spec/support/dns_seedlist_discovery_tests/two-results-default-port.yml +11 -0
  147. data/spec/support/dns_seedlist_discovery_tests/two-results-nonstandard-port.yml +11 -0
  148. data/spec/support/dns_seedlist_discovery_tests/two-txt-records.yml +5 -0
  149. data/spec/support/dns_seedlist_discovery_tests/txt-record-not-allowed-option.yml +5 -0
  150. data/spec/support/dns_seedlist_discovery_tests/txt-record-with-overridden-ssl-option.yml +11 -0
  151. data/spec/support/dns_seedlist_discovery_tests/txt-record-with-overridden-uri-option.yml +11 -0
  152. data/spec/support/dns_seedlist_discovery_tests/txt-record-with-unallowed-option.yml +5 -0
  153. data/spec/support/dns_seedlist_discovery_tests/uri-with-port.yml +5 -0
  154. data/spec/support/dns_seedlist_discovery_tests/uri-with-two-hosts.yml +5 -0
  155. data/spec/support/retryable_writes_tests/bulkWrite.yml +305 -0
  156. data/spec/support/retryable_writes_tests/deleteOne.yml +51 -0
  157. data/spec/support/retryable_writes_tests/findOneAndDelete.yml +52 -0
  158. data/spec/support/retryable_writes_tests/findOneAndReplace.yml +57 -0
  159. data/spec/support/retryable_writes_tests/findOneAndUpdate.yml +56 -0
  160. data/spec/support/retryable_writes_tests/insertMany.yml +72 -0
  161. data/spec/support/retryable_writes_tests/insertOne.yml +55 -0
  162. data/spec/support/retryable_writes_tests/replaceOne.yml +60 -0
  163. data/spec/support/retryable_writes_tests/updateOne.yml +120 -0
  164. data/spec/support/shared/session.rb +525 -24
  165. metadata +437 -350
  166. metadata.gz.sig +0 -0
  167. data/lib/mongo/operation/commands/user_query.rb +0 -72
  168. data/lib/mongo/operation/write/create_index.rb +0 -67
  169. data/lib/mongo/operation/write/create_user.rb +0 -50
  170. data/lib/mongo/operation/write/drop_index.rb +0 -63
  171. data/lib/mongo/operation/write/remove_user.rb +0 -48
  172. data/lib/mongo/operation/write/update_user.rb +0 -50
@@ -1,9 +1,5 @@
1
1
  require 'spec_helper'
2
2
 
3
- def skippable?(file)
4
- !write_command_enabled? && (file.include?('bulkWrite') || file.include?('insert'))
5
- end
6
-
7
3
  def ignore?(test)
8
4
  if version = test.ignore_if_server_version_greater_than
9
5
  return true if version == "3.0" && find_command_enabled?
@@ -18,43 +14,41 @@ describe 'Command Monitoring Events' do
18
14
 
19
15
  COMMAND_MONITORING_TESTS.each do |file|
20
16
 
21
- if !skippable?(file)
22
17
 
23
- spec = Mongo::CommandMonitoring::Spec.new(file)
18
+ spec = Mongo::CommandMonitoring::Spec.new(file)
24
19
 
25
- spec.tests.each do |test|
20
+ spec.tests.each do |test|
26
21
 
27
- context(test.description) do
22
+ context(test.description) do
28
23
 
29
- let(:subscriber) do
30
- Mongo::CommandMonitoring::TestSubscriber.new
31
- end
24
+ let(:subscriber) do
25
+ Mongo::CommandMonitoring::TestSubscriber.new
26
+ end
32
27
 
33
- let(:monitoring) do
34
- authorized_client.instance_variable_get(:@monitoring)
35
- end
28
+ let(:monitoring) do
29
+ authorized_client.instance_variable_get(:@monitoring)
30
+ end
36
31
 
37
- before do
38
- authorized_collection.find.delete_many
39
- authorized_client.subscribe(Mongo::Monitoring::COMMAND, subscriber)
40
- end
32
+ before do
33
+ authorized_collection.find.delete_many
34
+ authorized_client.subscribe(Mongo::Monitoring::COMMAND, subscriber)
35
+ end
41
36
 
42
- after do
43
- monitoring.subscribers[Mongo::Monitoring::COMMAND].delete(subscriber)
44
- authorized_collection.find.delete_many
45
- end
37
+ after do
38
+ monitoring.subscribers[Mongo::Monitoring::COMMAND].delete(subscriber)
39
+ authorized_collection.find.delete_many
40
+ end
46
41
 
47
- test.expectations.each do |expectation|
42
+ test.expectations.each do |expectation|
48
43
 
49
- it "generates a #{expectation.event_name} for #{expectation.command_name}", unless: ignore?(test) do
50
- begin
51
- test.run(authorized_collection)
52
- event = subscriber.send(expectation.event_type)[expectation.command_name]
53
- expect(event).to send(expectation.matcher, expectation)
54
- rescue Mongo::Error::OperationFailure, Mongo::Error::BulkWriteError
55
- event = subscriber.send(expectation.event_type)[expectation.command_name]
56
- expect(event).to send(expectation.matcher, expectation)
57
- end
44
+ it "generates a #{expectation.event_name} for #{expectation.command_name}", unless: ignore?(test) do
45
+ begin
46
+ test.run(authorized_collection)
47
+ event = subscriber.send(expectation.event_type)[expectation.command_name]
48
+ expect(event).to send(expectation.matcher, expectation)
49
+ rescue Mongo::Error::OperationFailure, Mongo::Error::BulkWriteError
50
+ event = subscriber.send(expectation.event_type)[expectation.command_name]
51
+ expect(event).to send(expectation.matcher, expectation)
58
52
  end
59
53
  end
60
54
  end
@@ -13,7 +13,7 @@ describe 'CRUD' do
13
13
  context(test.description) do
14
14
 
15
15
  before(:each) do
16
- authorized_collection.delete_many
16
+ test.setup_test(authorized_collection)
17
17
  end
18
18
 
19
19
  after(:each) do
@@ -267,9 +267,8 @@ describe Mongo::Cursor do
267
267
  authorized_client.cluster.instance_variable_get(:@cursor_reaper)
268
268
  end
269
269
 
270
-
271
- it 'schedules a kill cursors op' do
272
- sleep(Mongo::Cluster::CursorReaper::FREQUENCY + 0.5)
270
+ it 'schedules a kill cursors op', unless: sessions_enabled? do
271
+ sleep(Mongo::Cluster::PeriodicExecutor::FREQUENCY)
273
272
  expect {
274
273
  cursor.to_a
275
274
  }.to raise_exception(Mongo::Error::OperationFailure)
@@ -208,7 +208,7 @@ describe Mongo::Database do
208
208
  described_class.new(authorized_client, 'invalid_database')
209
209
  end
210
210
 
211
- it 'returns an empty list', if: write_command_enabled? do
211
+ it 'returns an empty list' do
212
212
  expect(database.collections).to be_empty
213
213
  end
214
214
  end
@@ -241,22 +241,44 @@ describe Mongo::Database do
241
241
  expect(database.command({:ismaster => 1}.freeze).written_count).to eq(0)
242
242
  end
243
243
 
244
- context 'when provided a session' do
244
+ context 'when provided a session', if: sessions_enabled? do
245
245
 
246
246
  let(:operation) do
247
- database.command({ :ismaster => 1 }, session: session)
247
+ client.database.command({ :ismaster => 1 }, session: session)
248
248
  end
249
249
 
250
250
  let(:failed_operation) do
251
- database.command({ :invalid => 1 }, session: session)
251
+ client.database.command({ :invalid => 1 }, session: session)
252
+ end
253
+
254
+ let(:session) do
255
+ client.start_session
252
256
  end
253
257
 
254
258
  let(:client) do
255
- authorized_client
259
+ authorized_client.with(heartbeat_frequency: 100).tap do |cl|
260
+ cl.subscribe(Mongo::Monitoring::COMMAND, subscriber)
261
+ end
262
+ end
263
+
264
+ let(:subscriber) do
265
+ EventSubscriber.new
256
266
  end
257
267
 
258
268
  it_behaves_like 'an operation using a session'
259
269
  it_behaves_like 'a failed operation using a session'
270
+
271
+
272
+ let(:full_command) do
273
+ subscriber.started_events.find { |cmd| cmd.command_name == :ismaster }.command
274
+ end
275
+
276
+ it 'does not add a afterClusterTime field' do
277
+ # Ensure that the session has an operation time
278
+ client.database.command({ ping: 1 }, session: session)
279
+ operation
280
+ expect(full_command['readConcern']).to be_nil
281
+ end
260
282
  end
261
283
 
262
284
  context 'when a read concern is provided', if: find_command_enabled? do
@@ -396,7 +418,7 @@ describe Mongo::Database do
396
418
  described_class.new(authorized_client.with(client_options), TEST_DB)
397
419
  end
398
420
 
399
- context 'when a write concern is not in the command selector', if: write_command_enabled? do
421
+ context 'when a write concern is not in the command selector' do
400
422
 
401
423
  let(:cmd) do
402
424
  {
@@ -410,7 +432,7 @@ describe Mongo::Database do
410
432
  end
411
433
  end
412
434
 
413
- context 'when a write concern is provided in the command selector', if: write_command_enabled? && standalone? do
435
+ context 'when a write concern is provided in the command selector', if: standalone? do
414
436
 
415
437
  let(:cmd) do
416
438
  {
@@ -435,16 +457,10 @@ describe Mongo::Database do
435
457
  described_class.new(authorized_client, TEST_DB)
436
458
  end
437
459
 
438
- it 'drops the database', if: write_command_enabled? do
460
+ it 'drops the database' do
439
461
  expect(database.drop).to be_successful
440
462
  end
441
463
 
442
- it 'raises an exception', if: (!write_command_enabled? && auth_enabled?) do
443
- expect {
444
- database.drop
445
- }.to raise_error(Mongo::Error::OperationFailure)
446
- end
447
-
448
464
  context 'when provided a session' do
449
465
 
450
466
  let(:operation) do
@@ -0,0 +1,94 @@
1
+ require 'spec_helper'
2
+
3
+ describe 'DNS Seedlist Discovery' do
4
+ include Mongo::ConnectionString
5
+
6
+ before(:all) do
7
+
8
+ module Mongo
9
+ class Server
10
+ # The constructor keeps the same API, but does not instantiate a
11
+ # monitor and run it.
12
+ alias :original_initialize :initialize
13
+
14
+ def initialize(address, cluster, monitoring, event_listeners, options = {})
15
+ @address = address
16
+ @cluster = cluster
17
+ @monitoring = monitoring
18
+ @options = options.freeze
19
+ @monitor = Monitor.new(address, event_listeners, options)
20
+ end
21
+
22
+ # Disconnect simply needs to return true since we have no monitor and
23
+ # no connection.
24
+ alias :original_disconnect! :disconnect!
25
+
26
+ def disconnect!;
27
+ true;
28
+ end
29
+ end
30
+ end
31
+ end
32
+
33
+ after(:all) do
34
+
35
+ module Mongo
36
+ class Server
37
+ alias :initialize :original_initialize
38
+ remove_method(:original_initialize)
39
+
40
+ alias :disconnect! :original_disconnect!
41
+ remove_method(:original_disconnect!)
42
+ end
43
+ end
44
+ end
45
+
46
+ DNS_SEEDLIST_DISCOVERY_TESTS.each do |file_name|
47
+
48
+ file = File.new(file_name)
49
+ spec = YAML.load(ERB.new(file.read).result)
50
+ file.close
51
+
52
+ test = Mongo::ConnectionString::Test.new(spec)
53
+
54
+ context(File.basename(file_name)) do
55
+
56
+ context 'when the uri is invalid', if: test.raise_error? do
57
+
58
+ let(:valid_errors) do
59
+ [
60
+ Mongo::Error::InvalidTXTRecord,
61
+ Mongo::Error::NoSRVRecords,
62
+ Mongo::Error::InvalidURI,
63
+ Mongo::Error::MismatchedDomain,
64
+ ]
65
+ end
66
+
67
+ let(:error) do
68
+ e = nil
69
+ begin; test.uri; rescue => ex; e = ex; end
70
+ e
71
+ end
72
+
73
+ it 'raises an error' do
74
+ expect(valid_errors).to include(error.class)
75
+ end
76
+ end
77
+
78
+ context 'when the uri is valid', unless: test.raise_error? do
79
+
80
+ it 'does not raise an exception' do
81
+ expect(test.uri).to be_a(Mongo::URI::SRVProtocol)
82
+ end
83
+
84
+ it 'creates a client with the correct hosts' do
85
+ expect(test.client).to have_hosts(test)
86
+ end
87
+
88
+ it 'creates a client with the correct options' do
89
+ expect(test.client).to match_options(test)
90
+ end
91
+ end
92
+ end
93
+ end
94
+ end
@@ -339,7 +339,7 @@ describe Mongo::Grid::FSBucket do
339
339
  end
340
340
  end
341
341
 
342
- context 'when the index creation encounters an error', if: write_command_enabled? do
342
+ context 'when the index creation encounters an error' do
343
343
 
344
344
  before do
345
345
  fs.chunks_collection.drop
@@ -275,7 +275,7 @@ describe Mongo::Grid::FSBucket::Stream::Write do
275
275
  end
276
276
  end
277
277
 
278
- context 'when the index creation encounters an error', if: write_command_enabled? do
278
+ context 'when the index creation encounters an error' do
279
279
 
280
280
  before do
281
281
  fs.chunks_collection.drop
@@ -347,18 +347,8 @@ describe Mongo::Index::View do
347
347
 
348
348
  context 'when the server does not accept writeConcern for the createIndexes operation', unless: collation_enabled? do
349
349
 
350
- context 'when the server supports the createIndexes command', if: write_command_enabled? do
351
-
352
- it 'does not apply the write concern' do
353
- expect(result).to be_successful
354
- end
355
- end
356
-
357
- context 'when the driver inserts into the system.indexes collection', unless: write_command_enabled? do
358
-
359
- it 'does not apply the write concern' do
360
- expect(result).to be_successful
361
- end
350
+ it 'does not apply the write concern' do
351
+ expect(result).to be_successful
362
352
  end
363
353
  end
364
354
  end
@@ -502,18 +492,8 @@ describe Mongo::Index::View do
502
492
 
503
493
  context 'when the server does not accept writeConcern for the createIndexes operation', unless: collation_enabled? do
504
494
 
505
- context 'when the server accepts the createIndexes command', if: write_command_enabled? do
506
-
507
- it 'does not apply the write concern' do
508
- expect(result).to be_successful
509
- end
510
- end
511
-
512
- context 'when the driver inserts into the system.indexes collection', unless: write_command_enabled? do
513
-
514
- it 'does not apply the write concern' do
515
- expect(result).to be_successful
516
- end
495
+ it 'does not apply the write concern' do
496
+ expect(result).to be_successful
517
497
  end
518
498
  end
519
499
  end
@@ -533,15 +513,11 @@ describe Mongo::Index::View do
533
513
  view.drop_one('name_1')
534
514
  end
535
515
 
536
- it 'raises an exception', if: write_command_enabled? do
516
+ it 'raises an exception' do
537
517
  expect {
538
518
  view.create_many([{ key: { name: 1 }, unique: false }])
539
519
  }.to raise_error(Mongo::Error::OperationFailure)
540
520
  end
541
-
542
- it 'does not raise an exception', unless: write_command_enabled? do
543
- expect(view.create_many([{ key: { name: 1 }, unique: false }])).to be_successful
544
- end
545
521
  end
546
522
  end
547
523
  end
@@ -613,18 +589,8 @@ describe Mongo::Index::View do
613
589
 
614
590
  context 'when the server does not accept writeConcern for the createIndexes operation', unless: collation_enabled? do
615
591
 
616
- context 'when the server supports the createIndexes command', if: write_command_enabled? do
617
-
618
- it 'does not apply the write concern' do
619
- expect(result).to be_successful
620
- end
621
- end
622
-
623
- context 'when the driver inserts into the system.indexes collection', unless: write_command_enabled? do
624
-
625
- it 'does not apply the write concern' do
626
- expect(result).to be_successful
627
- end
592
+ it 'does not apply the write concern' do
593
+ expect(result).to be_successful
628
594
  end
629
595
  end
630
596
  end
@@ -667,15 +633,11 @@ describe Mongo::Index::View do
667
633
  view.drop_one('name_1')
668
634
  end
669
635
 
670
- it 'raises an exception', if: write_command_enabled? do
636
+ it 'raises an exception' do
671
637
  expect {
672
638
  view.create_one(spec, unique: false)
673
639
  }.to raise_error(Mongo::Error::OperationFailure)
674
640
  end
675
-
676
- it 'does not raise an exception', unless: write_command_enabled? do
677
- expect(view.create_one(spec, unique: false)).to be_successful
678
- end
679
641
  end
680
642
 
681
643
  context 'when providing an index name' do
@@ -125,7 +125,7 @@ describe Mongo::Operation::Write::Bulk::Delete do
125
125
  context 'when the deletes are ordered' do
126
126
 
127
127
  let(:documents) do
128
- [ failing_delete_doc,
128
+ [ { q: { '$set' => { a: 1 } }, limit: 0 },
129
129
  { 'q' => { field: 'test' }, 'limit' => 1 }
130
130
  ]
131
131
  end
@@ -174,7 +174,7 @@ describe Mongo::Operation::Write::Bulk::Delete do
174
174
  context 'when the deletes are unordered' do
175
175
 
176
176
  let(:documents) do
177
- [ failing_delete_doc,
177
+ [ { q: { '$set' => { a: 1 } }, limit: 0 },
178
178
  { 'q' => { field: 'test' }, 'limit' => 1 }
179
179
  ]
180
180
  end
@@ -119,13 +119,9 @@ describe Mongo::Operation::Write::Bulk::Insert do
119
119
  op.execute(authorized_primary)
120
120
  end
121
121
 
122
- it 'inserts the documents into the database', if: write_command_enabled? do
122
+ it 'inserts the documents into the database' do
123
123
  expect(response.written_count).to eq(1)
124
124
  end
125
-
126
- it 'inserts the documents into the database', unless: write_command_enabled? do
127
- expect(response.written_count).to eq(0)
128
- end
129
125
  end
130
126
  end
131
127
 
@@ -141,13 +137,9 @@ describe Mongo::Operation::Write::Bulk::Insert do
141
137
  op.execute(authorized_primary)
142
138
  end
143
139
 
144
- it 'inserts the documents into the database', if: write_command_enabled? do
140
+ it 'inserts the documents into the database' do
145
141
  expect(response.written_count).to eq(2)
146
142
  end
147
-
148
- it 'inserts the documents into the database', unless: write_command_enabled? do
149
- expect(response.written_count).to eq(0)
150
- end
151
143
  end
152
144
  end
153
145