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
@@ -2,6 +2,9 @@ runOn:
2
2
  -
3
3
  minServerVersion: "4.0"
4
4
  topology: ["replicaset"]
5
+ -
6
+ minServerVersion: "4.1.8"
7
+ topology: ["sharded"]
5
8
 
6
9
  database_name: &database_name "transaction-tests"
7
10
  collection_name: &collection_name "test"
@@ -3,6 +3,9 @@ runOn:
3
3
  -
4
4
  minServerVersion: "4.0"
5
5
  topology: ["replicaset"]
6
+ -
7
+ minServerVersion: "4.1.8"
8
+ topology: ["sharded"]
6
9
 
7
10
  database_name: &database_name "transaction-tests"
8
11
  collection_name: &collection_name "test"
@@ -2,6 +2,9 @@ runOn:
2
2
  -
3
3
  minServerVersion: "4.0"
4
4
  topology: ["replicaset"]
5
+ -
6
+ minServerVersion: "4.1.8"
7
+ topology: ["sharded"]
5
8
 
6
9
  database_name: &database_name "transaction-tests"
7
10
  collection_name: &collection_name "test"
@@ -2,6 +2,9 @@ runOn:
2
2
  -
3
3
  minServerVersion: "4.0"
4
4
  topology: ["replicaset"]
5
+ -
6
+ minServerVersion: "4.1.8"
7
+ topology: ["sharded"]
5
8
 
6
9
  database_name: &database_name "transaction-tests"
7
10
  collection_name: &collection_name "test"
@@ -464,7 +467,7 @@ tests:
464
467
  collection:
465
468
  data: []
466
469
 
467
- - description: abortTransaction succeeds after InterruptedDueToStepDown
470
+ - description: abortTransaction succeeds after InterruptedDueToReplStateChange
468
471
 
469
472
  failPoint:
470
473
  configureFailPoint: failCommand
@@ -1074,7 +1077,7 @@ tests:
1074
1077
  collection:
1075
1078
  data: []
1076
1079
 
1077
- - description: abortTransaction succeeds after WriteConcernError InterruptedDueToStepDown
1080
+ - description: abortTransaction succeeds after WriteConcernError InterruptedDueToReplStateChange
1078
1081
 
1079
1082
  failPoint:
1080
1083
  configureFailPoint: failCommand
@@ -2,6 +2,9 @@ runOn:
2
2
  -
3
3
  minServerVersion: "4.0"
4
4
  topology: ["replicaset"]
5
+ -
6
+ minServerVersion: "4.1.8"
7
+ topology: ["sharded"]
5
8
 
6
9
  database_name: &database_name "transaction-tests"
7
10
  collection_name: &collection_name "test"
@@ -1216,7 +1219,7 @@ tests:
1216
1219
  data:
1217
1220
  - _id: 1
1218
1221
 
1219
- - description: commitTransaction succeeds after WriteConcernError InterruptedDueToStepDown
1222
+ - description: commitTransaction succeeds after WriteConcernError InterruptedDueToReplStateChange
1220
1223
 
1221
1224
  failPoint:
1222
1225
  configureFailPoint: failCommand
@@ -2,6 +2,9 @@ runOn:
2
2
  -
3
3
  minServerVersion: "4.0"
4
4
  topology: ["replicaset"]
5
+ -
6
+ minServerVersion: "4.1.8"
7
+ topology: ["sharded"]
5
8
 
6
9
  database_name: &database_name "transaction-tests"
7
10
  collection_name: &collection_name "test"
@@ -2,6 +2,9 @@ runOn:
2
2
  -
3
3
  minServerVersion: "4.0"
4
4
  topology: ["replicaset"]
5
+ -
6
+ minServerVersion: "4.1.8"
7
+ topology: ["sharded"]
5
8
 
6
9
  database_name: &database_name "transaction-tests"
7
10
  collection_name: &collection_name "test"
@@ -2,6 +2,12 @@ runOn:
2
2
  -
3
3
  minServerVersion: "4.0"
4
4
  topology: ["replicaset"]
5
+ # Skip these tests on 4.3 due to
6
+ # https://jira.mongodb.org/browse/SERVER-40685 and
7
+ # https://jira.mongodb.org/browse/HELP-10518
8
+ #-
9
+ # minServerVersion: "4.1.8"
10
+ # topology: ["sharded"]
5
11
 
6
12
  database_name: &database_name "transaction-tests"
7
13
  collection_name: &collection_name "test"
@@ -2,6 +2,9 @@ runOn:
2
2
  -
3
3
  minServerVersion: "4.0"
4
4
  topology: ["replicaset"]
5
+ -
6
+ minServerVersion: "4.1.8"
7
+ topology: ["sharded"]
5
8
 
6
9
  database_name: &database_name "transaction-tests"
7
10
  collection_name: &collection_name "test"
@@ -62,7 +65,6 @@ tests:
62
65
  updates:
63
66
  - q: {_id: 4}
64
67
  u: {$inc: {x: 1}}
65
- multi: false
66
68
  upsert: true
67
69
  ordered: true
68
70
  readConcern:
@@ -80,8 +82,6 @@ tests:
80
82
  updates:
81
83
  - q: {x: 1}
82
84
  u: {y: 1}
83
- multi: false
84
- upsert: false
85
85
  ordered: true
86
86
  lsid: session0
87
87
  txnNumber:
@@ -98,7 +98,6 @@ tests:
98
98
  - q: {_id: {$gte: 3}}
99
99
  u: {$set: {z: 1}}
100
100
  multi: true
101
- upsert: false
102
101
  ordered: true
103
102
  lsid: session0
104
103
  txnNumber:
@@ -191,7 +190,6 @@ tests:
191
190
  updates:
192
191
  - q: {_id: 4}
193
192
  u: {$inc: {x: 1}}
194
- multi: false
195
193
  upsert: true
196
194
  ordered: true
197
195
  readConcern:
@@ -209,8 +207,6 @@ tests:
209
207
  updates:
210
208
  - q: {x: 1}
211
209
  u: {y: 1}
212
- multi: false
213
- upsert: false
214
210
  ordered: true
215
211
  lsid: session0
216
212
  txnNumber:
@@ -227,7 +223,6 @@ tests:
227
223
  - q: {_id: {$gte: 3}}
228
224
  u: {$set: {z: 1}}
229
225
  multi: true
230
- upsert: false
231
226
  ordered: true
232
227
  lsid: session0
233
228
  txnNumber:
@@ -8,7 +8,8 @@ runOn:
8
8
  database_name: &database_name "transaction-tests"
9
9
  collection_name: &collection_name "test"
10
10
 
11
- data: []
11
+ data: &data
12
+ - _id: 0
12
13
 
13
14
  tests:
14
15
  - description: commit with majority
@@ -27,23 +28,26 @@ tests:
27
28
  _id: 1
28
29
  result:
29
30
  insertedId: 1
30
- - name: commitTransaction
31
+ - &commitTransaction
32
+ name: commitTransaction
31
33
  object: session0
32
34
 
33
35
  expectations:
34
- - command_started_event:
36
+ - &insertOneEvent
37
+ command_started_event:
35
38
  command:
36
39
  insert: *collection_name
37
40
  documents:
38
41
  - _id: 1
39
42
  ordered: true
40
- readConcern:
41
- lsid: session0
42
- txnNumber:
43
- $numberLong: "1"
44
- startTransaction: true
45
- autocommit: false
46
- writeConcern:
43
+ <<: &transactionCommandArgs
44
+ lsid: session0
45
+ txnNumber:
46
+ $numberLong: "1"
47
+ startTransaction: true
48
+ autocommit: false
49
+ readConcern:
50
+ writeConcern:
47
51
  command_name: insert
48
52
  database_name: *database_name
49
53
  - command_started_event:
@@ -62,12 +66,14 @@ tests:
62
66
  outcome:
63
67
  collection:
64
68
  data:
69
+ - _id: 0
65
70
  - _id: 1
66
71
 
67
72
  - description: commit with default
68
73
 
69
74
  operations:
70
- - name: startTransaction
75
+ - &startTransaction
76
+ name: startTransaction
71
77
  object: session0
72
78
  - name: insertOne
73
79
  object: collection
@@ -77,8 +83,7 @@ tests:
77
83
  _id: 1
78
84
  result:
79
85
  insertedId: 1
80
- - name: commitTransaction
81
- object: session0
86
+ - *commitTransaction
82
87
 
83
88
  expectations:
84
89
  - command_started_event:
@@ -87,16 +92,11 @@ tests:
87
92
  documents:
88
93
  - _id: 1
89
94
  ordered: true
90
- readConcern:
91
- lsid: session0
92
- txnNumber:
93
- $numberLong: "1"
94
- startTransaction: true
95
- autocommit: false
96
- writeConcern:
95
+ <<: *transactionCommandArgs
97
96
  command_name: insert
98
97
  database_name: *database_name
99
- - command_started_event:
98
+ - &commitWithDefaultWCEvent
99
+ command_started_event:
100
100
  command:
101
101
  commitTransaction: 1
102
102
  lsid: session0
@@ -111,7 +111,7 @@ tests:
111
111
  outcome:
112
112
  collection:
113
113
  data:
114
-
114
+ - _id: 0
115
115
  - _id: 1
116
116
 
117
117
  - description: abort with majority
@@ -141,13 +141,7 @@ tests:
141
141
  documents:
142
142
  - _id: 1
143
143
  ordered: true
144
- readConcern:
145
- lsid: session0
146
- txnNumber:
147
- $numberLong: "1"
148
- startTransaction: true
149
- autocommit: false
150
- writeConcern:
144
+ <<: *transactionCommandArgs
151
145
  command_name: insert
152
146
  database_name: *database_name
153
147
  - command_started_event:
@@ -165,7 +159,7 @@ tests:
165
159
 
166
160
  outcome:
167
161
  collection:
168
- data: []
162
+ data: *data
169
163
 
170
164
  - description: abort with default
171
165
 
@@ -190,13 +184,7 @@ tests:
190
184
  documents:
191
185
  - _id: 1
192
186
  ordered: true
193
- readConcern:
194
- lsid: session0
195
- txnNumber:
196
- $numberLong: "1"
197
- startTransaction: true
198
- autocommit: false
199
- writeConcern:
187
+ <<: *transactionCommandArgs
200
188
  command_name: insert
201
189
  database_name: *database_name
202
190
  - command_started_event:
@@ -213,7 +201,7 @@ tests:
213
201
 
214
202
  outcome:
215
203
  collection:
216
- data: []
204
+ data: *data
217
205
 
218
206
  - description: start with unacknowledged write concern
219
207
 
@@ -239,3 +227,325 @@ tests:
239
227
  result:
240
228
  # Client-side error.
241
229
  errorContains: transactions do not support unacknowledged write concern
230
+
231
+ - description: unacknowledged write concern coll insertOne
232
+
233
+ operations:
234
+ - *startTransaction
235
+ - name: insertOne
236
+ <<: &collection_w0
237
+ object: collection
238
+ collectionOptions:
239
+ writeConcern: { w: 0 }
240
+ arguments:
241
+ session: session0
242
+ document:
243
+ _id: 1
244
+ result:
245
+ insertedId: 1
246
+ - *commitTransaction
247
+
248
+ expectations:
249
+ - *insertOneEvent
250
+ - *commitWithDefaultWCEvent
251
+
252
+ outcome:
253
+ collection:
254
+ data:
255
+ - _id: 0
256
+ - _id: 1
257
+
258
+ - description: unacknowledged write concern coll insertMany
259
+
260
+ operations:
261
+ - *startTransaction
262
+ - name: insertMany
263
+ <<: *collection_w0
264
+ arguments:
265
+ session: session0
266
+ documents:
267
+ - _id: 1
268
+ - _id: 2
269
+ result:
270
+ insertedIds: {0: 1, 1: 2}
271
+ - *commitTransaction
272
+
273
+ expectations:
274
+ - command_started_event:
275
+ command:
276
+ insert: *collection_name
277
+ documents:
278
+ - _id: 1
279
+ - _id: 2
280
+ ordered: true
281
+ <<: *transactionCommandArgs
282
+ command_name: insert
283
+ database_name: *database_name
284
+ - *commitWithDefaultWCEvent
285
+
286
+ outcome:
287
+ collection:
288
+ data:
289
+ - _id: 0
290
+ - _id: 1
291
+ - _id: 2
292
+
293
+ - description: unacknowledged write concern coll bulkWrite
294
+
295
+ operations:
296
+ - *startTransaction
297
+ - name: bulkWrite
298
+ <<: *collection_w0
299
+ arguments:
300
+ session: session0
301
+ requests:
302
+ - name: insertOne
303
+ arguments:
304
+ document: {_id: 1}
305
+ result:
306
+ deletedCount: 0
307
+ insertedCount: 1
308
+ insertedIds: {0: 1}
309
+ matchedCount: 0
310
+ modifiedCount: 0
311
+ upsertedCount: 0
312
+ upsertedIds: {}
313
+ - *commitTransaction
314
+
315
+ expectations:
316
+ - *insertOneEvent
317
+ - *commitWithDefaultWCEvent
318
+
319
+ outcome:
320
+ collection:
321
+ data:
322
+ - _id: 0
323
+ - _id: 1
324
+
325
+
326
+ - description: unacknowledged write concern coll deleteOne
327
+
328
+ operations:
329
+ - *startTransaction
330
+ - name: deleteOne
331
+ <<: *collection_w0
332
+ arguments:
333
+ session: session0
334
+ filter:
335
+ _id: 0
336
+ result:
337
+ deletedCount: 1
338
+ - *commitTransaction
339
+
340
+ expectations:
341
+ - command_started_event:
342
+ command:
343
+ delete: *collection_name
344
+ deletes:
345
+ - q: {_id: 0}
346
+ limit: 1
347
+ ordered: true
348
+ <<: *transactionCommandArgs
349
+ command_name: delete
350
+ database_name: *database_name
351
+ - *commitWithDefaultWCEvent
352
+
353
+ outcome:
354
+ collection:
355
+ data: []
356
+
357
+ - description: unacknowledged write concern coll deleteMany
358
+
359
+ operations:
360
+ - *startTransaction
361
+ - name: deleteMany
362
+ <<: *collection_w0
363
+ arguments:
364
+ session: session0
365
+ filter:
366
+ _id: 0
367
+ result:
368
+ deletedCount: 1
369
+ - *commitTransaction
370
+
371
+ expectations:
372
+ - command_started_event:
373
+ command:
374
+ delete: *collection_name
375
+ deletes:
376
+ - q: {_id: 0}
377
+ limit: 0
378
+ ordered: true
379
+ <<: *transactionCommandArgs
380
+ command_name: delete
381
+ database_name: *database_name
382
+ - *commitWithDefaultWCEvent
383
+
384
+ outcome:
385
+ collection:
386
+ data: []
387
+
388
+ - description: unacknowledged write concern coll updateOne
389
+
390
+ operations:
391
+ - *startTransaction
392
+ - name: updateOne
393
+ <<: *collection_w0
394
+ arguments:
395
+ session: session0
396
+ filter: {_id: 0}
397
+ update:
398
+ $inc: {x: 1}
399
+ upsert: true
400
+ result:
401
+ matchedCount: 1
402
+ modifiedCount: 1
403
+ upsertedCount: 0
404
+ - *commitTransaction
405
+
406
+ expectations:
407
+ - command_started_event:
408
+ command:
409
+ update: *collection_name
410
+ updates:
411
+ - q: {_id: 0}
412
+ u: {$inc: {x: 1}}
413
+ upsert: true
414
+ ordered: true
415
+ <<: *transactionCommandArgs
416
+ command_name: update
417
+ database_name: *database_name
418
+ - *commitWithDefaultWCEvent
419
+
420
+ outcome:
421
+ collection:
422
+ data:
423
+ - {_id: 0, x: 1}
424
+
425
+ - description: unacknowledged write concern coll updateMany
426
+
427
+ operations:
428
+ - *startTransaction
429
+ - name: updateMany
430
+ <<: *collection_w0
431
+ arguments:
432
+ session: session0
433
+ filter: {_id: 0}
434
+ update:
435
+ $inc: {x: 1}
436
+ upsert: true
437
+ result:
438
+ matchedCount: 1
439
+ modifiedCount: 1
440
+ upsertedCount: 0
441
+ - *commitTransaction
442
+
443
+ expectations:
444
+ - command_started_event:
445
+ command:
446
+ update: *collection_name
447
+ updates:
448
+ - q: {_id: 0}
449
+ u: {$inc: {x: 1}}
450
+ multi: true
451
+ upsert: true
452
+ ordered: true
453
+ <<: *transactionCommandArgs
454
+ command_name: update
455
+ database_name: *database_name
456
+ - *commitWithDefaultWCEvent
457
+
458
+ outcome:
459
+ collection:
460
+ data:
461
+ - {_id: 0, x: 1}
462
+
463
+ - description: unacknowledged write concern coll findOneAndDelete
464
+
465
+ operations:
466
+ - *startTransaction
467
+ - name: findOneAndDelete
468
+ <<: *collection_w0
469
+ arguments:
470
+ session: session0
471
+ filter: {_id: 0}
472
+ result: {_id: 0}
473
+ - *commitTransaction
474
+
475
+ expectations:
476
+ - command_started_event:
477
+ command:
478
+ findAndModify: *collection_name
479
+ query: {_id: 0}
480
+ remove: True
481
+ <<: *transactionCommandArgs
482
+ command_name: findAndModify
483
+ database_name: *database_name
484
+ - *commitWithDefaultWCEvent
485
+
486
+ outcome:
487
+ collection:
488
+ data: []
489
+
490
+ - description: unacknowledged write concern coll findOneAndReplace
491
+
492
+ operations:
493
+ - *startTransaction
494
+ - name: findOneAndReplace
495
+ <<: *collection_w0
496
+ arguments:
497
+ session: session0
498
+ filter: {_id: 0}
499
+ replacement: {x: 1}
500
+ returnDocument: Before
501
+ result: {_id: 0}
502
+ - *commitTransaction
503
+
504
+ expectations:
505
+ - command_started_event:
506
+ command:
507
+ findAndModify: *collection_name
508
+ query: {_id: 0}
509
+ update: {x: 1}
510
+ new: false
511
+ <<: *transactionCommandArgs
512
+ command_name: findAndModify
513
+ database_name: *database_name
514
+ - *commitWithDefaultWCEvent
515
+
516
+ outcome:
517
+ collection:
518
+ data:
519
+ - {_id: 0, x: 1}
520
+
521
+ - description: unacknowledged write concern coll findOneAndUpdate
522
+
523
+ operations:
524
+ - *startTransaction
525
+ - name: findOneAndUpdate
526
+ <<: *collection_w0
527
+ arguments:
528
+ session: session0
529
+ filter: {_id: 0}
530
+ update:
531
+ $inc: {x: 1}
532
+ returnDocument: Before
533
+ result: {_id: 0}
534
+ - *commitTransaction
535
+
536
+ expectations:
537
+ - command_started_event:
538
+ command:
539
+ findAndModify: *collection_name
540
+ query: {_id: 0}
541
+ update: {$inc: {x: 1}}
542
+ new: false
543
+ <<: *transactionCommandArgs
544
+ command_name: findAndModify
545
+ database_name: *database_name
546
+ - *commitWithDefaultWCEvent
547
+
548
+ outcome:
549
+ collection:
550
+ data:
551
+ - {_id: 0, x: 1}