Skip to content

Commit

Permalink
test(retryableWrites): sync retryableWrites tests
Browse files Browse the repository at this point in the history
Fixes NODE-1706
Fixes NODE-1714
  • Loading branch information
daprahamian authored and kiku-jw committed Feb 11, 2019
1 parent 0178354 commit 93904eb
Show file tree
Hide file tree
Showing 9 changed files with 158 additions and 3 deletions.
6 changes: 3 additions & 3 deletions test/functional/spec/retryable-writes/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ the cluster.
Server Fail Point
=================

The tests depend on a server fail point, ``onPrimaryTransactionalWrite``, which
Some tests depend on a server fail point, ``onPrimaryTransactionalWrite``, which
allows us to force a network error before the server would return a write result
to the client. The fail point also allows control whether the server will
successfully commit the write via its ``failBeforeCommitExceptionCode`` option.
Expand Down Expand Up @@ -140,8 +140,8 @@ Each YAML file has the following keys:

- ``clientOptions``: Parameters to pass to MongoClient().

- ``failPoint``: The ``configureFailPoint`` command document to run to
configure a fail point on the primary server. Drivers must ensure that
- ``failPoint`` (optional): The ``configureFailPoint`` command document to run
to configure a fail point on the primary server. Drivers must ensure that
``configureFailPoint`` is the first field in the command.

- ``operation``: Document describing the operation to be executed. The
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@
"outcome": {
"result": {
"deletedCount": 1,
"insertedCount": 1,
"insertedIds": {
"1": 3
},
Expand Down Expand Up @@ -156,6 +157,7 @@
"outcome": {
"result": {
"deletedCount": 1,
"insertedCount": 1,
"insertedIds": {
"1": 3
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ tests:
outcome:
result:
deletedCount: 1
insertedCount: 1
insertedIds: { 1: 3 }
matchedCount: 1
modifiedCount: 1
Expand Down Expand Up @@ -79,6 +80,7 @@ tests:
outcome:
result:
deletedCount: 1
insertedCount: 1
insertedIds: { 1: 3 }
matchedCount: 1
modifiedCount: 1
Expand Down
10 changes: 10 additions & 0 deletions test/functional/spec/retryable-writes/bulkWrite.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@
"outcome": {
"result": {
"deletedCount": 1,
"insertedCount": 1,
"insertedIds": {
"0": 2
},
Expand Down Expand Up @@ -178,6 +179,7 @@
"outcome": {
"result": {
"deletedCount": 1,
"insertedCount": 3,
"insertedIds": {
"0": 2,
"2": 3,
Expand Down Expand Up @@ -271,6 +273,7 @@
"outcome": {
"result": {
"deletedCount": 0,
"insertedCount": 1,
"insertedIds": {
"0": 2
},
Expand Down Expand Up @@ -352,6 +355,7 @@
"outcome": {
"result": {
"deletedCount": 0,
"insertedCount": 1,
"insertedIds": {
"0": 2
},
Expand Down Expand Up @@ -416,6 +420,7 @@
"outcome": {
"result": {
"deletedCount": 0,
"insertedCount": 2,
"insertedIds": {
"0": 2,
"1": 3
Expand Down Expand Up @@ -501,6 +506,7 @@
"error": true,
"result": {
"deletedCount": 0,
"insertedCount": 0,
"insertedIds": {},
"matchedCount": 0,
"modifiedCount": 0,
Expand Down Expand Up @@ -575,6 +581,7 @@
"error": true,
"result": {
"deletedCount": 0,
"insertedCount": 1,
"insertedIds": {
"0": 2
},
Expand Down Expand Up @@ -660,6 +667,7 @@
"error": true,
"result": {
"deletedCount": 0,
"insertedCount": 1,
"insertedIds": {
"1": 2
},
Expand Down Expand Up @@ -726,6 +734,7 @@
"outcome": {
"result": {
"deletedCount": 1,
"insertedCount": 1,
"insertedIds": {
"1": 2
},
Expand Down Expand Up @@ -793,6 +802,7 @@
"outcome": {
"result": {
"deletedCount": 0,
"insertedCount": 1,
"insertedIds": {
"1": 2
},
Expand Down
10 changes: 10 additions & 0 deletions test/functional/spec/retryable-writes/bulkWrite.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ tests:
outcome:
result:
deletedCount: 1
insertedCount: 1
insertedIds: { 0: 2 }
matchedCount: 1
modifiedCount: 1
Expand Down Expand Up @@ -90,6 +91,7 @@ tests:
outcome:
result:
deletedCount: 1
insertedCount: 3
insertedIds: { 0: 2, 2: 3, 4: 5 }
matchedCount: 2
modifiedCount: 2
Expand Down Expand Up @@ -130,6 +132,7 @@ tests:
outcome:
result:
deletedCount: 0
insertedCount: 1
insertedIds: { 0: 2 }
matchedCount: 2
modifiedCount: 2
Expand Down Expand Up @@ -168,6 +171,7 @@ tests:
outcome:
result:
deletedCount: 0
insertedCount: 1
insertedIds: { 0: 2 }
matchedCount: 2
modifiedCount: 2
Expand Down Expand Up @@ -200,6 +204,7 @@ tests:
outcome:
result:
deletedCount: 0
insertedCount: 2
insertedIds: { 0: 2, 1: 3 }
matchedCount: 0
modifiedCount: 0
Expand Down Expand Up @@ -240,6 +245,7 @@ tests:
error: true
result:
deletedCount: 0
insertedCount: 0
insertedIds: { }
matchedCount: 0
modifiedCount: 0
Expand Down Expand Up @@ -278,6 +284,7 @@ tests:
error: true
result:
deletedCount: 0
insertedCount: 1
insertedIds: { 0: 2 }
matchedCount: 0
modifiedCount: 0
Expand Down Expand Up @@ -318,6 +325,7 @@ tests:
error: true
result:
deletedCount: 0
insertedCount: 1
insertedIds: { 1: 2 }
matchedCount: 1
modifiedCount: 1
Expand Down Expand Up @@ -355,6 +363,7 @@ tests:
outcome:
result:
deletedCount: 1
insertedCount: 1
insertedIds: { 1: 2 }
matchedCount: 0
modifiedCount: 0
Expand Down Expand Up @@ -392,6 +401,7 @@ tests:
outcome:
result:
deletedCount: 0
insertedCount: 1
insertedIds: { 1: 2 }
matchedCount: 1
modifiedCount: 1
Expand Down
35 changes: 35 additions & 0 deletions test/functional/spec/retryable-writes/deleteMany.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
{
"data": [
{
"_id": 1,
"x": 11
},
{
"_id": 2,
"x": 22
}
],
"minServerVersion": "3.6",
"tests": [
{
"description": "DeleteMany ignores retryWrites",
"clientOptions": {
"retryWrites": true
},
"operation": {
"name": "deleteMany",
"arguments": {
"filter": {}
}
},
"outcome": {
"result": {
"deletedCount": 2
},
"collection": {
"data": []
}
}
}
]
}
20 changes: 20 additions & 0 deletions test/functional/spec/retryable-writes/deleteMany.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
data:
- { _id: 1, x: 11 }
- { _id: 2, x: 22 }

minServerVersion: '3.6'

tests:
-
description: "DeleteMany ignores retryWrites"
clientOptions:
retryWrites: true
operation:
name: "deleteMany"
arguments:
filter: { }
outcome:
result:
deletedCount: 2
collection:
data: []
51 changes: 51 additions & 0 deletions test/functional/spec/retryable-writes/updateMany.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
{
"data": [
{
"_id": 1,
"x": 11
},
{
"_id": 2,
"x": 22
}
],
"minServerVersion": "3.6",
"tests": [
{
"description": "UpdateMany ignores retryWrites",
"clientOptions": {
"retryWrites": 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
}
]
}
}
}
]
}
25 changes: 25 additions & 0 deletions test/functional/spec/retryable-writes/updateMany.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
data:
- { _id: 1, x: 11 }
- { _id: 2, x: 22 }

minServerVersion: '3.6'

tests:
-
description: "UpdateMany ignores retryWrites"
clientOptions:
retryWrites: 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 }

0 comments on commit 93904eb

Please sign in to comment.