Skip to content

PHPLIB-1228: Run legacy transaction tests on LB topologies #1148

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Oct 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions tests/SpecTests/Operation.php
Original file line number Diff line number Diff line change
Expand Up @@ -638,6 +638,7 @@ private function executeForTestRunner(FunctionalTestCase $test, Context $context

case 'targetedFailPoint':
$test->assertInstanceOf(Session::class, $args['session']);
$test->assertInstanceOf(Server::class, $args['session']->getServer());
$test->configureFailPoint($this->arguments['failPoint'], $args['session']->getServer());

return null;
Expand Down
74 changes: 74 additions & 0 deletions tests/SpecTests/TransactionsSpecTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,76 @@ class TransactionsSpecTest extends FunctionalTestCase
'transactions/pin-mongos: unpin after transient error within a transaction and commit' => 'isMaster failpoints cannot be disabled',
];

/**
* Any tests that rely on session pinning (including targetedFailPoint) must
* be skipped since libmongoc does not pin on load-balanced toplogies. */
private static array $incompleteLoadBalancerTests = [
'transactions/mongos-pin-auto: remain pinned after non-transient Interrupted error on insertOne' => 'libmongoc does not pin for load-balanced topology',
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is alluded to in the description of CDRIVER-4718 but not actually documented anywhere.

The reason libmongoc does not pin is because a mongoc_client_t only has a single socket per endpoint (e.g. mongod, mongos, LB). Since clients themselves are pooled (unlike connections in other drivers), the idea of connecting pinning doesn't apply for a load balanced topology.

'transactions/mongos-pin-auto: unpin after transient error within a transaction' => 'libmongoc does not pin for load-balanced topology',
'transactions/mongos-pin-auto: remain pinned after non-transient Interrupted error on insertOne insert' => 'libmongoc does not pin for load-balanced topology',
'transactions/mongos-pin-auto: remain pinned after non-transient Interrupted error on insertMany insert' => 'libmongoc does not pin for load-balanced topology',
'transactions/mongos-pin-auto: remain pinned after non-transient Interrupted error on updateOne update' => 'libmongoc does not pin for load-balanced topology',
'transactions/mongos-pin-auto: remain pinned after non-transient Interrupted error on replaceOne update' => 'libmongoc does not pin for load-balanced topology',
'transactions/mongos-pin-auto: remain pinned after non-transient Interrupted error on updateMany update' => 'libmongoc does not pin for load-balanced topology',
'transactions/mongos-pin-auto: remain pinned after non-transient Interrupted error on deleteOne delete' => 'libmongoc does not pin for load-balanced topology',
'transactions/mongos-pin-auto: remain pinned after non-transient Interrupted error on deleteMany delete' => 'libmongoc does not pin for load-balanced topology',
'transactions/mongos-pin-auto: remain pinned after non-transient Interrupted error on findOneAndDelete findAndModify' => 'libmongoc does not pin for load-balanced topology',
'transactions/mongos-pin-auto: remain pinned after non-transient Interrupted error on findOneAndUpdate findAndModify' => 'libmongoc does not pin for load-balanced topology',
'transactions/mongos-pin-auto: remain pinned after non-transient Interrupted error on findOneAndReplace findAndModify' => 'libmongoc does not pin for load-balanced topology',
'transactions/mongos-pin-auto: remain pinned after non-transient Interrupted error on bulkWrite insert' => 'libmongoc does not pin for load-balanced topology',
'transactions/mongos-pin-auto: remain pinned after non-transient Interrupted error on bulkWrite update' => 'libmongoc does not pin for load-balanced topology',
'transactions/mongos-pin-auto: remain pinned after non-transient Interrupted error on bulkWrite delete' => 'libmongoc does not pin for load-balanced topology',
'transactions/mongos-pin-auto: remain pinned after non-transient Interrupted error on find find' => 'libmongoc does not pin for load-balanced topology',
'transactions/mongos-pin-auto: remain pinned after non-transient Interrupted error on countDocuments aggregate' => 'libmongoc does not pin for load-balanced topology',
'transactions/mongos-pin-auto: remain pinned after non-transient Interrupted error on aggregate aggregate' => 'libmongoc does not pin for load-balanced topology',
'transactions/mongos-pin-auto: remain pinned after non-transient Interrupted error on distinct distinct' => 'libmongoc does not pin for load-balanced topology',
'transactions/mongos-pin-auto: remain pinned after non-transient Interrupted error on runCommand insert' => 'libmongoc does not pin for load-balanced topology',
'transactions/mongos-pin-auto: unpin after transient connection error on insertOne insert' => 'libmongoc does not pin for load-balanced topology',
'transactions/mongos-pin-auto: unpin after transient ShutdownInProgress error on insertOne insert' => 'libmongoc does not pin for load-balanced topology',
'transactions/mongos-pin-auto: unpin after transient connection error on insertMany insert' => 'libmongoc does not pin for load-balanced topology',
'transactions/mongos-pin-auto: unpin after transient ShutdownInProgress error on insertMany insert' => 'libmongoc does not pin for load-balanced topology',
'transactions/mongos-pin-auto: unpin after transient connection error on updateOne update' => 'libmongoc does not pin for load-balanced topology',
'transactions/mongos-pin-auto: unpin after transient ShutdownInProgress error on updateOne update' => 'libmongoc does not pin for load-balanced topology',
'transactions/mongos-pin-auto: unpin after transient connection error on replaceOne update' => 'libmongoc does not pin for load-balanced topology',
'transactions/mongos-pin-auto: unpin after transient ShutdownInProgress error on replaceOne update' => 'libmongoc does not pin for load-balanced topology',
'transactions/mongos-pin-auto: unpin after transient connection error on updateMany update' => 'libmongoc does not pin for load-balanced topology',
'transactions/mongos-pin-auto: unpin after transient ShutdownInProgress error on updateMany update' => 'libmongoc does not pin for load-balanced topology',
'transactions/mongos-pin-auto: unpin after transient connection error on deleteOne delete' => 'libmongoc does not pin for load-balanced topology',
'transactions/mongos-pin-auto: unpin after transient ShutdownInProgress error on deleteOne delete' => 'libmongoc does not pin for load-balanced topology',
'transactions/mongos-pin-auto: unpin after transient connection error on deleteMany delete' => 'libmongoc does not pin for load-balanced topology',
'transactions/mongos-pin-auto: unpin after transient ShutdownInProgress error on deleteMany delete' => 'libmongoc does not pin for load-balanced topology',
'transactions/mongos-pin-auto: unpin after transient connection error on findOneAndDelete findAndModify' => 'libmongoc does not pin for load-balanced topology',
'transactions/mongos-pin-auto: unpin after transient ShutdownInProgress error on findOneAndDelete findAndModify' => 'libmongoc does not pin for load-balanced topology',
'transactions/mongos-pin-auto: unpin after transient connection error on findOneAndUpdate findAndModify' => 'libmongoc does not pin for load-balanced topology',
'transactions/mongos-pin-auto: unpin after transient ShutdownInProgress error on findOneAndUpdate findAndModify' => 'libmongoc does not pin for load-balanced topology',
'transactions/mongos-pin-auto: unpin after transient connection error on findOneAndReplace findAndModify' => 'libmongoc does not pin for load-balanced topology',
'transactions/mongos-pin-auto: unpin after transient ShutdownInProgress error on findOneAndReplace findAndModify' => 'libmongoc does not pin for load-balanced topology',
'transactions/mongos-pin-auto: unpin after transient connection error on bulkWrite insert' => 'libmongoc does not pin for load-balanced topology',
'transactions/mongos-pin-auto: unpin after transient ShutdownInProgress error on bulkWrite insert' => 'libmongoc does not pin for load-balanced topology',
'transactions/mongos-pin-auto: unpin after transient connection error on bulkWrite update' => 'libmongoc does not pin for load-balanced topology',
'transactions/mongos-pin-auto: unpin after transient ShutdownInProgress error on bulkWrite update' => 'libmongoc does not pin for load-balanced topology',
'transactions/mongos-pin-auto: unpin after transient connection error on bulkWrite delete' => 'libmongoc does not pin for load-balanced topology',
'transactions/mongos-pin-auto: unpin after transient ShutdownInProgress error on bulkWrite delete' => 'libmongoc does not pin for load-balanced topology',
'transactions/mongos-pin-auto: unpin after transient connection error on find find' => 'libmongoc does not pin for load-balanced topology',
'transactions/mongos-pin-auto: unpin after transient ShutdownInProgress error on find find' => 'libmongoc does not pin for load-balanced topology',
'transactions/mongos-pin-auto: unpin after transient connection error on countDocuments aggregate' => 'libmongoc does not pin for load-balanced topology',
'transactions/mongos-pin-auto: unpin after transient ShutdownInProgress error on countDocuments aggregate' => 'libmongoc does not pin for load-balanced topology',
'transactions/mongos-pin-auto: unpin after transient connection error on aggregate aggregate' => 'libmongoc does not pin for load-balanced topology',
'transactions/mongos-pin-auto: unpin after transient ShutdownInProgress error on aggregate aggregate' => 'libmongoc does not pin for load-balanced topology',
'transactions/mongos-pin-auto: unpin after transient connection error on distinct distinct' => 'libmongoc does not pin for load-balanced topology',
'transactions/mongos-pin-auto: unpin after transient ShutdownInProgress error on distinct distinct' => 'libmongoc does not pin for load-balanced topology',
'transactions/mongos-pin-auto: unpin after transient connection error on runCommand insert' => 'libmongoc does not pin for load-balanced topology',
'transactions/mongos-pin-auto: unpin after transient ShutdownInProgress error on runCommand insert' => 'libmongoc does not pin for load-balanced topology',
'transactions/mongos-recovery-token: commitTransaction explicit retries include recoveryToken' => 'libmongoc omits recoveryToken for load-balanced topology (CDRIVER-4718)',
'transactions/mongos-recovery-token: commitTransaction retry succeeds on new mongos' => 'libmongoc does not pin for load-balanced topology',
'transactions/mongos-recovery-token: commitTransaction retry fails on new mongos' => 'libmongoc does not pin for load-balanced topology',
'transactions/mongos-recovery-token: abortTransaction sends recoveryToken' => 'libmongoc does not pin for load-balanced topology',
'transactions/pin-mongos: multiple commits' => 'libmongoc does not pin for load-balanced topology',
'transactions/pin-mongos: remain pinned after non-transient error on commit' => 'libmongoc does not pin for load-balanced topology',
'transactions/pin-mongos: unpin after transient error within a transaction' => 'libmongoc does not pin for load-balanced topology',
'transactions/pin-mongos: unpin after transient error within a transaction and commit' => 'libmongoc does not pin for load-balanced topology',
];

public function setUp(): void
{
parent::setUp();
Expand Down Expand Up @@ -143,6 +213,10 @@ private function runTransactionTest(stdClass $test, ?array $runOn, array $data,
$this->markTestIncomplete(self::$incompleteTests[$this->dataDescription()]);
}

if ($this->isLoadBalanced() && isset(self::$incompleteLoadBalancerTests[$this->dataDescription()])) {
$this->markTestIncomplete(self::$incompleteLoadBalancerTests[$this->dataDescription()]);
}

if (isset($runOn)) {
$this->checkServerRequirements($runOn);
}
Expand Down
3 changes: 2 additions & 1 deletion tests/SpecTests/transactions/abort.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
{
"minServerVersion": "4.1.8",
"topology": [
"sharded"
"sharded",
"load-balanced"
]
}
],
Expand Down
3 changes: 2 additions & 1 deletion tests/SpecTests/transactions/bulk.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
{
"minServerVersion": "4.1.8",
"topology": [
"sharded"
"sharded",
"load-balanced"
]
}
],
Expand Down
3 changes: 2 additions & 1 deletion tests/SpecTests/transactions/causal-consistency.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
{
"minServerVersion": "4.1.8",
"topology": [
"sharded"
"sharded",
"load-balanced"
]
}
],
Expand Down
3 changes: 2 additions & 1 deletion tests/SpecTests/transactions/commit.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
{
"minServerVersion": "4.1.8",
"topology": [
"sharded"
"sharded",
"load-balanced"
]
}
],
Expand Down
3 changes: 2 additions & 1 deletion tests/SpecTests/transactions/count.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
{
"minServerVersion": "4.1.8",
"topology": [
"sharded"
"sharded",
"load-balanced"
]
}
],
Expand Down
3 changes: 2 additions & 1 deletion tests/SpecTests/transactions/create-collection.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
"minServerVersion": "4.3.4",
"topology": [
"replicaset",
"sharded"
"sharded",
"load-balanced"
]
}
],
Expand Down
3 changes: 2 additions & 1 deletion tests/SpecTests/transactions/create-index.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
"minServerVersion": "4.3.4",
"topology": [
"replicaset",
"sharded"
"sharded",
"load-balanced"
]
}
],
Expand Down
3 changes: 2 additions & 1 deletion tests/SpecTests/transactions/delete.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
{
"minServerVersion": "4.1.8",
"topology": [
"sharded"
"sharded",
"load-balanced"
]
}
],
Expand Down
160 changes: 160 additions & 0 deletions tests/SpecTests/transactions/error-labels-blockConnection.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,160 @@
{
"runOn": [
{
"minServerVersion": "4.2",
"topology": [
"replicaset",
"sharded",
"load-balanced"
]
}
],
"database_name": "transaction-tests",
"collection_name": "test",
"data": [],
"tests": [
{
"description": "add RetryableWriteError and UnknownTransactionCommitResult labels to connection errors",
"clientOptions": {
"socketTimeoutMS": 100
},
"failPoint": {
"configureFailPoint": "failCommand",
"mode": {
"times": 2
},
"data": {
"failCommands": [
"commitTransaction"
],
"blockConnection": true,
"blockTimeMS": 150
}
},
"operations": [
{
"name": "startTransaction",
"object": "session0"
},
{
"name": "insertOne",
"object": "collection",
"arguments": {
"session": "session0",
"document": {
"_id": 1
}
},
"result": {
"insertedId": 1
}
},
{
"name": "commitTransaction",
"object": "session0",
"result": {
"errorLabelsContain": [
"RetryableWriteError",
"UnknownTransactionCommitResult"
],
"errorLabelsOmit": [
"TransientTransactionError"
]
}
},
{
"name": "commitTransaction",
"object": "session0"
}
],
"expectations": [
{
"command_started_event": {
"command": {
"insert": "test",
"documents": [
{
"_id": 1
}
],
"ordered": true,
"readConcern": null,
"lsid": "session0",
"txnNumber": {
"$numberLong": "1"
},
"startTransaction": true,
"autocommit": false,
"writeConcern": null
},
"command_name": "insert",
"database_name": "transaction-tests"
}
},
{
"command_started_event": {
"command": {
"commitTransaction": 1,
"lsid": "session0",
"txnNumber": {
"$numberLong": "1"
},
"startTransaction": null,
"autocommit": false,
"writeConcern": null
},
"command_name": "commitTransaction",
"database_name": "admin"
}
},
{
"command_started_event": {
"command": {
"commitTransaction": 1,
"lsid": "session0",
"txnNumber": {
"$numberLong": "1"
},
"startTransaction": null,
"autocommit": false,
"writeConcern": {
"w": "majority",
"wtimeout": 10000
}
},
"command_name": "commitTransaction",
"database_name": "admin"
}
},
{
"command_started_event": {
"command": {
"commitTransaction": 1,
"lsid": "session0",
"txnNumber": {
"$numberLong": "1"
},
"startTransaction": null,
"autocommit": false,
"writeConcern": {
"w": "majority",
"wtimeout": 10000
}
},
"command_name": "commitTransaction",
"database_name": "admin"
}
}
],
"outcome": {
"collection": {
"data": [
{
"_id": 1
}
]
}
}
}
]
}
3 changes: 2 additions & 1 deletion tests/SpecTests/transactions/error-labels.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
{
"minServerVersion": "4.1.8",
"topology": [
"sharded"
"sharded",
"load-balanced"
],
"serverless": "forbid"
}
Expand Down
3 changes: 2 additions & 1 deletion tests/SpecTests/transactions/errors-client.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
{
"minServerVersion": "4.1.8",
"topology": [
"sharded"
"sharded",
"load-balanced"
]
}
],
Expand Down
3 changes: 2 additions & 1 deletion tests/SpecTests/transactions/errors.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
{
"minServerVersion": "4.1.8",
"topology": [
"sharded"
"sharded",
"load-balanced"
]
}
],
Expand Down
3 changes: 2 additions & 1 deletion tests/SpecTests/transactions/findOneAndDelete.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
{
"minServerVersion": "4.1.8",
"topology": [
"sharded"
"sharded",
"load-balanced"
]
}
],
Expand Down
3 changes: 2 additions & 1 deletion tests/SpecTests/transactions/findOneAndReplace.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
{
"minServerVersion": "4.1.8",
"topology": [
"sharded"
"sharded",
"load-balanced"
]
}
],
Expand Down
3 changes: 2 additions & 1 deletion tests/SpecTests/transactions/findOneAndUpdate.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
{
"minServerVersion": "4.1.8",
"topology": [
"sharded"
"sharded",
"load-balanced"
]
}
],
Expand Down
Loading