Skip to content

PHPLIB-1330: Sync tests for failCommand errorLabels reqs #1214

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
Jan 12, 2024
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
12 changes: 6 additions & 6 deletions tests/SpecTests/RetryableWritesSpecTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,15 +80,17 @@ public function provideTests()
}

/**
* Prose test 1: when encountering a NoWritesPerformed error after an error with a RetryableWriteError label
* Prose test 3: when encountering a NoWritesPerformed error after an error with a RetryableWriteError label
*/
public function testNoWritesPerformedErrorReturnsOriginalError(): void
{
if (! $this->isReplicaSet()) {
$this->markTestSkipped('Test only applies to replica sets');
}

$this->skipIfServerVersion('<', '4.4.0', 'NoWritesPerformed error label is only supported on MongoDB 4.4+');
/* Note: the NoWritesPerformed label was introduced in MongoDB 6.1
* (SERVER-66479), but the test can still be run on earlier versions. */
$this->skipIfServerVersion('<', '6.0.0', 'Test should only be run for MongoDB 6.0+');

$client = self::createTestClient(null, ['retryWrites' => true]);

Expand All @@ -97,11 +99,9 @@ public function testNoWritesPerformedErrorReturnsOriginalError(): void
'configureFailPoint' => 'failCommand',
'mode' => ['times' => 1],
'data' => [
'writeConcernError' => [
'code' => self::SHUTDOWN_IN_PROGRESS,
'errorLabels' => ['RetryableWriteError'],
],
'failCommands' => ['insert'],
'errorLabels' => ['RetryableWriteError'],
'writeConcernError' => ['code' => self::SHUTDOWN_IN_PROGRESS],
],
]);

Expand Down
169 changes: 169 additions & 0 deletions tests/SpecTests/retryable-writes/bulkWrite-errorLabels.json
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,175 @@
]
}
}
},
{
"description": "BulkWrite succeeds after PrimarySteppedDown",
"failPoint": {
"configureFailPoint": "failCommand",
"mode": {
"times": 1
},
"data": {
"failCommands": [
"update"
],
"errorCode": 189,
"errorLabels": [
"RetryableWriteError"
]
}
},
"operation": {
"name": "bulkWrite",
"arguments": {
"requests": [
{
"name": "deleteOne",
"arguments": {
"filter": {
"_id": 1
}
}
},
{
"name": "insertOne",
"arguments": {
"document": {
"_id": 3,
"x": 33
}
}
},
{
"name": "updateOne",
"arguments": {
"filter": {
"_id": 2
},
"update": {
"$inc": {
"x": 1
}
}
}
}
],
"options": {
"ordered": true
}
}
},
"outcome": {
"result": {
"deletedCount": 1,
"insertedCount": 1,
"insertedIds": {
"1": 3
},
"matchedCount": 1,
"modifiedCount": 1,
"upsertedCount": 0,
"upsertedIds": {}
},
"collection": {
"data": [
{
"_id": 2,
"x": 23
},
{
"_id": 3,
"x": 33
}
]
}
}
},
{
"description": "BulkWrite succeeds after WriteConcernError ShutdownInProgress",
"failPoint": {
"configureFailPoint": "failCommand",
"mode": {
"times": 1
},
"data": {
"failCommands": [
"insert"
],
"errorLabels": [
"RetryableWriteError"
],
"writeConcernError": {
"code": 91,
"errmsg": "Replication is being shut down"
}
}
},
"operation": {
"name": "bulkWrite",
"arguments": {
"requests": [
{
"name": "deleteOne",
"arguments": {
"filter": {
"_id": 1
}
}
},
{
"name": "insertOne",
"arguments": {
"document": {
"_id": 3,
"x": 33
}
}
},
{
"name": "updateOne",
"arguments": {
"filter": {
"_id": 2
},
"update": {
"$inc": {
"x": 1
}
}
}
}
],
"options": {
"ordered": true
}
}
},
"outcome": {
"result": {
"deletedCount": 1,
"insertedCount": 1,
"insertedIds": {
"1": 3
},
"matchedCount": 1,
"modifiedCount": 1,
"upsertedCount": 0,
"upsertedIds": {}
},
"collection": {
"data": [
{
"_id": 2,
"x": 23
},
{
"_id": 3,
"x": 33
}
]
}
}
}
]
}
169 changes: 0 additions & 169 deletions tests/SpecTests/retryable-writes/bulkWrite-serverErrors.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,175 +25,6 @@
}
],
"tests": [
{
"description": "BulkWrite succeeds after PrimarySteppedDown",
"failPoint": {
"configureFailPoint": "failCommand",
"mode": {
"times": 1
},
"data": {
"failCommands": [
"update"
],
"errorCode": 189,
"errorLabels": [
"RetryableWriteError"
]
}
},
"operation": {
"name": "bulkWrite",
"arguments": {
"requests": [
{
"name": "deleteOne",
"arguments": {
"filter": {
"_id": 1
}
}
},
{
"name": "insertOne",
"arguments": {
"document": {
"_id": 3,
"x": 33
}
}
},
{
"name": "updateOne",
"arguments": {
"filter": {
"_id": 2
},
"update": {
"$inc": {
"x": 1
}
}
}
}
],
"options": {
"ordered": true
}
}
},
"outcome": {
"result": {
"deletedCount": 1,
"insertedCount": 1,
"insertedIds": {
"1": 3
},
"matchedCount": 1,
"modifiedCount": 1,
"upsertedCount": 0,
"upsertedIds": {}
},
"collection": {
"data": [
{
"_id": 2,
"x": 23
},
{
"_id": 3,
"x": 33
}
]
}
}
},
{
"description": "BulkWrite succeeds after WriteConcernError ShutdownInProgress",
"failPoint": {
"configureFailPoint": "failCommand",
"mode": {
"times": 1
},
"data": {
"failCommands": [
"insert"
],
"errorLabels": [
"RetryableWriteError"
],
"writeConcernError": {
"code": 91,
"errmsg": "Replication is being shut down"
}
}
},
"operation": {
"name": "bulkWrite",
"arguments": {
"requests": [
{
"name": "deleteOne",
"arguments": {
"filter": {
"_id": 1
}
}
},
{
"name": "insertOne",
"arguments": {
"document": {
"_id": 3,
"x": 33
}
}
},
{
"name": "updateOne",
"arguments": {
"filter": {
"_id": 2
},
"update": {
"$inc": {
"x": 1
}
}
}
}
],
"options": {
"ordered": true
}
}
},
"outcome": {
"result": {
"deletedCount": 1,
"insertedCount": 1,
"insertedIds": {
"1": 3
},
"matchedCount": 1,
"modifiedCount": 1,
"upsertedCount": 0,
"upsertedIds": {}
},
"collection": {
"data": [
{
"_id": 2,
"x": 23
},
{
"_id": 3,
"x": 33
}
]
}
}
},
{
"description": "BulkWrite fails with a RetryableWriteError label after two connection failures",
"failPoint": {
Expand Down
Loading