Skip to content

Commit ec9f257

Browse files
committed
CSHARP-2447: Resync transactions tests to include test with session1 in APM expectations
1 parent b0a4173 commit ec9f257

File tree

2 files changed

+306
-0
lines changed

2 files changed

+306
-0
lines changed

tests/MongoDB.Driver.Tests/Specifications/transactions/tests/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": [

tests/MongoDB.Driver.Tests/Specifications/transactions/tests/insert.yml

Lines changed: 116 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,122 @@ tests:
141141
- _id: 4
142142
- _id: 5
143143

144+
# This test proves that the driver uses "session1" correctly in operations
145+
# and APM expectations.
146+
- description: insert with session1
147+
148+
operations:
149+
- name: startTransaction
150+
object: session1
151+
- name: insertOne
152+
object: collection
153+
arguments:
154+
session: session1
155+
document:
156+
_id: 1
157+
result:
158+
insertedId: 1
159+
- name: insertMany
160+
object: collection
161+
arguments:
162+
documents:
163+
- _id: 2
164+
- _id: 3
165+
session: session1
166+
result:
167+
insertedIds: {0: 2, 1: 3}
168+
- name: commitTransaction
169+
object: session1
170+
- name: startTransaction
171+
object: session1
172+
- name: insertOne
173+
object: collection
174+
arguments:
175+
session: session1
176+
document:
177+
_id: 4
178+
result:
179+
insertedId: 4
180+
- name: abortTransaction
181+
object: session1
182+
183+
expectations:
184+
- command_started_event:
185+
command:
186+
insert: *collection_name
187+
documents:
188+
- _id: 1
189+
ordered: true
190+
readConcern:
191+
lsid: session1
192+
txnNumber:
193+
$numberLong: "1"
194+
startTransaction: true
195+
autocommit: false
196+
writeConcern:
197+
command_name: insert
198+
database_name: *database_name
199+
- command_started_event:
200+
command:
201+
insert: *collection_name
202+
documents:
203+
- _id: 2
204+
- _id: 3
205+
ordered: true
206+
lsid: session1
207+
txnNumber:
208+
$numberLong: "1"
209+
startTransaction:
210+
autocommit: false
211+
writeConcern:
212+
command_name: insert
213+
database_name: *database_name
214+
- command_started_event:
215+
command:
216+
commitTransaction: 1
217+
lsid: session1
218+
txnNumber:
219+
$numberLong: "1"
220+
startTransaction:
221+
autocommit: false
222+
writeConcern:
223+
command_name: commitTransaction
224+
database_name: admin
225+
- command_started_event:
226+
command:
227+
insert: *collection_name
228+
documents:
229+
- _id: 4
230+
ordered: true
231+
readConcern:
232+
afterClusterTime: 42
233+
lsid: session1
234+
txnNumber:
235+
$numberLong: "2"
236+
startTransaction: true
237+
autocommit: false
238+
writeConcern:
239+
command_name: insert
240+
database_name: *database_name
241+
- command_started_event:
242+
command:
243+
abortTransaction: 1
244+
lsid: session1
245+
txnNumber:
246+
$numberLong: "2"
247+
startTransaction:
248+
autocommit: false
249+
writeConcern:
250+
command_name: abortTransaction
251+
database_name: admin
252+
253+
outcome:
254+
collection:
255+
data:
256+
- _id: 1
257+
- _id: 2
258+
- _id: 3
259+
144260
# This test proves that the driver parses the collectionOptions writeConcern.
145261
- description: collection writeConcern without transaction
146262
operations:

0 commit comments

Comments
 (0)