Skip to content

RetryableWriteError label spec tests #725

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 3 commits into from
Mar 10, 2020
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
3 changes: 0 additions & 3 deletions tests/SpecTests/Context.php
Original file line number Diff line number Diff line change
Expand Up @@ -185,9 +185,6 @@ public static function fromRetryableWrites(stdClass $test, $databaseName, $colle

$clientOptions = isset($test->clientOptions) ? (array) $test->clientOptions : [];

// TODO: Remove this once retryWrites=true by default (see: PHPC-1324)
$clientOptions['retryWrites'] = true;

if (isset($test->outcome->collection->name)) {
$o->outcomeCollectionName = $test->outcome->collection->name;
}
Expand Down
2 changes: 1 addition & 1 deletion tests/SpecTests/ResultExpectation.php
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ public static function fromRetryableReads(stdClass $operation, $defaultAssertion

public static function fromRetryableWrites(stdClass $outcome, $defaultAssertionType)
{
if (property_exists($outcome, 'result')) {
if (property_exists($outcome, 'result') && ! self::isErrorResult($outcome->result)) {
Copy link
Member

@jmikola jmikola Mar 10, 2020

Choose a reason for hiding this comment

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

Was this necessary because the retryable writes tests synced in this PR were the first to include error fields under an outcome.result object? For example:

"error": true,
"result": {
  "errorLabelsContain": [
    "RetryableWriteError"
  ]
},

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, other tests didn’t include error results.

$assertionType = $outcome->result === null ? self::ASSERT_NULL : $defaultAssertionType;
$expectedValue = $outcome->result;
} else {
Expand Down
182 changes: 182 additions & 0 deletions tests/SpecTests/retryable-writes/bulkWrite-errorLabels.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,182 @@
{
"runOn": [
{
"minServerVersion": "4.3.1",
"topology": [
"replicaset",
"sharded"
]
}
],
"data": [
{
"_id": 1,
"x": 11
},
{
"_id": 2,
"x": 22
}
],
"tests": [
{
"description": "BulkWrite succeeds with RetryableWriteError from server",
"failPoint": {
"configureFailPoint": "failCommand",
"mode": {
"times": 1
},
"data": {
"failCommands": [
"update"
],
"errorCode": 112,
"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 fails if server does not return RetryableWriteError",
"failPoint": {
"configureFailPoint": "failCommand",
"mode": {
"times": 1
},
"data": {
"failCommands": [
"update"
],
"errorCode": 11600,
"errorLabels": []
}
},
"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": {
"error": true,
"result": {
"errorLabelsOmit": [
"RetryableWriteError"
]
},
"collection": {
"data": [
{
"_id": 2,
"x": 22
},
{
"_id": 3,
"x": 33
}
]
}
}
}
]
}
85 changes: 83 additions & 2 deletions tests/SpecTests/retryable-writes/bulkWrite-serverErrors.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,10 @@
"failCommands": [
"update"
],
"errorCode": 189
"errorCode": 189,
"errorLabels": [
"RetryableWriteError"
]
}
},
"operation": {
Expand Down Expand Up @@ -117,7 +120,10 @@
],
"writeConcernError": {
"code": 91,
"errmsg": "Replication is being shut down"
"errmsg": "Replication is being shut down",
"errorLabels": [
"RetryableWriteError"
]
}
}
},
Expand Down Expand Up @@ -186,6 +192,81 @@
]
}
}
},
{
"description": "BulkWrite fails with a RetryableWriteError label after two connection failures",
"failPoint": {
"configureFailPoint": "failCommand",
"mode": {
"times": 2
},
"data": {
"failCommands": [
"update"
],
"closeConnection": true
}
},
"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": {
"error": true,
"result": {
"errorLabelsContain": [
"RetryableWriteError"
]
},
"collection": {
"data": [
{
"_id": 2,
"x": 22
},
{
"_id": 3,
"x": 33
}
]
}
}
}
]
}
Loading