Skip to content

RUST-1088 Always specify error labels at the top level #553

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 1 commit into from
Jan 12, 2022
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
99 changes: 89 additions & 10 deletions src/test/spec/json/retryable-writes/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,13 @@ Retryable Write Tests
Introduction
============

The YAML and JSON files in this directory tree are platform-independent tests
that drivers can use to prove their conformance to the Retryable Writes spec.
Tests in this directory are platform-independent tests that drivers can use to
prove their conformance to the Retryable Writes specification.

Tests in the ``unified`` directory are implemented in the
`Unified Test Format <../../unified-test-format/unified-test-format.rst>`__.

Tests in the ``legacy`` directory should be executed as described below.

Several prose tests, which are not easily expressed in YAML, are also presented
in this file. Those tests will need to be manually implemented by each driver.
Expand Down Expand Up @@ -91,6 +96,11 @@ disabled like so::
mode: "off"
});

Speeding Up Tests
=================

See `Speeding Up Tests <../../retryable-reads/tests/README.rst#speeding-up-tests>`_ in the retryable reads spec tests.

Use as Integration Tests
========================

Expand Down Expand Up @@ -154,9 +164,22 @@ Each YAML file has the following keys:
version.

- ``topology`` (optional): An array of server topologies against which the
tests can be run successfully. Valid topologies are "single", "replicaset",
and "sharded". If this field is omitted, the default is all topologies (i.e.
``["single", "replicaset", "sharded"]``).
tests can be run successfully. Valid topologies are "single",
"replicaset", "sharded", and "load-balanced". If this field is omitted,
the default is all topologies (i.e. ``["single", "replicaset", "sharded",
"load-balanced"]``).

- ``serverless``: Optional string. Whether or not the test should be run on
serverless instances imitating sharded clusters. Valid values are "require",
"forbid", and "allow". If "require", the test MUST only be run on serverless
instances. If "forbid", the test MUST NOT be run on serverless instances. If
omitted or "allow", this option has no effect.

The test runner MUST be informed whether or not serverless is being used in
order to determine if this requirement is met (e.g. through an environment
variable or configuration option). Since the serverless proxy imitates a
mongos, the runner is not capable of determining this by issuing a server
command such as ``buildInfo`` or ``hello``.

- ``data``: The data that should exist in the collection under test before each
test run.
Expand All @@ -168,10 +191,18 @@ Each YAML file has the following keys:

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

- ``useMultipleMongoses`` (optional): If ``true``, the MongoClient for this
test should be initialized with multiple mongos seed addresses. If ``false``
or omitted, only a single mongos address should be specified. This field has
no effect for non-sharded topologies.
- ``useMultipleMongoses`` (optional): If ``true``, and the topology type is
``Sharded``, the MongoClient for this test should be initialized with multiple
mongos seed addresses. If ``false`` or omitted, only a single mongos address
should be specified.

If ``true``, and the topology type is ``LoadBalanced``, the MongoClient for
this test should be initialized with the URI of the load balancer fronting
multiple servers. If ``false`` or omitted, the MongoClient for this test
should be initialized with the URI of the load balancer fronting a single
server.

``useMultipleMongoses`` only affects ``Sharded`` and ``LoadBalanced`` topologies.

- ``failPoint`` (optional): The ``configureFailPoint`` command document to run
to configure a fail point on the primary server. Drivers must ensure that
Expand Down Expand Up @@ -322,10 +353,58 @@ and sharded clusters.
in use MAY skip this test for sharded clusters, since ``mongos`` does not report
this information in its ``serverStatus`` response.

#. Test that drivers properly retry after encountering PoolClearedErrors. This
test MUST be implemented by any driver that implements the CMAP
specification. This test requires MongoDB 4.2.9+ for ``blockConnection`` support in the failpoint.

1. Create a client with maxPoolSize=1 and retryWrites=true. If testing
against a sharded deployment, be sure to connect to only a single mongos.

2. Enable the following failpoint::

{
configureFailPoint: "failCommand",
mode: { times: 1 },
data: {
failCommands: ["insert"],
errorCode: 91,
blockConnection: true,
blockTimeMS: 1000,
errorLabels: ["RetryableWriteError"]
}
}

3. Start two threads and attempt to perform an ``insertOne`` simultaneously on both.

4. Verify that both ``insertOne`` attempts succeed.

5. Via CMAP monitoring, assert that the first check out succeeds.

6. Via CMAP monitoring, assert that a PoolClearedEvent is then emitted.

7. Via CMAP monitoring, assert that the second check out then fails due to a
connection error.

8. Via Command Monitoring, assert that exactly three ``insert``
CommandStartedEvents were observed in total.

9. Disable the failpoint.


Changelog
=========

:2019-10-21: Add ``errorLabelsContain`` and ``errorLabelsContain`` fields to ``result``


:2021-08-27: Add ``serverless`` to ``runOn``. Clarify behavior of
``useMultipleMongoses`` for ``LoadBalanced`` topologies.

:2021-04-23: Add ``load-balanced`` to test topology requirements.

:2021-03-24: Add prose test verifying ``PoolClearedErrors`` are retried.

:2019-10-21: Add ``errorLabelsContain`` and ``errorLabelsContain`` fields to
``result``

:2019-08-07: Add Prose Tests section

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,12 +119,12 @@
"failCommands": [
"insert"
],
"errorLabels": [
"RetryableWriteError"
],
"writeConcernError": {
"code": 91,
"errmsg": "Replication is being shut down",
"errorLabels": [
"RetryableWriteError"
]
"errmsg": "Replication is being shut down"
}
}
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,10 @@ tests:
mode: { times: 1 }
data:
failCommands: ["insert"]
errorLabels: ["RetryableWriteError"]
writeConcernError:
code: 91
errmsg: Replication is being shut down
errorLabels: ["RetryableWriteError"]
operation:
name: "bulkWrite"
arguments:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,12 +75,12 @@
"failCommands": [
"delete"
],
"errorLabels": [
"RetryableWriteError"
],
"writeConcernError": {
"code": 91,
"errmsg": "Replication is being shut down",
"errorLabels": [
"RetryableWriteError"
]
"errmsg": "Replication is being shut down"
}
}
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,10 @@ tests:
mode: { times: 1 }
data:
failCommands: ["delete"]
errorLabels: ["RetryableWriteError"]
writeConcernError:
code: 91
errmsg: Replication is being shut down
errorLabels: ["RetryableWriteError"]
operation:
name: "deleteOne"
arguments:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,12 +81,12 @@
"failCommands": [
"findAndModify"
],
"errorLabels": [
"RetryableWriteError"
],
"writeConcernError": {
"code": 91,
"errmsg": "Replication is being shut down",
"errorLabels": [
"RetryableWriteError"
]
"errmsg": "Replication is being shut down"
}
}
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,10 @@ tests:
mode: { times: 1 }
data:
failCommands: ["findAndModify"]
errorLabels: ["RetryableWriteError"]
writeConcernError:
code: 91
errmsg: Replication is being shut down
errorLabels: ["RetryableWriteError"]
operation:
name: "findOneAndDelete"
arguments:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,12 +85,12 @@
"failCommands": [
"findAndModify"
],
"errorLabels": [
"RetryableWriteError"
],
"writeConcernError": {
"code": 91,
"errmsg": "Replication is being shut down",
"errorLabels": [
"RetryableWriteError"
]
"errmsg": "Replication is being shut down"
}
}
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,10 @@ tests:
mode: { times: 1 }
data:
failCommands: ["findAndModify"]
errorLabels: ["RetryableWriteError"]
writeConcernError:
code: 91
errmsg: Replication is being shut down
errorLabels: ["RetryableWriteError"]
operation:
name: "findOneAndReplace"
arguments:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,12 +86,12 @@
"failCommands": [
"findAndModify"
],
"errorLabels": [
"RetryableWriteError"
],
"writeConcernError": {
"code": 91,
"errmsg": "Replication is being shut down",
"errorLabels": [
"RetryableWriteError"
]
"errmsg": "Replication is being shut down"
}
}
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,10 @@ tests:
mode: { times: 1 }
data:
failCommands: ["findAndModify"]
errorLabels: ["RetryableWriteError"]
writeConcernError:
code: 91
errmsg: Replication is being shut down
errorLabels: ["RetryableWriteError"]
operation:
name: "findOneAndUpdate"
arguments:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,12 +92,12 @@
"failCommands": [
"insert"
],
"errorLabels": [
"RetryableWriteError"
],
"writeConcernError": {
"code": 91,
"errmsg": "Replication is being shut down",
"errorLabels": [
"RetryableWriteError"
]
"errmsg": "Replication is being shut down"
}
}
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,10 @@ tests:
mode: { times: 1 }
data:
failCommands: ["insert"]
errorLabels: ["RetryableWriteError"]
writeConcernError:
code: 91
errmsg: Replication is being shut down
errorLabels: ["RetryableWriteError"]
operation:
name: "insertMany"
arguments:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -761,12 +761,12 @@
"failCommands": [
"insert"
],
"errorLabels": [
"RetryableWriteError"
],
"writeConcernError": {
"code": 11600,
"errmsg": "Replication is being shut down",
"errorLabels": [
"RetryableWriteError"
]
"errmsg": "Replication is being shut down"
}
}
},
Expand Down Expand Up @@ -812,12 +812,12 @@
"failCommands": [
"insert"
],
"errorLabels": [
"RetryableWriteError"
],
"writeConcernError": {
"code": 11602,
"errmsg": "Replication is being shut down",
"errorLabels": [
"RetryableWriteError"
]
"errmsg": "Replication is being shut down"
}
}
},
Expand Down Expand Up @@ -863,12 +863,12 @@
"failCommands": [
"insert"
],
"errorLabels": [
"RetryableWriteError"
],
"writeConcernError": {
"code": 189,
"errmsg": "Replication is being shut down",
"errorLabels": [
"RetryableWriteError"
]
"errmsg": "Replication is being shut down"
}
}
},
Expand Down Expand Up @@ -914,12 +914,12 @@
"failCommands": [
"insert"
],
"errorLabels": [
"RetryableWriteError"
],
"writeConcernError": {
"code": 91,
"errmsg": "Replication is being shut down",
"errorLabels": [
"RetryableWriteError"
]
"errmsg": "Replication is being shut down"
}
}
},
Expand Down Expand Up @@ -965,12 +965,12 @@
"failCommands": [
"insert"
],
"errorLabels": [
"RetryableWriteError"
],
"writeConcernError": {
"code": 91,
"errmsg": "Replication is being shut down",
"errorLabels": [
"RetryableWriteError"
]
"errmsg": "Replication is being shut down"
}
}
},
Expand Down
Loading