Skip to content

Commit 55f9fac

Browse files
committed
Sync transactions and transactions-convenient-api spec tests
Synced with mongodb/specifications@e51a7bc
1 parent 5c219b9 commit 55f9fac

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+38023
-0
lines changed

tests/UnifiedSpecTests/UnifiedSpecTest.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -313,6 +313,17 @@ public function provideTransactionsTests()
313313
return $this->provideTests(__DIR__ . '/transactions/*.json');
314314
}
315315

316+
/** @dataProvider provideTransactionsConvenientApiTests */
317+
public function testTransactionsConvenientApi(UnifiedTestCase $test): void
318+
{
319+
self::$runner->run($test);
320+
}
321+
322+
public function provideTransactionsConvenientApiTests()
323+
{
324+
return $this->provideTests(__DIR__ . '/transactions-convenient-api/*.json');
325+
}
326+
316327
/**
317328
* @dataProvider provideVersionedApiTests
318329
* @group versioned-api
Lines changed: 344 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,344 @@
1+
{
2+
"description": "callback-aborts",
3+
"schemaVersion": "1.3",
4+
"runOnRequirements": [
5+
{
6+
"minServerVersion": "4.0",
7+
"topologies": [
8+
"replicaset"
9+
]
10+
},
11+
{
12+
"minServerVersion": "4.1.8",
13+
"topologies": [
14+
"sharded",
15+
"load-balanced"
16+
]
17+
}
18+
],
19+
"createEntities": [
20+
{
21+
"client": {
22+
"id": "client0",
23+
"useMultipleMongoses": true,
24+
"observeEvents": [
25+
"commandStartedEvent"
26+
]
27+
}
28+
},
29+
{
30+
"database": {
31+
"id": "database0",
32+
"client": "client0",
33+
"databaseName": "withTransaction-tests"
34+
}
35+
},
36+
{
37+
"collection": {
38+
"id": "collection0",
39+
"database": "database0",
40+
"collectionName": "test"
41+
}
42+
},
43+
{
44+
"session": {
45+
"id": "session0",
46+
"client": "client0"
47+
}
48+
}
49+
],
50+
"initialData": [
51+
{
52+
"collectionName": "test",
53+
"databaseName": "withTransaction-tests",
54+
"documents": []
55+
}
56+
],
57+
"tests": [
58+
{
59+
"description": "withTransaction succeeds if callback aborts",
60+
"operations": [
61+
{
62+
"name": "withTransaction",
63+
"object": "session0",
64+
"arguments": {
65+
"callback": [
66+
{
67+
"name": "insertOne",
68+
"object": "collection0",
69+
"arguments": {
70+
"session": "session0",
71+
"document": {
72+
"_id": 1
73+
}
74+
},
75+
"expectResult": {
76+
"$$unsetOrMatches": {
77+
"insertedId": {
78+
"$$unsetOrMatches": 1
79+
}
80+
}
81+
}
82+
},
83+
{
84+
"name": "abortTransaction",
85+
"object": "session0"
86+
}
87+
]
88+
}
89+
}
90+
],
91+
"expectEvents": [
92+
{
93+
"client": "client0",
94+
"events": [
95+
{
96+
"commandStartedEvent": {
97+
"command": {
98+
"insert": "test",
99+
"documents": [
100+
{
101+
"_id": 1
102+
}
103+
],
104+
"ordered": true,
105+
"lsid": {
106+
"$$sessionLsid": "session0"
107+
},
108+
"txnNumber": {
109+
"$numberLong": "1"
110+
},
111+
"startTransaction": true,
112+
"autocommit": false,
113+
"readConcern": {
114+
"$$exists": false
115+
},
116+
"writeConcern": {
117+
"$$exists": false
118+
}
119+
},
120+
"commandName": "insert",
121+
"databaseName": "withTransaction-tests"
122+
}
123+
},
124+
{
125+
"commandStartedEvent": {
126+
"command": {
127+
"abortTransaction": 1,
128+
"lsid": {
129+
"$$sessionLsid": "session0"
130+
},
131+
"txnNumber": {
132+
"$numberLong": "1"
133+
},
134+
"autocommit": false,
135+
"readConcern": {
136+
"$$exists": false
137+
},
138+
"startTransaction": {
139+
"$$exists": false
140+
},
141+
"writeConcern": {
142+
"$$exists": false
143+
}
144+
},
145+
"commandName": "abortTransaction",
146+
"databaseName": "admin"
147+
}
148+
}
149+
]
150+
}
151+
],
152+
"outcome": [
153+
{
154+
"collectionName": "test",
155+
"databaseName": "withTransaction-tests",
156+
"documents": []
157+
}
158+
]
159+
},
160+
{
161+
"description": "withTransaction succeeds if callback aborts with no ops",
162+
"operations": [
163+
{
164+
"name": "withTransaction",
165+
"object": "session0",
166+
"arguments": {
167+
"callback": [
168+
{
169+
"name": "abortTransaction",
170+
"object": "session0"
171+
}
172+
]
173+
}
174+
}
175+
],
176+
"expectEvents": [
177+
{
178+
"client": "client0",
179+
"events": []
180+
}
181+
],
182+
"outcome": [
183+
{
184+
"collectionName": "test",
185+
"databaseName": "withTransaction-tests",
186+
"documents": []
187+
}
188+
]
189+
},
190+
{
191+
"description": "withTransaction still succeeds if callback aborts and runs extra op",
192+
"operations": [
193+
{
194+
"name": "withTransaction",
195+
"object": "session0",
196+
"arguments": {
197+
"callback": [
198+
{
199+
"name": "insertOne",
200+
"object": "collection0",
201+
"arguments": {
202+
"session": "session0",
203+
"document": {
204+
"_id": 1
205+
}
206+
},
207+
"expectResult": {
208+
"$$unsetOrMatches": {
209+
"insertedId": {
210+
"$$unsetOrMatches": 1
211+
}
212+
}
213+
}
214+
},
215+
{
216+
"name": "abortTransaction",
217+
"object": "session0"
218+
},
219+
{
220+
"name": "insertOne",
221+
"object": "collection0",
222+
"arguments": {
223+
"session": "session0",
224+
"document": {
225+
"_id": 2
226+
}
227+
},
228+
"expectResult": {
229+
"$$unsetOrMatches": {
230+
"insertedId": {
231+
"$$unsetOrMatches": 2
232+
}
233+
}
234+
}
235+
}
236+
]
237+
}
238+
}
239+
],
240+
"expectEvents": [
241+
{
242+
"client": "client0",
243+
"events": [
244+
{
245+
"commandStartedEvent": {
246+
"command": {
247+
"insert": "test",
248+
"documents": [
249+
{
250+
"_id": 1
251+
}
252+
],
253+
"ordered": true,
254+
"lsid": {
255+
"$$sessionLsid": "session0"
256+
},
257+
"txnNumber": {
258+
"$numberLong": "1"
259+
},
260+
"startTransaction": true,
261+
"autocommit": false,
262+
"readConcern": {
263+
"$$exists": false
264+
},
265+
"writeConcern": {
266+
"$$exists": false
267+
}
268+
},
269+
"commandName": "insert",
270+
"databaseName": "withTransaction-tests"
271+
}
272+
},
273+
{
274+
"commandStartedEvent": {
275+
"command": {
276+
"abortTransaction": 1,
277+
"lsid": {
278+
"$$sessionLsid": "session0"
279+
},
280+
"txnNumber": {
281+
"$numberLong": "1"
282+
},
283+
"autocommit": false,
284+
"readConcern": {
285+
"$$exists": false
286+
},
287+
"startTransaction": {
288+
"$$exists": false
289+
},
290+
"writeConcern": {
291+
"$$exists": false
292+
}
293+
},
294+
"commandName": "abortTransaction",
295+
"databaseName": "admin"
296+
}
297+
},
298+
{
299+
"commandStartedEvent": {
300+
"command": {
301+
"insert": "test",
302+
"documents": [
303+
{
304+
"_id": 2
305+
}
306+
],
307+
"ordered": true,
308+
"lsid": {
309+
"$$sessionLsid": "session0"
310+
},
311+
"autocommit": {
312+
"$$exists": false
313+
},
314+
"readConcern": {
315+
"$$exists": false
316+
},
317+
"startTransaction": {
318+
"$$exists": false
319+
},
320+
"writeConcern": {
321+
"$$exists": false
322+
}
323+
},
324+
"commandName": "insert",
325+
"databaseName": "withTransaction-tests"
326+
}
327+
}
328+
]
329+
}
330+
],
331+
"outcome": [
332+
{
333+
"collectionName": "test",
334+
"databaseName": "withTransaction-tests",
335+
"documents": [
336+
{
337+
"_id": 2
338+
}
339+
]
340+
}
341+
]
342+
}
343+
]
344+
}

0 commit comments

Comments
 (0)