Skip to content

Commit 162ed98

Browse files
Added spec tests for transactions API and convenient transactions API
1 parent 1c2fa76 commit 162ed98

Some content is hidden

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

41 files changed

+29284
-0
lines changed
Lines changed: 244 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,244 @@
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": "withTransaction-tests",
17+
"collection_name": "test",
18+
"data": [],
19+
"tests": [
20+
{
21+
"description": "withTransaction succeeds if callback aborts",
22+
"useMultipleMongoses": true,
23+
"operations": [
24+
{
25+
"name": "withTransaction",
26+
"object": "session0",
27+
"arguments": {
28+
"callback": {
29+
"operations": [
30+
{
31+
"name": "insertOne",
32+
"object": "collection",
33+
"arguments": {
34+
"session": "session0",
35+
"document": {
36+
"_id": 1
37+
}
38+
},
39+
"result": {
40+
"insertedId": 1
41+
}
42+
},
43+
{
44+
"name": "abortTransaction",
45+
"object": "session0"
46+
}
47+
]
48+
}
49+
}
50+
}
51+
],
52+
"expectations": [
53+
{
54+
"command_started_event": {
55+
"command": {
56+
"insert": "test",
57+
"documents": [
58+
{
59+
"_id": 1
60+
}
61+
],
62+
"ordered": true,
63+
"lsid": "session0",
64+
"txnNumber": {
65+
"$numberLong": "1"
66+
},
67+
"startTransaction": true,
68+
"autocommit": false,
69+
"readConcern": null,
70+
"writeConcern": null
71+
},
72+
"command_name": "insert",
73+
"database_name": "withTransaction-tests"
74+
}
75+
},
76+
{
77+
"command_started_event": {
78+
"command": {
79+
"abortTransaction": 1,
80+
"lsid": "session0",
81+
"txnNumber": {
82+
"$numberLong": "1"
83+
},
84+
"autocommit": false,
85+
"readConcern": null,
86+
"startTransaction": null,
87+
"writeConcern": null
88+
},
89+
"command_name": "abortTransaction",
90+
"database_name": "admin"
91+
}
92+
}
93+
],
94+
"outcome": {
95+
"collection": {
96+
"data": []
97+
}
98+
}
99+
},
100+
{
101+
"description": "withTransaction succeeds if callback aborts with no ops",
102+
"useMultipleMongoses": true,
103+
"operations": [
104+
{
105+
"name": "withTransaction",
106+
"object": "session0",
107+
"arguments": {
108+
"callback": {
109+
"operations": [
110+
{
111+
"name": "abortTransaction",
112+
"object": "session0"
113+
}
114+
]
115+
}
116+
}
117+
}
118+
],
119+
"expectations": [],
120+
"outcome": {
121+
"collection": {
122+
"data": []
123+
}
124+
}
125+
},
126+
{
127+
"description": "withTransaction still succeeds if callback aborts and runs extra op",
128+
"useMultipleMongoses": true,
129+
"operations": [
130+
{
131+
"name": "withTransaction",
132+
"object": "session0",
133+
"arguments": {
134+
"callback": {
135+
"operations": [
136+
{
137+
"name": "insertOne",
138+
"object": "collection",
139+
"arguments": {
140+
"session": "session0",
141+
"document": {
142+
"_id": 1
143+
}
144+
},
145+
"result": {
146+
"insertedId": 1
147+
}
148+
},
149+
{
150+
"name": "abortTransaction",
151+
"object": "session0"
152+
},
153+
{
154+
"name": "insertOne",
155+
"object": "collection",
156+
"arguments": {
157+
"session": "session0",
158+
"document": {
159+
"_id": 2
160+
}
161+
},
162+
"result": {
163+
"insertedId": 2
164+
}
165+
}
166+
]
167+
}
168+
}
169+
}
170+
],
171+
"expectations": [
172+
{
173+
"command_started_event": {
174+
"command": {
175+
"insert": "test",
176+
"documents": [
177+
{
178+
"_id": 1
179+
}
180+
],
181+
"ordered": true,
182+
"lsid": "session0",
183+
"txnNumber": {
184+
"$numberLong": "1"
185+
},
186+
"startTransaction": true,
187+
"autocommit": false,
188+
"readConcern": null,
189+
"writeConcern": null
190+
},
191+
"command_name": "insert",
192+
"database_name": "withTransaction-tests"
193+
}
194+
},
195+
{
196+
"command_started_event": {
197+
"command": {
198+
"abortTransaction": 1,
199+
"lsid": "session0",
200+
"txnNumber": {
201+
"$numberLong": "1"
202+
},
203+
"autocommit": false,
204+
"readConcern": null,
205+
"startTransaction": null,
206+
"writeConcern": null
207+
},
208+
"command_name": "abortTransaction",
209+
"database_name": "admin"
210+
}
211+
},
212+
{
213+
"command_started_event": {
214+
"command": {
215+
"insert": "test",
216+
"documents": [
217+
{
218+
"_id": 2
219+
}
220+
],
221+
"ordered": true,
222+
"lsid": "session0",
223+
"autocommit": null,
224+
"readConcern": null,
225+
"startTransaction": null,
226+
"writeConcern": null
227+
},
228+
"command_name": "insert",
229+
"database_name": "withTransaction-tests"
230+
}
231+
}
232+
],
233+
"outcome": {
234+
"collection": {
235+
"data": [
236+
{
237+
"_id": 2
238+
}
239+
]
240+
}
241+
}
242+
}
243+
]
244+
}

0 commit comments

Comments
 (0)