| 1 | { |
| 2 | "runOn": [ |
| 3 | { |
| 4 | "minServerVersion": "4.0", |
| 5 | "topology": [ |
| 6 | "replicaset" |
| 7 | ] |
| 8 | }, |
| 9 | { |
| 10 | "minServerVersion": "4.1.8", |
| 11 | "topology": [ |
| 12 | "sharded" |
| 13 | ] |
| 14 | } |
| 15 | ], |
| 16 | "database_name": "transaction-tests", |
| 17 | "collection_name": "test", |
| 18 | "data": [], |
| 19 | "tests": [ |
| 20 | { |
| 21 | "description": "run command with default read preference", |
| 22 | "operations": [ |
| 23 | { |
| 24 | "name": "startTransaction", |
| 25 | "object": "session0" |
| 26 | }, |
| 27 | { |
| 28 | "name": "runCommand", |
| 29 | "object": "database", |
| 30 | "command_name": "insert", |
| 31 | "arguments": { |
| 32 | "session": "session0", |
| 33 | "command": { |
| 34 | "insert": "test", |
| 35 | "documents": [ |
| 36 | { |
| 37 | "_id": 1 |
| 38 | } |
| 39 | ] |
| 40 | } |
| 41 | }, |
| 42 | "result": { |
| 43 | "n": 1 |
| 44 | } |
| 45 | }, |
| 46 | { |
| 47 | "name": "commitTransaction", |
| 48 | "object": "session0" |
| 49 | } |
| 50 | ], |
| 51 | "expectations": [ |
| 52 | { |
| 53 | "command_started_event": { |
| 54 | "command": { |
| 55 | "insert": "test", |
| 56 | "documents": [ |
| 57 | { |
| 58 | "_id": 1 |
| 59 | } |
| 60 | ], |
| 61 | "readConcern": null, |
| 62 | "lsid": "session0", |
| 63 | "txnNumber": { |
| 64 | "$numberLong": "1" |
| 65 | }, |
| 66 | "startTransaction": true, |
| 67 | "autocommit": false, |
| 68 | "writeConcern": null |
| 69 | }, |
| 70 | "command_name": "insert", |
| 71 | "database_name": "transaction-tests" |
| 72 | } |
| 73 | }, |
| 74 | { |
| 75 | "command_started_event": { |
| 76 | "command": { |
| 77 | "commitTransaction": 1, |
| 78 | "lsid": "session0", |
| 79 | "txnNumber": { |
| 80 | "$numberLong": "1" |
| 81 | }, |
| 82 | "startTransaction": null, |
| 83 | "autocommit": false, |
| 84 | "writeConcern": null |
| 85 | }, |
| 86 | "command_name": "commitTransaction", |
| 87 | "database_name": "admin" |
| 88 | } |
| 89 | } |
| 90 | ] |
| 91 | }, |
| 92 | { |
| 93 | "description": "run command with secondary read preference in client option and primary read preference in transaction options", |
| 94 | "clientOptions": { |
| 95 | "readPreference": "secondary" |
| 96 | }, |
| 97 | "operations": [ |
| 98 | { |
| 99 | "name": "startTransaction", |
| 100 | "object": "session0", |
| 101 | "arguments": { |
| 102 | "options": { |
| 103 | "readPreference": { |
| 104 | "mode": "Primary" |
| 105 | } |
| 106 | } |
| 107 | } |
| 108 | }, |
| 109 | { |
| 110 | "name": "runCommand", |
| 111 | "object": "database", |
| 112 | "command_name": "insert", |
| 113 | "arguments": { |
| 114 | "session": "session0", |
| 115 | "command": { |
| 116 | "insert": "test", |
| 117 | "documents": [ |
| 118 | { |
| 119 | "_id": 1 |
| 120 | } |
| 121 | ] |
| 122 | } |
| 123 | }, |
| 124 | "result": { |
| 125 | "n": 1 |
| 126 | } |
| 127 | }, |
| 128 | { |
| 129 | "name": "commitTransaction", |
| 130 | "object": "session0" |
| 131 | } |
| 132 | ], |
| 133 | "expectations": [ |
| 134 | { |
| 135 | "command_started_event": { |
| 136 | "command": { |
| 137 | "insert": "test", |
| 138 | "documents": [ |
| 139 | { |
| 140 | "_id": 1 |
| 141 | } |
| 142 | ], |
| 143 | "readConcern": null, |
| 144 | "lsid": "session0", |
| 145 | "txnNumber": { |
| 146 | "$numberLong": "1" |
| 147 | }, |
| 148 | "startTransaction": true, |
| 149 | "autocommit": false, |
| 150 | "writeConcern": null |
| 151 | }, |
| 152 | "command_name": "insert", |
| 153 | "database_name": "transaction-tests" |
| 154 | } |
| 155 | }, |
| 156 | { |
| 157 | "command_started_event": { |
| 158 | "command": { |
| 159 | "commitTransaction": 1, |
| 160 | "lsid": "session0", |
| 161 | "txnNumber": { |
| 162 | "$numberLong": "1" |
| 163 | }, |
| 164 | "startTransaction": null, |
| 165 | "autocommit": false, |
| 166 | "writeConcern": null |
| 167 | }, |
| 168 | "command_name": "commitTransaction", |
| 169 | "database_name": "admin" |
| 170 | } |
| 171 | } |
| 172 | ] |
| 173 | }, |
| 174 | { |
| 175 | "description": "run command with explicit primary read preference", |
| 176 | "operations": [ |
| 177 | { |
| 178 | "name": "startTransaction", |
| 179 | "object": "session0" |
| 180 | }, |
| 181 | { |
| 182 | "name": "runCommand", |
| 183 | "object": "database", |
| 184 | "command_name": "insert", |
| 185 | "arguments": { |
| 186 | "session": "session0", |
| 187 | "command": { |
| 188 | "insert": "test", |
| 189 | "documents": [ |
| 190 | { |
| 191 | "_id": 1 |
| 192 | } |
| 193 | ] |
| 194 | }, |
| 195 | "readPreference": { |
| 196 | "mode": "Primary" |
| 197 | } |
| 198 | }, |
| 199 | "result": { |
| 200 | "n": 1 |
| 201 | } |
| 202 | }, |
| 203 | { |
| 204 | "name": "commitTransaction", |
| 205 | "object": "session0" |
| 206 | } |
| 207 | ], |
| 208 | "expectations": [ |
| 209 | { |
| 210 | "command_started_event": { |
| 211 | "command": { |
| 212 | "insert": "test", |
| 213 | "documents": [ |
| 214 | { |
| 215 | "_id": 1 |
| 216 | } |
| 217 | ], |
| 218 | "readConcern": null, |
| 219 | "lsid": "session0", |
| 220 | "txnNumber": { |
| 221 | "$numberLong": "1" |
| 222 | }, |
| 223 | "startTransaction": true, |
| 224 | "autocommit": false, |
| 225 | "writeConcern": null |
| 226 | }, |
| 227 | "command_name": "insert", |
| 228 | "database_name": "transaction-tests" |
| 229 | } |
| 230 | }, |
| 231 | { |
| 232 | "command_started_event": { |
| 233 | "command": { |
| 234 | "commitTransaction": 1, |
| 235 | "lsid": "session0", |
| 236 | "txnNumber": { |
| 237 | "$numberLong": "1" |
| 238 | }, |
| 239 | "startTransaction": null, |
| 240 | "autocommit": false, |
| 241 | "writeConcern": null |
| 242 | }, |
| 243 | "command_name": "commitTransaction", |
| 244 | "database_name": "admin" |
| 245 | } |
| 246 | } |
| 247 | ] |
| 248 | }, |
| 249 | { |
| 250 | "description": "run command fails with explicit secondary read preference", |
| 251 | "operations": [ |
| 252 | { |
| 253 | "name": "startTransaction", |
| 254 | "object": "session0" |
| 255 | }, |
| 256 | { |
| 257 | "name": "runCommand", |
| 258 | "object": "database", |
| 259 | "command_name": "find", |
| 260 | "arguments": { |
| 261 | "session": "session0", |
| 262 | "command": { |
| 263 | "find": "test" |
| 264 | }, |
| 265 | "readPreference": { |
| 266 | "mode": "Secondary" |
| 267 | } |
| 268 | }, |
| 269 | "result": { |
| 270 | "errorContains": "read preference in a transaction must be primary" |
| 271 | } |
| 272 | } |
| 273 | ] |
| 274 | }, |
| 275 | { |
| 276 | "description": "run command fails with secondary read preference from transaction options", |
| 277 | "operations": [ |
| 278 | { |
| 279 | "name": "startTransaction", |
| 280 | "object": "session0", |
| 281 | "arguments": { |
| 282 | "options": { |
| 283 | "readPreference": { |
| 284 | "mode": "Secondary" |
| 285 | } |
| 286 | } |
| 287 | } |
| 288 | }, |
| 289 | { |
| 290 | "name": "runCommand", |
| 291 | "object": "database", |
| 292 | "command_name": "find", |
| 293 | "arguments": { |
| 294 | "session": "session0", |
| 295 | "command": { |
| 296 | "find": "test" |
| 297 | } |
| 298 | }, |
| 299 | "result": { |
| 300 | "errorContains": "read preference in a transaction must be primary" |
| 301 | } |
| 302 | } |
| 303 | ] |
| 304 | } |
| 305 | ] |
| 306 | } |