Skip to content

Commit 45c67f5

Browse files
authored
CSHARP-4267: Updated to latest transaction spec tests and enabled load balanced transaction spec tests. (#872)
1 parent 786e324 commit 45c67f5

File tree

5 files changed

+236
-8
lines changed

5 files changed

+236
-8
lines changed

tests/MongoDB.Driver.Tests/Specifications/transactions/TransactionUnifiedTestRunner.cs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,6 @@ public TransactionUnifiedTestRunner(ITestOutputHelper testOutputHelper)
3838
[ClassData(typeof(TestCaseFactory))]
3939
public void Run(JsonDrivenTestCase testCase)
4040
{
41-
if (testCase.Name.Contains("mongos-unpin.json"))
42-
{
43-
throw new SkipException("Load balancer support not yet implemented.");
44-
}
45-
4641
using (var runner = new UnifiedTestRunner(loggerFactory: LoggerFactory))
4742
{
4843
runner.Run(testCase);
Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
{
2+
"description": "do not retry read in a transaction",
3+
"schemaVersion": "1.4",
4+
"runOnRequirements": [
5+
{
6+
"minServerVersion": "4.0.0",
7+
"topologies": [
8+
"replicaset"
9+
]
10+
},
11+
{
12+
"minServerVersion": "4.2.0",
13+
"topologies": [
14+
"sharded",
15+
"load-balanced"
16+
]
17+
}
18+
],
19+
"createEntities": [
20+
{
21+
"client": {
22+
"id": "client0",
23+
"useMultipleMongoses": false,
24+
"observeEvents": [
25+
"commandStartedEvent"
26+
],
27+
"uriOptions": {
28+
"retryReads": true
29+
}
30+
}
31+
},
32+
{
33+
"database": {
34+
"id": "database0",
35+
"client": "client0",
36+
"databaseName": "retryable-read-in-transaction-test"
37+
}
38+
},
39+
{
40+
"collection": {
41+
"id": "collection0",
42+
"database": "database0",
43+
"collectionName": "coll"
44+
}
45+
},
46+
{
47+
"session": {
48+
"id": "session0",
49+
"client": "client0"
50+
}
51+
}
52+
],
53+
"tests": [
54+
{
55+
"description": "find does not retry in a transaction",
56+
"operations": [
57+
{
58+
"name": "startTransaction",
59+
"object": "session0"
60+
},
61+
{
62+
"name": "failPoint",
63+
"object": "testRunner",
64+
"arguments": {
65+
"client": "client0",
66+
"failPoint": {
67+
"configureFailPoint": "failCommand",
68+
"mode": {
69+
"times": 1
70+
},
71+
"data": {
72+
"failCommands": [
73+
"find"
74+
],
75+
"closeConnection": true
76+
}
77+
}
78+
}
79+
},
80+
{
81+
"name": "find",
82+
"object": "collection0",
83+
"arguments": {
84+
"filter": {},
85+
"session": "session0"
86+
},
87+
"expectError": {
88+
"isError": true,
89+
"errorLabelsContain": [
90+
"TransientTransactionError"
91+
]
92+
}
93+
}
94+
],
95+
"expectEvents": [
96+
{
97+
"client": "client0",
98+
"events": [
99+
{
100+
"commandStartedEvent": {
101+
"command": {
102+
"find": "coll",
103+
"filter": {},
104+
"startTransaction": true
105+
},
106+
"commandName": "find",
107+
"databaseName": "retryable-read-in-transaction-test"
108+
}
109+
}
110+
]
111+
}
112+
]
113+
}
114+
]
115+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
description: "do not retry read in a transaction"
2+
3+
schemaVersion: "1.4"
4+
5+
runOnRequirements:
6+
- minServerVersion: "4.0.0"
7+
topologies: [ replicaset ]
8+
- minServerVersion: "4.2.0"
9+
topologies: [ sharded, load-balanced ]
10+
11+
createEntities:
12+
- client:
13+
id: &client0 client0
14+
useMultipleMongoses: false
15+
observeEvents: [commandStartedEvent]
16+
uriOptions: { retryReads: true }
17+
- database:
18+
id: &database0 database0
19+
client: *client0
20+
databaseName: &databaseName retryable-read-in-transaction-test
21+
- collection:
22+
id: &collection0 collection0
23+
database: *database0
24+
collectionName: &collectionName coll
25+
- session:
26+
id: &session0 session0
27+
client: *client0
28+
29+
tests:
30+
- description: "find does not retry in a transaction"
31+
operations:
32+
33+
- name: startTransaction
34+
object: *session0
35+
36+
- name: failPoint # fail the following find command
37+
object: testRunner
38+
arguments:
39+
client: *client0
40+
failPoint:
41+
configureFailPoint: failCommand
42+
mode: { times: 1 }
43+
data:
44+
failCommands: [find]
45+
closeConnection: true
46+
47+
- name: find
48+
object: *collection0
49+
arguments:
50+
filter: {}
51+
session: *session0
52+
expectError:
53+
isError: true
54+
errorLabelsContain: ["TransientTransactionError"]
55+
expectEvents:
56+
- client: *client0
57+
events:
58+
- commandStartedEvent:
59+
command:
60+
find: *collectionName
61+
filter: {}
62+
startTransaction: true
63+
commandName: find
64+
databaseName: *databaseName

tests/MongoDB.Driver.Tests/Specifications/transactions/tests/unified/mongos-unpin.json

Lines changed: 56 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,24 @@
108108
"arguments": {
109109
"session": "session0"
110110
}
111+
},
112+
{
113+
"name": "startTransaction",
114+
"object": "session0"
115+
},
116+
{
117+
"name": "insertOne",
118+
"object": "collection0",
119+
"arguments": {
120+
"document": {
121+
"x": 1
122+
},
123+
"session": "session0"
124+
}
125+
},
126+
{
127+
"name": "abortTransaction",
128+
"object": "session0"
111129
}
112130
]
113131
},
@@ -142,7 +160,7 @@
142160
]
143161
},
144162
{
145-
"description": "unpin after TransientTransactionError error on abort",
163+
"description": "unpin after non-transient error on abort",
146164
"runOnRequirements": [
147165
{
148166
"serverless": "forbid"
@@ -192,11 +210,29 @@
192210
"arguments": {
193211
"session": "session0"
194212
}
213+
},
214+
{
215+
"name": "startTransaction",
216+
"object": "session0"
217+
},
218+
{
219+
"name": "insertOne",
220+
"object": "collection0",
221+
"arguments": {
222+
"document": {
223+
"x": 1
224+
},
225+
"session": "session0"
226+
}
227+
},
228+
{
229+
"name": "abortTransaction",
230+
"object": "session0"
195231
}
196232
]
197233
},
198234
{
199-
"description": "unpin after non-transient error on abort",
235+
"description": "unpin after TransientTransactionError error on abort",
200236
"operations": [
201237
{
202238
"name": "startTransaction",
@@ -241,6 +277,24 @@
241277
"arguments": {
242278
"session": "session0"
243279
}
280+
},
281+
{
282+
"name": "startTransaction",
283+
"object": "session0"
284+
},
285+
{
286+
"name": "insertOne",
287+
"object": "collection0",
288+
"arguments": {
289+
"document": {
290+
"x": 1
291+
},
292+
"session": "session0"
293+
}
294+
},
295+
{
296+
"name": "abortTransaction",
297+
"object": "session0"
244298
}
245299
]
246300
},

tests/MongoDB.Driver.Tests/Specifications/transactions/tests/unified/mongos-unpin.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ tests:
8585
- *abortTransaction
8686
- *assertNoPinnedServer
8787

88-
- description: unpin after TransientTransactionError error on abort
88+
- description: unpin after non-transient error on abort
8989
runOnRequirements:
9090
# serverless proxy doesn't append error labels to errors in transactions
9191
# caused by failpoints (CLOUDP-88216)

0 commit comments

Comments
 (0)