mongo 2.9.2 → 2.10.0.rc0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (227) 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.rb +1 -0
  5. data/lib/mongo/auth/user/view.rb +4 -4
  6. data/lib/mongo/bulk_write.rb +14 -8
  7. data/lib/mongo/bulk_write/result.rb +1 -1
  8. data/lib/mongo/bulk_write/result_combiner.rb +2 -2
  9. data/lib/mongo/bulk_write/transformable.rb +17 -9
  10. data/lib/mongo/client.rb +107 -16
  11. data/lib/mongo/cluster.rb +47 -25
  12. data/lib/mongo/cluster/topology/replica_set_no_primary.rb +1 -1
  13. data/lib/mongo/cluster_time.rb +139 -0
  14. data/lib/mongo/collection.rb +84 -25
  15. data/lib/mongo/collection/view.rb +7 -3
  16. data/lib/mongo/collection/view/aggregation.rb +4 -4
  17. data/lib/mongo/collection/view/builder/aggregation.rb +31 -6
  18. data/lib/mongo/collection/view/builder/find_command.rb +4 -1
  19. data/lib/mongo/collection/view/builder/map_reduce.rb +4 -1
  20. data/lib/mongo/collection/view/change_stream.rb +54 -66
  21. data/lib/mongo/collection/view/iterable.rb +2 -2
  22. data/lib/mongo/collection/view/map_reduce.rb +6 -4
  23. data/lib/mongo/collection/view/readable.rb +36 -16
  24. data/lib/mongo/collection/view/writable.rb +68 -22
  25. data/lib/mongo/cursor.rb +87 -20
  26. data/lib/mongo/database.rb +47 -43
  27. data/lib/mongo/database/view.rb +54 -11
  28. data/lib/mongo/error.rb +13 -4
  29. data/lib/mongo/error/invalid_write_concern.rb +2 -2
  30. data/lib/mongo/error/operation_failure.rb +65 -11
  31. data/lib/mongo/error/parser.rb +41 -8
  32. data/lib/mongo/grid/fs_bucket.rb +26 -6
  33. data/lib/mongo/grid/stream/read.rb +9 -2
  34. data/lib/mongo/grid/stream/write.rb +21 -5
  35. data/lib/mongo/index/view.rb +3 -3
  36. data/lib/mongo/lint.rb +10 -3
  37. data/lib/mongo/operation.rb +2 -0
  38. data/lib/mongo/operation/aggregate/result.rb +19 -6
  39. data/lib/mongo/operation/collections_info.rb +1 -1
  40. data/lib/mongo/operation/get_more/result.rb +9 -0
  41. data/lib/mongo/operation/list_collections/command.rb +1 -3
  42. data/lib/mongo/operation/list_collections/op_msg.rb +1 -2
  43. data/lib/mongo/operation/parallel_scan/command.rb +4 -1
  44. data/lib/mongo/operation/parallel_scan/op_msg.rb +4 -1
  45. data/lib/mongo/operation/result.rb +27 -4
  46. data/lib/mongo/operation/shared/executable.rb +19 -5
  47. data/lib/mongo/operation/shared/executable_no_validate.rb +1 -2
  48. data/lib/mongo/operation/shared/executable_transaction_label.rb +0 -9
  49. data/lib/mongo/operation/shared/polymorphic_result.rb +9 -1
  50. data/lib/mongo/operation/shared/result/aggregatable.rb +2 -2
  51. data/lib/mongo/operation/shared/sessions_supported.rb +42 -32
  52. data/lib/mongo/operation/shared/specifiable.rb +40 -0
  53. data/lib/mongo/operation/shared/unpinnable.rb +39 -0
  54. data/lib/mongo/operation/shared/write.rb +1 -1
  55. data/lib/mongo/protocol/update.rb +6 -2
  56. data/lib/mongo/retryable.rb +79 -39
  57. data/lib/mongo/server/connection.rb +10 -3
  58. data/lib/mongo/server/description.rb +25 -1
  59. data/lib/mongo/server/monitor/connection.rb +1 -1
  60. data/lib/mongo/server_selector.rb +10 -0
  61. data/lib/mongo/server_selector/selectable.rb +172 -32
  62. data/lib/mongo/session.rb +654 -581
  63. data/lib/mongo/session/session_pool.rb +1 -1
  64. data/lib/mongo/socket.rb +7 -28
  65. data/lib/mongo/socket/ssl.rb +26 -1
  66. data/lib/mongo/socket/tcp.rb +3 -0
  67. data/lib/mongo/socket/unix.rb +3 -0
  68. data/lib/mongo/uri.rb +112 -265
  69. data/lib/mongo/uri/srv_protocol.rb +4 -1
  70. data/lib/mongo/version.rb +1 -1
  71. data/lib/mongo/write_concern.rb +10 -29
  72. data/lib/mongo/write_concern/acknowledged.rb +12 -0
  73. data/lib/mongo/write_concern/base.rb +17 -13
  74. data/lib/mongo/write_concern/unacknowledged.rb +12 -0
  75. data/spec/atlas/atlas_connectivity_spec.rb +7 -37
  76. data/spec/atlas/operations_spec.rb +25 -0
  77. data/spec/integration/change_stream_examples_spec.rb +45 -31
  78. data/spec/integration/change_stream_spec.rb +305 -5
  79. data/spec/integration/client_spec.rb +44 -0
  80. data/spec/integration/command_monitoring_spec.rb +1 -0
  81. data/spec/integration/command_spec.rb +7 -1
  82. data/spec/integration/mmapv1_spec.rb +28 -0
  83. data/spec/integration/mongos_pinning_spec.rb +34 -0
  84. data/spec/integration/operation_failure_code_spec.rb +2 -2
  85. data/spec/integration/{read_concern.rb → read_concern_spec.rb} +7 -1
  86. data/spec/integration/read_preference_spec.rb +485 -0
  87. data/spec/integration/retryable_writes_spec.rb +8 -19
  88. data/spec/integration/sdam_error_handling_spec.rb +1 -1
  89. data/spec/integration/sdam_events_spec.rb +2 -2
  90. data/spec/integration/server_description_spec.rb +14 -17
  91. data/spec/integration/server_selector_spec.rb +7 -3
  92. data/spec/integration/server_spec.rb +48 -0
  93. data/spec/integration/ssl_uri_options_spec.rb +1 -1
  94. data/spec/integration/step_down_spec.rb +10 -4
  95. data/spec/integration/transactions_examples_spec.rb +11 -10
  96. data/spec/lite_spec_helper.rb +19 -16
  97. data/spec/mongo/auth/scram/negotiation_spec.rb +11 -8
  98. data/spec/mongo/bulk_write/ordered_combiner_spec.rb +6 -6
  99. data/spec/mongo/bulk_write/unordered_combiner_spec.rb +4 -4
  100. data/spec/mongo/bulk_write_spec.rb +12 -2
  101. data/spec/mongo/client_construction_spec.rb +160 -8
  102. data/spec/mongo/client_spec.rb +5 -4
  103. data/spec/mongo/cluster_spec.rb +6 -6
  104. data/spec/mongo/cluster_time_spec.rb +148 -0
  105. data/spec/mongo/collection/view/aggregation_spec.rb +34 -15
  106. data/spec/mongo/collection/view/change_stream_spec.rb +62 -3
  107. data/spec/mongo/collection/view/map_reduce_spec.rb +7 -5
  108. data/spec/mongo/collection/view/readable_spec.rb +4 -4
  109. data/spec/mongo/collection_spec.rb +331 -14
  110. data/spec/mongo/cursor_spec.rb +117 -5
  111. data/spec/mongo/database_spec.rb +240 -8
  112. data/spec/mongo/error/operation_failure_spec.rb +47 -1
  113. data/spec/mongo/error/parser_spec.rb +160 -23
  114. data/spec/mongo/operation/insert/bulk_spec.rb +2 -1
  115. data/spec/mongo/operation/result_spec.rb +27 -0
  116. data/spec/mongo/operation/update/bulk_spec.rb +1 -0
  117. data/spec/mongo/retryable_spec.rb +2 -0
  118. data/spec/mongo/server/app_metadata_spec.rb +2 -2
  119. data/spec/mongo/server/connection_spec.rb +13 -17
  120. data/spec/mongo/server/monitor/connection_spec.rb +13 -10
  121. data/spec/mongo/server_selector_spec.rb +34 -2
  122. data/spec/mongo/session/session_pool_spec.rb +14 -3
  123. data/spec/mongo/session_spec.rb +3 -3
  124. data/spec/mongo/session_transaction_spec.rb +4 -3
  125. data/spec/mongo/socket/ssl_spec.rb +19 -5
  126. data/spec/mongo/socket_spec.rb +1 -62
  127. data/spec/mongo/uri/srv_protocol_spec.rb +14 -20
  128. data/spec/mongo/uri_option_parsing_spec.rb +94 -8
  129. data/spec/mongo/uri_spec.rb +23 -10
  130. data/spec/mongo/write_concern_spec.rb +56 -3
  131. data/spec/spec_tests/change_streams_spec.rb +2 -1
  132. data/spec/spec_tests/cmap_spec.rb +1 -1
  133. data/spec/spec_tests/crud_spec.rb +12 -2
  134. data/spec/spec_tests/data/change_streams/change-streams-errors.yml +24 -1
  135. data/spec/spec_tests/data/change_streams/change-streams.yml +172 -3
  136. data/spec/spec_tests/data/command_monitoring/bulkWrite.yml +1 -1
  137. data/spec/spec_tests/data/command_monitoring/updateMany.yml +0 -2
  138. data/spec/spec_tests/data/command_monitoring/updateOne.yml +0 -5
  139. data/spec/spec_tests/data/crud/read/aggregate-out.yml +0 -6
  140. data/spec/spec_tests/data/crud/read/count-empty.yml +29 -0
  141. data/spec/spec_tests/data/crud/write/bulkWrite-arrayFilters.yml +1 -0
  142. data/spec/spec_tests/data/crud/write/bulkWrite-collation.yml +101 -0
  143. data/spec/spec_tests/data/crud/write/bulkWrite.yml +401 -0
  144. data/spec/spec_tests/data/crud/write/insertMany.yml +58 -2
  145. data/spec/spec_tests/data/crud/write/updateMany-arrayFilters.yml +3 -0
  146. data/spec/spec_tests/data/crud/write/updateOne-arrayFilters.yml +6 -1
  147. data/spec/spec_tests/data/crud_v2/aggregate-merge.yml +103 -0
  148. data/spec/spec_tests/data/crud_v2/aggregate-out-readConcern.yml +110 -0
  149. data/spec/spec_tests/data/crud_v2/bulkWrite-arrayFilters.yml +81 -0
  150. data/spec/spec_tests/data/crud_v2/db-aggregate.yml +38 -0
  151. data/spec/spec_tests/data/crud_v2/updateWithPipelines.yml +92 -0
  152. data/spec/spec_tests/data/retryable_writes/insertOne-serverErrors.yml +2 -2
  153. data/spec/spec_tests/data/transactions/abort.yml +3 -0
  154. data/spec/spec_tests/data/transactions/bulk.yml +3 -8
  155. data/spec/spec_tests/data/transactions/causal-consistency.yml +3 -8
  156. data/spec/spec_tests/data/transactions/commit.yml +3 -1
  157. data/spec/spec_tests/data/transactions/count.yml +3 -0
  158. data/spec/spec_tests/data/transactions/delete.yml +3 -0
  159. data/spec/spec_tests/data/transactions/error-labels.yml +4 -1
  160. data/spec/spec_tests/data/transactions/errors-client.yml +56 -0
  161. data/spec/spec_tests/data/transactions/errors.yml +3 -0
  162. data/spec/spec_tests/data/transactions/findOneAndDelete.yml +3 -0
  163. data/spec/spec_tests/data/transactions/findOneAndReplace.yml +3 -0
  164. data/spec/spec_tests/data/transactions/findOneAndUpdate.yml +3 -0
  165. data/spec/spec_tests/data/transactions/insert.yml +3 -0
  166. data/spec/spec_tests/data/transactions/isolation.yml +3 -0
  167. data/spec/spec_tests/data/transactions/mongos-pin-auto.yml +1671 -0
  168. data/spec/spec_tests/data/transactions/mongos-recovery-token.yml +347 -0
  169. data/spec/spec_tests/data/transactions/pin-mongos.yml +557 -0
  170. data/spec/spec_tests/data/transactions/read-concern.yml +3 -0
  171. data/spec/spec_tests/data/transactions/read-pref.yml +3 -0
  172. data/spec/spec_tests/data/transactions/reads.yml +3 -0
  173. data/spec/spec_tests/data/transactions/retryable-abort.yml +5 -2
  174. data/spec/spec_tests/data/transactions/retryable-commit.yml +4 -1
  175. data/spec/spec_tests/data/transactions/retryable-writes.yml +3 -0
  176. data/spec/spec_tests/data/transactions/run-command.yml +3 -0
  177. data/spec/spec_tests/data/transactions/transaction-options.yml +6 -0
  178. data/spec/spec_tests/data/transactions/update.yml +3 -8
  179. data/spec/spec_tests/data/transactions/write-concern.yml +348 -38
  180. data/spec/spec_tests/data/transactions_api/callback-aborts.yml +6 -0
  181. data/spec/spec_tests/data/transactions_api/callback-commits.yml +5 -0
  182. data/spec/spec_tests/data/transactions_api/callback-retry.yml +7 -2
  183. data/spec/spec_tests/data/transactions_api/commit-retry.yml +70 -15
  184. data/spec/spec_tests/data/transactions_api/commit-transienttransactionerror-4.2.yml +3 -0
  185. data/spec/spec_tests/data/transactions_api/commit-transienttransactionerror.yml +3 -0
  186. data/spec/spec_tests/data/transactions_api/commit-writeconcernerror.yml +59 -109
  187. data/spec/spec_tests/data/transactions_api/commit.yml +5 -0
  188. data/spec/spec_tests/data/transactions_api/transaction-options.yml +10 -0
  189. data/spec/spec_tests/retryable_reads_spec.rb +5 -2
  190. data/spec/spec_tests/retryable_writes_spec.rb +5 -2
  191. data/spec/spec_tests/sdam_monitoring_spec.rb +3 -3
  192. data/spec/spec_tests/sdam_spec.rb +2 -2
  193. data/spec/spec_tests/transactions_api_spec.rb +1 -67
  194. data/spec/spec_tests/transactions_spec.rb +2 -66
  195. data/spec/support/authorization.rb +4 -0
  196. data/spec/support/change_streams.rb +30 -10
  197. data/spec/support/change_streams/operation.rb +27 -0
  198. data/spec/support/client_registry.rb +44 -25
  199. data/spec/support/cluster_config.rb +25 -14
  200. data/spec/support/cluster_tools.rb +32 -10
  201. data/spec/support/command_monitoring.rb +1 -1
  202. data/spec/support/common_shortcuts.rb +30 -0
  203. data/spec/support/connection_string.rb +8 -3
  204. data/spec/support/constraints.rb +34 -0
  205. data/spec/support/crud.rb +31 -16
  206. data/spec/support/crud/context.rb +23 -0
  207. data/spec/support/crud/operation.rb +311 -14
  208. data/spec/support/crud/spec.rb +2 -1
  209. data/spec/support/crud/test.rb +24 -27
  210. data/spec/support/crud/test_base.rb +22 -0
  211. data/spec/support/crud/verifier.rb +15 -1
  212. data/spec/support/event_subscriber.rb +12 -0
  213. data/spec/support/sdam_formatter_integration.rb +12 -6
  214. data/spec/support/shared/server_selector.rb +10 -0
  215. data/spec/support/shared/session.rb +13 -12
  216. data/spec/support/spec_config.rb +32 -22
  217. data/spec/support/spec_setup.rb +2 -2
  218. data/spec/support/transactions.rb +87 -0
  219. data/spec/support/transactions/context.rb +33 -0
  220. data/spec/support/transactions/operation.rb +99 -349
  221. data/spec/support/transactions/spec.rb +1 -3
  222. data/spec/support/transactions/test.rb +110 -49
  223. data/spec/support/utils.rb +74 -1
  224. metadata +52 -10
  225. metadata.gz.sig +0 -0
  226. data/spec/support/crud/read.rb +0 -265
  227. data/spec/support/crud/write.rb +0 -284
@@ -262,6 +262,19 @@ describe Mongo::URI do
262
262
  end
263
263
  end
264
264
 
265
+ context 'options start with ampersand' do
266
+
267
+ let(:string) { 'mongodb://example.com/?&appName=foo' }
268
+
269
+ it 'returns a Mongo::URI object' do
270
+ expect(uri).to be_a(Mongo::URI)
271
+ end
272
+
273
+ it 'parses the options' do
274
+ expect(uri.uri_options[:app_name]).to eq('foo')
275
+ end
276
+ end
277
+
265
278
  context 'mongodb://alice:foo:bar@127.0.0.1' do
266
279
 
267
280
  let(:string) { 'mongodb://alice:foo:bar@127.0.0.1' }
@@ -444,12 +457,12 @@ describe Mongo::URI do
444
457
  let(:concern) { Mongo::Options::Redacted.new(:w => 1)}
445
458
 
446
459
  it 'sets the write concern options' do
447
- expect(uri.uri_options[:write]).to eq(concern)
460
+ expect(uri.uri_options[:write_concern]).to eq(concern)
448
461
  end
449
462
 
450
463
  it 'sets the options on a client created with the uri' do
451
464
  client = new_local_client_nmio(string)
452
- expect(client.options[:write]).to eq(concern)
465
+ expect(client.options[:write_concern]).to eq(concern)
453
466
  end
454
467
  end
455
468
 
@@ -458,12 +471,12 @@ describe Mongo::URI do
458
471
  let(:concern) { Mongo::Options::Redacted.new(:w => :majority) }
459
472
 
460
473
  it 'sets the write concern options' do
461
- expect(uri.uri_options[:write]).to eq(concern)
474
+ expect(uri.uri_options[:write_concern]).to eq(concern)
462
475
  end
463
476
 
464
477
  it 'sets the options on a client created with the uri' do
465
478
  client = new_local_client_nmio(string)
466
- expect(client.options[:write]).to eq(concern)
479
+ expect(client.options[:write_concern]).to eq(concern)
467
480
  end
468
481
  end
469
482
 
@@ -472,12 +485,12 @@ describe Mongo::URI do
472
485
  let(:concern) { Mongo::Options::Redacted.new(:j => true) }
473
486
 
474
487
  it 'sets the write concern options' do
475
- expect(uri.uri_options[:write]).to eq(concern)
488
+ expect(uri.uri_options[:write_concern]).to eq(concern)
476
489
  end
477
490
 
478
491
  it 'sets the options on a client created with the uri' do
479
492
  client = new_local_client_nmio(string)
480
- expect(client.options[:write]).to eq(concern)
493
+ expect(client.options[:write_concern]).to eq(concern)
481
494
  end
482
495
  end
483
496
 
@@ -486,12 +499,12 @@ describe Mongo::URI do
486
499
  let(:concern) { Mongo::Options::Redacted.new(:fsync => true) }
487
500
 
488
501
  it 'sets the write concern options' do
489
- expect(uri.uri_options[:write]).to eq(concern)
502
+ expect(uri.uri_options[:write_concern]).to eq(concern)
490
503
  end
491
504
 
492
505
  it 'sets the options on a client created with the uri' do
493
506
  client = new_local_client_nmio(string)
494
- expect(client.options[:write]).to eq(concern)
507
+ expect(client.options[:write_concern]).to eq(concern)
495
508
  end
496
509
  end
497
510
 
@@ -501,12 +514,12 @@ describe Mongo::URI do
501
514
  let(:concern) { Mongo::Options::Redacted.new(:w => 2, :wtimeout => timeout) }
502
515
 
503
516
  it 'sets the write concern options' do
504
- expect(uri.uri_options[:write]).to eq(concern)
517
+ expect(uri.uri_options[:write_concern]).to eq(concern)
505
518
  end
506
519
 
507
520
  it 'sets the options on a client created with the uri' do
508
521
  client = new_local_client_nmio(string)
509
- expect(client.options[:write]).to eq(concern)
522
+ expect(client.options[:write_concern]).to eq(concern)
510
523
  end
511
524
  end
512
525
  end
@@ -4,6 +4,8 @@ describe Mongo::WriteConcern do
4
4
 
5
5
  describe '#get' do
6
6
 
7
+ let(:wc) { Mongo::WriteConcern.get(options) }
8
+
7
9
  context 'when no options are set' do
8
10
 
9
11
  let(:options) do
@@ -70,6 +72,19 @@ describe Mongo::WriteConcern do
70
72
  Mongo::WriteConcern.get(options)
71
73
  }.to raise_error(Mongo::Error::InvalidWriteConcern)
72
74
  end
75
+
76
+ context 'when j is given as a string' do
77
+
78
+ let(:options) do
79
+ { w: 0, 'j' => true }
80
+ end
81
+
82
+ it 'raises an exception' do
83
+ expect {
84
+ Mongo::WriteConcern.get(options)
85
+ }.to raise_error(Mongo::Error::InvalidWriteConcern)
86
+ end
87
+ end
73
88
  end
74
89
 
75
90
  context 'when fsync is true' do
@@ -114,7 +129,7 @@ describe Mongo::WriteConcern do
114
129
  context 'when w is greater than 0' do
115
130
 
116
131
  let(:options) do
117
- { w: 2, journal: true }
132
+ { w: 2, j: true }
118
133
  end
119
134
 
120
135
  it 'returns an Acknowledged write concern object' do
@@ -129,7 +144,7 @@ describe Mongo::WriteConcern do
129
144
  context 'when w is a string' do
130
145
 
131
146
  let(:options) do
132
- { w: 'majority', journal: true }
147
+ { w: 'majority', j: true }
133
148
  end
134
149
 
135
150
  it 'returns an Acknowledged write concern object' do
@@ -144,7 +159,7 @@ describe Mongo::WriteConcern do
144
159
  context 'when w is a symbol' do
145
160
 
146
161
  let(:options) do
147
- { w: :majority, journal: true }
162
+ { w: :majority, j: true }
148
163
  end
149
164
 
150
165
  it 'returns an Acknowledged write concern object' do
@@ -155,5 +170,43 @@ describe Mongo::WriteConcern do
155
170
  expect(Mongo::WriteConcern.get(options).options[:w]).to eq('majority')
156
171
  end
157
172
  end
173
+
174
+ context 'when options are provided with string keys' do
175
+
176
+ context 'acknowledged write concern' do
177
+ let(:options) do
178
+ { 'w' => 2, 'j' => true }
179
+ end
180
+
181
+ it 'converts keys to symbols' do
182
+ expect(wc).to be_a(Mongo::WriteConcern::Acknowledged)
183
+ expect(wc.options[:w]).to eq(2)
184
+ expect(wc.options[:j]).to be true
185
+ end
186
+ end
187
+
188
+ context 'unacknowledged write concern' do
189
+ let(:options) do
190
+ { 'w' => 0 }
191
+ end
192
+
193
+ it 'converts keys to symbols' do
194
+ expect(wc).to be_a(Mongo::WriteConcern::Unacknowledged)
195
+ expect(wc.options[:w]).to eq(0)
196
+ end
197
+ end
198
+ end
199
+
200
+ context 'when :journal option is given' do
201
+ let(:options) do
202
+ { 'w' => 1, journal: true }
203
+ end
204
+
205
+ it 'raises an exception' do
206
+ expect do
207
+ wc
208
+ end.to raise_error(Mongo::Error::InvalidWriteConcern, /use :j for journal/)
209
+ end
210
+ end
158
211
  end
159
212
  end
@@ -1,6 +1,7 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe 'ChangeStreams' do
4
+ require_wired_tiger
4
5
 
5
6
  CHANGE_STREAMS_TESTS.each do |file|
6
7
 
@@ -29,7 +30,7 @@ describe 'ChangeStreams' do
29
30
  expect(result[:result]).to match_result(test)
30
31
  end
31
32
 
32
- it 'has the correct command_started events' do
33
+ it 'has the correct command_started events', if: test.expectations do
33
34
  expect(result[:events]).to match_commands(test)
34
35
  end
35
36
  end
@@ -11,7 +11,7 @@ describe 'Cmap' do
11
11
  end
12
12
  end
13
13
 
14
- CMAP_TESTS.sort.each do |file|
14
+ CMAP_TESTS.each do |file|
15
15
  spec = Mongo::Cmap::Spec.new(file)
16
16
 
17
17
  context("#{spec.description} (#{file.sub(%r'.*/data/cmap/', '')})") do
@@ -1,7 +1,17 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe do
4
- define_crud_spec_tests('CRUD spec tests', CRUD_TESTS.sort) do |spec, req, test|
3
+ describe 'CRUD v1 spec tests' do
4
+ define_crud_spec_tests(CRUD_TESTS) do |spec, req, test|
5
5
  let(:client) { authorized_client }
6
6
  end
7
7
  end
8
+
9
+ describe 'CRUD v2 spec tests' do
10
+ define_crud_spec_tests(CRUD2_TESTS) do |spec, req, test|
11
+ let(:client) do
12
+ authorized_client.tap do |client|
13
+ client.subscribe(Mongo::Monitoring::COMMAND, event_subscriber)
14
+ end
15
+ end
16
+ end
17
+ end
@@ -50,4 +50,27 @@ tests:
50
50
  database_name: *database_name
51
51
  result:
52
52
  error:
53
- code: 40324
53
+ code: 40324
54
+ -
55
+ description: Change Stream should error when _id is projected out
56
+ minServerVersion: "4.1.11"
57
+ target: collection
58
+ topology:
59
+ - replicaset
60
+ - sharded
61
+ changeStreamPipeline:
62
+ -
63
+ $project: { _id: 0 }
64
+ changeStreamOptions: {}
65
+ operations:
66
+ -
67
+ database: *database_name
68
+ collection: *collection_name
69
+ name: insertOne
70
+ arguments:
71
+ document:
72
+ z: 3
73
+ result:
74
+ error:
75
+ code: 280
76
+ errorLabels: [ "NonResumableChangeStreamError" ]
@@ -20,19 +20,29 @@ tests:
20
20
  document:
21
21
  x: 1
22
22
  expectations:
23
- -
23
+ -
24
24
  command_started_event:
25
25
  command:
26
26
  aggregate: *collection_name
27
27
  cursor: {}
28
28
  pipeline:
29
- -
29
+ -
30
30
  $changeStream:
31
31
  fullDocument: default
32
32
  command_name: aggregate
33
33
  database_name: *database_name
34
34
  result:
35
- success: []
35
+ success:
36
+ -
37
+ _id: "42"
38
+ documentKey: "42"
39
+ operationType: insert
40
+ ns:
41
+ db: *database_name
42
+ coll: *collection_name
43
+ fullDocument:
44
+ x:
45
+ $numberInt: "1"
36
46
  -
37
47
  description: The server returns change stream responses in the specified server response format
38
48
  minServerVersion: "3.6.0"
@@ -297,3 +307,162 @@ tests:
297
307
  fullDocument:
298
308
  z:
299
309
  $numberInt: "3"
310
+ -
311
+ description: Test insert, update, replace, and delete event types
312
+ minServerVersion: "3.6.0"
313
+ target: collection
314
+ topology:
315
+ - replicaset
316
+ changeStreamPipeline: []
317
+ changeStreamOptions: {}
318
+ operations:
319
+ -
320
+ database: *database_name
321
+ collection: *collection_name
322
+ name: insertOne
323
+ arguments:
324
+ document:
325
+ x: 1
326
+ -
327
+ database: *database_name
328
+ collection: *collection_name
329
+ name: updateOne
330
+ arguments:
331
+ filter:
332
+ x: 1
333
+ update:
334
+ $set:
335
+ x: 2
336
+ -
337
+ database: *database_name
338
+ collection: *collection_name
339
+ name: replaceOne
340
+ arguments:
341
+ filter:
342
+ x: 2
343
+ replacement:
344
+ x: 3
345
+ -
346
+ database: *database_name
347
+ collection: *collection_name
348
+ name: deleteOne
349
+ arguments:
350
+ filter:
351
+ x: 3
352
+ expectations:
353
+ -
354
+ command_started_event:
355
+ command:
356
+ aggregate: *collection_name
357
+ cursor: {}
358
+ pipeline:
359
+ -
360
+ $changeStream:
361
+ fullDocument: default
362
+ command_name: aggregate
363
+ database_name: *database_name
364
+ result:
365
+ success:
366
+ -
367
+ operationType: insert
368
+ ns:
369
+ db: *database_name
370
+ coll: *collection_name
371
+ fullDocument:
372
+ x:
373
+ $numberInt: "1"
374
+ -
375
+ operationType: update
376
+ ns:
377
+ db: *database_name
378
+ coll: *collection_name
379
+ updateDescription:
380
+ updatedFields:
381
+ x:
382
+ $numberInt: "2"
383
+ -
384
+ operationType: replace
385
+ ns:
386
+ db: *database_name
387
+ coll: *collection_name
388
+ fullDocument:
389
+ x:
390
+ $numberInt: "3"
391
+ -
392
+ operationType: delete
393
+ ns:
394
+ db: *database_name
395
+ coll: *collection_name
396
+ -
397
+ description: Test rename and invalidate event types
398
+ minServerVersion: "4.0.1"
399
+ target: collection
400
+ topology:
401
+ - replicaset
402
+ changeStreamPipeline: []
403
+ changeStreamOptions: {}
404
+ operations:
405
+ -
406
+ database: *database_name
407
+ collection: *collection_name
408
+ name: rename
409
+ arguments:
410
+ to: *collection2_name
411
+ expectations:
412
+ -
413
+ command_started_event:
414
+ command:
415
+ aggregate: *collection_name
416
+ cursor: {}
417
+ pipeline:
418
+ -
419
+ $changeStream:
420
+ fullDocument: default
421
+ command_name: aggregate
422
+ database_name: *database_name
423
+ result:
424
+ success:
425
+ -
426
+ operationType: rename
427
+ ns:
428
+ db: *database_name
429
+ coll: *collection_name
430
+ to:
431
+ db: *database_name
432
+ coll: *collection2_name
433
+ -
434
+ operationType: invalidate
435
+ -
436
+ description: Test drop and invalidate event types
437
+ minServerVersion: "4.0.1"
438
+ target: collection
439
+ topology:
440
+ - replicaset
441
+ changeStreamPipeline: []
442
+ changeStreamOptions: {}
443
+ operations:
444
+ -
445
+ database: *database_name
446
+ collection: *collection_name
447
+ name: drop
448
+ expectations:
449
+ -
450
+ command_started_event:
451
+ command:
452
+ aggregate: *collection_name
453
+ cursor: {}
454
+ pipeline:
455
+ -
456
+ $changeStream:
457
+ fullDocument: default
458
+ command_name: aggregate
459
+ database_name: *database_name
460
+ result:
461
+ success:
462
+ -
463
+ operationType: drop
464
+ ns:
465
+ db: *database_name
466
+ coll: *collection_name
467
+ -
468
+ operationType: invalidate