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
@@ -0,0 +1,51 @@
1
+ data:
2
+ - { _id: 1, x: 11 }
3
+ - { _id: 2, x: 22 }
4
+
5
+ minServerVersion: '3.6'
6
+
7
+ tests:
8
+ -
9
+ description: "DeleteOne is committed on first attempt"
10
+ failPoint:
11
+ mode: { times: 1 }
12
+ operation:
13
+ name: "deleteOne"
14
+ arguments:
15
+ filter: { _id: 1 }
16
+ outcome:
17
+ result:
18
+ deletedCount: 1
19
+ collection:
20
+ data:
21
+ - { _id: 2, x: 22 }
22
+ -
23
+ description: "DeleteOne is not committed on first attempt"
24
+ failPoint:
25
+ mode: { times: 1 }
26
+ data: { failBeforeCommitExceptionCode: 1 }
27
+ operation:
28
+ name: "deleteOne"
29
+ arguments:
30
+ filter: { _id: 1 }
31
+ outcome:
32
+ result:
33
+ deletedCount: 1
34
+ collection:
35
+ data:
36
+ - { _id: 2, x: 22 }
37
+ -
38
+ description: "DeleteOne is never committed"
39
+ failPoint:
40
+ mode: { times: 2 }
41
+ data: { failBeforeCommitExceptionCode: 1 }
42
+ operation:
43
+ name: "deleteOne"
44
+ arguments:
45
+ filter: { _id: 1 }
46
+ outcome:
47
+ error: true
48
+ collection:
49
+ data:
50
+ - { _id: 1, x: 11 }
51
+ - { _id: 2, x: 22 }
@@ -0,0 +1,52 @@
1
+ data:
2
+ - { _id: 1, x: 11 }
3
+ - { _id: 2, x: 22 }
4
+
5
+ minServerVersion: '3.6'
6
+
7
+ tests:
8
+ # -
9
+ # description: "FindOneAndDelete is committed on first attempt"
10
+ # failPoint:
11
+ # mode: { times: 1 }
12
+ # operation:
13
+ # name: "findOneAndDelete"
14
+ # arguments:
15
+ # filter: { x: { $gte: 11 }}
16
+ # sort: { x: 1 }
17
+ # outcome:
18
+ # result: { _id: 1, x: 11 }
19
+ # collection:
20
+ # data:
21
+ # - { _id: 2, x: 22 }
22
+ # -
23
+ # description: "FindOneAndDelete is not committed on first attempt"
24
+ # failPoint:
25
+ # mode: { times: 1 }
26
+ # data: { failBeforeCommitExceptionCode: 1 }
27
+ # operation:
28
+ # name: "findOneAndDelete"
29
+ # arguments:
30
+ # filter: { x: { $gte: 11 }}
31
+ # sort: { x: 1 }
32
+ # outcome:
33
+ # result: { _id: 1, x: 11 }
34
+ # collection:
35
+ # data:
36
+ # - { _id: 2, x: 22 }
37
+ -
38
+ description: "FindOneAndDelete is never committed"
39
+ failPoint:
40
+ mode: { times: 2 }
41
+ data: { failBeforeCommitExceptionCode: 1 }
42
+ operation:
43
+ name: "findOneAndDelete"
44
+ arguments:
45
+ filter: { x: { $gte: 11 }}
46
+ sort: { x: 1 }
47
+ outcome:
48
+ error: true
49
+ collection:
50
+ data:
51
+ - { _id: 1, x: 11 }
52
+ - { _id: 2, x: 22 }
@@ -0,0 +1,57 @@
1
+ data:
2
+ - { _id: 1, x: 11 }
3
+ - { _id: 2, x: 22 }
4
+
5
+ minServerVersion: '3.6'
6
+
7
+ tests:
8
+ -
9
+ description: "FindOneAndReplace is committed on first attempt"
10
+ failPoint:
11
+ mode: { times: 1 }
12
+ operation:
13
+ name: "findOneAndReplace"
14
+ arguments:
15
+ filter: { _id: 1 }
16
+ replacement: { _id: 1, x: 111 }
17
+ returnDocument: "Before"
18
+ outcome:
19
+ result: { _id: 1, x: 11 }
20
+ collection:
21
+ data:
22
+ - { _id: 1, x: 111 }
23
+ - { _id: 2, x: 22 }
24
+ -
25
+ description: "FindOneAndReplace is not committed on first attempt"
26
+ failPoint:
27
+ mode: { times: 1 }
28
+ data: { failBeforeCommitExceptionCode: 1 }
29
+ operation:
30
+ name: "findOneAndReplace"
31
+ arguments:
32
+ filter: { _id: 1 }
33
+ replacement: { _id: 1, x: 111 }
34
+ returnDocument: "Before"
35
+ outcome:
36
+ result: { _id: 1, x: 11 }
37
+ collection:
38
+ data:
39
+ - { _id: 1, x: 111 }
40
+ - { _id: 2, x: 22 }
41
+ -
42
+ description: "FindOneAndReplace is never committed"
43
+ failPoint:
44
+ mode: { times: 2 }
45
+ data: { failBeforeCommitExceptionCode: 1 }
46
+ operation:
47
+ name: "findOneAndReplace"
48
+ arguments:
49
+ filter: { _id: 1 }
50
+ replacement: { _id: 1, x: 111 }
51
+ returnDocument: "Before"
52
+ outcome:
53
+ error: true
54
+ collection:
55
+ data:
56
+ - { _id: 1, x: 11 }
57
+ - { _id: 2, x: 22 }
@@ -0,0 +1,56 @@
1
+ data:
2
+ - { _id: 1, x: 11 }
3
+ - { _id: 2, x: 22 }
4
+
5
+ minServerVersion: '3.6'
6
+
7
+ tests:
8
+ -
9
+ description: "FindOneAndUpdate is committed on first attempt"
10
+ failPoint:
11
+ mode: { times: 1 }
12
+ operation:
13
+ name: "findOneAndUpdate"
14
+ arguments:
15
+ filter: { _id: 1 }
16
+ update: { $inc: { x : 1 }}
17
+ returnDocument: "Before"
18
+ outcome:
19
+ result: { _id: 1, x: 11 }
20
+ collection:
21
+ data:
22
+ - { _id: 1, x: 12 }
23
+ - { _id: 2, x: 22 }
24
+ -
25
+ description: "FindOneAndUpdate is not committed on first attempt"
26
+ failPoint:
27
+ mode: { times: 1 }
28
+ data: { failBeforeCommitExceptionCode: 1 }
29
+ operation:
30
+ name: "findOneAndUpdate"
31
+ arguments:
32
+ filter: { _id: 1 }
33
+ update: { $inc: { x : 1 }}
34
+ returnDocument: "Before"
35
+ outcome:
36
+ result: { _id: 1, x: 11 }
37
+ collection:
38
+ data:
39
+ - { _id: 1, x: 12 }
40
+ - { _id: 2, x: 22 }
41
+ -
42
+ description: "FindOneAndUpdate is never committed"
43
+ failPoint:
44
+ mode: { times: 2 }
45
+ data: { failBeforeCommitExceptionCode: 1 }
46
+ operation:
47
+ name: "findOneAndUpdate"
48
+ arguments:
49
+ filter: { _id: 1 }
50
+ update: { $inc: { x : 1 }}
51
+ outcome:
52
+ error: true
53
+ collection:
54
+ data:
55
+ - { _id: 1, x: 11 }
56
+ - { _id: 2, x: 22 }
@@ -0,0 +1,72 @@
1
+ data:
2
+ - { _id: 1, x: 11 }
3
+
4
+ minServerVersion: '3.6'
5
+
6
+ tests:
7
+ -
8
+ description: "InsertMany succeeds after one network error"
9
+ failPoint:
10
+ mode: { times: 1 }
11
+ operation:
12
+ name: "insertMany"
13
+ arguments:
14
+ documents:
15
+ - { _id: 2, x: 22 }
16
+ - { _id: 3, x: 33 }
17
+ options: { ordered: true }
18
+ outcome:
19
+ result:
20
+ insertedIds:
21
+ - 2
22
+ - 3
23
+ collection:
24
+ data:
25
+ - { _id: 1, x: 11 }
26
+ - { _id: 2, x: 22 }
27
+ - { _id: 3, x: 33 }
28
+ -
29
+ description: "InsertMany with unordered execution"
30
+ failPoint:
31
+ mode: { times: 1 }
32
+ operation:
33
+ name: "insertMany"
34
+ arguments:
35
+ documents:
36
+ - { _id: 2, x: 22 }
37
+ - { _id: 3, x: 33 }
38
+ options: { ordered: false }
39
+ outcome:
40
+ result:
41
+ insertedIds:
42
+ - 2
43
+ - 3
44
+ collection:
45
+ data:
46
+ - { _id: 1, x: 11 }
47
+ - { _id: 2, x: 22 }
48
+ - { _id: 3, x: 33 }
49
+ -
50
+ description: "InsertMany fails after multiple network errors"
51
+ failPoint:
52
+ # Normally, a mongod will insert the documents as a batch with a
53
+ # single commit. If this fails, mongod may try to insert each
54
+ # document one at a time depending on the failure. Therefore our
55
+ # single insert command may trigger the failpoint twice on each
56
+ # driver attempt. This test permanently enables the fail point to
57
+ # ensure the retry attempt always fails.
58
+ mode: "alwaysOn"
59
+ data: { failBeforeCommitExceptionCode: 1 }
60
+ operation:
61
+ name: "insertMany"
62
+ arguments:
63
+ documents:
64
+ - { _id: 2, x: 22 }
65
+ - { _id: 3, x: 33 }
66
+ - { _id: 4, x: 44 }
67
+ options: { ordered: true }
68
+ outcome:
69
+ error: true
70
+ collection:
71
+ data:
72
+ - { _id: 1, x: 11 }
@@ -0,0 +1,55 @@
1
+ data:
2
+ - { _id: 1, x: 11 }
3
+ - { _id: 2, x: 22 }
4
+
5
+ minServerVersion: '3.6'
6
+
7
+ tests:
8
+ -
9
+ description: "InsertOne is committed on first attempt"
10
+ failPoint:
11
+ mode: { times: 1 }
12
+ operation:
13
+ name: "insertOne"
14
+ arguments:
15
+ document: { _id: 3, x: 33 }
16
+ outcome:
17
+ result:
18
+ insertedId: 3
19
+ collection:
20
+ data:
21
+ - { _id: 1, x: 11 }
22
+ - { _id: 2, x: 22 }
23
+ - { _id: 3, x: 33 }
24
+ -
25
+ description: "InsertOne is not committed on first attempt"
26
+ failPoint:
27
+ mode: { times: 1 }
28
+ data: { failBeforeCommitExceptionCode: 1 }
29
+ operation:
30
+ name: "insertOne"
31
+ arguments:
32
+ document: { _id: 3, x: 33 }
33
+ outcome:
34
+ result:
35
+ insertedId: 3
36
+ collection:
37
+ data:
38
+ - { _id: 1, x: 11 }
39
+ - { _id: 2, x: 22 }
40
+ - { _id: 3, x: 33 }
41
+ -
42
+ description: "InsertOne is never committed"
43
+ failPoint:
44
+ mode: { times: 2 }
45
+ data: { failBeforeCommitExceptionCode: 1 }
46
+ operation:
47
+ name: "insertOne"
48
+ arguments:
49
+ document: { _id: 3, x: 33 }
50
+ outcome:
51
+ error: true
52
+ collection:
53
+ data:
54
+ - { _id: 1, x: 11 }
55
+ - { _id: 2, x: 22 }
@@ -0,0 +1,60 @@
1
+ data:
2
+ - { _id: 1, x: 11 }
3
+ - { _id: 2, x: 22 }
4
+
5
+ minServerVersion: '3.6'
6
+
7
+ tests:
8
+ -
9
+ description: "ReplaceOne is committed on first attempt"
10
+ failPoint:
11
+ mode: { times: 1 }
12
+ operation:
13
+ name: "replaceOne"
14
+ arguments:
15
+ filter: { _id: 1 }
16
+ replacement: { _id: 1, x: 111 }
17
+ outcome:
18
+ result:
19
+ matchedCount: 1
20
+ modifiedCount: 1
21
+ upsertedCount: 0
22
+ collection:
23
+ data:
24
+ - { _id: 1, x: 111 }
25
+ - { _id: 2, x: 22 }
26
+ -
27
+ description: "ReplaceOne is not committed on first attempt"
28
+ failPoint:
29
+ mode: { times: 1 }
30
+ data: { failBeforeCommitExceptionCode: 1 }
31
+ operation:
32
+ name: "replaceOne"
33
+ arguments:
34
+ filter: { _id: 1 }
35
+ replacement: { _id: 1, x: 111 }
36
+ outcome:
37
+ result:
38
+ matchedCount: 1
39
+ modifiedCount: 1
40
+ upsertedCount: 0
41
+ collection:
42
+ data:
43
+ - { _id: 1, x: 111 }
44
+ - { _id: 2, x: 22 }
45
+ -
46
+ description: "ReplaceOne is never committed"
47
+ failPoint:
48
+ mode: { times: 2 }
49
+ data: { failBeforeCommitExceptionCode: 1 }
50
+ operation:
51
+ name: "replaceOne"
52
+ arguments:
53
+ filter: { _id: 1 }
54
+ replacement: { _id: 1, x: 111 }
55
+ outcome:
56
+ error: true
57
+ collection:
58
+ data:
59
+ - { _id: 1, x: 11 }
60
+ - { _id: 2, x: 22 }
@@ -0,0 +1,120 @@
1
+ data:
2
+ - { _id: 1, x: 11 }
3
+ - { _id: 2, x: 22 }
4
+
5
+ minServerVersion: '3.6'
6
+
7
+ tests:
8
+ # -
9
+ # description: "UpdateOne is committed on first attempt"
10
+ # failPoint:
11
+ # mode: { times: 1 }
12
+ # operation:
13
+ # name: "updateOne"
14
+ # arguments:
15
+ # filter: { _id: 1 }
16
+ # update: { $inc: { x : 1 }}
17
+ # outcome:
18
+ # result:
19
+ # matchedCount: 1
20
+ # modifiedCount: 1
21
+ # upsertedCount: 0
22
+ # collection:
23
+ # data:
24
+ # - { _id: 1, x: 12 }
25
+ # - { _id: 2, x: 22 }
26
+ # -
27
+ # description: "UpdateOne is not committed on first attempt"
28
+ # failPoint:
29
+ # mode: { times: 1 }
30
+ # data: { failBeforeCommitExceptionCode: 1 }
31
+ # operation:
32
+ # name: "updateOne"
33
+ # arguments:
34
+ # filter: { _id: 1 }
35
+ # update: { $inc: { x : 1 }}
36
+ # outcome:
37
+ # result:
38
+ # matchedCount: 1
39
+ # modifiedCount: 1
40
+ # upsertedCount: 0
41
+ # collection:
42
+ # data:
43
+ # - { _id: 1, x: 12 }
44
+ # - { _id: 2, x: 22 }
45
+ # -
46
+ # description: "UpdateOne is never committed"
47
+ # failPoint:
48
+ # mode: { times: 2 }
49
+ # data: { failBeforeCommitExceptionCode: 1 }
50
+ # operation:
51
+ # name: "updateOne"
52
+ # arguments:
53
+ # filter: { _id: 1 }
54
+ # update: { $inc: { x : 1 }}
55
+ # outcome:
56
+ # error: true
57
+ # collection:
58
+ # data:
59
+ # - { _id: 1, x: 11 }
60
+ # - { _id: 2, x: 22 }
61
+ -
62
+ description: "UpdateOne with upsert is committed on first attempt"
63
+ failPoint:
64
+ mode: { times: 1 }
65
+ operation:
66
+ name: "updateOne"
67
+ arguments:
68
+ filter: { _id: 3, x: 33 }
69
+ update: { $inc: { x : 1 }}
70
+ upsert: true
71
+ outcome:
72
+ result:
73
+ matchedCount: 0
74
+ modifiedCount: 0
75
+ upsertedCount: 1
76
+ upsertedId: 3
77
+ collection:
78
+ data:
79
+ - { _id: 1, x: 11 }
80
+ - { _id: 2, x: 22 }
81
+ - { _id: 3, x: 34 }
82
+ -
83
+ description: "UpdateOne with upsert is not committed on first attempt"
84
+ failPoint:
85
+ mode: { times: 1 }
86
+ data: { failBeforeCommitExceptionCode: 1 }
87
+ operation:
88
+ name: "updateOne"
89
+ arguments:
90
+ filter: { _id: 3, x: 33 }
91
+ update: { $inc: { x : 1 }}
92
+ upsert: true
93
+ outcome:
94
+ result:
95
+ matchedCount: 0
96
+ modifiedCount: 0
97
+ upsertedCount: 1
98
+ upsertedId: 3
99
+ collection:
100
+ data:
101
+ - { _id: 1, x: 11 }
102
+ - { _id: 2, x: 22 }
103
+ - { _id: 3, x: 34 }
104
+ -
105
+ description: "UpdateOne with upsert is never committed"
106
+ failPoint:
107
+ mode: { times: 2 }
108
+ data: { failBeforeCommitExceptionCode: 1 }
109
+ operation:
110
+ name: "updateOne"
111
+ arguments:
112
+ filter: { _id: 3, x: 33 }
113
+ update: { $inc: { x : 1 }}
114
+ upsert: true
115
+ outcome:
116
+ error: true
117
+ collection:
118
+ data:
119
+ - { _id: 1, x: 11 }
120
+ - { _id: 2, x: 22 }