| 1 |
runOn: |
| 2 |
- |
| 3 |
minServerVersion: "4.0" |
| 4 |
topology: ["replicaset"] |
| 5 |
- |
| 6 |
minServerVersion: "4.1.8" |
| 7 |
topology: ["sharded"] |
| 8 |
|
| 9 |
database_name: &database_name "withTransaction-tests" |
| 10 |
collection_name: &collection_name "test" |
| 11 |
|
| 12 |
data: [] |
| 13 |
|
| 14 |
tests: |
| 15 |
- |
| 16 |
# Session state will be ABORTED when callback returns to withTransaction |
| 17 |
description: withTransaction succeeds if callback aborts |
| 18 |
useMultipleMongoses: true |
| 19 |
operations: |
| 20 |
- |
| 21 |
name: withTransaction |
| 22 |
object: session0 |
| 23 |
arguments: |
| 24 |
callback: |
| 25 |
operations: |
| 26 |
- |
| 27 |
name: insertOne |
| 28 |
object: collection |
| 29 |
arguments: |
| 30 |
session: session0 |
| 31 |
document: { _id: 1 } |
| 32 |
result: |
| 33 |
insertedId: 1 |
| 34 |
- |
| 35 |
name: abortTransaction |
| 36 |
object: session0 |
| 37 |
expectations: |
| 38 |
- |
| 39 |
command_started_event: |
| 40 |
command: |
| 41 |
insert: *collection_name |
| 42 |
documents: |
| 43 |
- { _id: 1 } |
| 44 |
ordered: true |
| 45 |
lsid: session0 |
| 46 |
txnNumber: { $numberLong: "1" } |
| 47 |
startTransaction: true |
| 48 |
autocommit: false |
| 49 |
# omitted fields |
| 50 |
readConcern: ~ |
| 51 |
writeConcern: ~ |
| 52 |
command_name: insert |
| 53 |
database_name: *database_name |
| 54 |
- |
| 55 |
command_started_event: |
| 56 |
command: |
| 57 |
abortTransaction: 1 |
| 58 |
lsid: session0 |
| 59 |
txnNumber: { $numberLong: "1" } |
| 60 |
autocommit: false |
| 61 |
# omitted fields |
| 62 |
readConcern: ~ |
| 63 |
startTransaction: ~ |
| 64 |
writeConcern: ~ |
| 65 |
command_name: abortTransaction |
| 66 |
database_name: admin |
| 67 |
outcome: |
| 68 |
collection: |
| 69 |
data: [] |
| 70 |
- |
| 71 |
# Session state will be ABORTED when callback returns to withTransaction |
| 72 |
description: withTransaction succeeds if callback aborts with no ops |
| 73 |
useMultipleMongoses: true |
| 74 |
operations: |
| 75 |
- |
| 76 |
name: withTransaction |
| 77 |
object: session0 |
| 78 |
arguments: |
| 79 |
callback: |
| 80 |
operations: |
| 81 |
- |
| 82 |
name: abortTransaction |
| 83 |
object: session0 |
| 84 |
expectations: [] |
| 85 |
outcome: |
| 86 |
collection: |
| 87 |
data: [] |
| 88 |
- |
| 89 |
# Session state will be NO_TXN when callback returns to withTransaction |
| 90 |
description: withTransaction still succeeds if callback aborts and runs extra op |
| 91 |
useMultipleMongoses: true |
| 92 |
operations: |
| 93 |
- |
| 94 |
name: withTransaction |
| 95 |
object: session0 |
| 96 |
arguments: |
| 97 |
callback: |
| 98 |
operations: |
| 99 |
- |
| 100 |
name: insertOne |
| 101 |
object: collection |
| 102 |
arguments: |
| 103 |
session: session0 |
| 104 |
document: { _id: 1 } |
| 105 |
result: |
| 106 |
insertedId: 1 |
| 107 |
- |
| 108 |
name: abortTransaction |
| 109 |
object: session0 |
| 110 |
- |
| 111 |
name: insertOne |
| 112 |
object: collection |
| 113 |
arguments: |
| 114 |
session: session0 |
| 115 |
document: { _id: 2 } |
| 116 |
result: |
| 117 |
insertedId: 2 |
| 118 |
expectations: |
| 119 |
- |
| 120 |
command_started_event: |
| 121 |
command: |
| 122 |
insert: *collection_name |
| 123 |
documents: |
| 124 |
- { _id: 1 } |
| 125 |
ordered: true |
| 126 |
lsid: session0 |
| 127 |
txnNumber: { $numberLong: "1" } |
| 128 |
startTransaction: true |
| 129 |
autocommit: false |
| 130 |
# omitted fields |
| 131 |
readConcern: ~ |
| 132 |
writeConcern: ~ |
| 133 |
command_name: insert |
| 134 |
database_name: *database_name |
| 135 |
- |
| 136 |
command_started_event: |
| 137 |
command: |
| 138 |
abortTransaction: 1 |
| 139 |
lsid: session0 |
| 140 |
txnNumber: { $numberLong: "1" } |
| 141 |
autocommit: false |
| 142 |
# omitted fields |
| 143 |
readConcern: ~ |
| 144 |
startTransaction: ~ |
| 145 |
writeConcern: ~ |
| 146 |
command_name: abortTransaction |
| 147 |
database_name: admin |
| 148 |
- |
| 149 |
command_started_event: |
| 150 |
command: |
| 151 |
# This test is agnostic about retryWrites, so we do not assert the |
| 152 |
# txnNumber. If retryWrites=true, the txnNumber will be incremented |
| 153 |
# from the value used in the previous transaction; otherwise, the |
| 154 |
# field will not be present at all. |
| 155 |
insert: *collection_name |
| 156 |
documents: |
| 157 |
- { _id: 2 } |
| 158 |
ordered: true |
| 159 |
lsid: session0 |
| 160 |
# omitted fields |
| 161 |
autocommit: ~ |
| 162 |
readConcern: ~ |
| 163 |
startTransaction: ~ |
| 164 |
writeConcern: ~ |
| 165 |
command_name: insert |
| 166 |
database_name: *database_name |
| 167 |
outcome: |
| 168 |
collection: |
| 169 |
data: |
| 170 |
- { _id: 2 } |