Commit ab5246d8 authored by Jeremy Mikola's avatar Jeremy Mikola

PHPLIB-307: Retryable writes test runner

Spec tests synced with mongodb/specifications@83a0e6b56bfd73b471c1b740190dbbb7c52ffa92
parent d444ddea
This diff is collapsed.
<?php
namespace MongoDB\Tests\SpecTests;
/**
* Retryable writes spec tests.
*
* @see https://github.com/mongodb/specifications/tree/master/source/retryable-writes
*/
class RetryableWritesSpecTest extends FunctionalTestCase
{
/**
* Execute an individual test case from the specification.
*
* @dataProvider provideTests
* @param string $name Test name
* @param array $test Individual "tests[]" document
* @param array $runOn Top-level "runOn" document
* @param array $data Top-level "data" array to initialize collection
*/
public function testRetryableWrites($name, array $test, array $runOn = null, array $data)
{
$this->setName($name);
if (isset($runOn)) {
$this->checkServerRequirements($runOn);
}
// TODO: Remove this once retryWrites=true by default (see: PHPC-1324)
$test['clientOptions']['retryWrites'] = true;
$this->initTestSubjects($test);
$this->initOutcomeCollection($test);
$this->initDataFixtures($data);
if (isset($test['failPoint'])) {
$this->configureFailPoint($test['failPoint']);
}
$this->assertOperation($test['operation'], $test['outcome']);
if (isset($test['outcome']['collection']['data'])) {
$this->assertOutcomeCollectionData($test['outcome']['collection']['data']);
}
}
public function provideTests()
{
$testArgs = [];
foreach (glob(__DIR__ . '/retryable-writes/*.json') as $filename) {
$json = json_decode(file_get_contents($filename), true);
$group = basename($filename, '.json');
$runOn = isset($json['runOn']) ? $json['runOn'] : null;
$data = isset($json['data']) ? $json['data'] : [];
foreach ($json['tests'] as $test) {
$name = $group . ': ' . $test['description'];
$testArgs[] = [$name, $test, $runOn, $data];
}
}
return $testArgs;
}
}
{
"runOn": [
{
"minServerVersion": "4.0",
"topology": [
"replicaset"
]
},
{
"minServerVersion": "4.1.7",
"topology": [
"sharded"
]
}
],
"data": [
{
"_id": 1,
"x": 11
},
{
"_id": 2,
"x": 22
}
],
"tests": [
{
"description": "BulkWrite succeeds after PrimarySteppedDown",
"failPoint": {
"configureFailPoint": "failCommand",
"mode": {
"times": 1
},
"data": {
"failCommands": [
"update"
],
"errorCode": 189
}
},
"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"
],
"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
}
]
}
}
}
]
}
This diff is collapsed.
{
"runOn": [
{
"minServerVersion": "3.6",
"topology": [
"replicaset",
"sharded"
]
}
],
"data": [
{
"_id": 1,
"x": 11
},
{
"_id": 2,
"x": 22
}
],
"tests": [
{
"description": "DeleteMany ignores retryWrites",
"useMultipleMongoses": true,
"operation": {
"name": "deleteMany",
"arguments": {
"filter": {}
}
},
"outcome": {
"result": {
"deletedCount": 2
},
"collection": {
"data": []
}
}
}
]
}
{
"runOn": [
{
"minServerVersion": "4.0",
"topology": [
"replicaset"
]
},
{
"minServerVersion": "4.1.7",
"topology": [
"sharded"
]
}
],
"data": [
{
"_id": 1,
"x": 11
},
{
"_id": 2,
"x": 22
}
],
"tests": [
{
"description": "DeleteOne succeeds after PrimarySteppedDown",
"failPoint": {
"configureFailPoint": "failCommand",
"mode": {
"times": 1
},
"data": {
"failCommands": [
"delete"
],
"errorCode": 189
}
},
"operation": {
"name": "deleteOne",
"arguments": {
"filter": {
"_id": 1
}
}
},
"outcome": {
"result": {
"deletedCount": 1
},
"collection": {
"data": [
{
"_id": 2,
"x": 22
}
]
}
}
},
{
"description": "DeleteOne succeeds after WriteConcernError ShutdownInProgress",
"failPoint": {
"configureFailPoint": "failCommand",
"mode": {
"times": 1
},
"data": {
"failCommands": [
"delete"
],
"writeConcernError": {
"code": 91,
"errmsg": "Replication is being shut down"
}
}
},
"operation": {
"name": "deleteOne",
"arguments": {
"filter": {
"_id": 1
}
}
},
"outcome": {
"result": {
"deletedCount": 1
},
"collection": {
"data": [
{
"_id": 2,
"x": 22
}
]
}
}
}
]
}
{
"runOn": [
{
"minServerVersion": "3.6",
"topology": [
"replicaset"
]
}
],
"data": [
{
"_id": 1,
"x": 11
},
{
"_id": 2,
"x": 22
}
],
"tests": [
{
"description": "DeleteOne is committed on first attempt",
"failPoint": {
"configureFailPoint": "onPrimaryTransactionalWrite",
"mode": {
"times": 1
}
},
"operation": {
"name": "deleteOne",
"arguments": {
"filter": {
"_id": 1
}
}
},
"outcome": {
"result": {
"deletedCount": 1
},
"collection": {
"data": [
{
"_id": 2,
"x": 22
}
]
}
}
},
{
"description": "DeleteOne is not committed on first attempt",
"failPoint": {
"configureFailPoint": "onPrimaryTransactionalWrite",
"mode": {
"times": 1
},
"data": {
"failBeforeCommitExceptionCode": 1
}
},
"operation": {
"name": "deleteOne",
"arguments": {
"filter": {
"_id": 1
}
}
},
"outcome": {
"result": {
"deletedCount": 1
},
"collection": {
"data": [
{
"_id": 2,
"x": 22
}
]
}
}
},
{
"description": "DeleteOne is never committed",
"failPoint": {
"configureFailPoint": "onPrimaryTransactionalWrite",
"mode": {
"times": 2
},
"data": {
"failBeforeCommitExceptionCode": 1
}
},
"operation": {
"name": "deleteOne",
"arguments": {
"filter": {
"_id": 1
}
}
},
"outcome": {
"error": true,
"collection": {
"data": [
{
"_id": 1,
"x": 11
},
{
"_id": 2,
"x": 22
}
]
}
}
}
]
}
{
"runOn": [
{
"minServerVersion": "4.0",
"topology": [
"replicaset"
]
},
{
"minServerVersion": "4.1.7",
"topology": [
"sharded"
]
}
],
"data": [
{
"_id": 1,
"x": 11
},
{
"_id": 2,
"x": 22
}
],
"tests": [
{
"description": "FindOneAndDelete succeeds after PrimarySteppedDown",
"failPoint": {
"configureFailPoint": "failCommand",
"mode": {
"times": 1
},
"data": {
"failCommands": [
"findAndModify"
],
"errorCode": 189
}
},
"operation": {
"name": "findOneAndDelete",
"arguments": {
"filter": {
"x": {
"$gte": 11
}
},
"sort": {
"x": 1
}
}
},
"outcome": {
"result": {
"_id": 1,
"x": 11
},
"collection": {
"data": [
{
"_id": 2,
"x": 22
}
]
}
}
},
{
"description": "FindOneAndDelete succeeds after WriteConcernError ShutdownInProgress",
"failPoint": {
"configureFailPoint": "failCommand",
"mode": {
"times": 1
},
"data": {
"failCommands": [
"findAndModify"
],
"writeConcernError": {
"code": 91,
"errmsg": "Replication is being shut down"
}
}
},
"operation": {
"name": "findOneAndDelete",
"arguments": {
"filter": {
"x": {
"$gte": 11
}
},
"sort": {
"x": 1
}
}
},
"outcome": {
"result": {
"_id": 1,
"x": 11
},
"collection": {
"data": [
{
"_id": 2,
"x": 22
}
]
}
}
}
]
}
{
"runOn": [
{
"minServerVersion": "3.6",
"topology": [
"replicaset"
]
}
],
"data": [
{
"_id": 1,
"x": 11
},
{
"_id": 2,
"x": 22
}
],
"tests": [
{
"description": "FindOneAndDelete is committed on first attempt",
"failPoint": {
"configureFailPoint": "onPrimaryTransactionalWrite",
"mode": {
"times": 1
}
},
"operation": {
"name": "findOneAndDelete",
"arguments": {
"filter": {
"x": {
"$gte": 11
}
},
"sort": {
"x": 1
}
}
},
"outcome": {
"result": {
"_id": 1,
"x": 11
},
"collection": {
"data": [
{
"_id": 2,
"x": 22
}
]
}
}
},
{
"description": "FindOneAndDelete is not committed on first attempt",
"failPoint": {
"configureFailPoint": "onPrimaryTransactionalWrite",
"mode": {
"times": 1
},
"data": {
"failBeforeCommitExceptionCode": 1
}
},
"operation": {
"name": "findOneAndDelete",
"arguments": {
"filter": {
"x": {
"$gte": 11
}
},
"sort": {
"x": 1
}
}
},
"outcome": {
"result": {
"_id": 1,
"x": 11
},
"collection": {
"data": [
{
"_id": 2,
"x": 22
}
]
}
}
},
{
"description": "FindOneAndDelete is never committed",
"failPoint": {
"configureFailPoint": "onPrimaryTransactionalWrite",
"mode": {
"times": 2
},
"data": {
"failBeforeCommitExceptionCode": 1
}
},
"operation": {
"name": "findOneAndDelete",
"arguments": {
"filter": {
"x": {
"$gte": 11
}
},
"sort": {
"x": 1
}
}
},
"outcome": {
"error": true,
"collection": {
"data": [
{
"_id": 1,
"x": 11
},
{
"_id": 2,
"x": 22
}
]
}
}
}
]
}
{
"runOn": [
{
"minServerVersion": "4.0",
"topology": [
"replicaset"
]
},
{
"minServerVersion": "4.1.7",
"topology": [
"sharded"
]
}
],
"data": [
{
"_id": 1,
"x": 11
},
{
"_id": 2,
"x": 22
}
],
"tests": [
{
"description": "FindOneAndReplace succeeds after PrimarySteppedDown",
"failPoint": {
"configureFailPoint": "failCommand",
"mode": {
"times": 1
},
"data": {
"failCommands": [
"findAndModify"
],
"errorCode": 189
}
},
"operation": {
"name": "findOneAndReplace",
"arguments": {
"filter": {
"_id": 1
},
"replacement": {
"_id": 1,
"x": 111
},
"returnDocument": "Before"
}
},
"outcome": {
"result": {
"_id": 1,
"x": 11
},
"collection": {
"data": [
{
"_id": 1,
"x": 111
},
{
"_id": 2,
"x": 22
}
]
}
}
},
{
"description": "FindOneAndReplace succeeds after WriteConcernError ShutdownInProgress",
"failPoint": {
"configureFailPoint": "failCommand",
"mode": {
"times": 1
},
"data": {
"failCommands": [
"findAndModify"
],
"writeConcernError": {
"code": 91,
"errmsg": "Replication is being shut down"
}
}
},
"operation": {
"name": "findOneAndReplace",
"arguments": {
"filter": {
"_id": 1
},
"replacement": {
"_id": 1,
"x": 111
},
"returnDocument": "Before"
}
},
"outcome": {
"result": {
"_id": 1,
"x": 11
},
"collection": {
"data": [
{
"_id": 1,
"x": 111
},
{
"_id": 2,
"x": 22
}
]
}
}
}
]
}
{
"runOn": [
{
"minServerVersion": "3.6",
"topology": [
"replicaset"
]
}
],
"data": [
{
"_id": 1,
"x": 11
},
{
"_id": 2,
"x": 22
}
],
"tests": [
{
"description": "FindOneAndReplace is committed on first attempt",
"failPoint": {
"configureFailPoint": "onPrimaryTransactionalWrite",
"mode": {
"times": 1
}
},
"operation": {
"name": "findOneAndReplace",
"arguments": {
"filter": {
"_id": 1
},
"replacement": {
"_id": 1,
"x": 111
},
"returnDocument": "Before"
}
},
"outcome": {
"result": {
"_id": 1,
"x": 11
},
"collection": {
"data": [
{
"_id": 1,
"x": 111
},
{
"_id": 2,
"x": 22
}
]
}
}
},
{
"description": "FindOneAndReplace is not committed on first attempt",
"failPoint": {
"configureFailPoint": "onPrimaryTransactionalWrite",
"mode": {
"times": 1
},
"data": {
"failBeforeCommitExceptionCode": 1
}
},
"operation": {
"name": "findOneAndReplace",
"arguments": {
"filter": {
"_id": 1
},
"replacement": {
"_id": 1,
"x": 111
},
"returnDocument": "Before"
}
},
"outcome": {
"result": {
"_id": 1,
"x": 11
},
"collection": {
"data": [
{
"_id": 1,
"x": 111
},
{
"_id": 2,
"x": 22
}
]
}
}
},
{
"description": "FindOneAndReplace is never committed",
"failPoint": {
"configureFailPoint": "onPrimaryTransactionalWrite",
"mode": {
"times": 2
},
"data": {
"failBeforeCommitExceptionCode": 1
}
},
"operation": {
"name": "findOneAndReplace",
"arguments": {
"filter": {
"_id": 1
},
"replacement": {
"_id": 1,
"x": 111
},
"returnDocument": "Before"
}
},
"outcome": {
"error": true,
"collection": {
"data": [
{
"_id": 1,
"x": 11
},
{
"_id": 2,
"x": 22
}
]
}
}
}
]
}
{
"runOn": [
{
"minServerVersion": "4.0",
"topology": [
"replicaset"
]
},
{
"minServerVersion": "4.1.7",
"topology": [
"sharded"
]
}
],
"data": [
{
"_id": 1,
"x": 11
},
{
"_id": 2,
"x": 22
}
],
"tests": [
{
"description": "FindOneAndUpdate succeeds after PrimarySteppedDown",
"failPoint": {
"configureFailPoint": "failCommand",
"mode": {
"times": 1
},
"data": {
"failCommands": [
"findAndModify"
],
"errorCode": 189
}
},
"operation": {
"name": "findOneAndUpdate",
"arguments": {
"filter": {
"_id": 1
},
"update": {
"$inc": {
"x": 1
}
},
"returnDocument": "Before"
}
},
"outcome": {
"result": {
"_id": 1,
"x": 11
},
"collection": {
"data": [
{
"_id": 1,
"x": 12
},
{
"_id": 2,
"x": 22
}
]
}
}
},
{
"description": "FindOneAndUpdate succeeds after WriteConcernError ShutdownInProgress",
"failPoint": {
"configureFailPoint": "failCommand",
"mode": {
"times": 1
},
"data": {
"failCommands": [
"findAndModify"
],
"writeConcernError": {
"code": 91,
"errmsg": "Replication is being shut down"
}
}
},
"operation": {
"name": "findOneAndUpdate",
"arguments": {
"filter": {
"_id": 1
},
"update": {
"$inc": {
"x": 1
}
},
"returnDocument": "Before"
}
},
"outcome": {
"result": {
"_id": 1,
"x": 11
},
"collection": {
"data": [
{
"_id": 1,
"x": 12
},
{
"_id": 2,
"x": 22
}
]
}
}
}
]
}
{
"runOn": [
{
"minServerVersion": "3.6",
"topology": [
"replicaset"
]
}
],
"data": [
{
"_id": 1,
"x": 11
},
{
"_id": 2,
"x": 22
}
],
"tests": [
{
"description": "FindOneAndUpdate is committed on first attempt",
"failPoint": {
"configureFailPoint": "onPrimaryTransactionalWrite",
"mode": {
"times": 1
}
},
"operation": {
"name": "findOneAndUpdate",
"arguments": {
"filter": {
"_id": 1
},
"update": {
"$inc": {
"x": 1
}
},
"returnDocument": "Before"
}
},
"outcome": {
"result": {
"_id": 1,
"x": 11
},
"collection": {
"data": [
{
"_id": 1,
"x": 12
},
{
"_id": 2,
"x": 22
}
]
}
}
},
{
"description": "FindOneAndUpdate is not committed on first attempt",
"failPoint": {
"configureFailPoint": "onPrimaryTransactionalWrite",
"mode": {
"times": 1
},
"data": {
"failBeforeCommitExceptionCode": 1
}
},
"operation": {
"name": "findOneAndUpdate",
"arguments": {
"filter": {
"_id": 1
},
"update": {
"$inc": {
"x": 1
}
},
"returnDocument": "Before"
}
},
"outcome": {
"result": {
"_id": 1,
"x": 11
},
"collection": {
"data": [
{
"_id": 1,
"x": 12
},
{
"_id": 2,
"x": 22
}
]
}
}
},
{
"description": "FindOneAndUpdate is never committed",
"failPoint": {
"configureFailPoint": "onPrimaryTransactionalWrite",
"mode": {
"times": 2
},
"data": {
"failBeforeCommitExceptionCode": 1
}
},
"operation": {
"name": "findOneAndUpdate",
"arguments": {
"filter": {
"_id": 1
},
"update": {
"$inc": {
"x": 1
}
}
}
},
"outcome": {
"error": true,
"collection": {
"data": [
{
"_id": 1,
"x": 11
},
{
"_id": 2,
"x": 22
}
]
}
}
}
]
}
{
"runOn": [
{
"minServerVersion": "4.0",
"topology": [
"replicaset"
]
},
{
"minServerVersion": "4.1.7",
"topology": [
"sharded"
]
}
],
"data": [
{
"_id": 1,
"x": 11
}
],
"tests": [
{
"description": "InsertMany succeeds after PrimarySteppedDown",
"failPoint": {
"configureFailPoint": "failCommand",
"mode": {
"times": 1
},
"data": {
"failCommands": [
"insert"
],
"errorCode": 189
}
},
"operation": {
"name": "insertMany",
"arguments": {
"documents": [
{
"_id": 2,
"x": 22
},
{
"_id": 3,
"x": 33
}
],
"options": {
"ordered": true
}
}
},
"outcome": {
"result": {
"insertedIds": {
"0": 2,
"1": 3
}
},
"collection": {
"data": [
{
"_id": 1,
"x": 11
},
{
"_id": 2,
"x": 22
},
{
"_id": 3,
"x": 33
}
]
}
}
},
{
"description": "InsertMany succeeds after WriteConcernError ShutdownInProgress",
"failPoint": {
"configureFailPoint": "failCommand",
"mode": {
"times": 1
},
"data": {
"failCommands": [
"insert"
],
"writeConcernError": {
"code": 91,
"errmsg": "Replication is being shut down"
}
}
},
"operation": {
"name": "insertMany",
"arguments": {
"documents": [
{
"_id": 2,
"x": 22
},
{
"_id": 3,
"x": 33
}
],
"options": {
"ordered": true
}
}
},
"outcome": {
"result": {
"insertedIds": {
"0": 2,
"1": 3
}
},
"collection": {
"data": [
{
"_id": 1,
"x": 11
},
{
"_id": 2,
"x": 22
},
{
"_id": 3,
"x": 33
}
]
}
}
}
]
}
{
"runOn": [
{
"minServerVersion": "3.6",
"topology": [
"replicaset"
]
}
],
"data": [
{
"_id": 1,
"x": 11
}
],
"tests": [
{
"description": "InsertMany succeeds after one network error",
"failPoint": {
"configureFailPoint": "onPrimaryTransactionalWrite",
"mode": {
"times": 1
}
},
"operation": {
"name": "insertMany",
"arguments": {
"documents": [
{
"_id": 2,
"x": 22
},
{
"_id": 3,
"x": 33
}
],
"options": {
"ordered": true
}
}
},
"outcome": {
"result": {
"insertedIds": {
"0": 2,
"1": 3
}
},
"collection": {
"data": [
{
"_id": 1,
"x": 11
},
{
"_id": 2,
"x": 22
},
{
"_id": 3,
"x": 33
}
]
}
}
},
{
"description": "InsertMany with unordered execution",
"failPoint": {
"configureFailPoint": "onPrimaryTransactionalWrite",
"mode": {
"times": 1
}
},
"operation": {
"name": "insertMany",
"arguments": {
"documents": [
{
"_id": 2,
"x": 22
},
{
"_id": 3,
"x": 33
}
],
"options": {
"ordered": false
}
}
},
"outcome": {
"result": {
"insertedIds": {
"0": 2,
"1": 3
}
},
"collection": {
"data": [
{
"_id": 1,
"x": 11
},
{
"_id": 2,
"x": 22
},
{
"_id": 3,
"x": 33
}
]
}
}
},
{
"description": "InsertMany fails after multiple network errors",
"failPoint": {
"configureFailPoint": "onPrimaryTransactionalWrite",
"mode": "alwaysOn",
"data": {
"failBeforeCommitExceptionCode": 1
}
},
"operation": {
"name": "insertMany",
"arguments": {
"documents": [
{
"_id": 2,
"x": 22
},
{
"_id": 3,
"x": 33
},
{
"_id": 4,
"x": 44
}
],
"options": {
"ordered": true
}
}
},
"outcome": {
"error": true,
"collection": {
"data": [
{
"_id": 1,
"x": 11
}
]
}
}
}
]
}
This diff is collapsed.
{
"runOn": [
{
"minServerVersion": "3.6",
"topology": [
"replicaset"
]
}
],
"data": [
{
"_id": 1,
"x": 11
},
{
"_id": 2,
"x": 22
}
],
"tests": [
{
"description": "InsertOne is committed on first attempt",
"failPoint": {
"configureFailPoint": "onPrimaryTransactionalWrite",
"mode": {
"times": 1
}
},
"operation": {
"name": "insertOne",
"arguments": {
"document": {
"_id": 3,
"x": 33
}
}
},
"outcome": {
"result": {
"insertedId": 3
},
"collection": {
"data": [
{
"_id": 1,
"x": 11
},
{
"_id": 2,
"x": 22
},
{
"_id": 3,
"x": 33
}
]
}
}
},
{
"description": "InsertOne is not committed on first attempt",
"failPoint": {
"configureFailPoint": "onPrimaryTransactionalWrite",
"mode": {
"times": 1
},
"data": {
"failBeforeCommitExceptionCode": 1
}
},
"operation": {
"name": "insertOne",
"arguments": {
"document": {
"_id": 3,
"x": 33
}
}
},
"outcome": {
"result": {
"insertedId": 3
},
"collection": {
"data": [
{
"_id": 1,
"x": 11
},
{
"_id": 2,
"x": 22
},
{
"_id": 3,
"x": 33
}
]
}
}
},
{
"description": "InsertOne is never committed",
"failPoint": {
"configureFailPoint": "onPrimaryTransactionalWrite",
"mode": {
"times": 2
},
"data": {
"failBeforeCommitExceptionCode": 1
}
},
"operation": {
"name": "insertOne",
"arguments": {
"document": {
"_id": 3,
"x": 33
}
}
},
"outcome": {
"error": true,
"collection": {
"data": [
{
"_id": 1,
"x": 11
},
{
"_id": 2,
"x": 22
}
]
}
}
}
]
}
{
"runOn": [
{
"minServerVersion": "4.0",
"topology": [
"replicaset"
]
},
{
"minServerVersion": "4.1.7",
"topology": [
"sharded"
]
}
],
"data": [
{
"_id": 1,
"x": 11
},
{
"_id": 2,
"x": 22
}
],
"tests": [
{
"description": "ReplaceOne succeeds after PrimarySteppedDown",
"failPoint": {
"configureFailPoint": "failCommand",
"mode": {
"times": 1
},
"data": {
"failCommands": [
"update"
],
"errorCode": 189
}
},
"operation": {
"name": "replaceOne",
"arguments": {
"filter": {
"_id": 1
},
"replacement": {
"_id": 1,
"x": 111
}
}
},
"outcome": {
"result": {
"matchedCount": 1,
"modifiedCount": 1,
"upsertedCount": 0
},
"collection": {
"data": [
{
"_id": 1,
"x": 111
},
{
"_id": 2,
"x": 22
}
]
}
}
},
{
"description": "ReplaceOne succeeds after WriteConcernError ShutdownInProgress",
"failPoint": {
"configureFailPoint": "failCommand",
"mode": {
"times": 1
},
"data": {
"failCommands": [
"update"
],
"writeConcernError": {
"code": 91,
"errmsg": "Replication is being shut down"
}
}
},
"operation": {
"name": "replaceOne",
"arguments": {
"filter": {
"_id": 1
},
"replacement": {
"_id": 1,
"x": 111
}
}
},
"outcome": {
"result": {
"matchedCount": 1,
"modifiedCount": 1,
"upsertedCount": 0
},
"collection": {
"data": [
{
"_id": 1,
"x": 111
},
{
"_id": 2,
"x": 22
}
]
}
}
}
]
}
{
"runOn": [
{
"minServerVersion": "3.6",
"topology": [
"replicaset"
]
}
],
"data": [
{
"_id": 1,
"x": 11
},
{
"_id": 2,
"x": 22
}
],
"tests": [
{
"description": "ReplaceOne is committed on first attempt",
"failPoint": {
"configureFailPoint": "onPrimaryTransactionalWrite",
"mode": {
"times": 1
}
},
"operation": {
"name": "replaceOne",
"arguments": {
"filter": {
"_id": 1
},
"replacement": {
"_id": 1,
"x": 111
}
}
},
"outcome": {
"result": {
"matchedCount": 1,
"modifiedCount": 1,
"upsertedCount": 0
},
"collection": {
"data": [
{
"_id": 1,
"x": 111
},
{
"_id": 2,
"x": 22
}
]
}
}
},
{
"description": "ReplaceOne is not committed on first attempt",
"failPoint": {
"configureFailPoint": "onPrimaryTransactionalWrite",
"mode": {
"times": 1
},
"data": {
"failBeforeCommitExceptionCode": 1
}
},
"operation": {
"name": "replaceOne",
"arguments": {
"filter": {
"_id": 1
},
"replacement": {
"_id": 1,
"x": 111
}
}
},
"outcome": {
"result": {
"matchedCount": 1,
"modifiedCount": 1,
"upsertedCount": 0
},
"collection": {
"data": [
{
"_id": 1,
"x": 111
},
{
"_id": 2,
"x": 22
}
]
}
}
},
{
"description": "ReplaceOne is never committed",
"failPoint": {
"configureFailPoint": "onPrimaryTransactionalWrite",
"mode": {
"times": 2
},
"data": {
"failBeforeCommitExceptionCode": 1
}
},
"operation": {
"name": "replaceOne",
"arguments": {
"filter": {
"_id": 1
},
"replacement": {
"_id": 1,
"x": 111
}
}
},
"outcome": {
"error": true,
"collection": {
"data": [
{
"_id": 1,
"x": 11
},
{
"_id": 2,
"x": 22
}
]
}
}
}
]
}
{
"runOn": [
{
"minServerVersion": "3.6",
"topology": [
"replicaset",
"sharded"
]
}
],
"data": [
{
"_id": 1,
"x": 11
},
{
"_id": 2,
"x": 22
}
],
"tests": [
{
"description": "UpdateMany ignores retryWrites",
"useMultipleMongoses": true,
"operation": {
"name": "updateMany",
"arguments": {
"filter": {},
"update": {
"$inc": {
"x": 1
}
}
}
},
"outcome": {
"result": {
"matchedCount": 2,
"modifiedCount": 2,
"upsertedCount": 0
},
"collection": {
"data": [
{
"_id": 1,
"x": 12
},
{
"_id": 2,
"x": 23
}
]
}
}
}
]
}
{
"runOn": [
{
"minServerVersion": "4.0",
"topology": [
"replicaset"
]
},
{
"minServerVersion": "4.1.7",
"topology": [
"sharded"
]
}
],
"data": [
{
"_id": 1,
"x": 11
},
{
"_id": 2,
"x": 22
}
],
"tests": [
{
"description": "UpdateOne succeeds after PrimarySteppedDown",
"failPoint": {
"configureFailPoint": "failCommand",
"mode": {
"times": 1
},
"data": {
"failCommands": [
"update"
],
"errorCode": 189
}
},
"operation": {
"name": "updateOne",
"arguments": {
"filter": {
"_id": 1
},
"update": {
"$inc": {
"x": 1
}
}
}
},
"outcome": {
"result": {
"matchedCount": 1,
"modifiedCount": 1,
"upsertedCount": 0
},
"collection": {
"data": [
{
"_id": 1,
"x": 12
},
{
"_id": 2,
"x": 22
}
]
}
}
},
{
"description": "UpdateOne succeeds after WriteConcernError ShutdownInProgress",
"failPoint": {
"configureFailPoint": "failCommand",
"mode": {
"times": 1
},
"data": {
"failCommands": [
"update"
],
"writeConcernError": {
"code": 91,
"errmsg": "Replication is being shut down"
}
}
},
"operation": {
"name": "updateOne",
"arguments": {
"filter": {
"_id": 1
},
"update": {
"$inc": {
"x": 1
}
}
}
},
"outcome": {
"result": {
"matchedCount": 1,
"modifiedCount": 1,
"upsertedCount": 0
},
"collection": {
"data": [
{
"_id": 1,
"x": 12
},
{
"_id": 2,
"x": 22
}
]
}
}
}
]
}
{
"runOn": [
{
"minServerVersion": "3.6",
"topology": [
"replicaset"
]
}
],
"data": [
{
"_id": 1,
"x": 11
},
{
"_id": 2,
"x": 22
}
],
"tests": [
{
"description": "UpdateOne is committed on first attempt",
"failPoint": {
"configureFailPoint": "onPrimaryTransactionalWrite",
"mode": {
"times": 1
}
},
"operation": {
"name": "updateOne",
"arguments": {
"filter": {
"_id": 1
},
"update": {
"$inc": {
"x": 1
}
}
}
},
"outcome": {
"result": {
"matchedCount": 1,
"modifiedCount": 1,
"upsertedCount": 0
},
"collection": {
"data": [
{
"_id": 1,
"x": 12
},
{
"_id": 2,
"x": 22
}
]
}
}
},
{
"description": "UpdateOne is not committed on first attempt",
"failPoint": {
"configureFailPoint": "onPrimaryTransactionalWrite",
"mode": {
"times": 1
},
"data": {
"failBeforeCommitExceptionCode": 1
}
},
"operation": {
"name": "updateOne",
"arguments": {
"filter": {
"_id": 1
},
"update": {
"$inc": {
"x": 1
}
}
}
},
"outcome": {
"result": {
"matchedCount": 1,
"modifiedCount": 1,
"upsertedCount": 0
},
"collection": {
"data": [
{
"_id": 1,
"x": 12
},
{
"_id": 2,
"x": 22
}
]
}
}
},
{
"description": "UpdateOne is never committed",
"failPoint": {
"configureFailPoint": "onPrimaryTransactionalWrite",
"mode": {
"times": 2
},
"data": {
"failBeforeCommitExceptionCode": 1
}
},
"operation": {
"name": "updateOne",
"arguments": {
"filter": {
"_id": 1
},
"update": {
"$inc": {
"x": 1
}
}
}
},
"outcome": {
"error": true,
"collection": {
"data": [
{
"_id": 1,
"x": 11
},
{
"_id": 2,
"x": 22
}
]
}
}
},
{
"description": "UpdateOne with upsert is committed on first attempt",
"failPoint": {
"configureFailPoint": "onPrimaryTransactionalWrite",
"mode": {
"times": 1
}
},
"operation": {
"name": "updateOne",
"arguments": {
"filter": {
"_id": 3,
"x": 33
},
"update": {
"$inc": {
"x": 1
}
},
"upsert": true
}
},
"outcome": {
"result": {
"matchedCount": 0,
"modifiedCount": 0,
"upsertedCount": 1,
"upsertedId": 3
},
"collection": {
"data": [
{
"_id": 1,
"x": 11
},
{
"_id": 2,
"x": 22
},
{
"_id": 3,
"x": 34
}
]
}
}
},
{
"description": "UpdateOne with upsert is not committed on first attempt",
"failPoint": {
"configureFailPoint": "onPrimaryTransactionalWrite",
"mode": {
"times": 1
},
"data": {
"failBeforeCommitExceptionCode": 1
}
},
"operation": {
"name": "updateOne",
"arguments": {
"filter": {
"_id": 3,
"x": 33
},
"update": {
"$inc": {
"x": 1
}
},
"upsert": true
}
},
"outcome": {
"result": {
"matchedCount": 0,
"modifiedCount": 0,
"upsertedCount": 1,
"upsertedId": 3
},
"collection": {
"data": [
{
"_id": 1,
"x": 11
},
{
"_id": 2,
"x": 22
},
{
"_id": 3,
"x": 34
}
]
}
}
},
{
"description": "UpdateOne with upsert is never committed",
"failPoint": {
"configureFailPoint": "onPrimaryTransactionalWrite",
"mode": {
"times": 2
},
"data": {
"failBeforeCommitExceptionCode": 1
}
},
"operation": {
"name": "updateOne",
"arguments": {
"filter": {
"_id": 3,
"x": 33
},
"update": {
"$inc": {
"x": 1
}
},
"upsert": true
}
},
"outcome": {
"error": true,
"collection": {
"data": [
{
"_id": 1,
"x": 11
},
{
"_id": 2,
"x": 22
}
]
}
}
}
]
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment