Skip to content

Commit 7b4ba07

Browse files
committed
Resync transaction specification tests
Includes a test that that proves session identifiers are used correctly JAVA-3115
1 parent f2eb58b commit 7b4ba07

File tree

1 file changed

+190
-0
lines changed

1 file changed

+190
-0
lines changed

driver-core/src/test/resources/transactions/insert.json

Lines changed: 190 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,196 @@
233233
}
234234
}
235235
},
236+
{
237+
"description": "insert with session1",
238+
"operations": [
239+
{
240+
"name": "startTransaction",
241+
"object": "session1"
242+
},
243+
{
244+
"name": "insertOne",
245+
"object": "collection",
246+
"arguments": {
247+
"session": "session1",
248+
"document": {
249+
"_id": 1
250+
}
251+
},
252+
"result": {
253+
"insertedId": 1
254+
}
255+
},
256+
{
257+
"name": "insertMany",
258+
"object": "collection",
259+
"arguments": {
260+
"documents": [
261+
{
262+
"_id": 2
263+
},
264+
{
265+
"_id": 3
266+
}
267+
],
268+
"session": "session1"
269+
},
270+
"result": {
271+
"insertedIds": {
272+
"0": 2,
273+
"1": 3
274+
}
275+
}
276+
},
277+
{
278+
"name": "commitTransaction",
279+
"object": "session1"
280+
},
281+
{
282+
"name": "startTransaction",
283+
"object": "session1"
284+
},
285+
{
286+
"name": "insertOne",
287+
"object": "collection",
288+
"arguments": {
289+
"session": "session1",
290+
"document": {
291+
"_id": 4
292+
}
293+
},
294+
"result": {
295+
"insertedId": 4
296+
}
297+
},
298+
{
299+
"name": "abortTransaction",
300+
"object": "session1"
301+
}
302+
],
303+
"expectations": [
304+
{
305+
"command_started_event": {
306+
"command": {
307+
"insert": "test",
308+
"documents": [
309+
{
310+
"_id": 1
311+
}
312+
],
313+
"ordered": true,
314+
"readConcern": null,
315+
"lsid": "session1",
316+
"txnNumber": {
317+
"$numberLong": "1"
318+
},
319+
"startTransaction": true,
320+
"autocommit": false,
321+
"writeConcern": null
322+
},
323+
"command_name": "insert",
324+
"database_name": "transaction-tests"
325+
}
326+
},
327+
{
328+
"command_started_event": {
329+
"command": {
330+
"insert": "test",
331+
"documents": [
332+
{
333+
"_id": 2
334+
},
335+
{
336+
"_id": 3
337+
}
338+
],
339+
"ordered": true,
340+
"lsid": "session1",
341+
"txnNumber": {
342+
"$numberLong": "1"
343+
},
344+
"startTransaction": null,
345+
"autocommit": false,
346+
"writeConcern": null
347+
},
348+
"command_name": "insert",
349+
"database_name": "transaction-tests"
350+
}
351+
},
352+
{
353+
"command_started_event": {
354+
"command": {
355+
"commitTransaction": 1,
356+
"lsid": "session1",
357+
"txnNumber": {
358+
"$numberLong": "1"
359+
},
360+
"startTransaction": null,
361+
"autocommit": false,
362+
"writeConcern": null
363+
},
364+
"command_name": "commitTransaction",
365+
"database_name": "admin"
366+
}
367+
},
368+
{
369+
"command_started_event": {
370+
"command": {
371+
"insert": "test",
372+
"documents": [
373+
{
374+
"_id": 4
375+
}
376+
],
377+
"ordered": true,
378+
"readConcern": {
379+
"afterClusterTime": 42
380+
},
381+
"lsid": "session1",
382+
"txnNumber": {
383+
"$numberLong": "2"
384+
},
385+
"startTransaction": true,
386+
"autocommit": false,
387+
"writeConcern": null
388+
},
389+
"command_name": "insert",
390+
"database_name": "transaction-tests"
391+
}
392+
},
393+
{
394+
"command_started_event": {
395+
"command": {
396+
"abortTransaction": 1,
397+
"lsid": "session1",
398+
"txnNumber": {
399+
"$numberLong": "2"
400+
},
401+
"startTransaction": null,
402+
"autocommit": false,
403+
"writeConcern": null
404+
},
405+
"command_name": "abortTransaction",
406+
"database_name": "admin"
407+
}
408+
}
409+
],
410+
"outcome": {
411+
"collection": {
412+
"data": [
413+
{
414+
"_id": 1
415+
},
416+
{
417+
"_id": 2
418+
},
419+
{
420+
"_id": 3
421+
}
422+
]
423+
}
424+
}
425+
},
236426
{
237427
"description": "collection writeConcern without transaction",
238428
"operations": [

0 commit comments

Comments
 (0)