Skip to content

Commit b4a7b2f

Browse files
committed
PHPLIB-1228: Run legacy transaction tests on LB topologies
Synced with mongodb/specifications@38e65fc Skip select legacy transaction spec tests on load balancers (per libmongoc). This includes any tests that rely on session pinning, including those that use targetedFailPoint.
1 parent bb63143 commit b4a7b2f

34 files changed

+984
-696
lines changed

tests/SpecTests/TransactionsSpecTest.php

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,76 @@ class TransactionsSpecTest extends FunctionalTestCase
3636
'transactions/pin-mongos: unpin after transient error within a transaction and commit' => 'isMaster failpoints cannot be disabled',
3737
];
3838

39+
/**
40+
* Any tests that rely on session pinning (including targetedFailPoint) must
41+
* be skipped since libmongoc does not pin on load-balanced toplogies. */
42+
private static array $incompleteLoadBalancerTests = [
43+
'transactions/mongos-pin-auto: remain pinned after non-transient Interrupted error on insertOne' => 'libmongoc does not pin for load-balanced topology',
44+
'transactions/mongos-pin-auto: unpin after transient error within a transaction' => 'libmongoc does not pin for load-balanced topology',
45+
'transactions/mongos-pin-auto: remain pinned after non-transient Interrupted error on insertOne insert' => 'libmongoc does not pin for load-balanced topology',
46+
'transactions/mongos-pin-auto: remain pinned after non-transient Interrupted error on insertMany insert' => 'libmongoc does not pin for load-balanced topology',
47+
'transactions/mongos-pin-auto: remain pinned after non-transient Interrupted error on updateOne update' => 'libmongoc does not pin for load-balanced topology',
48+
'transactions/mongos-pin-auto: remain pinned after non-transient Interrupted error on replaceOne update' => 'libmongoc does not pin for load-balanced topology',
49+
'transactions/mongos-pin-auto: remain pinned after non-transient Interrupted error on updateMany update' => 'libmongoc does not pin for load-balanced topology',
50+
'transactions/mongos-pin-auto: remain pinned after non-transient Interrupted error on deleteOne delete' => 'libmongoc does not pin for load-balanced topology',
51+
'transactions/mongos-pin-auto: remain pinned after non-transient Interrupted error on deleteMany delete' => 'libmongoc does not pin for load-balanced topology',
52+
'transactions/mongos-pin-auto: remain pinned after non-transient Interrupted error on findOneAndDelete findAndModify' => 'libmongoc does not pin for load-balanced topology',
53+
'transactions/mongos-pin-auto: remain pinned after non-transient Interrupted error on findOneAndUpdate findAndModify' => 'libmongoc does not pin for load-balanced topology',
54+
'transactions/mongos-pin-auto: remain pinned after non-transient Interrupted error on findOneAndReplace findAndModify' => 'libmongoc does not pin for load-balanced topology',
55+
'transactions/mongos-pin-auto: remain pinned after non-transient Interrupted error on bulkWrite insert' => 'libmongoc does not pin for load-balanced topology',
56+
'transactions/mongos-pin-auto: remain pinned after non-transient Interrupted error on bulkWrite update' => 'libmongoc does not pin for load-balanced topology',
57+
'transactions/mongos-pin-auto: remain pinned after non-transient Interrupted error on bulkWrite delete' => 'libmongoc does not pin for load-balanced topology',
58+
'transactions/mongos-pin-auto: remain pinned after non-transient Interrupted error on find find' => 'libmongoc does not pin for load-balanced topology',
59+
'transactions/mongos-pin-auto: remain pinned after non-transient Interrupted error on countDocuments aggregate' => 'libmongoc does not pin for load-balanced topology',
60+
'transactions/mongos-pin-auto: remain pinned after non-transient Interrupted error on aggregate aggregate' => 'libmongoc does not pin for load-balanced topology',
61+
'transactions/mongos-pin-auto: remain pinned after non-transient Interrupted error on distinct distinct' => 'libmongoc does not pin for load-balanced topology',
62+
'transactions/mongos-pin-auto: remain pinned after non-transient Interrupted error on runCommand insert' => 'libmongoc does not pin for load-balanced topology',
63+
'transactions/mongos-pin-auto: unpin after transient connection error on insertOne insert' => 'libmongoc does not pin for load-balanced topology',
64+
'transactions/mongos-pin-auto: unpin after transient ShutdownInProgress error on insertOne insert' => 'libmongoc does not pin for load-balanced topology',
65+
'transactions/mongos-pin-auto: unpin after transient connection error on insertMany insert' => 'libmongoc does not pin for load-balanced topology',
66+
'transactions/mongos-pin-auto: unpin after transient ShutdownInProgress error on insertMany insert' => 'libmongoc does not pin for load-balanced topology',
67+
'transactions/mongos-pin-auto: unpin after transient connection error on updateOne update' => 'libmongoc does not pin for load-balanced topology',
68+
'transactions/mongos-pin-auto: unpin after transient ShutdownInProgress error on updateOne update' => 'libmongoc does not pin for load-balanced topology',
69+
'transactions/mongos-pin-auto: unpin after transient connection error on replaceOne update' => 'libmongoc does not pin for load-balanced topology',
70+
'transactions/mongos-pin-auto: unpin after transient ShutdownInProgress error on replaceOne update' => 'libmongoc does not pin for load-balanced topology',
71+
'transactions/mongos-pin-auto: unpin after transient connection error on updateMany update' => 'libmongoc does not pin for load-balanced topology',
72+
'transactions/mongos-pin-auto: unpin after transient ShutdownInProgress error on updateMany update' => 'libmongoc does not pin for load-balanced topology',
73+
'transactions/mongos-pin-auto: unpin after transient connection error on deleteOne delete' => 'libmongoc does not pin for load-balanced topology',
74+
'transactions/mongos-pin-auto: unpin after transient ShutdownInProgress error on deleteOne delete' => 'libmongoc does not pin for load-balanced topology',
75+
'transactions/mongos-pin-auto: unpin after transient connection error on deleteMany delete' => 'libmongoc does not pin for load-balanced topology',
76+
'transactions/mongos-pin-auto: unpin after transient ShutdownInProgress error on deleteMany delete' => 'libmongoc does not pin for load-balanced topology',
77+
'transactions/mongos-pin-auto: unpin after transient connection error on findOneAndDelete findAndModify' => 'libmongoc does not pin for load-balanced topology',
78+
'transactions/mongos-pin-auto: unpin after transient ShutdownInProgress error on findOneAndDelete findAndModify' => 'libmongoc does not pin for load-balanced topology',
79+
'transactions/mongos-pin-auto: unpin after transient connection error on findOneAndUpdate findAndModify' => 'libmongoc does not pin for load-balanced topology',
80+
'transactions/mongos-pin-auto: unpin after transient ShutdownInProgress error on findOneAndUpdate findAndModify' => 'libmongoc does not pin for load-balanced topology',
81+
'transactions/mongos-pin-auto: unpin after transient connection error on findOneAndReplace findAndModify' => 'libmongoc does not pin for load-balanced topology',
82+
'transactions/mongos-pin-auto: unpin after transient ShutdownInProgress error on findOneAndReplace findAndModify' => 'libmongoc does not pin for load-balanced topology',
83+
'transactions/mongos-pin-auto: unpin after transient connection error on bulkWrite insert' => 'libmongoc does not pin for load-balanced topology',
84+
'transactions/mongos-pin-auto: unpin after transient ShutdownInProgress error on bulkWrite insert' => 'libmongoc does not pin for load-balanced topology',
85+
'transactions/mongos-pin-auto: unpin after transient connection error on bulkWrite update' => 'libmongoc does not pin for load-balanced topology',
86+
'transactions/mongos-pin-auto: unpin after transient ShutdownInProgress error on bulkWrite update' => 'libmongoc does not pin for load-balanced topology',
87+
'transactions/mongos-pin-auto: unpin after transient connection error on bulkWrite delete' => 'libmongoc does not pin for load-balanced topology',
88+
'transactions/mongos-pin-auto: unpin after transient ShutdownInProgress error on bulkWrite delete' => 'libmongoc does not pin for load-balanced topology',
89+
'transactions/mongos-pin-auto: unpin after transient connection error on find find' => 'libmongoc does not pin for load-balanced topology',
90+
'transactions/mongos-pin-auto: unpin after transient ShutdownInProgress error on find find' => 'libmongoc does not pin for load-balanced topology',
91+
'transactions/mongos-pin-auto: unpin after transient connection error on countDocuments aggregate' => 'libmongoc does not pin for load-balanced topology',
92+
'transactions/mongos-pin-auto: unpin after transient ShutdownInProgress error on countDocuments aggregate' => 'libmongoc does not pin for load-balanced topology',
93+
'transactions/mongos-pin-auto: unpin after transient connection error on aggregate aggregate' => 'libmongoc does not pin for load-balanced topology',
94+
'transactions/mongos-pin-auto: unpin after transient ShutdownInProgress error on aggregate aggregate' => 'libmongoc does not pin for load-balanced topology',
95+
'transactions/mongos-pin-auto: unpin after transient connection error on distinct distinct' => 'libmongoc does not pin for load-balanced topology',
96+
'transactions/mongos-pin-auto: unpin after transient ShutdownInProgress error on distinct distinct' => 'libmongoc does not pin for load-balanced topology',
97+
'transactions/mongos-pin-auto: unpin after transient connection error on runCommand insert' => 'libmongoc does not pin for load-balanced topology',
98+
'transactions/mongos-pin-auto: unpin after transient ShutdownInProgress error on runCommand insert' => 'libmongoc does not pin for load-balanced topology',
99+
'transactions/mongos-recovery-token: commitTransaction explicit retries include recoveryToken' => 'libmongoc omits recoveryToken for load-balanced topology (CDRIVER-4718)',
100+
'transactions/mongos-recovery-token: commitTransaction retry succeeds on new mongos' => 'libmongoc does not pin for load-balanced topology',
101+
'transactions/mongos-recovery-token: commitTransaction retry fails on new mongos' => 'libmongoc does not pin for load-balanced topology',
102+
'transactions/mongos-recovery-token: abortTransaction sends recoveryToken' => 'libmongoc does not pin for load-balanced topology',
103+
'transactions/pin-mongos: multiple commits' => 'libmongoc does not pin for load-balanced topology',
104+
'transactions/pin-mongos: remain pinned after non-transient error on commit' => 'libmongoc does not pin for load-balanced topology',
105+
'transactions/pin-mongos: unpin after transient error within a transaction' => 'libmongoc does not pin for load-balanced topology',
106+
'transactions/pin-mongos: unpin after transient error within a transaction and commit' => 'libmongoc does not pin for load-balanced topology',
107+
];
108+
39109
public function setUp(): void
40110
{
41111
parent::setUp();
@@ -143,6 +213,10 @@ private function runTransactionTest(stdClass $test, ?array $runOn, array $data,
143213
$this->markTestIncomplete(self::$incompleteTests[$this->dataDescription()]);
144214
}
145215

216+
if ($this->isLoadBalanced() && isset(self::$incompleteLoadBalancerTests[$this->dataDescription()])) {
217+
$this->markTestIncomplete(self::$incompleteLoadBalancerTests[$this->dataDescription()]);
218+
}
219+
146220
if (isset($runOn)) {
147221
$this->checkServerRequirements($runOn);
148222
}

tests/SpecTests/transactions/abort.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@
99
{
1010
"minServerVersion": "4.1.8",
1111
"topology": [
12-
"sharded"
12+
"sharded",
13+
"load-balanced"
1314
]
1415
}
1516
],

tests/SpecTests/transactions/bulk.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@
99
{
1010
"minServerVersion": "4.1.8",
1111
"topology": [
12-
"sharded"
12+
"sharded",
13+
"load-balanced"
1314
]
1415
}
1516
],

tests/SpecTests/transactions/causal-consistency.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@
99
{
1010
"minServerVersion": "4.1.8",
1111
"topology": [
12-
"sharded"
12+
"sharded",
13+
"load-balanced"
1314
]
1415
}
1516
],

tests/SpecTests/transactions/commit.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@
99
{
1010
"minServerVersion": "4.1.8",
1111
"topology": [
12-
"sharded"
12+
"sharded",
13+
"load-balanced"
1314
]
1415
}
1516
],

tests/SpecTests/transactions/count.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@
99
{
1010
"minServerVersion": "4.1.8",
1111
"topology": [
12-
"sharded"
12+
"sharded",
13+
"load-balanced"
1314
]
1415
}
1516
],

tests/SpecTests/transactions/create-collection.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44
"minServerVersion": "4.3.4",
55
"topology": [
66
"replicaset",
7-
"sharded"
7+
"sharded",
8+
"load-balanced"
89
]
910
}
1011
],

tests/SpecTests/transactions/create-index.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44
"minServerVersion": "4.3.4",
55
"topology": [
66
"replicaset",
7-
"sharded"
7+
"sharded",
8+
"load-balanced"
89
]
910
}
1011
],

tests/SpecTests/transactions/delete.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@
99
{
1010
"minServerVersion": "4.1.8",
1111
"topology": [
12-
"sharded"
12+
"sharded",
13+
"load-balanced"
1314
]
1415
}
1516
],
Lines changed: 160 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,160 @@
1+
{
2+
"runOn": [
3+
{
4+
"minServerVersion": "4.2",
5+
"topology": [
6+
"replicaset",
7+
"sharded",
8+
"load-balanced"
9+
]
10+
}
11+
],
12+
"database_name": "transaction-tests",
13+
"collection_name": "test",
14+
"data": [],
15+
"tests": [
16+
{
17+
"description": "add RetryableWriteError and UnknownTransactionCommitResult labels to connection errors",
18+
"clientOptions": {
19+
"socketTimeoutMS": 100
20+
},
21+
"failPoint": {
22+
"configureFailPoint": "failCommand",
23+
"mode": {
24+
"times": 2
25+
},
26+
"data": {
27+
"failCommands": [
28+
"commitTransaction"
29+
],
30+
"blockConnection": true,
31+
"blockTimeMS": 150
32+
}
33+
},
34+
"operations": [
35+
{
36+
"name": "startTransaction",
37+
"object": "session0"
38+
},
39+
{
40+
"name": "insertOne",
41+
"object": "collection",
42+
"arguments": {
43+
"session": "session0",
44+
"document": {
45+
"_id": 1
46+
}
47+
},
48+
"result": {
49+
"insertedId": 1
50+
}
51+
},
52+
{
53+
"name": "commitTransaction",
54+
"object": "session0",
55+
"result": {
56+
"errorLabelsContain": [
57+
"RetryableWriteError",
58+
"UnknownTransactionCommitResult"
59+
],
60+
"errorLabelsOmit": [
61+
"TransientTransactionError"
62+
]
63+
}
64+
},
65+
{
66+
"name": "commitTransaction",
67+
"object": "session0"
68+
}
69+
],
70+
"expectations": [
71+
{
72+
"command_started_event": {
73+
"command": {
74+
"insert": "test",
75+
"documents": [
76+
{
77+
"_id": 1
78+
}
79+
],
80+
"ordered": true,
81+
"readConcern": null,
82+
"lsid": "session0",
83+
"txnNumber": {
84+
"$numberLong": "1"
85+
},
86+
"startTransaction": true,
87+
"autocommit": false,
88+
"writeConcern": null
89+
},
90+
"command_name": "insert",
91+
"database_name": "transaction-tests"
92+
}
93+
},
94+
{
95+
"command_started_event": {
96+
"command": {
97+
"commitTransaction": 1,
98+
"lsid": "session0",
99+
"txnNumber": {
100+
"$numberLong": "1"
101+
},
102+
"startTransaction": null,
103+
"autocommit": false,
104+
"writeConcern": null
105+
},
106+
"command_name": "commitTransaction",
107+
"database_name": "admin"
108+
}
109+
},
110+
{
111+
"command_started_event": {
112+
"command": {
113+
"commitTransaction": 1,
114+
"lsid": "session0",
115+
"txnNumber": {
116+
"$numberLong": "1"
117+
},
118+
"startTransaction": null,
119+
"autocommit": false,
120+
"writeConcern": {
121+
"w": "majority",
122+
"wtimeout": 10000
123+
}
124+
},
125+
"command_name": "commitTransaction",
126+
"database_name": "admin"
127+
}
128+
},
129+
{
130+
"command_started_event": {
131+
"command": {
132+
"commitTransaction": 1,
133+
"lsid": "session0",
134+
"txnNumber": {
135+
"$numberLong": "1"
136+
},
137+
"startTransaction": null,
138+
"autocommit": false,
139+
"writeConcern": {
140+
"w": "majority",
141+
"wtimeout": 10000
142+
}
143+
},
144+
"command_name": "commitTransaction",
145+
"database_name": "admin"
146+
}
147+
}
148+
],
149+
"outcome": {
150+
"collection": {
151+
"data": [
152+
{
153+
"_id": 1
154+
}
155+
]
156+
}
157+
}
158+
}
159+
]
160+
}

tests/SpecTests/transactions/error-labels.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@
99
{
1010
"minServerVersion": "4.1.8",
1111
"topology": [
12-
"sharded"
12+
"sharded",
13+
"load-balanced"
1314
],
1415
"serverless": "forbid"
1516
}

tests/SpecTests/transactions/errors-client.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@
99
{
1010
"minServerVersion": "4.1.8",
1111
"topology": [
12-
"sharded"
12+
"sharded",
13+
"load-balanced"
1314
]
1415
}
1516
],

tests/SpecTests/transactions/errors.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@
99
{
1010
"minServerVersion": "4.1.8",
1111
"topology": [
12-
"sharded"
12+
"sharded",
13+
"load-balanced"
1314
]
1415
}
1516
],

tests/SpecTests/transactions/findOneAndDelete.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@
99
{
1010
"minServerVersion": "4.1.8",
1111
"topology": [
12-
"sharded"
12+
"sharded",
13+
"load-balanced"
1314
]
1415
}
1516
],

tests/SpecTests/transactions/findOneAndReplace.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@
99
{
1010
"minServerVersion": "4.1.8",
1111
"topology": [
12-
"sharded"
12+
"sharded",
13+
"load-balanced"
1314
]
1415
}
1516
],

tests/SpecTests/transactions/findOneAndUpdate.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@
99
{
1010
"minServerVersion": "4.1.8",
1111
"topology": [
12-
"sharded"
12+
"sharded",
13+
"load-balanced"
1314
]
1415
}
1516
],

tests/SpecTests/transactions/insert.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@
99
{
1010
"minServerVersion": "4.1.8",
1111
"topology": [
12-
"sharded"
12+
"sharded",
13+
"load-balanced"
1314
]
1415
}
1516
],

0 commit comments

Comments
 (0)