diff --git a/source/client-side-encryption/tests/README.rst b/source/client-side-encryption/tests/README.rst index cefc26d25e..f16d811047 100644 --- a/source/client-side-encryption/tests/README.rst +++ b/source/client-side-encryption/tests/README.rst @@ -39,7 +39,7 @@ are true: Spec Test Format ================ -The spec tests format is an extension of `transactions spec tests `_ with some additions: +The spec tests format is an extension of the `transactions spec legacy test format `__ with some additions: - A ``json_schema`` to set on the collection used for operations. diff --git a/source/read-write-concern/tests/README.rst b/source/read-write-concern/tests/README.rst index 2f2b84dc9c..1d4beb3fc1 100644 --- a/source/read-write-concern/tests/README.rst +++ b/source/read-write-concern/tests/README.rst @@ -57,7 +57,7 @@ Operation These tests check that the default write concern is omitted in operations. -The spec test format is an extension of `transactions spec tests `_ with the following additions: +The spec test format is an extension of the `transactions spec legacy test format `__ with the following additions: - ``writeConcern`` in the ``databaseOptions`` or ``collectionOptions`` may be an empty document to indicate a `server default write concern `_. For example, in libmongoc: diff --git a/source/transactions/tests/README.rst b/source/transactions/tests/README.rst index b42cac4259..c772509cd3 100644 --- a/source/transactions/tests/README.rst +++ b/source/transactions/tests/README.rst @@ -9,531 +9,13 @@ Transactions Tests Introduction ============ -The YAML and JSON files in the ``legacy`` and ``unified`` sub-directories are -platform-independent tests that drivers can use to prove their conformance to -the Transactions Spec. The tests in the ``legacy`` directory are designed with -the intention of sharing some test-runner code with the CRUD Spec tests and the -Command Monitoring Spec tests. The format for these tests and instructions for -executing them are provided in the following sections. Tests in the -``unified`` directory are written using the `Unified Test Format -<../../unified-test-format/unified-test-format.md>`_. +The YAML and JSON files in this directory are platform-independent tests +meant to exercise a driver's implementation of transactions. These tests utilize +the `Unified Test Format <../../unified-test-format/unified-test-format.md>`__. 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. -Server Fail Point -================= - -failCommand -``````````` - -Some tests depend on a server fail point, expressed in the ``failPoint`` field. -For example the ``failCommand`` fail point allows the client to force the -server to return an error. Keep in mind that the fail point only triggers for -commands listed in the "failCommands" field. See `SERVER-35004`_ and -`SERVER-35083`_ for more information. - -.. _SERVER-35004: https://jira.mongodb.org/browse/SERVER-35004 -.. _SERVER-35083: https://jira.mongodb.org/browse/SERVER-35083 - -The ``failCommand`` fail point may be configured like so:: - - db.adminCommand({ - configureFailPoint: "failCommand", - mode: , - data: { - failCommands: ["commandName", "commandName2"], - closeConnection: , - errorCode: , - writeConcernError: , - appName: , - blockConnection: , - blockTimeMS: , - } - }); - -``mode`` is a generic fail point option and may be assigned a string or document -value. The string values ``"alwaysOn"`` and ``"off"`` may be used to enable or -disable the fail point, respectively. A document may be used to specify either -``times`` or ``skip``, which are mutually exclusive: - -- ``{ times: }`` may be used to limit the number of times the fail - point may trigger before transitioning to ``"off"``. -- ``{ skip: }`` may be used to defer the first trigger of a fail - point, after which it will transition to ``"alwaysOn"``. - -The ``data`` option is a document that may be used to specify options that -control the fail point's behavior. ``failCommand`` supports the following -``data`` options, which may be combined if desired: - -- ``failCommands``: Required, the list of command names to fail. -- ``closeConnection``: Boolean option, which defaults to ``false``. If - ``true``, the command will not be executed, the connection will be closed, and - the client will see a network error. -- ``errorCode``: Integer option, which is unset by default. If set, the command - will not be executed and the specified command error code will be returned as - a command error. -- ``appName``: A string to filter which MongoClient should be affected by - the failpoint. `New in mongod 4.4.0-rc2 `_. -- ``blockConnection``: Whether the server should block the affected commands. - Default false. -- ``blockTimeMS``: The number of milliseconds the affect commands should be - blocked for. Required when blockConnection is true. - `New in mongod 4.3.4 `_. - -Speeding Up Tests -================= - -See `Speeding Up Tests <../../retryable-reads/tests/README.rst#speeding-up-tests>`_ in the retryable reads spec tests. - -Test Format -=========== - -Each YAML file has the following keys: - -- ``runOn`` (optional): An array of server version and/or topology requirements - for which the tests can be run. If the test environment satisfies one or more - of these requirements, the tests may be executed; otherwise, this file should - be skipped. If this field is omitted, the tests can be assumed to have no - particular requirements and should be executed. Each element will have some or - all of the following fields: - - - ``minServerVersion`` (optional): The minimum server version (inclusive) - required to successfully run the tests. If this field is omitted, it should - be assumed that there is no lower bound on the required server version. - - - ``maxServerVersion`` (optional): The maximum server version (inclusive) - against which the tests can be run successfully. If this field is omitted, - it should be assumed that there is no upper bound on the required server - version. - - - ``topology`` (optional): An array of server topologies against which the - 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): Whether or not the test should be run on Atlas - Serverless instances. Valid values are "require", "forbid", and "allow". If - "require", the test MUST only be run on Atlas Serverless instances. If - "forbid", the test MUST NOT be run on Atlas Serverless instances. If omitted - or "allow", this option has no effect. - - The test runner MUST be informed whether or not Atlas Serverless is being - used in order to determine if this requirement is met (e.g. through an - environment variable or configuration option). - - Note: the Atlas Serverless proxy imitates mongos, so the test runner is not - capable of determining if Atlas Serverless is in use by issuing commands - such as ``buildInfo`` or ``hello``. Furthermore, connections to Atlas - Serverless use a load balancer, so the topology will appear as - "load-balanced". - -- ``database_name`` and ``collection_name``: The database and collection to use - for testing. - -- ``data``: The data that should exist in the collection under test before each - test run. - -- ``tests``: An array of tests that are to be run independently of each other. - Each test will have some or all of the following fields: - - - ``description``: The name of the test. - - - ``skipReason``: Optional, string describing why this test should be - skipped. - - - ``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``, the topology type is ``LoadBalanced``, and Atlas Serverless is - not being used, 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 (excluding Atlas Serverless). - - - ``clientOptions``: Optional, parameters to pass to MongoClient(). - - - ``failPoint``: Optional, a server failpoint to enable expressed as the - configureFailPoint command to run on the admin database. This option and - ``useMultipleMongoses: true`` are mutually exclusive. - - - ``sessionOptions``: Optional, map of session names (e.g. "session0") to - parameters to pass to MongoClient.startSession() when creating that session. - - - ``operations``: Array of documents, each describing an operation to be - executed. Each document has the following fields: - - - ``name``: The name of the operation on ``object``. - - - ``object``: The name of the object to perform the operation on. Can be - "database", "collection", "session0", "session1", or "testRunner". See - the "targetedFailPoint" operation in `Special Test Operations`_. - - - ``collectionOptions``: Optional, parameters to pass to the Collection() - used for this operation. - - - ``databaseOptions``: Optional, parameters to pass to the Database() - used for this operation. - - - ``command_name``: Present only when ``name`` is "runCommand". The name - of the command to run. Required for languages that are unable preserve - the order keys in the "command" argument when parsing JSON/YAML. - - - ``arguments``: Optional, the names and values of arguments. - - - ``error``: Optional. If true, the test should expect an error or - exception. This could be a server-generated or a driver-generated error. - - - ``result``: The return value from the operation, if any. This field may - be a single document or an array of documents in the case of a - multi-document read. If the operation is expected to return an error, the - ``result`` is a single document that has one or more of the following - fields: - - - ``errorContains``: A substring of the expected error message. - - - ``errorCodeName``: The expected "codeName" field in the server - error response. - - - ``errorLabelsContain``: A list of error label strings that the - error is expected to have. - - - ``errorLabelsOmit``: A list of error label strings that the - error is expected not to have. - - - ``expectations``: Optional list of command-started events. - - - ``outcome``: Document describing the return value and/or expected state of - the collection after the operation is executed. Contains the following - fields: - - - ``collection``: - - - ``data``: The data that should exist in the collection after the - operations have run, sorted by "_id". - -Use as Integration Tests -======================== - -Run a MongoDB replica set with a primary, a secondary, and an arbiter, -**server version 4.0.0 or later**. (Including a secondary ensures that -server selection in a transaction works properly. Including an arbiter helps -ensure that no new bugs have been introduced related to arbiters.) - -A driver that implements support for sharded transactions MUST also run these -tests against a MongoDB sharded cluster with multiple mongoses and -**server version 4.2 or later**. Some tests require -initializing the MongoClient with multiple mongos seeds to ensures that mongos -transaction pinning and the recoveryToken works properly. - -Load each YAML (or JSON) file using a Canonical Extended JSON parser. - -Then for each element in ``tests``: - -#. If the ``skipReason`` field is present, skip this test completely. -#. Create a MongoClient and call - ``client.admin.runCommand({killAllSessions: []})`` to clean up any open - transactions from previous test failures. Ignore a command failure with - error code 11601 ("Interrupted") to work around `SERVER-38335`_. - - - Running ``killAllSessions`` cleans up any open transactions from - a previously failed test to prevent the current test from blocking. - It is sufficient to run this command once before starting the test suite - and once after each failed test. - - When testing against a sharded cluster run this command on ALL mongoses. - -#. Create a collection object from the MongoClient, using the ``database_name`` - and ``collection_name`` fields of the YAML file. -#. Drop the test collection, using writeConcern "majority". -#. Execute the "create" command to recreate the collection, using writeConcern - "majority". (Creating the collection inside a transaction is prohibited, so - create it explicitly.) -#. If the YAML file contains a ``data`` array, insert the documents in ``data`` - into the test collection, using writeConcern "majority". -#. When testing against a sharded cluster run a ``distinct`` command on the - newly created collection on all mongoses. For an explanation see, - `Why do tests that run distinct sometimes fail with StaleDbVersion?`_ -#. If ``failPoint`` is specified, its value is a configureFailPoint command. - Run the command on the admin database to enable the fail point. -#. Create a **new** MongoClient ``client``, with Command Monitoring listeners - enabled. (Using a new MongoClient for each test ensures a fresh session pool - that hasn't executed any transactions previously, so the tests can assert - actual txnNumbers, starting from 1.) Pass this test's ``clientOptions`` if - present. - - - When testing against a sharded cluster and ``useMultipleMongoses`` is - ``true`` the client MUST be created with multiple (valid) mongos seed - addresses. - -#. Call ``client.startSession`` twice to create ClientSession objects - ``session0`` and ``session1``, using the test's "sessionOptions" if they - are present. Save their lsids so they are available after calling - ``endSession``, see `Logical Session Id`_. -#. For each element in ``operations``: - - - If the operation ``name`` is a special test operation type, execute it and - go to the next operation, otherwise proceed to the next step. - - Enter a "try" block or your programming language's closest equivalent. - - Create a Database object from the MongoClient, using the ``database_name`` - field at the top level of the test file. - - Create a Collection object from the Database, using the - ``collection_name`` field at the top level of the test file. - If ``collectionOptions`` or ``databaseOptions`` is present, create the - Collection or Database object with the provided options, respectively. - Otherwise create the object with the default options. - - Execute the named method on the provided ``object``, passing the - arguments listed. Pass ``session0`` or ``session1`` to the method, - depending on which session's name is in the arguments list. - If ``arguments`` contains no "session", pass no explicit session to the - method. - - If the driver throws an exception / returns an error while executing this - series of operations, store the error message and server error code. - - If the operation's ``error`` field is ``true``, verify that the method - threw an exception or returned an error. - - If the result document has an "errorContains" field, verify that the - method threw an exception or returned an error, and that the value of the - "errorContains" field matches the error string. "errorContains" is a - substring (case-insensitive) of the actual error message. - - If the result document has an "errorCodeName" field, verify that the - method threw a command failed exception or returned an error, and that - the value of the "errorCodeName" field matches the "codeName" in the - server error response. - - If the result document has an "errorLabelsContain" field, verify that the - method threw an exception or returned an error. Verify that all of the - error labels in "errorLabelsContain" are present in the error or exception - using the ``hasErrorLabel`` method. - - If the result document has an "errorLabelsOmit" field, verify that the - method threw an exception or returned an error. Verify that none of the - error labels in "errorLabelsOmit" are present in the error or exception - using the ``hasErrorLabel`` method. - - If the operation returns a raw command response, eg from ``runCommand``, - then compare only the fields present in the expected result document. - Otherwise, compare the method's return value to ``result`` using the same - logic as the CRUD Spec Tests runner. - -#. Call ``session0.endSession()`` and ``session1.endSession``. -#. If the test includes a list of command-started events in ``expectations``, - compare them to the actual command-started events using the - same logic as the `legacy Command Monitoring Spec Tests runner `_, plus the rules in - the Command-Started Events instructions below. -#. If ``failPoint`` is specified, disable the fail point to avoid spurious - failures in subsequent tests. The fail point may be disabled like so:: - - db.adminCommand({ - configureFailPoint: , - mode: "off" - }); - -#. For each element in ``outcome``: - - - If ``name`` is "collection", verify that the test collection contains - exactly the documents in the ``data`` array. Ensure this find reads the - latest data by using **primary read preference** with - **local read concern** even when the MongoClient is configured with - another read preference or read concern. - Note the server does not guarantee that documents returned by a find - command will be in inserted order. This find MUST sort by ``{_id:1}``. - -.. _SERVER-38335: https://jira.mongodb.org/browse/SERVER-38335 - -Special Test Operations -``````````````````````` - -Certain operations that appear in the "operations" array do not correspond to -API methods but instead represent special test operations. Such operations are -defined on the "testRunner" object and documented here: - -targetedFailPoint -~~~~~~~~~~~~~~~~~ - -The "targetedFailPoint" operation instructs the test runner to configure a fail -point on a specific mongos. The mongos to run the ``configureFailPoint`` is -determined by the "session" argument (either "session0" or "session1"). -The session must already be pinned to a mongos server. The "failPoint" argument -is the ``configureFailPoint`` command to run. - -If a test uses ``targetedFailPoint``, disable the fail point after running -all ``operations`` to avoid spurious failures in subsequent tests. The fail -point may be disabled like so:: - - db.adminCommand({ - configureFailPoint: , - mode: "off" - }); - -Here is an example which instructs the test runner to enable the failCommand -fail point on the mongos server which "session0" is pinned to:: - - # Enable the fail point only on the Mongos that session0 is pinned to. - - name: targetedFailPoint - object: testRunner - arguments: - session: session0 - failPoint: - configureFailPoint: failCommand - mode: { times: 1 } - data: - failCommands: ["commitTransaction"] - closeConnection: true - -Tests that use the "targetedFailPoint" operation do not include -``configureFailPoint`` commands in their command expectations. Drivers MUST -ensure that ``configureFailPoint`` commands do not appear in the list of logged -commands, either by manually filtering it from the list of observed commands or -by using a different MongoClient to execute ``configureFailPoint``. - -assertSessionTransactionState -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -The "assertSessionTransactionState" operation instructs the test runner to -assert that the transaction state of the given session is equal to the -specified value. The possible values are as follows: ``none``, ``starting``, -``in_progress``, ``committed``, ``aborted``:: - - - name: assertSessionTransactionState - object: testRunner - arguments: - session: session0 - state: in_progress - -assertSessionPinned -~~~~~~~~~~~~~~~~~~~ - -The "assertSessionPinned" operation instructs the test runner to assert that -the given session is pinned to a mongos:: - - - name: assertSessionPinned - object: testRunner - arguments: - session: session0 - -assertSessionUnpinned -~~~~~~~~~~~~~~~~~~~~~ - -The "assertSessionUnpinned" operation instructs the test runner to assert that -the given session is not pinned to a mongos:: - - - name: assertSessionPinned - object: testRunner - arguments: - session: session0 - -assertCollectionExists -~~~~~~~~~~~~~~~~~~~~~~ - -The "assertCollectionExists" operation instructs the test runner to assert that -the given collection exists in the database:: - - - name: assertCollectionExists - object: testRunner - arguments: - database: db - collection: test - -Use a ``listCollections`` command to check whether the collection exists. Note -that it is currently not possible to run ``listCollections`` from within a -transaction. - -assertCollectionNotExists -~~~~~~~~~~~~~~~~~~~~~~~~~ - -The "assertCollectionNotExists" operation instructs the test runner to assert -that the given collection does not exist in the database:: - - - name: assertCollectionNotExists - object: testRunner - arguments: - database: db - collection: test - -Use a ``listCollections`` command to check whether the collection exists. Note -that it is currently not possible to run ``listCollections`` from within a -transaction. - -assertIndexExists -~~~~~~~~~~~~~~~~~ - -The "assertIndexExists" operation instructs the test runner to assert that the -index with the given name exists on the collection:: - - - name: assertIndexExists - object: testRunner - arguments: - database: db - collection: test - index: t_1 - -Use a ``listIndexes`` command to check whether the index exists. Note that it is -currently not possible to run ``listIndexes`` from within a transaction. - -assertIndexNotExists -~~~~~~~~~~~~~~~~~~~~ - -The "assertIndexNotExists" operation instructs the test runner to assert that -the index with the given name does not exist on the collection:: - - - name: assertIndexNotExists - object: testRunner - arguments: - database: db - collection: test - index: t_1 - -Use a ``listIndexes`` command to check whether the index exists. Note that it is -currently not possible to run ``listIndexes`` from within a transaction. - -Command-Started Events -`````````````````````` - -The event listener used for these tests MUST ignore the security commands -listed in the Command Monitoring Spec. - -Logical Session Id -~~~~~~~~~~~~~~~~~~ - -Each command-started event in ``expectations`` includes an ``lsid`` with the -value "session0" or "session1". Tests MUST assert that the command's actual -``lsid`` matches the id of the correct ClientSession named ``session0`` or -``session1``. - -Null Values -~~~~~~~~~~~ - -Some command-started events in ``expectations`` include ``null`` values for top -level ``command`` fields such as ``txnNumber``, ``autocommit``, and -``writeConcern``. Tests MUST assert that the actual command **omits** any field -that has a ``null`` value in the expected command. - -Cursor Id -~~~~~~~~~ - -A ``getMore`` value of ``"42"`` in a command-started event is a fake cursorId -that MUST be ignored. (In the Command Monitoring Spec tests, fake cursorIds are -correlated with real ones, but that is not necessary for Transactions Spec -tests.) - -afterClusterTime -~~~~~~~~~~~~~~~~ - -A ``readConcern.afterClusterTime`` value of ``42`` in a command-started event -is a fake cluster time. Drivers MUST assert that the actual command includes an -afterClusterTime. - -recoveryToken -~~~~~~~~~~~~~ - -A ``recoveryToken`` value of ``42`` in a command-started event is a -placeholder for an arbitrary recovery token. Drivers MUST assert that the -actual command includes a "recoveryToken" field and SHOULD assert that field -is a BSON document. Mongos Pinning Prose Tests ========================== @@ -601,44 +83,9 @@ instead. assert len(addresses) > 1 -Q & A -===== - -Why do tests that run distinct sometimes fail with StaleDbVersion? -`````````````````````````````````````````````````````````````````` - -When a shard receives its first command that contains a dbVersion, the shard -returns a StaleDbVersion error and the Mongos retries the operation. In a -sharded transaction, Mongos does not retry these operations and instead returns -the error to the client. For example:: - - Command distinct failed: Transaction aa09e296-472a-494f-8334-48d57ab530b6:1 was aborted on statement 0 due to: an error from cluster data placement change :: caused by :: got stale databaseVersion response from shard sh01 at host localhost:27217 :: caused by :: don't know dbVersion. - -To workaround this limitation, a driver test runner MUST run a -non-transactional ``distinct`` command on each Mongos before running any test -that uses ``distinct``. To ease the implementation drivers can simply run -``distinct`` before *every* test. - -Note that drivers can remove this workaround once `SERVER-39704`_ is resolved -so that mongos retries this operation transparently. The ``distinct`` command -is the only command allowed in a sharded transaction that uses the -``dbVersion`` concept so it is the only command affected. - -.. _SERVER-39704: https://jira.mongodb.org/browse/SERVER-39704 Changelog ========= -:2023-09-28: Add ``load-balanced`` to test topology requirements. -:2022-04-22: Clarifications to ``serverless`` and ``useMultipleMongoses``. -:2019-05-15: Add operation level ``error`` field to assert any error. -:2019-03-25: Add workaround for StaleDbVersion on distinct. -:2019-03-01: Add top-level ``runOn`` field to denote server version and/or - topology requirements requirements for the test file. Removes the - ``topology`` top-level field, which is now expressed within - ``runOn`` elements. -:2019-02-28: ``useMultipleMongoses: true`` and non-targeted fail points are - mutually exclusive. -:2019-02-13: Modify test format for 4.2 sharded transactions, including - "useMultipleMongoses", ``object: testRunner``, the - ``targetedFailPoint`` operation, and recoveryToken assertions. +:2024-02-07: Converted legacy transaction tests to unified format and moved the + legacy test format docs to a separate file. diff --git a/source/transactions/tests/legacy-test-format.rst b/source/transactions/tests/legacy-test-format.rst new file mode 100644 index 0000000000..5414f6321a --- /dev/null +++ b/source/transactions/tests/legacy-test-format.rst @@ -0,0 +1,570 @@ +================================ +Legacy Transactions Tests Format +================================ + +.. contents:: + +---- + +Introduction +============ + +This test format is no longer used by the transactions spec but may still be +referenced by other specs (e.g. CSFLE) and is preserved for historical record. + +Server Fail Point +================= + +failCommand +``````````` + +Some tests depend on a server fail point, expressed in the ``failPoint`` field. +For example the ``failCommand`` fail point allows the client to force the +server to return an error. Keep in mind that the fail point only triggers for +commands listed in the "failCommands" field. See `SERVER-35004`_ and +`SERVER-35083`_ for more information. + +.. _SERVER-35004: https://jira.mongodb.org/browse/SERVER-35004 +.. _SERVER-35083: https://jira.mongodb.org/browse/SERVER-35083 + +The ``failCommand`` fail point may be configured like so:: + + db.adminCommand({ + configureFailPoint: "failCommand", + mode: , + data: { + failCommands: ["commandName", "commandName2"], + closeConnection: , + errorCode: , + writeConcernError: , + appName: , + blockConnection: , + blockTimeMS: , + } + }); + +``mode`` is a generic fail point option and may be assigned a string or document +value. The string values ``"alwaysOn"`` and ``"off"`` may be used to enable or +disable the fail point, respectively. A document may be used to specify either +``times`` or ``skip``, which are mutually exclusive: + +- ``{ times: }`` may be used to limit the number of times the fail + point may trigger before transitioning to ``"off"``. +- ``{ skip: }`` may be used to defer the first trigger of a fail + point, after which it will transition to ``"alwaysOn"``. + +The ``data`` option is a document that may be used to specify options that +control the fail point's behavior. ``failCommand`` supports the following +``data`` options, which may be combined if desired: + +- ``failCommands``: Required, the list of command names to fail. +- ``closeConnection``: Boolean option, which defaults to ``false``. If + ``true``, the command will not be executed, the connection will be closed, and + the client will see a network error. +- ``errorCode``: Integer option, which is unset by default. If set, the command + will not be executed and the specified command error code will be returned as + a command error. +- ``appName``: A string to filter which MongoClient should be affected by + the failpoint. `New in mongod 4.4.0-rc2 `_. +- ``blockConnection``: Whether the server should block the affected commands. + Default false. +- ``blockTimeMS``: The number of milliseconds the affect commands should be + blocked for. Required when blockConnection is true. + `New in mongod 4.3.4 `_. + +Speeding Up Tests +================= + +See `Speeding Up Tests <../../retryable-reads/tests/README.rst#speeding-up-tests>`_ in the retryable reads spec tests. + +Test Format +=========== + +Each YAML file has the following keys: + +- ``runOn`` (optional): An array of server version and/or topology requirements + for which the tests can be run. If the test environment satisfies one or more + of these requirements, the tests may be executed; otherwise, this file should + be skipped. If this field is omitted, the tests can be assumed to have no + particular requirements and should be executed. Each element will have some or + all of the following fields: + + - ``minServerVersion`` (optional): The minimum server version (inclusive) + required to successfully run the tests. If this field is omitted, it should + be assumed that there is no lower bound on the required server version. + + - ``maxServerVersion`` (optional): The maximum server version (inclusive) + against which the tests can be run successfully. If this field is omitted, + it should be assumed that there is no upper bound on the required server + version. + + - ``topology`` (optional): An array of server topologies against which the + 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): Whether or not the test should be run on Atlas + Serverless instances. Valid values are "require", "forbid", and "allow". If + "require", the test MUST only be run on Atlas Serverless instances. If + "forbid", the test MUST NOT be run on Atlas Serverless instances. If omitted + or "allow", this option has no effect. + + The test runner MUST be informed whether or not Atlas Serverless is being + used in order to determine if this requirement is met (e.g. through an + environment variable or configuration option). + + Note: the Atlas Serverless proxy imitates mongos, so the test runner is not + capable of determining if Atlas Serverless is in use by issuing commands + such as ``buildInfo`` or ``hello``. Furthermore, connections to Atlas + Serverless use a load balancer, so the topology will appear as + "load-balanced". + +- ``database_name`` and ``collection_name``: The database and collection to use + for testing. + +- ``data``: The data that should exist in the collection under test before each + test run. + +- ``tests``: An array of tests that are to be run independently of each other. + Each test will have some or all of the following fields: + + - ``description``: The name of the test. + + - ``skipReason``: Optional, string describing why this test should be + skipped. + + - ``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``, the topology type is ``LoadBalanced``, and Atlas Serverless is + not being used, 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 (excluding Atlas Serverless). + + - ``clientOptions``: Optional, parameters to pass to MongoClient(). + + - ``failPoint``: Optional, a server failpoint to enable expressed as the + configureFailPoint command to run on the admin database. This option and + ``useMultipleMongoses: true`` are mutually exclusive. + + - ``sessionOptions``: Optional, map of session names (e.g. "session0") to + parameters to pass to MongoClient.startSession() when creating that session. + + - ``operations``: Array of documents, each describing an operation to be + executed. Each document has the following fields: + + - ``name``: The name of the operation on ``object``. + + - ``object``: The name of the object to perform the operation on. Can be + "database", "collection", "session0", "session1", or "testRunner". See + the "targetedFailPoint" operation in `Special Test Operations`_. + + - ``collectionOptions``: Optional, parameters to pass to the Collection() + used for this operation. + + - ``databaseOptions``: Optional, parameters to pass to the Database() + used for this operation. + + - ``command_name``: Present only when ``name`` is "runCommand". The name + of the command to run. Required for languages that are unable preserve + the order keys in the "command" argument when parsing JSON/YAML. + + - ``arguments``: Optional, the names and values of arguments. + + - ``error``: Optional. If true, the test should expect an error or + exception. This could be a server-generated or a driver-generated error. + + - ``result``: The return value from the operation, if any. This field may + be a single document or an array of documents in the case of a + multi-document read. If the operation is expected to return an error, the + ``result`` is a single document that has one or more of the following + fields: + + - ``errorContains``: A substring of the expected error message. + + - ``errorCodeName``: The expected "codeName" field in the server + error response. + + - ``errorLabelsContain``: A list of error label strings that the + error is expected to have. + + - ``errorLabelsOmit``: A list of error label strings that the + error is expected not to have. + + - ``expectations``: Optional list of command-started events. + + - ``outcome``: Document describing the return value and/or expected state of + the collection after the operation is executed. Contains the following + fields: + + - ``collection``: + + - ``data``: The data that should exist in the collection after the + operations have run, sorted by "_id". + +Use as Integration Tests +======================== + +Run a MongoDB replica set with a primary, a secondary, and an arbiter, +**server version 4.0.0 or later**. (Including a secondary ensures that +server selection in a transaction works properly. Including an arbiter helps +ensure that no new bugs have been introduced related to arbiters.) + +A driver that implements support for sharded transactions MUST also run these +tests against a MongoDB sharded cluster with multiple mongoses and +**server version 4.2 or later**. Some tests require +initializing the MongoClient with multiple mongos seeds to ensures that mongos +transaction pinning and the recoveryToken works properly. + +Load each YAML (or JSON) file using a Canonical Extended JSON parser. + +Then for each element in ``tests``: + +#. If the ``skipReason`` field is present, skip this test completely. +#. Create a MongoClient and call + ``client.admin.runCommand({killAllSessions: []})`` to clean up any open + transactions from previous test failures. Ignore a command failure with + error code 11601 ("Interrupted") to work around `SERVER-38335`_. + + - Running ``killAllSessions`` cleans up any open transactions from + a previously failed test to prevent the current test from blocking. + It is sufficient to run this command once before starting the test suite + and once after each failed test. + - When testing against a sharded cluster run this command on ALL mongoses. + +#. Create a collection object from the MongoClient, using the ``database_name`` + and ``collection_name`` fields of the YAML file. +#. Drop the test collection, using writeConcern "majority". +#. Execute the "create" command to recreate the collection, using writeConcern + "majority". (Creating the collection inside a transaction is prohibited, so + create it explicitly.) +#. If the YAML file contains a ``data`` array, insert the documents in ``data`` + into the test collection, using writeConcern "majority". +#. When testing against a sharded cluster run a ``distinct`` command on the + newly created collection on all mongoses. For an explanation see, + `Why do tests that run distinct sometimes fail with StaleDbVersion?`_ +#. If ``failPoint`` is specified, its value is a configureFailPoint command. + Run the command on the admin database to enable the fail point. +#. Create a **new** MongoClient ``client``, with Command Monitoring listeners + enabled. (Using a new MongoClient for each test ensures a fresh session pool + that hasn't executed any transactions previously, so the tests can assert + actual txnNumbers, starting from 1.) Pass this test's ``clientOptions`` if + present. + + - When testing against a sharded cluster and ``useMultipleMongoses`` is + ``true`` the client MUST be created with multiple (valid) mongos seed + addresses. + +#. Call ``client.startSession`` twice to create ClientSession objects + ``session0`` and ``session1``, using the test's "sessionOptions" if they + are present. Save their lsids so they are available after calling + ``endSession``, see `Logical Session Id`_. +#. For each element in ``operations``: + + - If the operation ``name`` is a special test operation type, execute it and + go to the next operation, otherwise proceed to the next step. + - Enter a "try" block or your programming language's closest equivalent. + - Create a Database object from the MongoClient, using the ``database_name`` + field at the top level of the test file. + - Create a Collection object from the Database, using the + ``collection_name`` field at the top level of the test file. + If ``collectionOptions`` or ``databaseOptions`` is present, create the + Collection or Database object with the provided options, respectively. + Otherwise create the object with the default options. + - Execute the named method on the provided ``object``, passing the + arguments listed. Pass ``session0`` or ``session1`` to the method, + depending on which session's name is in the arguments list. + If ``arguments`` contains no "session", pass no explicit session to the + method. + - If the driver throws an exception / returns an error while executing this + series of operations, store the error message and server error code. + - If the operation's ``error`` field is ``true``, verify that the method + threw an exception or returned an error. + - If the result document has an "errorContains" field, verify that the + method threw an exception or returned an error, and that the value of the + "errorContains" field matches the error string. "errorContains" is a + substring (case-insensitive) of the actual error message. + + If the result document has an "errorCodeName" field, verify that the + method threw a command failed exception or returned an error, and that + the value of the "errorCodeName" field matches the "codeName" in the + server error response. + + If the result document has an "errorLabelsContain" field, verify that the + method threw an exception or returned an error. Verify that all of the + error labels in "errorLabelsContain" are present in the error or exception + using the ``hasErrorLabel`` method. + + If the result document has an "errorLabelsOmit" field, verify that the + method threw an exception or returned an error. Verify that none of the + error labels in "errorLabelsOmit" are present in the error or exception + using the ``hasErrorLabel`` method. + - If the operation returns a raw command response, eg from ``runCommand``, + then compare only the fields present in the expected result document. + Otherwise, compare the method's return value to ``result`` using the same + logic as the CRUD Spec Tests runner. + +#. Call ``session0.endSession()`` and ``session1.endSession``. +#. If the test includes a list of command-started events in ``expectations``, + compare them to the actual command-started events using the + same logic as the `legacy Command Monitoring Spec Tests runner `_, plus the rules in + the Command-Started Events instructions below. +#. If ``failPoint`` is specified, disable the fail point to avoid spurious + failures in subsequent tests. The fail point may be disabled like so:: + + db.adminCommand({ + configureFailPoint: , + mode: "off" + }); + +#. For each element in ``outcome``: + + - If ``name`` is "collection", verify that the test collection contains + exactly the documents in the ``data`` array. Ensure this find reads the + latest data by using **primary read preference** with + **local read concern** even when the MongoClient is configured with + another read preference or read concern. + Note the server does not guarantee that documents returned by a find + command will be in inserted order. This find MUST sort by ``{_id:1}``. + +.. _SERVER-38335: https://jira.mongodb.org/browse/SERVER-38335 + +Special Test Operations +``````````````````````` + +Certain operations that appear in the "operations" array do not correspond to +API methods but instead represent special test operations. Such operations are +defined on the "testRunner" object and documented here: + +targetedFailPoint +~~~~~~~~~~~~~~~~~ + +The "targetedFailPoint" operation instructs the test runner to configure a fail +point on a specific mongos. The mongos to run the ``configureFailPoint`` is +determined by the "session" argument (either "session0" or "session1"). +The session must already be pinned to a mongos server. The "failPoint" argument +is the ``configureFailPoint`` command to run. + +If a test uses ``targetedFailPoint``, disable the fail point after running +all ``operations`` to avoid spurious failures in subsequent tests. The fail +point may be disabled like so:: + + db.adminCommand({ + configureFailPoint: , + mode: "off" + }); + +Here is an example which instructs the test runner to enable the failCommand +fail point on the mongos server which "session0" is pinned to:: + + # Enable the fail point only on the Mongos that session0 is pinned to. + - name: targetedFailPoint + object: testRunner + arguments: + session: session0 + failPoint: + configureFailPoint: failCommand + mode: { times: 1 } + data: + failCommands: ["commitTransaction"] + closeConnection: true + +Tests that use the "targetedFailPoint" operation do not include +``configureFailPoint`` commands in their command expectations. Drivers MUST +ensure that ``configureFailPoint`` commands do not appear in the list of logged +commands, either by manually filtering it from the list of observed commands or +by using a different MongoClient to execute ``configureFailPoint``. + +assertSessionTransactionState +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +The "assertSessionTransactionState" operation instructs the test runner to +assert that the transaction state of the given session is equal to the +specified value. The possible values are as follows: ``none``, ``starting``, +``in_progress``, ``committed``, ``aborted``:: + + - name: assertSessionTransactionState + object: testRunner + arguments: + session: session0 + state: in_progress + +assertSessionPinned +~~~~~~~~~~~~~~~~~~~ + +The "assertSessionPinned" operation instructs the test runner to assert that +the given session is pinned to a mongos:: + + - name: assertSessionPinned + object: testRunner + arguments: + session: session0 + +assertSessionUnpinned +~~~~~~~~~~~~~~~~~~~~~ + +The "assertSessionUnpinned" operation instructs the test runner to assert that +the given session is not pinned to a mongos:: + + - name: assertSessionPinned + object: testRunner + arguments: + session: session0 + +assertCollectionExists +~~~~~~~~~~~~~~~~~~~~~~ + +The "assertCollectionExists" operation instructs the test runner to assert that +the given collection exists in the database:: + + - name: assertCollectionExists + object: testRunner + arguments: + database: db + collection: test + +Use a ``listCollections`` command to check whether the collection exists. Note +that it is currently not possible to run ``listCollections`` from within a +transaction. + +assertCollectionNotExists +~~~~~~~~~~~~~~~~~~~~~~~~~ + +The "assertCollectionNotExists" operation instructs the test runner to assert +that the given collection does not exist in the database:: + + - name: assertCollectionNotExists + object: testRunner + arguments: + database: db + collection: test + +Use a ``listCollections`` command to check whether the collection exists. Note +that it is currently not possible to run ``listCollections`` from within a +transaction. + +assertIndexExists +~~~~~~~~~~~~~~~~~ + +The "assertIndexExists" operation instructs the test runner to assert that the +index with the given name exists on the collection:: + + - name: assertIndexExists + object: testRunner + arguments: + database: db + collection: test + index: t_1 + +Use a ``listIndexes`` command to check whether the index exists. Note that it is +currently not possible to run ``listIndexes`` from within a transaction. + +assertIndexNotExists +~~~~~~~~~~~~~~~~~~~~ + +The "assertIndexNotExists" operation instructs the test runner to assert that +the index with the given name does not exist on the collection:: + + - name: assertIndexNotExists + object: testRunner + arguments: + database: db + collection: test + index: t_1 + +Use a ``listIndexes`` command to check whether the index exists. Note that it is +currently not possible to run ``listIndexes`` from within a transaction. + +Command-Started Events +`````````````````````` + +The event listener used for these tests MUST ignore the security commands +listed in the Command Monitoring Spec. + +Logical Session Id +~~~~~~~~~~~~~~~~~~ + +Each command-started event in ``expectations`` includes an ``lsid`` with the +value "session0" or "session1". Tests MUST assert that the command's actual +``lsid`` matches the id of the correct ClientSession named ``session0`` or +``session1``. + +Null Values +~~~~~~~~~~~ + +Some command-started events in ``expectations`` include ``null`` values for top +level ``command`` fields such as ``txnNumber``, ``autocommit``, and +``writeConcern``. Tests MUST assert that the actual command **omits** any field +that has a ``null`` value in the expected command. + +Cursor Id +~~~~~~~~~ + +A ``getMore`` value of ``"42"`` in a command-started event is a fake cursorId +that MUST be ignored. (In the Command Monitoring Spec tests, fake cursorIds are +correlated with real ones, but that is not necessary for Transactions Spec +tests.) + +afterClusterTime +~~~~~~~~~~~~~~~~ + +A ``readConcern.afterClusterTime`` value of ``42`` in a command-started event +is a fake cluster time. Drivers MUST assert that the actual command includes an +afterClusterTime. + +recoveryToken +~~~~~~~~~~~~~ + +A ``recoveryToken`` value of ``42`` in a command-started event is a +placeholder for an arbitrary recovery token. Drivers MUST assert that the +actual command includes a "recoveryToken" field and SHOULD assert that field +is a BSON document. + +Q & A +===== + +Why do tests that run distinct sometimes fail with StaleDbVersion? +`````````````````````````````````````````````````````````````````` + +When a shard receives its first command that contains a dbVersion, the shard +returns a StaleDbVersion error and the Mongos retries the operation. In a +sharded transaction, Mongos does not retry these operations and instead returns +the error to the client. For example:: + + Command distinct failed: Transaction aa09e296-472a-494f-8334-48d57ab530b6:1 was aborted on statement 0 due to: an error from cluster data placement change :: caused by :: got stale databaseVersion response from shard sh01 at host localhost:27217 :: caused by :: don't know dbVersion. + +To workaround this limitation, a driver test runner MUST run a +non-transactional ``distinct`` command on each Mongos before running any test +that uses ``distinct``. To ease the implementation drivers can simply run +``distinct`` before *every* test. + +Note that drivers can remove this workaround once `SERVER-39704`_ is resolved +so that mongos retries this operation transparently. The ``distinct`` command +is the only command allowed in a sharded transaction that uses the +``dbVersion`` concept so it is the only command affected. + +.. _SERVER-39704: https://jira.mongodb.org/browse/SERVER-39704 + +Changelog +========= + +:2024-02-07: Moved legacy test format docs to this file from README.rst. +:2023-09-28: Add ``load-balanced`` to test topology requirements. +:2022-04-22: Clarifications to ``serverless`` and ``useMultipleMongoses``. +:2019-05-15: Add operation level ``error`` field to assert any error. +:2019-03-25: Add workaround for StaleDbVersion on distinct. +:2019-03-01: Add top-level ``runOn`` field to denote server version and/or + topology requirements requirements for the test file. Removes the + ``topology`` top-level field, which is now expressed within + ``runOn`` elements. +:2019-02-28: ``useMultipleMongoses: true`` and non-targeted fail points are + mutually exclusive. +:2019-02-13: Modify test format for 4.2 sharded transactions, including + "useMultipleMongoses", ``object: testRunner``, the + ``targetedFailPoint`` operation, and recoveryToken assertions. diff --git a/source/transactions/tests/legacy/abort.json b/source/transactions/tests/legacy/abort.json deleted file mode 100644 index 2398e48712..0000000000 --- a/source/transactions/tests/legacy/abort.json +++ /dev/null @@ -1,622 +0,0 @@ -{ - "runOn": [ - { - "minServerVersion": "4.0", - "topology": [ - "replicaset" - ] - }, - { - "minServerVersion": "4.1.8", - "topology": [ - "sharded", - "load-balanced" - ] - } - ], - "database_name": "transaction-tests", - "collection_name": "test", - "data": [], - "tests": [ - { - "description": "abort", - "operations": [ - { - "name": "startTransaction", - "object": "session0" - }, - { - "name": "insertOne", - "object": "collection", - "arguments": { - "session": "session0", - "document": { - "_id": 1 - } - }, - "result": { - "insertedId": 1 - } - }, - { - "name": "abortTransaction", - "object": "session0" - }, - { - "name": "startTransaction", - "object": "session0" - }, - { - "name": "insertOne", - "object": "collection", - "arguments": { - "session": "session0", - "document": { - "_id": 1 - } - }, - "result": { - "insertedId": 1 - } - }, - { - "name": "abortTransaction", - "object": "session0" - } - ], - "expectations": [ - { - "command_started_event": { - "command": { - "insert": "test", - "documents": [ - { - "_id": 1 - } - ], - "ordered": true, - "readConcern": null, - "lsid": "session0", - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": true, - "autocommit": false, - "writeConcern": null - }, - "command_name": "insert", - "database_name": "transaction-tests" - } - }, - { - "command_started_event": { - "command": { - "abortTransaction": 1, - "lsid": "session0", - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": null, - "autocommit": false, - "writeConcern": null - }, - "command_name": "abortTransaction", - "database_name": "admin" - } - }, - { - "command_started_event": { - "command": { - "insert": "test", - "documents": [ - { - "_id": 1 - } - ], - "ordered": true, - "readConcern": { - "afterClusterTime": 42 - }, - "lsid": "session0", - "txnNumber": { - "$numberLong": "2" - }, - "startTransaction": true, - "autocommit": false, - "writeConcern": null - }, - "command_name": "insert", - "database_name": "transaction-tests" - } - }, - { - "command_started_event": { - "command": { - "abortTransaction": 1, - "lsid": "session0", - "txnNumber": { - "$numberLong": "2" - }, - "startTransaction": null, - "autocommit": false, - "writeConcern": null - }, - "command_name": "abortTransaction", - "database_name": "admin" - } - } - ], - "outcome": { - "collection": { - "data": [] - } - } - }, - { - "description": "implicit abort", - "operations": [ - { - "name": "startTransaction", - "object": "session0" - }, - { - "name": "insertOne", - "object": "collection", - "arguments": { - "session": "session0", - "document": { - "_id": 1 - } - }, - "result": { - "insertedId": 1 - } - } - ], - "expectations": [ - { - "command_started_event": { - "command": { - "insert": "test", - "documents": [ - { - "_id": 1 - } - ], - "ordered": true, - "readConcern": null, - "lsid": "session0", - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": true, - "autocommit": false, - "writeConcern": null - }, - "command_name": "insert", - "database_name": "transaction-tests" - } - }, - { - "command_started_event": { - "command": { - "abortTransaction": 1, - "lsid": "session0", - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": null, - "autocommit": false, - "writeConcern": null - }, - "command_name": "abortTransaction", - "database_name": "admin" - } - } - ], - "outcome": { - "collection": { - "data": [] - } - } - }, - { - "description": "two aborts", - "operations": [ - { - "name": "startTransaction", - "object": "session0" - }, - { - "name": "insertOne", - "object": "collection", - "arguments": { - "session": "session0", - "document": { - "_id": 1 - } - }, - "result": { - "insertedId": 1 - } - }, - { - "name": "abortTransaction", - "object": "session0" - }, - { - "name": "abortTransaction", - "object": "session0", - "result": { - "errorContains": "cannot call abortTransaction twice" - } - } - ], - "expectations": [ - { - "command_started_event": { - "command": { - "insert": "test", - "documents": [ - { - "_id": 1 - } - ], - "ordered": true, - "readConcern": null, - "lsid": "session0", - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": true, - "autocommit": false, - "writeConcern": null - }, - "command_name": "insert", - "database_name": "transaction-tests" - } - }, - { - "command_started_event": { - "command": { - "abortTransaction": 1, - "lsid": "session0", - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": null, - "autocommit": false, - "writeConcern": null - }, - "command_name": "abortTransaction", - "database_name": "admin" - } - } - ], - "outcome": { - "collection": { - "data": [] - } - } - }, - { - "description": "abort without start", - "operations": [ - { - "name": "abortTransaction", - "object": "session0", - "result": { - "errorContains": "no transaction started" - } - } - ], - "expectations": [], - "outcome": { - "collection": { - "data": [] - } - } - }, - { - "description": "abort directly after no-op commit", - "operations": [ - { - "name": "startTransaction", - "object": "session0" - }, - { - "name": "commitTransaction", - "object": "session0" - }, - { - "name": "abortTransaction", - "object": "session0", - "result": { - "errorContains": "Cannot call abortTransaction after calling commitTransaction" - } - } - ], - "expectations": [], - "outcome": { - "collection": { - "data": [] - } - } - }, - { - "description": "abort directly after commit", - "operations": [ - { - "name": "startTransaction", - "object": "session0" - }, - { - "name": "insertOne", - "object": "collection", - "arguments": { - "session": "session0", - "document": { - "_id": 1 - } - }, - "result": { - "insertedId": 1 - } - }, - { - "name": "commitTransaction", - "object": "session0" - }, - { - "name": "abortTransaction", - "object": "session0", - "result": { - "errorContains": "Cannot call abortTransaction after calling commitTransaction" - } - } - ], - "expectations": [ - { - "command_started_event": { - "command": { - "insert": "test", - "documents": [ - { - "_id": 1 - } - ], - "ordered": true, - "readConcern": null, - "lsid": "session0", - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": true, - "autocommit": false, - "writeConcern": null - }, - "command_name": "insert", - "database_name": "transaction-tests" - } - }, - { - "command_started_event": { - "command": { - "commitTransaction": 1, - "lsid": "session0", - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": null, - "autocommit": false, - "writeConcern": null - }, - "command_name": "commitTransaction", - "database_name": "admin" - } - } - ], - "outcome": { - "collection": { - "data": [ - { - "_id": 1 - } - ] - } - } - }, - { - "description": "abort ignores TransactionAborted", - "operations": [ - { - "name": "startTransaction", - "object": "session0" - }, - { - "name": "insertOne", - "object": "collection", - "arguments": { - "session": "session0", - "document": { - "_id": 1 - } - }, - "result": { - "insertedId": 1 - } - }, - { - "name": "insertOne", - "object": "collection", - "arguments": { - "session": "session0", - "document": { - "_id": 1 - } - }, - "result": { - "errorLabelsOmit": [ - "TransientTransactionError", - "UnknownTransactionCommitResult" - ], - "errorContains": "E11000" - } - }, - { - "name": "insertOne", - "object": "collection", - "arguments": { - "session": "session0", - "document": { - "_id": 1 - } - }, - "result": { - "errorCodeName": "NoSuchTransaction", - "errorLabelsContain": [ - "TransientTransactionError" - ], - "errorLabelsOmit": [ - "UnknownTransactionCommitResult" - ] - } - }, - { - "name": "abortTransaction", - "object": "session0" - } - ], - "expectations": [ - { - "command_started_event": { - "command": { - "insert": "test", - "documents": [ - { - "_id": 1 - } - ], - "ordered": true, - "readConcern": null, - "lsid": "session0", - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": true, - "autocommit": false, - "writeConcern": null - }, - "command_name": "insert", - "database_name": "transaction-tests" - } - }, - { - "command_started_event": { - "command": { - "insert": "test", - "documents": [ - { - "_id": 1 - } - ], - "ordered": true, - "readConcern": null, - "lsid": "session0", - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": null, - "autocommit": false, - "writeConcern": null - }, - "command_name": "insert", - "database_name": "transaction-tests" - } - }, - { - "command_started_event": { - "command": { - "insert": "test", - "documents": [ - { - "_id": 1 - } - ], - "ordered": true, - "readConcern": null, - "lsid": "session0", - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": null, - "autocommit": false, - "writeConcern": null - }, - "command_name": "insert", - "database_name": "transaction-tests" - } - }, - { - "command_started_event": { - "command": { - "abortTransaction": 1, - "lsid": "session0", - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": null, - "autocommit": false, - "writeConcern": null - }, - "command_name": "abortTransaction", - "database_name": "admin" - } - } - ], - "outcome": { - "collection": { - "data": [] - } - } - }, - { - "description": "abort does not apply writeConcern", - "operations": [ - { - "name": "startTransaction", - "object": "session0", - "arguments": { - "options": { - "writeConcern": { - "w": 10 - } - } - } - }, - { - "name": "insertOne", - "object": "collection", - "arguments": { - "session": "session0", - "document": { - "_id": 1 - } - }, - "result": { - "insertedId": 1 - } - }, - { - "name": "abortTransaction", - "object": "session0" - } - ], - "outcome": { - "collection": { - "data": [] - } - } - } - ] -} diff --git a/source/transactions/tests/legacy/abort.yml b/source/transactions/tests/legacy/abort.yml deleted file mode 100644 index d06bfb74d4..0000000000 --- a/source/transactions/tests/legacy/abort.yml +++ /dev/null @@ -1,413 +0,0 @@ -runOn: - - - minServerVersion: "4.0" - topology: ["replicaset"] - - - minServerVersion: "4.1.8" - topology: ["sharded", "load-balanced"] - -database_name: &database_name "transaction-tests" -collection_name: &collection_name "test" - -data: [] - -tests: - - description: abort - - operations: - - name: startTransaction - object: session0 - - name: insertOne - object: collection - arguments: - session: session0 - document: - _id: 1 - result: - insertedId: 1 - - name: abortTransaction - object: session0 - - name: startTransaction - object: session0 - - name: insertOne - object: collection - arguments: - session: session0 - document: - _id: 1 - result: - insertedId: 1 - - name: abortTransaction - object: session0 - - expectations: - - command_started_event: - command: - insert: *collection_name - documents: - - _id: 1 - ordered: true - readConcern: - lsid: session0 - txnNumber: - $numberLong: "1" - startTransaction: true - autocommit: false - writeConcern: - command_name: insert - database_name: *database_name - - command_started_event: - command: - abortTransaction: 1 - lsid: session0 - txnNumber: - "$numberLong": "1" - startTransaction: - autocommit: false - writeConcern: - command_name: abortTransaction - database_name: admin - - command_started_event: - command: - insert: *collection_name - documents: - - _id: 1 - ordered: true - readConcern: - afterClusterTime: 42 - lsid: session0 - txnNumber: - $numberLong: "2" - startTransaction: true - autocommit: false - writeConcern: - command_name: insert - database_name: *database_name - - command_started_event: - command: - abortTransaction: 1 - lsid: session0 - txnNumber: - $numberLong: "2" - startTransaction: - autocommit: false - writeConcern: - command_name: abortTransaction - database_name: admin - - outcome: - collection: - data: [] - - - description: implicit abort - - operations: - # Start a transaction but don't commit - the driver calls abortTransaction - # from ClientSession.endSession(). - - name: startTransaction - object: session0 - - name: insertOne - object: collection - arguments: - session: session0 - document: - _id: 1 - result: - insertedId: 1 - - expectations: - - command_started_event: - command: - insert: *collection_name - documents: - - _id: 1 - ordered: true - readConcern: - lsid: session0 - txnNumber: - $numberLong: "1" - startTransaction: true - autocommit: false - writeConcern: - command_name: insert - database_name: *database_name - - command_started_event: - command: - abortTransaction: 1 - lsid: session0 - txnNumber: - $numberLong: "1" - startTransaction: - autocommit: false - writeConcern: - command_name: abortTransaction - database_name: admin - - outcome: - collection: - data: [] - - - description: two aborts - - operations: - - name: startTransaction - object: session0 - - name: insertOne - object: collection - arguments: - session: session0 - document: - _id: 1 - result: - insertedId: 1 - - name: abortTransaction - object: session0 - - name: abortTransaction - object: session0 - result: - errorContains: cannot call abortTransaction twice - - expectations: - - command_started_event: - command: - insert: *collection_name - documents: - - _id: 1 - ordered: true - readConcern: - lsid: session0 - txnNumber: - $numberLong: "1" - startTransaction: true - autocommit: false - writeConcern: - command_name: insert - database_name: *database_name - - command_started_event: - command: - abortTransaction: 1 - lsid: session0 - txnNumber: - $numberLong: "1" - startTransaction: - autocommit: false - writeConcern: - command_name: abortTransaction - database_name: admin - - outcome: - collection: - data: [] - - - description: abort without start - - operations: - - name: abortTransaction - object: session0 - result: - errorContains: no transaction started - - expectations: [] - - outcome: - collection: - data: [] - - - description: abort directly after no-op commit - - operations: - - name: startTransaction - object: session0 - - name: commitTransaction - object: session0 - - name: abortTransaction # Error calling abort after no-op commit. - object: session0 - result: - errorContains: Cannot call abortTransaction after calling commitTransaction - - expectations: [] - - outcome: - collection: - data: [] - - - description: abort directly after commit - - operations: - - name: startTransaction - object: session0 - - name: insertOne - object: collection - arguments: - session: session0 - document: - _id: 1 - result: - insertedId: 1 - - name: commitTransaction - object: session0 - - name: abortTransaction # Error calling abort after commit. - object: session0 - result: - errorContains: Cannot call abortTransaction after calling commitTransaction - - expectations: - - command_started_event: - command: - insert: *collection_name - documents: - - _id: 1 - ordered: true - readConcern: - lsid: session0 - txnNumber: - $numberLong: "1" - startTransaction: true - autocommit: false - writeConcern: - command_name: insert - database_name: *database_name - - command_started_event: - command: - commitTransaction: 1 - lsid: session0 - txnNumber: - $numberLong: "1" - startTransaction: - autocommit: false - writeConcern: - command_name: commitTransaction - database_name: admin - - outcome: - collection: - data: - - _id: 1 - - - description: abort ignores TransactionAborted - - operations: - - name: startTransaction - object: session0 - - name: insertOne - object: collection - arguments: - session: session0 - document: - _id: 1 - result: - insertedId: 1 - # Abort the server transaction with a duplicate key error. - - name: insertOne - object: collection - arguments: - session: session0 - document: - _id: 1 - result: - errorLabelsOmit: ["TransientTransactionError", "UnknownTransactionCommitResult"] - # DuplicateKey error code included in the bulk write error message - # returned by the server - errorContains: E11000 - # Make sure the server aborted the transaction. - - name: insertOne - object: collection - arguments: - session: session0 - document: - _id: 1 - result: - errorCodeName: NoSuchTransaction - errorLabelsContain: ["TransientTransactionError"] - errorLabelsOmit: ["UnknownTransactionCommitResult"] - # abortTransaction must ignore the TransactionAborted and succeed. - - name: abortTransaction - object: session0 - - expectations: - - command_started_event: - command: - insert: *collection_name - documents: - - _id: 1 - ordered: true - readConcern: - lsid: session0 - txnNumber: - $numberLong: "1" - startTransaction: true - autocommit: false - writeConcern: - command_name: insert - database_name: *database_name - - command_started_event: - command: - insert: *collection_name - documents: - - _id: 1 - ordered: true - readConcern: - lsid: session0 - txnNumber: - $numberLong: "1" - startTransaction: - autocommit: false - writeConcern: - command_name: insert - database_name: *database_name - - command_started_event: - command: - insert: *collection_name - documents: - - _id: 1 - ordered: true - readConcern: - lsid: session0 - txnNumber: - $numberLong: "1" - startTransaction: - autocommit: false - writeConcern: - command_name: insert - database_name: *database_name - - command_started_event: - command: - abortTransaction: 1 - lsid: session0 - txnNumber: - $numberLong: "1" - startTransaction: - autocommit: false - writeConcern: - command_name: abortTransaction - database_name: admin - - - outcome: - collection: - data: [] - - - description: abort does not apply writeConcern - - operations: - - name: startTransaction - object: session0 - arguments: - options: - writeConcern: - w: 10 - - name: insertOne - object: collection - arguments: - session: session0 - document: - _id: 1 - result: - insertedId: 1 - - name: abortTransaction - object: session0 - # No write concern error. - - outcome: - collection: - data: [] diff --git a/source/transactions/tests/legacy/bulk.json b/source/transactions/tests/legacy/bulk.json deleted file mode 100644 index 8ed78649f8..0000000000 --- a/source/transactions/tests/legacy/bulk.json +++ /dev/null @@ -1,532 +0,0 @@ -{ - "runOn": [ - { - "minServerVersion": "4.0", - "topology": [ - "replicaset" - ] - }, - { - "minServerVersion": "4.1.8", - "topology": [ - "sharded", - "load-balanced" - ] - } - ], - "database_name": "transaction-tests", - "collection_name": "test", - "data": [], - "tests": [ - { - "description": "bulk", - "operations": [ - { - "name": "startTransaction", - "object": "session0" - }, - { - "name": "insertOne", - "object": "collection", - "arguments": { - "session": "session0", - "document": { - "_id": 1 - } - }, - "result": { - "insertedId": 1 - } - }, - { - "name": "deleteOne", - "object": "collection", - "arguments": { - "session": "session0", - "filter": { - "_id": 1 - } - }, - "result": { - "deletedCount": 1 - } - }, - { - "name": "bulkWrite", - "object": "collection", - "arguments": { - "session": "session0", - "requests": [ - { - "name": "insertOne", - "arguments": { - "document": { - "_id": 1 - } - } - }, - { - "name": "updateOne", - "arguments": { - "filter": { - "_id": 1 - }, - "update": { - "$set": { - "x": 1 - } - } - } - }, - { - "name": "updateOne", - "arguments": { - "filter": { - "_id": 2 - }, - "update": { - "$set": { - "x": 2 - } - }, - "upsert": true - } - }, - { - "name": "insertOne", - "arguments": { - "document": { - "_id": 3 - } - } - }, - { - "name": "insertOne", - "arguments": { - "document": { - "_id": 4 - } - } - }, - { - "name": "insertOne", - "arguments": { - "document": { - "_id": 5 - } - } - }, - { - "name": "insertOne", - "arguments": { - "document": { - "_id": 6 - } - } - }, - { - "name": "insertOne", - "arguments": { - "document": { - "_id": 7 - } - } - }, - { - "name": "replaceOne", - "arguments": { - "filter": { - "_id": 1 - }, - "replacement": { - "y": 1 - } - } - }, - { - "name": "replaceOne", - "arguments": { - "filter": { - "_id": 2 - }, - "replacement": { - "y": 2 - } - } - }, - { - "name": "deleteOne", - "arguments": { - "filter": { - "_id": 3 - } - } - }, - { - "name": "deleteOne", - "arguments": { - "filter": { - "_id": 4 - } - } - }, - { - "name": "updateMany", - "arguments": { - "filter": { - "_id": { - "$gte": 2 - } - }, - "update": { - "$set": { - "z": 1 - } - } - } - }, - { - "name": "deleteMany", - "arguments": { - "filter": { - "_id": { - "$gte": 6 - } - } - } - } - ] - }, - "result": { - "deletedCount": 4, - "insertedCount": 6, - "insertedIds": { - "0": 1, - "3": 3, - "4": 4, - "5": 5, - "6": 6, - "7": 7 - }, - "matchedCount": 7, - "modifiedCount": 7, - "upsertedCount": 1, - "upsertedIds": { - "2": 2 - } - } - }, - { - "name": "commitTransaction", - "object": "session0" - } - ], - "expectations": [ - { - "command_started_event": { - "command": { - "insert": "test", - "documents": [ - { - "_id": 1 - } - ], - "ordered": true, - "readConcern": null, - "lsid": "session0", - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": true, - "autocommit": false, - "writeConcern": null - }, - "command_name": "insert", - "database_name": "transaction-tests" - } - }, - { - "command_started_event": { - "command": { - "delete": "test", - "deletes": [ - { - "q": { - "_id": 1 - }, - "limit": 1 - } - ], - "ordered": true, - "lsid": "session0", - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": null, - "autocommit": false, - "writeConcern": null - }, - "command_name": "delete", - "database_name": "transaction-tests" - } - }, - { - "command_started_event": { - "command": { - "insert": "test", - "documents": [ - { - "_id": 1 - } - ], - "ordered": true, - "lsid": "session0", - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": null, - "autocommit": false, - "writeConcern": null - }, - "command_name": "insert", - "database_name": "transaction-tests" - } - }, - { - "command_started_event": { - "command": { - "update": "test", - "updates": [ - { - "q": { - "_id": 1 - }, - "u": { - "$set": { - "x": 1 - } - } - }, - { - "q": { - "_id": 2 - }, - "u": { - "$set": { - "x": 2 - } - }, - "upsert": true - } - ], - "ordered": true, - "lsid": "session0", - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": null, - "autocommit": false, - "writeConcern": null - }, - "command_name": "update", - "database_name": "transaction-tests" - } - }, - { - "command_started_event": { - "command": { - "insert": "test", - "documents": [ - { - "_id": 3 - }, - { - "_id": 4 - }, - { - "_id": 5 - }, - { - "_id": 6 - }, - { - "_id": 7 - } - ], - "ordered": true, - "lsid": "session0", - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": null, - "autocommit": false, - "writeConcern": null - }, - "command_name": "insert", - "database_name": "transaction-tests" - } - }, - { - "command_started_event": { - "command": { - "update": "test", - "updates": [ - { - "q": { - "_id": 1 - }, - "u": { - "y": 1 - } - }, - { - "q": { - "_id": 2 - }, - "u": { - "y": 2 - } - } - ], - "ordered": true, - "lsid": "session0", - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": null, - "autocommit": false, - "writeConcern": null - }, - "command_name": "update", - "database_name": "transaction-tests" - } - }, - { - "command_started_event": { - "command": { - "delete": "test", - "deletes": [ - { - "q": { - "_id": 3 - }, - "limit": 1 - }, - { - "q": { - "_id": 4 - }, - "limit": 1 - } - ], - "ordered": true, - "lsid": "session0", - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": null, - "autocommit": false, - "writeConcern": null - }, - "command_name": "delete", - "database_name": "transaction-tests" - } - }, - { - "command_started_event": { - "command": { - "update": "test", - "updates": [ - { - "q": { - "_id": { - "$gte": 2 - } - }, - "u": { - "$set": { - "z": 1 - } - }, - "multi": true - } - ], - "ordered": true, - "lsid": "session0", - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": null, - "autocommit": false, - "writeConcern": null - }, - "command_name": "update", - "database_name": "transaction-tests" - } - }, - { - "command_started_event": { - "command": { - "delete": "test", - "deletes": [ - { - "q": { - "_id": { - "$gte": 6 - } - }, - "limit": 0 - } - ], - "ordered": true, - "lsid": "session0", - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": null, - "autocommit": false, - "writeConcern": null - }, - "command_name": "delete", - "database_name": "transaction-tests" - } - }, - { - "command_started_event": { - "command": { - "commitTransaction": 1, - "lsid": "session0", - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": null, - "autocommit": false, - "writeConcern": null - }, - "command_name": "commitTransaction", - "database_name": "admin" - } - } - ], - "outcome": { - "collection": { - "data": [ - { - "_id": 1, - "y": 1 - }, - { - "_id": 2, - "y": 2, - "z": 1 - }, - { - "_id": 5, - "z": 1 - } - ] - } - } - } - ] -} diff --git a/source/transactions/tests/legacy/bulk.yml b/source/transactions/tests/legacy/bulk.yml deleted file mode 100644 index 9b467f2aab..0000000000 --- a/source/transactions/tests/legacy/bulk.yml +++ /dev/null @@ -1,268 +0,0 @@ -runOn: - - - minServerVersion: "4.0" - topology: ["replicaset"] - - - minServerVersion: "4.1.8" - topology: ["sharded", "load-balanced"] - -database_name: &database_name "transaction-tests" -collection_name: &collection_name "test" - -data: [] - -tests: - - description: bulk - - operations: - - name: startTransaction - object: session0 - - name: insertOne - object: collection - arguments: - session: session0 - document: - _id: 1 - result: - insertedId: 1 - - name: deleteOne - object: collection - arguments: - session: session0 - filter: - _id: 1 - result: - deletedCount: 1 - - name: bulkWrite - object: collection - arguments: - session: session0 - requests: - - name: insertOne - arguments: - document: {_id: 1} - - name: updateOne - arguments: - filter: {_id: 1} - update: {$set: {x: 1}} - - name: updateOne - arguments: - filter: {_id: 2} - update: {$set: {x: 2}} - upsert: true # Produces upsertedIds: {2: 2} in the result. - - name: insertOne - arguments: - document: {_id: 3} - - name: insertOne - arguments: - document: {_id: 4} - - name: insertOne - arguments: - document: {_id: 5} - - name: insertOne - arguments: - document: {_id: 6} - - name: insertOne - arguments: - document: {_id: 7} - # Keep replaces segregated from updates, so that drivers that aren't able to coalesce - # adjacent updates and replaces into a single update command will still pass this test - - name: replaceOne - arguments: - filter: {_id: 1} - replacement: {y: 1} - - name: replaceOne - arguments: - filter: {_id: 2} - replacement: {y: 2} - - name: deleteOne - arguments: - filter: {_id: 3} - - name: deleteOne - arguments: - filter: {_id: 4} - - name: updateMany - arguments: - filter: {_id: {$gte: 2}} - update: {$set: {z: 1}} - # Keep deleteMany segregated from deleteOne, so that drivers that aren't able to coalesce - # adjacent mixed deletes into a single delete command will still pass this test - - name: deleteMany - arguments: - filter: {_id: {$gte: 6}} - result: - deletedCount: 4 - insertedCount: 6 - insertedIds: {0: 1, 3: 3, 4: 4, 5: 5, 6: 6, 7: 7} - matchedCount: 7 - modifiedCount: 7 - upsertedCount: 1 - upsertedIds: {2: 2} - - name: commitTransaction - object: session0 - - expectations: - - command_started_event: - command: - insert: *collection_name - documents: - - _id: 1 - ordered: true - readConcern: - lsid: session0 - txnNumber: - $numberLong: "1" - startTransaction: true - autocommit: false - writeConcern: - command_name: insert - database_name: *database_name - - command_started_event: - command: - delete: *collection_name - deletes: - - q: {_id: 1} - limit: 1 - ordered: true - lsid: session0 - txnNumber: - $numberLong: "1" - startTransaction: - autocommit: false - writeConcern: - command_name: delete - database_name: *database_name - # Commands in the bulkWrite. - - command_started_event: - command: - insert: *collection_name - documents: - - _id: 1 - ordered: true - lsid: session0 - txnNumber: - $numberLong: "1" - startTransaction: - autocommit: false - writeConcern: - command_name: insert - database_name: *database_name - - command_started_event: - command: - update: *collection_name - updates: - - q: {_id: 1} - u: {$set: {x: 1}} - - q: {_id: 2} - u: {$set: {x: 2}} - upsert: true - ordered: true - lsid: session0 - txnNumber: - $numberLong: "1" - startTransaction: - autocommit: false - writeConcern: - command_name: update - database_name: *database_name - - command_started_event: - command: - insert: *collection_name - documents: - - _id: 3 - - _id: 4 - - _id: 5 - - _id: 6 - - _id: 7 - ordered: true - lsid: session0 - txnNumber: - $numberLong: "1" - startTransaction: - autocommit: false - writeConcern: - command_name: insert - database_name: *database_name - - command_started_event: - command: - update: *collection_name - updates: - - q: {_id: 1} - u: {y: 1} - - q: {_id: 2} - u: {y: 2} - ordered: true - lsid: session0 - txnNumber: - $numberLong: "1" - startTransaction: - autocommit: false - writeConcern: - command_name: update - database_name: *database_name - - command_started_event: - command: - delete: *collection_name - deletes: - - q: {_id: 3} - limit: 1 - - q: {_id: 4} - limit: 1 - ordered: true - lsid: session0 - txnNumber: - $numberLong: "1" - startTransaction: - autocommit: false - writeConcern: - command_name: delete - database_name: *database_name - - command_started_event: - command: - update: *collection_name - updates: - - q: {_id: {$gte: 2}} - u: {$set: {z: 1}} - multi: true - ordered: true - lsid: session0 - txnNumber: - $numberLong: "1" - startTransaction: - autocommit: false - writeConcern: - command_name: update - database_name: *database_name - - command_started_event: - command: - delete: *collection_name - deletes: - - q: {_id: {$gte: 6}} - limit: 0 - ordered: true - lsid: session0 - txnNumber: - $numberLong: "1" - startTransaction: - autocommit: false - writeConcern: - command_name: delete - database_name: *database_name - - command_started_event: - command: - commitTransaction: 1 - lsid: session0 - txnNumber: - $numberLong: "1" - startTransaction: - autocommit: false - writeConcern: - command_name: commitTransaction - database_name: admin - - outcome: - collection: - data: - - {_id: 1, y: 1} - - {_id: 2, y: 2, z: 1} - - {_id: 5, z: 1} diff --git a/source/transactions/tests/legacy/causal-consistency.json b/source/transactions/tests/legacy/causal-consistency.json deleted file mode 100644 index 46b4ba839d..0000000000 --- a/source/transactions/tests/legacy/causal-consistency.json +++ /dev/null @@ -1,306 +0,0 @@ -{ - "runOn": [ - { - "minServerVersion": "4.0", - "topology": [ - "replicaset" - ] - }, - { - "minServerVersion": "4.1.8", - "topology": [ - "sharded", - "load-balanced" - ] - } - ], - "database_name": "transaction-tests", - "collection_name": "test", - "data": [ - { - "_id": 1, - "count": 0 - } - ], - "tests": [ - { - "description": "causal consistency", - "clientOptions": { - "retryWrites": false - }, - "operations": [ - { - "name": "updateOne", - "object": "collection", - "arguments": { - "session": "session0", - "filter": { - "_id": 1 - }, - "update": { - "$inc": { - "count": 1 - } - } - }, - "result": { - "matchedCount": 1, - "modifiedCount": 1, - "upsertedCount": 0 - } - }, - { - "name": "startTransaction", - "object": "session0" - }, - { - "name": "updateOne", - "object": "collection", - "arguments": { - "session": "session0", - "filter": { - "_id": 1 - }, - "update": { - "$inc": { - "count": 1 - } - } - }, - "result": { - "matchedCount": 1, - "modifiedCount": 1, - "upsertedCount": 0 - } - }, - { - "name": "commitTransaction", - "object": "session0" - } - ], - "expectations": [ - { - "command_started_event": { - "command": { - "update": "test", - "updates": [ - { - "q": { - "_id": 1 - }, - "u": { - "$inc": { - "count": 1 - } - } - } - ], - "ordered": true, - "lsid": "session0", - "readConcern": null, - "txnNumber": null, - "startTransaction": null, - "autocommit": null, - "writeConcern": null - }, - "command_name": "update", - "database_name": "transaction-tests" - } - }, - { - "command_started_event": { - "command": { - "update": "test", - "updates": [ - { - "q": { - "_id": 1 - }, - "u": { - "$inc": { - "count": 1 - } - } - } - ], - "ordered": true, - "readConcern": { - "afterClusterTime": 42 - }, - "lsid": "session0", - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": true, - "autocommit": false, - "writeConcern": null - }, - "command_name": "update", - "database_name": "transaction-tests" - } - }, - { - "command_started_event": { - "command": { - "commitTransaction": 1, - "lsid": "session0", - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": null, - "autocommit": false, - "writeConcern": null - }, - "command_name": "commitTransaction", - "database_name": "admin" - } - } - ], - "outcome": { - "collection": { - "data": [ - { - "_id": 1, - "count": 2 - } - ] - } - } - }, - { - "description": "causal consistency disabled", - "clientOptions": { - "retryWrites": false - }, - "sessionOptions": { - "session0": { - "causalConsistency": false - } - }, - "operations": [ - { - "name": "insertOne", - "object": "collection", - "arguments": { - "session": "session0", - "document": { - "_id": 2 - } - }, - "result": { - "insertedId": 2 - } - }, - { - "name": "startTransaction", - "object": "session0" - }, - { - "name": "updateOne", - "object": "collection", - "arguments": { - "session": "session0", - "filter": { - "_id": 1 - }, - "update": { - "$inc": { - "count": 1 - } - } - }, - "result": { - "matchedCount": 1, - "modifiedCount": 1, - "upsertedCount": 0 - } - }, - { - "name": "commitTransaction", - "object": "session0" - } - ], - "expectations": [ - { - "command_started_event": { - "command": { - "insert": "test", - "documents": [ - { - "_id": 2 - } - ], - "ordered": true, - "readConcern": null, - "lsid": "session0", - "txnNumber": null, - "autocommit": null, - "writeConcern": null - }, - "command_name": "insert", - "database_name": "transaction-tests" - } - }, - { - "command_started_event": { - "command": { - "update": "test", - "updates": [ - { - "q": { - "_id": 1 - }, - "u": { - "$inc": { - "count": 1 - } - } - } - ], - "ordered": true, - "readConcern": null, - "lsid": "session0", - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": true, - "autocommit": false, - "writeConcern": null - }, - "command_name": "update", - "database_name": "transaction-tests" - } - }, - { - "command_started_event": { - "command": { - "commitTransaction": 1, - "lsid": "session0", - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": null, - "autocommit": false, - "writeConcern": null - }, - "command_name": "commitTransaction", - "database_name": "admin" - } - } - ], - "outcome": { - "collection": { - "data": [ - { - "_id": 1, - "count": 1 - }, - { - "_id": 2 - } - ] - } - } - } - ] -} diff --git a/source/transactions/tests/legacy/causal-consistency.yml b/source/transactions/tests/legacy/causal-consistency.yml deleted file mode 100644 index 0a655b3a4c..0000000000 --- a/source/transactions/tests/legacy/causal-consistency.yml +++ /dev/null @@ -1,175 +0,0 @@ -runOn: - - - minServerVersion: "4.0" - topology: ["replicaset"] - - - minServerVersion: "4.1.8" - topology: ["sharded", "load-balanced"] - -database_name: &database_name "transaction-tests" -collection_name: &collection_name "test" - -data: - - _id: 1 - count: 0 - -tests: - - description: causal consistency - clientOptions: - retryWrites: false - operations: - # Update a document without a transaction. - - &updateOne - name: updateOne - object: collection - arguments: - session: session0 - filter: {_id: 1} - update: - $inc: {count: 1} - result: - matchedCount: 1 - modifiedCount: 1 - upsertedCount: 0 - # Updating the same document inside a transaction. - # Casual consistency ensures that the transaction snapshot is causally - # after the first updateOne. - - name: startTransaction - object: session0 - - *updateOne - - name: commitTransaction - object: session0 - - expectations: - - command_started_event: - command: - update: *collection_name - updates: - - q: {_id: 1} - u: {$inc: {count: 1}} - ordered: true - lsid: session0 - readConcern: - txnNumber: - startTransaction: - autocommit: - writeConcern: - command_name: update - database_name: *database_name - - command_started_event: - command: - update: *collection_name - updates: - - q: {_id: 1} - u: {$inc: {count: 1}} - ordered: true - readConcern: - afterClusterTime: 42 - lsid: session0 - txnNumber: - $numberLong: "1" - startTransaction: true - autocommit: false - writeConcern: - command_name: update - database_name: *database_name - - command_started_event: - command: - commitTransaction: 1 - lsid: session0 - txnNumber: - $numberLong: "1" - startTransaction: - autocommit: false - writeConcern: - command_name: commitTransaction - database_name: admin - - outcome: - collection: - data: - - _id: 1 - count: 2 - - - description: causal consistency disabled - clientOptions: - retryWrites: false - sessionOptions: - session0: - causalConsistency: false - - operations: - # Insert a document without a transaction. - - name: insertOne - object: collection - arguments: - session: session0 - document: - _id: 2 - result: - insertedId: 2 - - name: startTransaction - object: session0 - - name: updateOne - object: collection - arguments: - session: session0 - filter: {_id: 1} - update: - $inc: {count: 1} - result: - matchedCount: 1 - modifiedCount: 1 - upsertedCount: 0 - - name: commitTransaction - object: session0 - - expectations: - - command_started_event: - command: - insert: *collection_name - documents: - - _id: 2 - ordered: true - readConcern: - lsid: session0 - txnNumber: - autocommit: - writeConcern: - command_name: insert - database_name: *database_name - - command_started_event: - command: - update: *collection_name - updates: - - q: {_id: 1} - u: {$inc: {count: 1}} - ordered: true - # No afterClusterTime - readConcern: - lsid: session0 - txnNumber: - $numberLong: "1" - startTransaction: true - autocommit: false - writeConcern: - command_name: update - database_name: *database_name - - command_started_event: - command: - commitTransaction: 1 - lsid: session0 - txnNumber: - $numberLong: "1" - startTransaction: - autocommit: false - writeConcern: - command_name: commitTransaction - database_name: admin - - outcome: - collection: - data: - - _id: 1 - count: 1 - - _id: 2 diff --git a/source/transactions/tests/legacy/commit.json b/source/transactions/tests/legacy/commit.json deleted file mode 100644 index d55a6b611c..0000000000 --- a/source/transactions/tests/legacy/commit.json +++ /dev/null @@ -1,926 +0,0 @@ -{ - "runOn": [ - { - "minServerVersion": "4.0", - "topology": [ - "replicaset" - ] - }, - { - "minServerVersion": "4.1.8", - "topology": [ - "sharded", - "load-balanced" - ] - } - ], - "database_name": "transaction-tests", - "collection_name": "test", - "data": [], - "tests": [ - { - "description": "commit", - "operations": [ - { - "name": "startTransaction", - "object": "session0" - }, - { - "name": "insertOne", - "object": "collection", - "arguments": { - "session": "session0", - "document": { - "_id": 1 - } - }, - "result": { - "insertedId": 1 - } - }, - { - "name": "commitTransaction", - "object": "session0" - }, - { - "name": "startTransaction", - "object": "session0" - }, - { - "name": "insertOne", - "object": "collection", - "arguments": { - "session": "session0", - "document": { - "_id": 2 - } - }, - "result": { - "insertedId": 2 - } - }, - { - "name": "commitTransaction", - "object": "session0" - } - ], - "expectations": [ - { - "command_started_event": { - "command": { - "insert": "test", - "documents": [ - { - "_id": 1 - } - ], - "ordered": true, - "readConcern": null, - "lsid": "session0", - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": true, - "autocommit": false, - "writeConcern": null - }, - "command_name": "insert", - "database_name": "transaction-tests" - } - }, - { - "command_started_event": { - "command": { - "commitTransaction": 1, - "lsid": "session0", - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": null, - "autocommit": false, - "writeConcern": null - }, - "command_name": "commitTransaction", - "database_name": "admin" - } - }, - { - "command_started_event": { - "command": { - "insert": "test", - "documents": [ - { - "_id": 2 - } - ], - "ordered": true, - "readConcern": { - "afterClusterTime": 42 - }, - "lsid": "session0", - "txnNumber": { - "$numberLong": "2" - }, - "startTransaction": true, - "autocommit": false, - "writeConcern": null - }, - "command_name": "insert", - "database_name": "transaction-tests" - } - }, - { - "command_started_event": { - "command": { - "commitTransaction": 1, - "lsid": "session0", - "txnNumber": { - "$numberLong": "2" - }, - "startTransaction": null, - "autocommit": false, - "writeConcern": null - }, - "command_name": "commitTransaction", - "database_name": "admin" - } - } - ], - "outcome": { - "collection": { - "data": [ - { - "_id": 1 - }, - { - "_id": 2 - } - ] - } - } - }, - { - "description": "rerun commit after empty transaction", - "operations": [ - { - "name": "startTransaction", - "object": "session0" - }, - { - "name": "commitTransaction", - "object": "session0" - }, - { - "name": "commitTransaction", - "object": "session0" - }, - { - "name": "startTransaction", - "object": "session0" - }, - { - "name": "insertOne", - "object": "collection", - "arguments": { - "session": "session0", - "document": { - "_id": 1 - } - }, - "result": { - "insertedId": 1 - } - }, - { - "name": "commitTransaction", - "object": "session0" - } - ], - "expectations": [ - { - "command_started_event": { - "command": { - "insert": "test", - "documents": [ - { - "_id": 1 - } - ], - "ordered": true, - "readConcern": null, - "lsid": "session0", - "txnNumber": { - "$numberLong": "2" - }, - "startTransaction": true, - "autocommit": false, - "writeConcern": null - }, - "command_name": "insert", - "database_name": "transaction-tests" - } - }, - { - "command_started_event": { - "command": { - "commitTransaction": 1, - "lsid": "session0", - "txnNumber": { - "$numberLong": "2" - }, - "startTransaction": null, - "autocommit": false, - "writeConcern": null - }, - "command_name": "commitTransaction", - "database_name": "admin" - } - } - ], - "outcome": { - "collection": { - "data": [ - { - "_id": 1 - } - ] - } - } - }, - { - "description": "multiple commits in a row", - "operations": [ - { - "name": "startTransaction", - "object": "session0" - }, - { - "name": "insertOne", - "object": "collection", - "arguments": { - "session": "session0", - "document": { - "_id": 1 - } - }, - "result": { - "insertedId": 1 - } - }, - { - "name": "commitTransaction", - "object": "session0" - }, - { - "name": "commitTransaction", - "object": "session0" - }, - { - "name": "commitTransaction", - "object": "session0" - } - ], - "expectations": [ - { - "command_started_event": { - "command": { - "insert": "test", - "documents": [ - { - "_id": 1 - } - ], - "ordered": true, - "readConcern": null, - "lsid": "session0", - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": true, - "autocommit": false, - "writeConcern": null - }, - "command_name": "insert", - "database_name": "transaction-tests" - } - }, - { - "command_started_event": { - "command": { - "commitTransaction": 1, - "lsid": "session0", - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": null, - "autocommit": false, - "writeConcern": null - }, - "command_name": "commitTransaction", - "database_name": "admin" - } - }, - { - "command_started_event": { - "command": { - "commitTransaction": 1, - "lsid": "session0", - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": null, - "autocommit": false, - "writeConcern": { - "w": "majority", - "wtimeout": 10000 - } - }, - "command_name": "commitTransaction", - "database_name": "admin" - } - }, - { - "command_started_event": { - "command": { - "commitTransaction": 1, - "lsid": "session0", - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": null, - "autocommit": false, - "writeConcern": { - "w": "majority", - "wtimeout": 10000 - } - }, - "command_name": "commitTransaction", - "database_name": "admin" - } - } - ], - "outcome": { - "collection": { - "data": [ - { - "_id": 1 - } - ] - } - } - }, - { - "description": "write concern error on commit", - "operations": [ - { - "name": "startTransaction", - "object": "session0", - "arguments": { - "options": { - "writeConcern": { - "w": 10 - } - } - } - }, - { - "name": "insertOne", - "object": "collection", - "arguments": { - "session": "session0", - "document": { - "_id": 1 - } - }, - "result": { - "insertedId": 1 - } - }, - { - "name": "commitTransaction", - "object": "session0", - "result": { - "errorLabelsOmit": [ - "TransientTransactionError", - "UnknownTransactionCommitResult" - ] - } - } - ], - "outcome": { - "collection": { - "data": [ - { - "_id": 1 - } - ] - } - } - }, - { - "description": "commit without start", - "operations": [ - { - "name": "commitTransaction", - "object": "session0", - "result": { - "errorContains": "no transaction started" - } - } - ], - "expectations": [], - "outcome": { - "collection": { - "data": [] - } - } - }, - { - "description": "commit after no-op abort", - "operations": [ - { - "name": "startTransaction", - "object": "session0" - }, - { - "name": "abortTransaction", - "object": "session0" - }, - { - "name": "commitTransaction", - "object": "session0", - "result": { - "errorContains": "Cannot call commitTransaction after calling abortTransaction" - } - } - ], - "expectations": [], - "outcome": { - "collection": { - "data": [] - } - } - }, - { - "description": "commit after abort", - "operations": [ - { - "name": "startTransaction", - "object": "session0" - }, - { - "name": "insertOne", - "object": "collection", - "arguments": { - "session": "session0", - "document": { - "_id": 1 - } - }, - "result": { - "insertedId": 1 - } - }, - { - "name": "abortTransaction", - "object": "session0" - }, - { - "name": "commitTransaction", - "object": "session0", - "result": { - "errorContains": "Cannot call commitTransaction after calling abortTransaction" - } - } - ], - "expectations": [ - { - "command_started_event": { - "command": { - "insert": "test", - "documents": [ - { - "_id": 1 - } - ], - "ordered": true, - "readConcern": null, - "lsid": "session0", - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": true, - "autocommit": false, - "writeConcern": null - }, - "command_name": "insert", - "database_name": "transaction-tests" - } - }, - { - "command_started_event": { - "command": { - "abortTransaction": 1, - "lsid": "session0", - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": null, - "autocommit": false, - "writeConcern": null - }, - "command_name": "abortTransaction", - "database_name": "admin" - } - } - ] - }, - { - "description": "multiple commits after empty transaction", - "operations": [ - { - "name": "startTransaction", - "object": "session0" - }, - { - "name": "insertOne", - "object": "collection", - "arguments": { - "session": "session0", - "document": { - "_id": 1 - } - }, - "result": { - "insertedId": 1 - } - }, - { - "name": "abortTransaction", - "object": "session0" - }, - { - "name": "startTransaction", - "object": "session0" - }, - { - "name": "commitTransaction", - "object": "session0" - }, - { - "name": "commitTransaction", - "object": "session0" - }, - { - "name": "startTransaction", - "object": "session0" - }, - { - "name": "insertOne", - "object": "collection", - "arguments": { - "session": "session0", - "document": { - "_id": 1 - } - }, - "result": { - "insertedId": 1 - } - }, - { - "name": "abortTransaction", - "object": "session0" - } - ], - "expectations": [ - { - "command_started_event": { - "command": { - "insert": "test", - "documents": [ - { - "_id": 1 - } - ], - "ordered": true, - "readConcern": null, - "lsid": "session0", - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": true, - "autocommit": false, - "writeConcern": null - }, - "command_name": "insert", - "database_name": "transaction-tests" - } - }, - { - "command_started_event": { - "command": { - "abortTransaction": 1, - "lsid": "session0", - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": null, - "autocommit": false, - "writeConcern": null - }, - "command_name": "abortTransaction", - "database_name": "admin" - } - }, - { - "command_started_event": { - "command": { - "insert": "test", - "documents": [ - { - "_id": 1 - } - ], - "ordered": true, - "readConcern": { - "afterClusterTime": 42 - }, - "lsid": "session0", - "txnNumber": { - "$numberLong": "3" - }, - "startTransaction": true, - "autocommit": false, - "writeConcern": null - }, - "command_name": "insert", - "database_name": "transaction-tests" - } - }, - { - "command_started_event": { - "command": { - "abortTransaction": 1, - "lsid": "session0", - "txnNumber": { - "$numberLong": "3" - }, - "startTransaction": null, - "autocommit": false, - "writeConcern": null - }, - "command_name": "abortTransaction", - "database_name": "admin" - } - } - ], - "outcome": { - "collection": { - "data": [] - } - } - }, - { - "description": "reset session state commit", - "clientOptions": { - "retryWrites": false - }, - "operations": [ - { - "name": "startTransaction", - "object": "session0" - }, - { - "name": "insertOne", - "object": "collection", - "arguments": { - "session": "session0", - "document": { - "_id": 1 - } - }, - "result": { - "insertedId": 1 - } - }, - { - "name": "commitTransaction", - "object": "session0" - }, - { - "name": "insertOne", - "object": "collection", - "arguments": { - "session": "session0", - "document": { - "_id": 2 - } - }, - "result": { - "insertedId": 2 - } - }, - { - "name": "commitTransaction", - "object": "session0", - "result": { - "errorContains": "no transaction started" - } - } - ], - "expectations": [ - { - "command_started_event": { - "command": { - "insert": "test", - "documents": [ - { - "_id": 1 - } - ], - "ordered": true, - "readConcern": null, - "lsid": "session0", - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": true, - "autocommit": false, - "writeConcern": null - }, - "command_name": "insert", - "database_name": "transaction-tests" - } - }, - { - "command_started_event": { - "command": { - "commitTransaction": 1, - "lsid": "session0", - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": null, - "autocommit": false, - "writeConcern": null - }, - "command_name": "commitTransaction", - "database_name": "admin" - } - }, - { - "command_started_event": { - "command": { - "insert": "test", - "documents": [ - { - "_id": 2 - } - ], - "ordered": true, - "readConcern": null, - "lsid": "session0", - "txnNumber": null, - "startTransaction": null, - "autocommit": null - }, - "command_name": "insert", - "database_name": "transaction-tests" - } - } - ], - "outcome": { - "collection": { - "data": [ - { - "_id": 1 - }, - { - "_id": 2 - } - ] - } - } - }, - { - "description": "reset session state abort", - "clientOptions": { - "retryWrites": false - }, - "operations": [ - { - "name": "startTransaction", - "object": "session0" - }, - { - "name": "insertOne", - "object": "collection", - "arguments": { - "session": "session0", - "document": { - "_id": 1 - } - }, - "result": { - "insertedId": 1 - } - }, - { - "name": "abortTransaction", - "object": "session0" - }, - { - "name": "insertOne", - "object": "collection", - "arguments": { - "session": "session0", - "document": { - "_id": 2 - } - }, - "result": { - "insertedId": 2 - } - }, - { - "name": "abortTransaction", - "object": "session0", - "result": { - "errorContains": "no transaction started" - } - } - ], - "expectations": [ - { - "command_started_event": { - "command": { - "insert": "test", - "documents": [ - { - "_id": 1 - } - ], - "ordered": true, - "readConcern": null, - "lsid": "session0", - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": true, - "autocommit": false, - "writeConcern": null - }, - "command_name": "insert", - "database_name": "transaction-tests" - } - }, - { - "command_started_event": { - "command": { - "abortTransaction": 1, - "lsid": "session0", - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": null, - "autocommit": false, - "writeConcern": null - }, - "command_name": "abortTransaction", - "database_name": "admin" - } - }, - { - "command_started_event": { - "command": { - "insert": "test", - "documents": [ - { - "_id": 2 - } - ], - "ordered": true, - "readConcern": null, - "lsid": "session0", - "txnNumber": null, - "startTransaction": null, - "autocommit": null - }, - "command_name": "insert", - "database_name": "transaction-tests" - } - } - ], - "outcome": { - "collection": { - "data": [ - { - "_id": 2 - } - ] - } - } - } - ] -} diff --git a/source/transactions/tests/legacy/commit.yml b/source/transactions/tests/legacy/commit.yml deleted file mode 100644 index e7d600d514..0000000000 --- a/source/transactions/tests/legacy/commit.yml +++ /dev/null @@ -1,603 +0,0 @@ -runOn: - - - minServerVersion: "4.0" - topology: ["replicaset"] - - - minServerVersion: "4.1.8" - topology: ["sharded", "load-balanced"] - -database_name: &database_name "transaction-tests" -collection_name: &collection_name "test" - -data: [] -tests: - - description: commit - - operations: - - name: startTransaction - object: session0 - - name: insertOne - object: collection - arguments: - session: session0 - document: - _id: 1 - result: - insertedId: 1 - - name: commitTransaction - object: session0 - # Again, to verify that txnNumber is incremented. - - name: startTransaction - object: session0 - - name: insertOne - object: collection - arguments: - session: session0 - document: - _id: 2 - result: - insertedId: 2 - - name: commitTransaction - object: session0 - - expectations: - - command_started_event: - command: - insert: *collection_name - documents: - - _id: 1 - ordered: true - readConcern: - lsid: session0 - txnNumber: - $numberLong: "1" - startTransaction: true - autocommit: false - writeConcern: - command_name: insert - database_name: *database_name - - command_started_event: - command: - commitTransaction: 1 - lsid: session0 - txnNumber: - $numberLong: "1" - startTransaction: - autocommit: false - writeConcern: - command_name: commitTransaction - database_name: admin - - command_started_event: - command: - insert: *collection_name - documents: - - _id: 2 - ordered: true - readConcern: - afterClusterTime: 42 - lsid: session0 - txnNumber: - $numberLong: "2" - startTransaction: true - autocommit: false - writeConcern: - command_name: insert - database_name: *database_name - - command_started_event: - command: - commitTransaction: 1 - lsid: session0 - txnNumber: - $numberLong: "2" - startTransaction: - autocommit: false - writeConcern: - command_name: commitTransaction - database_name: admin - - outcome: - collection: - data: - - _id: 1 - - _id: 2 - - - description: rerun commit after empty transaction - - operations: - - name: startTransaction - object: session0 - - name: commitTransaction - object: session0 - # Rerun the commit (which does not increment the txnNumber). - - name: commitTransaction - object: session0 - - name: startTransaction - object: session0 - - name: insertOne - object: collection - arguments: - session: session0 - document: - _id: 1 - result: - insertedId: 1 - - name: commitTransaction - object: session0 - - expectations: - - command_started_event: - command: - insert: *collection_name - documents: - - _id: 1 - ordered: true - readConcern: - lsid: session0 - txnNumber: - $numberLong: "2" - startTransaction: true - autocommit: false - writeConcern: - command_name: insert - database_name: *database_name - - command_started_event: - command: - commitTransaction: 1 - lsid: session0 - txnNumber: - $numberLong: "2" - startTransaction: - autocommit: false - writeConcern: - command_name: commitTransaction - database_name: admin - - outcome: - collection: - data: - - _id: 1 - - - description: multiple commits in a row - - operations: - - name: startTransaction - object: session0 - - name: insertOne - object: collection - arguments: - session: session0 - document: - _id: 1 - result: - insertedId: 1 - - name: commitTransaction - object: session0 - - name: commitTransaction - object: session0 - - name: commitTransaction - object: session0 - - expectations: - - command_started_event: - command: - insert: *collection_name - documents: - - _id: 1 - ordered: true - readConcern: - lsid: session0 - txnNumber: - $numberLong: "1" - startTransaction: true - autocommit: false - writeConcern: - command_name: insert - database_name: *database_name - - command_started_event: - command: - commitTransaction: 1 - lsid: session0 - txnNumber: - $numberLong: "1" - startTransaction: - autocommit: false - writeConcern: - command_name: commitTransaction - database_name: admin - - command_started_event: - command: - commitTransaction: 1 - lsid: session0 - txnNumber: - $numberLong: "1" - startTransaction: - autocommit: false - # commitTransaction applies w:majority on retries - writeConcern: { w: majority, wtimeout: 10000 } - command_name: commitTransaction - database_name: admin - - command_started_event: - command: - commitTransaction: 1 - lsid: session0 - txnNumber: - $numberLong: "1" - startTransaction: - autocommit: false - writeConcern: { w: majority, wtimeout: 10000 } - command_name: commitTransaction - database_name: admin - - outcome: - collection: - data: - - _id: 1 - - - description: write concern error on commit - operations: - - name: startTransaction - object: session0 - arguments: - options: - writeConcern: - w: 10 - - name: insertOne - object: collection - arguments: - session: session0 - document: - _id: 1 - result: - insertedId: 1 - - name: commitTransaction - object: session0 - result: - # { - # 'ok': 1.0, - # 'writeConcernError': { - # 'code': 100, - # 'codeName': 'UnsatisfiableWriteConcern', - # 'errmsg': 'Not enough data-bearing nodes' - # } - # } - errorLabelsOmit: ["TransientTransactionError", "UnknownTransactionCommitResult"] - - outcome: - collection: - data: - - _id: 1 - - - description: commit without start - - operations: - - name: commitTransaction - object: session0 - result: - errorContains: no transaction started - - expectations: [] - - outcome: - collection: - data: [] - - - description: commit after no-op abort - - operations: - - name: startTransaction - object: session0 - - name: abortTransaction - object: session0 - - name: commitTransaction - object: session0 - result: - errorContains: Cannot call commitTransaction after calling abortTransaction - - expectations: [] - - outcome: - collection: - data: [] - - - description: commit after abort - - operations: - - name: startTransaction - object: session0 - - name: insertOne - object: collection - arguments: - session: session0 - document: - _id: 1 - result: - insertedId: 1 - - name: abortTransaction - object: session0 - - name: commitTransaction - object: session0 - result: - errorContains: Cannot call commitTransaction after calling abortTransaction - - expectations: - - command_started_event: - command: - insert: *collection_name - documents: - - _id: 1 - ordered: true - readConcern: - lsid: session0 - txnNumber: - $numberLong: "1" - startTransaction: true - autocommit: false - writeConcern: - command_name: insert - database_name: *database_name - - command_started_event: - command: - abortTransaction: 1 - lsid: session0 - txnNumber: - $numberLong: "1" - startTransaction: - autocommit: false - writeConcern: - command_name: abortTransaction - database_name: admin - - - description: multiple commits after empty transaction - - operations: - - name: startTransaction - object: session0 - - name: insertOne - object: collection - arguments: - session: session0 - document: - _id: 1 - result: - insertedId: 1 - - name: abortTransaction - object: session0 - # Increments txnNumber. - - name: startTransaction - object: session0 - # These commits aren't sent to server, transaction is empty. - - name: commitTransaction - object: session0 - - name: commitTransaction - object: session0 - # Verify that previous, empty transaction incremented txnNumber. - - name: startTransaction - object: session0 - - name: insertOne - object: collection - arguments: - session: session0 - document: - _id: 1 - result: - insertedId: 1 - - name: abortTransaction - object: session0 - - expectations: - - command_started_event: - command: - insert: *collection_name - documents: - - _id: 1 - ordered: true - readConcern: - lsid: session0 - txnNumber: - $numberLong: "1" - startTransaction: true - autocommit: false - writeConcern: - command_name: insert - database_name: *database_name - - command_started_event: - command: - abortTransaction: 1 - lsid: session0 - txnNumber: - $numberLong: "1" - startTransaction: - autocommit: false - writeConcern: - command_name: abortTransaction - database_name: admin - - command_started_event: - command: - insert: *collection_name - documents: - - _id: 1 - ordered: true - readConcern: - afterClusterTime: 42 - lsid: session0 - # txnNumber 2 was skipped. - txnNumber: - $numberLong: "3" - startTransaction: true - autocommit: false - writeConcern: - command_name: insert - database_name: *database_name - - command_started_event: - command: - abortTransaction: 1 - lsid: session0 - txnNumber: - $numberLong: "3" - startTransaction: - autocommit: false - writeConcern: - command_name: abortTransaction - database_name: admin - - outcome: - collection: - data: [] - - - description: reset session state commit - clientOptions: - retryWrites: false - operations: - - name: startTransaction - object: session0 - - name: insertOne - object: collection - arguments: - session: session0 - document: - _id: 1 - result: - insertedId: 1 - - name: commitTransaction - object: session0 - # Running any operation after an ended transaction resets the session - # state to "no transaction". - - name: insertOne - object: collection - arguments: - session: session0 - document: - _id: 2 - result: - insertedId: 2 - # Calling commit again should error instead of re-running the commit. - - name: commitTransaction - object: session0 - result: - errorContains: no transaction started - - expectations: - - command_started_event: - command: - insert: *collection_name - documents: - - _id: 1 - ordered: true - readConcern: - lsid: session0 - txnNumber: - $numberLong: "1" - startTransaction: true - autocommit: false - writeConcern: - command_name: insert - database_name: *database_name - - command_started_event: - command: - commitTransaction: 1 - lsid: session0 - txnNumber: - $numberLong: "1" - startTransaction: - autocommit: false - writeConcern: - command_name: commitTransaction - database_name: admin - - command_started_event: - command: - insert: *collection_name - documents: - - _id: 2 - ordered: true - readConcern: - lsid: session0 - txnNumber: - startTransaction: - autocommit: - command_name: insert - database_name: *database_name - - outcome: - collection: - data: - - _id: 1 - - _id: 2 - - - description: reset session state abort - clientOptions: - retryWrites: false - operations: - - name: startTransaction - object: session0 - - name: insertOne - object: collection - arguments: - session: session0 - document: - _id: 1 - result: - insertedId: 1 - - name: abortTransaction - object: session0 - # Running any operation after an ended transaction resets the session - # state to "no transaction". - - name: insertOne - object: collection - arguments: - session: session0 - document: - _id: 2 - result: - insertedId: 2 - # Calling abort should error with "no transaction started" instead of - # "cannot call abortTransaction twice". - - name: abortTransaction - object: session0 - result: - errorContains: no transaction started - - expectations: - - command_started_event: - command: - insert: *collection_name - documents: - - _id: 1 - ordered: true - readConcern: - lsid: session0 - txnNumber: - $numberLong: "1" - startTransaction: true - autocommit: false - writeConcern: - command_name: insert - database_name: *database_name - - command_started_event: - command: - abortTransaction: 1 - lsid: session0 - txnNumber: - $numberLong: "1" - startTransaction: - autocommit: false - writeConcern: - command_name: abortTransaction - database_name: admin - - command_started_event: - command: - insert: *collection_name - documents: - - _id: 2 - ordered: true - readConcern: - lsid: session0 - txnNumber: - startTransaction: - autocommit: - command_name: insert - database_name: *database_name - - outcome: - collection: - data: - - _id: 2 diff --git a/source/transactions/tests/legacy/count.json b/source/transactions/tests/legacy/count.json deleted file mode 100644 index 357bc252d6..0000000000 --- a/source/transactions/tests/legacy/count.json +++ /dev/null @@ -1,121 +0,0 @@ -{ - "runOn": [ - { - "minServerVersion": "4.0.2", - "topology": [ - "replicaset" - ] - }, - { - "minServerVersion": "4.1.8", - "topology": [ - "sharded", - "load-balanced" - ] - } - ], - "database_name": "transaction-tests", - "collection_name": "test", - "data": [ - { - "_id": 1 - }, - { - "_id": 2 - }, - { - "_id": 3 - }, - { - "_id": 4 - } - ], - "tests": [ - { - "description": "count", - "operations": [ - { - "name": "startTransaction", - "object": "session0" - }, - { - "name": "count", - "object": "collection", - "arguments": { - "session": "session0", - "filter": { - "_id": 1 - } - }, - "result": { - "errorCodeName": "OperationNotSupportedInTransaction", - "errorLabelsOmit": [ - "TransientTransactionError", - "UnknownTransactionCommitResult" - ] - } - }, - { - "name": "abortTransaction", - "object": "session0" - } - ], - "expectations": [ - { - "command_started_event": { - "command": { - "count": "test", - "query": { - "_id": 1 - }, - "readConcern": null, - "lsid": "session0", - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": true, - "autocommit": false, - "writeConcern": null - }, - "command_name": "count", - "database_name": "transaction-tests" - } - }, - { - "command_started_event": { - "command": { - "abortTransaction": 1, - "lsid": "session0", - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": null, - "autocommit": false, - "writeConcern": null - }, - "command_name": "abortTransaction", - "database_name": "admin" - } - } - ], - "outcome": { - "collection": { - "data": [ - { - "_id": 1 - }, - { - "_id": 2 - }, - { - "_id": 3 - }, - { - "_id": 4 - } - ] - } - } - } - ] -} diff --git a/source/transactions/tests/legacy/count.yml b/source/transactions/tests/legacy/count.yml deleted file mode 100644 index 49924be585..0000000000 --- a/source/transactions/tests/legacy/count.yml +++ /dev/null @@ -1,67 +0,0 @@ -runOn: - # SERVER-35388 introduced OperationNotSupportedInTransaction in 4.0.2 - - - minServerVersion: "4.0.2" - topology: ["replicaset"] - - - minServerVersion: "4.1.8" - topology: ["sharded", "load-balanced"] - -database_name: &database_name "transaction-tests" -collection_name: &collection_name "test" - -data: &data - - {_id: 1} - - {_id: 2} - - {_id: 3} - - {_id: 4} - -tests: - - description: count - - operations: - - name: startTransaction - object: session0 - - name: count - object: collection - arguments: - session: session0 - filter: - _id: 1 - result: - errorCodeName: OperationNotSupportedInTransaction - errorLabelsOmit: ["TransientTransactionError", "UnknownTransactionCommitResult"] - - name: abortTransaction - object: session0 - - expectations: - - command_started_event: - command: - count: *collection_name - query: - _id: 1 - readConcern: - lsid: session0 - txnNumber: - $numberLong: "1" - startTransaction: true - autocommit: false - writeConcern: - command_name: count - database_name: *database_name - - command_started_event: - command: - abortTransaction: 1 - lsid: session0 - txnNumber: - $numberLong: "1" - startTransaction: - autocommit: false - writeConcern: - command_name: abortTransaction - database_name: admin - - outcome: - collection: - data: - *data diff --git a/source/transactions/tests/legacy/create-collection.json b/source/transactions/tests/legacy/create-collection.json deleted file mode 100644 index d65159d024..0000000000 --- a/source/transactions/tests/legacy/create-collection.json +++ /dev/null @@ -1,205 +0,0 @@ -{ - "runOn": [ - { - "minServerVersion": "4.3.4", - "topology": [ - "replicaset", - "sharded", - "load-balanced" - ] - } - ], - "database_name": "transaction-tests", - "collection_name": "test", - "data": [], - "tests": [ - { - "description": "explicitly create collection using create command", - "operations": [ - { - "name": "dropCollection", - "object": "database", - "arguments": { - "collection": "test" - } - }, - { - "name": "startTransaction", - "object": "session0" - }, - { - "name": "createCollection", - "object": "database", - "arguments": { - "session": "session0", - "collection": "test" - } - }, - { - "name": "assertCollectionNotExists", - "object": "testRunner", - "arguments": { - "database": "transaction-tests", - "collection": "test" - } - }, - { - "name": "commitTransaction", - "object": "session0" - }, - { - "name": "assertCollectionExists", - "object": "testRunner", - "arguments": { - "database": "transaction-tests", - "collection": "test" - } - } - ], - "expectations": [ - { - "command_started_event": { - "command": { - "drop": "test", - "writeConcern": null - }, - "command_name": "drop", - "database_name": "transaction-tests" - } - }, - { - "command_started_event": { - "command": { - "create": "test", - "lsid": "session0", - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": true, - "autocommit": false, - "writeConcern": null - }, - "command_name": "create", - "database_name": "transaction-tests" - } - }, - { - "command_started_event": { - "command": { - "commitTransaction": 1, - "lsid": "session0", - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": null, - "autocommit": false, - "writeConcern": null - }, - "command_name": "commitTransaction", - "database_name": "admin" - } - } - ] - }, - { - "description": "implicitly create collection using insert", - "operations": [ - { - "name": "dropCollection", - "object": "database", - "arguments": { - "collection": "test" - } - }, - { - "name": "startTransaction", - "object": "session0" - }, - { - "name": "insertOne", - "object": "collection", - "arguments": { - "session": "session0", - "document": { - "_id": 1 - } - }, - "result": { - "insertedId": 1 - } - }, - { - "name": "assertCollectionNotExists", - "object": "testRunner", - "arguments": { - "database": "transaction-tests", - "collection": "test" - } - }, - { - "name": "commitTransaction", - "object": "session0" - }, - { - "name": "assertCollectionExists", - "object": "testRunner", - "arguments": { - "database": "transaction-tests", - "collection": "test" - } - } - ], - "expectations": [ - { - "command_started_event": { - "command": { - "drop": "test", - "writeConcern": null - }, - "command_name": "drop", - "database_name": "transaction-tests" - } - }, - { - "command_started_event": { - "command": { - "insert": "test", - "documents": [ - { - "_id": 1 - } - ], - "ordered": true, - "readConcern": null, - "lsid": "session0", - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": true, - "autocommit": false, - "writeConcern": null - }, - "command_name": "insert", - "database_name": "transaction-tests" - } - }, - { - "command_started_event": { - "command": { - "commitTransaction": 1, - "lsid": "session0", - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": null, - "autocommit": false, - "writeConcern": null - }, - "command_name": "commitTransaction", - "database_name": "admin" - } - } - ] - } - ] -} diff --git a/source/transactions/tests/legacy/create-collection.yml b/source/transactions/tests/legacy/create-collection.yml deleted file mode 100644 index 2786f2ae2a..0000000000 --- a/source/transactions/tests/legacy/create-collection.yml +++ /dev/null @@ -1,131 +0,0 @@ -runOn: - - - minServerVersion: "4.3.4" - topology: ["replicaset", "sharded", "load-balanced"] - -database_name: &database_name "transaction-tests" -collection_name: &collection_name "test" - -data: [] - -tests: - - description: explicitly create collection using create command - - operations: - - name: dropCollection - object: database - arguments: - collection: *collection_name - - name: startTransaction - object: session0 - - name: createCollection - object: database - arguments: - session: session0 - collection: *collection_name - - name: assertCollectionNotExists - object: testRunner - arguments: - database: *database_name - collection: *collection_name - - name: commitTransaction - object: session0 - - name: assertCollectionExists - object: testRunner - arguments: - database: *database_name - collection: *collection_name - - expectations: - - command_started_event: - command: - drop: *collection_name - writeConcern: - command_name: drop - database_name: *database_name - - command_started_event: - command: - create: *collection_name - lsid: session0 - txnNumber: - $numberLong: "1" - startTransaction: true - autocommit: false - writeConcern: - command_name: create - database_name: *database_name - - command_started_event: - command: - commitTransaction: 1 - lsid: session0 - txnNumber: - $numberLong: "1" - startTransaction: - autocommit: false - writeConcern: - command_name: commitTransaction - database_name: admin - - - description: implicitly create collection using insert - - operations: - - name: dropCollection - object: database - arguments: - collection: *collection_name - - name: startTransaction - object: session0 - - name: insertOne - object: collection - arguments: - session: session0 - document: - _id: 1 - result: - insertedId: 1 - - name: assertCollectionNotExists - object: testRunner - arguments: - database: *database_name - collection: *collection_name - - name: commitTransaction - object: session0 - - name: assertCollectionExists - object: testRunner - arguments: - database: *database_name - collection: *collection_name - - expectations: - - command_started_event: - command: - drop: *collection_name - writeConcern: - command_name: drop - database_name: *database_name - - command_started_event: - command: - insert: *collection_name - documents: - - _id: 1 - ordered: true - readConcern: - lsid: session0 - txnNumber: - $numberLong: "1" - startTransaction: true - autocommit: false - writeConcern: - command_name: insert - database_name: *database_name - - command_started_event: - command: - commitTransaction: 1 - lsid: session0 - txnNumber: - $numberLong: "1" - startTransaction: - autocommit: false - writeConcern: - command_name: commitTransaction - database_name: admin diff --git a/source/transactions/tests/legacy/create-index.json b/source/transactions/tests/legacy/create-index.json deleted file mode 100644 index cd0d75d0bc..0000000000 --- a/source/transactions/tests/legacy/create-index.json +++ /dev/null @@ -1,238 +0,0 @@ -{ - "runOn": [ - { - "minServerVersion": "4.3.4", - "topology": [ - "replicaset", - "sharded", - "load-balanced" - ] - } - ], - "database_name": "transaction-tests", - "collection_name": "test", - "data": [], - "tests": [ - { - "description": "create index on a non-existing collection", - "operations": [ - { - "name": "dropCollection", - "object": "database", - "arguments": { - "collection": "test" - } - }, - { - "name": "startTransaction", - "object": "session0" - }, - { - "name": "createIndex", - "object": "collection", - "arguments": { - "session": "session0", - "name": "t_1", - "keys": { - "x": 1 - } - } - }, - { - "name": "assertIndexNotExists", - "object": "testRunner", - "arguments": { - "database": "transaction-tests", - "collection": "test", - "index": "t_1" - } - }, - { - "name": "commitTransaction", - "object": "session0" - }, - { - "name": "assertIndexExists", - "object": "testRunner", - "arguments": { - "database": "transaction-tests", - "collection": "test", - "index": "t_1" - } - } - ], - "expectations": [ - { - "command_started_event": { - "command": { - "drop": "test", - "writeConcern": null - }, - "command_name": "drop", - "database_name": "transaction-tests" - } - }, - { - "command_started_event": { - "command": { - "createIndexes": "test", - "indexes": [ - { - "name": "t_1", - "key": { - "x": 1 - } - } - ], - "lsid": "session0", - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": true, - "autocommit": false, - "writeConcern": null - }, - "command_name": "createIndexes", - "database_name": "transaction-tests" - } - }, - { - "command_started_event": { - "command": { - "commitTransaction": 1, - "lsid": "session0", - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": null, - "autocommit": false, - "writeConcern": null - }, - "command_name": "commitTransaction", - "database_name": "admin" - } - } - ] - }, - { - "description": "create index on a collection created within the same transaction", - "operations": [ - { - "name": "dropCollection", - "object": "database", - "arguments": { - "collection": "test" - } - }, - { - "name": "startTransaction", - "object": "session0" - }, - { - "name": "createCollection", - "object": "database", - "arguments": { - "session": "session0", - "collection": "test" - } - }, - { - "name": "createIndex", - "object": "collection", - "arguments": { - "session": "session0", - "name": "t_1", - "keys": { - "x": 1 - } - } - }, - { - "name": "assertIndexNotExists", - "object": "testRunner", - "arguments": { - "database": "transaction-tests", - "collection": "test", - "index": "t_1" - } - }, - { - "name": "commitTransaction", - "object": "session0" - }, - { - "name": "assertIndexExists", - "object": "testRunner", - "arguments": { - "database": "transaction-tests", - "collection": "test", - "index": "t_1" - } - } - ], - "expectations": [ - { - "command_started_event": { - "command": { - "drop": "test", - "writeConcern": null - }, - "command_name": "drop", - "database_name": "transaction-tests" - } - }, - { - "command_started_event": { - "command": { - "create": "test", - "lsid": "session0", - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": true, - "autocommit": false, - "writeConcern": null - }, - "command_name": "create", - "database_name": "transaction-tests" - } - }, - { - "command_started_event": { - "command": { - "createIndexes": "test", - "indexes": [ - { - "name": "t_1", - "key": { - "x": 1 - } - } - ], - "lsid": "session0", - "writeConcern": null - }, - "command_name": "createIndexes", - "database_name": "transaction-tests" - } - }, - { - "command_started_event": { - "command": { - "commitTransaction": 1, - "lsid": "session0", - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": null, - "autocommit": false, - "writeConcern": null - }, - "command_name": "commitTransaction", - "database_name": "admin" - } - } - ] - } - ] -} diff --git a/source/transactions/tests/legacy/create-index.yml b/source/transactions/tests/legacy/create-index.yml deleted file mode 100644 index 0f964af2fd..0000000000 --- a/source/transactions/tests/legacy/create-index.yml +++ /dev/null @@ -1,152 +0,0 @@ -runOn: - - - minServerVersion: "4.3.4" - topology: ["replicaset", "sharded", "load-balanced"] - -database_name: &database_name "transaction-tests" -collection_name: &collection_name "test" - -data: [] - -tests: - - description: create index on a non-existing collection - - operations: - - name: dropCollection - object: database - arguments: - collection: *collection_name - - name: startTransaction - object: session0 - - name: createIndex - object: collection - arguments: - session: session0 - name: &index_name "t_1" - keys: - x: 1 - - name: assertIndexNotExists - object: testRunner - arguments: - database: *database_name - collection: *collection_name - index: *index_name - - name: commitTransaction - object: session0 - - name: assertIndexExists - object: testRunner - arguments: - database: *database_name - collection: *collection_name - index: *index_name - - expectations: - - command_started_event: - command: - drop: *collection_name - writeConcern: - command_name: drop - database_name: *database_name - - command_started_event: - command: - createIndexes: *collection_name - indexes: - - name: *index_name - key: - x: 1 - lsid: session0 - txnNumber: - $numberLong: "1" - startTransaction: true - autocommit: false - writeConcern: - command_name: createIndexes - database_name: *database_name - - command_started_event: - command: - commitTransaction: 1 - lsid: session0 - txnNumber: - $numberLong: "1" - startTransaction: - autocommit: false - writeConcern: - command_name: commitTransaction - database_name: admin - - - description: create index on a collection created within the same transaction - - operations: - - name: dropCollection - object: database - arguments: - collection: *collection_name - - name: startTransaction - object: session0 - - name: createCollection - object: database - arguments: - session: session0 - collection: *collection_name - - name: createIndex - object: collection - arguments: - session: session0 - name: *index_name - keys: - x: 1 - - name: assertIndexNotExists - object: testRunner - arguments: - database: *database_name - collection: *collection_name - index: *index_name - - name: commitTransaction - object: session0 - - name: assertIndexExists - object: testRunner - arguments: - database: *database_name - collection: *collection_name - index: *index_name - - expectations: - - command_started_event: - command: - drop: *collection_name - writeConcern: - command_name: drop - database_name: *database_name - - command_started_event: - command: - create: *collection_name - lsid: session0 - txnNumber: - $numberLong: "1" - startTransaction: true - autocommit: false - writeConcern: - command_name: create - database_name: *database_name - - command_started_event: - command: - createIndexes: *collection_name - indexes: - - name: *index_name - key: - x: 1 - lsid: session0 - writeConcern: - command_name: createIndexes - database_name: *database_name - - command_started_event: - command: - commitTransaction: 1 - lsid: session0 - txnNumber: - $numberLong: "1" - startTransaction: - autocommit: false - writeConcern: - command_name: commitTransaction - database_name: admin diff --git a/source/transactions/tests/legacy/delete.json b/source/transactions/tests/legacy/delete.json deleted file mode 100644 index 2e21494536..0000000000 --- a/source/transactions/tests/legacy/delete.json +++ /dev/null @@ -1,328 +0,0 @@ -{ - "runOn": [ - { - "minServerVersion": "4.0", - "topology": [ - "replicaset" - ] - }, - { - "minServerVersion": "4.1.8", - "topology": [ - "sharded", - "load-balanced" - ] - } - ], - "database_name": "transaction-tests", - "collection_name": "test", - "data": [ - { - "_id": 1 - }, - { - "_id": 2 - }, - { - "_id": 3 - }, - { - "_id": 4 - }, - { - "_id": 5 - } - ], - "tests": [ - { - "description": "delete", - "operations": [ - { - "name": "startTransaction", - "object": "session0" - }, - { - "name": "deleteOne", - "object": "collection", - "arguments": { - "session": "session0", - "filter": { - "_id": 1 - } - }, - "result": { - "deletedCount": 1 - } - }, - { - "name": "deleteMany", - "object": "collection", - "arguments": { - "session": "session0", - "filter": { - "_id": { - "$lte": 3 - } - } - }, - "result": { - "deletedCount": 2 - } - }, - { - "name": "deleteOne", - "object": "collection", - "arguments": { - "session": "session0", - "filter": { - "_id": 4 - } - }, - "result": { - "deletedCount": 1 - } - }, - { - "name": "commitTransaction", - "object": "session0" - } - ], - "expectations": [ - { - "command_started_event": { - "command": { - "delete": "test", - "deletes": [ - { - "q": { - "_id": 1 - }, - "limit": 1 - } - ], - "ordered": true, - "readConcern": null, - "lsid": "session0", - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": true, - "autocommit": false, - "writeConcern": null - }, - "command_name": "delete", - "database_name": "transaction-tests" - } - }, - { - "command_started_event": { - "command": { - "delete": "test", - "deletes": [ - { - "q": { - "_id": { - "$lte": 3 - } - }, - "limit": 0 - } - ], - "ordered": true, - "lsid": "session0", - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": null, - "autocommit": false, - "writeConcern": null - }, - "command_name": "delete", - "database_name": "transaction-tests" - } - }, - { - "command_started_event": { - "command": { - "delete": "test", - "deletes": [ - { - "q": { - "_id": 4 - }, - "limit": 1 - } - ], - "ordered": true, - "lsid": "session0", - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": null, - "autocommit": false, - "writeConcern": null - }, - "command_name": "delete", - "database_name": "transaction-tests" - } - }, - { - "command_started_event": { - "command": { - "commitTransaction": 1, - "lsid": "session0", - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": null, - "autocommit": false, - "writeConcern": null - }, - "command_name": "commitTransaction", - "database_name": "admin" - } - } - ], - "outcome": { - "collection": { - "data": [ - { - "_id": 5 - } - ] - } - } - }, - { - "description": "collection writeConcern ignored for delete", - "operations": [ - { - "name": "startTransaction", - "object": "session0", - "arguments": { - "options": { - "writeConcern": { - "w": "majority" - } - } - } - }, - { - "name": "deleteOne", - "object": "collection", - "collectionOptions": { - "writeConcern": { - "w": "majority" - } - }, - "arguments": { - "session": "session0", - "filter": { - "_id": 1 - } - }, - "result": { - "deletedCount": 1 - } - }, - { - "name": "deleteMany", - "object": "collection", - "collectionOptions": { - "writeConcern": { - "w": "majority" - } - }, - "arguments": { - "session": "session0", - "filter": { - "_id": { - "$lte": 3 - } - } - }, - "result": { - "deletedCount": 2 - } - }, - { - "name": "commitTransaction", - "object": "session0" - } - ], - "expectations": [ - { - "command_started_event": { - "command": { - "delete": "test", - "deletes": [ - { - "q": { - "_id": 1 - }, - "limit": 1 - } - ], - "ordered": true, - "readConcern": null, - "lsid": "session0", - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": true, - "autocommit": false, - "writeConcern": null - }, - "command_name": "delete", - "database_name": "transaction-tests" - } - }, - { - "command_started_event": { - "command": { - "delete": "test", - "deletes": [ - { - "q": { - "_id": { - "$lte": 3 - } - }, - "limit": 0 - } - ], - "ordered": true, - "lsid": "session0", - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": null, - "autocommit": false, - "writeConcern": null - }, - "command_name": "delete", - "database_name": "transaction-tests" - } - }, - { - "command_started_event": { - "command": { - "commitTransaction": 1, - "lsid": "session0", - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": null, - "autocommit": false, - "writeConcern": { - "w": "majority" - } - }, - "command_name": "commitTransaction", - "database_name": "admin" - } - } - ] - } - ] -} diff --git a/source/transactions/tests/legacy/delete.yml b/source/transactions/tests/legacy/delete.yml deleted file mode 100644 index b8ef99fef8..0000000000 --- a/source/transactions/tests/legacy/delete.yml +++ /dev/null @@ -1,192 +0,0 @@ -runOn: - - - minServerVersion: "4.0" - topology: ["replicaset"] - - - minServerVersion: "4.1.8" - topology: ["sharded", "load-balanced"] - -database_name: &database_name "transaction-tests" -collection_name: &collection_name "test" - -data: - - _id: 1 - - _id: 2 - - _id: 3 - - _id: 4 - - _id: 5 - -tests: - - description: delete - - operations: - - name: startTransaction - object: session0 - - name: deleteOne - object: collection - arguments: - session: session0 - filter: - _id: 1 - result: - deletedCount: 1 - - name: deleteMany - object: collection - arguments: - session: session0 - filter: - _id: {$lte: 3} - result: - deletedCount: 2 - - name: deleteOne - object: collection - arguments: - session: session0 - filter: - _id: 4 - result: - deletedCount: 1 - - name: commitTransaction - object: session0 - - expectations: - - command_started_event: - command: - delete: *collection_name - deletes: - - q: {_id: 1} - limit: 1 - ordered: true - readConcern: - lsid: session0 - txnNumber: - $numberLong: "1" - startTransaction: true - autocommit: false - writeConcern: - command_name: delete - database_name: *database_name - - command_started_event: - command: - delete: *collection_name - deletes: - - q: {_id: {$lte: 3}} - limit: 0 - ordered: true - lsid: session0 - txnNumber: - $numberLong: "1" - startTransaction: - autocommit: false - writeConcern: - command_name: delete - database_name: *database_name - - command_started_event: - command: - delete: *collection_name - deletes: - - q: {_id: 4} - limit: 1 - ordered: true - lsid: session0 - txnNumber: - $numberLong: "1" - startTransaction: - autocommit: false - writeConcern: - command_name: delete - database_name: *database_name - - command_started_event: - command: - commitTransaction: 1 - lsid: session0 - txnNumber: - $numberLong: "1" - startTransaction: - autocommit: false - writeConcern: - command_name: commitTransaction - database_name: admin - - outcome: - collection: - data: - - _id: 5 - - - description: collection writeConcern ignored for delete - operations: - - name: startTransaction - object: session0 - arguments: - options: - writeConcern: - w: majority - - name: deleteOne - object: collection - collectionOptions: - writeConcern: - w: majority - arguments: - session: session0 - filter: - _id: 1 - result: - deletedCount: 1 - - name: deleteMany - object: collection - collectionOptions: - writeConcern: - w: majority - arguments: - session: session0 - filter: - _id: {$lte: 3} - result: - deletedCount: 2 - - name: commitTransaction - object: session0 - - expectations: - - command_started_event: - command: - delete: *collection_name - deletes: - - q: {_id: 1} - limit: 1 - ordered: true - readConcern: - lsid: session0 - txnNumber: - $numberLong: "1" - startTransaction: true - autocommit: false - writeConcern: - command_name: delete - database_name: *database_name - - command_started_event: - command: - delete: *collection_name - deletes: - - q: {_id: {$lte: 3}} - limit: 0 - ordered: true - lsid: session0 - txnNumber: - $numberLong: "1" - startTransaction: - autocommit: false - writeConcern: - command_name: delete - database_name: *database_name - - command_started_event: - command: - commitTransaction: 1 - lsid: session0 - txnNumber: - $numberLong: "1" - startTransaction: - autocommit: false - writeConcern: - w: majority - command_name: commitTransaction - database_name: admin diff --git a/source/transactions/tests/legacy/error-labels-blockConnection.json b/source/transactions/tests/legacy/error-labels-blockConnection.json deleted file mode 100644 index 848f56fa3c..0000000000 --- a/source/transactions/tests/legacy/error-labels-blockConnection.json +++ /dev/null @@ -1,160 +0,0 @@ -{ - "runOn": [ - { - "minServerVersion": "4.2", - "topology": [ - "replicaset", - "sharded", - "load-balanced" - ] - } - ], - "database_name": "transaction-tests", - "collection_name": "test", - "data": [], - "tests": [ - { - "description": "add RetryableWriteError and UnknownTransactionCommitResult labels to connection errors", - "clientOptions": { - "socketTimeoutMS": 100 - }, - "failPoint": { - "configureFailPoint": "failCommand", - "mode": { - "times": 2 - }, - "data": { - "failCommands": [ - "commitTransaction" - ], - "blockConnection": true, - "blockTimeMS": 150 - } - }, - "operations": [ - { - "name": "startTransaction", - "object": "session0" - }, - { - "name": "insertOne", - "object": "collection", - "arguments": { - "session": "session0", - "document": { - "_id": 1 - } - }, - "result": { - "insertedId": 1 - } - }, - { - "name": "commitTransaction", - "object": "session0", - "result": { - "errorLabelsContain": [ - "RetryableWriteError", - "UnknownTransactionCommitResult" - ], - "errorLabelsOmit": [ - "TransientTransactionError" - ] - } - }, - { - "name": "commitTransaction", - "object": "session0" - } - ], - "expectations": [ - { - "command_started_event": { - "command": { - "insert": "test", - "documents": [ - { - "_id": 1 - } - ], - "ordered": true, - "readConcern": null, - "lsid": "session0", - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": true, - "autocommit": false, - "writeConcern": null - }, - "command_name": "insert", - "database_name": "transaction-tests" - } - }, - { - "command_started_event": { - "command": { - "commitTransaction": 1, - "lsid": "session0", - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": null, - "autocommit": false, - "writeConcern": null - }, - "command_name": "commitTransaction", - "database_name": "admin" - } - }, - { - "command_started_event": { - "command": { - "commitTransaction": 1, - "lsid": "session0", - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": null, - "autocommit": false, - "writeConcern": { - "w": "majority", - "wtimeout": 10000 - } - }, - "command_name": "commitTransaction", - "database_name": "admin" - } - }, - { - "command_started_event": { - "command": { - "commitTransaction": 1, - "lsid": "session0", - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": null, - "autocommit": false, - "writeConcern": { - "w": "majority", - "wtimeout": 10000 - } - }, - "command_name": "commitTransaction", - "database_name": "admin" - } - } - ], - "outcome": { - "collection": { - "data": [ - { - "_id": 1 - } - ] - } - } - } - ] -} diff --git a/source/transactions/tests/legacy/error-labels-blockConnection.yml b/source/transactions/tests/legacy/error-labels-blockConnection.yml deleted file mode 100644 index 6b36749e76..0000000000 --- a/source/transactions/tests/legacy/error-labels-blockConnection.yml +++ /dev/null @@ -1,113 +0,0 @@ -# This file contains a single test that should be in error-labels.yml. The test -# was moved from error-labels.yml during the spec work for client-side -# operations timeout because it uses the blockConnection parameter in -# failCommand, which is only available in server versions 4.2+. It should be -# merged back into error-labels.yml when that test file is ported to the -# unified test format as the format allows for per-test runOn requirements. - -runOn: - - - minServerVersion: "4.2" - topology: ["replicaset", "sharded", "load-balanced"] - -database_name: &database_name "transaction-tests" -collection_name: &collection_name "test" - -data: [] - -tests: - - # This test previously used failCommand with closeConnection=true to force a - # network error, but this does not work after CSOT is implemented because - # network errors are retried indefinitely. It has been changed to use - # socketTimeoutMS with blockConnection to force a network error because - # drivers only retry socketTimeoutMS-related errors once rather than - # indefinitely. - - description: add RetryableWriteError and UnknownTransactionCommitResult labels to connection errors - - clientOptions: - socketTimeoutMS: 100 - - failPoint: - # Drivers stop retrying after two socket timeouts that occur due to the use of socketTimeoutMS. - configureFailPoint: failCommand - mode: { times: 2 } - data: - failCommands: ["commitTransaction"] - blockConnection: true - blockTimeMS: 150 - - operations: - - name: startTransaction - object: session0 - - name: insertOne - object: collection - arguments: - session: session0 - document: - _id: 1 - result: - insertedId: 1 - - name: commitTransaction - object: session0 - result: - errorLabelsContain: ["RetryableWriteError", "UnknownTransactionCommitResult"] - errorLabelsOmit: ["TransientTransactionError"] - - name: commitTransaction - object: session0 - - expectations: - - command_started_event: - command: - insert: *collection_name - documents: - - _id: 1 - ordered: true - readConcern: - lsid: session0 - txnNumber: - $numberLong: "1" - startTransaction: true - autocommit: false - writeConcern: - command_name: insert - database_name: *database_name - - command_started_event: - command: - commitTransaction: 1 - lsid: session0 - txnNumber: - $numberLong: "1" - startTransaction: - autocommit: false - writeConcern: - command_name: commitTransaction - database_name: admin - - command_started_event: - command: - commitTransaction: 1 - lsid: session0 - txnNumber: - $numberLong: "1" - startTransaction: - autocommit: false - # commitTransaction applies w:majority on retries - writeConcern: { w: majority, wtimeout: 10000 } - command_name: commitTransaction - database_name: admin - - command_started_event: - command: - commitTransaction: 1 - lsid: session0 - txnNumber: - $numberLong: "1" - startTransaction: - autocommit: false - writeConcern: { w: majority, wtimeout: 10000 } - command_name: commitTransaction - database_name: admin - - outcome: - collection: - data: - - _id: 1 diff --git a/source/transactions/tests/legacy/error-labels-errorLabels.json b/source/transactions/tests/legacy/error-labels-errorLabels.json deleted file mode 100644 index 50d90c36f8..0000000000 --- a/source/transactions/tests/legacy/error-labels-errorLabels.json +++ /dev/null @@ -1,314 +0,0 @@ -{ - "runOn": [ - { - "minServerVersion": "4.3.1", - "topology": [ - "replicaset", - "sharded", - "load-balanced" - ], - "serverless": "forbid" - } - ], - "database_name": "transaction-tests", - "collection_name": "test", - "data": [], - "tests": [ - { - "description": "add RetryableWriteError and UnknownTransactionCommitResult labels to retryable commit errors", - "failPoint": { - "configureFailPoint": "failCommand", - "mode": { - "times": 2 - }, - "data": { - "failCommands": [ - "commitTransaction" - ], - "errorCode": 11602, - "errorLabels": [ - "RetryableWriteError" - ] - } - }, - "operations": [ - { - "name": "startTransaction", - "object": "session0" - }, - { - "name": "insertOne", - "object": "collection", - "arguments": { - "session": "session0", - "document": { - "_id": 1 - } - }, - "result": { - "insertedId": 1 - } - }, - { - "name": "commitTransaction", - "object": "session0", - "result": { - "errorLabelsContain": [ - "RetryableWriteError", - "UnknownTransactionCommitResult" - ], - "errorLabelsOmit": [ - "TransientTransactionError" - ] - } - }, - { - "name": "commitTransaction", - "object": "session0" - } - ], - "expectations": [ - { - "command_started_event": { - "command": { - "insert": "test", - "documents": [ - { - "_id": 1 - } - ], - "ordered": true, - "readConcern": null, - "lsid": "session0", - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": true, - "autocommit": false, - "writeConcern": null - }, - "command_name": "insert", - "database_name": "transaction-tests" - } - }, - { - "command_started_event": { - "command": { - "commitTransaction": 1, - "lsid": "session0", - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": null, - "autocommit": false, - "writeConcern": null - }, - "command_name": "commitTransaction", - "database_name": "admin" - } - }, - { - "command_started_event": { - "command": { - "commitTransaction": 1, - "lsid": "session0", - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": null, - "autocommit": false, - "writeConcern": { - "w": "majority", - "wtimeout": 10000 - } - }, - "command_name": "commitTransaction", - "database_name": "admin" - } - }, - { - "command_started_event": { - "command": { - "commitTransaction": 1, - "lsid": "session0", - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": null, - "autocommit": false, - "writeConcern": { - "w": "majority", - "wtimeout": 10000 - } - }, - "command_name": "commitTransaction", - "database_name": "admin" - } - } - ], - "outcome": { - "collection": { - "data": [ - { - "_id": 1 - } - ] - } - } - }, - { - "description": "add RetryableWriteError and UnknownTransactionCommitResult labels to writeConcernError ShutdownInProgress", - "failPoint": { - "configureFailPoint": "failCommand", - "mode": { - "times": 2 - }, - "data": { - "failCommands": [ - "commitTransaction" - ], - "errorLabels": [ - "RetryableWriteError" - ], - "writeConcernError": { - "code": 91, - "errmsg": "Replication is being shut down" - } - } - }, - "operations": [ - { - "name": "startTransaction", - "object": "session0", - "arguments": { - "options": { - "writeConcern": { - "w": "majority" - } - } - } - }, - { - "name": "insertOne", - "object": "collection", - "arguments": { - "session": "session0", - "document": { - "_id": 1 - } - }, - "result": { - "insertedId": 1 - } - }, - { - "name": "commitTransaction", - "object": "session0", - "result": { - "errorLabelsContain": [ - "RetryableWriteError", - "UnknownTransactionCommitResult" - ], - "errorLabelsOmit": [ - "TransientTransactionError" - ] - } - }, - { - "name": "commitTransaction", - "object": "session0" - } - ], - "expectations": [ - { - "command_started_event": { - "command": { - "insert": "test", - "documents": [ - { - "_id": 1 - } - ], - "ordered": true, - "readConcern": null, - "lsid": "session0", - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": true, - "autocommit": false, - "writeConcern": null - }, - "command_name": "insert", - "database_name": "transaction-tests" - } - }, - { - "command_started_event": { - "command": { - "commitTransaction": 1, - "lsid": "session0", - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": null, - "autocommit": false, - "writeConcern": { - "w": "majority" - } - }, - "command_name": "commitTransaction", - "database_name": "admin" - } - }, - { - "command_started_event": { - "command": { - "commitTransaction": 1, - "lsid": "session0", - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": null, - "autocommit": false, - "writeConcern": { - "w": "majority", - "wtimeout": 10000 - } - }, - "command_name": "commitTransaction", - "database_name": "admin" - } - }, - { - "command_started_event": { - "command": { - "commitTransaction": 1, - "lsid": "session0", - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": null, - "autocommit": false, - "writeConcern": { - "w": "majority", - "wtimeout": 10000 - } - }, - "command_name": "commitTransaction", - "database_name": "admin" - } - } - ], - "outcome": { - "collection": { - "data": [ - { - "_id": 1 - } - ] - } - } - } - ] -} diff --git a/source/transactions/tests/legacy/error-labels-errorLabels.yml b/source/transactions/tests/legacy/error-labels-errorLabels.yml deleted file mode 100644 index adbdccaded..0000000000 --- a/source/transactions/tests/legacy/error-labels-errorLabels.yml +++ /dev/null @@ -1,183 +0,0 @@ -runOn: - - - minServerVersion: "4.3.1" # failCommand errorLabels option - topology: ["replicaset", "sharded", "load-balanced"] - # serverless proxy doesn't append error labels to errors in transactions - # caused by failpoints (CLOUDP-88216) - serverless: "forbid" - -database_name: &database_name "transaction-tests" -collection_name: &collection_name "test" - -data: [] - -tests: - - description: add RetryableWriteError and UnknownTransactionCommitResult labels to retryable commit errors - failPoint: - configureFailPoint: failCommand - mode: { times: 2 } - data: - failCommands: ["commitTransaction"] - errorCode: 11602 # InterruptedDueToReplStateChange - errorLabels: ["RetryableWriteError"] - operations: - - name: startTransaction - object: session0 - - name: insertOne - object: collection - arguments: - session: session0 - document: - _id: 1 - result: - insertedId: 1 - - name: commitTransaction - object: session0 - result: - errorLabelsContain: ["RetryableWriteError", "UnknownTransactionCommitResult"] - errorLabelsOmit: ["TransientTransactionError"] - - name: commitTransaction - object: session0 - expectations: - - command_started_event: - command: - insert: *collection_name - documents: - - _id: 1 - ordered: true - readConcern: - lsid: session0 - txnNumber: - $numberLong: "1" - startTransaction: true - autocommit: false - writeConcern: - command_name: insert - database_name: *database_name - - command_started_event: - command: - commitTransaction: 1 - lsid: session0 - txnNumber: - $numberLong: "1" - startTransaction: - autocommit: false - writeConcern: - command_name: commitTransaction - database_name: admin - - command_started_event: - command: - commitTransaction: 1 - lsid: session0 - txnNumber: - $numberLong: "1" - startTransaction: - autocommit: false - # commitTransaction applies w:majority on retries - writeConcern: { w: majority, wtimeout: 10000 } - command_name: commitTransaction - database_name: admin - - command_started_event: - command: - commitTransaction: 1 - lsid: session0 - txnNumber: - $numberLong: "1" - startTransaction: - autocommit: false - writeConcern: { w: majority, wtimeout: 10000 } - command_name: commitTransaction - database_name: admin - outcome: - collection: - data: - - _id: 1 - - - description: add RetryableWriteError and UnknownTransactionCommitResult labels to writeConcernError ShutdownInProgress - failPoint: - configureFailPoint: failCommand - mode: { times: 2 } - data: - failCommands: ["commitTransaction"] - errorLabels: ["RetryableWriteError"] - writeConcernError: - code: 91 - errmsg: Replication is being shut down - operations: - - name: startTransaction - object: session0 - arguments: - options: - writeConcern: - w: majority - - name: insertOne - object: collection - arguments: - session: session0 - document: - _id: 1 - result: - insertedId: 1 - - name: commitTransaction - object: session0 - result: - errorLabelsContain: ["RetryableWriteError", "UnknownTransactionCommitResult"] - errorLabelsOmit: ["TransientTransactionError"] - - name: commitTransaction - object: session0 - expectations: - - command_started_event: - command: - insert: *collection_name - documents: - - _id: 1 - ordered: true - readConcern: - lsid: session0 - txnNumber: - $numberLong: "1" - startTransaction: true - autocommit: false - writeConcern: - command_name: insert - database_name: *database_name - - command_started_event: - command: - commitTransaction: 1 - lsid: session0 - txnNumber: - $numberLong: "1" - startTransaction: - autocommit: false - writeConcern: - w: majority - command_name: commitTransaction - database_name: admin - - command_started_event: - command: - commitTransaction: 1 - lsid: session0 - txnNumber: - $numberLong: "1" - startTransaction: - autocommit: false - # commitTransaction applies w:majority on retries - writeConcern: { w: majority, wtimeout: 10000 } - command_name: commitTransaction - database_name: admin - - command_started_event: - command: - commitTransaction: 1 - lsid: session0 - txnNumber: - $numberLong: "1" - startTransaction: - autocommit: false - # commitTransaction applies w:majority on retries - writeConcern: { w: majority, wtimeout: 10000 } - command_name: commitTransaction - database_name: admin - outcome: - collection: - data: - - _id: 1 diff --git a/source/transactions/tests/legacy/error-labels.json b/source/transactions/tests/legacy/error-labels.json deleted file mode 100644 index ac1265517f..0000000000 --- a/source/transactions/tests/legacy/error-labels.json +++ /dev/null @@ -1,1791 +0,0 @@ -{ - "runOn": [ - { - "minServerVersion": "4.0", - "topology": [ - "replicaset" - ] - }, - { - "minServerVersion": "4.1.8", - "topology": [ - "sharded", - "load-balanced" - ], - "serverless": "forbid" - } - ], - "database_name": "transaction-tests", - "collection_name": "test", - "data": [], - "tests": [ - { - "description": "DuplicateKey errors do not contain transient label", - "operations": [ - { - "name": "startTransaction", - "object": "session0" - }, - { - "name": "insertMany", - "object": "collection", - "arguments": { - "session": "session0", - "documents": [ - { - "_id": 1 - }, - { - "_id": 1 - } - ] - }, - "result": { - "errorLabelsOmit": [ - "TransientTransactionError", - "UnknownTransactionCommitResult" - ], - "errorContains": "E11000" - } - }, - { - "name": "abortTransaction", - "object": "session0" - } - ], - "expectations": [ - { - "command_started_event": { - "command": { - "insert": "test", - "documents": [ - { - "_id": 1 - }, - { - "_id": 1 - } - ], - "ordered": true, - "readConcern": null, - "lsid": "session0", - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": true, - "autocommit": false, - "writeConcern": null - }, - "command_name": "insert", - "database_name": "transaction-tests" - } - }, - { - "command_started_event": { - "command": { - "abortTransaction": 1, - "lsid": "session0", - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": null, - "autocommit": false, - "writeConcern": null - }, - "command_name": "abortTransaction", - "database_name": "admin" - } - } - ], - "outcome": { - "collection": { - "data": [] - } - } - }, - { - "description": "NotWritablePrimary errors contain transient label", - "failPoint": { - "configureFailPoint": "failCommand", - "mode": { - "times": 1 - }, - "data": { - "failCommands": [ - "insert" - ], - "errorCode": 10107 - } - }, - "operations": [ - { - "name": "startTransaction", - "object": "session0" - }, - { - "name": "insertOne", - "object": "collection", - "arguments": { - "session": "session0", - "document": { - "_id": 1 - } - }, - "result": { - "errorLabelsContain": [ - "TransientTransactionError" - ], - "errorLabelsOmit": [ - "RetryableWriteError", - "UnknownTransactionCommitResult" - ] - } - }, - { - "name": "abortTransaction", - "object": "session0" - } - ], - "expectations": [ - { - "command_started_event": { - "command": { - "insert": "test", - "documents": [ - { - "_id": 1 - } - ], - "ordered": true, - "readConcern": null, - "lsid": "session0", - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": true, - "autocommit": false, - "writeConcern": null - }, - "command_name": "insert", - "database_name": "transaction-tests" - } - }, - { - "command_started_event": { - "command": { - "abortTransaction": 1, - "lsid": "session0", - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": null, - "autocommit": false, - "writeConcern": null - }, - "command_name": "abortTransaction", - "database_name": "admin" - } - } - ], - "outcome": { - "collection": { - "data": [] - } - } - }, - { - "description": "WriteConflict errors contain transient label", - "failPoint": { - "configureFailPoint": "failCommand", - "mode": { - "times": 1 - }, - "data": { - "failCommands": [ - "insert" - ], - "errorCode": 112 - } - }, - "operations": [ - { - "name": "startTransaction", - "object": "session0" - }, - { - "name": "insertOne", - "object": "collection", - "arguments": { - "session": "session0", - "document": { - "_id": 1 - } - }, - "result": { - "errorLabelsContain": [ - "TransientTransactionError" - ], - "errorLabelsOmit": [ - "RetryableWriteError", - "UnknownTransactionCommitResult" - ] - } - }, - { - "name": "abortTransaction", - "object": "session0" - } - ], - "expectations": [ - { - "command_started_event": { - "command": { - "insert": "test", - "documents": [ - { - "_id": 1 - } - ], - "ordered": true, - "readConcern": null, - "lsid": "session0", - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": true, - "autocommit": false, - "writeConcern": null - }, - "command_name": "insert", - "database_name": "transaction-tests" - } - }, - { - "command_started_event": { - "command": { - "abortTransaction": 1, - "lsid": "session0", - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": null, - "autocommit": false, - "writeConcern": null - }, - "command_name": "abortTransaction", - "database_name": "admin" - } - } - ], - "outcome": { - "collection": { - "data": [] - } - } - }, - { - "description": "NoSuchTransaction errors contain transient label", - "failPoint": { - "configureFailPoint": "failCommand", - "mode": { - "times": 1 - }, - "data": { - "failCommands": [ - "insert" - ], - "errorCode": 251 - } - }, - "operations": [ - { - "name": "startTransaction", - "object": "session0" - }, - { - "name": "insertOne", - "object": "collection", - "arguments": { - "session": "session0", - "document": { - "_id": 1 - } - }, - "result": { - "errorLabelsContain": [ - "TransientTransactionError" - ], - "errorLabelsOmit": [ - "RetryableWriteError", - "UnknownTransactionCommitResult" - ] - } - }, - { - "name": "abortTransaction", - "object": "session0" - } - ], - "expectations": [ - { - "command_started_event": { - "command": { - "insert": "test", - "documents": [ - { - "_id": 1 - } - ], - "ordered": true, - "readConcern": null, - "lsid": "session0", - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": true, - "autocommit": false, - "writeConcern": null - }, - "command_name": "insert", - "database_name": "transaction-tests" - } - }, - { - "command_started_event": { - "command": { - "abortTransaction": 1, - "lsid": "session0", - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": null, - "autocommit": false, - "writeConcern": null - }, - "command_name": "abortTransaction", - "database_name": "admin" - } - } - ], - "outcome": { - "collection": { - "data": [] - } - } - }, - { - "description": "NoSuchTransaction errors on commit contain transient label", - "failPoint": { - "configureFailPoint": "failCommand", - "mode": { - "times": 1 - }, - "data": { - "failCommands": [ - "commitTransaction" - ], - "errorCode": 251 - } - }, - "operations": [ - { - "name": "startTransaction", - "object": "session0" - }, - { - "name": "insertOne", - "object": "collection", - "arguments": { - "session": "session0", - "document": { - "_id": 1 - } - }, - "result": { - "insertedId": 1 - } - }, - { - "name": "commitTransaction", - "object": "session0", - "result": { - "errorLabelsContain": [ - "TransientTransactionError" - ], - "errorLabelsOmit": [ - "RetryableWriteError", - "UnknownTransactionCommitResult" - ] - } - } - ], - "expectations": [ - { - "command_started_event": { - "command": { - "insert": "test", - "documents": [ - { - "_id": 1 - } - ], - "ordered": true, - "readConcern": null, - "lsid": "session0", - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": true, - "autocommit": false, - "writeConcern": null - }, - "command_name": "insert", - "database_name": "transaction-tests" - } - }, - { - "command_started_event": { - "command": { - "commitTransaction": 1, - "lsid": "session0", - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": null, - "autocommit": false, - "writeConcern": null - }, - "command_name": "commitTransaction", - "database_name": "admin" - } - } - ], - "outcome": { - "collection": { - "data": [] - } - } - }, - { - "description": "add TransientTransactionError label to connection errors, but do not add RetryableWriteError label", - "failPoint": { - "configureFailPoint": "failCommand", - "mode": { - "times": 4 - }, - "data": { - "failCommands": [ - "insert", - "find", - "aggregate", - "distinct" - ], - "closeConnection": true - } - }, - "operations": [ - { - "name": "startTransaction", - "object": "session0" - }, - { - "name": "insertOne", - "object": "collection", - "arguments": { - "session": "session0", - "document": { - "_id": 1 - } - }, - "result": { - "errorLabelsContain": [ - "TransientTransactionError" - ], - "errorLabelsOmit": [ - "RetryableWriteError", - "UnknownTransactionCommitResult" - ] - } - }, - { - "name": "find", - "object": "collection", - "arguments": { - "session": "session0" - }, - "result": { - "errorLabelsContain": [ - "TransientTransactionError" - ], - "errorLabelsOmit": [ - "RetryableWriteError", - "UnknownTransactionCommitResult" - ] - } - }, - { - "name": "aggregate", - "object": "collection", - "arguments": { - "pipeline": [ - { - "$project": { - "_id": 1 - } - } - ], - "session": "session0" - }, - "result": { - "errorLabelsContain": [ - "TransientTransactionError" - ], - "errorLabelsOmit": [ - "RetryableWriteError", - "UnknownTransactionCommitResult" - ] - } - }, - { - "name": "distinct", - "object": "collection", - "arguments": { - "fieldName": "_id", - "session": "session0" - }, - "result": { - "errorLabelsContain": [ - "TransientTransactionError" - ], - "errorLabelsOmit": [ - "RetryableWriteError", - "UnknownTransactionCommitResult" - ] - } - }, - { - "name": "abortTransaction", - "object": "session0" - } - ], - "expectations": [ - { - "command_started_event": { - "command": { - "insert": "test", - "documents": [ - { - "_id": 1 - } - ], - "ordered": true, - "readConcern": null, - "lsid": "session0", - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": true, - "autocommit": false, - "writeConcern": null - }, - "command_name": "insert", - "database_name": "transaction-tests" - } - }, - { - "command_started_event": { - "command": { - "find": "test", - "readConcern": null, - "lsid": "session0", - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": null, - "autocommit": false - }, - "command_name": "find", - "database_name": "transaction-tests" - } - }, - { - "command_started_event": { - "command": { - "aggregate": "test", - "pipeline": [ - { - "$project": { - "_id": 1 - } - } - ], - "cursor": {}, - "readConcern": null, - "lsid": "session0", - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": null, - "autocommit": false - }, - "command_name": "aggregate", - "database_name": "transaction-tests" - } - }, - { - "command_started_event": { - "command": { - "distinct": "test", - "key": "_id", - "lsid": "session0", - "readConcern": null, - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": null, - "autocommit": false - }, - "command_name": "distinct", - "database_name": "transaction-tests" - } - }, - { - "command_started_event": { - "command": { - "abortTransaction": 1, - "lsid": "session0", - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": null, - "autocommit": false, - "writeConcern": null - }, - "command_name": "abortTransaction", - "database_name": "admin" - } - } - ], - "outcome": { - "collection": { - "data": [] - } - } - }, - { - "description": "add RetryableWriteError and UnknownTransactionCommitResult labels to connection errors", - "failPoint": { - "configureFailPoint": "failCommand", - "mode": { - "times": 2 - }, - "data": { - "failCommands": [ - "commitTransaction" - ], - "closeConnection": true - } - }, - "operations": [ - { - "name": "startTransaction", - "object": "session0" - }, - { - "name": "insertOne", - "object": "collection", - "arguments": { - "session": "session0", - "document": { - "_id": 1 - } - }, - "result": { - "insertedId": 1 - } - }, - { - "name": "commitTransaction", - "object": "session0", - "result": { - "errorLabelsContain": [ - "RetryableWriteError", - "UnknownTransactionCommitResult" - ], - "errorLabelsOmit": [ - "TransientTransactionError" - ] - } - }, - { - "name": "commitTransaction", - "object": "session0" - } - ], - "expectations": [ - { - "command_started_event": { - "command": { - "insert": "test", - "documents": [ - { - "_id": 1 - } - ], - "ordered": true, - "readConcern": null, - "lsid": "session0", - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": true, - "autocommit": false, - "writeConcern": null - }, - "command_name": "insert", - "database_name": "transaction-tests" - } - }, - { - "command_started_event": { - "command": { - "commitTransaction": 1, - "lsid": "session0", - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": null, - "autocommit": false, - "writeConcern": null - }, - "command_name": "commitTransaction", - "database_name": "admin" - } - }, - { - "command_started_event": { - "command": { - "commitTransaction": 1, - "lsid": "session0", - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": null, - "autocommit": false, - "writeConcern": { - "w": "majority", - "wtimeout": 10000 - } - }, - "command_name": "commitTransaction", - "database_name": "admin" - } - }, - { - "command_started_event": { - "command": { - "commitTransaction": 1, - "lsid": "session0", - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": null, - "autocommit": false, - "writeConcern": { - "w": "majority", - "wtimeout": 10000 - } - }, - "command_name": "commitTransaction", - "database_name": "admin" - } - } - ], - "outcome": { - "collection": { - "data": [ - { - "_id": 1 - } - ] - } - } - }, - { - "description": "do not add RetryableWriteError label to writeConcernError ShutdownInProgress that occurs within transaction", - "failPoint": { - "configureFailPoint": "failCommand", - "mode": { - "times": 1 - }, - "data": { - "failCommands": [ - "insert" - ], - "writeConcernError": { - "code": 91, - "errmsg": "Replication is being shut down" - } - } - }, - "operations": [ - { - "name": "startTransaction", - "object": "session0", - "arguments": { - "options": { - "writeConcern": { - "w": "majority" - } - } - } - }, - { - "name": "insertOne", - "object": "collection", - "arguments": { - "session": "session0", - "document": { - "_id": 1 - } - }, - "result": { - "errorLabelsContain": [], - "errorLabelsOmit": [ - "RetryableWriteError", - "TransientTransactionError", - "UnknownTransactionCommitResult" - ] - } - }, - { - "name": "abortTransaction", - "object": "session0" - } - ], - "expectations": [ - { - "command_started_event": { - "command": { - "insert": "test", - "documents": [ - { - "_id": 1 - } - ], - "ordered": true, - "readConcern": null, - "lsid": "session0", - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": true, - "autocommit": false - }, - "command_name": "insert", - "database_name": "transaction-tests" - } - }, - { - "command_started_event": { - "command": { - "abortTransaction": 1, - "lsid": "session0", - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": null, - "autocommit": false - }, - "command_name": "abortTransaction", - "database_name": "admin" - } - } - ], - "outcome": { - "collection": { - "data": [] - } - } - }, - { - "description": "add UnknownTransactionCommitResult label to writeConcernError WriteConcernFailed", - "failPoint": { - "configureFailPoint": "failCommand", - "mode": { - "times": 1 - }, - "data": { - "failCommands": [ - "commitTransaction" - ], - "writeConcernError": { - "code": 64, - "errmsg": "multiple errors reported" - } - } - }, - "operations": [ - { - "name": "startTransaction", - "object": "session0", - "arguments": { - "options": { - "writeConcern": { - "w": "majority" - } - } - } - }, - { - "name": "insertOne", - "object": "collection", - "arguments": { - "session": "session0", - "document": { - "_id": 1 - } - }, - "result": { - "insertedId": 1 - } - }, - { - "name": "commitTransaction", - "object": "session0", - "result": { - "errorLabelsContain": [ - "UnknownTransactionCommitResult" - ], - "errorLabelsOmit": [ - "RetryableWriteError", - "TransientTransactionError" - ] - } - }, - { - "name": "commitTransaction", - "object": "session0" - } - ], - "expectations": [ - { - "command_started_event": { - "command": { - "insert": "test", - "documents": [ - { - "_id": 1 - } - ], - "ordered": true, - "readConcern": null, - "lsid": "session0", - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": true, - "autocommit": false, - "writeConcern": null - }, - "command_name": "insert", - "database_name": "transaction-tests" - } - }, - { - "command_started_event": { - "command": { - "commitTransaction": 1, - "lsid": "session0", - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": null, - "autocommit": false, - "writeConcern": { - "w": "majority" - } - }, - "command_name": "commitTransaction", - "database_name": "admin" - } - }, - { - "command_started_event": { - "command": { - "commitTransaction": 1, - "lsid": "session0", - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": null, - "autocommit": false, - "writeConcern": { - "w": "majority", - "wtimeout": 10000 - } - }, - "command_name": "commitTransaction", - "database_name": "admin" - } - } - ], - "outcome": { - "collection": { - "data": [ - { - "_id": 1 - } - ] - } - } - }, - { - "description": "add UnknownTransactionCommitResult label to writeConcernError WriteConcernFailed with wtimeout", - "failPoint": { - "configureFailPoint": "failCommand", - "mode": { - "times": 1 - }, - "data": { - "failCommands": [ - "commitTransaction" - ], - "writeConcernError": { - "code": 64, - "codeName": "WriteConcernFailed", - "errmsg": "waiting for replication timed out", - "errInfo": { - "wtimeout": true - } - } - } - }, - "operations": [ - { - "name": "startTransaction", - "object": "session0", - "arguments": { - "options": { - "writeConcern": { - "w": "majority" - } - } - } - }, - { - "name": "insertOne", - "object": "collection", - "arguments": { - "session": "session0", - "document": { - "_id": 1 - } - }, - "result": { - "insertedId": 1 - } - }, - { - "name": "commitTransaction", - "object": "session0", - "result": { - "errorLabelsContain": [ - "UnknownTransactionCommitResult" - ], - "errorLabelsOmit": [ - "RetryableWriteError", - "TransientTransactionError" - ] - } - }, - { - "name": "commitTransaction", - "object": "session0" - } - ], - "expectations": [ - { - "command_started_event": { - "command": { - "insert": "test", - "documents": [ - { - "_id": 1 - } - ], - "ordered": true, - "readConcern": null, - "lsid": "session0", - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": true, - "autocommit": false, - "writeConcern": null - }, - "command_name": "insert", - "database_name": "transaction-tests" - } - }, - { - "command_started_event": { - "command": { - "commitTransaction": 1, - "lsid": "session0", - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": null, - "autocommit": false, - "writeConcern": { - "w": "majority" - } - }, - "command_name": "commitTransaction", - "database_name": "admin" - } - }, - { - "command_started_event": { - "command": { - "commitTransaction": 1, - "lsid": "session0", - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": null, - "autocommit": false, - "writeConcern": { - "w": "majority", - "wtimeout": 10000 - } - }, - "command_name": "commitTransaction", - "database_name": "admin" - } - } - ], - "outcome": { - "collection": { - "data": [ - { - "_id": 1 - } - ] - } - } - }, - { - "description": "omit UnknownTransactionCommitResult label from writeConcernError UnsatisfiableWriteConcern", - "failPoint": { - "configureFailPoint": "failCommand", - "mode": { - "times": 1 - }, - "data": { - "failCommands": [ - "commitTransaction" - ], - "writeConcernError": { - "code": 100, - "errmsg": "Not enough data-bearing nodes" - } - } - }, - "operations": [ - { - "name": "startTransaction", - "object": "session0", - "arguments": { - "options": { - "writeConcern": { - "w": "majority" - } - } - } - }, - { - "name": "insertOne", - "object": "collection", - "arguments": { - "session": "session0", - "document": { - "_id": 1 - } - }, - "result": { - "insertedId": 1 - } - }, - { - "name": "commitTransaction", - "object": "session0", - "result": { - "errorLabelsOmit": [ - "RetryableWriteError", - "TransientTransactionError", - "UnknownTransactionCommitResult" - ] - } - } - ], - "expectations": [ - { - "command_started_event": { - "command": { - "insert": "test", - "documents": [ - { - "_id": 1 - } - ], - "ordered": true, - "readConcern": null, - "lsid": "session0", - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": true, - "autocommit": false, - "writeConcern": null - }, - "command_name": "insert", - "database_name": "transaction-tests" - } - }, - { - "command_started_event": { - "command": { - "commitTransaction": 1, - "lsid": "session0", - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": null, - "autocommit": false, - "writeConcern": { - "w": "majority" - } - }, - "command_name": "commitTransaction", - "database_name": "admin" - } - } - ], - "outcome": { - "collection": { - "data": [ - { - "_id": 1 - } - ] - } - } - }, - { - "description": "omit UnknownTransactionCommitResult label from writeConcernError UnknownReplWriteConcern", - "failPoint": { - "configureFailPoint": "failCommand", - "mode": { - "times": 1 - }, - "data": { - "failCommands": [ - "commitTransaction" - ], - "writeConcernError": { - "code": 79, - "errmsg": "No write concern mode named 'blah' found in replica set configuration" - } - } - }, - "operations": [ - { - "name": "startTransaction", - "object": "session0", - "arguments": { - "options": { - "writeConcern": { - "w": "majority" - } - } - } - }, - { - "name": "insertOne", - "object": "collection", - "arguments": { - "session": "session0", - "document": { - "_id": 1 - } - }, - "result": { - "insertedId": 1 - } - }, - { - "name": "commitTransaction", - "object": "session0", - "result": { - "errorLabelsOmit": [ - "RetryableWriteConcern", - "TransientTransactionError", - "UnknownTransactionCommitResult" - ] - } - } - ], - "expectations": [ - { - "command_started_event": { - "command": { - "insert": "test", - "documents": [ - { - "_id": 1 - } - ], - "ordered": true, - "readConcern": null, - "lsid": "session0", - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": true, - "autocommit": false, - "writeConcern": null - }, - "command_name": "insert", - "database_name": "transaction-tests" - } - }, - { - "command_started_event": { - "command": { - "commitTransaction": 1, - "lsid": "session0", - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": null, - "autocommit": false, - "writeConcern": { - "w": "majority" - } - }, - "command_name": "commitTransaction", - "database_name": "admin" - } - } - ], - "outcome": { - "collection": { - "data": [ - { - "_id": 1 - } - ] - } - } - }, - { - "description": "do not add UnknownTransactionCommitResult label to MaxTimeMSExpired inside transactions", - "failPoint": { - "configureFailPoint": "failCommand", - "mode": { - "times": 1 - }, - "data": { - "failCommands": [ - "aggregate" - ], - "errorCode": 50 - } - }, - "operations": [ - { - "name": "startTransaction", - "object": "session0" - }, - { - "name": "insertOne", - "object": "collection", - "arguments": { - "session": "session0", - "document": { - "_id": 1 - } - }, - "result": { - "insertedId": 1 - } - }, - { - "name": "aggregate", - "object": "collection", - "arguments": { - "pipeline": [ - { - "$project": { - "_id": 1 - } - } - ], - "maxTimeMS": 60000, - "session": "session0" - }, - "result": { - "errorLabelsOmit": [ - "RetryableWriteError", - "UnknownTransactionCommitResult", - "TransientTransactionError" - ] - } - }, - { - "name": "abortTransaction", - "object": "session0" - } - ], - "expectations": [ - { - "command_started_event": { - "command": { - "insert": "test", - "documents": [ - { - "_id": 1 - } - ], - "ordered": true, - "readConcern": null, - "lsid": "session0", - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": true, - "autocommit": false, - "writeConcern": null - }, - "command_name": "insert", - "database_name": "transaction-tests" - } - }, - { - "command_started_event": { - "command": { - "aggregate": "test", - "pipeline": [ - { - "$project": { - "_id": 1 - } - } - ], - "cursor": {}, - "readConcern": null, - "lsid": "session0", - "txnNumber": { - "$numberLong": "1" - }, - "autocommit": false, - "maxTimeMS": 60000 - }, - "command_name": "aggregate", - "database_name": "transaction-tests" - } - }, - { - "command_started_event": { - "command": { - "abortTransaction": 1, - "lsid": "session0", - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": null, - "autocommit": false, - "writeConcern": null - }, - "command_name": "abortTransaction", - "database_name": "admin" - } - } - ], - "outcome": { - "collection": { - "data": [] - } - } - }, - { - "description": "add UnknownTransactionCommitResult label to MaxTimeMSExpired", - "failPoint": { - "configureFailPoint": "failCommand", - "mode": { - "times": 1 - }, - "data": { - "failCommands": [ - "commitTransaction" - ], - "errorCode": 50 - } - }, - "operations": [ - { - "name": "startTransaction", - "object": "session0", - "arguments": { - "options": { - "writeConcern": { - "w": "majority" - }, - "maxCommitTimeMS": 60000 - } - } - }, - { - "name": "insertOne", - "object": "collection", - "arguments": { - "session": "session0", - "document": { - "_id": 1 - } - }, - "result": { - "insertedId": 1 - } - }, - { - "name": "commitTransaction", - "object": "session0", - "result": { - "errorLabelsContain": [ - "UnknownTransactionCommitResult" - ], - "errorLabelsOmit": [ - "RetryableWriteError", - "TransientTransactionError" - ] - } - }, - { - "name": "commitTransaction", - "object": "session0" - } - ], - "expectations": [ - { - "command_started_event": { - "command": { - "insert": "test", - "documents": [ - { - "_id": 1 - } - ], - "ordered": true, - "readConcern": null, - "lsid": "session0", - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": true, - "autocommit": false, - "writeConcern": null - }, - "command_name": "insert", - "database_name": "transaction-tests" - } - }, - { - "command_started_event": { - "command": { - "commitTransaction": 1, - "lsid": "session0", - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": null, - "autocommit": false, - "writeConcern": { - "w": "majority" - }, - "maxTimeMS": 60000 - }, - "command_name": "commitTransaction", - "database_name": "admin" - } - }, - { - "command_started_event": { - "command": { - "commitTransaction": 1, - "lsid": "session0", - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": null, - "autocommit": false, - "writeConcern": { - "w": "majority", - "wtimeout": 10000 - }, - "maxTimeMS": 60000 - }, - "command_name": "commitTransaction", - "database_name": "admin" - } - } - ], - "outcome": { - "collection": { - "data": [ - { - "_id": 1 - } - ] - } - } - }, - { - "description": "add UnknownTransactionCommitResult label to writeConcernError MaxTimeMSExpired", - "failPoint": { - "configureFailPoint": "failCommand", - "mode": { - "times": 1 - }, - "data": { - "failCommands": [ - "commitTransaction" - ], - "writeConcernError": { - "code": 50, - "errmsg": "operation exceeded time limit" - } - } - }, - "operations": [ - { - "name": "startTransaction", - "object": "session0", - "arguments": { - "options": { - "writeConcern": { - "w": "majority" - }, - "maxCommitTimeMS": 60000 - } - } - }, - { - "name": "insertOne", - "object": "collection", - "arguments": { - "session": "session0", - "document": { - "_id": 1 - } - }, - "result": { - "insertedId": 1 - } - }, - { - "name": "commitTransaction", - "object": "session0", - "result": { - "errorLabelsContain": [ - "UnknownTransactionCommitResult" - ], - "errorLabelsOmit": [ - "RetryableWriteError", - "TransientTransactionError" - ] - } - }, - { - "name": "commitTransaction", - "object": "session0" - } - ], - "expectations": [ - { - "command_started_event": { - "command": { - "insert": "test", - "documents": [ - { - "_id": 1 - } - ], - "ordered": true, - "readConcern": null, - "lsid": "session0", - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": true, - "autocommit": false, - "writeConcern": null - }, - "command_name": "insert", - "database_name": "transaction-tests" - } - }, - { - "command_started_event": { - "command": { - "commitTransaction": 1, - "lsid": "session0", - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": null, - "autocommit": false, - "writeConcern": { - "w": "majority" - }, - "maxTimeMS": 60000 - }, - "command_name": "commitTransaction", - "database_name": "admin" - } - }, - { - "command_started_event": { - "command": { - "commitTransaction": 1, - "lsid": "session0", - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": null, - "autocommit": false, - "writeConcern": { - "w": "majority", - "wtimeout": 10000 - }, - "maxTimeMS": 60000 - }, - "command_name": "commitTransaction", - "database_name": "admin" - } - } - ], - "outcome": { - "collection": { - "data": [ - { - "_id": 1 - } - ] - } - } - } - ] -} diff --git a/source/transactions/tests/legacy/error-labels.yml b/source/transactions/tests/legacy/error-labels.yml deleted file mode 100644 index 12219d085b..0000000000 --- a/source/transactions/tests/legacy/error-labels.yml +++ /dev/null @@ -1,1095 +0,0 @@ -runOn: - - - minServerVersion: "4.0" - topology: ["replicaset"] - - - minServerVersion: "4.1.8" - topology: ["sharded", "load-balanced"] - # serverless proxy doesn't append error labels to errors in transactions - # caused by failpoints (CLOUDP-88216) - serverless: "forbid" - -database_name: &database_name "transaction-tests" -collection_name: &collection_name "test" - -data: [] - -tests: - - description: DuplicateKey errors do not contain transient label - - operations: - - name: startTransaction - object: session0 - - name: insertMany - object: collection - arguments: - session: session0 - documents: - - _id: 1 - - _id: 1 - result: - errorLabelsOmit: ["TransientTransactionError", "UnknownTransactionCommitResult"] - # DuplicateKey error code included in the bulk write error message - # returned by the server - errorContains: E11000 - - name: abortTransaction - object: session0 - - expectations: - - command_started_event: - command: - insert: *collection_name - documents: - - _id: 1 - - _id: 1 - ordered: true - readConcern: - lsid: session0 - txnNumber: - $numberLong: "1" - startTransaction: true - autocommit: false - writeConcern: - command_name: insert - database_name: *database_name - - command_started_event: - command: - abortTransaction: 1 - lsid: session0 - txnNumber: - $numberLong: "1" - startTransaction: - autocommit: false - writeConcern: - command_name: abortTransaction - database_name: admin - - outcome: - collection: - data: [] - - - description: NotWritablePrimary errors contain transient label - - failPoint: - configureFailPoint: failCommand - mode: { times: 1 } - data: - failCommands: ["insert"] - errorCode: 10107 # NotWritablePrimary - - operations: - - name: startTransaction - object: session0 - - name: insertOne - object: collection - arguments: - session: session0 - document: - _id: 1 - result: - # Note, the server will return the errorLabel in this case. - errorLabelsContain: ["TransientTransactionError"] - errorLabelsOmit: ["RetryableWriteError", "UnknownTransactionCommitResult"] - - name: abortTransaction - object: session0 - - expectations: - - command_started_event: - command: - insert: *collection_name - documents: - - _id: 1 - ordered: true - readConcern: - lsid: session0 - txnNumber: - $numberLong: "1" - startTransaction: true - autocommit: false - writeConcern: - command_name: insert - database_name: *database_name - - command_started_event: - command: - abortTransaction: 1 - lsid: session0 - txnNumber: - $numberLong: "1" - startTransaction: - autocommit: false - writeConcern: - command_name: abortTransaction - database_name: admin - - outcome: - collection: - data: [] - - - description: WriteConflict errors contain transient label - - failPoint: - configureFailPoint: failCommand - mode: { times: 1 } - data: - failCommands: ["insert"] - errorCode: 112 # WriteConflict - - operations: - - name: startTransaction - object: session0 - - name: insertOne - object: collection - arguments: - session: session0 - document: - _id: 1 - result: - # Note, the server will return the errorLabel in this case. - errorLabelsContain: ["TransientTransactionError"] - errorLabelsOmit: ["RetryableWriteError", "UnknownTransactionCommitResult"] - - name: abortTransaction - object: session0 - - expectations: - - command_started_event: - command: - insert: *collection_name - documents: - - _id: 1 - ordered: true - readConcern: - lsid: session0 - txnNumber: - $numberLong: "1" - startTransaction: true - autocommit: false - writeConcern: - command_name: insert - database_name: *database_name - - command_started_event: - command: - abortTransaction: 1 - lsid: session0 - txnNumber: - $numberLong: "1" - startTransaction: - autocommit: false - writeConcern: - command_name: abortTransaction - database_name: admin - - outcome: - collection: - data: [] - - - description: NoSuchTransaction errors contain transient label - - failPoint: - configureFailPoint: failCommand - mode: { times: 1 } - data: - failCommands: ["insert"] - errorCode: 251 # NoSuchTransaction - - operations: - - name: startTransaction - object: session0 - - name: insertOne - object: collection - arguments: - session: session0 - document: - _id: 1 - result: - # Note, the server will return the errorLabel in this case. - errorLabelsContain: ["TransientTransactionError"] - errorLabelsOmit: ["RetryableWriteError", "UnknownTransactionCommitResult"] - - name: abortTransaction - object: session0 - - expectations: - - command_started_event: - command: - insert: *collection_name - documents: - - _id: 1 - ordered: true - readConcern: - lsid: session0 - txnNumber: - $numberLong: "1" - startTransaction: true - autocommit: false - writeConcern: - command_name: insert - database_name: *database_name - - command_started_event: - command: - abortTransaction: 1 - lsid: session0 - txnNumber: - $numberLong: "1" - startTransaction: - autocommit: false - writeConcern: - command_name: abortTransaction - database_name: admin - - outcome: - collection: - data: [] - - - description: NoSuchTransaction errors on commit contain transient label - - failPoint: - configureFailPoint: failCommand - mode: { times: 1 } - data: - failCommands: ["commitTransaction"] - errorCode: 251 # NoSuchTransaction - - operations: - - name: startTransaction - object: session0 - - name: insertOne - object: collection - arguments: - session: session0 - document: - _id: 1 - result: - insertedId: 1 - - name: commitTransaction - object: session0 - result: - # Note, the server will return the errorLabel in this case. - errorLabelsContain: ["TransientTransactionError"] - errorLabelsOmit: ["RetryableWriteError", "UnknownTransactionCommitResult"] - - expectations: - - command_started_event: - command: - insert: *collection_name - documents: - - _id: 1 - ordered: true - readConcern: - lsid: session0 - txnNumber: - $numberLong: "1" - startTransaction: true - autocommit: false - writeConcern: - command_name: insert - database_name: *database_name - - command_started_event: - command: - commitTransaction: 1 - lsid: session0 - txnNumber: - $numberLong: "1" - startTransaction: - autocommit: false - writeConcern: - command_name: commitTransaction - database_name: admin - - outcome: - collection: - data: [] - - - description: add TransientTransactionError label to connection errors, but do not add RetryableWriteError label - - failPoint: - configureFailPoint: failCommand - mode: { times: 4 } - data: - failCommands: ["insert", "find", "aggregate", "distinct"] - closeConnection: true - - operations: - - name: startTransaction - object: session0 - - name: insertOne - object: collection - arguments: - session: session0 - document: - _id: 1 - result: &transient_label_only - errorLabelsContain: ["TransientTransactionError"] - # While a connection error would normally be retryable, these are not because - # they occur within a transaction; ensure the driver does not add the - # RetryableWriteError label to these errors. - errorLabelsOmit: ["RetryableWriteError", "UnknownTransactionCommitResult"] - - name: find - object: collection - arguments: - session: session0 - result: *transient_label_only - - name: aggregate - object: collection - arguments: - pipeline: - - $project: - _id: 1 - session: session0 - result: *transient_label_only - - name: distinct - object: collection - arguments: - fieldName: _id - session: session0 - result: *transient_label_only - - name: abortTransaction - object: session0 - - expectations: - - command_started_event: - command: - insert: *collection_name - documents: - - _id: 1 - ordered: true - readConcern: - lsid: session0 - txnNumber: - $numberLong: "1" - startTransaction: true - autocommit: false - writeConcern: - command_name: insert - database_name: *database_name - - command_started_event: - command: - find: *collection_name - readConcern: - lsid: session0 - txnNumber: - $numberLong: "1" - startTransaction: - autocommit: false - command_name: find - database_name: *database_name - - command_started_event: - command: - aggregate: *collection_name - pipeline: - - $project: - _id: 1 - cursor: {} - readConcern: - lsid: session0 - txnNumber: - $numberLong: "1" - startTransaction: - autocommit: false - command_name: aggregate - database_name: *database_name - - command_started_event: - command: - distinct: *collection_name - key: _id - lsid: session0 - readConcern: - txnNumber: - $numberLong: "1" - startTransaction: - autocommit: false - command_name: distinct - database_name: *database_name - - command_started_event: - command: - abortTransaction: 1 - lsid: session0 - txnNumber: - $numberLong: "1" - startTransaction: - autocommit: false - writeConcern: - command_name: abortTransaction - database_name: admin - - outcome: - collection: - data: [] - - - description: add RetryableWriteError and UnknownTransactionCommitResult labels to connection errors - - failPoint: - configureFailPoint: failCommand - mode: { times: 2 } - data: - failCommands: ["commitTransaction"] - closeConnection: true - - operations: - - name: startTransaction - object: session0 - - name: insertOne - object: collection - arguments: - session: session0 - document: - _id: 1 - result: - insertedId: 1 - - name: commitTransaction - object: session0 - result: - errorLabelsContain: ["RetryableWriteError", "UnknownTransactionCommitResult"] - errorLabelsOmit: ["TransientTransactionError"] - - name: commitTransaction - object: session0 - - expectations: - - command_started_event: - command: - insert: *collection_name - documents: - - _id: 1 - ordered: true - readConcern: - lsid: session0 - txnNumber: - $numberLong: "1" - startTransaction: true - autocommit: false - writeConcern: - command_name: insert - database_name: *database_name - - command_started_event: - command: - commitTransaction: 1 - lsid: session0 - txnNumber: - $numberLong: "1" - startTransaction: - autocommit: false - writeConcern: - command_name: commitTransaction - database_name: admin - - command_started_event: - command: - commitTransaction: 1 - lsid: session0 - txnNumber: - $numberLong: "1" - startTransaction: - autocommit: false - # commitTransaction applies w:majority on retries - writeConcern: { w: majority, wtimeout: 10000 } - command_name: commitTransaction - database_name: admin - - command_started_event: - command: - commitTransaction: 1 - lsid: session0 - txnNumber: - $numberLong: "1" - startTransaction: - autocommit: false - writeConcern: { w: majority, wtimeout: 10000 } - command_name: commitTransaction - database_name: admin - - outcome: - collection: - data: - - _id: 1 - - - description: do not add RetryableWriteError label to writeConcernError ShutdownInProgress that occurs within transaction - - failPoint: - configureFailPoint: failCommand - mode: { times: 1 } - data: - failCommands: ["insert"] - writeConcernError: - code: 91 - errmsg: Replication is being shut down - - operations: - - name: startTransaction - object: session0 - arguments: - options: - writeConcern: - w: majority - - name: insertOne - object: collection - arguments: - session: session0 - document: - _id: 1 - result: - errorLabelsContain: [] - errorLabelsOmit: ["RetryableWriteError", "TransientTransactionError", "UnknownTransactionCommitResult"] - - name: abortTransaction - object: session0 - - expectations: - - command_started_event: - command: - insert: *collection_name - documents: - - _id: 1 - ordered: true - readConcern: - lsid: session0 - txnNumber: - $numberLong: "1" - startTransaction: true - autocommit: false - command_name: insert - database_name: *database_name - - command_started_event: - command: - abortTransaction: 1 - lsid: session0 - txnNumber: - $numberLong: "1" - startTransaction: - autocommit: false - command_name: abortTransaction - database_name: admin - - outcome: - collection: - data: [] - - - description: add UnknownTransactionCommitResult label to writeConcernError WriteConcernFailed - - failPoint: - configureFailPoint: failCommand - mode: { times: 1 } - data: - failCommands: ["commitTransaction"] - writeConcernError: - code: 64 # WriteConcernFailed without wtimeout - errmsg: multiple errors reported - - operations: - - name: startTransaction - object: session0 - arguments: - options: - writeConcern: - w: majority - - name: insertOne - object: collection - arguments: - session: session0 - document: - _id: 1 - result: - insertedId: 1 - - name: commitTransaction - object: session0 - result: - errorLabelsContain: ["UnknownTransactionCommitResult"] - errorLabelsOmit: ["RetryableWriteError", "TransientTransactionError"] - - name: commitTransaction - object: session0 - - expectations: - - command_started_event: - command: - insert: *collection_name - documents: - - _id: 1 - ordered: true - readConcern: - lsid: session0 - txnNumber: - $numberLong: "1" - startTransaction: true - autocommit: false - writeConcern: - command_name: insert - database_name: *database_name - - command_started_event: - command: - commitTransaction: 1 - lsid: session0 - txnNumber: - $numberLong: "1" - startTransaction: - autocommit: false - writeConcern: - w: majority - command_name: commitTransaction - database_name: admin - - command_started_event: - command: - commitTransaction: 1 - lsid: session0 - txnNumber: - $numberLong: "1" - startTransaction: - autocommit: false - # commitTransaction applies w:majority on retries - writeConcern: { w: majority, wtimeout: 10000 } - command_name: commitTransaction - database_name: admin - - outcome: - collection: - data: - - _id: 1 - - - description: add UnknownTransactionCommitResult label to writeConcernError WriteConcernFailed with wtimeout - - failPoint: - configureFailPoint: failCommand - mode: { times: 1 } - data: - failCommands: ["commitTransaction"] - writeConcernError: - code: 64 - codeName: WriteConcernFailed - errmsg: waiting for replication timed out - errInfo: {wtimeout: True} - - operations: - - name: startTransaction - object: session0 - arguments: - options: - writeConcern: - w: majority - - name: insertOne - object: collection - arguments: - session: session0 - document: - _id: 1 - result: - insertedId: 1 - - name: commitTransaction - object: session0 - result: - errorLabelsContain: ["UnknownTransactionCommitResult"] - errorLabelsOmit: ["RetryableWriteError", "TransientTransactionError"] - - name: commitTransaction - object: session0 - - expectations: - - command_started_event: - command: - insert: *collection_name - documents: - - _id: 1 - ordered: true - readConcern: - lsid: session0 - txnNumber: - $numberLong: "1" - startTransaction: true - autocommit: false - writeConcern: - command_name: insert - database_name: *database_name - - command_started_event: - command: - commitTransaction: 1 - lsid: session0 - txnNumber: - $numberLong: "1" - startTransaction: - autocommit: false - writeConcern: - w: majority - command_name: commitTransaction - database_name: admin - - command_started_event: - command: - commitTransaction: 1 - lsid: session0 - txnNumber: - $numberLong: "1" - startTransaction: - autocommit: false - # commitTransaction applies w:majority on retries - writeConcern: { w: majority, wtimeout: 10000 } - command_name: commitTransaction - database_name: admin - - outcome: - collection: - data: - - _id: 1 - - - description: omit UnknownTransactionCommitResult label from writeConcernError UnsatisfiableWriteConcern - - failPoint: - configureFailPoint: failCommand - mode: { times: 1 } - data: - failCommands: ["commitTransaction"] - writeConcernError: - code: 100 # UnsatisfiableWriteConcern - errmsg: Not enough data-bearing nodes - - operations: - - name: startTransaction - object: session0 - arguments: - options: - writeConcern: - w: majority - - name: insertOne - object: collection - arguments: - session: session0 - document: - _id: 1 - result: - insertedId: 1 - - name: commitTransaction - object: session0 - result: - errorLabelsOmit: ["RetryableWriteError", "TransientTransactionError", "UnknownTransactionCommitResult"] - - expectations: - - command_started_event: - command: - insert: *collection_name - documents: - - _id: 1 - ordered: true - readConcern: - lsid: session0 - txnNumber: - $numberLong: "1" - startTransaction: true - autocommit: false - writeConcern: - command_name: insert - database_name: *database_name - - command_started_event: - command: - commitTransaction: 1 - lsid: session0 - txnNumber: - $numberLong: "1" - startTransaction: - autocommit: false - writeConcern: - w: majority - command_name: commitTransaction - database_name: admin - - outcome: - collection: - data: - - _id: 1 - - - description: omit UnknownTransactionCommitResult label from writeConcernError UnknownReplWriteConcern - - failPoint: - configureFailPoint: failCommand - mode: { times: 1 } - data: - failCommands: ["commitTransaction"] - writeConcernError: - code: 79 # UnknownReplWriteConcern - errmsg: No write concern mode named 'blah' found in replica set configuration - - operations: - - name: startTransaction - object: session0 - arguments: - options: - writeConcern: - w: majority - - name: insertOne - object: collection - arguments: - session: session0 - document: - _id: 1 - result: - insertedId: 1 - - name: commitTransaction - object: session0 - result: - errorLabelsOmit: ["RetryableWriteConcern", "TransientTransactionError", "UnknownTransactionCommitResult"] - - expectations: - - command_started_event: - command: - insert: *collection_name - documents: - - _id: 1 - ordered: true - readConcern: - lsid: session0 - txnNumber: - $numberLong: "1" - startTransaction: true - autocommit: false - writeConcern: - command_name: insert - database_name: *database_name - - command_started_event: - command: - commitTransaction: 1 - lsid: session0 - txnNumber: - $numberLong: "1" - startTransaction: - autocommit: false - writeConcern: - w: majority - command_name: commitTransaction - database_name: admin - - outcome: - collection: - data: - - _id: 1 - - - description: do not add UnknownTransactionCommitResult label to MaxTimeMSExpired inside transactions - - failPoint: - configureFailPoint: failCommand - mode: { times: 1 } - data: - failCommands: ["aggregate"] - errorCode: 50 # MaxTimeMSExpired - - operations: - - name: startTransaction - object: session0 - - name: insertOne - object: collection - arguments: - session: session0 - document: - _id: 1 - result: - insertedId: 1 - - name: aggregate - object: collection - arguments: - pipeline: - - $project: - _id: 1 - maxTimeMS: 60000 - session: session0 - result: - errorLabelsOmit: ["RetryableWriteError", "UnknownTransactionCommitResult", "TransientTransactionError"] - - name: abortTransaction - object: session0 - - expectations: - - command_started_event: - command: - insert: *collection_name - documents: - - _id: 1 - ordered: true - readConcern: - lsid: session0 - txnNumber: - $numberLong: "1" - startTransaction: true - autocommit: false - writeConcern: - command_name: insert - database_name: *database_name - - command_started_event: - command: - aggregate: *collection_name - pipeline: - - $project: - _id: 1 - cursor: {} - readConcern: - lsid: session0 - txnNumber: - $numberLong: "1" - autocommit: false - maxTimeMS: 60000 - command_name: aggregate - database_name: *database_name - - command_started_event: - command: - abortTransaction: 1 - lsid: session0 - txnNumber: - $numberLong: "1" - startTransaction: - autocommit: false - writeConcern: - command_name: abortTransaction - database_name: admin - - outcome: - collection: - data: [] - - - description: add UnknownTransactionCommitResult label to MaxTimeMSExpired - - failPoint: - configureFailPoint: failCommand - mode: { times: 1 } - data: - failCommands: ["commitTransaction"] - errorCode: 50 # MaxTimeMSExpired - - operations: - - name: startTransaction - object: session0 - arguments: - options: - writeConcern: - w: majority - maxCommitTimeMS: 60000 - - name: insertOne - object: collection - arguments: - session: session0 - document: - _id: 1 - result: - insertedId: 1 - - name: commitTransaction - object: session0 - result: - errorLabelsContain: ["UnknownTransactionCommitResult"] - errorLabelsOmit: ["RetryableWriteError", "TransientTransactionError"] - - name: commitTransaction - object: session0 - - expectations: - - command_started_event: - command: - insert: *collection_name - documents: - - _id: 1 - ordered: true - readConcern: - lsid: session0 - txnNumber: - $numberLong: "1" - startTransaction: true - autocommit: false - writeConcern: - command_name: insert - database_name: *database_name - - command_started_event: - command: - commitTransaction: 1 - lsid: session0 - txnNumber: - $numberLong: "1" - startTransaction: - autocommit: false - writeConcern: - w: majority - maxTimeMS: 60000 - command_name: commitTransaction - database_name: admin - - command_started_event: - command: - commitTransaction: 1 - lsid: session0 - txnNumber: - $numberLong: "1" - startTransaction: - autocommit: false - # commitTransaction applies w:majority on retries - writeConcern: { w: majority, wtimeout: 10000 } - maxTimeMS: 60000 - command_name: commitTransaction - database_name: admin - - outcome: - collection: - data: - - _id: 1 - - - description: add UnknownTransactionCommitResult label to writeConcernError MaxTimeMSExpired - - failPoint: - configureFailPoint: failCommand - mode: { times: 1 } - data: - failCommands: ["commitTransaction"] - writeConcernError: - code: 50 # MaxTimeMSExpired - errmsg: operation exceeded time limit - - operations: - - name: startTransaction - object: session0 - arguments: - options: - writeConcern: - w: majority - maxCommitTimeMS: 60000 - - name: insertOne - object: collection - arguments: - session: session0 - document: - _id: 1 - result: - insertedId: 1 - - name: commitTransaction - object: session0 - result: - errorLabelsContain: ["UnknownTransactionCommitResult"] - errorLabelsOmit: ["RetryableWriteError", "TransientTransactionError"] - - name: commitTransaction - object: session0 - - expectations: - - command_started_event: - command: - insert: *collection_name - documents: - - _id: 1 - ordered: true - readConcern: - lsid: session0 - txnNumber: - $numberLong: "1" - startTransaction: true - autocommit: false - writeConcern: - command_name: insert - database_name: *database_name - - command_started_event: - command: - commitTransaction: 1 - lsid: session0 - txnNumber: - $numberLong: "1" - startTransaction: - autocommit: false - writeConcern: - w: majority - maxTimeMS: 60000 - command_name: commitTransaction - database_name: admin - - command_started_event: - command: - commitTransaction: 1 - lsid: session0 - txnNumber: - $numberLong: "1" - startTransaction: - autocommit: false - # commitTransaction applies w:majority on retries - writeConcern: { w: majority, wtimeout: 10000 } - maxTimeMS: 60000 - command_name: commitTransaction - database_name: admin - - outcome: - collection: - data: - - _id: 1 diff --git a/source/transactions/tests/legacy/errors-client.yml b/source/transactions/tests/legacy/errors-client.yml deleted file mode 100644 index 40a0234d41..0000000000 --- a/source/transactions/tests/legacy/errors-client.yml +++ /dev/null @@ -1,55 +0,0 @@ -runOn: - - - minServerVersion: "4.0" - topology: ["replicaset"] - - - minServerVersion: "4.1.8" - topology: ["sharded", "load-balanced"] - -database_name: &database_name "transaction-tests" -collection_name: &collection_name "test" - -data: [] -tests: - - description: Client side error in command starting transaction - - operations: - - name: startTransaction - object: session0 - - name: updateOne - object: collection - arguments: - session: session0 - filter: { _id: 1 } - update: { x: 1 } - error: true - - name: assertSessionTransactionState - object: testRunner - arguments: - session: session0 - state: starting - - - description: Client side error when transaction is in progress - - operations: - - name: startTransaction - object: session0 - - name: insertOne - object: collection - arguments: - session: session0 - document: { _id: 1 } - result: - insertedId: 1 - - name: updateOne - object: collection - arguments: - session: session0 - filter: { _id: 1 } - update: { x: 1 } - error: true - - name: assertSessionTransactionState - object: testRunner - arguments: - session: session0 - state: in_progress diff --git a/source/transactions/tests/legacy/errors.yml b/source/transactions/tests/legacy/errors.yml deleted file mode 100644 index f061886c19..0000000000 --- a/source/transactions/tests/legacy/errors.yml +++ /dev/null @@ -1,133 +0,0 @@ -runOn: - - - minServerVersion: "4.0" - topology: ["replicaset"] - - - minServerVersion: "4.1.8" - topology: ["sharded", "load-balanced"] - -database_name: &database_name "transaction-tests" -collection_name: &collection_name "test" - -data: [] -tests: - - description: start insert start - - operations: - - name: startTransaction - object: session0 - - name: insertOne - object: collection - arguments: - session: session0 - document: - _id: 1 - result: - insertedId: 1 - - name: startTransaction - object: session0 - result: - # Client-side error. - errorContains: transaction already in progress - # Just to clean up. - - name: commitTransaction - object: session0 - - - description: start twice - - operations: - - name: startTransaction - object: session0 - - name: startTransaction - object: session0 - result: - # Client-side error. - errorContains: transaction already in progress - - - description: commit and start twice - - operations: - - name: startTransaction - object: session0 - - name: insertOne - object: collection - arguments: - session: session0 - document: - _id: 1 - result: - insertedId: 1 - - name: commitTransaction - object: session0 - - name: startTransaction - object: session0 - - name: startTransaction - object: session0 - result: - # Client-side error. - errorContains: transaction already in progress - - - description: write conflict commit - - operations: - - name: startTransaction - object: session0 - - name: insertOne - object: collection - arguments: - session: session0 - document: - _id: 1 - result: - insertedId: 1 - - name: startTransaction - object: session1 - - name: insertOne - object: collection - arguments: - session: session1 - document: - _id: 1 - result: - errorCodeName: WriteConflict - errorLabelsContain: ["TransientTransactionError"] - errorLabelsOmit: ["UnknownTransactionCommitResult"] - - name: commitTransaction - object: session0 - - name: commitTransaction - object: session1 - result: - errorCodeName: NoSuchTransaction - errorLabelsContain: ["TransientTransactionError"] - errorLabelsOmit: ["UnknownTransactionCommitResult"] - - - description: write conflict abort - - operations: - - name: startTransaction - object: session0 - - name: insertOne - object: collection - arguments: - session: session0 - document: - _id: 1 - result: - insertedId: 1 - - name: startTransaction - object: session1 - - name: insertOne - object: collection - arguments: - session: session1 - document: - _id: 1 - result: - errorCodeName: WriteConflict - errorLabelsContain: ["TransientTransactionError"] - errorLabelsOmit: ["UnknownTransactionCommitResult"] - - name: commitTransaction - object: session0 - # Driver ignores "NoSuchTransaction" error. - - name: abortTransaction - object: session1 diff --git a/source/transactions/tests/legacy/findOneAndDelete.json b/source/transactions/tests/legacy/findOneAndDelete.json deleted file mode 100644 index e7aab710d6..0000000000 --- a/source/transactions/tests/legacy/findOneAndDelete.json +++ /dev/null @@ -1,222 +0,0 @@ -{ - "runOn": [ - { - "minServerVersion": "4.0", - "topology": [ - "replicaset" - ] - }, - { - "minServerVersion": "4.1.8", - "topology": [ - "sharded", - "load-balanced" - ] - } - ], - "database_name": "transaction-tests", - "collection_name": "test", - "data": [ - { - "_id": 1 - }, - { - "_id": 2 - }, - { - "_id": 3 - } - ], - "tests": [ - { - "description": "findOneAndDelete", - "operations": [ - { - "name": "startTransaction", - "object": "session0" - }, - { - "name": "findOneAndDelete", - "object": "collection", - "arguments": { - "session": "session0", - "filter": { - "_id": 3 - } - }, - "result": { - "_id": 3 - } - }, - { - "name": "findOneAndDelete", - "object": "collection", - "arguments": { - "session": "session0", - "filter": { - "_id": 4 - } - }, - "result": null - }, - { - "name": "commitTransaction", - "object": "session0" - } - ], - "expectations": [ - { - "command_started_event": { - "command": { - "findAndModify": "test", - "query": { - "_id": 3 - }, - "remove": true, - "lsid": "session0", - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": true, - "autocommit": false, - "readConcern": null, - "writeConcern": null - }, - "command_name": "findAndModify", - "database_name": "transaction-tests" - } - }, - { - "command_started_event": { - "command": { - "findAndModify": "test", - "query": { - "_id": 4 - }, - "remove": true, - "lsid": "session0", - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": null, - "autocommit": false, - "readConcern": null, - "writeConcern": null - }, - "command_name": "findAndModify", - "database_name": "transaction-tests" - } - }, - { - "command_started_event": { - "command": { - "commitTransaction": 1, - "lsid": "session0", - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": null, - "autocommit": false, - "readConcern": null, - "writeConcern": null - }, - "command_name": "commitTransaction", - "database_name": "admin" - } - } - ], - "outcome": { - "collection": { - "data": [ - { - "_id": 1 - }, - { - "_id": 2 - } - ] - } - } - }, - { - "description": "collection writeConcern ignored for findOneAndDelete", - "operations": [ - { - "name": "startTransaction", - "object": "session0", - "arguments": { - "options": { - "writeConcern": { - "w": "majority" - } - } - } - }, - { - "name": "findOneAndDelete", - "object": "collection", - "collectionOptions": { - "writeConcern": { - "w": "majority" - } - }, - "arguments": { - "session": "session0", - "filter": { - "_id": 3 - } - }, - "result": { - "_id": 3 - } - }, - { - "name": "commitTransaction", - "object": "session0" - } - ], - "expectations": [ - { - "command_started_event": { - "command": { - "findAndModify": "test", - "query": { - "_id": 3 - }, - "remove": true, - "lsid": "session0", - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": true, - "autocommit": false, - "readConcern": null, - "writeConcern": null - }, - "command_name": "findAndModify", - "database_name": "transaction-tests" - } - }, - { - "command_started_event": { - "command": { - "commitTransaction": 1, - "lsid": "session0", - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": null, - "autocommit": false, - "readConcern": null, - "writeConcern": { - "w": "majority" - } - }, - "command_name": "commitTransaction", - "database_name": "admin" - } - } - ] - } - ] -} diff --git a/source/transactions/tests/legacy/findOneAndDelete.yml b/source/transactions/tests/legacy/findOneAndDelete.yml deleted file mode 100644 index 144e51e993..0000000000 --- a/source/transactions/tests/legacy/findOneAndDelete.yml +++ /dev/null @@ -1,134 +0,0 @@ -runOn: - - - minServerVersion: "4.0" - topology: ["replicaset"] - - - minServerVersion: "4.1.8" - topology: ["sharded", "load-balanced"] - -database_name: &database_name "transaction-tests" -collection_name: &collection_name "test" - -data: - - _id: 1 - - _id: 2 - - _id: 3 - -tests: - - description: findOneAndDelete - - operations: - - name: startTransaction - object: session0 - - name: findOneAndDelete - object: collection - arguments: - session: session0 - filter: {_id: 3} - result: {_id: 3} - - name: findOneAndDelete - object: collection - arguments: - session: session0 - filter: {_id: 4} - result: - - name: commitTransaction - object: session0 - - expectations: - - command_started_event: - command: - findAndModify: *collection_name - query: {_id: 3} - remove: True - lsid: session0 - txnNumber: - $numberLong: "1" - startTransaction: true - autocommit: false - readConcern: - writeConcern: - command_name: findAndModify - database_name: *database_name - - command_started_event: - command: - findAndModify: *collection_name - query: {_id: 4} - remove: True - lsid: session0 - txnNumber: - $numberLong: "1" - startTransaction: - autocommit: false - readConcern: - writeConcern: - command_name: findAndModify - database_name: *database_name - - command_started_event: - command: - commitTransaction: 1 - lsid: session0 - txnNumber: - $numberLong: "1" - startTransaction: - autocommit: false - readConcern: - writeConcern: - command_name: commitTransaction - database_name: admin - - outcome: - collection: - data: - - {_id: 1} - - {_id: 2} - - - description: collection writeConcern ignored for findOneAndDelete - - operations: - - name: startTransaction - object: session0 - arguments: - options: - writeConcern: - w: majority - - name: findOneAndDelete - object: collection - collectionOptions: - writeConcern: - w: majority - arguments: - session: session0 - filter: {_id: 3} - result: {_id: 3} - - name: commitTransaction - object: session0 - - expectations: - - command_started_event: - command: - findAndModify: *collection_name - query: {_id: 3} - remove: True - lsid: session0 - txnNumber: - $numberLong: "1" - startTransaction: true - autocommit: false - readConcern: - writeConcern: - command_name: findAndModify - database_name: *database_name - - command_started_event: - command: - commitTransaction: 1 - lsid: session0 - txnNumber: - $numberLong: "1" - startTransaction: - autocommit: false - readConcern: - writeConcern: - w: majority - command_name: commitTransaction - database_name: admin diff --git a/source/transactions/tests/legacy/findOneAndReplace.json b/source/transactions/tests/legacy/findOneAndReplace.json deleted file mode 100644 index 595b5c58b3..0000000000 --- a/source/transactions/tests/legacy/findOneAndReplace.json +++ /dev/null @@ -1,256 +0,0 @@ -{ - "runOn": [ - { - "minServerVersion": "4.0", - "topology": [ - "replicaset" - ] - }, - { - "minServerVersion": "4.1.8", - "topology": [ - "sharded", - "load-balanced" - ] - } - ], - "database_name": "transaction-tests", - "collection_name": "test", - "data": [ - { - "_id": 1 - }, - { - "_id": 2 - }, - { - "_id": 3 - } - ], - "tests": [ - { - "description": "findOneAndReplace", - "operations": [ - { - "name": "startTransaction", - "object": "session0" - }, - { - "name": "findOneAndReplace", - "object": "collection", - "arguments": { - "session": "session0", - "filter": { - "_id": 3 - }, - "replacement": { - "x": 1 - }, - "returnDocument": "Before" - }, - "result": { - "_id": 3 - } - }, - { - "name": "findOneAndReplace", - "object": "collection", - "arguments": { - "session": "session0", - "filter": { - "_id": 4 - }, - "replacement": { - "x": 1 - }, - "upsert": true, - "returnDocument": "After" - }, - "result": { - "_id": 4, - "x": 1 - } - }, - { - "name": "commitTransaction", - "object": "session0" - } - ], - "expectations": [ - { - "command_started_event": { - "command": { - "findAndModify": "test", - "query": { - "_id": 3 - }, - "update": { - "x": 1 - }, - "new": false, - "lsid": "session0", - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": true, - "autocommit": false, - "readConcern": null, - "writeConcern": null - }, - "command_name": "findAndModify", - "database_name": "transaction-tests" - } - }, - { - "command_started_event": { - "command": { - "findAndModify": "test", - "query": { - "_id": 4 - }, - "update": { - "x": 1 - }, - "new": true, - "upsert": true, - "lsid": "session0", - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": null, - "autocommit": false, - "readConcern": null, - "writeConcern": null - }, - "command_name": "findAndModify", - "database_name": "transaction-tests" - } - }, - { - "command_started_event": { - "command": { - "commitTransaction": 1, - "lsid": "session0", - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": null, - "autocommit": false, - "readConcern": null, - "writeConcern": null - }, - "command_name": "commitTransaction", - "database_name": "admin" - } - } - ], - "outcome": { - "collection": { - "data": [ - { - "_id": 1 - }, - { - "_id": 2 - }, - { - "_id": 3, - "x": 1 - }, - { - "_id": 4, - "x": 1 - } - ] - } - } - }, - { - "description": "collection writeConcern ignored for findOneAndReplace", - "operations": [ - { - "name": "startTransaction", - "object": "session0", - "arguments": { - "options": { - "writeConcern": { - "w": "majority" - } - } - } - }, - { - "name": "findOneAndReplace", - "object": "collection", - "collectionOptions": { - "writeConcern": { - "w": "majority" - } - }, - "arguments": { - "session": "session0", - "filter": { - "_id": 3 - }, - "replacement": { - "x": 1 - }, - "returnDocument": "Before" - }, - "result": { - "_id": 3 - } - }, - { - "name": "commitTransaction", - "object": "session0" - } - ], - "expectations": [ - { - "command_started_event": { - "command": { - "findAndModify": "test", - "query": { - "_id": 3 - }, - "update": { - "x": 1 - }, - "new": false, - "lsid": "session0", - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": true, - "autocommit": false, - "readConcern": null, - "writeConcern": null - }, - "command_name": "findAndModify", - "database_name": "transaction-tests" - } - }, - { - "command_started_event": { - "command": { - "commitTransaction": 1, - "lsid": "session0", - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": null, - "autocommit": false, - "readConcern": null, - "writeConcern": { - "w": "majority" - } - }, - "command_name": "commitTransaction", - "database_name": "admin" - } - } - ] - } - ] -} diff --git a/source/transactions/tests/legacy/findOneAndReplace.yml b/source/transactions/tests/legacy/findOneAndReplace.yml deleted file mode 100644 index a997105727..0000000000 --- a/source/transactions/tests/legacy/findOneAndReplace.yml +++ /dev/null @@ -1,148 +0,0 @@ -runOn: - - - minServerVersion: "4.0" - topology: ["replicaset"] - - - minServerVersion: "4.1.8" - topology: ["sharded", "load-balanced"] - -database_name: &database_name "transaction-tests" -collection_name: &collection_name "test" - -data: - - _id: 1 - - _id: 2 - - _id: 3 - -tests: - - description: findOneAndReplace - - operations: - - name: startTransaction - object: session0 - - name: findOneAndReplace - object: collection - arguments: - session: session0 - filter: {_id: 3} - replacement: {x: 1} - returnDocument: Before - result: {_id: 3} - - name: findOneAndReplace - object: collection - arguments: - session: session0 - filter: {_id: 4} - replacement: {x: 1} - upsert: true - returnDocument: After - result: {_id: 4, x: 1} - - name: commitTransaction - object: session0 - - expectations: - - command_started_event: - command: - findAndModify: *collection_name - query: {_id: 3} - update: {x: 1} - new: false - lsid: session0 - txnNumber: - $numberLong: "1" - startTransaction: true - autocommit: false - readConcern: - writeConcern: - command_name: findAndModify - database_name: *database_name - - command_started_event: - command: - findAndModify: *collection_name - query: {_id: 4} - update: {x: 1} - new: true - upsert: true - lsid: session0 - txnNumber: - $numberLong: "1" - startTransaction: - autocommit: false - readConcern: - writeConcern: - command_name: findAndModify - database_name: *database_name - - command_started_event: - command: - commitTransaction: 1 - lsid: session0 - txnNumber: - $numberLong: "1" - startTransaction: - autocommit: false - readConcern: - writeConcern: - command_name: commitTransaction - database_name: admin - - outcome: - collection: - data: - - {_id: 1} - - {_id: 2} - - {_id: 3, x: 1} - - {_id: 4, x: 1} - - - description: collection writeConcern ignored for findOneAndReplace - - operations: - - name: startTransaction - object: session0 - arguments: - options: - writeConcern: - w: majority - - name: findOneAndReplace - object: collection - collectionOptions: - writeConcern: - w: majority - arguments: - session: session0 - filter: {_id: 3} - replacement: {x: 1} - returnDocument: Before - result: {_id: 3} - - name: commitTransaction - object: session0 - - expectations: - - command_started_event: - command: - findAndModify: *collection_name - query: {_id: 3} - update: {x: 1} - new: false - lsid: session0 - txnNumber: - $numberLong: "1" - startTransaction: true - autocommit: false - readConcern: - writeConcern: - command_name: findAndModify - database_name: *database_name - - command_started_event: - command: - commitTransaction: 1 - lsid: session0 - txnNumber: - $numberLong: "1" - startTransaction: - autocommit: false - readConcern: - writeConcern: - w: majority - command_name: commitTransaction - database_name: admin - diff --git a/source/transactions/tests/legacy/findOneAndUpdate.json b/source/transactions/tests/legacy/findOneAndUpdate.json deleted file mode 100644 index 8044f04766..0000000000 --- a/source/transactions/tests/legacy/findOneAndUpdate.json +++ /dev/null @@ -1,414 +0,0 @@ -{ - "runOn": [ - { - "minServerVersion": "4.0", - "topology": [ - "replicaset" - ] - }, - { - "minServerVersion": "4.1.8", - "topology": [ - "sharded", - "load-balanced" - ] - } - ], - "database_name": "transaction-tests", - "collection_name": "test", - "data": [ - { - "_id": 1 - }, - { - "_id": 2 - }, - { - "_id": 3 - } - ], - "tests": [ - { - "description": "findOneAndUpdate", - "operations": [ - { - "name": "startTransaction", - "object": "session0" - }, - { - "name": "findOneAndUpdate", - "object": "collection", - "arguments": { - "session": "session0", - "filter": { - "_id": 3 - }, - "update": { - "$inc": { - "x": 1 - } - }, - "returnDocument": "Before" - }, - "result": { - "_id": 3 - } - }, - { - "name": "findOneAndUpdate", - "object": "collection", - "arguments": { - "session": "session0", - "filter": { - "_id": 4 - }, - "update": { - "$inc": { - "x": 1 - } - }, - "upsert": true, - "returnDocument": "After" - }, - "result": { - "_id": 4, - "x": 1 - } - }, - { - "name": "commitTransaction", - "object": "session0" - }, - { - "name": "startTransaction", - "object": "session0" - }, - { - "name": "findOneAndUpdate", - "object": "collection", - "arguments": { - "session": "session0", - "filter": { - "_id": 3 - }, - "update": { - "$inc": { - "x": 1 - } - }, - "returnDocument": "Before" - }, - "result": { - "_id": 3, - "x": 1 - } - }, - { - "name": "commitTransaction", - "object": "session0" - }, - { - "name": "startTransaction", - "object": "session0" - }, - { - "name": "findOneAndUpdate", - "object": "collection", - "arguments": { - "session": "session0", - "filter": { - "_id": 3 - }, - "update": { - "$inc": { - "x": 1 - } - }, - "returnDocument": "Before" - }, - "result": { - "_id": 3, - "x": 2 - } - }, - { - "name": "abortTransaction", - "object": "session0" - } - ], - "expectations": [ - { - "command_started_event": { - "command": { - "findAndModify": "test", - "query": { - "_id": 3 - }, - "update": { - "$inc": { - "x": 1 - } - }, - "new": false, - "lsid": "session0", - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": true, - "autocommit": false, - "readConcern": null, - "writeConcern": null - }, - "command_name": "findAndModify", - "database_name": "transaction-tests" - } - }, - { - "command_started_event": { - "command": { - "findAndModify": "test", - "query": { - "_id": 4 - }, - "update": { - "$inc": { - "x": 1 - } - }, - "new": true, - "upsert": true, - "lsid": "session0", - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": null, - "autocommit": false, - "readConcern": null, - "writeConcern": null - }, - "command_name": "findAndModify", - "database_name": "transaction-tests" - } - }, - { - "command_started_event": { - "command": { - "commitTransaction": 1, - "lsid": "session0", - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": null, - "autocommit": false, - "readConcern": null, - "writeConcern": null - }, - "command_name": "commitTransaction", - "database_name": "admin" - } - }, - { - "command_started_event": { - "command": { - "findAndModify": "test", - "query": { - "_id": 3 - }, - "update": { - "$inc": { - "x": 1 - } - }, - "new": false, - "lsid": "session0", - "txnNumber": { - "$numberLong": "2" - }, - "startTransaction": true, - "autocommit": false, - "readConcern": { - "afterClusterTime": 42 - }, - "writeConcern": null - }, - "command_name": "findAndModify", - "database_name": "transaction-tests" - } - }, - { - "command_started_event": { - "command": { - "commitTransaction": 1, - "lsid": "session0", - "txnNumber": { - "$numberLong": "2" - }, - "startTransaction": null, - "autocommit": false, - "readConcern": null, - "writeConcern": null - }, - "command_name": "commitTransaction", - "database_name": "admin" - } - }, - { - "command_started_event": { - "command": { - "findAndModify": "test", - "query": { - "_id": 3 - }, - "update": { - "$inc": { - "x": 1 - } - }, - "new": false, - "lsid": "session0", - "txnNumber": { - "$numberLong": "3" - }, - "startTransaction": true, - "autocommit": false, - "readConcern": { - "afterClusterTime": 42 - }, - "writeConcern": null - }, - "command_name": "findAndModify", - "database_name": "transaction-tests" - } - }, - { - "command_started_event": { - "command": { - "abortTransaction": 1, - "lsid": "session0", - "txnNumber": { - "$numberLong": "3" - }, - "startTransaction": null, - "autocommit": false, - "readConcern": null, - "writeConcern": null - }, - "command_name": "abortTransaction", - "database_name": "admin" - } - } - ], - "outcome": { - "collection": { - "data": [ - { - "_id": 1 - }, - { - "_id": 2 - }, - { - "_id": 3, - "x": 2 - }, - { - "_id": 4, - "x": 1 - } - ] - } - } - }, - { - "description": "collection writeConcern ignored for findOneAndUpdate", - "operations": [ - { - "name": "startTransaction", - "object": "session0", - "arguments": { - "options": { - "writeConcern": { - "w": "majority" - } - } - } - }, - { - "name": "findOneAndUpdate", - "object": "collection", - "collectionOptions": { - "writeConcern": { - "w": "majority" - } - }, - "arguments": { - "session": "session0", - "filter": { - "_id": 3 - }, - "update": { - "$inc": { - "x": 1 - } - }, - "returnDocument": "Before" - }, - "result": { - "_id": 3 - } - }, - { - "name": "commitTransaction", - "object": "session0" - } - ], - "expectations": [ - { - "command_started_event": { - "command": { - "findAndModify": "test", - "query": { - "_id": 3 - }, - "update": { - "$inc": { - "x": 1 - } - }, - "new": false, - "lsid": "session0", - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": true, - "autocommit": false, - "readConcern": null, - "writeConcern": null - }, - "command_name": "findAndModify", - "database_name": "transaction-tests" - } - }, - { - "command_started_event": { - "command": { - "commitTransaction": 1, - "lsid": "session0", - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": null, - "autocommit": false, - "readConcern": null, - "writeConcern": { - "w": "majority" - } - }, - "command_name": "commitTransaction", - "database_name": "admin" - } - } - ] - } - ] -} diff --git a/source/transactions/tests/legacy/findOneAndUpdate.yml b/source/transactions/tests/legacy/findOneAndUpdate.yml deleted file mode 100644 index d6efaa34d2..0000000000 --- a/source/transactions/tests/legacy/findOneAndUpdate.yml +++ /dev/null @@ -1,236 +0,0 @@ -runOn: - - - minServerVersion: "4.0" - topology: ["replicaset"] - - - minServerVersion: "4.1.8" - topology: ["sharded", "load-balanced"] - -database_name: &database_name "transaction-tests" -collection_name: &collection_name "test" - -data: - - _id: 1 - - _id: 2 - - _id: 3 - -tests: - - description: findOneAndUpdate - - operations: - - name: startTransaction - object: session0 - - name: findOneAndUpdate - object: collection - arguments: - session: session0 - filter: {_id: 3} - update: - $inc: {x: 1} - returnDocument: Before - result: {_id: 3} - - name: findOneAndUpdate - object: collection - arguments: - session: session0 - filter: {_id: 4} - update: - $inc: {x: 1} - upsert: true - returnDocument: After - result: {_id: 4, x: 1} - - name: commitTransaction - object: session0 - - name: startTransaction - object: session0 - # Test a second time to ensure txnNumber is incremented. - - name: findOneAndUpdate - object: collection - arguments: - session: session0 - filter: {_id: 3} - update: - $inc: {x: 1} - returnDocument: Before - result: {_id: 3, x: 1} - - name: commitTransaction - object: session0 - # Test a third time to ensure abort works. - - name: startTransaction - object: session0 - - name: findOneAndUpdate - object: collection - arguments: - session: session0 - filter: {_id: 3} - update: - $inc: {x: 1} - returnDocument: Before - result: {_id: 3, x: 2} - - name: abortTransaction - object: session0 - - expectations: - - command_started_event: - command: - findAndModify: *collection_name - query: {_id: 3} - update: {$inc: {x: 1}} - new: false - lsid: session0 - txnNumber: - $numberLong: "1" - startTransaction: true - autocommit: false - readConcern: - writeConcern: - command_name: findAndModify - database_name: *database_name - - command_started_event: - command: - findAndModify: *collection_name - query: {_id: 4} - update: {$inc: {x: 1}} - new: true - upsert: true - lsid: session0 - txnNumber: - $numberLong: "1" - startTransaction: - autocommit: false - readConcern: - writeConcern: - command_name: findAndModify - database_name: *database_name - - command_started_event: - command: - commitTransaction: 1 - lsid: session0 - txnNumber: - $numberLong: "1" - startTransaction: - autocommit: false - readConcern: - writeConcern: - command_name: commitTransaction - database_name: admin - - command_started_event: - command: - findAndModify: *collection_name - query: {_id: 3} - update: {$inc: {x: 1}} - new: false - lsid: session0 - txnNumber: - $numberLong: "2" - startTransaction: true - autocommit: false - readConcern: - afterClusterTime: 42 - writeConcern: - command_name: findAndModify - database_name: *database_name - - command_started_event: - command: - commitTransaction: 1 - lsid: session0 - txnNumber: - $numberLong: "2" - startTransaction: - autocommit: false - readConcern: - writeConcern: - command_name: commitTransaction - database_name: admin - - command_started_event: - command: - findAndModify: *collection_name - query: {_id: 3} - update: {$inc: {x: 1}} - new: false - lsid: session0 - txnNumber: - $numberLong: "3" - startTransaction: true - autocommit: false - readConcern: - afterClusterTime: 42 - writeConcern: - command_name: findAndModify - database_name: *database_name - - command_started_event: - command: - abortTransaction: 1 - lsid: session0 - txnNumber: - $numberLong: "3" - startTransaction: - autocommit: false - readConcern: - writeConcern: - command_name: abortTransaction - database_name: admin - - outcome: - collection: - data: - - {_id: 1} - - {_id: 2} - - {_id: 3, x: 2} - - {_id: 4, x: 1} - - - description: collection writeConcern ignored for findOneAndUpdate - - operations: - - name: startTransaction - object: session0 - arguments: - options: - writeConcern: - w: majority - - name: findOneAndUpdate - object: collection - collectionOptions: - writeConcern: - w: majority - arguments: - session: session0 - filter: {_id: 3} - update: - $inc: {x: 1} - returnDocument: Before - result: {_id: 3} - - name: commitTransaction - object: session0 - - expectations: - - command_started_event: - command: - findAndModify: *collection_name - query: {_id: 3} - update: - $inc: {x: 1} - new: false - lsid: session0 - txnNumber: - $numberLong: "1" - startTransaction: true - autocommit: false - readConcern: - writeConcern: - command_name: findAndModify - database_name: *database_name - - command_started_event: - command: - commitTransaction: 1 - lsid: session0 - txnNumber: - $numberLong: "1" - startTransaction: - autocommit: false - readConcern: - writeConcern: - w: majority - command_name: commitTransaction - database_name: admin - diff --git a/source/transactions/tests/legacy/insert.json b/source/transactions/tests/legacy/insert.json deleted file mode 100644 index 2f29d4fa31..0000000000 --- a/source/transactions/tests/legacy/insert.json +++ /dev/null @@ -1,649 +0,0 @@ -{ - "runOn": [ - { - "minServerVersion": "4.0", - "topology": [ - "replicaset" - ] - }, - { - "minServerVersion": "4.1.8", - "topology": [ - "sharded", - "load-balanced" - ] - } - ], - "database_name": "transaction-tests", - "collection_name": "test", - "data": [], - "tests": [ - { - "description": "insert", - "operations": [ - { - "name": "startTransaction", - "object": "session0" - }, - { - "name": "insertOne", - "object": "collection", - "arguments": { - "session": "session0", - "document": { - "_id": 1 - } - }, - "result": { - "insertedId": 1 - } - }, - { - "name": "insertMany", - "object": "collection", - "arguments": { - "documents": [ - { - "_id": 2 - }, - { - "_id": 3 - } - ], - "session": "session0" - }, - "result": { - "insertedIds": { - "0": 2, - "1": 3 - } - } - }, - { - "name": "insertOne", - "object": "collection", - "arguments": { - "session": "session0", - "document": { - "_id": 4 - } - }, - "result": { - "insertedId": 4 - } - }, - { - "name": "commitTransaction", - "object": "session0" - }, - { - "name": "startTransaction", - "object": "session0" - }, - { - "name": "insertOne", - "object": "collection", - "arguments": { - "session": "session0", - "document": { - "_id": 5 - } - }, - "result": { - "insertedId": 5 - } - }, - { - "name": "commitTransaction", - "object": "session0" - } - ], - "expectations": [ - { - "command_started_event": { - "command": { - "insert": "test", - "documents": [ - { - "_id": 1 - } - ], - "ordered": true, - "readConcern": null, - "lsid": "session0", - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": true, - "autocommit": false, - "writeConcern": null - }, - "command_name": "insert", - "database_name": "transaction-tests" - } - }, - { - "command_started_event": { - "command": { - "insert": "test", - "documents": [ - { - "_id": 2 - }, - { - "_id": 3 - } - ], - "ordered": true, - "lsid": "session0", - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": null, - "autocommit": false, - "writeConcern": null - }, - "command_name": "insert", - "database_name": "transaction-tests" - } - }, - { - "command_started_event": { - "command": { - "insert": "test", - "documents": [ - { - "_id": 4 - } - ], - "ordered": true, - "lsid": "session0", - "txnNumber": { - "$numberLong": "1" - }, - "autocommit": false, - "writeConcern": null - }, - "command_name": "insert", - "database_name": "transaction-tests" - } - }, - { - "command_started_event": { - "command": { - "commitTransaction": 1, - "lsid": "session0", - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": null, - "autocommit": false, - "writeConcern": null - }, - "command_name": "commitTransaction", - "database_name": "admin" - } - }, - { - "command_started_event": { - "command": { - "insert": "test", - "documents": [ - { - "_id": 5 - } - ], - "ordered": true, - "readConcern": { - "afterClusterTime": 42 - }, - "lsid": "session0", - "txnNumber": { - "$numberLong": "2" - }, - "startTransaction": true, - "autocommit": false, - "writeConcern": null - }, - "command_name": "insert", - "database_name": "transaction-tests" - } - }, - { - "command_started_event": { - "command": { - "commitTransaction": 1, - "lsid": "session0", - "txnNumber": { - "$numberLong": "2" - }, - "startTransaction": null, - "autocommit": false, - "writeConcern": null - }, - "command_name": "commitTransaction", - "database_name": "admin" - } - } - ], - "outcome": { - "collection": { - "data": [ - { - "_id": 1 - }, - { - "_id": 2 - }, - { - "_id": 3 - }, - { - "_id": 4 - }, - { - "_id": 5 - } - ] - } - } - }, - { - "description": "insert with session1", - "operations": [ - { - "name": "startTransaction", - "object": "session1" - }, - { - "name": "insertOne", - "object": "collection", - "arguments": { - "session": "session1", - "document": { - "_id": 1 - } - }, - "result": { - "insertedId": 1 - } - }, - { - "name": "insertMany", - "object": "collection", - "arguments": { - "documents": [ - { - "_id": 2 - }, - { - "_id": 3 - } - ], - "session": "session1" - }, - "result": { - "insertedIds": { - "0": 2, - "1": 3 - } - } - }, - { - "name": "commitTransaction", - "object": "session1" - }, - { - "name": "startTransaction", - "object": "session1" - }, - { - "name": "insertOne", - "object": "collection", - "arguments": { - "session": "session1", - "document": { - "_id": 4 - } - }, - "result": { - "insertedId": 4 - } - }, - { - "name": "abortTransaction", - "object": "session1" - } - ], - "expectations": [ - { - "command_started_event": { - "command": { - "insert": "test", - "documents": [ - { - "_id": 1 - } - ], - "ordered": true, - "readConcern": null, - "lsid": "session1", - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": true, - "autocommit": false, - "writeConcern": null - }, - "command_name": "insert", - "database_name": "transaction-tests" - } - }, - { - "command_started_event": { - "command": { - "insert": "test", - "documents": [ - { - "_id": 2 - }, - { - "_id": 3 - } - ], - "ordered": true, - "lsid": "session1", - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": null, - "autocommit": false, - "writeConcern": null - }, - "command_name": "insert", - "database_name": "transaction-tests" - } - }, - { - "command_started_event": { - "command": { - "commitTransaction": 1, - "lsid": "session1", - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": null, - "autocommit": false, - "writeConcern": null - }, - "command_name": "commitTransaction", - "database_name": "admin" - } - }, - { - "command_started_event": { - "command": { - "insert": "test", - "documents": [ - { - "_id": 4 - } - ], - "ordered": true, - "readConcern": { - "afterClusterTime": 42 - }, - "lsid": "session1", - "txnNumber": { - "$numberLong": "2" - }, - "startTransaction": true, - "autocommit": false, - "writeConcern": null - }, - "command_name": "insert", - "database_name": "transaction-tests" - } - }, - { - "command_started_event": { - "command": { - "abortTransaction": 1, - "lsid": "session1", - "txnNumber": { - "$numberLong": "2" - }, - "startTransaction": null, - "autocommit": false, - "writeConcern": null - }, - "command_name": "abortTransaction", - "database_name": "admin" - } - } - ], - "outcome": { - "collection": { - "data": [ - { - "_id": 1 - }, - { - "_id": 2 - }, - { - "_id": 3 - } - ] - } - } - }, - { - "description": "collection writeConcern without transaction", - "clientOptions": { - "retryWrites": false - }, - "operations": [ - { - "name": "insertOne", - "object": "collection", - "collectionOptions": { - "writeConcern": { - "w": "majority" - } - }, - "arguments": { - "session": "session0", - "document": { - "_id": 1 - } - }, - "result": { - "insertedId": 1 - } - } - ], - "expectations": [ - { - "command_started_event": { - "command": { - "insert": "test", - "documents": [ - { - "_id": 1 - } - ], - "ordered": true, - "readConcern": null, - "lsid": "session0", - "txnNumber": null, - "startTransaction": null, - "autocommit": null, - "writeConcern": { - "w": "majority" - } - }, - "command_name": "insert", - "database_name": "transaction-tests" - } - } - ], - "outcome": { - "collection": { - "data": [ - { - "_id": 1 - } - ] - } - } - }, - { - "description": "collection writeConcern ignored for insert", - "operations": [ - { - "name": "startTransaction", - "object": "session0", - "arguments": { - "options": { - "writeConcern": { - "w": "majority" - } - } - } - }, - { - "name": "insertOne", - "object": "collection", - "collectionOptions": { - "writeConcern": { - "w": "majority" - } - }, - "arguments": { - "session": "session0", - "document": { - "_id": 1 - } - }, - "result": { - "insertedId": 1 - } - }, - { - "name": "insertMany", - "object": "collection", - "collectionOptions": { - "writeConcern": { - "w": "majority" - } - }, - "arguments": { - "documents": [ - { - "_id": 2 - }, - { - "_id": 3 - } - ], - "session": "session0" - }, - "result": { - "insertedIds": { - "0": 2, - "1": 3 - } - } - }, - { - "name": "commitTransaction", - "object": "session0" - } - ], - "expectations": [ - { - "command_started_event": { - "command": { - "insert": "test", - "documents": [ - { - "_id": 1 - } - ], - "ordered": true, - "readConcern": null, - "lsid": "session0", - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": true, - "autocommit": false, - "writeConcern": null - }, - "command_name": "insert", - "database_name": "transaction-tests" - } - }, - { - "command_started_event": { - "command": { - "insert": "test", - "documents": [ - { - "_id": 2 - }, - { - "_id": 3 - } - ], - "ordered": true, - "lsid": "session0", - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": null, - "autocommit": false, - "writeConcern": null - }, - "command_name": "insert", - "database_name": "transaction-tests" - } - }, - { - "command_started_event": { - "command": { - "commitTransaction": 1, - "lsid": "session0", - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": null, - "autocommit": false, - "writeConcern": { - "w": "majority" - } - }, - "command_name": "commitTransaction", - "database_name": "admin" - } - } - ], - "outcome": { - "collection": { - "data": [ - { - "_id": 1 - }, - { - "_id": 2 - }, - { - "_id": 3 - } - ] - } - } - } - ] -} diff --git a/source/transactions/tests/legacy/insert.yml b/source/transactions/tests/legacy/insert.yml deleted file mode 100644 index 45a5f8633c..0000000000 --- a/source/transactions/tests/legacy/insert.yml +++ /dev/null @@ -1,390 +0,0 @@ -runOn: - - - minServerVersion: "4.0" - topology: ["replicaset"] - - - minServerVersion: "4.1.8" - topology: ["sharded", "load-balanced"] - -database_name: &database_name "transaction-tests" -collection_name: &collection_name "test" - -data: [] - -tests: - - description: insert - - operations: - - name: startTransaction - object: session0 - - name: insertOne - object: collection - arguments: - session: session0 - document: - _id: 1 - result: - insertedId: 1 - - name: insertMany - object: collection - arguments: - documents: - - _id: 2 - - _id: 3 - session: session0 - result: - insertedIds: {0: 2, 1: 3} - - name: insertOne - object: collection - arguments: - session: session0 - document: - _id: 4 - result: - insertedId: 4 - - name: commitTransaction - object: session0 - - name: startTransaction - object: session0 - - name: insertOne - object: collection - arguments: - session: session0 - document: - _id: 5 - result: - insertedId: 5 - - name: commitTransaction - object: session0 - - expectations: - - command_started_event: - command: - insert: *collection_name - documents: - - _id: 1 - ordered: true - readConcern: - lsid: session0 - txnNumber: - $numberLong: "1" - startTransaction: true - autocommit: false - writeConcern: - command_name: insert - database_name: *database_name - - command_started_event: - command: - insert: *collection_name - documents: - - _id: 2 - - _id: 3 - ordered: true - lsid: session0 - txnNumber: - $numberLong: "1" - startTransaction: - autocommit: false - writeConcern: - command_name: insert - database_name: *database_name - - command_started_event: - command: - insert: *collection_name - documents: - - _id: 4 - ordered: true - lsid: session0 - txnNumber: - $numberLong: "1" - autocommit: false - writeConcern: - command_name: insert - database_name: *database_name - - command_started_event: - command: - commitTransaction: 1 - lsid: session0 - txnNumber: - $numberLong: "1" - startTransaction: - autocommit: false - writeConcern: - command_name: commitTransaction - database_name: admin - - command_started_event: - command: - insert: *collection_name - documents: - - _id: 5 - ordered: true - readConcern: - afterClusterTime: 42 - lsid: session0 - txnNumber: - $numberLong: "2" - startTransaction: true - autocommit: false - writeConcern: - command_name: insert - database_name: *database_name - - command_started_event: - command: - commitTransaction: 1 - lsid: session0 - txnNumber: - $numberLong: "2" - startTransaction: - autocommit: false - writeConcern: - command_name: commitTransaction - database_name: admin - - outcome: - collection: - data: - - _id: 1 - - _id: 2 - - _id: 3 - - _id: 4 - - _id: 5 - - # This test proves that the driver uses "session1" correctly in operations - # and APM expectations. - - description: insert with session1 - - operations: - - name: startTransaction - object: session1 - - name: insertOne - object: collection - arguments: - session: session1 - document: - _id: 1 - result: - insertedId: 1 - - name: insertMany - object: collection - arguments: - documents: - - _id: 2 - - _id: 3 - session: session1 - result: - insertedIds: {0: 2, 1: 3} - - name: commitTransaction - object: session1 - - name: startTransaction - object: session1 - - name: insertOne - object: collection - arguments: - session: session1 - document: - _id: 4 - result: - insertedId: 4 - - name: abortTransaction - object: session1 - - expectations: - - command_started_event: - command: - insert: *collection_name - documents: - - _id: 1 - ordered: true - readConcern: - lsid: session1 - txnNumber: - $numberLong: "1" - startTransaction: true - autocommit: false - writeConcern: - command_name: insert - database_name: *database_name - - command_started_event: - command: - insert: *collection_name - documents: - - _id: 2 - - _id: 3 - ordered: true - lsid: session1 - txnNumber: - $numberLong: "1" - startTransaction: - autocommit: false - writeConcern: - command_name: insert - database_name: *database_name - - command_started_event: - command: - commitTransaction: 1 - lsid: session1 - txnNumber: - $numberLong: "1" - startTransaction: - autocommit: false - writeConcern: - command_name: commitTransaction - database_name: admin - - command_started_event: - command: - insert: *collection_name - documents: - - _id: 4 - ordered: true - readConcern: - afterClusterTime: 42 - lsid: session1 - txnNumber: - $numberLong: "2" - startTransaction: true - autocommit: false - writeConcern: - command_name: insert - database_name: *database_name - - command_started_event: - command: - abortTransaction: 1 - lsid: session1 - txnNumber: - $numberLong: "2" - startTransaction: - autocommit: false - writeConcern: - command_name: abortTransaction - database_name: admin - - outcome: - collection: - data: - - _id: 1 - - _id: 2 - - _id: 3 - - # This test proves that the driver parses the collectionOptions writeConcern. - - description: collection writeConcern without transaction - clientOptions: - retryWrites: false - operations: - - name: insertOne - object: collection - collectionOptions: - writeConcern: - w: majority - arguments: - session: session0 - document: - _id: 1 - result: - insertedId: 1 - - expectations: - - command_started_event: - command: - insert: *collection_name - documents: - - _id: 1 - ordered: true - readConcern: - lsid: session0 - txnNumber: - startTransaction: - autocommit: - writeConcern: - w: majority - command_name: insert - database_name: *database_name - - outcome: - collection: - data: - - _id: 1 - - - description: collection writeConcern ignored for insert - operations: - - name: startTransaction - object: session0 - arguments: - options: - writeConcern: - w: majority - - name: insertOne - object: collection - collectionOptions: - writeConcern: - w: majority - arguments: - session: session0 - document: - _id: 1 - result: - insertedId: 1 - - name: insertMany - object: collection - collectionOptions: - writeConcern: - w: majority - arguments: - documents: - - _id: 2 - - _id: 3 - session: session0 - result: - insertedIds: {0: 2, 1: 3} - - name: commitTransaction - object: session0 - - expectations: - - command_started_event: - command: - insert: *collection_name - documents: - - _id: 1 - ordered: true - readConcern: - lsid: session0 - txnNumber: - $numberLong: "1" - startTransaction: true - autocommit: false - writeConcern: - command_name: insert - database_name: *database_name - - command_started_event: - command: - insert: *collection_name - documents: - - _id: 2 - - _id: 3 - ordered: true - lsid: session0 - txnNumber: - $numberLong: "1" - startTransaction: - autocommit: false - writeConcern: - command_name: insert - database_name: *database_name - - command_started_event: - command: - commitTransaction: 1 - lsid: session0 - txnNumber: - $numberLong: "1" - startTransaction: - autocommit: false - writeConcern: - w: majority - command_name: commitTransaction - database_name: admin - - outcome: - collection: - data: - - _id: 1 - - _id: 2 - - _id: 3 diff --git a/source/transactions/tests/legacy/isolation.yml b/source/transactions/tests/legacy/isolation.yml deleted file mode 100644 index d2e733085a..0000000000 --- a/source/transactions/tests/legacy/isolation.yml +++ /dev/null @@ -1,133 +0,0 @@ -# Test snapshot isolation. -# This test doesn't check contents of command-started events. -runOn: - - - minServerVersion: "4.0" - topology: ["replicaset"] - - - minServerVersion: "4.1.8" - topology: ["sharded", "load-balanced"] - -database_name: &database_name "transaction-tests" -collection_name: &collection_name "test" - -data: [] - -tests: - - description: one transaction - - operations: - - name: startTransaction - object: session0 - - name: insertOne - object: collection - arguments: - session: session0 - document: - _id: 1 - result: - insertedId: 1 - - name: find - object: collection - arguments: - session: session0 - filter: - _id: 1 - result: - - {_id: 1} - - name: find - object: collection - arguments: - session: session1 - filter: - _id: 1 - result: [] - - name: find - object: collection - arguments: - filter: - _id: 1 - result: [] - - name: commitTransaction - object: session0 - - name: find - object: collection - arguments: - session: session1 - filter: - _id: 1 - result: - - {_id: 1} - - name: find - object: collection - arguments: - filter: - _id: 1 - result: - - {_id: 1} - - outcome: - collection: - data: - - _id: 1 - - - description: two transactions - - operations: - - name: startTransaction - object: session0 - - name: startTransaction - object: session1 - - name: insertOne - object: collection - arguments: - session: session0 - document: - _id: 1 - result: - insertedId: 1 - - name: find - object: collection - arguments: - session: session0 - filter: - _id: 1 - result: - - {_id: 1} - - name: find - object: collection - arguments: - session: session1 - filter: - _id: 1 - result: [] - - name: find - object: collection - arguments: - filter: - _id: 1 - result: [] - - name: commitTransaction - object: session0 - # Snapshot isolation in session1, not read-committed. - - name: find - object: collection - arguments: - session: session1 - filter: - _id: 1 - result: [] - - name: find - object: collection - arguments: - filter: - _id: 1 - result: - - {_id: 1} - - name: commitTransaction - object: session1 - - outcome: - collection: - data: - - {_id: 1} diff --git a/source/transactions/tests/legacy/mongos-pin-auto-tests.py b/source/transactions/tests/legacy/mongos-pin-auto-tests.py deleted file mode 100644 index df5905d8b2..0000000000 --- a/source/transactions/tests/legacy/mongos-pin-auto-tests.py +++ /dev/null @@ -1,340 +0,0 @@ -import itertools -import sys - -# Require Python 3.7+ for ordered dictionaries so that the order of the -# generated tests remain the same. -# Usage: -# python3.7 mongos-pin-auto-tests.py > mongos-pin-auto.yml -if sys.version_info[:2] < (3, 7): - print('ERROR: This script requires Python >= 3.7, not:') - print(sys.version) - print('Usage: python3.7 mongos-pin-auto-tests.py > mongos-pin-auto.yml') - exit(1) - -HEADER = '''# Autogenerated tests that transient errors in a transaction unpin the session. -# See mongos-pin-auto-tests.py -runOn: - - - minServerVersion: "4.1.8" - topology: ["sharded", "load-balanced"] - # serverless proxy doesn't append error labels to errors in transactions - # caused by failpoints (CLOUDP-88216) - serverless: "forbid" - -database_name: &database_name "transaction-tests" -collection_name: &collection_name "test" - -data: &data - - {_id: 1} - - {_id: 2} - -tests: - - description: remain pinned after non-transient Interrupted error on insertOne - useMultipleMongoses: true - operations: - - &startTransaction - name: startTransaction - object: session0 - - &initialCommand - name: insertOne - object: collection - arguments: - session: session0 - document: {_id: 3} - result: - insertedId: 3 - - name: targetedFailPoint - object: testRunner - arguments: - session: session0 - failPoint: - configureFailPoint: failCommand - mode: {times: 1} - data: - failCommands: ["insert"] - errorCode: 11601 - - name: insertOne - object: collection - arguments: - session: session0 - document: - _id: 4 - result: - errorLabelsOmit: ["TransientTransactionError", "UnknownTransactionCommitResult"] - errorCodeName: Interrupted - - &assertSessionPinned - name: assertSessionPinned - object: testRunner - arguments: - session: session0 - - &commitTransaction - name: commitTransaction - object: session0 - - expectations: - - command_started_event: - command: - insert: *collection_name - documents: - - _id: 3 - ordered: true - readConcern: - lsid: session0 - txnNumber: - $numberLong: "1" - startTransaction: true - autocommit: false - writeConcern: - command_name: insert - database_name: *database_name - - command_started_event: - command: - insert: *collection_name - documents: - - _id: 4 - ordered: true - readConcern: - lsid: session0 - txnNumber: - $numberLong: "1" - startTransaction: - autocommit: false - writeConcern: - command_name: insert - database_name: *database_name - - command_started_event: - command: - commitTransaction: 1 - lsid: session0 - txnNumber: - $numberLong: "1" - startTransaction: - autocommit: false - writeConcern: - recoveryToken: 42 - command_name: commitTransaction - database_name: admin - - outcome: &outcome - collection: - data: - - {_id: 1} - - {_id: 2} - - {_id: 3} - - - description: unpin after transient error within a transaction - useMultipleMongoses: true - operations: - - &startTransaction - name: startTransaction - object: session0 - - &initialCommand - name: insertOne - object: collection - arguments: - session: session0 - document: - _id: 3 - result: - insertedId: 3 - - name: targetedFailPoint - object: testRunner - arguments: - session: session0 - failPoint: - configureFailPoint: failCommand - mode: { times: 1 } - data: - failCommands: ["insert"] - closeConnection: true - - name: insertOne - object: collection - arguments: - session: session0 - document: - _id: 4 - result: - errorLabelsContain: ["TransientTransactionError"] - errorLabelsOmit: ["UnknownTransactionCommitResult"] - # Session unpins from the first mongos after the insert error and - # abortTransaction succeeds immediately on any mongos. - - &assertSessionUnpinned - name: assertSessionUnpinned - object: testRunner - arguments: - session: session0 - - &abortTransaction - name: abortTransaction - object: session0 - - expectations: - - command_started_event: - command: - insert: *collection_name - documents: - - _id: 3 - ordered: true - readConcern: - lsid: session0 - txnNumber: - $numberLong: "1" - startTransaction: true - autocommit: false - writeConcern: - command_name: insert - database_name: *database_name - - command_started_event: - command: - insert: *collection_name - documents: - - _id: 4 - ordered: true - readConcern: - lsid: session0 - txnNumber: - $numberLong: "1" - startTransaction: - autocommit: false - writeConcern: - command_name: insert - database_name: *database_name - - command_started_event: - command: - abortTransaction: 1 - lsid: session0 - txnNumber: - $numberLong: "1" - startTransaction: - autocommit: false - writeConcern: - recoveryToken: 42 - command_name: abortTransaction - database_name: admin - - outcome: &outcome - collection: - data: *data - - # The rest of the tests in this file test every operation type against - # multiple types of transient errors (connection and error code).''' - -TEMPLATE = ''' - - description: {test_name} {error_name} error on {op_name} {command_name} - useMultipleMongoses: true - operations: - - *startTransaction - - *initialCommand - - name: targetedFailPoint - object: testRunner - arguments: - session: session0 - failPoint: - configureFailPoint: failCommand - mode: {{times: 1}} - data: - failCommands: ["{command_name}"] - {error_data} - - name: {op_name} - object: {object_name} - arguments: - session: session0 - {op_args} - result: - {error_labels}: ["TransientTransactionError"] - - *{assertion} - - *abortTransaction - outcome: *outcome -''' - - -# Maps from op_name to (command_name, object_name, op_args) -OPS = { - # Write ops: - 'insertOne': ('insert', 'collection', r'document: {_id: 4}'), - 'insertMany': ('insert', 'collection', r'documents: [{_id: 4}, {_id: 5}]'), - 'updateOne': ('update', 'collection', r'''filter: {_id: 1} - update: {$inc: {x: 1}}'''), - 'replaceOne': ('update', 'collection', r'''filter: {_id: 1} - replacement: {y: 1}'''), - 'updateMany': ('update', 'collection', r'''filter: {_id: {$gte: 1}} - update: {$set: {z: 1}}'''), - 'deleteOne': ('delete', 'collection', r'filter: {_id: 1}'), - 'deleteMany': ('delete', 'collection', r'filter: {_id: {$gte: 1}}'), - 'findOneAndDelete': ('findAndModify', 'collection', r'filter: {_id: 1}'), - 'findOneAndUpdate': ('findAndModify', 'collection', r'''filter: {_id: 1} - update: {$inc: {x: 1}} - returnDocument: Before'''), - 'findOneAndReplace': ('findAndModify', 'collection', r'''filter: {_id: 1} - replacement: {y: 1} - returnDocument: Before'''), - # Bulk write insert/update/delete: - 'bulkWrite insert': ('insert', 'collection', r'''requests: - - name: insertOne - arguments: - document: {_id: 1}'''), - 'bulkWrite update': ('update', 'collection', r'''requests: - - name: updateOne - arguments: - filter: {_id: 1} - update: {$set: {x: 1}}'''), - 'bulkWrite delete': ('delete', 'collection', r'''requests: - - name: deleteOne - arguments: - filter: {_id: 1}'''), - # Read ops: - 'find': ('find', 'collection', r'filter: {_id: 1}'), - 'countDocuments': ('aggregate', 'collection', r'filter: {}'), - 'aggregate': ('aggregate', 'collection', r'pipeline: []'), - 'distinct': ('distinct', 'collection', r'fieldName: _id'), - # runCommand: - 'runCommand': ( - 'insert', - r'''database - command_name: insert''', # runCommand requires command_name. - r'''command: - insert: *collection_name - documents: - - _id : 1'''), -} - -# Maps from error_name to error_data. -NON_TRANSIENT_ERRORS = { - 'Interrupted': 'errorCode: 11601', -} - -# Maps from error_name to error_data. -TRANSIENT_ERRORS = { - 'connection': 'closeConnection: true', - 'ShutdownInProgress': 'errorCode: 91', -} - - -def create_pin_test(op_name, error_name): - test_name = 'remain pinned after non-transient' - assertion = 'assertSessionPinned' - error_labels = 'errorLabelsOmit' - command_name, object_name, op_args = OPS[op_name] - error_data = NON_TRANSIENT_ERRORS[error_name] - if op_name.startswith('bulkWrite'): - op_name = 'bulkWrite' - return TEMPLATE.format(**locals()) - - -def create_unpin_test(op_name, error_name): - test_name = 'unpin after transient' - assertion = 'assertSessionUnpinned' - error_labels = 'errorLabelsContain' - command_name, object_name, op_args = OPS[op_name] - error_data = TRANSIENT_ERRORS[error_name] - if op_name.startswith('bulkWrite'): - op_name = 'bulkWrite' - return TEMPLATE.format(**locals()) - -tests = [] -for op_name, error_name in itertools.product(OPS, NON_TRANSIENT_ERRORS): - tests.append(create_pin_test(op_name, error_name)) -for op_name, error_name in itertools.product(OPS, TRANSIENT_ERRORS): - tests.append(create_unpin_test(op_name, error_name)) - -print(HEADER) -print(''.join(tests)) diff --git a/source/transactions/tests/legacy/mongos-recovery-token-errorLabels.json b/source/transactions/tests/legacy/mongos-recovery-token-errorLabels.json deleted file mode 100644 index 874dae2f69..0000000000 --- a/source/transactions/tests/legacy/mongos-recovery-token-errorLabels.json +++ /dev/null @@ -1,149 +0,0 @@ -{ - "runOn": [ - { - "minServerVersion": "4.3.1", - "topology": [ - "sharded", - "load-balanced" - ], - "serverless": "forbid" - } - ], - "database_name": "transaction-tests", - "collection_name": "test", - "data": [], - "tests": [ - { - "description": "commitTransaction retry succeeds on new mongos", - "useMultipleMongoses": true, - "operations": [ - { - "name": "startTransaction", - "object": "session0", - "arguments": { - "options": { - "writeConcern": { - "w": "majority" - } - } - } - }, - { - "name": "insertOne", - "object": "collection", - "arguments": { - "session": "session0", - "document": { - "_id": 1 - } - }, - "result": { - "insertedId": 1 - } - }, - { - "name": "targetedFailPoint", - "object": "testRunner", - "arguments": { - "session": "session0", - "failPoint": { - "configureFailPoint": "failCommand", - "mode": { - "times": 1 - }, - "data": { - "failCommands": [ - "commitTransaction" - ], - "errorLabels": [ - "RetryableWriteError" - ], - "writeConcernError": { - "code": 91, - "errmsg": "Replication is being shut down" - } - } - } - } - }, - { - "name": "commitTransaction", - "object": "session0" - } - ], - "expectations": [ - { - "command_started_event": { - "command": { - "insert": "test", - "documents": [ - { - "_id": 1 - } - ], - "ordered": true, - "readConcern": null, - "lsid": "session0", - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": true, - "autocommit": false, - "writeConcern": null - }, - "command_name": "insert", - "database_name": "transaction-tests" - } - }, - { - "command_started_event": { - "command": { - "commitTransaction": 1, - "lsid": "session0", - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": null, - "autocommit": false, - "writeConcern": { - "w": "majority" - }, - "recoveryToken": 42 - }, - "command_name": "commitTransaction", - "database_name": "admin" - } - }, - { - "command_started_event": { - "command": { - "commitTransaction": 1, - "lsid": "session0", - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": null, - "autocommit": false, - "writeConcern": { - "w": "majority", - "wtimeout": 10000 - }, - "recoveryToken": 42 - }, - "command_name": "commitTransaction", - "database_name": "admin" - } - } - ], - "outcome": { - "collection": { - "data": [ - { - "_id": 1 - } - ] - } - } - } - ] -} diff --git a/source/transactions/tests/legacy/mongos-recovery-token-errorLabels.yml b/source/transactions/tests/legacy/mongos-recovery-token-errorLabels.yml deleted file mode 100644 index 800562c3a7..0000000000 --- a/source/transactions/tests/legacy/mongos-recovery-token-errorLabels.yml +++ /dev/null @@ -1,96 +0,0 @@ -runOn: - - - minServerVersion: "4.3.1" # failCommand errorLabels option - topology: ["sharded", "load-balanced"] - # serverless proxy doesn't use recovery tokens - serverless: "forbid" - -database_name: &database_name "transaction-tests" -collection_name: &collection_name "test" - -data: [] - -tests: - - description: commitTransaction retry succeeds on new mongos - useMultipleMongoses: true - operations: - - name: startTransaction - object: session0 - arguments: - options: - writeConcern: - w: majority - - name: insertOne - object: collection - arguments: - session: session0 - document: - _id: 1 - result: - insertedId: 1 - # Enable the fail point only on the Mongos that session0 is pinned to. - - name: targetedFailPoint - object: testRunner - arguments: - session: session0 - failPoint: - configureFailPoint: failCommand - mode: { times: 1 } - data: - failCommands: ["commitTransaction"] - errorLabels: ["RetryableWriteError"] - writeConcernError: - code: 91 - errmsg: Replication is being shut down - # The client sees a retryable writeConcernError on the first - # commitTransaction due to the fail point but it actually succeeds on the - # server (SERVER-39346). The retry will succeed both on a new mongos and - # on the original. - - name: commitTransaction - object: session0 - expectations: - - command_started_event: - command: - insert: *collection_name - documents: - - _id: 1 - ordered: true - readConcern: - lsid: session0 - txnNumber: - $numberLong: "1" - startTransaction: true - autocommit: false - writeConcern: - command_name: insert - database_name: *database_name - - command_started_event: - command: - commitTransaction: 1 - lsid: session0 - txnNumber: - $numberLong: "1" - startTransaction: - autocommit: false - writeConcern: - w: majority - recoveryToken: 42 - command_name: commitTransaction - database_name: admin - - command_started_event: - command: - commitTransaction: 1 - lsid: session0 - txnNumber: - $numberLong: "1" - startTransaction: - autocommit: false - # commitTransaction applies w:majority on retries - writeConcern: { w: majority, wtimeout: 10000 } - recoveryToken: 42 - command_name: commitTransaction - database_name: admin - outcome: - collection: - data: - - _id: 1 diff --git a/source/transactions/tests/legacy/mongos-recovery-token.json b/source/transactions/tests/legacy/mongos-recovery-token.json deleted file mode 100644 index 3be3857ddd..0000000000 --- a/source/transactions/tests/legacy/mongos-recovery-token.json +++ /dev/null @@ -1,380 +0,0 @@ -{ - "runOn": [ - { - "minServerVersion": "4.1.8", - "topology": [ - "sharded", - "load-balanced" - ], - "serverless": "forbid" - } - ], - "database_name": "transaction-tests", - "collection_name": "test", - "data": [], - "tests": [ - { - "description": "commitTransaction explicit retries include recoveryToken", - "useMultipleMongoses": true, - "operations": [ - { - "name": "startTransaction", - "object": "session0" - }, - { - "name": "insertOne", - "object": "collection", - "arguments": { - "session": "session0", - "document": { - "_id": 1 - } - }, - "result": { - "insertedId": 1 - } - }, - { - "name": "commitTransaction", - "object": "session0" - }, - { - "name": "commitTransaction", - "object": "session0" - }, - { - "name": "commitTransaction", - "object": "session0" - } - ], - "expectations": [ - { - "command_started_event": { - "command": { - "insert": "test", - "documents": [ - { - "_id": 1 - } - ], - "ordered": true, - "readConcern": null, - "lsid": "session0", - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": true, - "autocommit": false, - "writeConcern": null - }, - "command_name": "insert", - "database_name": "transaction-tests" - } - }, - { - "command_started_event": { - "command": { - "commitTransaction": 1, - "lsid": "session0", - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": null, - "autocommit": false, - "writeConcern": null, - "recoveryToken": 42 - }, - "command_name": "commitTransaction", - "database_name": "admin" - } - }, - { - "command_started_event": { - "command": { - "commitTransaction": 1, - "lsid": "session0", - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": null, - "autocommit": false, - "writeConcern": { - "w": "majority", - "wtimeout": 10000 - }, - "recoveryToken": 42 - }, - "command_name": "commitTransaction", - "database_name": "admin" - } - }, - { - "command_started_event": { - "command": { - "commitTransaction": 1, - "lsid": "session0", - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": null, - "autocommit": false, - "writeConcern": { - "w": "majority", - "wtimeout": 10000 - }, - "recoveryToken": 42 - }, - "command_name": "commitTransaction", - "database_name": "admin" - } - } - ], - "outcome": { - "collection": { - "data": [ - { - "_id": 1 - } - ] - } - } - }, - { - "description": "commitTransaction retry fails on new mongos", - "useMultipleMongoses": true, - "clientOptions": { - "heartbeatFrequencyMS": 30000 - }, - "operations": [ - { - "name": "startTransaction", - "object": "session0" - }, - { - "name": "insertOne", - "object": "collection", - "arguments": { - "session": "session0", - "document": { - "_id": 1 - } - }, - "result": { - "insertedId": 1 - } - }, - { - "name": "targetedFailPoint", - "object": "testRunner", - "arguments": { - "session": "session0", - "failPoint": { - "configureFailPoint": "failCommand", - "mode": { - "times": 7 - }, - "data": { - "failCommands": [ - "commitTransaction", - "isMaster", - "hello" - ], - "closeConnection": true - } - } - } - }, - { - "name": "commitTransaction", - "object": "session0", - "result": { - "errorLabelsContain": [ - "TransientTransactionError" - ], - "errorLabelsOmit": [ - "UnknownTransactionCommitResult" - ], - "errorCodeName": "NoSuchTransaction" - } - } - ], - "expectations": [ - { - "command_started_event": { - "command": { - "insert": "test", - "documents": [ - { - "_id": 1 - } - ], - "ordered": true, - "readConcern": null, - "lsid": "session0", - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": true, - "autocommit": false, - "writeConcern": null - }, - "command_name": "insert", - "database_name": "transaction-tests" - } - }, - { - "command_started_event": { - "command": { - "commitTransaction": 1, - "lsid": "session0", - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": null, - "autocommit": false, - "writeConcern": null, - "recoveryToken": 42 - }, - "command_name": "commitTransaction", - "database_name": "admin" - } - }, - { - "command_started_event": { - "command": { - "commitTransaction": 1, - "lsid": "session0", - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": null, - "autocommit": false, - "writeConcern": { - "w": "majority", - "wtimeout": 10000 - }, - "recoveryToken": 42 - }, - "command_name": "commitTransaction", - "database_name": "admin" - } - } - ], - "outcome": { - "collection": { - "data": [] - } - } - }, - { - "description": "abortTransaction sends recoveryToken", - "useMultipleMongoses": true, - "operations": [ - { - "name": "startTransaction", - "object": "session0" - }, - { - "name": "insertOne", - "object": "collection", - "arguments": { - "session": "session0", - "document": { - "_id": 1 - } - }, - "result": { - "insertedId": 1 - } - }, - { - "name": "targetedFailPoint", - "object": "testRunner", - "arguments": { - "session": "session0", - "failPoint": { - "configureFailPoint": "failCommand", - "mode": { - "times": 1 - }, - "data": { - "failCommands": [ - "abortTransaction" - ], - "closeConnection": true - } - } - } - }, - { - "name": "abortTransaction", - "object": "session0" - } - ], - "expectations": [ - { - "command_started_event": { - "command": { - "insert": "test", - "documents": [ - { - "_id": 1 - } - ], - "ordered": true, - "readConcern": null, - "lsid": "session0", - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": true, - "autocommit": false, - "writeConcern": null - }, - "command_name": "insert", - "database_name": "transaction-tests" - } - }, - { - "command_started_event": { - "command": { - "abortTransaction": 1, - "lsid": "session0", - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": null, - "autocommit": false, - "writeConcern": null, - "recoveryToken": 42 - }, - "command_name": "abortTransaction", - "database_name": "admin" - } - }, - { - "command_started_event": { - "command": { - "abortTransaction": 1, - "lsid": "session0", - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": null, - "autocommit": false, - "writeConcern": null, - "recoveryToken": 42 - }, - "command_name": "abortTransaction", - "database_name": "admin" - } - } - ], - "outcome": { - "collection": { - "data": [] - } - } - } - ] -} diff --git a/source/transactions/tests/legacy/mongos-recovery-token.yml b/source/transactions/tests/legacy/mongos-recovery-token.yml deleted file mode 100644 index 6727161fa8..0000000000 --- a/source/transactions/tests/legacy/mongos-recovery-token.yml +++ /dev/null @@ -1,264 +0,0 @@ -runOn: - - - minServerVersion: "4.1.8" - topology: ["sharded", "load-balanced"] - # serverless proxy doesn't use recovery tokens - serverless: "forbid" - -database_name: &database_name "transaction-tests" -collection_name: &collection_name "test" - -data: [] - -tests: - - description: commitTransaction explicit retries include recoveryToken - useMultipleMongoses: true - operations: - - name: startTransaction - object: session0 - - name: insertOne - object: collection - arguments: - session: session0 - document: - _id: 1 - result: - insertedId: 1 - - name: commitTransaction - object: session0 - - name: commitTransaction - object: session0 - - name: commitTransaction - object: session0 - - expectations: - - command_started_event: - command: - insert: *collection_name - documents: - - _id: 1 - ordered: true - readConcern: - lsid: session0 - txnNumber: - $numberLong: "1" - startTransaction: true - autocommit: false - writeConcern: - command_name: insert - database_name: *database_name - - command_started_event: - command: - commitTransaction: 1 - lsid: session0 - txnNumber: - $numberLong: "1" - startTransaction: - autocommit: false - writeConcern: - recoveryToken: 42 - command_name: commitTransaction - database_name: admin - - command_started_event: - command: - commitTransaction: 1 - lsid: session0 - txnNumber: - $numberLong: "1" - startTransaction: - autocommit: false - # commitTransaction applies w:majority on retries - writeConcern: { w: majority, wtimeout: 10000 } - recoveryToken: 42 - command_name: commitTransaction - database_name: admin - - command_started_event: - command: - commitTransaction: 1 - lsid: session0 - txnNumber: - $numberLong: "1" - startTransaction: - autocommit: false - # commitTransaction applies w:majority on retries - writeConcern: { w: majority, wtimeout: 10000 } - recoveryToken: 42 - command_name: commitTransaction - database_name: admin - - outcome: - collection: - data: - - _id: 1 - - - description: commitTransaction retry fails on new mongos - useMultipleMongoses: true - clientOptions: - # Increase heartbeatFrequencyMS to avoid the race condition where an in - # flight heartbeat refreshes the first mongoes' SDAM state in between - # the initial commitTransaction and the retry attempt. - heartbeatFrequencyMS: 30000 - operations: - - name: startTransaction - object: session0 - - name: insertOne - object: collection - arguments: - session: session0 - document: - _id: 1 - result: - insertedId: 1 - # Enable the fail point only on the Mongos that session0 is pinned to. - # Fail hello/legacy hello to prevent the heartbeat requested directly after the - # retryable commit error from racing with server selection for the retry. - # Note: times: 7 is slightly artbitrary but it accounts for one failed - # commit and some SDAM heartbeats. A test runner will have multiple - # clients connected to this server so this fail point configuration - # is also racy. - - name: targetedFailPoint - object: testRunner - arguments: - session: session0 - failPoint: - configureFailPoint: failCommand - mode: { times: 7 } - data: - failCommands: ["commitTransaction", "isMaster", "hello"] - closeConnection: true - # The first commitTransaction sees a retryable connection error due to - # the fail point and also fails on the server. The retry attempt on a - # new mongos will wait for the transaction to timeout and will fail - # because the transaction was aborted. Note that the retry attempt should - # not select the original mongos because that server's SDAM state is - # reset by the connection error, heartbeatFrequencyMS is high, and - # subsequent heartbeats should fail. - - name: commitTransaction - object: session0 - result: - errorLabelsContain: ["TransientTransactionError"] - errorLabelsOmit: ["UnknownTransactionCommitResult"] - errorCodeName: NoSuchTransaction - - expectations: - - command_started_event: - command: - insert: *collection_name - documents: - - _id: 1 - ordered: true - readConcern: - lsid: session0 - txnNumber: - $numberLong: "1" - startTransaction: true - autocommit: false - writeConcern: - command_name: insert - database_name: *database_name - - command_started_event: - command: - commitTransaction: 1 - lsid: session0 - txnNumber: - $numberLong: "1" - startTransaction: - autocommit: false - writeConcern: - recoveryToken: 42 - command_name: commitTransaction - database_name: admin - - command_started_event: - command: - commitTransaction: 1 - lsid: session0 - txnNumber: - $numberLong: "1" - startTransaction: - autocommit: false - # commitTransaction applies w:majority on retries - writeConcern: { w: majority, wtimeout: 10000 } - recoveryToken: 42 - command_name: commitTransaction - database_name: admin - - outcome: - collection: - data: [] - - - description: abortTransaction sends recoveryToken - useMultipleMongoses: true - operations: - - name: startTransaction - object: session0 - - name: insertOne - object: collection - arguments: - session: session0 - document: - _id: 1 - result: - insertedId: 1 - # Enable the fail point only on the Mongos that session0 is pinned to. - - name: targetedFailPoint - object: testRunner - arguments: - session: session0 - failPoint: - configureFailPoint: failCommand - mode: { times: 1 } - data: - failCommands: ["abortTransaction"] - closeConnection: true - # The first abortTransaction sees a retryable connection error due to - # the fail point. The retry attempt on a new mongos will send the - # recoveryToken. Note that the retry attempt will also fail because the - # server does not yet support aborting from a new mongos, however this - # operation should "succeed" since abortTransaction ignores errors. - - name: abortTransaction - object: session0 - - expectations: - - command_started_event: - command: - insert: *collection_name - documents: - - _id: 1 - ordered: true - readConcern: - lsid: session0 - txnNumber: - $numberLong: "1" - startTransaction: true - autocommit: false - writeConcern: - command_name: insert - database_name: *database_name - - command_started_event: - command: - abortTransaction: 1 - lsid: session0 - txnNumber: - $numberLong: "1" - startTransaction: - autocommit: false - writeConcern: - recoveryToken: 42 - command_name: abortTransaction - database_name: admin - - command_started_event: - command: - abortTransaction: 1 - lsid: session0 - txnNumber: - $numberLong: "1" - startTransaction: - autocommit: false - writeConcern: - recoveryToken: 42 - command_name: abortTransaction - database_name: admin - - outcome: - collection: - data: [] diff --git a/source/transactions/tests/legacy/pin-mongos.yml b/source/transactions/tests/legacy/pin-mongos.yml deleted file mode 100644 index 08051dfd4e..0000000000 --- a/source/transactions/tests/legacy/pin-mongos.yml +++ /dev/null @@ -1,559 +0,0 @@ -# Test that all the operations go to the same mongos. -# -# In tests that don't include command-started events the assertion is implicit: -# that all the read operations succeed. If the driver does not properly pin to -# a single mongos then one of the operations in a transaction will eventually -# be sent to a different mongos, which is unaware of the transaction, and the -# mongos will return a command error. An example of such an error is: -# { -# 'ok': 0.0, -# 'errmsg': 'cannot continue txnId -1 for session 28938f50-9d29-4ca5-8de5-ddaf261267c4 - 47DEQpj8HBSa+/TImW+5JCeuQeRkm5NMpJWZG3hSuFU= with txnId 1', -# 'code': 251, -# 'codeName': 'NoSuchTransaction', -# 'errorLabels': ['TransientTransactionError'] -# } -runOn: - - - minServerVersion: "4.1.8" - topology: ["sharded", "load-balanced"] - # serverless proxy doesn't append error labels to errors in transactions - # caused by failpoints (CLOUDP-88216) - serverless: "forbid" - -database_name: &database_name "transaction-tests" -collection_name: &collection_name "test" - -data: &data - - {_id: 1} - - {_id: 2} - -tests: - - description: countDocuments - useMultipleMongoses: true - operations: - - &startTransaction - name: startTransaction - object: session0 - - &countDocuments - name: countDocuments - object: collection - arguments: - filter: - _id: 2 - session: session0 - result: 1 - - *countDocuments - - *countDocuments - - *countDocuments - - *countDocuments - - *countDocuments - - *countDocuments - - *countDocuments - - &commitTransaction - name: commitTransaction - object: session0 - - outcome: - collection: - data: *data - - - description: distinct - useMultipleMongoses: true - operations: - - *startTransaction - - &distinct - name: distinct - object: collection - arguments: - fieldName: _id - session: session0 - result: [1, 2] - - *distinct - - *distinct - - *distinct - - *distinct - - *distinct - - *distinct - - *distinct - - *commitTransaction - - outcome: - collection: - data: *data - - - description: find - useMultipleMongoses: true - operations: - - name: startTransaction - object: session0 - - &find - name: find - object: collection - arguments: - filter: - _id: 2 - session: session0 - result: - - {_id: 2} - - *find - - *find - - *find - - *find - - *find - - *find - - *find - - *commitTransaction - - outcome: - collection: - data: *data - - - description: insertOne - useMultipleMongoses: true - operations: - - name: startTransaction - object: session0 - - name: insertOne - object: collection - arguments: - document: - _id: 3 - session: session0 - result: - insertedId: 3 - - name: insertOne - object: collection - arguments: - document: - _id: 4 - session: session0 - result: - insertedId: 4 - - name: insertOne - object: collection - arguments: - document: - _id: 5 - session: session0 - result: - insertedId: 5 - - name: insertOne - object: collection - arguments: - document: - _id: 6 - session: session0 - result: - insertedId: 6 - - name: insertOne - object: collection - arguments: - document: - _id: 7 - session: session0 - result: - insertedId: 7 - - name: insertOne - object: collection - arguments: - document: - _id: 8 - session: session0 - result: - insertedId: 8 - - name: insertOne - object: collection - arguments: - document: - _id: 9 - session: session0 - result: - insertedId: 9 - - name: insertOne - object: collection - arguments: - document: - _id: 10 - session: session0 - result: - insertedId: 10 - - *commitTransaction - - outcome: - collection: - data: - - {_id: 1} - - {_id: 2} - - {_id: 3} - - {_id: 4} - - {_id: 5} - - {_id: 6} - - {_id: 7} - - {_id: 8} - - {_id: 9} - - {_id: 10} - - - description: mixed read write operations - useMultipleMongoses: true - operations: - - name: startTransaction - object: session0 - - name: insertOne - object: collection - arguments: - document: - _id: 3 - session: session0 - result: - insertedId: 3 - - &countDocuments - name: countDocuments - object: collection - arguments: - filter: - _id: 3 - session: session0 - result: 1 - - *countDocuments - - *countDocuments - - *countDocuments - - *countDocuments - - name: insertOne - object: collection - arguments: - document: - _id: 4 - session: session0 - result: - insertedId: 4 - - name: insertOne - object: collection - arguments: - document: - _id: 5 - session: session0 - result: - insertedId: 5 - - name: insertOne - object: collection - arguments: - document: - _id: 6 - session: session0 - result: - insertedId: 6 - - name: insertOne - object: collection - arguments: - document: - _id: 7 - session: session0 - result: - insertedId: 7 - - *commitTransaction - - outcome: - collection: - data: - - {_id: 1} - - {_id: 2} - - {_id: 3} - - {_id: 4} - - {_id: 5} - - {_id: 6} - - {_id: 7} - - - description: multiple commits - useMultipleMongoses: true - operations: - - name: startTransaction - object: session0 - - name: insertMany - object: collection - arguments: - documents: - - _id: 3 - - _id: 4 - session: session0 - result: - insertedIds: {0: 3, 1: 4} - # Session is pinned and remains pinned after successful commits. - - &assertSessionPinned - name: assertSessionPinned - object: testRunner - arguments: - session: session0 - - *commitTransaction - - *assertSessionPinned - - *commitTransaction - - *commitTransaction - - *commitTransaction - - *commitTransaction - - *commitTransaction - - *commitTransaction - - *commitTransaction - - *commitTransaction - - *commitTransaction - - *assertSessionPinned - - outcome: - collection: - data: - - {_id: 1} - - {_id: 2} - - {_id: 3} - - {_id: 4} - - - description: remain pinned after non-transient error on commit - useMultipleMongoses: true - operations: - - name: startTransaction - object: session0 - - name: insertMany - object: collection - arguments: - documents: - - _id: 3 - - _id: 4 - session: session0 - result: - insertedIds: {0: 3, 1: 4} - # Session is pinned. - - *assertSessionPinned - # Fail the commit with a non-transient error. - - name: targetedFailPoint - object: testRunner - arguments: - session: session0 - failPoint: - configureFailPoint: failCommand - mode: { times: 1 } - data: - failCommands: ["commitTransaction"] - errorCode: 51 # ManualInterventionRequired - - name: commitTransaction - object: session0 - result: - errorLabelsOmit: ["TransientTransactionError"] - errorCode: 51 - - *assertSessionPinned - # The next commit should succeed. - - name: commitTransaction - object: session0 - - *assertSessionPinned - - outcome: - collection: - data: - - {_id: 1} - - {_id: 2} - - {_id: 3} - - {_id: 4} - - - description: unpin after transient error within a transaction - useMultipleMongoses: true - operations: - - name: startTransaction - object: session0 - - name: insertOne - object: collection - arguments: - session: session0 - document: - _id: 3 - result: - insertedId: 3 - # Enable the fail point only on the Mongos that session0 is pinned to. - - name: targetedFailPoint - object: testRunner - arguments: - session: session0 - failPoint: - configureFailPoint: failCommand - mode: { times: 1 } - data: - failCommands: ["insert"] - closeConnection: true - - name: insertOne - object: collection - arguments: - session: session0 - document: - _id: 4 - result: - errorLabelsContain: ["TransientTransactionError"] - errorLabelsOmit: ["UnknownTransactionCommitResult"] - # Session unpins from the first mongos after the insert error and - # abortTransaction succeeds immediately on any mongos. - - name: abortTransaction - object: session0 - - expectations: - - command_started_event: - command: - insert: *collection_name - documents: - - _id: 3 - ordered: true - readConcern: - lsid: session0 - txnNumber: - $numberLong: "1" - startTransaction: true - autocommit: false - writeConcern: - command_name: insert - database_name: *database_name - - command_started_event: - command: - insert: *collection_name - documents: - - _id: 4 - ordered: true - readConcern: - lsid: session0 - txnNumber: - $numberLong: "1" - startTransaction: - autocommit: false - writeConcern: - command_name: insert - database_name: *database_name - - command_started_event: - command: - abortTransaction: 1 - lsid: session0 - txnNumber: - $numberLong: "1" - startTransaction: - autocommit: false - writeConcern: - recoveryToken: 42 - command_name: abortTransaction - database_name: admin - - outcome: - collection: - data: - - _id: 1 - - _id: 2 - - # Applications should not run commitTransaction after transient errors but - # the transactions API allows it and this test confirms unpinning behavior. - # In a sharded cluster, a transient error within a transaction unpins the - # session. This way a subsequent abort can "succeed" immediately instead of - # blocking for serverSelectionTimeoutMS in the case the mongos went down. - # However since the abortTransaction helper ignores errors, this test uses - # commitTransaction to prove the session was unpinned. - - description: unpin after transient error within a transaction and commit - useMultipleMongoses: true - clientOptions: - # Increase heartbeatFrequencyMS to avoid the race condition where an in - # flight heartbeat refreshes the first mongoes' SDAM state in between - # the insert connection error and the single commit attempt. - heartbeatFrequencyMS: 30000 - operations: - - name: startTransaction - object: session0 - - name: insertOne - object: collection - arguments: - session: session0 - document: - _id: 3 - result: - insertedId: 3 - # Enable the fail point only on the Mongos that session0 is pinned to. - # Fail hello/legacy hello to prevent the heartbeat requested directly after the - # insert error from racing with server selection for the commit. - # Note: times: 7 is slightly artbitrary but it accounts for one failed - # insert and some SDAM heartbeats. A test runner will have multiple - # clients connected to this server so this fail point configuration - # is also racy. - - name: targetedFailPoint - object: testRunner - arguments: - session: session0 - failPoint: - configureFailPoint: failCommand - mode: { times: 7 } - data: - failCommands: ["insert", "isMaster", "hello"] - closeConnection: true - - name: insertOne - object: collection - arguments: - session: session0 - document: - _id: 4 - result: - errorLabelsContain: ["TransientTransactionError"] - errorLabelsOmit: ["UnknownTransactionCommitResult"] - # Session unpins from the first mongos after the insert error and - # commitTransaction selects the second mongos which is unaware of the - # transaction and therefore fails with NoSuchTransaction error. If this - # commit succeeds it indicates a bug, either: - # - the driver mistakenly remained pinned even after the insert error, or - # - the test client was initialized with a single mongos seed - # - # Note that the commit attempt should not select the original mongos - # because that server's SDAM state is reset by the connection error, - # heartbeatFrequencyMS is high, and subsequent heartbeats - # should fail. - - name: commitTransaction - object: session0 - result: - errorLabelsContain: ["TransientTransactionError"] - errorLabelsOmit: ["UnknownTransactionCommitResult"] - errorCodeName: NoSuchTransaction - - - expectations: - - command_started_event: - command: - insert: *collection_name - documents: - - _id: 3 - ordered: true - readConcern: - lsid: session0 - txnNumber: - $numberLong: "1" - startTransaction: true - autocommit: false - writeConcern: - command_name: insert - database_name: *database_name - - command_started_event: - command: - insert: *collection_name - documents: - - _id: 4 - ordered: true - readConcern: - lsid: session0 - txnNumber: - $numberLong: "1" - startTransaction: - autocommit: false - writeConcern: - command_name: insert - database_name: *database_name - - command_started_event: - command: - commitTransaction: 1 - lsid: session0 - txnNumber: - $numberLong: "1" - startTransaction: - autocommit: false - writeConcern: - recoveryToken: 42 - command_name: commitTransaction - database_name: admin - - outcome: - collection: - data: - - _id: 1 - - _id: 2 diff --git a/source/transactions/tests/legacy/read-concern.json b/source/transactions/tests/legacy/read-concern.json deleted file mode 100644 index 99495ddc4b..0000000000 --- a/source/transactions/tests/legacy/read-concern.json +++ /dev/null @@ -1,1629 +0,0 @@ -{ - "runOn": [ - { - "minServerVersion": "4.0", - "topology": [ - "replicaset" - ] - }, - { - "minServerVersion": "4.1.8", - "topology": [ - "sharded", - "load-balanced" - ] - } - ], - "database_name": "transaction-tests", - "collection_name": "test", - "data": [ - { - "_id": 1 - }, - { - "_id": 2 - }, - { - "_id": 3 - }, - { - "_id": 4 - } - ], - "tests": [ - { - "description": "only first countDocuments includes readConcern", - "operations": [ - { - "name": "startTransaction", - "object": "session0", - "arguments": { - "options": { - "readConcern": { - "level": "majority" - } - } - } - }, - { - "name": "countDocuments", - "object": "collection", - "collectionOptions": { - "readConcern": { - "level": "majority" - } - }, - "arguments": { - "session": "session0", - "filter": { - "_id": { - "$gte": 2 - } - } - }, - "result": 3 - }, - { - "name": "countDocuments", - "object": "collection", - "collectionOptions": { - "readConcern": { - "level": "majority" - } - }, - "arguments": { - "session": "session0", - "filter": { - "_id": { - "$gte": 2 - } - } - }, - "result": 3 - }, - { - "name": "commitTransaction", - "object": "session0" - } - ], - "expectations": [ - { - "command_started_event": { - "command": { - "aggregate": "test", - "pipeline": [ - { - "$match": { - "_id": { - "$gte": 2 - } - } - }, - { - "$group": { - "_id": 1, - "n": { - "$sum": 1 - } - } - } - ], - "cursor": {}, - "lsid": "session0", - "readConcern": { - "level": "majority" - }, - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": true, - "autocommit": false - }, - "command_name": "aggregate", - "database_name": "transaction-tests" - } - }, - { - "command_started_event": { - "command": { - "aggregate": "test", - "pipeline": [ - { - "$match": { - "_id": { - "$gte": 2 - } - } - }, - { - "$group": { - "_id": 1, - "n": { - "$sum": 1 - } - } - } - ], - "cursor": {}, - "lsid": "session0", - "readConcern": null, - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": null, - "autocommit": false - }, - "command_name": "aggregate", - "database_name": "transaction-tests" - } - }, - { - "command_started_event": { - "command": { - "commitTransaction": 1, - "lsid": "session0", - "readConcern": null, - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": null, - "autocommit": false, - "writeConcern": null - }, - "command_name": "commitTransaction", - "database_name": "admin" - } - } - ], - "outcome": { - "collection": { - "data": [ - { - "_id": 1 - }, - { - "_id": 2 - }, - { - "_id": 3 - }, - { - "_id": 4 - } - ] - } - } - }, - { - "description": "only first find includes readConcern", - "operations": [ - { - "name": "startTransaction", - "object": "session0", - "arguments": { - "options": { - "readConcern": { - "level": "majority" - } - } - } - }, - { - "name": "find", - "object": "collection", - "collectionOptions": { - "readConcern": { - "level": "majority" - } - }, - "arguments": { - "session": "session0", - "batchSize": 3 - }, - "result": [ - { - "_id": 1 - }, - { - "_id": 2 - }, - { - "_id": 3 - }, - { - "_id": 4 - } - ] - }, - { - "name": "find", - "object": "collection", - "collectionOptions": { - "readConcern": { - "level": "majority" - } - }, - "arguments": { - "session": "session0", - "batchSize": 3 - }, - "result": [ - { - "_id": 1 - }, - { - "_id": 2 - }, - { - "_id": 3 - }, - { - "_id": 4 - } - ] - }, - { - "name": "commitTransaction", - "object": "session0" - } - ], - "expectations": [ - { - "command_started_event": { - "command": { - "find": "test", - "batchSize": 3, - "lsid": "session0", - "readConcern": { - "level": "majority" - }, - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": true, - "autocommit": false - }, - "command_name": "find", - "database_name": "transaction-tests" - } - }, - { - "command_started_event": { - "command": { - "getMore": { - "$numberLong": "42" - }, - "collection": "test", - "batchSize": 3, - "lsid": "session0", - "readConcern": null, - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": null, - "autocommit": false - }, - "command_name": "getMore", - "database_name": "transaction-tests" - } - }, - { - "command_started_event": { - "command": { - "find": "test", - "batchSize": 3, - "lsid": "session0", - "readConcern": null, - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": null, - "autocommit": false - }, - "command_name": "find", - "database_name": "transaction-tests" - } - }, - { - "command_started_event": { - "command": { - "getMore": { - "$numberLong": "42" - }, - "collection": "test", - "batchSize": 3, - "lsid": "session0", - "readConcern": null, - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": null, - "autocommit": false - }, - "command_name": "getMore", - "database_name": "transaction-tests" - } - }, - { - "command_started_event": { - "command": { - "commitTransaction": 1, - "lsid": "session0", - "readConcern": null, - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": null, - "autocommit": false, - "writeConcern": null - }, - "command_name": "commitTransaction", - "database_name": "admin" - } - } - ], - "outcome": { - "collection": { - "data": [ - { - "_id": 1 - }, - { - "_id": 2 - }, - { - "_id": 3 - }, - { - "_id": 4 - } - ] - } - } - }, - { - "description": "only first aggregate includes readConcern", - "operations": [ - { - "name": "startTransaction", - "object": "session0", - "arguments": { - "options": { - "readConcern": { - "level": "majority" - } - } - } - }, - { - "name": "aggregate", - "object": "collection", - "collectionOptions": { - "readConcern": { - "level": "majority" - } - }, - "arguments": { - "pipeline": [ - { - "$project": { - "_id": 1 - } - } - ], - "batchSize": 3, - "session": "session0" - }, - "result": [ - { - "_id": 1 - }, - { - "_id": 2 - }, - { - "_id": 3 - }, - { - "_id": 4 - } - ] - }, - { - "name": "aggregate", - "object": "collection", - "collectionOptions": { - "readConcern": { - "level": "majority" - } - }, - "arguments": { - "pipeline": [ - { - "$project": { - "_id": 1 - } - } - ], - "batchSize": 3, - "session": "session0" - }, - "result": [ - { - "_id": 1 - }, - { - "_id": 2 - }, - { - "_id": 3 - }, - { - "_id": 4 - } - ] - }, - { - "name": "commitTransaction", - "object": "session0" - } - ], - "expectations": [ - { - "command_started_event": { - "command": { - "aggregate": "test", - "pipeline": [ - { - "$project": { - "_id": 1 - } - } - ], - "cursor": { - "batchSize": 3 - }, - "lsid": "session0", - "readConcern": { - "level": "majority" - }, - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": true, - "autocommit": false - }, - "command_name": "aggregate", - "database_name": "transaction-tests" - } - }, - { - "command_started_event": { - "command": { - "getMore": { - "$numberLong": "42" - }, - "collection": "test", - "batchSize": 3, - "lsid": "session0", - "readConcern": null, - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": null, - "autocommit": false - }, - "command_name": "getMore", - "database_name": "transaction-tests" - } - }, - { - "command_started_event": { - "command": { - "aggregate": "test", - "pipeline": [ - { - "$project": { - "_id": 1 - } - } - ], - "cursor": { - "batchSize": 3 - }, - "lsid": "session0", - "readConcern": null, - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": null, - "autocommit": false - }, - "command_name": "aggregate", - "database_name": "transaction-tests" - } - }, - { - "command_started_event": { - "command": { - "getMore": { - "$numberLong": "42" - }, - "collection": "test", - "batchSize": 3, - "lsid": "session0", - "readConcern": null, - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": null, - "autocommit": false - }, - "command_name": "getMore", - "database_name": "transaction-tests" - } - }, - { - "command_started_event": { - "command": { - "commitTransaction": 1, - "lsid": "session0", - "readConcern": null, - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": null, - "autocommit": false, - "writeConcern": null - }, - "command_name": "commitTransaction", - "database_name": "admin" - } - } - ], - "outcome": { - "collection": { - "data": [ - { - "_id": 1 - }, - { - "_id": 2 - }, - { - "_id": 3 - }, - { - "_id": 4 - } - ] - } - } - }, - { - "description": "only first distinct includes readConcern", - "operations": [ - { - "name": "startTransaction", - "object": "session0", - "arguments": { - "options": { - "readConcern": { - "level": "majority" - } - } - } - }, - { - "name": "distinct", - "object": "collection", - "collectionOptions": { - "readConcern": { - "level": "majority" - } - }, - "arguments": { - "session": "session0", - "fieldName": "_id" - }, - "result": [ - 1, - 2, - 3, - 4 - ] - }, - { - "name": "distinct", - "object": "collection", - "collectionOptions": { - "readConcern": { - "level": "majority" - } - }, - "arguments": { - "session": "session0", - "fieldName": "_id" - }, - "result": [ - 1, - 2, - 3, - 4 - ] - }, - { - "name": "commitTransaction", - "object": "session0" - } - ], - "expectations": [ - { - "command_started_event": { - "command": { - "distinct": "test", - "key": "_id", - "lsid": "session0", - "readConcern": { - "level": "majority" - }, - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": true, - "autocommit": false, - "writeConcern": null - }, - "command_name": "distinct", - "database_name": "transaction-tests" - } - }, - { - "command_started_event": { - "command": { - "distinct": "test", - "key": "_id", - "lsid": "session0", - "readConcern": null, - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": null, - "autocommit": false, - "writeConcern": null - }, - "command_name": "distinct", - "database_name": "transaction-tests" - } - }, - { - "command_started_event": { - "command": { - "commitTransaction": 1, - "lsid": "session0", - "readConcern": null, - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": null, - "autocommit": false, - "writeConcern": null - }, - "command_name": "commitTransaction", - "database_name": "admin" - } - } - ], - "outcome": { - "collection": { - "data": [ - { - "_id": 1 - }, - { - "_id": 2 - }, - { - "_id": 3 - }, - { - "_id": 4 - } - ] - } - } - }, - { - "description": "only first runCommand includes readConcern", - "operations": [ - { - "name": "startTransaction", - "object": "session0", - "arguments": { - "options": { - "readConcern": { - "level": "majority" - } - } - } - }, - { - "name": "runCommand", - "object": "database", - "command_name": "find", - "arguments": { - "session": "session0", - "command": { - "find": "test" - } - } - }, - { - "name": "runCommand", - "object": "database", - "command_name": "find", - "arguments": { - "session": "session0", - "command": { - "find": "test" - } - } - }, - { - "name": "commitTransaction", - "object": "session0" - } - ], - "expectations": [ - { - "command_started_event": { - "command": { - "find": "test", - "lsid": "session0", - "readConcern": { - "level": "majority" - }, - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": true, - "autocommit": false, - "writeConcern": null - }, - "command_name": "find", - "database_name": "transaction-tests" - } - }, - { - "command_started_event": { - "command": { - "find": "test", - "lsid": "session0", - "readConcern": null, - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": null, - "autocommit": false, - "writeConcern": null - }, - "command_name": "find", - "database_name": "transaction-tests" - } - }, - { - "command_started_event": { - "command": { - "commitTransaction": 1, - "lsid": "session0", - "readConcern": null, - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": null, - "autocommit": false, - "writeConcern": null - }, - "command_name": "commitTransaction", - "database_name": "admin" - } - } - ], - "outcome": { - "collection": { - "data": [ - { - "_id": 1 - }, - { - "_id": 2 - }, - { - "_id": 3 - }, - { - "_id": 4 - } - ] - } - } - }, - { - "description": "countDocuments ignores collection readConcern", - "operations": [ - { - "name": "startTransaction", - "object": "session0" - }, - { - "name": "countDocuments", - "object": "collection", - "collectionOptions": { - "readConcern": { - "level": "majority" - } - }, - "arguments": { - "session": "session0", - "filter": { - "_id": { - "$gte": 2 - } - } - }, - "result": 3 - }, - { - "name": "countDocuments", - "object": "collection", - "collectionOptions": { - "readConcern": { - "level": "majority" - } - }, - "arguments": { - "session": "session0", - "filter": { - "_id": { - "$gte": 2 - } - } - }, - "result": 3 - }, - { - "name": "commitTransaction", - "object": "session0" - } - ], - "expectations": [ - { - "command_started_event": { - "command": { - "aggregate": "test", - "pipeline": [ - { - "$match": { - "_id": { - "$gte": 2 - } - } - }, - { - "$group": { - "_id": 1, - "n": { - "$sum": 1 - } - } - } - ], - "cursor": {}, - "lsid": "session0", - "readConcern": null, - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": true, - "autocommit": false - }, - "command_name": "aggregate", - "database_name": "transaction-tests" - } - }, - { - "command_started_event": { - "command": { - "aggregate": "test", - "pipeline": [ - { - "$match": { - "_id": { - "$gte": 2 - } - } - }, - { - "$group": { - "_id": 1, - "n": { - "$sum": 1 - } - } - } - ], - "cursor": {}, - "lsid": "session0", - "readConcern": null, - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": null, - "autocommit": false - }, - "command_name": "aggregate", - "database_name": "transaction-tests" - } - }, - { - "command_started_event": { - "command": { - "commitTransaction": 1, - "lsid": "session0", - "readConcern": null, - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": null, - "autocommit": false, - "writeConcern": null - }, - "command_name": "commitTransaction", - "database_name": "admin" - } - } - ], - "outcome": { - "collection": { - "data": [ - { - "_id": 1 - }, - { - "_id": 2 - }, - { - "_id": 3 - }, - { - "_id": 4 - } - ] - } - } - }, - { - "description": "find ignores collection readConcern", - "operations": [ - { - "name": "startTransaction", - "object": "session0" - }, - { - "name": "find", - "object": "collection", - "collectionOptions": { - "readConcern": { - "level": "majority" - } - }, - "arguments": { - "session": "session0", - "batchSize": 3 - }, - "result": [ - { - "_id": 1 - }, - { - "_id": 2 - }, - { - "_id": 3 - }, - { - "_id": 4 - } - ] - }, - { - "name": "find", - "object": "collection", - "collectionOptions": { - "readConcern": { - "level": "majority" - } - }, - "arguments": { - "session": "session0", - "batchSize": 3 - }, - "result": [ - { - "_id": 1 - }, - { - "_id": 2 - }, - { - "_id": 3 - }, - { - "_id": 4 - } - ] - }, - { - "name": "commitTransaction", - "object": "session0" - } - ], - "expectations": [ - { - "command_started_event": { - "command": { - "find": "test", - "batchSize": 3, - "lsid": "session0", - "readConcern": null, - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": true, - "autocommit": false - }, - "command_name": "find", - "database_name": "transaction-tests" - } - }, - { - "command_started_event": { - "command": { - "getMore": { - "$numberLong": "42" - }, - "collection": "test", - "batchSize": 3, - "lsid": "session0", - "readConcern": null, - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": null, - "autocommit": false - }, - "command_name": "getMore", - "database_name": "transaction-tests" - } - }, - { - "command_started_event": { - "command": { - "find": "test", - "batchSize": 3, - "lsid": "session0", - "readConcern": null, - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": null, - "autocommit": false - }, - "command_name": "find", - "database_name": "transaction-tests" - } - }, - { - "command_started_event": { - "command": { - "getMore": { - "$numberLong": "42" - }, - "collection": "test", - "batchSize": 3, - "lsid": "session0", - "readConcern": null, - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": null, - "autocommit": false - }, - "command_name": "getMore", - "database_name": "transaction-tests" - } - }, - { - "command_started_event": { - "command": { - "commitTransaction": 1, - "lsid": "session0", - "readConcern": null, - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": null, - "autocommit": false, - "writeConcern": null - }, - "command_name": "commitTransaction", - "database_name": "admin" - } - } - ], - "outcome": { - "collection": { - "data": [ - { - "_id": 1 - }, - { - "_id": 2 - }, - { - "_id": 3 - }, - { - "_id": 4 - } - ] - } - } - }, - { - "description": "aggregate ignores collection readConcern", - "operations": [ - { - "name": "startTransaction", - "object": "session0" - }, - { - "name": "aggregate", - "object": "collection", - "collectionOptions": { - "readConcern": { - "level": "majority" - } - }, - "arguments": { - "pipeline": [ - { - "$project": { - "_id": 1 - } - } - ], - "batchSize": 3, - "session": "session0" - }, - "result": [ - { - "_id": 1 - }, - { - "_id": 2 - }, - { - "_id": 3 - }, - { - "_id": 4 - } - ] - }, - { - "name": "aggregate", - "object": "collection", - "collectionOptions": { - "readConcern": { - "level": "majority" - } - }, - "arguments": { - "pipeline": [ - { - "$project": { - "_id": 1 - } - } - ], - "batchSize": 3, - "session": "session0" - }, - "result": [ - { - "_id": 1 - }, - { - "_id": 2 - }, - { - "_id": 3 - }, - { - "_id": 4 - } - ] - }, - { - "name": "commitTransaction", - "object": "session0" - } - ], - "expectations": [ - { - "command_started_event": { - "command": { - "aggregate": "test", - "pipeline": [ - { - "$project": { - "_id": 1 - } - } - ], - "cursor": { - "batchSize": 3 - }, - "lsid": "session0", - "readConcern": null, - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": true, - "autocommit": false - }, - "command_name": "aggregate", - "database_name": "transaction-tests" - } - }, - { - "command_started_event": { - "command": { - "getMore": { - "$numberLong": "42" - }, - "collection": "test", - "batchSize": 3, - "lsid": "session0", - "readConcern": null, - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": null, - "autocommit": false - }, - "command_name": "getMore", - "database_name": "transaction-tests" - } - }, - { - "command_started_event": { - "command": { - "aggregate": "test", - "pipeline": [ - { - "$project": { - "_id": 1 - } - } - ], - "cursor": { - "batchSize": 3 - }, - "lsid": "session0", - "readConcern": null, - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": null, - "autocommit": false - }, - "command_name": "aggregate", - "database_name": "transaction-tests" - } - }, - { - "command_started_event": { - "command": { - "getMore": { - "$numberLong": "42" - }, - "collection": "test", - "batchSize": 3, - "lsid": "session0", - "readConcern": null, - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": null, - "autocommit": false - }, - "command_name": "getMore", - "database_name": "transaction-tests" - } - }, - { - "command_started_event": { - "command": { - "commitTransaction": 1, - "lsid": "session0", - "readConcern": null, - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": null, - "autocommit": false, - "writeConcern": null - }, - "command_name": "commitTransaction", - "database_name": "admin" - } - } - ], - "outcome": { - "collection": { - "data": [ - { - "_id": 1 - }, - { - "_id": 2 - }, - { - "_id": 3 - }, - { - "_id": 4 - } - ] - } - } - }, - { - "description": "distinct ignores collection readConcern", - "operations": [ - { - "name": "startTransaction", - "object": "session0" - }, - { - "name": "distinct", - "object": "collection", - "collectionOptions": { - "readConcern": { - "level": "majority" - } - }, - "arguments": { - "session": "session0", - "fieldName": "_id" - }, - "result": [ - 1, - 2, - 3, - 4 - ] - }, - { - "name": "distinct", - "object": "collection", - "collectionOptions": { - "readConcern": { - "level": "majority" - } - }, - "arguments": { - "session": "session0", - "fieldName": "_id" - }, - "result": [ - 1, - 2, - 3, - 4 - ] - }, - { - "name": "commitTransaction", - "object": "session0" - } - ], - "expectations": [ - { - "command_started_event": { - "command": { - "distinct": "test", - "key": "_id", - "lsid": "session0", - "readConcern": null, - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": true, - "autocommit": false, - "writeConcern": null - }, - "command_name": "distinct", - "database_name": "transaction-tests" - } - }, - { - "command_started_event": { - "command": { - "distinct": "test", - "key": "_id", - "lsid": "session0", - "readConcern": null, - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": null, - "autocommit": false, - "writeConcern": null - }, - "command_name": "distinct", - "database_name": "transaction-tests" - } - }, - { - "command_started_event": { - "command": { - "commitTransaction": 1, - "lsid": "session0", - "readConcern": null, - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": null, - "autocommit": false, - "writeConcern": null - }, - "command_name": "commitTransaction", - "database_name": "admin" - } - } - ], - "outcome": { - "collection": { - "data": [ - { - "_id": 1 - }, - { - "_id": 2 - }, - { - "_id": 3 - }, - { - "_id": 4 - } - ] - } - } - }, - { - "description": "runCommand ignores database readConcern", - "operations": [ - { - "name": "startTransaction", - "object": "session0" - }, - { - "name": "runCommand", - "object": "database", - "databaseOptions": { - "readConcern": { - "level": "majority" - } - }, - "command_name": "find", - "arguments": { - "session": "session0", - "command": { - "find": "test" - } - } - }, - { - "name": "runCommand", - "object": "database", - "command_name": "find", - "arguments": { - "session": "session0", - "command": { - "find": "test" - } - } - }, - { - "name": "commitTransaction", - "object": "session0" - } - ], - "expectations": [ - { - "command_started_event": { - "command": { - "find": "test", - "lsid": "session0", - "readConcern": null, - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": true, - "autocommit": false, - "writeConcern": null - }, - "command_name": "find", - "database_name": "transaction-tests" - } - }, - { - "command_started_event": { - "command": { - "find": "test", - "lsid": "session0", - "readConcern": null, - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": null, - "autocommit": false, - "writeConcern": null - }, - "command_name": "find", - "database_name": "transaction-tests" - } - }, - { - "command_started_event": { - "command": { - "commitTransaction": 1, - "lsid": "session0", - "readConcern": null, - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": null, - "autocommit": false, - "writeConcern": null - }, - "command_name": "commitTransaction", - "database_name": "admin" - } - } - ], - "outcome": { - "collection": { - "data": [ - { - "_id": 1 - }, - { - "_id": 2 - }, - { - "_id": 3 - }, - { - "_id": 4 - } - ] - } - } - } - ] -} diff --git a/source/transactions/tests/legacy/read-concern.yml b/source/transactions/tests/legacy/read-concern.yml deleted file mode 100644 index 128a02ceb9..0000000000 --- a/source/transactions/tests/legacy/read-concern.yml +++ /dev/null @@ -1,623 +0,0 @@ -runOn: - - - minServerVersion: "4.0" - topology: ["replicaset"] - - - minServerVersion: "4.1.8" - topology: ["sharded", "load-balanced"] - -database_name: &database_name "transaction-tests" -collection_name: &collection_name "test" - -data: &data - - {_id: 1} - - {_id: 2} - - {_id: 3} - - {_id: 4} - -tests: - - description: only first countDocuments includes readConcern - - operations: - - &startTransaction - name: startTransaction - object: session0 - arguments: - options: - readConcern: - level: majority - - &countDocuments - name: countDocuments - object: collection - collectionOptions: - readConcern: - level: majority - arguments: - session: session0 - filter: {_id: {$gte: 2}} - result: 3 - - *countDocuments - - &commitTransaction - name: commitTransaction - object: session0 - - expectations: - - command_started_event: - command: - aggregate: *collection_name - pipeline: - - $match: {_id: {$gte: 2}} - - $group: {_id: 1, n: {$sum: 1}} - cursor: {} - lsid: session0 - readConcern: - level: majority - txnNumber: - $numberLong: "1" - startTransaction: true - autocommit: false - command_name: aggregate - database_name: *database_name - - command_started_event: - command: - aggregate: *collection_name - pipeline: - - $match: {_id: {$gte: 2}} - - $group: {_id: 1, n: {$sum: 1}} - cursor: {} - lsid: session0 - readConcern: # No readConcern - txnNumber: - $numberLong: "1" - startTransaction: - autocommit: false - command_name: aggregate - database_name: *database_name - - &commitTransactionEvent - command_started_event: - command: - commitTransaction: 1 - lsid: session0 - readConcern: - txnNumber: - $numberLong: "1" - startTransaction: - autocommit: false - writeConcern: - command_name: commitTransaction - database_name: admin - - outcome: &outcome - collection: - data: - *data - - - description: only first find includes readConcern - - operations: - - *startTransaction - - &find - name: find - object: collection - collectionOptions: - readConcern: - level: majority - arguments: - session: session0 - batchSize: 3 - result: *data - - *find - - *commitTransaction - - expectations: - - command_started_event: - command: - find: *collection_name - batchSize: 3 - lsid: session0 - readConcern: - level: majority - txnNumber: - $numberLong: "1" - startTransaction: true - autocommit: false - command_name: find - database_name: *database_name - - command_started_event: - command: - getMore: - # 42 is a fake placeholder value for the cursorId. - $numberLong: '42' - collection: *collection_name - batchSize: 3 - lsid: session0 - readConcern: # No readConcern - txnNumber: - $numberLong: "1" - startTransaction: - autocommit: false - command_name: getMore - database_name: *database_name - - command_started_event: - command: - find: *collection_name - batchSize: 3 - lsid: session0 - readConcern: # No readConcern - txnNumber: - $numberLong: "1" - startTransaction: - autocommit: false - command_name: find - database_name: *database_name - - command_started_event: - command: - getMore: - $numberLong: '42' - collection: *collection_name - batchSize: 3 - lsid: session0 - readConcern: # No readConcern - txnNumber: - $numberLong: "1" - startTransaction: - autocommit: false - command_name: getMore - database_name: *database_name - - *commitTransactionEvent - - outcome: &outcome - collection: - data: - *data - - - description: only first aggregate includes readConcern - - operations: - - *startTransaction - - &aggregate - name: aggregate - object: collection - collectionOptions: - readConcern: - level: majority - arguments: - pipeline: - - $project: - _id: 1 - batchSize: 3 - session: session0 - result: *data - - *aggregate - - *commitTransaction - - expectations: - - command_started_event: - command: - aggregate: *collection_name - pipeline: - - $project: - _id: 1 - cursor: - batchSize: 3 - lsid: session0 - readConcern: - level: majority - txnNumber: - $numberLong: "1" - startTransaction: true - autocommit: false - command_name: aggregate - database_name: *database_name - - command_started_event: - command: - getMore: - # 42 is a fake placeholder value for the cursorId. - $numberLong: '42' - collection: *collection_name - batchSize: 3 - lsid: session0 - readConcern: # No readConcern - txnNumber: - $numberLong: "1" - startTransaction: - autocommit: false - command_name: getMore - database_name: *database_name - - command_started_event: - command: - aggregate: *collection_name - pipeline: - - $project: - _id: 1 - cursor: - batchSize: 3 - lsid: session0 - readConcern: # No readConcern - txnNumber: - $numberLong: "1" - startTransaction: - autocommit: false - command_name: aggregate - database_name: *database_name - - command_started_event: - command: - getMore: - $numberLong: '42' - collection: *collection_name - batchSize: 3 - lsid: session0 - readConcern: # No readConcern - txnNumber: - $numberLong: "1" - startTransaction: - autocommit: false - command_name: getMore - database_name: *database_name - - *commitTransactionEvent - - outcome: *outcome - - - description: only first distinct includes readConcern - - operations: - - *startTransaction - - &distinct - name: distinct - object: collection - collectionOptions: - readConcern: - level: majority - arguments: - session: session0 - fieldName: _id - result: [1, 2, 3, 4] - - *distinct - - *commitTransaction - - expectations: - - command_started_event: - command: - distinct: *collection_name - key: _id - lsid: session0 - readConcern: - level: majority - txnNumber: - $numberLong: "1" - startTransaction: true - autocommit: false - writeConcern: - command_name: distinct - database_name: *database_name - - command_started_event: - command: - distinct: *collection_name - key: _id - lsid: session0 - readConcern: # No readConcern - txnNumber: - $numberLong: "1" - startTransaction: - autocommit: false - writeConcern: - command_name: distinct - database_name: *database_name - - *commitTransactionEvent - - outcome: *outcome - - - description: only first runCommand includes readConcern - - operations: - - *startTransaction - - &runCommand - name: runCommand - object: database - command_name: find - arguments: - session: session0 - command: - find: *collection_name - - *runCommand - - *commitTransaction - - expectations: - - command_started_event: - command: - find: *collection_name - lsid: session0 - readConcern: - level: majority - txnNumber: - $numberLong: "1" - startTransaction: true - autocommit: false - writeConcern: - command_name: find - database_name: *database_name - - command_started_event: - command: - find: *collection_name - lsid: session0 - readConcern: # No readConcern - txnNumber: - $numberLong: "1" - startTransaction: - autocommit: false - writeConcern: - command_name: find - database_name: *database_name - - *commitTransactionEvent - - outcome: *outcome - - - description: countDocuments ignores collection readConcern - - operations: - - &startTransactionNoReadConcern - name: startTransaction - object: session0 - - *countDocuments - - *countDocuments - - *commitTransaction - - expectations: - - command_started_event: - command: - aggregate: *collection_name - pipeline: - - $match: {_id: {$gte: 2}} - - $group: {_id: 1, n: {$sum: 1}} - cursor: {} - lsid: session0 - readConcern: # No readConcern - txnNumber: - $numberLong: "1" - startTransaction: true - autocommit: false - command_name: aggregate - database_name: *database_name - - command_started_event: - command: - aggregate: *collection_name - pipeline: - - $match: {_id: {$gte: 2}} - - $group: {_id: 1, n: {$sum: 1}} - cursor: {} - lsid: session0 - readConcern: # No readConcern - txnNumber: - $numberLong: "1" - startTransaction: - autocommit: false - command_name: aggregate - database_name: *database_name - - *commitTransactionEvent - - outcome: *outcome - - - description: find ignores collection readConcern - - operations: - - *startTransactionNoReadConcern - - *find - - *find - - *commitTransaction - - expectations: - - command_started_event: - command: - find: *collection_name - batchSize: 3 - lsid: session0 - readConcern: # No readConcern - txnNumber: - $numberLong: "1" - startTransaction: true - autocommit: false - command_name: find - database_name: *database_name - - command_started_event: - command: - getMore: - # 42 is a fake placeholder value for the cursorId. - $numberLong: '42' - collection: *collection_name - batchSize: 3 - lsid: session0 - readConcern: # No readConcern - txnNumber: - $numberLong: "1" - startTransaction: - autocommit: false - command_name: getMore - database_name: *database_name - - command_started_event: - command: - find: *collection_name - batchSize: 3 - lsid: session0 - readConcern: # No readConcern - txnNumber: - $numberLong: "1" - startTransaction: - autocommit: false - command_name: find - database_name: *database_name - - command_started_event: - command: - getMore: - $numberLong: '42' - collection: *collection_name - batchSize: 3 - lsid: session0 - readConcern: # No readConcern - txnNumber: - $numberLong: "1" - startTransaction: - autocommit: false - command_name: getMore - database_name: *database_name - - *commitTransactionEvent - - outcome: *outcome - - - description: aggregate ignores collection readConcern - - operations: - - *startTransactionNoReadConcern - - *aggregate - - *aggregate - - *commitTransaction - - expectations: - - command_started_event: - command: - aggregate: *collection_name - pipeline: - - $project: - _id: 1 - cursor: - batchSize: 3 - lsid: session0 - readConcern: # No readConcern - txnNumber: - $numberLong: "1" - startTransaction: true - autocommit: false - command_name: aggregate - database_name: *database_name - - command_started_event: - command: - getMore: - # 42 is a fake placeholder value for the cursorId. - $numberLong: '42' - collection: *collection_name - batchSize: 3 - lsid: session0 - readConcern: # No readConcern - txnNumber: - $numberLong: "1" - startTransaction: - autocommit: false - command_name: getMore - database_name: *database_name - - command_started_event: - command: - aggregate: *collection_name - pipeline: - - $project: - _id: 1 - cursor: - batchSize: 3 - lsid: session0 - readConcern: # No readConcern - txnNumber: - $numberLong: "1" - startTransaction: - autocommit: false - command_name: aggregate - database_name: *database_name - - command_started_event: - command: - getMore: - $numberLong: '42' - collection: *collection_name - batchSize: 3 - lsid: session0 - readConcern: # No readConcern - txnNumber: - $numberLong: "1" - startTransaction: - autocommit: false - command_name: getMore - database_name: *database_name - - *commitTransactionEvent - - outcome: *outcome - - - description: distinct ignores collection readConcern - - operations: - - *startTransactionNoReadConcern - - *distinct - - *distinct - - *commitTransaction - - expectations: - - command_started_event: - command: - distinct: *collection_name - key: _id - lsid: session0 - readConcern: # No readConcern - txnNumber: - $numberLong: "1" - startTransaction: true - autocommit: false - writeConcern: - command_name: distinct - database_name: *database_name - - command_started_event: - command: - distinct: *collection_name - key: _id - lsid: session0 - readConcern: # No readConcern - txnNumber: - $numberLong: "1" - startTransaction: - autocommit: false - writeConcern: - command_name: distinct - database_name: *database_name - - *commitTransactionEvent - - outcome: *outcome - - - description: runCommand ignores database readConcern - - operations: - - *startTransactionNoReadConcern - - name: runCommand - object: database - databaseOptions: - readConcern: - level: majority - command_name: find - arguments: - session: session0 - command: - find: *collection_name - - *runCommand - - *commitTransaction - - expectations: - - command_started_event: - command: - find: *collection_name - lsid: session0 - readConcern: # No readConcern - txnNumber: - $numberLong: "1" - startTransaction: true - autocommit: false - writeConcern: - command_name: find - database_name: *database_name - - command_started_event: - command: - find: *collection_name - lsid: session0 - readConcern: # No readConcern - txnNumber: - $numberLong: "1" - startTransaction: - autocommit: false - writeConcern: - command_name: find - database_name: *database_name - - *commitTransactionEvent - - outcome: *outcome diff --git a/source/transactions/tests/legacy/read-pref.yml b/source/transactions/tests/legacy/read-pref.yml deleted file mode 100644 index 8c5d8ba6a9..0000000000 --- a/source/transactions/tests/legacy/read-pref.yml +++ /dev/null @@ -1,348 +0,0 @@ -# This test doesn't check contents of command-started events. -runOn: - - - minServerVersion: "4.0" - topology: ["replicaset"] - - - minServerVersion: "4.1.8" - topology: ["sharded", "load-balanced"] - -database_name: &database_name "transaction-tests" -collection_name: &collection_name "test" - -data: [] - -tests: - - description: default readPreference - - operations: - - name: startTransaction - object: session0 - - name: insertMany - object: collection - arguments: - documents: &insertedDocs - - _id: 1 - - _id: 2 - - _id: 3 - - _id: 4 - session: session0 - result: - insertedIds: {0: 1, 1: 2, 2: 3, 3: 4} - - name: aggregate - object: collection - collectionOptions: - # The driver overrides the collection's read pref with the - # transaction's so count runs with Primary and succeeds. - readPreference: - mode: Secondary - arguments: - session: session0 - pipeline: - - $match: - _id: 1 - - $count: count - result: - - count: 1 - - name: find - object: collection - collectionOptions: - readPreference: - mode: Secondary - arguments: - session: session0 - batchSize: 3 - result: *insertedDocs - - name: aggregate - object: collection - collectionOptions: - readPreference: - mode: Secondary - arguments: - pipeline: - - $project: - _id: 1 - batchSize: 3 - session: session0 - result: *insertedDocs - - name: commitTransaction - object: session0 - - outcome: - collection: - data: *insertedDocs - - - description: primary readPreference - - operations: - - name: startTransaction - object: session0 - arguments: - options: - readPreference: - mode: Primary - - name: insertMany - object: collection - arguments: - documents: &insertedDocs - - _id: 1 - - _id: 2 - - _id: 3 - - _id: 4 - session: session0 - result: - insertedIds: {0: 1, 1: 2, 2: 3, 3: 4} - - name: aggregate - object: collection - collectionOptions: - readPreference: - mode: Secondary - arguments: - session: session0 - pipeline: - - $match: - _id: 1 - - $count: count - result: - - count: 1 - - name: find - object: collection - collectionOptions: - readPreference: - mode: Secondary - arguments: - session: session0 - batchSize: 3 - result: *insertedDocs - - name: aggregate - object: collection - collectionOptions: - readPreference: - mode: Secondary - arguments: - pipeline: - - $project: - _id: 1 - batchSize: 3 - session: session0 - result: *insertedDocs - - name: commitTransaction - object: session0 - - outcome: - collection: - data: *insertedDocs - - - description: secondary readPreference - - operations: - - name: startTransaction - object: session0 - arguments: - options: - readPreference: - mode: Secondary - - name: insertMany - object: collection - arguments: - documents: &insertedDocs - - _id: 1 - - _id: 2 - - _id: 3 - - _id: 4 - session: session0 - result: - insertedIds: {0: 1, 1: 2, 2: 3, 3: 4} - - name: aggregate - object: collection - collectionOptions: - readPreference: - mode: Primary - arguments: - session: session0 - pipeline: - - $match: - _id: 1 - - $count: count - result: - errorContains: read preference in a transaction must be primary - - name: find - object: collection - collectionOptions: - readPreference: - mode: Primary - arguments: - session: session0 - batchSize: 3 - result: - errorContains: read preference in a transaction must be primary - - name: aggregate - object: collection - collectionOptions: - readPreference: - mode: Primary - arguments: - pipeline: - - $project: - _id: 1 - batchSize: 3 - session: session0 - result: - errorContains: read preference in a transaction must be primary - - name: abortTransaction - object: session0 - - outcome: - collection: - data: [] - - - description: primaryPreferred readPreference - - operations: - - name: startTransaction - object: session0 - arguments: - options: - readPreference: - mode: PrimaryPreferred - - name: insertMany - object: collection - arguments: - documents: &insertedDocs - - _id: 1 - - _id: 2 - - _id: 3 - - _id: 4 - session: session0 - result: - insertedIds: {0: 1, 1: 2, 2: 3, 3: 4} - - name: aggregate - object: collection - collectionOptions: - readPreference: - mode: Primary - arguments: - session: session0 - pipeline: - - $match: - _id: 1 - - $count: count - result: - errorContains: read preference in a transaction must be primary - - name: find - object: collection - collectionOptions: - readPreference: - mode: Primary - arguments: - session: session0 - batchSize: 3 - result: - errorContains: read preference in a transaction must be primary - - name: aggregate - object: collection - collectionOptions: - readPreference: - mode: Primary - arguments: - pipeline: - - $project: - _id: 1 - batchSize: 3 - session: session0 - result: - errorContains: read preference in a transaction must be primary - - name: abortTransaction - object: session0 - - outcome: - collection: - data: [] - - - description: nearest readPreference - - operations: - - name: startTransaction - object: session0 - arguments: - options: - readPreference: - mode: Nearest - - name: insertMany - object: collection - arguments: - documents: &insertedDocs - - _id: 1 - - _id: 2 - - _id: 3 - - _id: 4 - session: session0 - result: - insertedIds: {0: 1, 1: 2, 2: 3, 3: 4} - - name: aggregate - object: collection - collectionOptions: - readPreference: - mode: Primary - arguments: - session: session0 - pipeline: - - $match: - _id: 1 - - $count: count - result: - errorContains: read preference in a transaction must be primary - - name: find - object: collection - collectionOptions: - readPreference: - mode: Primary - arguments: - session: session0 - batchSize: 3 - result: - errorContains: read preference in a transaction must be primary - - name: aggregate - object: collection - collectionOptions: - readPreference: - mode: Primary - arguments: - pipeline: - - $project: - _id: 1 - batchSize: 3 - session: session0 - result: - errorContains: read preference in a transaction must be primary - - name: abortTransaction - object: session0 - - outcome: - collection: - data: [] - - - description: secondary write only - - operations: - - name: startTransaction - object: session0 - arguments: - options: - readPreference: - mode: Secondary - - name: insertOne - object: collection - arguments: - session: session0 - document: - _id: 1 - result: - insertedId: 1 - - name: commitTransaction - object: session0 - - outcome: - collection: - data: - - _id: 1 diff --git a/source/transactions/tests/legacy/reads.json b/source/transactions/tests/legacy/reads.json deleted file mode 100644 index ce9353a66a..0000000000 --- a/source/transactions/tests/legacy/reads.json +++ /dev/null @@ -1,544 +0,0 @@ -{ - "runOn": [ - { - "minServerVersion": "4.0", - "topology": [ - "replicaset" - ] - }, - { - "minServerVersion": "4.1.8", - "topology": [ - "sharded", - "load-balanced" - ] - } - ], - "database_name": "transaction-tests", - "collection_name": "test", - "data": [ - { - "_id": 1 - }, - { - "_id": 2 - }, - { - "_id": 3 - }, - { - "_id": 4 - } - ], - "tests": [ - { - "description": "collection readConcern without transaction", - "operations": [ - { - "name": "find", - "object": "collection", - "collectionOptions": { - "readConcern": { - "level": "majority" - } - }, - "arguments": { - "session": "session0" - }, - "result": [ - { - "_id": 1 - }, - { - "_id": 2 - }, - { - "_id": 3 - }, - { - "_id": 4 - } - ] - } - ], - "expectations": [ - { - "command_started_event": { - "command": { - "find": "test", - "readConcern": { - "level": "majority" - }, - "lsid": "session0", - "txnNumber": null, - "startTransaction": null, - "autocommit": null - }, - "command_name": "find", - "database_name": "transaction-tests" - } - } - ], - "outcome": { - "collection": { - "data": [ - { - "_id": 1 - }, - { - "_id": 2 - }, - { - "_id": 3 - }, - { - "_id": 4 - } - ] - } - } - }, - { - "description": "find", - "operations": [ - { - "name": "startTransaction", - "object": "session0" - }, - { - "name": "find", - "object": "collection", - "arguments": { - "session": "session0", - "batchSize": 3 - }, - "result": [ - { - "_id": 1 - }, - { - "_id": 2 - }, - { - "_id": 3 - }, - { - "_id": 4 - } - ] - }, - { - "name": "find", - "object": "collection", - "arguments": { - "session": "session0", - "batchSize": 3 - }, - "result": [ - { - "_id": 1 - }, - { - "_id": 2 - }, - { - "_id": 3 - }, - { - "_id": 4 - } - ] - }, - { - "name": "commitTransaction", - "object": "session0" - } - ], - "expectations": [ - { - "command_started_event": { - "command": { - "find": "test", - "batchSize": 3, - "readConcern": null, - "lsid": "session0", - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": true, - "autocommit": false - }, - "command_name": "find", - "database_name": "transaction-tests" - } - }, - { - "command_started_event": { - "command": { - "getMore": { - "$numberLong": "42" - }, - "collection": "test", - "batchSize": 3, - "lsid": "session0", - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": null, - "autocommit": false - }, - "command_name": "getMore", - "database_name": "transaction-tests" - } - }, - { - "command_started_event": { - "command": { - "find": "test", - "batchSize": 3, - "lsid": "session0", - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": null, - "autocommit": false - }, - "command_name": "find", - "database_name": "transaction-tests" - } - }, - { - "command_started_event": { - "command": { - "getMore": { - "$numberLong": "42" - }, - "collection": "test", - "batchSize": 3, - "lsid": "session0", - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": null, - "autocommit": false - }, - "command_name": "getMore", - "database_name": "transaction-tests" - } - }, - { - "command_started_event": { - "command": { - "commitTransaction": 1, - "lsid": "session0", - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": null, - "autocommit": false, - "writeConcern": null - }, - "command_name": "commitTransaction", - "database_name": "admin" - } - } - ], - "outcome": { - "collection": { - "data": [ - { - "_id": 1 - }, - { - "_id": 2 - }, - { - "_id": 3 - }, - { - "_id": 4 - } - ] - } - } - }, - { - "description": "aggregate", - "operations": [ - { - "name": "startTransaction", - "object": "session0" - }, - { - "name": "aggregate", - "object": "collection", - "arguments": { - "pipeline": [ - { - "$project": { - "_id": 1 - } - } - ], - "batchSize": 3, - "session": "session0" - }, - "result": [ - { - "_id": 1 - }, - { - "_id": 2 - }, - { - "_id": 3 - }, - { - "_id": 4 - } - ] - }, - { - "name": "aggregate", - "object": "collection", - "arguments": { - "pipeline": [ - { - "$project": { - "_id": 1 - } - } - ], - "batchSize": 3, - "session": "session0" - }, - "result": [ - { - "_id": 1 - }, - { - "_id": 2 - }, - { - "_id": 3 - }, - { - "_id": 4 - } - ] - }, - { - "name": "commitTransaction", - "object": "session0" - } - ], - "expectations": [ - { - "command_started_event": { - "command": { - "aggregate": "test", - "pipeline": [ - { - "$project": { - "_id": 1 - } - } - ], - "cursor": { - "batchSize": 3 - }, - "readConcern": null, - "lsid": "session0", - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": true, - "autocommit": false - }, - "command_name": "aggregate", - "database_name": "transaction-tests" - } - }, - { - "command_started_event": { - "command": { - "getMore": { - "$numberLong": "42" - }, - "collection": "test", - "batchSize": 3, - "lsid": "session0", - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": null, - "autocommit": false - }, - "command_name": "getMore", - "database_name": "transaction-tests" - } - }, - { - "command_started_event": { - "command": { - "aggregate": "test", - "pipeline": [ - { - "$project": { - "_id": 1 - } - } - ], - "cursor": { - "batchSize": 3 - }, - "lsid": "session0", - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": null, - "autocommit": false - }, - "command_name": "aggregate", - "database_name": "transaction-tests" - } - }, - { - "command_started_event": { - "command": { - "getMore": { - "$numberLong": "42" - }, - "collection": "test", - "batchSize": 3, - "lsid": "session0", - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": null, - "autocommit": false - }, - "command_name": "getMore", - "database_name": "transaction-tests" - } - }, - { - "command_started_event": { - "command": { - "commitTransaction": 1, - "lsid": "session0", - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": null, - "autocommit": false, - "writeConcern": null - }, - "command_name": "commitTransaction", - "database_name": "admin" - } - } - ], - "outcome": { - "collection": { - "data": [ - { - "_id": 1 - }, - { - "_id": 2 - }, - { - "_id": 3 - }, - { - "_id": 4 - } - ] - } - } - }, - { - "description": "distinct", - "operations": [ - { - "name": "startTransaction", - "object": "session0" - }, - { - "name": "distinct", - "object": "collection", - "arguments": { - "session": "session0", - "fieldName": "_id" - }, - "result": [ - 1, - 2, - 3, - 4 - ] - }, - { - "name": "commitTransaction", - "object": "session0" - } - ], - "expectations": [ - { - "command_started_event": { - "command": { - "distinct": "test", - "key": "_id", - "lsid": "session0", - "readConcern": null, - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": true, - "autocommit": false, - "writeConcern": null - }, - "command_name": "distinct", - "database_name": "transaction-tests" - } - }, - { - "command_started_event": { - "command": { - "commitTransaction": 1, - "lsid": "session0", - "readConcern": null, - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": null, - "autocommit": false, - "writeConcern": null - }, - "command_name": "commitTransaction", - "database_name": "admin" - } - } - ], - "outcome": { - "collection": { - "data": [ - { - "_id": 1 - }, - { - "_id": 2 - }, - { - "_id": 3 - }, - { - "_id": 4 - } - ] - } - } - } - ] -} diff --git a/source/transactions/tests/legacy/reads.yml b/source/transactions/tests/legacy/reads.yml deleted file mode 100644 index 69c59a3fa0..0000000000 --- a/source/transactions/tests/legacy/reads.yml +++ /dev/null @@ -1,261 +0,0 @@ -runOn: - - - minServerVersion: "4.0" - topology: ["replicaset"] - - - minServerVersion: "4.1.8" - topology: ["sharded", "load-balanced"] - -database_name: &database_name "transaction-tests" -collection_name: &collection_name "test" - -data: &data - - {_id: 1} - - {_id: 2} - - {_id: 3} - - {_id: 4} - -tests: - - description: collection readConcern without transaction - - operations: - - name: find - object: collection - collectionOptions: - readConcern: - level: majority - arguments: - session: session0 - result: *data - - expectations: - - command_started_event: - command: - find: *collection_name - readConcern: - level: majority - lsid: session0 - txnNumber: - startTransaction: - autocommit: - command_name: find - database_name: *database_name - - outcome: &outcome - collection: - data: - *data - - - description: find - - operations: - - &startTransaction - name: startTransaction - object: session0 - - &find - name: find - object: collection - arguments: - session: session0 - batchSize: 3 - result: *data - - *find - - &commitTransaction - name: commitTransaction - object: session0 - - expectations: - - command_started_event: - command: - find: *collection_name - batchSize: 3 - readConcern: - lsid: session0 - txnNumber: - $numberLong: "1" - startTransaction: true - autocommit: false - command_name: find - database_name: *database_name - - command_started_event: - command: - getMore: - # 42 is a fake placeholder value for the cursorId. - $numberLong: '42' - collection: *collection_name - batchSize: 3 - lsid: session0 - txnNumber: - $numberLong: "1" - startTransaction: - autocommit: false - command_name: getMore - database_name: *database_name - - command_started_event: - command: - find: *collection_name - batchSize: 3 - lsid: session0 - txnNumber: - $numberLong: "1" - startTransaction: - autocommit: false - command_name: find - database_name: *database_name - - command_started_event: - command: - getMore: - $numberLong: '42' - collection: *collection_name - batchSize: 3 - lsid: session0 - txnNumber: - $numberLong: "1" - startTransaction: - autocommit: false - command_name: getMore - database_name: *database_name - - command_started_event: - command: - commitTransaction: 1 - lsid: session0 - txnNumber: - $numberLong: "1" - startTransaction: - autocommit: false - writeConcern: - command_name: commitTransaction - database_name: admin - - outcome: *outcome - - - description: aggregate - - operations: - - *startTransaction - - &aggregate - name: aggregate - object: collection - arguments: - pipeline: - - $project: - _id: 1 - batchSize: 3 - session: session0 - result: *data - - *aggregate - - *commitTransaction - - expectations: - - command_started_event: - command: - aggregate: *collection_name - pipeline: - - $project: - _id: 1 - cursor: - batchSize: 3 - readConcern: - lsid: session0 - txnNumber: - $numberLong: "1" - startTransaction: true - autocommit: false - command_name: aggregate - database_name: *database_name - - command_started_event: - command: - getMore: - # 42 is a fake placeholder value for the cursorId. - $numberLong: '42' - collection: *collection_name - batchSize: 3 - lsid: session0 - txnNumber: - $numberLong: "1" - startTransaction: - autocommit: false - command_name: getMore - database_name: *database_name - - command_started_event: - command: - aggregate: *collection_name - pipeline: - - $project: - _id: 1 - cursor: - batchSize: 3 - lsid: session0 - txnNumber: - $numberLong: "1" - startTransaction: - autocommit: false - command_name: aggregate - database_name: *database_name - - command_started_event: - command: - getMore: - $numberLong: '42' - collection: *collection_name - batchSize: 3 - lsid: session0 - txnNumber: - $numberLong: "1" - startTransaction: - autocommit: false - command_name: getMore - database_name: *database_name - - command_started_event: - command: - commitTransaction: 1 - lsid: session0 - txnNumber: - $numberLong: "1" - startTransaction: - autocommit: false - writeConcern: - command_name: commitTransaction - database_name: admin - - outcome: *outcome - - - description: distinct - - operations: - - *startTransaction - - name: distinct - object: collection - arguments: - session: session0 - fieldName: _id - result: [1, 2, 3, 4] - - *commitTransaction - - expectations: - - command_started_event: - command: - distinct: *collection_name - key: _id - lsid: session0 - readConcern: - txnNumber: - $numberLong: "1" - startTransaction: true - autocommit: false - writeConcern: - command_name: distinct - database_name: *database_name - - command_started_event: - command: - commitTransaction: 1 - lsid: session0 - readConcern: - txnNumber: - $numberLong: "1" - startTransaction: - autocommit: false - writeConcern: - command_name: commitTransaction - database_name: admin - - outcome: *outcome diff --git a/source/transactions/tests/legacy/retryable-abort-errorLabels.json b/source/transactions/tests/legacy/retryable-abort-errorLabels.json deleted file mode 100644 index 8e4a50a699..0000000000 --- a/source/transactions/tests/legacy/retryable-abort-errorLabels.json +++ /dev/null @@ -1,1817 +0,0 @@ -{ - "runOn": [ - { - "minServerVersion": "4.3.1", - "topology": [ - "replicaset", - "sharded", - "load-balanced" - ] - } - ], - "database_name": "transaction-tests", - "collection_name": "test", - "data": [], - "tests": [ - { - "description": "abortTransaction only retries once with RetryableWriteError from server", - "failPoint": { - "configureFailPoint": "failCommand", - "mode": { - "times": 2 - }, - "data": { - "failCommands": [ - "abortTransaction" - ], - "errorCode": 112, - "errorLabels": [ - "RetryableWriteError" - ] - } - }, - "operations": [ - { - "name": "startTransaction", - "object": "session0" - }, - { - "name": "insertOne", - "object": "collection", - "arguments": { - "session": "session0", - "document": { - "_id": 1 - } - }, - "result": { - "insertedId": 1 - } - }, - { - "name": "abortTransaction", - "object": "session0" - } - ], - "expectations": [ - { - "command_started_event": { - "command": { - "insert": "test", - "documents": [ - { - "_id": 1 - } - ], - "ordered": true, - "readConcern": null, - "lsid": "session0", - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": true, - "autocommit": false, - "writeConcern": null - }, - "command_name": "insert", - "database_name": "transaction-tests" - } - }, - { - "command_started_event": { - "command": { - "abortTransaction": 1, - "lsid": "session0", - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": null, - "autocommit": false, - "writeConcern": null - }, - "command_name": "abortTransaction", - "database_name": "admin" - } - }, - { - "command_started_event": { - "command": { - "abortTransaction": 1, - "lsid": "session0", - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": null, - "autocommit": false, - "writeConcern": null - }, - "command_name": "abortTransaction", - "database_name": "admin" - } - } - ], - "outcome": { - "collection": { - "data": [] - } - } - }, - { - "description": "abortTransaction does not retry without RetryableWriteError label", - "failPoint": { - "configureFailPoint": "failCommand", - "mode": { - "times": 1 - }, - "data": { - "failCommands": [ - "abortTransaction" - ], - "errorCode": 11600, - "errorLabels": [] - } - }, - "operations": [ - { - "name": "startTransaction", - "object": "session0" - }, - { - "name": "insertOne", - "object": "collection", - "arguments": { - "session": "session0", - "document": { - "_id": 1 - } - }, - "result": { - "insertedId": 1 - } - }, - { - "name": "abortTransaction", - "object": "session0" - } - ], - "expectations": [ - { - "command_started_event": { - "command": { - "insert": "test", - "documents": [ - { - "_id": 1 - } - ], - "ordered": true, - "readConcern": null, - "lsid": "session0", - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": true, - "autocommit": false, - "writeConcern": null - }, - "command_name": "insert", - "database_name": "transaction-tests" - } - }, - { - "command_started_event": { - "command": { - "abortTransaction": 1, - "lsid": "session0", - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": null, - "autocommit": false, - "writeConcern": null - }, - "command_name": "abortTransaction", - "database_name": "admin" - } - } - ], - "outcome": { - "collection": { - "data": [] - } - } - }, - { - "description": "abortTransaction succeeds after NotWritablePrimary", - "failPoint": { - "configureFailPoint": "failCommand", - "mode": { - "times": 1 - }, - "data": { - "failCommands": [ - "abortTransaction" - ], - "errorCode": 10107, - "errorLabels": [ - "RetryableWriteError" - ], - "closeConnection": false - } - }, - "operations": [ - { - "name": "startTransaction", - "object": "session0" - }, - { - "name": "insertOne", - "object": "collection", - "arguments": { - "session": "session0", - "document": { - "_id": 1 - } - }, - "result": { - "insertedId": 1 - } - }, - { - "name": "abortTransaction", - "object": "session0" - } - ], - "expectations": [ - { - "command_started_event": { - "command": { - "insert": "test", - "documents": [ - { - "_id": 1 - } - ], - "ordered": true, - "readConcern": null, - "lsid": "session0", - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": true, - "autocommit": false, - "writeConcern": null - }, - "command_name": "insert", - "database_name": "transaction-tests" - } - }, - { - "command_started_event": { - "command": { - "abortTransaction": 1, - "lsid": "session0", - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": null, - "autocommit": false, - "writeConcern": null - }, - "command_name": "abortTransaction", - "database_name": "admin" - } - }, - { - "command_started_event": { - "command": { - "abortTransaction": 1, - "lsid": "session0", - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": null, - "autocommit": false, - "writeConcern": null - }, - "command_name": "abortTransaction", - "database_name": "admin" - } - } - ], - "outcome": { - "collection": { - "data": [] - } - } - }, - { - "description": "abortTransaction succeeds after NotPrimaryOrSecondary", - "failPoint": { - "configureFailPoint": "failCommand", - "mode": { - "times": 1 - }, - "data": { - "failCommands": [ - "abortTransaction" - ], - "errorCode": 13436, - "errorLabels": [ - "RetryableWriteError" - ], - "closeConnection": false - } - }, - "operations": [ - { - "name": "startTransaction", - "object": "session0" - }, - { - "name": "insertOne", - "object": "collection", - "arguments": { - "session": "session0", - "document": { - "_id": 1 - } - }, - "result": { - "insertedId": 1 - } - }, - { - "name": "abortTransaction", - "object": "session0" - } - ], - "expectations": [ - { - "command_started_event": { - "command": { - "insert": "test", - "documents": [ - { - "_id": 1 - } - ], - "ordered": true, - "readConcern": null, - "lsid": "session0", - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": true, - "autocommit": false, - "writeConcern": null - }, - "command_name": "insert", - "database_name": "transaction-tests" - } - }, - { - "command_started_event": { - "command": { - "abortTransaction": 1, - "lsid": "session0", - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": null, - "autocommit": false, - "writeConcern": null - }, - "command_name": "abortTransaction", - "database_name": "admin" - } - }, - { - "command_started_event": { - "command": { - "abortTransaction": 1, - "lsid": "session0", - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": null, - "autocommit": false, - "writeConcern": null - }, - "command_name": "abortTransaction", - "database_name": "admin" - } - } - ], - "outcome": { - "collection": { - "data": [] - } - } - }, - { - "description": "abortTransaction succeeds after NotPrimaryNoSecondaryOk", - "failPoint": { - "configureFailPoint": "failCommand", - "mode": { - "times": 1 - }, - "data": { - "failCommands": [ - "abortTransaction" - ], - "errorCode": 13435, - "errorLabels": [ - "RetryableWriteError" - ], - "closeConnection": false - } - }, - "operations": [ - { - "name": "startTransaction", - "object": "session0" - }, - { - "name": "insertOne", - "object": "collection", - "arguments": { - "session": "session0", - "document": { - "_id": 1 - } - }, - "result": { - "insertedId": 1 - } - }, - { - "name": "abortTransaction", - "object": "session0" - } - ], - "expectations": [ - { - "command_started_event": { - "command": { - "insert": "test", - "documents": [ - { - "_id": 1 - } - ], - "ordered": true, - "readConcern": null, - "lsid": "session0", - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": true, - "autocommit": false, - "writeConcern": null - }, - "command_name": "insert", - "database_name": "transaction-tests" - } - }, - { - "command_started_event": { - "command": { - "abortTransaction": 1, - "lsid": "session0", - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": null, - "autocommit": false, - "writeConcern": null - }, - "command_name": "abortTransaction", - "database_name": "admin" - } - }, - { - "command_started_event": { - "command": { - "abortTransaction": 1, - "lsid": "session0", - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": null, - "autocommit": false, - "writeConcern": null - }, - "command_name": "abortTransaction", - "database_name": "admin" - } - } - ], - "outcome": { - "collection": { - "data": [] - } - } - }, - { - "description": "abortTransaction succeeds after InterruptedDueToReplStateChange", - "failPoint": { - "configureFailPoint": "failCommand", - "mode": { - "times": 1 - }, - "data": { - "failCommands": [ - "abortTransaction" - ], - "errorCode": 11602, - "errorLabels": [ - "RetryableWriteError" - ], - "closeConnection": false - } - }, - "operations": [ - { - "name": "startTransaction", - "object": "session0" - }, - { - "name": "insertOne", - "object": "collection", - "arguments": { - "session": "session0", - "document": { - "_id": 1 - } - }, - "result": { - "insertedId": 1 - } - }, - { - "name": "abortTransaction", - "object": "session0" - } - ], - "expectations": [ - { - "command_started_event": { - "command": { - "insert": "test", - "documents": [ - { - "_id": 1 - } - ], - "ordered": true, - "readConcern": null, - "lsid": "session0", - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": true, - "autocommit": false, - "writeConcern": null - }, - "command_name": "insert", - "database_name": "transaction-tests" - } - }, - { - "command_started_event": { - "command": { - "abortTransaction": 1, - "lsid": "session0", - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": null, - "autocommit": false, - "writeConcern": null - }, - "command_name": "abortTransaction", - "database_name": "admin" - } - }, - { - "command_started_event": { - "command": { - "abortTransaction": 1, - "lsid": "session0", - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": null, - "autocommit": false, - "writeConcern": null - }, - "command_name": "abortTransaction", - "database_name": "admin" - } - } - ], - "outcome": { - "collection": { - "data": [] - } - } - }, - { - "description": "abortTransaction succeeds after InterruptedAtShutdown", - "failPoint": { - "configureFailPoint": "failCommand", - "mode": { - "times": 1 - }, - "data": { - "failCommands": [ - "abortTransaction" - ], - "errorCode": 11600, - "errorLabels": [ - "RetryableWriteError" - ], - "closeConnection": false - } - }, - "operations": [ - { - "name": "startTransaction", - "object": "session0" - }, - { - "name": "insertOne", - "object": "collection", - "arguments": { - "session": "session0", - "document": { - "_id": 1 - } - }, - "result": { - "insertedId": 1 - } - }, - { - "name": "abortTransaction", - "object": "session0" - } - ], - "expectations": [ - { - "command_started_event": { - "command": { - "insert": "test", - "documents": [ - { - "_id": 1 - } - ], - "ordered": true, - "readConcern": null, - "lsid": "session0", - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": true, - "autocommit": false, - "writeConcern": null - }, - "command_name": "insert", - "database_name": "transaction-tests" - } - }, - { - "command_started_event": { - "command": { - "abortTransaction": 1, - "lsid": "session0", - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": null, - "autocommit": false, - "writeConcern": null - }, - "command_name": "abortTransaction", - "database_name": "admin" - } - }, - { - "command_started_event": { - "command": { - "abortTransaction": 1, - "lsid": "session0", - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": null, - "autocommit": false, - "writeConcern": null - }, - "command_name": "abortTransaction", - "database_name": "admin" - } - } - ], - "outcome": { - "collection": { - "data": [] - } - } - }, - { - "description": "abortTransaction succeeds after PrimarySteppedDown", - "failPoint": { - "configureFailPoint": "failCommand", - "mode": { - "times": 1 - }, - "data": { - "failCommands": [ - "abortTransaction" - ], - "errorCode": 189, - "errorLabels": [ - "RetryableWriteError" - ], - "closeConnection": false - } - }, - "operations": [ - { - "name": "startTransaction", - "object": "session0" - }, - { - "name": "insertOne", - "object": "collection", - "arguments": { - "session": "session0", - "document": { - "_id": 1 - } - }, - "result": { - "insertedId": 1 - } - }, - { - "name": "abortTransaction", - "object": "session0" - } - ], - "expectations": [ - { - "command_started_event": { - "command": { - "insert": "test", - "documents": [ - { - "_id": 1 - } - ], - "ordered": true, - "readConcern": null, - "lsid": "session0", - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": true, - "autocommit": false, - "writeConcern": null - }, - "command_name": "insert", - "database_name": "transaction-tests" - } - }, - { - "command_started_event": { - "command": { - "abortTransaction": 1, - "lsid": "session0", - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": null, - "autocommit": false, - "writeConcern": null - }, - "command_name": "abortTransaction", - "database_name": "admin" - } - }, - { - "command_started_event": { - "command": { - "abortTransaction": 1, - "lsid": "session0", - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": null, - "autocommit": false, - "writeConcern": null - }, - "command_name": "abortTransaction", - "database_name": "admin" - } - } - ], - "outcome": { - "collection": { - "data": [] - } - } - }, - { - "description": "abortTransaction succeeds after ShutdownInProgress", - "failPoint": { - "configureFailPoint": "failCommand", - "mode": { - "times": 1 - }, - "data": { - "failCommands": [ - "abortTransaction" - ], - "errorCode": 91, - "errorLabels": [ - "RetryableWriteError" - ], - "closeConnection": false - } - }, - "operations": [ - { - "name": "startTransaction", - "object": "session0" - }, - { - "name": "insertOne", - "object": "collection", - "arguments": { - "session": "session0", - "document": { - "_id": 1 - } - }, - "result": { - "insertedId": 1 - } - }, - { - "name": "abortTransaction", - "object": "session0" - } - ], - "expectations": [ - { - "command_started_event": { - "command": { - "insert": "test", - "documents": [ - { - "_id": 1 - } - ], - "ordered": true, - "readConcern": null, - "lsid": "session0", - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": true, - "autocommit": false, - "writeConcern": null - }, - "command_name": "insert", - "database_name": "transaction-tests" - } - }, - { - "command_started_event": { - "command": { - "abortTransaction": 1, - "lsid": "session0", - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": null, - "autocommit": false, - "writeConcern": null - }, - "command_name": "abortTransaction", - "database_name": "admin" - } - }, - { - "command_started_event": { - "command": { - "abortTransaction": 1, - "lsid": "session0", - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": null, - "autocommit": false, - "writeConcern": null - }, - "command_name": "abortTransaction", - "database_name": "admin" - } - } - ], - "outcome": { - "collection": { - "data": [] - } - } - }, - { - "description": "abortTransaction succeeds after HostNotFound", - "failPoint": { - "configureFailPoint": "failCommand", - "mode": { - "times": 1 - }, - "data": { - "failCommands": [ - "abortTransaction" - ], - "errorCode": 7, - "errorLabels": [ - "RetryableWriteError" - ], - "closeConnection": false - } - }, - "operations": [ - { - "name": "startTransaction", - "object": "session0" - }, - { - "name": "insertOne", - "object": "collection", - "arguments": { - "session": "session0", - "document": { - "_id": 1 - } - }, - "result": { - "insertedId": 1 - } - }, - { - "name": "abortTransaction", - "object": "session0" - } - ], - "expectations": [ - { - "command_started_event": { - "command": { - "insert": "test", - "documents": [ - { - "_id": 1 - } - ], - "ordered": true, - "readConcern": null, - "lsid": "session0", - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": true, - "autocommit": false, - "writeConcern": null - }, - "command_name": "insert", - "database_name": "transaction-tests" - } - }, - { - "command_started_event": { - "command": { - "abortTransaction": 1, - "lsid": "session0", - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": null, - "autocommit": false, - "writeConcern": null - }, - "command_name": "abortTransaction", - "database_name": "admin" - } - }, - { - "command_started_event": { - "command": { - "abortTransaction": 1, - "lsid": "session0", - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": null, - "autocommit": false, - "writeConcern": null - }, - "command_name": "abortTransaction", - "database_name": "admin" - } - } - ], - "outcome": { - "collection": { - "data": [] - } - } - }, - { - "description": "abortTransaction succeeds after HostUnreachable", - "failPoint": { - "configureFailPoint": "failCommand", - "mode": { - "times": 1 - }, - "data": { - "failCommands": [ - "abortTransaction" - ], - "errorCode": 6, - "errorLabels": [ - "RetryableWriteError" - ], - "closeConnection": false - } - }, - "operations": [ - { - "name": "startTransaction", - "object": "session0" - }, - { - "name": "insertOne", - "object": "collection", - "arguments": { - "session": "session0", - "document": { - "_id": 1 - } - }, - "result": { - "insertedId": 1 - } - }, - { - "name": "abortTransaction", - "object": "session0" - } - ], - "expectations": [ - { - "command_started_event": { - "command": { - "insert": "test", - "documents": [ - { - "_id": 1 - } - ], - "ordered": true, - "readConcern": null, - "lsid": "session0", - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": true, - "autocommit": false, - "writeConcern": null - }, - "command_name": "insert", - "database_name": "transaction-tests" - } - }, - { - "command_started_event": { - "command": { - "abortTransaction": 1, - "lsid": "session0", - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": null, - "autocommit": false, - "writeConcern": null - }, - "command_name": "abortTransaction", - "database_name": "admin" - } - }, - { - "command_started_event": { - "command": { - "abortTransaction": 1, - "lsid": "session0", - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": null, - "autocommit": false, - "writeConcern": null - }, - "command_name": "abortTransaction", - "database_name": "admin" - } - } - ], - "outcome": { - "collection": { - "data": [] - } - } - }, - { - "description": "abortTransaction succeeds after SocketException", - "failPoint": { - "configureFailPoint": "failCommand", - "mode": { - "times": 1 - }, - "data": { - "failCommands": [ - "abortTransaction" - ], - "errorCode": 9001, - "errorLabels": [ - "RetryableWriteError" - ], - "closeConnection": false - } - }, - "operations": [ - { - "name": "startTransaction", - "object": "session0" - }, - { - "name": "insertOne", - "object": "collection", - "arguments": { - "session": "session0", - "document": { - "_id": 1 - } - }, - "result": { - "insertedId": 1 - } - }, - { - "name": "abortTransaction", - "object": "session0" - } - ], - "expectations": [ - { - "command_started_event": { - "command": { - "insert": "test", - "documents": [ - { - "_id": 1 - } - ], - "ordered": true, - "readConcern": null, - "lsid": "session0", - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": true, - "autocommit": false, - "writeConcern": null - }, - "command_name": "insert", - "database_name": "transaction-tests" - } - }, - { - "command_started_event": { - "command": { - "abortTransaction": 1, - "lsid": "session0", - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": null, - "autocommit": false, - "writeConcern": null - }, - "command_name": "abortTransaction", - "database_name": "admin" - } - }, - { - "command_started_event": { - "command": { - "abortTransaction": 1, - "lsid": "session0", - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": null, - "autocommit": false, - "writeConcern": null - }, - "command_name": "abortTransaction", - "database_name": "admin" - } - } - ], - "outcome": { - "collection": { - "data": [] - } - } - }, - { - "description": "abortTransaction succeeds after NetworkTimeout", - "failPoint": { - "configureFailPoint": "failCommand", - "mode": { - "times": 1 - }, - "data": { - "failCommands": [ - "abortTransaction" - ], - "errorCode": 89, - "errorLabels": [ - "RetryableWriteError" - ], - "closeConnection": false - } - }, - "operations": [ - { - "name": "startTransaction", - "object": "session0" - }, - { - "name": "insertOne", - "object": "collection", - "arguments": { - "session": "session0", - "document": { - "_id": 1 - } - }, - "result": { - "insertedId": 1 - } - }, - { - "name": "abortTransaction", - "object": "session0" - } - ], - "expectations": [ - { - "command_started_event": { - "command": { - "insert": "test", - "documents": [ - { - "_id": 1 - } - ], - "ordered": true, - "readConcern": null, - "lsid": "session0", - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": true, - "autocommit": false, - "writeConcern": null - }, - "command_name": "insert", - "database_name": "transaction-tests" - } - }, - { - "command_started_event": { - "command": { - "abortTransaction": 1, - "lsid": "session0", - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": null, - "autocommit": false, - "writeConcern": null - }, - "command_name": "abortTransaction", - "database_name": "admin" - } - }, - { - "command_started_event": { - "command": { - "abortTransaction": 1, - "lsid": "session0", - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": null, - "autocommit": false, - "writeConcern": null - }, - "command_name": "abortTransaction", - "database_name": "admin" - } - } - ], - "outcome": { - "collection": { - "data": [] - } - } - }, - { - "description": "abortTransaction succeeds after WriteConcernError InterruptedAtShutdown", - "failPoint": { - "configureFailPoint": "failCommand", - "mode": { - "times": 1 - }, - "data": { - "failCommands": [ - "abortTransaction" - ], - "errorLabels": [ - "RetryableWriteError" - ], - "writeConcernError": { - "code": 11600, - "errmsg": "Replication is being shut down" - } - } - }, - "operations": [ - { - "name": "startTransaction", - "object": "session0", - "arguments": { - "options": { - "writeConcern": { - "w": "majority" - } - } - } - }, - { - "name": "insertOne", - "object": "collection", - "arguments": { - "session": "session0", - "document": { - "_id": 1 - } - }, - "result": { - "insertedId": 1 - } - }, - { - "name": "abortTransaction", - "object": "session0" - } - ], - "expectations": [ - { - "command_started_event": { - "command": { - "insert": "test", - "documents": [ - { - "_id": 1 - } - ], - "ordered": true, - "readConcern": null, - "lsid": "session0", - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": true, - "autocommit": false, - "writeConcern": null - }, - "command_name": "insert", - "database_name": "transaction-tests" - } - }, - { - "command_started_event": { - "command": { - "abortTransaction": 1, - "lsid": "session0", - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": null, - "autocommit": false, - "writeConcern": { - "w": "majority" - } - }, - "command_name": "abortTransaction", - "database_name": "admin" - } - }, - { - "command_started_event": { - "command": { - "abortTransaction": 1, - "lsid": "session0", - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": null, - "autocommit": false, - "writeConcern": { - "w": "majority" - } - }, - "command_name": "abortTransaction", - "database_name": "admin" - } - } - ], - "outcome": { - "collection": { - "data": [] - } - } - }, - { - "description": "abortTransaction succeeds after WriteConcernError InterruptedDueToReplStateChange", - "failPoint": { - "configureFailPoint": "failCommand", - "mode": { - "times": 1 - }, - "data": { - "failCommands": [ - "abortTransaction" - ], - "errorLabels": [ - "RetryableWriteError" - ], - "writeConcernError": { - "code": 11602, - "errmsg": "Replication is being shut down" - } - } - }, - "operations": [ - { - "name": "startTransaction", - "object": "session0", - "arguments": { - "options": { - "writeConcern": { - "w": "majority" - } - } - } - }, - { - "name": "insertOne", - "object": "collection", - "arguments": { - "session": "session0", - "document": { - "_id": 1 - } - }, - "result": { - "insertedId": 1 - } - }, - { - "name": "abortTransaction", - "object": "session0" - } - ], - "expectations": [ - { - "command_started_event": { - "command": { - "insert": "test", - "documents": [ - { - "_id": 1 - } - ], - "ordered": true, - "readConcern": null, - "lsid": "session0", - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": true, - "autocommit": false, - "writeConcern": null - }, - "command_name": "insert", - "database_name": "transaction-tests" - } - }, - { - "command_started_event": { - "command": { - "abortTransaction": 1, - "lsid": "session0", - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": null, - "autocommit": false, - "writeConcern": { - "w": "majority" - } - }, - "command_name": "abortTransaction", - "database_name": "admin" - } - }, - { - "command_started_event": { - "command": { - "abortTransaction": 1, - "lsid": "session0", - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": null, - "autocommit": false, - "writeConcern": { - "w": "majority" - } - }, - "command_name": "abortTransaction", - "database_name": "admin" - } - } - ], - "outcome": { - "collection": { - "data": [] - } - } - }, - { - "description": "abortTransaction succeeds after WriteConcernError PrimarySteppedDown", - "failPoint": { - "configureFailPoint": "failCommand", - "mode": { - "times": 1 - }, - "data": { - "failCommands": [ - "abortTransaction" - ], - "errorLabels": [ - "RetryableWriteError" - ], - "writeConcernError": { - "code": 189, - "errmsg": "Replication is being shut down" - } - } - }, - "operations": [ - { - "name": "startTransaction", - "object": "session0", - "arguments": { - "options": { - "writeConcern": { - "w": "majority" - } - } - } - }, - { - "name": "insertOne", - "object": "collection", - "arguments": { - "session": "session0", - "document": { - "_id": 1 - } - }, - "result": { - "insertedId": 1 - } - }, - { - "name": "abortTransaction", - "object": "session0" - } - ], - "expectations": [ - { - "command_started_event": { - "command": { - "insert": "test", - "documents": [ - { - "_id": 1 - } - ], - "ordered": true, - "readConcern": null, - "lsid": "session0", - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": true, - "autocommit": false, - "writeConcern": null - }, - "command_name": "insert", - "database_name": "transaction-tests" - } - }, - { - "command_started_event": { - "command": { - "abortTransaction": 1, - "lsid": "session0", - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": null, - "autocommit": false, - "writeConcern": { - "w": "majority" - } - }, - "command_name": "abortTransaction", - "database_name": "admin" - } - }, - { - "command_started_event": { - "command": { - "abortTransaction": 1, - "lsid": "session0", - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": null, - "autocommit": false, - "writeConcern": { - "w": "majority" - } - }, - "command_name": "abortTransaction", - "database_name": "admin" - } - } - ], - "outcome": { - "collection": { - "data": [] - } - } - }, - { - "description": "abortTransaction succeeds after WriteConcernError ShutdownInProgress", - "failPoint": { - "configureFailPoint": "failCommand", - "mode": { - "times": 1 - }, - "data": { - "failCommands": [ - "abortTransaction" - ], - "errorLabels": [ - "RetryableWriteError" - ], - "writeConcernError": { - "code": 91, - "errmsg": "Replication is being shut down" - } - } - }, - "operations": [ - { - "name": "startTransaction", - "object": "session0", - "arguments": { - "options": { - "writeConcern": { - "w": "majority" - } - } - } - }, - { - "name": "insertOne", - "object": "collection", - "arguments": { - "session": "session0", - "document": { - "_id": 1 - } - }, - "result": { - "insertedId": 1 - } - }, - { - "name": "abortTransaction", - "object": "session0" - } - ], - "expectations": [ - { - "command_started_event": { - "command": { - "insert": "test", - "documents": [ - { - "_id": 1 - } - ], - "ordered": true, - "readConcern": null, - "lsid": "session0", - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": true, - "autocommit": false, - "writeConcern": null - }, - "command_name": "insert", - "database_name": "transaction-tests" - } - }, - { - "command_started_event": { - "command": { - "abortTransaction": 1, - "lsid": "session0", - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": null, - "autocommit": false, - "writeConcern": { - "w": "majority" - } - }, - "command_name": "abortTransaction", - "database_name": "admin" - } - }, - { - "command_started_event": { - "command": { - "abortTransaction": 1, - "lsid": "session0", - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": null, - "autocommit": false, - "writeConcern": { - "w": "majority" - } - }, - "command_name": "abortTransaction", - "database_name": "admin" - } - } - ], - "outcome": { - "collection": { - "data": [] - } - } - } - ] -} diff --git a/source/transactions/tests/legacy/retryable-abort-errorLabels.yml b/source/transactions/tests/legacy/retryable-abort-errorLabels.yml deleted file mode 100644 index 83f9a78c49..0000000000 --- a/source/transactions/tests/legacy/retryable-abort-errorLabels.yml +++ /dev/null @@ -1,1112 +0,0 @@ -runOn: - - - minServerVersion: "4.3.1" # failCommand errorLabels option - topology: ["replicaset", "sharded", "load-balanced"] - -database_name: &database_name "transaction-tests" -collection_name: &collection_name "test" - -data: [] -tests: - - description: abortTransaction only retries once with RetryableWriteError from server - failPoint: - configureFailPoint: failCommand - mode: { times: 2 } - data: - failCommands: ["abortTransaction"] - errorCode: 112 # WriteConflict, not a retryable error code - errorLabels: ["RetryableWriteError"] # Override server behavior: send RetryableWriteError label with non-retryable error code - operations: - - name: startTransaction - object: session0 - - name: insertOne - object: collection - arguments: - session: session0 - document: - _id: 1 - result: - insertedId: 1 - - name: abortTransaction - object: session0 - expectations: - - command_started_event: - command: - insert: *collection_name - documents: - - _id: 1 - ordered: true - readConcern: - lsid: session0 - txnNumber: - $numberLong: "1" - startTransaction: true - autocommit: false - writeConcern: - command_name: insert - database_name: *database_name - - command_started_event: - command: - abortTransaction: 1 - lsid: session0 - txnNumber: - $numberLong: "1" - startTransaction: - autocommit: false - writeConcern: - command_name: abortTransaction - database_name: admin - - command_started_event: # Driver retries abort once - command: - abortTransaction: 1 - lsid: session0 - txnNumber: - $numberLong: "1" - startTransaction: - autocommit: false - writeConcern: - command_name: abortTransaction - database_name: admin - outcome: - collection: - data: [] - - - description: abortTransaction does not retry without RetryableWriteError label - failPoint: - configureFailPoint: failCommand - mode: { times: 1 } - data: - failCommands: ["abortTransaction"] - errorCode: 11600 # InterruptedAtShutdown, normally a retryable error code - errorLabels: [] # Override server behavior: do not send RetryableWriteError label with retryable code - operations: - - name: startTransaction - object: session0 - - name: insertOne - object: collection - arguments: - session: session0 - document: - _id: 1 - result: - insertedId: 1 - - name: abortTransaction - object: session0 - expectations: - - command_started_event: - command: - insert: *collection_name - documents: - - _id: 1 - ordered: true - readConcern: - lsid: session0 - txnNumber: - $numberLong: "1" - startTransaction: true - autocommit: false - writeConcern: - command_name: insert - database_name: *database_name - - command_started_event: - command: - abortTransaction: 1 - lsid: session0 - txnNumber: - $numberLong: "1" - startTransaction: - autocommit: false - writeConcern: - command_name: abortTransaction - database_name: admin - outcome: # Driver does not retry abort - collection: - data: [] - - - description: abortTransaction succeeds after NotWritablePrimary - failPoint: - configureFailPoint: failCommand - mode: { times: 1 } - data: - failCommands: ["abortTransaction"] - errorCode: 10107 - errorLabels: ["RetryableWriteError"] - closeConnection: false - operations: - - name: startTransaction - object: session0 - - name: insertOne - object: collection - arguments: - session: session0 - document: - _id: 1 - result: - insertedId: 1 - - name: abortTransaction - object: session0 - expectations: - - command_started_event: - command: - insert: *collection_name - documents: - - _id: 1 - ordered: true - readConcern: - lsid: session0 - txnNumber: - $numberLong: "1" - startTransaction: true - autocommit: false - writeConcern: - command_name: insert - database_name: *database_name - - command_started_event: - command: - abortTransaction: 1 - lsid: session0 - txnNumber: - $numberLong: "1" - startTransaction: - autocommit: false - writeConcern: - command_name: abortTransaction - database_name: admin - - command_started_event: - command: - abortTransaction: 1 - lsid: session0 - txnNumber: - $numberLong: "1" - startTransaction: - autocommit: false - writeConcern: - command_name: abortTransaction - database_name: admin - outcome: - collection: - data: [] - - - description: abortTransaction succeeds after NotPrimaryOrSecondary - failPoint: - configureFailPoint: failCommand - mode: { times: 1 } - data: - failCommands: ["abortTransaction"] - errorCode: 13436 - errorLabels: ["RetryableWriteError"] - closeConnection: false - operations: - - name: startTransaction - object: session0 - - name: insertOne - object: collection - arguments: - session: session0 - document: - _id: 1 - result: - insertedId: 1 - - name: abortTransaction - object: session0 - expectations: - - command_started_event: - command: - insert: *collection_name - documents: - - _id: 1 - ordered: true - readConcern: - lsid: session0 - txnNumber: - $numberLong: "1" - startTransaction: true - autocommit: false - writeConcern: - command_name: insert - database_name: *database_name - - command_started_event: - command: - abortTransaction: 1 - lsid: session0 - txnNumber: - $numberLong: "1" - startTransaction: - autocommit: false - writeConcern: - command_name: abortTransaction - database_name: admin - - command_started_event: - command: - abortTransaction: 1 - lsid: session0 - txnNumber: - $numberLong: "1" - startTransaction: - autocommit: false - writeConcern: - command_name: abortTransaction - database_name: admin - outcome: - collection: - data: [] - - - description: abortTransaction succeeds after NotPrimaryNoSecondaryOk - failPoint: - configureFailPoint: failCommand - mode: { times: 1 } - data: - failCommands: ["abortTransaction"] - errorCode: 13435 - errorLabels: ["RetryableWriteError"] - closeConnection: false - operations: - - name: startTransaction - object: session0 - - name: insertOne - object: collection - arguments: - session: session0 - document: - _id: 1 - result: - insertedId: 1 - - name: abortTransaction - object: session0 - expectations: - - command_started_event: - command: - insert: *collection_name - documents: - - _id: 1 - ordered: true - readConcern: - lsid: session0 - txnNumber: - $numberLong: "1" - startTransaction: true - autocommit: false - writeConcern: - command_name: insert - database_name: *database_name - - command_started_event: - command: - abortTransaction: 1 - lsid: session0 - txnNumber: - $numberLong: "1" - startTransaction: - autocommit: false - writeConcern: - command_name: abortTransaction - database_name: admin - - command_started_event: - command: - abortTransaction: 1 - lsid: session0 - txnNumber: - $numberLong: "1" - startTransaction: - autocommit: false - writeConcern: - command_name: abortTransaction - database_name: admin - outcome: - collection: - data: [] - - - description: abortTransaction succeeds after InterruptedDueToReplStateChange - failPoint: - configureFailPoint: failCommand - mode: { times: 1 } - data: - failCommands: ["abortTransaction"] - errorCode: 11602 - errorLabels: ["RetryableWriteError"] - closeConnection: false - operations: - - name: startTransaction - object: session0 - - name: insertOne - object: collection - arguments: - session: session0 - document: - _id: 1 - result: - insertedId: 1 - - name: abortTransaction - object: session0 - expectations: - - command_started_event: - command: - insert: *collection_name - documents: - - _id: 1 - ordered: true - readConcern: - lsid: session0 - txnNumber: - $numberLong: "1" - startTransaction: true - autocommit: false - writeConcern: - command_name: insert - database_name: *database_name - - command_started_event: - command: - abortTransaction: 1 - lsid: session0 - txnNumber: - $numberLong: "1" - startTransaction: - autocommit: false - writeConcern: - command_name: abortTransaction - database_name: admin - - command_started_event: - command: - abortTransaction: 1 - lsid: session0 - txnNumber: - $numberLong: "1" - startTransaction: - autocommit: false - writeConcern: - command_name: abortTransaction - database_name: admin - outcome: - collection: - data: [] - - - description: abortTransaction succeeds after InterruptedAtShutdown - failPoint: - configureFailPoint: failCommand - mode: { times: 1 } - data: - failCommands: ["abortTransaction"] - errorCode: 11600 - errorLabels: ["RetryableWriteError"] - closeConnection: false - operations: - - name: startTransaction - object: session0 - - name: insertOne - object: collection - arguments: - session: session0 - document: - _id: 1 - result: - insertedId: 1 - - name: abortTransaction - object: session0 - expectations: - - command_started_event: - command: - insert: *collection_name - documents: - - _id: 1 - ordered: true - readConcern: - lsid: session0 - txnNumber: - $numberLong: "1" - startTransaction: true - autocommit: false - writeConcern: - command_name: insert - database_name: *database_name - - command_started_event: - command: - abortTransaction: 1 - lsid: session0 - txnNumber: - $numberLong: "1" - startTransaction: - autocommit: false - writeConcern: - command_name: abortTransaction - database_name: admin - - command_started_event: - command: - abortTransaction: 1 - lsid: session0 - txnNumber: - $numberLong: "1" - startTransaction: - autocommit: false - writeConcern: - command_name: abortTransaction - database_name: admin - outcome: - collection: - data: [] - - - description: abortTransaction succeeds after PrimarySteppedDown - failPoint: - configureFailPoint: failCommand - mode: { times: 1 } - data: - failCommands: ["abortTransaction"] - errorCode: 189 - errorLabels: ["RetryableWriteError"] - closeConnection: false - operations: - - name: startTransaction - object: session0 - - name: insertOne - object: collection - arguments: - session: session0 - document: - _id: 1 - result: - insertedId: 1 - - name: abortTransaction - object: session0 - expectations: - - command_started_event: - command: - insert: *collection_name - documents: - - _id: 1 - ordered: true - readConcern: - lsid: session0 - txnNumber: - $numberLong: "1" - startTransaction: true - autocommit: false - writeConcern: - command_name: insert - database_name: *database_name - - command_started_event: - command: - abortTransaction: 1 - lsid: session0 - txnNumber: - $numberLong: "1" - startTransaction: - autocommit: false - writeConcern: - command_name: abortTransaction - database_name: admin - - command_started_event: - command: - abortTransaction: 1 - lsid: session0 - txnNumber: - $numberLong: "1" - startTransaction: - autocommit: false - writeConcern: - command_name: abortTransaction - database_name: admin - outcome: - collection: - data: [] - - - description: abortTransaction succeeds after ShutdownInProgress - failPoint: - configureFailPoint: failCommand - mode: { times: 1 } - data: - failCommands: ["abortTransaction"] - errorCode: 91 - errorLabels: ["RetryableWriteError"] - closeConnection: false - operations: - - name: startTransaction - object: session0 - - name: insertOne - object: collection - arguments: - session: session0 - document: - _id: 1 - result: - insertedId: 1 - - name: abortTransaction - object: session0 - expectations: - - command_started_event: - command: - insert: *collection_name - documents: - - _id: 1 - ordered: true - readConcern: - lsid: session0 - txnNumber: - $numberLong: "1" - startTransaction: true - autocommit: false - writeConcern: - command_name: insert - database_name: *database_name - - command_started_event: - command: - abortTransaction: 1 - lsid: session0 - txnNumber: - $numberLong: "1" - startTransaction: - autocommit: false - writeConcern: - command_name: abortTransaction - database_name: admin - - command_started_event: - command: - abortTransaction: 1 - lsid: session0 - txnNumber: - $numberLong: "1" - startTransaction: - autocommit: false - writeConcern: - command_name: abortTransaction - database_name: admin - outcome: - collection: - data: [] - - - description: abortTransaction succeeds after HostNotFound - failPoint: - configureFailPoint: failCommand - mode: { times: 1 } - data: - failCommands: ["abortTransaction"] - errorCode: 7 - errorLabels: ["RetryableWriteError"] - closeConnection: false - operations: - - name: startTransaction - object: session0 - - name: insertOne - object: collection - arguments: - session: session0 - document: - _id: 1 - result: - insertedId: 1 - - name: abortTransaction - object: session0 - expectations: - - command_started_event: - command: - insert: *collection_name - documents: - - _id: 1 - ordered: true - readConcern: - lsid: session0 - txnNumber: - $numberLong: "1" - startTransaction: true - autocommit: false - writeConcern: - command_name: insert - database_name: *database_name - - command_started_event: - command: - abortTransaction: 1 - lsid: session0 - txnNumber: - $numberLong: "1" - startTransaction: - autocommit: false - writeConcern: - command_name: abortTransaction - database_name: admin - - command_started_event: - command: - abortTransaction: 1 - lsid: session0 - txnNumber: - $numberLong: "1" - startTransaction: - autocommit: false - writeConcern: - command_name: abortTransaction - database_name: admin - outcome: - collection: - data: [] - - - description: abortTransaction succeeds after HostUnreachable - failPoint: - configureFailPoint: failCommand - mode: { times: 1 } - data: - failCommands: ["abortTransaction"] - errorCode: 6 - errorLabels: ["RetryableWriteError"] - closeConnection: false - operations: - - name: startTransaction - object: session0 - - name: insertOne - object: collection - arguments: - session: session0 - document: - _id: 1 - result: - insertedId: 1 - - name: abortTransaction - object: session0 - expectations: - - command_started_event: - command: - insert: *collection_name - documents: - - _id: 1 - ordered: true - readConcern: - lsid: session0 - txnNumber: - $numberLong: "1" - startTransaction: true - autocommit: false - writeConcern: - command_name: insert - database_name: *database_name - - command_started_event: - command: - abortTransaction: 1 - lsid: session0 - txnNumber: - $numberLong: "1" - startTransaction: - autocommit: false - writeConcern: - command_name: abortTransaction - database_name: admin - - command_started_event: - command: - abortTransaction: 1 - lsid: session0 - txnNumber: - $numberLong: "1" - startTransaction: - autocommit: false - writeConcern: - command_name: abortTransaction - database_name: admin - outcome: - collection: - data: [] - - - description: abortTransaction succeeds after SocketException - failPoint: - configureFailPoint: failCommand - mode: { times: 1 } - data: - failCommands: ["abortTransaction"] - errorCode: 9001 - errorLabels: ["RetryableWriteError"] - closeConnection: false - operations: - - name: startTransaction - object: session0 - - name: insertOne - object: collection - arguments: - session: session0 - document: - _id: 1 - result: - insertedId: 1 - - name: abortTransaction - object: session0 - expectations: - - command_started_event: - command: - insert: *collection_name - documents: - - _id: 1 - ordered: true - readConcern: - lsid: session0 - txnNumber: - $numberLong: "1" - startTransaction: true - autocommit: false - writeConcern: - command_name: insert - database_name: *database_name - - command_started_event: - command: - abortTransaction: 1 - lsid: session0 - txnNumber: - $numberLong: "1" - startTransaction: - autocommit: false - writeConcern: - command_name: abortTransaction - database_name: admin - - command_started_event: - command: - abortTransaction: 1 - lsid: session0 - txnNumber: - $numberLong: "1" - startTransaction: - autocommit: false - writeConcern: - command_name: abortTransaction - database_name: admin - outcome: - collection: - data: [] - - - description: abortTransaction succeeds after NetworkTimeout - failPoint: - configureFailPoint: failCommand - mode: { times: 1 } - data: - failCommands: ["abortTransaction"] - errorCode: 89 - errorLabels: ["RetryableWriteError"] - closeConnection: false - operations: - - name: startTransaction - object: session0 - - name: insertOne - object: collection - arguments: - session: session0 - document: - _id: 1 - result: - insertedId: 1 - - name: abortTransaction - object: session0 - expectations: - - command_started_event: - command: - insert: *collection_name - documents: - - _id: 1 - ordered: true - readConcern: - lsid: session0 - txnNumber: - $numberLong: "1" - startTransaction: true - autocommit: false - writeConcern: - command_name: insert - database_name: *database_name - - command_started_event: - command: - abortTransaction: 1 - lsid: session0 - txnNumber: - $numberLong: "1" - startTransaction: - autocommit: false - writeConcern: - command_name: abortTransaction - database_name: admin - - command_started_event: - command: - abortTransaction: 1 - lsid: session0 - txnNumber: - $numberLong: "1" - startTransaction: - autocommit: false - writeConcern: - command_name: abortTransaction - database_name: admin - outcome: - collection: - data: [] - - - description: abortTransaction succeeds after WriteConcernError InterruptedAtShutdown - failPoint: - configureFailPoint: failCommand - mode: { times: 1 } - data: - failCommands: ["abortTransaction"] - errorLabels: ["RetryableWriteError"] - writeConcernError: - code: 11600 - errmsg: Replication is being shut down - operations: - - name: startTransaction - object: session0 - arguments: - options: - writeConcern: - w: majority - - name: insertOne - object: collection - arguments: - session: session0 - document: - _id: 1 - result: - insertedId: 1 - - name: abortTransaction - object: session0 - expectations: - - command_started_event: - command: - insert: *collection_name - documents: - - _id: 1 - ordered: true - readConcern: - lsid: session0 - txnNumber: - $numberLong: "1" - startTransaction: true - autocommit: false - writeConcern: - command_name: insert - database_name: *database_name - - command_started_event: - command: - abortTransaction: 1 - lsid: session0 - txnNumber: - $numberLong: "1" - startTransaction: - autocommit: false - writeConcern: - w: majority - command_name: abortTransaction - database_name: admin - - command_started_event: - command: - abortTransaction: 1 - lsid: session0 - txnNumber: - $numberLong: "1" - startTransaction: - autocommit: false - writeConcern: - w: majority - command_name: abortTransaction - database_name: admin - outcome: - collection: - data: [] - - - description: abortTransaction succeeds after WriteConcernError InterruptedDueToReplStateChange - failPoint: - configureFailPoint: failCommand - mode: { times: 1 } - data: - failCommands: ["abortTransaction"] - errorLabels: ["RetryableWriteError"] - writeConcernError: - code: 11602 - errmsg: Replication is being shut down - operations: - - name: startTransaction - object: session0 - arguments: - options: - writeConcern: - w: majority - - name: insertOne - object: collection - arguments: - session: session0 - document: - _id: 1 - result: - insertedId: 1 - - name: abortTransaction - object: session0 - expectations: - - command_started_event: - command: - insert: *collection_name - documents: - - _id: 1 - ordered: true - readConcern: - lsid: session0 - txnNumber: - $numberLong: "1" - startTransaction: true - autocommit: false - writeConcern: - command_name: insert - database_name: *database_name - - command_started_event: - command: - abortTransaction: 1 - lsid: session0 - txnNumber: - $numberLong: "1" - startTransaction: - autocommit: false - writeConcern: - w: majority - command_name: abortTransaction - database_name: admin - - command_started_event: - command: - abortTransaction: 1 - lsid: session0 - txnNumber: - $numberLong: "1" - startTransaction: - autocommit: false - writeConcern: - w: majority - command_name: abortTransaction - database_name: admin - outcome: - collection: - data: [] - - - description: abortTransaction succeeds after WriteConcernError PrimarySteppedDown - failPoint: - configureFailPoint: failCommand - mode: { times: 1 } - data: - failCommands: ["abortTransaction"] - errorLabels: ["RetryableWriteError"] - writeConcernError: - code: 189 - errmsg: Replication is being shut down - operations: - - name: startTransaction - object: session0 - arguments: - options: - writeConcern: - w: majority - - name: insertOne - object: collection - arguments: - session: session0 - document: - _id: 1 - result: - insertedId: 1 - - name: abortTransaction - object: session0 - expectations: - - command_started_event: - command: - insert: *collection_name - documents: - - _id: 1 - ordered: true - readConcern: - lsid: session0 - txnNumber: - $numberLong: "1" - startTransaction: true - autocommit: false - writeConcern: - command_name: insert - database_name: *database_name - - command_started_event: - command: - abortTransaction: 1 - lsid: session0 - txnNumber: - $numberLong: "1" - startTransaction: - autocommit: false - writeConcern: - w: majority - command_name: abortTransaction - database_name: admin - - command_started_event: - command: - abortTransaction: 1 - lsid: session0 - txnNumber: - $numberLong: "1" - startTransaction: - autocommit: false - writeConcern: - w: majority - command_name: abortTransaction - database_name: admin - outcome: - collection: - data: [] - - - description: abortTransaction succeeds after WriteConcernError ShutdownInProgress - failPoint: - configureFailPoint: failCommand - mode: { times: 1 } - data: - failCommands: ["abortTransaction"] - errorLabels: ["RetryableWriteError"] - writeConcernError: - code: 91 - errmsg: Replication is being shut down - operations: - - name: startTransaction - object: session0 - arguments: - options: - writeConcern: - w: majority - - name: insertOne - object: collection - arguments: - session: session0 - document: - _id: 1 - result: - insertedId: 1 - - name: abortTransaction - object: session0 - expectations: - - command_started_event: - command: - insert: *collection_name - documents: - - _id: 1 - ordered: true - readConcern: - lsid: session0 - txnNumber: - $numberLong: "1" - startTransaction: true - autocommit: false - writeConcern: - command_name: insert - database_name: *database_name - - command_started_event: - command: - abortTransaction: 1 - lsid: session0 - txnNumber: - $numberLong: "1" - startTransaction: - autocommit: false - writeConcern: - w: majority - command_name: abortTransaction - database_name: admin - - command_started_event: - command: - abortTransaction: 1 - lsid: session0 - txnNumber: - $numberLong: "1" - startTransaction: - autocommit: false - writeConcern: - w: majority - command_name: abortTransaction - database_name: admin - outcome: - collection: - data: [] diff --git a/source/transactions/tests/legacy/retryable-abort.json b/source/transactions/tests/legacy/retryable-abort.json deleted file mode 100644 index 61be87a910..0000000000 --- a/source/transactions/tests/legacy/retryable-abort.json +++ /dev/null @@ -1,406 +0,0 @@ -{ - "runOn": [ - { - "minServerVersion": "4.0", - "topology": [ - "replicaset" - ] - }, - { - "minServerVersion": "4.1.8", - "topology": [ - "sharded", - "load-balanced" - ] - } - ], - "database_name": "transaction-tests", - "collection_name": "test", - "data": [], - "tests": [ - { - "description": "abortTransaction only performs a single retry", - "clientOptions": { - "retryWrites": false - }, - "failPoint": { - "configureFailPoint": "failCommand", - "mode": { - "times": 2 - }, - "data": { - "failCommands": [ - "abortTransaction" - ], - "closeConnection": true - } - }, - "operations": [ - { - "name": "startTransaction", - "object": "session0" - }, - { - "name": "insertOne", - "object": "collection", - "arguments": { - "session": "session0", - "document": { - "_id": 1 - } - }, - "result": { - "insertedId": 1 - } - }, - { - "name": "abortTransaction", - "object": "session0" - } - ], - "expectations": [ - { - "command_started_event": { - "command": { - "insert": "test", - "documents": [ - { - "_id": 1 - } - ], - "ordered": true, - "readConcern": null, - "lsid": "session0", - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": true, - "autocommit": false, - "writeConcern": null - }, - "command_name": "insert", - "database_name": "transaction-tests" - } - }, - { - "command_started_event": { - "command": { - "abortTransaction": 1, - "lsid": "session0", - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": null, - "autocommit": false, - "writeConcern": null - }, - "command_name": "abortTransaction", - "database_name": "admin" - } - }, - { - "command_started_event": { - "command": { - "abortTransaction": 1, - "lsid": "session0", - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": null, - "autocommit": false, - "writeConcern": null - }, - "command_name": "abortTransaction", - "database_name": "admin" - } - } - ], - "outcome": { - "collection": { - "data": [] - } - } - }, - { - "description": "abortTransaction does not retry after Interrupted", - "failPoint": { - "configureFailPoint": "failCommand", - "mode": { - "times": 1 - }, - "data": { - "failCommands": [ - "abortTransaction" - ], - "errorCode": 11601, - "closeConnection": false - } - }, - "operations": [ - { - "name": "startTransaction", - "object": "session0" - }, - { - "name": "insertOne", - "object": "collection", - "arguments": { - "session": "session0", - "document": { - "_id": 1 - } - }, - "result": { - "insertedId": 1 - } - }, - { - "name": "abortTransaction", - "object": "session0" - } - ], - "expectations": [ - { - "command_started_event": { - "command": { - "insert": "test", - "documents": [ - { - "_id": 1 - } - ], - "ordered": true, - "readConcern": null, - "lsid": "session0", - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": true, - "autocommit": false, - "writeConcern": null - }, - "command_name": "insert", - "database_name": "transaction-tests" - } - }, - { - "command_started_event": { - "command": { - "abortTransaction": 1, - "lsid": "session0", - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": null, - "autocommit": false, - "writeConcern": null - }, - "command_name": "abortTransaction", - "database_name": "admin" - } - } - ], - "outcome": { - "collection": { - "data": [] - } - } - }, - { - "description": "abortTransaction does not retry after WriteConcernError Interrupted", - "failPoint": { - "configureFailPoint": "failCommand", - "mode": { - "times": 1 - }, - "data": { - "failCommands": [ - "abortTransaction" - ], - "writeConcernError": { - "code": 11601, - "errmsg": "operation was interrupted" - } - } - }, - "operations": [ - { - "name": "startTransaction", - "object": "session0", - "arguments": { - "options": { - "writeConcern": { - "w": "majority" - } - } - } - }, - { - "name": "insertOne", - "object": "collection", - "arguments": { - "session": "session0", - "document": { - "_id": 1 - } - }, - "result": { - "insertedId": 1 - } - }, - { - "name": "abortTransaction", - "object": "session0" - } - ], - "expectations": [ - { - "command_started_event": { - "command": { - "insert": "test", - "documents": [ - { - "_id": 1 - } - ], - "ordered": true, - "readConcern": null, - "lsid": "session0", - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": true, - "autocommit": false, - "writeConcern": null - }, - "command_name": "insert", - "database_name": "transaction-tests" - } - }, - { - "command_started_event": { - "command": { - "abortTransaction": 1, - "lsid": "session0", - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": null, - "autocommit": false, - "writeConcern": { - "w": "majority" - } - }, - "command_name": "abortTransaction", - "database_name": "admin" - } - } - ], - "outcome": { - "collection": { - "data": [] - } - } - }, - { - "description": "abortTransaction succeeds after connection error", - "failPoint": { - "configureFailPoint": "failCommand", - "mode": { - "times": 1 - }, - "data": { - "failCommands": [ - "abortTransaction" - ], - "closeConnection": true - } - }, - "operations": [ - { - "name": "startTransaction", - "object": "session0" - }, - { - "name": "insertOne", - "object": "collection", - "arguments": { - "session": "session0", - "document": { - "_id": 1 - } - }, - "result": { - "insertedId": 1 - } - }, - { - "name": "abortTransaction", - "object": "session0" - } - ], - "expectations": [ - { - "command_started_event": { - "command": { - "insert": "test", - "documents": [ - { - "_id": 1 - } - ], - "ordered": true, - "readConcern": null, - "lsid": "session0", - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": true, - "autocommit": false, - "writeConcern": null - }, - "command_name": "insert", - "database_name": "transaction-tests" - } - }, - { - "command_started_event": { - "command": { - "abortTransaction": 1, - "lsid": "session0", - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": null, - "autocommit": false, - "writeConcern": null - }, - "command_name": "abortTransaction", - "database_name": "admin" - } - }, - { - "command_started_event": { - "command": { - "abortTransaction": 1, - "lsid": "session0", - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": null, - "autocommit": false, - "writeConcern": null - }, - "command_name": "abortTransaction", - "database_name": "admin" - } - } - ], - "outcome": { - "collection": { - "data": [] - } - } - } - ] -} diff --git a/source/transactions/tests/legacy/retryable-abort.yml b/source/transactions/tests/legacy/retryable-abort.yml deleted file mode 100644 index 0beab8e5a6..0000000000 --- a/source/transactions/tests/legacy/retryable-abort.yml +++ /dev/null @@ -1,267 +0,0 @@ -runOn: - - - minServerVersion: "4.0" - topology: ["replicaset"] - - - minServerVersion: "4.1.8" - topology: ["sharded", "load-balanced"] - -database_name: &database_name "transaction-tests" -collection_name: &collection_name "test" - -data: [] - -tests: - - description: abortTransaction only performs a single retry - - clientOptions: - retryWrites: false - - failPoint: - configureFailPoint: failCommand - mode: { times: 2 } - data: - failCommands: ["abortTransaction"] - closeConnection: true - - operations: - - name: startTransaction - object: session0 - - name: insertOne - object: collection - arguments: - session: session0 - document: - _id: 1 - result: - insertedId: 1 - # Call to abort returns no error even when the retry attempt fails. - - name: abortTransaction - object: session0 - - expectations: - - command_started_event: - command: - insert: *collection_name - documents: - - _id: 1 - ordered: true - readConcern: - lsid: session0 - txnNumber: - $numberLong: "1" - startTransaction: true - autocommit: false - writeConcern: - command_name: insert - database_name: *database_name - - command_started_event: - command: - abortTransaction: 1 - lsid: session0 - txnNumber: - $numberLong: "1" - startTransaction: - autocommit: false - writeConcern: - command_name: abortTransaction - database_name: admin - - command_started_event: - command: - abortTransaction: 1 - lsid: session0 - txnNumber: - $numberLong: "1" - startTransaction: - autocommit: false - writeConcern: - command_name: abortTransaction - database_name: admin - - outcome: - collection: - data: [] - - - description: abortTransaction does not retry after Interrupted - - failPoint: - configureFailPoint: failCommand - mode: { times: 1 } - data: - failCommands: ["abortTransaction"] - errorCode: 11601 - closeConnection: false - - operations: - - name: startTransaction - object: session0 - - name: insertOne - object: collection - arguments: - session: session0 - document: - _id: 1 - result: - insertedId: 1 - - name: abortTransaction - object: session0 - - expectations: - - command_started_event: - command: - insert: *collection_name - documents: - - _id: 1 - ordered: true - readConcern: - lsid: session0 - txnNumber: - $numberLong: "1" - startTransaction: true - autocommit: false - writeConcern: - command_name: insert - database_name: *database_name - - command_started_event: - command: - abortTransaction: 1 - lsid: session0 - txnNumber: - $numberLong: "1" - startTransaction: - autocommit: false - writeConcern: - command_name: abortTransaction - database_name: admin - - outcome: - collection: - data: [] - - - description: abortTransaction does not retry after WriteConcernError Interrupted - - failPoint: - configureFailPoint: failCommand - mode: { times: 1 } - data: - failCommands: ["abortTransaction"] - writeConcernError: - code: 11601 - errmsg: operation was interrupted - - operations: - - name: startTransaction - object: session0 - arguments: - options: - writeConcern: - w: majority - - name: insertOne - object: collection - arguments: - session: session0 - document: - _id: 1 - result: - insertedId: 1 - - name: abortTransaction - object: session0 - - expectations: - - command_started_event: - command: - insert: *collection_name - documents: - - _id: 1 - ordered: true - readConcern: - lsid: session0 - txnNumber: - $numberLong: "1" - startTransaction: true - autocommit: false - writeConcern: - command_name: insert - database_name: *database_name - - command_started_event: - command: - abortTransaction: 1 - lsid: session0 - txnNumber: - $numberLong: "1" - startTransaction: - autocommit: false - writeConcern: - w: majority - command_name: abortTransaction - database_name: admin - - outcome: - collection: - data: [] - - - description: abortTransaction succeeds after connection error - - failPoint: - configureFailPoint: failCommand - mode: { times: 1 } - data: - failCommands: ["abortTransaction"] - closeConnection: true - - operations: - - name: startTransaction - object: session0 - - name: insertOne - object: collection - arguments: - session: session0 - document: - _id: 1 - result: - insertedId: 1 - - name: abortTransaction - object: session0 - - expectations: - - command_started_event: - command: - insert: *collection_name - documents: - - _id: 1 - ordered: true - readConcern: - lsid: session0 - txnNumber: - $numberLong: "1" - startTransaction: true - autocommit: false - writeConcern: - command_name: insert - database_name: *database_name - - command_started_event: - command: - abortTransaction: 1 - lsid: session0 - txnNumber: - $numberLong: "1" - startTransaction: - autocommit: false - writeConcern: - command_name: abortTransaction - database_name: admin - - command_started_event: - command: - abortTransaction: 1 - lsid: session0 - txnNumber: - $numberLong: "1" - startTransaction: - autocommit: false - writeConcern: - command_name: abortTransaction - database_name: admin - - outcome: - collection: - data: [] diff --git a/source/transactions/tests/legacy/retryable-commit-errorLabels-forbid_serverless.json b/source/transactions/tests/legacy/retryable-commit-errorLabels-forbid_serverless.json deleted file mode 100644 index bf65ed6eab..0000000000 --- a/source/transactions/tests/legacy/retryable-commit-errorLabels-forbid_serverless.json +++ /dev/null @@ -1,240 +0,0 @@ -{ - "runOn": [ - { - "minServerVersion": "4.3.1", - "topology": [ - "replicaset", - "sharded", - "load-balanced" - ], - "serverless": "forbid" - } - ], - "database_name": "transaction-tests", - "collection_name": "test", - "data": [], - "tests": [ - { - "description": "commitTransaction succeeds after InterruptedAtShutdown", - "failPoint": { - "configureFailPoint": "failCommand", - "mode": { - "times": 1 - }, - "data": { - "failCommands": [ - "commitTransaction" - ], - "errorCode": 11600, - "errorLabels": [ - "RetryableWriteError" - ], - "closeConnection": false - } - }, - "operations": [ - { - "name": "startTransaction", - "object": "session0" - }, - { - "name": "insertOne", - "object": "collection", - "arguments": { - "session": "session0", - "document": { - "_id": 1 - } - }, - "result": { - "insertedId": 1 - } - }, - { - "name": "commitTransaction", - "object": "session0" - } - ], - "expectations": [ - { - "command_started_event": { - "command": { - "insert": "test", - "documents": [ - { - "_id": 1 - } - ], - "ordered": true, - "readConcern": null, - "lsid": "session0", - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": true, - "autocommit": false, - "writeConcern": null - }, - "command_name": "insert", - "database_name": "transaction-tests" - } - }, - { - "command_started_event": { - "command": { - "commitTransaction": 1, - "lsid": "session0", - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": null, - "autocommit": false, - "writeConcern": null - }, - "command_name": "commitTransaction", - "database_name": "admin" - } - }, - { - "command_started_event": { - "command": { - "commitTransaction": 1, - "lsid": "session0", - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": null, - "autocommit": false, - "writeConcern": { - "w": "majority", - "wtimeout": 10000 - } - }, - "command_name": "commitTransaction", - "database_name": "admin" - } - } - ], - "outcome": { - "collection": { - "data": [ - { - "_id": 1 - } - ] - } - } - }, - { - "description": "commitTransaction succeeds after ShutdownInProgress", - "failPoint": { - "configureFailPoint": "failCommand", - "mode": { - "times": 1 - }, - "data": { - "failCommands": [ - "commitTransaction" - ], - "errorCode": 91, - "errorLabels": [ - "RetryableWriteError" - ], - "closeConnection": false - } - }, - "operations": [ - { - "name": "startTransaction", - "object": "session0" - }, - { - "name": "insertOne", - "object": "collection", - "arguments": { - "session": "session0", - "document": { - "_id": 1 - } - }, - "result": { - "insertedId": 1 - } - }, - { - "name": "commitTransaction", - "object": "session0" - } - ], - "expectations": [ - { - "command_started_event": { - "command": { - "insert": "test", - "documents": [ - { - "_id": 1 - } - ], - "ordered": true, - "readConcern": null, - "lsid": "session0", - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": true, - "autocommit": false, - "writeConcern": null - }, - "command_name": "insert", - "database_name": "transaction-tests" - } - }, - { - "command_started_event": { - "command": { - "commitTransaction": 1, - "lsid": "session0", - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": null, - "autocommit": false, - "writeConcern": null - }, - "command_name": "commitTransaction", - "database_name": "admin" - } - }, - { - "command_started_event": { - "command": { - "commitTransaction": 1, - "lsid": "session0", - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": null, - "autocommit": false, - "writeConcern": { - "w": "majority", - "wtimeout": 10000 - } - }, - "command_name": "commitTransaction", - "database_name": "admin" - } - } - ], - "outcome": { - "collection": { - "data": [ - { - "_id": 1 - } - ] - } - } - } - ] -} diff --git a/source/transactions/tests/legacy/retryable-commit-errorLabels-forbid_serverless.yml b/source/transactions/tests/legacy/retryable-commit-errorLabels-forbid_serverless.yml deleted file mode 100644 index c3290800b7..0000000000 --- a/source/transactions/tests/legacy/retryable-commit-errorLabels-forbid_serverless.yml +++ /dev/null @@ -1,150 +0,0 @@ -runOn: - - - minServerVersion: "4.3.1" # failCommand errorLabels option - topology: ["replicaset", "sharded", "load-balanced"] - # This file contains tests originally found in retryable-commit.yml that - # are incompatible with serverless: - # - # * Failing commitTransaction with closeConnection:true may abort the - # transaction (CLOUDP-202309). - # * Fail points using state change errors (e.g. InterruptedAtShutdown, - # ShutdownInProgress) may remain enabled indefinitely (CLOUDP-84573). - serverless: "forbid" - -database_name: &database_name "transaction-tests" -collection_name: &collection_name "test" - -data: [] - -tests: - - description: commitTransaction succeeds after InterruptedAtShutdown - failPoint: - configureFailPoint: failCommand - mode: { times: 1 } - data: - failCommands: ["commitTransaction"] - errorCode: 11600 - errorLabels: ["RetryableWriteError"] - closeConnection: false - operations: - - name: startTransaction - object: session0 - - name: insertOne - object: collection - arguments: - session: session0 - document: - _id: 1 - result: - insertedId: 1 - - name: commitTransaction - object: session0 - expectations: - - command_started_event: - command: - insert: *collection_name - documents: - - _id: 1 - ordered: true - readConcern: - lsid: session0 - txnNumber: - $numberLong: "1" - startTransaction: true - autocommit: false - writeConcern: - command_name: insert - database_name: *database_name - - command_started_event: - command: - commitTransaction: 1 - lsid: session0 - txnNumber: - $numberLong: "1" - startTransaction: - autocommit: false - writeConcern: - command_name: commitTransaction - database_name: admin - - command_started_event: - command: - commitTransaction: 1 - lsid: session0 - txnNumber: - $numberLong: "1" - startTransaction: - autocommit: false - # commitTransaction applies w:majority on retries - writeConcern: { w: majority, wtimeout: 10000 } - command_name: commitTransaction - database_name: admin - outcome: - collection: - data: - - _id: 1 - - - description: commitTransaction succeeds after ShutdownInProgress - failPoint: - configureFailPoint: failCommand - mode: { times: 1 } - data: - failCommands: ["commitTransaction"] - errorCode: 91 - errorLabels: ["RetryableWriteError"] - closeConnection: false - operations: - - name: startTransaction - object: session0 - - name: insertOne - object: collection - arguments: - session: session0 - document: - _id: 1 - result: - insertedId: 1 - - name: commitTransaction - object: session0 - expectations: - - command_started_event: - command: - insert: *collection_name - documents: - - _id: 1 - ordered: true - readConcern: - lsid: session0 - txnNumber: - $numberLong: "1" - startTransaction: true - autocommit: false - writeConcern: - command_name: insert - database_name: *database_name - - command_started_event: - command: - commitTransaction: 1 - lsid: session0 - txnNumber: - $numberLong: "1" - startTransaction: - autocommit: false - writeConcern: - command_name: commitTransaction - database_name: admin - - command_started_event: - command: - commitTransaction: 1 - lsid: session0 - txnNumber: - $numberLong: "1" - startTransaction: - autocommit: false - # commitTransaction applies w:majority on retries - writeConcern: { w: majority, wtimeout: 10000 } - command_name: commitTransaction - database_name: admin - outcome: - collection: - data: - - _id: 1 diff --git a/source/transactions/tests/legacy/retryable-commit-errorLabels.json b/source/transactions/tests/legacy/retryable-commit-errorLabels.json deleted file mode 100644 index 2e060c8a81..0000000000 --- a/source/transactions/tests/legacy/retryable-commit-errorLabels.json +++ /dev/null @@ -1,1711 +0,0 @@ -{ - "runOn": [ - { - "minServerVersion": "4.3.1", - "topology": [ - "replicaset", - "sharded", - "load-balanced" - ] - } - ], - "database_name": "transaction-tests", - "collection_name": "test", - "data": [], - "tests": [ - { - "description": "commitTransaction does not retry error without RetryableWriteError label", - "clientOptions": { - "retryWrites": false - }, - "failPoint": { - "configureFailPoint": "failCommand", - "mode": { - "times": 1 - }, - "data": { - "failCommands": [ - "commitTransaction" - ], - "errorCode": 11600, - "errorLabels": [] - } - }, - "operations": [ - { - "name": "startTransaction", - "object": "session0" - }, - { - "name": "insertOne", - "object": "collection", - "arguments": { - "session": "session0", - "document": { - "_id": 1 - } - }, - "result": { - "insertedId": 1 - } - }, - { - "name": "commitTransaction", - "object": "session0", - "result": { - "errorLabelsOmit": [ - "RetryableWriteError", - "TransientTransactionError" - ] - } - } - ], - "expectations": [ - { - "command_started_event": { - "command": { - "insert": "test", - "documents": [ - { - "_id": 1 - } - ], - "ordered": true, - "readConcern": null, - "lsid": "session0", - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": true, - "autocommit": false, - "writeConcern": null - }, - "command_name": "insert", - "database_name": "transaction-tests" - } - }, - { - "command_started_event": { - "command": { - "commitTransaction": 1, - "lsid": "session0", - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": null, - "autocommit": false, - "writeConcern": null - }, - "command_name": "commitTransaction", - "database_name": "admin" - } - } - ], - "outcome": { - "collection": { - "data": [] - } - } - }, - { - "description": "commitTransaction retries once with RetryableWriteError from server", - "clientOptions": { - "retryWrites": false - }, - "failPoint": { - "configureFailPoint": "failCommand", - "mode": { - "times": 1 - }, - "data": { - "failCommands": [ - "commitTransaction" - ], - "errorCode": 112, - "errorLabels": [ - "RetryableWriteError" - ] - } - }, - "operations": [ - { - "name": "startTransaction", - "object": "session0" - }, - { - "name": "insertOne", - "object": "collection", - "arguments": { - "session": "session0", - "document": { - "_id": 1 - } - }, - "result": { - "insertedId": 1 - } - }, - { - "name": "commitTransaction", - "object": "session0" - } - ], - "expectations": [ - { - "command_started_event": { - "command": { - "insert": "test", - "documents": [ - { - "_id": 1 - } - ], - "ordered": true, - "readConcern": null, - "lsid": "session0", - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": true, - "autocommit": false, - "writeConcern": null - }, - "command_name": "insert", - "database_name": "transaction-tests" - } - }, - { - "command_started_event": { - "command": { - "commitTransaction": 1, - "lsid": "session0", - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": null, - "autocommit": false, - "writeConcern": null - }, - "command_name": "commitTransaction", - "database_name": "admin" - } - }, - { - "command_started_event": { - "command": { - "commitTransaction": 1, - "lsid": "session0", - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": null, - "autocommit": false, - "writeConcern": { - "w": "majority", - "wtimeout": 10000 - } - }, - "command_name": "commitTransaction", - "database_name": "admin" - } - } - ], - "outcome": { - "collection": { - "data": [ - { - "_id": 1 - } - ] - } - } - }, - { - "description": "commitTransaction succeeds after NotWritablePrimary", - "failPoint": { - "configureFailPoint": "failCommand", - "mode": { - "times": 1 - }, - "data": { - "failCommands": [ - "commitTransaction" - ], - "errorCode": 10107, - "errorLabels": [ - "RetryableWriteError" - ], - "closeConnection": false - } - }, - "operations": [ - { - "name": "startTransaction", - "object": "session0" - }, - { - "name": "insertOne", - "object": "collection", - "arguments": { - "session": "session0", - "document": { - "_id": 1 - } - }, - "result": { - "insertedId": 1 - } - }, - { - "name": "commitTransaction", - "object": "session0" - } - ], - "expectations": [ - { - "command_started_event": { - "command": { - "insert": "test", - "documents": [ - { - "_id": 1 - } - ], - "ordered": true, - "readConcern": null, - "lsid": "session0", - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": true, - "autocommit": false, - "writeConcern": null - }, - "command_name": "insert", - "database_name": "transaction-tests" - } - }, - { - "command_started_event": { - "command": { - "commitTransaction": 1, - "lsid": "session0", - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": null, - "autocommit": false, - "writeConcern": null - }, - "command_name": "commitTransaction", - "database_name": "admin" - } - }, - { - "command_started_event": { - "command": { - "commitTransaction": 1, - "lsid": "session0", - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": null, - "autocommit": false, - "writeConcern": { - "w": "majority", - "wtimeout": 10000 - } - }, - "command_name": "commitTransaction", - "database_name": "admin" - } - } - ], - "outcome": { - "collection": { - "data": [ - { - "_id": 1 - } - ] - } - } - }, - { - "description": "commitTransaction succeeds after NotPrimaryOrSecondary", - "failPoint": { - "configureFailPoint": "failCommand", - "mode": { - "times": 1 - }, - "data": { - "failCommands": [ - "commitTransaction" - ], - "errorCode": 13436, - "errorLabels": [ - "RetryableWriteError" - ], - "closeConnection": false - } - }, - "operations": [ - { - "name": "startTransaction", - "object": "session0" - }, - { - "name": "insertOne", - "object": "collection", - "arguments": { - "session": "session0", - "document": { - "_id": 1 - } - }, - "result": { - "insertedId": 1 - } - }, - { - "name": "commitTransaction", - "object": "session0" - } - ], - "expectations": [ - { - "command_started_event": { - "command": { - "insert": "test", - "documents": [ - { - "_id": 1 - } - ], - "ordered": true, - "readConcern": null, - "lsid": "session0", - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": true, - "autocommit": false, - "writeConcern": null - }, - "command_name": "insert", - "database_name": "transaction-tests" - } - }, - { - "command_started_event": { - "command": { - "commitTransaction": 1, - "lsid": "session0", - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": null, - "autocommit": false, - "writeConcern": null - }, - "command_name": "commitTransaction", - "database_name": "admin" - } - }, - { - "command_started_event": { - "command": { - "commitTransaction": 1, - "lsid": "session0", - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": null, - "autocommit": false, - "writeConcern": { - "w": "majority", - "wtimeout": 10000 - } - }, - "command_name": "commitTransaction", - "database_name": "admin" - } - } - ], - "outcome": { - "collection": { - "data": [ - { - "_id": 1 - } - ] - } - } - }, - { - "description": "commitTransaction succeeds after NotPrimaryNoSecondaryOk", - "failPoint": { - "configureFailPoint": "failCommand", - "mode": { - "times": 1 - }, - "data": { - "failCommands": [ - "commitTransaction" - ], - "errorCode": 13435, - "errorLabels": [ - "RetryableWriteError" - ], - "closeConnection": false - } - }, - "operations": [ - { - "name": "startTransaction", - "object": "session0" - }, - { - "name": "insertOne", - "object": "collection", - "arguments": { - "session": "session0", - "document": { - "_id": 1 - } - }, - "result": { - "insertedId": 1 - } - }, - { - "name": "commitTransaction", - "object": "session0" - } - ], - "expectations": [ - { - "command_started_event": { - "command": { - "insert": "test", - "documents": [ - { - "_id": 1 - } - ], - "ordered": true, - "readConcern": null, - "lsid": "session0", - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": true, - "autocommit": false, - "writeConcern": null - }, - "command_name": "insert", - "database_name": "transaction-tests" - } - }, - { - "command_started_event": { - "command": { - "commitTransaction": 1, - "lsid": "session0", - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": null, - "autocommit": false, - "writeConcern": null - }, - "command_name": "commitTransaction", - "database_name": "admin" - } - }, - { - "command_started_event": { - "command": { - "commitTransaction": 1, - "lsid": "session0", - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": null, - "autocommit": false, - "writeConcern": { - "w": "majority", - "wtimeout": 10000 - } - }, - "command_name": "commitTransaction", - "database_name": "admin" - } - } - ], - "outcome": { - "collection": { - "data": [ - { - "_id": 1 - } - ] - } - } - }, - { - "description": "commitTransaction succeeds after InterruptedDueToReplStateChange", - "failPoint": { - "configureFailPoint": "failCommand", - "mode": { - "times": 1 - }, - "data": { - "failCommands": [ - "commitTransaction" - ], - "errorCode": 11602, - "errorLabels": [ - "RetryableWriteError" - ], - "closeConnection": false - } - }, - "operations": [ - { - "name": "startTransaction", - "object": "session0" - }, - { - "name": "insertOne", - "object": "collection", - "arguments": { - "session": "session0", - "document": { - "_id": 1 - } - }, - "result": { - "insertedId": 1 - } - }, - { - "name": "commitTransaction", - "object": "session0" - } - ], - "expectations": [ - { - "command_started_event": { - "command": { - "insert": "test", - "documents": [ - { - "_id": 1 - } - ], - "ordered": true, - "readConcern": null, - "lsid": "session0", - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": true, - "autocommit": false, - "writeConcern": null - }, - "command_name": "insert", - "database_name": "transaction-tests" - } - }, - { - "command_started_event": { - "command": { - "commitTransaction": 1, - "lsid": "session0", - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": null, - "autocommit": false, - "writeConcern": null - }, - "command_name": "commitTransaction", - "database_name": "admin" - } - }, - { - "command_started_event": { - "command": { - "commitTransaction": 1, - "lsid": "session0", - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": null, - "autocommit": false, - "writeConcern": { - "w": "majority", - "wtimeout": 10000 - } - }, - "command_name": "commitTransaction", - "database_name": "admin" - } - } - ], - "outcome": { - "collection": { - "data": [ - { - "_id": 1 - } - ] - } - } - }, - { - "description": "commitTransaction succeeds after PrimarySteppedDown", - "failPoint": { - "configureFailPoint": "failCommand", - "mode": { - "times": 1 - }, - "data": { - "failCommands": [ - "commitTransaction" - ], - "errorCode": 189, - "errorLabels": [ - "RetryableWriteError" - ], - "closeConnection": false - } - }, - "operations": [ - { - "name": "startTransaction", - "object": "session0" - }, - { - "name": "insertOne", - "object": "collection", - "arguments": { - "session": "session0", - "document": { - "_id": 1 - } - }, - "result": { - "insertedId": 1 - } - }, - { - "name": "commitTransaction", - "object": "session0" - } - ], - "expectations": [ - { - "command_started_event": { - "command": { - "insert": "test", - "documents": [ - { - "_id": 1 - } - ], - "ordered": true, - "readConcern": null, - "lsid": "session0", - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": true, - "autocommit": false, - "writeConcern": null - }, - "command_name": "insert", - "database_name": "transaction-tests" - } - }, - { - "command_started_event": { - "command": { - "commitTransaction": 1, - "lsid": "session0", - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": null, - "autocommit": false, - "writeConcern": null - }, - "command_name": "commitTransaction", - "database_name": "admin" - } - }, - { - "command_started_event": { - "command": { - "commitTransaction": 1, - "lsid": "session0", - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": null, - "autocommit": false, - "writeConcern": { - "w": "majority", - "wtimeout": 10000 - } - }, - "command_name": "commitTransaction", - "database_name": "admin" - } - } - ], - "outcome": { - "collection": { - "data": [ - { - "_id": 1 - } - ] - } - } - }, - { - "description": "commitTransaction succeeds after HostNotFound", - "failPoint": { - "configureFailPoint": "failCommand", - "mode": { - "times": 1 - }, - "data": { - "failCommands": [ - "commitTransaction" - ], - "errorCode": 7, - "errorLabels": [ - "RetryableWriteError" - ], - "closeConnection": false - } - }, - "operations": [ - { - "name": "startTransaction", - "object": "session0" - }, - { - "name": "insertOne", - "object": "collection", - "arguments": { - "session": "session0", - "document": { - "_id": 1 - } - }, - "result": { - "insertedId": 1 - } - }, - { - "name": "commitTransaction", - "object": "session0" - } - ], - "expectations": [ - { - "command_started_event": { - "command": { - "insert": "test", - "documents": [ - { - "_id": 1 - } - ], - "ordered": true, - "readConcern": null, - "lsid": "session0", - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": true, - "autocommit": false, - "writeConcern": null - }, - "command_name": "insert", - "database_name": "transaction-tests" - } - }, - { - "command_started_event": { - "command": { - "commitTransaction": 1, - "lsid": "session0", - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": null, - "autocommit": false, - "writeConcern": null - }, - "command_name": "commitTransaction", - "database_name": "admin" - } - }, - { - "command_started_event": { - "command": { - "commitTransaction": 1, - "lsid": "session0", - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": null, - "autocommit": false, - "writeConcern": { - "w": "majority", - "wtimeout": 10000 - } - }, - "command_name": "commitTransaction", - "database_name": "admin" - } - } - ], - "outcome": { - "collection": { - "data": [ - { - "_id": 1 - } - ] - } - } - }, - { - "description": "commitTransaction succeeds after HostUnreachable", - "failPoint": { - "configureFailPoint": "failCommand", - "mode": { - "times": 1 - }, - "data": { - "failCommands": [ - "commitTransaction" - ], - "errorCode": 6, - "errorLabels": [ - "RetryableWriteError" - ], - "closeConnection": false - } - }, - "operations": [ - { - "name": "startTransaction", - "object": "session0" - }, - { - "name": "insertOne", - "object": "collection", - "arguments": { - "session": "session0", - "document": { - "_id": 1 - } - }, - "result": { - "insertedId": 1 - } - }, - { - "name": "commitTransaction", - "object": "session0" - } - ], - "expectations": [ - { - "command_started_event": { - "command": { - "insert": "test", - "documents": [ - { - "_id": 1 - } - ], - "ordered": true, - "readConcern": null, - "lsid": "session0", - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": true, - "autocommit": false, - "writeConcern": null - }, - "command_name": "insert", - "database_name": "transaction-tests" - } - }, - { - "command_started_event": { - "command": { - "commitTransaction": 1, - "lsid": "session0", - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": null, - "autocommit": false, - "writeConcern": null - }, - "command_name": "commitTransaction", - "database_name": "admin" - } - }, - { - "command_started_event": { - "command": { - "commitTransaction": 1, - "lsid": "session0", - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": null, - "autocommit": false, - "writeConcern": { - "w": "majority", - "wtimeout": 10000 - } - }, - "command_name": "commitTransaction", - "database_name": "admin" - } - } - ], - "outcome": { - "collection": { - "data": [ - { - "_id": 1 - } - ] - } - } - }, - { - "description": "commitTransaction succeeds after SocketException", - "failPoint": { - "configureFailPoint": "failCommand", - "mode": { - "times": 1 - }, - "data": { - "failCommands": [ - "commitTransaction" - ], - "errorCode": 9001, - "errorLabels": [ - "RetryableWriteError" - ], - "closeConnection": false - } - }, - "operations": [ - { - "name": "startTransaction", - "object": "session0" - }, - { - "name": "insertOne", - "object": "collection", - "arguments": { - "session": "session0", - "document": { - "_id": 1 - } - }, - "result": { - "insertedId": 1 - } - }, - { - "name": "commitTransaction", - "object": "session0" - } - ], - "expectations": [ - { - "command_started_event": { - "command": { - "insert": "test", - "documents": [ - { - "_id": 1 - } - ], - "ordered": true, - "readConcern": null, - "lsid": "session0", - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": true, - "autocommit": false, - "writeConcern": null - }, - "command_name": "insert", - "database_name": "transaction-tests" - } - }, - { - "command_started_event": { - "command": { - "commitTransaction": 1, - "lsid": "session0", - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": null, - "autocommit": false, - "writeConcern": null - }, - "command_name": "commitTransaction", - "database_name": "admin" - } - }, - { - "command_started_event": { - "command": { - "commitTransaction": 1, - "lsid": "session0", - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": null, - "autocommit": false, - "writeConcern": { - "w": "majority", - "wtimeout": 10000 - } - }, - "command_name": "commitTransaction", - "database_name": "admin" - } - } - ], - "outcome": { - "collection": { - "data": [ - { - "_id": 1 - } - ] - } - } - }, - { - "description": "commitTransaction succeeds after NetworkTimeout", - "failPoint": { - "configureFailPoint": "failCommand", - "mode": { - "times": 1 - }, - "data": { - "failCommands": [ - "commitTransaction" - ], - "errorCode": 89, - "errorLabels": [ - "RetryableWriteError" - ], - "closeConnection": false - } - }, - "operations": [ - { - "name": "startTransaction", - "object": "session0" - }, - { - "name": "insertOne", - "object": "collection", - "arguments": { - "session": "session0", - "document": { - "_id": 1 - } - }, - "result": { - "insertedId": 1 - } - }, - { - "name": "commitTransaction", - "object": "session0" - } - ], - "expectations": [ - { - "command_started_event": { - "command": { - "insert": "test", - "documents": [ - { - "_id": 1 - } - ], - "ordered": true, - "readConcern": null, - "lsid": "session0", - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": true, - "autocommit": false, - "writeConcern": null - }, - "command_name": "insert", - "database_name": "transaction-tests" - } - }, - { - "command_started_event": { - "command": { - "commitTransaction": 1, - "lsid": "session0", - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": null, - "autocommit": false, - "writeConcern": null - }, - "command_name": "commitTransaction", - "database_name": "admin" - } - }, - { - "command_started_event": { - "command": { - "commitTransaction": 1, - "lsid": "session0", - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": null, - "autocommit": false, - "writeConcern": { - "w": "majority", - "wtimeout": 10000 - } - }, - "command_name": "commitTransaction", - "database_name": "admin" - } - } - ], - "outcome": { - "collection": { - "data": [ - { - "_id": 1 - } - ] - } - } - }, - { - "description": "commitTransaction succeeds after WriteConcernError InterruptedAtShutdown", - "failPoint": { - "configureFailPoint": "failCommand", - "mode": { - "times": 1 - }, - "data": { - "failCommands": [ - "commitTransaction" - ], - "errorLabels": [ - "RetryableWriteError" - ], - "writeConcernError": { - "code": 11600, - "errmsg": "Replication is being shut down" - } - } - }, - "operations": [ - { - "name": "startTransaction", - "object": "session0", - "arguments": { - "options": { - "writeConcern": { - "w": "majority" - } - } - } - }, - { - "name": "insertOne", - "object": "collection", - "arguments": { - "session": "session0", - "document": { - "_id": 1 - } - }, - "result": { - "insertedId": 1 - } - }, - { - "name": "commitTransaction", - "object": "session0" - } - ], - "expectations": [ - { - "command_started_event": { - "command": { - "insert": "test", - "documents": [ - { - "_id": 1 - } - ], - "ordered": true, - "readConcern": null, - "lsid": "session0", - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": true, - "autocommit": false, - "writeConcern": null - }, - "command_name": "insert", - "database_name": "transaction-tests" - } - }, - { - "command_started_event": { - "command": { - "commitTransaction": 1, - "lsid": "session0", - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": null, - "autocommit": false, - "writeConcern": { - "w": "majority" - } - }, - "command_name": "commitTransaction", - "database_name": "admin" - } - }, - { - "command_started_event": { - "command": { - "commitTransaction": 1, - "lsid": "session0", - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": null, - "autocommit": false, - "writeConcern": { - "w": "majority", - "wtimeout": 10000 - } - }, - "command_name": "commitTransaction", - "database_name": "admin" - } - } - ], - "outcome": { - "collection": { - "data": [ - { - "_id": 1 - } - ] - } - } - }, - { - "description": "commitTransaction succeeds after WriteConcernError InterruptedDueToReplStateChange", - "failPoint": { - "configureFailPoint": "failCommand", - "mode": { - "times": 1 - }, - "data": { - "failCommands": [ - "commitTransaction" - ], - "errorLabels": [ - "RetryableWriteError" - ], - "writeConcernError": { - "code": 11602, - "errmsg": "Replication is being shut down" - } - } - }, - "operations": [ - { - "name": "startTransaction", - "object": "session0", - "arguments": { - "options": { - "writeConcern": { - "w": "majority" - } - } - } - }, - { - "name": "insertOne", - "object": "collection", - "arguments": { - "session": "session0", - "document": { - "_id": 1 - } - }, - "result": { - "insertedId": 1 - } - }, - { - "name": "commitTransaction", - "object": "session0" - } - ], - "expectations": [ - { - "command_started_event": { - "command": { - "insert": "test", - "documents": [ - { - "_id": 1 - } - ], - "ordered": true, - "readConcern": null, - "lsid": "session0", - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": true, - "autocommit": false, - "writeConcern": null - }, - "command_name": "insert", - "database_name": "transaction-tests" - } - }, - { - "command_started_event": { - "command": { - "commitTransaction": 1, - "lsid": "session0", - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": null, - "autocommit": false, - "writeConcern": { - "w": "majority" - } - }, - "command_name": "commitTransaction", - "database_name": "admin" - } - }, - { - "command_started_event": { - "command": { - "commitTransaction": 1, - "lsid": "session0", - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": null, - "autocommit": false, - "writeConcern": { - "w": "majority", - "wtimeout": 10000 - } - }, - "command_name": "commitTransaction", - "database_name": "admin" - } - } - ], - "outcome": { - "collection": { - "data": [ - { - "_id": 1 - } - ] - } - } - }, - { - "description": "commitTransaction succeeds after WriteConcernError PrimarySteppedDown", - "failPoint": { - "configureFailPoint": "failCommand", - "mode": { - "times": 1 - }, - "data": { - "failCommands": [ - "commitTransaction" - ], - "errorLabels": [ - "RetryableWriteError" - ], - "writeConcernError": { - "code": 189, - "errmsg": "Replication is being shut down" - } - } - }, - "operations": [ - { - "name": "startTransaction", - "object": "session0", - "arguments": { - "options": { - "writeConcern": { - "w": "majority" - } - } - } - }, - { - "name": "insertOne", - "object": "collection", - "arguments": { - "session": "session0", - "document": { - "_id": 1 - } - }, - "result": { - "insertedId": 1 - } - }, - { - "name": "commitTransaction", - "object": "session0" - } - ], - "expectations": [ - { - "command_started_event": { - "command": { - "insert": "test", - "documents": [ - { - "_id": 1 - } - ], - "ordered": true, - "readConcern": null, - "lsid": "session0", - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": true, - "autocommit": false, - "writeConcern": null - }, - "command_name": "insert", - "database_name": "transaction-tests" - } - }, - { - "command_started_event": { - "command": { - "commitTransaction": 1, - "lsid": "session0", - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": null, - "autocommit": false, - "writeConcern": { - "w": "majority" - } - }, - "command_name": "commitTransaction", - "database_name": "admin" - } - }, - { - "command_started_event": { - "command": { - "commitTransaction": 1, - "lsid": "session0", - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": null, - "autocommit": false, - "writeConcern": { - "w": "majority", - "wtimeout": 10000 - } - }, - "command_name": "commitTransaction", - "database_name": "admin" - } - } - ], - "outcome": { - "collection": { - "data": [ - { - "_id": 1 - } - ] - } - } - }, - { - "description": "commitTransaction succeeds after WriteConcernError ShutdownInProgress", - "failPoint": { - "configureFailPoint": "failCommand", - "mode": { - "times": 1 - }, - "data": { - "failCommands": [ - "commitTransaction" - ], - "errorLabels": [ - "RetryableWriteError" - ], - "writeConcernError": { - "code": 91, - "errmsg": "Replication is being shut down" - } - } - }, - "operations": [ - { - "name": "startTransaction", - "object": "session0", - "arguments": { - "options": { - "writeConcern": { - "w": "majority" - } - } - } - }, - { - "name": "insertOne", - "object": "collection", - "arguments": { - "session": "session0", - "document": { - "_id": 1 - } - }, - "result": { - "insertedId": 1 - } - }, - { - "name": "commitTransaction", - "object": "session0" - } - ], - "expectations": [ - { - "command_started_event": { - "command": { - "insert": "test", - "documents": [ - { - "_id": 1 - } - ], - "ordered": true, - "readConcern": null, - "lsid": "session0", - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": true, - "autocommit": false, - "writeConcern": null - }, - "command_name": "insert", - "database_name": "transaction-tests" - } - }, - { - "command_started_event": { - "command": { - "commitTransaction": 1, - "lsid": "session0", - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": null, - "autocommit": false, - "writeConcern": { - "w": "majority" - } - }, - "command_name": "commitTransaction", - "database_name": "admin" - } - }, - { - "command_started_event": { - "command": { - "commitTransaction": 1, - "lsid": "session0", - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": null, - "autocommit": false, - "writeConcern": { - "w": "majority", - "wtimeout": 10000 - } - }, - "command_name": "commitTransaction", - "database_name": "admin" - } - } - ], - "outcome": { - "collection": { - "data": [ - { - "_id": 1 - } - ] - } - } - } - ] -} diff --git a/source/transactions/tests/legacy/retryable-commit-errorLabels.yml b/source/transactions/tests/legacy/retryable-commit-errorLabels.yml deleted file mode 100644 index d3a74d8f35..0000000000 --- a/source/transactions/tests/legacy/retryable-commit-errorLabels.yml +++ /dev/null @@ -1,1014 +0,0 @@ -runOn: - - - minServerVersion: "4.3.1" # failCommand errorLabels option - topology: ["replicaset", "sharded", "load-balanced"] - -database_name: &database_name "transaction-tests" -collection_name: &collection_name "test" - -data: [] - -tests: - - description: commitTransaction does not retry error without RetryableWriteError label - clientOptions: - retryWrites: false - failPoint: - configureFailPoint: failCommand - mode: { times: 1 } - data: - failCommands: ["commitTransaction"] - errorCode: 11600 # InterruptedAtShutdown, normally a retryable error code - errorLabels: [] # Override server behavior: do not send RetryableWriteError label with retryable code - operations: - - name: startTransaction - object: session0 - - name: insertOne - object: collection - arguments: - session: session0 - document: - _id: 1 - result: - insertedId: 1 - - name: commitTransaction - object: session0 - result: - errorLabelsOmit: ["RetryableWriteError", "TransientTransactionError"] - expectations: - - command_started_event: - command: - insert: *collection_name - documents: - - _id: 1 - ordered: true - readConcern: - lsid: session0 - txnNumber: - $numberLong: "1" - startTransaction: true - autocommit: false - writeConcern: - command_name: insert - database_name: *database_name - - command_started_event: - command: - commitTransaction: 1 - lsid: session0 - txnNumber: - $numberLong: "1" - startTransaction: - autocommit: false - writeConcern: - command_name: commitTransaction - database_name: admin - outcome: # Driver does not retry commit because there was no RetryableWriteError label on response - collection: - data: [] - - - description: commitTransaction retries once with RetryableWriteError from server - clientOptions: - retryWrites: false - failPoint: - configureFailPoint: failCommand - mode: { times: 1 } - data: - failCommands: ["commitTransaction"] - errorCode: 112 # WriteConflict, not a retryable error code - errorLabels: ["RetryableWriteError"] # Override server behavior: send RetryableWriteError label with non-retryable error code - operations: - - name: startTransaction - object: session0 - - name: insertOne - object: collection - arguments: - session: session0 - document: - _id: 1 - result: - insertedId: 1 - - name: commitTransaction - object: session0 - expectations: - - command_started_event: - command: - insert: *collection_name - documents: - - _id: 1 - ordered: true - readConcern: - lsid: session0 - txnNumber: - $numberLong: "1" - startTransaction: true - autocommit: false - writeConcern: - command_name: insert - database_name: *database_name - - command_started_event: - command: - commitTransaction: 1 - lsid: session0 - txnNumber: - $numberLong: "1" - startTransaction: - autocommit: false - writeConcern: - command_name: commitTransaction - database_name: admin - - command_started_event: - command: - commitTransaction: 1 - lsid: session0 - txnNumber: - $numberLong: "1" - startTransaction: - autocommit: false - writeConcern: { w: majority, wtimeout: 10000 } - command_name: commitTransaction - database_name: admin - outcome: # Driver retries commit and it succeeds - collection: - data: - - _id: 1 - - - description: commitTransaction succeeds after NotWritablePrimary - failPoint: - configureFailPoint: failCommand - mode: { times: 1 } - data: - failCommands: ["commitTransaction"] - errorCode: 10107 - errorLabels: ["RetryableWriteError"] - closeConnection: false - operations: - - name: startTransaction - object: session0 - - name: insertOne - object: collection - arguments: - session: session0 - document: - _id: 1 - result: - insertedId: 1 - - name: commitTransaction - object: session0 - expectations: - - command_started_event: - command: - insert: *collection_name - documents: - - _id: 1 - ordered: true - readConcern: - lsid: session0 - txnNumber: - $numberLong: "1" - startTransaction: true - autocommit: false - writeConcern: - command_name: insert - database_name: *database_name - - command_started_event: - command: - commitTransaction: 1 - lsid: session0 - txnNumber: - $numberLong: "1" - startTransaction: - autocommit: false - writeConcern: - command_name: commitTransaction - database_name: admin - - command_started_event: - command: - commitTransaction: 1 - lsid: session0 - txnNumber: - $numberLong: "1" - startTransaction: - autocommit: false - # commitTransaction applies w:majority on retries - writeConcern: { w: majority, wtimeout: 10000 } - command_name: commitTransaction - database_name: admin - outcome: - collection: - data: - - _id: 1 - - - description: commitTransaction succeeds after NotPrimaryOrSecondary - failPoint: - configureFailPoint: failCommand - mode: { times: 1 } - data: - failCommands: ["commitTransaction"] - errorCode: 13436 - errorLabels: ["RetryableWriteError"] - closeConnection: false - operations: - - name: startTransaction - object: session0 - - name: insertOne - object: collection - arguments: - session: session0 - document: - _id: 1 - result: - insertedId: 1 - - name: commitTransaction - object: session0 - expectations: - - command_started_event: - command: - insert: *collection_name - documents: - - _id: 1 - ordered: true - readConcern: - lsid: session0 - txnNumber: - $numberLong: "1" - startTransaction: true - autocommit: false - writeConcern: - command_name: insert - database_name: *database_name - - command_started_event: - command: - commitTransaction: 1 - lsid: session0 - txnNumber: - $numberLong: "1" - startTransaction: - autocommit: false - writeConcern: - command_name: commitTransaction - database_name: admin - - command_started_event: - command: - commitTransaction: 1 - lsid: session0 - txnNumber: - $numberLong: "1" - startTransaction: - autocommit: false - # commitTransaction applies w:majority on retries - writeConcern: { w: majority, wtimeout: 10000 } - command_name: commitTransaction - database_name: admin - outcome: - collection: - data: - - _id: 1 - - - description: commitTransaction succeeds after NotPrimaryNoSecondaryOk - failPoint: - configureFailPoint: failCommand - mode: { times: 1 } - data: - failCommands: ["commitTransaction"] - errorCode: 13435 - errorLabels: ["RetryableWriteError"] - closeConnection: false - operations: - - name: startTransaction - object: session0 - - name: insertOne - object: collection - arguments: - session: session0 - document: - _id: 1 - result: - insertedId: 1 - - name: commitTransaction - object: session0 - expectations: - - command_started_event: - command: - insert: *collection_name - documents: - - _id: 1 - ordered: true - readConcern: - lsid: session0 - txnNumber: - $numberLong: "1" - startTransaction: true - autocommit: false - writeConcern: - command_name: insert - database_name: *database_name - - command_started_event: - command: - commitTransaction: 1 - lsid: session0 - txnNumber: - $numberLong: "1" - startTransaction: - autocommit: false - writeConcern: - command_name: commitTransaction - database_name: admin - - command_started_event: - command: - commitTransaction: 1 - lsid: session0 - txnNumber: - $numberLong: "1" - startTransaction: - autocommit: false - # commitTransaction applies w:majority on retries - writeConcern: { w: majority, wtimeout: 10000 } - command_name: commitTransaction - database_name: admin - outcome: - collection: - data: - - _id: 1 - - - description: commitTransaction succeeds after InterruptedDueToReplStateChange - failPoint: - configureFailPoint: failCommand - mode: { times: 1 } - data: - failCommands: ["commitTransaction"] - errorCode: 11602 - errorLabels: ["RetryableWriteError"] - closeConnection: false - operations: - - name: startTransaction - object: session0 - - name: insertOne - object: collection - arguments: - session: session0 - document: - _id: 1 - result: - insertedId: 1 - - name: commitTransaction - object: session0 - expectations: - - command_started_event: - command: - insert: *collection_name - documents: - - _id: 1 - ordered: true - readConcern: - lsid: session0 - txnNumber: - $numberLong: "1" - startTransaction: true - autocommit: false - writeConcern: - command_name: insert - database_name: *database_name - - command_started_event: - command: - commitTransaction: 1 - lsid: session0 - txnNumber: - $numberLong: "1" - startTransaction: - autocommit: false - writeConcern: - command_name: commitTransaction - database_name: admin - - command_started_event: - command: - commitTransaction: 1 - lsid: session0 - txnNumber: - $numberLong: "1" - startTransaction: - autocommit: false - # commitTransaction applies w:majority on retries - writeConcern: { w: majority, wtimeout: 10000 } - command_name: commitTransaction - database_name: admin - outcome: - collection: - data: - - _id: 1 - - - description: commitTransaction succeeds after PrimarySteppedDown - failPoint: - configureFailPoint: failCommand - mode: { times: 1 } - data: - failCommands: ["commitTransaction"] - errorCode: 189 - errorLabels: ["RetryableWriteError"] - closeConnection: false - operations: - - name: startTransaction - object: session0 - - name: insertOne - object: collection - arguments: - session: session0 - document: - _id: 1 - result: - insertedId: 1 - - name: commitTransaction - object: session0 - expectations: - - command_started_event: - command: - insert: *collection_name - documents: - - _id: 1 - ordered: true - readConcern: - lsid: session0 - txnNumber: - $numberLong: "1" - startTransaction: true - autocommit: false - writeConcern: - command_name: insert - database_name: *database_name - - command_started_event: - command: - commitTransaction: 1 - lsid: session0 - txnNumber: - $numberLong: "1" - startTransaction: - autocommit: false - writeConcern: - command_name: commitTransaction - database_name: admin - - command_started_event: - command: - commitTransaction: 1 - lsid: session0 - txnNumber: - $numberLong: "1" - startTransaction: - autocommit: false - # commitTransaction applies w:majority on retries - writeConcern: { w: majority, wtimeout: 10000 } - command_name: commitTransaction - database_name: admin - outcome: - collection: - data: - - _id: 1 - - - description: commitTransaction succeeds after HostNotFound - failPoint: - configureFailPoint: failCommand - mode: { times: 1 } - data: - failCommands: ["commitTransaction"] - errorCode: 7 - errorLabels: ["RetryableWriteError"] - closeConnection: false - operations: - - name: startTransaction - object: session0 - - name: insertOne - object: collection - arguments: - session: session0 - document: - _id: 1 - result: - insertedId: 1 - - name: commitTransaction - object: session0 - expectations: - - command_started_event: - command: - insert: *collection_name - documents: - - _id: 1 - ordered: true - readConcern: - lsid: session0 - txnNumber: - $numberLong: "1" - startTransaction: true - autocommit: false - writeConcern: - command_name: insert - database_name: *database_name - - command_started_event: - command: - commitTransaction: 1 - lsid: session0 - txnNumber: - $numberLong: "1" - startTransaction: - autocommit: false - writeConcern: - command_name: commitTransaction - database_name: admin - - command_started_event: - command: - commitTransaction: 1 - lsid: session0 - txnNumber: - $numberLong: "1" - startTransaction: - autocommit: false - # commitTransaction applies w:majority on retries - writeConcern: { w: majority, wtimeout: 10000 } - command_name: commitTransaction - database_name: admin - outcome: - collection: - data: - - _id: 1 - - - description: commitTransaction succeeds after HostUnreachable - failPoint: - configureFailPoint: failCommand - mode: { times: 1 } - data: - failCommands: ["commitTransaction"] - errorCode: 6 - errorLabels: ["RetryableWriteError"] - closeConnection: false - operations: - - name: startTransaction - object: session0 - - name: insertOne - object: collection - arguments: - session: session0 - document: - _id: 1 - result: - insertedId: 1 - - name: commitTransaction - object: session0 - expectations: - - command_started_event: - command: - insert: *collection_name - documents: - - _id: 1 - ordered: true - readConcern: - lsid: session0 - txnNumber: - $numberLong: "1" - startTransaction: true - autocommit: false - writeConcern: - command_name: insert - database_name: *database_name - - command_started_event: - command: - commitTransaction: 1 - lsid: session0 - txnNumber: - $numberLong: "1" - startTransaction: - autocommit: false - writeConcern: - command_name: commitTransaction - database_name: admin - - command_started_event: - command: - commitTransaction: 1 - lsid: session0 - txnNumber: - $numberLong: "1" - startTransaction: - autocommit: false - # commitTransaction applies w:majority on retries - writeConcern: { w: majority, wtimeout: 10000 } - command_name: commitTransaction - database_name: admin - outcome: - collection: - data: - - _id: 1 - - - description: commitTransaction succeeds after SocketException - failPoint: - configureFailPoint: failCommand - mode: { times: 1 } - data: - failCommands: ["commitTransaction"] - errorCode: 9001 - errorLabels: ["RetryableWriteError"] - closeConnection: false - operations: - - name: startTransaction - object: session0 - - name: insertOne - object: collection - arguments: - session: session0 - document: - _id: 1 - result: - insertedId: 1 - - name: commitTransaction - object: session0 - expectations: - - command_started_event: - command: - insert: *collection_name - documents: - - _id: 1 - ordered: true - readConcern: - lsid: session0 - txnNumber: - $numberLong: "1" - startTransaction: true - autocommit: false - writeConcern: - command_name: insert - database_name: *database_name - - command_started_event: - command: - commitTransaction: 1 - lsid: session0 - txnNumber: - $numberLong: "1" - startTransaction: - autocommit: false - writeConcern: - command_name: commitTransaction - database_name: admin - - command_started_event: - command: - commitTransaction: 1 - lsid: session0 - txnNumber: - $numberLong: "1" - startTransaction: - autocommit: false - # commitTransaction applies w:majority on retries - writeConcern: { w: majority, wtimeout: 10000 } - command_name: commitTransaction - database_name: admin - outcome: - collection: - data: - - _id: 1 - - - description: commitTransaction succeeds after NetworkTimeout - failPoint: - configureFailPoint: failCommand - mode: { times: 1 } - data: - failCommands: ["commitTransaction"] - errorCode: 89 - errorLabels: ["RetryableWriteError"] - closeConnection: false - operations: - - name: startTransaction - object: session0 - - name: insertOne - object: collection - arguments: - session: session0 - document: - _id: 1 - result: - insertedId: 1 - - name: commitTransaction - object: session0 - expectations: - - command_started_event: - command: - insert: *collection_name - documents: - - _id: 1 - ordered: true - readConcern: - lsid: session0 - txnNumber: - $numberLong: "1" - startTransaction: true - autocommit: false - writeConcern: - command_name: insert - database_name: *database_name - - command_started_event: - command: - commitTransaction: 1 - lsid: session0 - txnNumber: - $numberLong: "1" - startTransaction: - autocommit: false - writeConcern: - command_name: commitTransaction - database_name: admin - - command_started_event: - command: - commitTransaction: 1 - lsid: session0 - txnNumber: - $numberLong: "1" - startTransaction: - autocommit: false - # commitTransaction applies w:majority on retries - writeConcern: { w: majority, wtimeout: 10000 } - command_name: commitTransaction - database_name: admin - outcome: - collection: - data: - - _id: 1 - - - description: commitTransaction succeeds after WriteConcernError InterruptedAtShutdown - failPoint: - configureFailPoint: failCommand - mode: { times: 1 } - data: - failCommands: ["commitTransaction"] - errorLabels: ["RetryableWriteError"] - writeConcernError: - code: 11600 - errmsg: Replication is being shut down - operations: - - name: startTransaction - object: session0 - arguments: - options: - writeConcern: - w: majority - - name: insertOne - object: collection - arguments: - session: session0 - document: - _id: 1 - result: - insertedId: 1 - - name: commitTransaction - object: session0 - expectations: - - command_started_event: - command: - insert: *collection_name - documents: - - _id: 1 - ordered: true - readConcern: - lsid: session0 - txnNumber: - $numberLong: "1" - startTransaction: true - autocommit: false - writeConcern: - command_name: insert - database_name: *database_name - - command_started_event: - command: - commitTransaction: 1 - lsid: session0 - txnNumber: - $numberLong: "1" - startTransaction: - autocommit: false - writeConcern: - w: majority - command_name: commitTransaction - database_name: admin - - command_started_event: - command: - commitTransaction: 1 - lsid: session0 - txnNumber: - $numberLong: "1" - startTransaction: - autocommit: false - # commitTransaction applies w:majority on retries - writeConcern: { w: majority, wtimeout: 10000 } - command_name: commitTransaction - database_name: admin - outcome: - collection: - data: - - _id: 1 - - - description: commitTransaction succeeds after WriteConcernError InterruptedDueToReplStateChange - failPoint: - configureFailPoint: failCommand - mode: { times: 1 } - data: - failCommands: ["commitTransaction"] - errorLabels: ["RetryableWriteError"] - writeConcernError: - code: 11602 - errmsg: Replication is being shut down - operations: - - name: startTransaction - object: session0 - arguments: - options: - writeConcern: - w: majority - - name: insertOne - object: collection - arguments: - session: session0 - document: - _id: 1 - result: - insertedId: 1 - - name: commitTransaction - object: session0 - expectations: - - command_started_event: - command: - insert: *collection_name - documents: - - _id: 1 - ordered: true - readConcern: - lsid: session0 - txnNumber: - $numberLong: "1" - startTransaction: true - autocommit: false - writeConcern: - command_name: insert - database_name: *database_name - - command_started_event: - command: - commitTransaction: 1 - lsid: session0 - txnNumber: - $numberLong: "1" - startTransaction: - autocommit: false - writeConcern: - w: majority - command_name: commitTransaction - database_name: admin - - command_started_event: - command: - commitTransaction: 1 - lsid: session0 - txnNumber: - $numberLong: "1" - startTransaction: - autocommit: false - # commitTransaction applies w:majority on retries - writeConcern: { w: majority, wtimeout: 10000 } - command_name: commitTransaction - database_name: admin - outcome: - collection: - data: - - _id: 1 - - - description: commitTransaction succeeds after WriteConcernError PrimarySteppedDown - failPoint: - configureFailPoint: failCommand - mode: { times: 1 } - data: - failCommands: ["commitTransaction"] - errorLabels: ["RetryableWriteError"] - writeConcernError: - code: 189 - errmsg: Replication is being shut down - operations: - - name: startTransaction - object: session0 - arguments: - options: - writeConcern: - w: majority - - name: insertOne - object: collection - arguments: - session: session0 - document: - _id: 1 - result: - insertedId: 1 - - name: commitTransaction - object: session0 - expectations: - - command_started_event: - command: - insert: *collection_name - documents: - - _id: 1 - ordered: true - readConcern: - lsid: session0 - txnNumber: - $numberLong: "1" - startTransaction: true - autocommit: false - writeConcern: - command_name: insert - database_name: *database_name - - command_started_event: - command: - commitTransaction: 1 - lsid: session0 - txnNumber: - $numberLong: "1" - startTransaction: - autocommit: false - writeConcern: - w: majority - command_name: commitTransaction - database_name: admin - - command_started_event: - command: - commitTransaction: 1 - lsid: session0 - txnNumber: - $numberLong: "1" - startTransaction: - autocommit: false - # commitTransaction applies w:majority on retries - writeConcern: { w: majority, wtimeout: 10000 } - command_name: commitTransaction - database_name: admin - outcome: - collection: - data: - - _id: 1 - - - description: commitTransaction succeeds after WriteConcernError ShutdownInProgress - failPoint: - configureFailPoint: failCommand - mode: { times: 1 } - data: - failCommands: ["commitTransaction"] - errorLabels: ["RetryableWriteError"] - writeConcernError: - code: 91 - errmsg: Replication is being shut down - operations: - - name: startTransaction - object: session0 - arguments: - options: - writeConcern: - w: majority - - name: insertOne - object: collection - arguments: - session: session0 - document: - _id: 1 - result: - insertedId: 1 - - name: commitTransaction - object: session0 - expectations: - - command_started_event: - command: - insert: *collection_name - documents: - - _id: 1 - ordered: true - readConcern: - lsid: session0 - txnNumber: - $numberLong: "1" - startTransaction: true - autocommit: false - writeConcern: - command_name: insert - database_name: *database_name - - command_started_event: - command: - commitTransaction: 1 - lsid: session0 - txnNumber: - $numberLong: "1" - startTransaction: - autocommit: false - writeConcern: - w: majority - command_name: commitTransaction - database_name: admin - - command_started_event: - command: - commitTransaction: 1 - lsid: session0 - txnNumber: - $numberLong: "1" - startTransaction: - autocommit: false - # commitTransaction applies w:majority on retries - writeConcern: { w: majority, wtimeout: 10000 } - command_name: commitTransaction - database_name: admin - outcome: - collection: - data: - - _id: 1 diff --git a/source/transactions/tests/legacy/retryable-commit-forbid_serverless.json b/source/transactions/tests/legacy/retryable-commit-forbid_serverless.json deleted file mode 100644 index 374f18d7ef..0000000000 --- a/source/transactions/tests/legacy/retryable-commit-forbid_serverless.json +++ /dev/null @@ -1,429 +0,0 @@ -{ - "runOn": [ - { - "minServerVersion": "4.0", - "topology": [ - "replicaset" - ] - }, - { - "minServerVersion": "4.1.8", - "topology": [ - "sharded", - "load-balanced" - ], - "serverless": "forbid" - } - ], - "database_name": "transaction-tests", - "collection_name": "test", - "data": [], - "tests": [ - { - "description": "commitTransaction fails after two errors", - "clientOptions": { - "retryWrites": false - }, - "failPoint": { - "configureFailPoint": "failCommand", - "mode": { - "times": 2 - }, - "data": { - "failCommands": [ - "commitTransaction" - ], - "closeConnection": true - } - }, - "operations": [ - { - "name": "startTransaction", - "object": "session0" - }, - { - "name": "insertOne", - "object": "collection", - "arguments": { - "session": "session0", - "document": { - "_id": 1 - } - }, - "result": { - "insertedId": 1 - } - }, - { - "name": "commitTransaction", - "object": "session0", - "result": { - "errorLabelsContain": [ - "RetryableWriteError", - "UnknownTransactionCommitResult" - ], - "errorLabelsOmit": [ - "TransientTransactionError" - ] - } - }, - { - "name": "commitTransaction", - "object": "session0" - } - ], - "expectations": [ - { - "command_started_event": { - "command": { - "insert": "test", - "documents": [ - { - "_id": 1 - } - ], - "ordered": true, - "readConcern": null, - "lsid": "session0", - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": true, - "autocommit": false, - "writeConcern": null - }, - "command_name": "insert", - "database_name": "transaction-tests" - } - }, - { - "command_started_event": { - "command": { - "commitTransaction": 1, - "lsid": "session0", - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": null, - "autocommit": false, - "writeConcern": null - }, - "command_name": "commitTransaction", - "database_name": "admin" - } - }, - { - "command_started_event": { - "command": { - "commitTransaction": 1, - "lsid": "session0", - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": null, - "autocommit": false, - "writeConcern": { - "w": "majority", - "wtimeout": 10000 - } - }, - "command_name": "commitTransaction", - "database_name": "admin" - } - }, - { - "command_started_event": { - "command": { - "commitTransaction": 1, - "lsid": "session0", - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": null, - "autocommit": false, - "writeConcern": { - "w": "majority", - "wtimeout": 10000 - } - }, - "command_name": "commitTransaction", - "database_name": "admin" - } - } - ], - "outcome": { - "collection": { - "data": [ - { - "_id": 1 - } - ] - } - } - }, - { - "description": "commitTransaction applies majority write concern on retries", - "clientOptions": { - "retryWrites": false - }, - "failPoint": { - "configureFailPoint": "failCommand", - "mode": { - "times": 2 - }, - "data": { - "failCommands": [ - "commitTransaction" - ], - "closeConnection": true - } - }, - "operations": [ - { - "name": "startTransaction", - "object": "session0", - "arguments": { - "options": { - "writeConcern": { - "w": 2, - "j": true, - "wtimeout": 5000 - } - } - } - }, - { - "name": "insertOne", - "object": "collection", - "arguments": { - "session": "session0", - "document": { - "_id": 1 - } - }, - "result": { - "insertedId": 1 - } - }, - { - "name": "commitTransaction", - "object": "session0", - "result": { - "errorLabelsContain": [ - "RetryableWriteError", - "UnknownTransactionCommitResult" - ], - "errorLabelsOmit": [ - "TransientTransactionError" - ] - } - }, - { - "name": "commitTransaction", - "object": "session0" - } - ], - "expectations": [ - { - "command_started_event": { - "command": { - "insert": "test", - "documents": [ - { - "_id": 1 - } - ], - "ordered": true, - "readConcern": null, - "lsid": "session0", - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": true, - "autocommit": false, - "writeConcern": null - }, - "command_name": "insert", - "database_name": "transaction-tests" - } - }, - { - "command_started_event": { - "command": { - "commitTransaction": 1, - "lsid": "session0", - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": null, - "autocommit": false, - "writeConcern": { - "w": 2, - "j": true, - "wtimeout": 5000 - } - }, - "command_name": "commitTransaction", - "database_name": "admin" - } - }, - { - "command_started_event": { - "command": { - "commitTransaction": 1, - "lsid": "session0", - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": null, - "autocommit": false, - "writeConcern": { - "w": "majority", - "j": true, - "wtimeout": 5000 - } - }, - "command_name": "commitTransaction", - "database_name": "admin" - } - }, - { - "command_started_event": { - "command": { - "commitTransaction": 1, - "lsid": "session0", - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": null, - "autocommit": false, - "writeConcern": { - "w": "majority", - "j": true, - "wtimeout": 5000 - } - }, - "command_name": "commitTransaction", - "database_name": "admin" - } - } - ], - "outcome": { - "collection": { - "data": [ - { - "_id": 1 - } - ] - } - } - }, - { - "description": "commitTransaction succeeds after connection error", - "failPoint": { - "configureFailPoint": "failCommand", - "mode": { - "times": 1 - }, - "data": { - "failCommands": [ - "commitTransaction" - ], - "closeConnection": true - } - }, - "operations": [ - { - "name": "startTransaction", - "object": "session0" - }, - { - "name": "insertOne", - "object": "collection", - "arguments": { - "session": "session0", - "document": { - "_id": 1 - } - }, - "result": { - "insertedId": 1 - } - }, - { - "name": "commitTransaction", - "object": "session0" - } - ], - "expectations": [ - { - "command_started_event": { - "command": { - "insert": "test", - "documents": [ - { - "_id": 1 - } - ], - "ordered": true, - "readConcern": null, - "lsid": "session0", - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": true, - "autocommit": false, - "writeConcern": null - }, - "command_name": "insert", - "database_name": "transaction-tests" - } - }, - { - "command_started_event": { - "command": { - "commitTransaction": 1, - "lsid": "session0", - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": null, - "autocommit": false, - "writeConcern": null - }, - "command_name": "commitTransaction", - "database_name": "admin" - } - }, - { - "command_started_event": { - "command": { - "commitTransaction": 1, - "lsid": "session0", - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": null, - "autocommit": false, - "writeConcern": { - "w": "majority", - "wtimeout": 10000 - } - }, - "command_name": "commitTransaction", - "database_name": "admin" - } - } - ], - "outcome": { - "collection": { - "data": [ - { - "_id": 1 - } - ] - } - } - } - ] -} diff --git a/source/transactions/tests/legacy/retryable-commit-forbid_serverless.yml b/source/transactions/tests/legacy/retryable-commit-forbid_serverless.yml deleted file mode 100644 index 17e1edd45a..0000000000 --- a/source/transactions/tests/legacy/retryable-commit-forbid_serverless.yml +++ /dev/null @@ -1,270 +0,0 @@ -runOn: - - - minServerVersion: "4.0" - topology: ["replicaset"] - - - minServerVersion: "4.1.8" - topology: ["sharded", "load-balanced"] - # This file contains tests originally found in retryable-commit.yml that - # are incompatible with serverless: - # - # * Failing commitTransaction with closeConnection:true may abort the - # transaction (CLOUDP-202309). - # * Fail points using state change errors (e.g. InterruptedAtShutdown, - # ShutdownInProgress) may remain enabled indefinitely (CLOUDP-84573). - serverless: "forbid" - -database_name: &database_name "transaction-tests" -collection_name: &collection_name "test" - -data: [] - -tests: - - description: commitTransaction fails after two errors - - clientOptions: - retryWrites: false - - failPoint: - configureFailPoint: failCommand - mode: { times: 2 } - data: - failCommands: ["commitTransaction"] - closeConnection: true - - operations: - - name: startTransaction - object: session0 - - name: insertOne - object: collection - arguments: - session: session0 - document: - _id: 1 - result: - insertedId: 1 - # First call to commit fails after a single retry attempt. - - name: commitTransaction - object: session0 - result: - errorLabelsContain: ["RetryableWriteError", "UnknownTransactionCommitResult"] - errorLabelsOmit: ["TransientTransactionError"] - # Second call to commit succeeds because the failpoint was disabled. - - name: commitTransaction - object: session0 - - expectations: - - command_started_event: - command: - insert: *collection_name - documents: - - _id: 1 - ordered: true - readConcern: - lsid: session0 - txnNumber: - $numberLong: "1" - startTransaction: true - autocommit: false - writeConcern: - command_name: insert - database_name: *database_name - - command_started_event: - command: - commitTransaction: 1 - lsid: session0 - txnNumber: - $numberLong: "1" - startTransaction: - autocommit: false - writeConcern: - command_name: commitTransaction - database_name: admin - - command_started_event: - command: - commitTransaction: 1 - lsid: session0 - txnNumber: - $numberLong: "1" - startTransaction: - autocommit: false - # commitTransaction applies w:majority on retries - writeConcern: { w: majority, wtimeout: 10000 } - command_name: commitTransaction - database_name: admin - - command_started_event: - command: - commitTransaction: 1 - lsid: session0 - txnNumber: - $numberLong: "1" - startTransaction: - autocommit: false - writeConcern: { w: majority, wtimeout: 10000 } - command_name: commitTransaction - database_name: admin - - outcome: - collection: - data: - - _id: 1 - - - description: commitTransaction applies majority write concern on retries - - clientOptions: - retryWrites: false - - failPoint: - configureFailPoint: failCommand - mode: { times: 2 } - data: - failCommands: ["commitTransaction"] - closeConnection: true - - operations: - - name: startTransaction - object: session0 - arguments: - options: - writeConcern: { w: 2, j: true, wtimeout: 5000 } - - name: insertOne - object: collection - arguments: - session: session0 - document: - _id: 1 - result: - insertedId: 1 - # First call to commit fails after a single retry attempt. - - name: commitTransaction - object: session0 - result: - errorLabelsContain: ["RetryableWriteError", "UnknownTransactionCommitResult"] - errorLabelsOmit: ["TransientTransactionError"] - # Second call to commit succeeds because the failpoint was disabled. - - name: commitTransaction - object: session0 - - expectations: - - command_started_event: - command: - insert: *collection_name - documents: - - _id: 1 - ordered: true - readConcern: - lsid: session0 - txnNumber: - $numberLong: "1" - startTransaction: true - autocommit: false - writeConcern: - command_name: insert - database_name: *database_name - - command_started_event: - command: - commitTransaction: 1 - lsid: session0 - txnNumber: - $numberLong: "1" - startTransaction: - autocommit: false - writeConcern: { w: 2, j: true, wtimeout: 5000 } - command_name: commitTransaction - database_name: admin - - command_started_event: - command: - commitTransaction: 1 - lsid: session0 - txnNumber: - $numberLong: "1" - startTransaction: - autocommit: false - # commitTransaction applies w:majority on retries - writeConcern: { w: majority, j: true, wtimeout: 5000 } - command_name: commitTransaction - database_name: admin - - command_started_event: - command: - commitTransaction: 1 - lsid: session0 - txnNumber: - $numberLong: "1" - startTransaction: - autocommit: false - writeConcern: { w: majority, j: true, wtimeout: 5000 } - command_name: commitTransaction - database_name: admin - - outcome: - collection: - data: - - _id: 1 - - - description: commitTransaction succeeds after connection error - - failPoint: - configureFailPoint: failCommand - mode: { times: 1 } - data: - failCommands: ["commitTransaction"] - closeConnection: true - - operations: - - name: startTransaction - object: session0 - - name: insertOne - object: collection - arguments: - session: session0 - document: - _id: 1 - result: - insertedId: 1 - - name: commitTransaction - object: session0 - - expectations: - - command_started_event: - command: - insert: *collection_name - documents: - - _id: 1 - ordered: true - readConcern: - lsid: session0 - txnNumber: - $numberLong: "1" - startTransaction: true - autocommit: false - writeConcern: - command_name: insert - database_name: *database_name - - command_started_event: - command: - commitTransaction: 1 - lsid: session0 - txnNumber: - $numberLong: "1" - startTransaction: - autocommit: false - writeConcern: - command_name: commitTransaction - database_name: admin - - command_started_event: - command: - commitTransaction: 1 - lsid: session0 - txnNumber: - $numberLong: "1" - startTransaction: - autocommit: false - # commitTransaction applies w:majority on retries - writeConcern: { w: majority, wtimeout: 10000 } - command_name: commitTransaction - database_name: admin - - outcome: - collection: - data: - - _id: 1 diff --git a/source/transactions/tests/legacy/retryable-commit.json b/source/transactions/tests/legacy/retryable-commit.json deleted file mode 100644 index e56440d303..0000000000 --- a/source/transactions/tests/legacy/retryable-commit.json +++ /dev/null @@ -1,222 +0,0 @@ -{ - "runOn": [ - { - "minServerVersion": "4.0", - "topology": [ - "replicaset" - ] - }, - { - "minServerVersion": "4.1.8", - "topology": [ - "sharded", - "load-balanced" - ] - } - ], - "database_name": "transaction-tests", - "collection_name": "test", - "data": [], - "tests": [ - { - "description": "commitTransaction fails after Interrupted", - "failPoint": { - "configureFailPoint": "failCommand", - "mode": { - "times": 1 - }, - "data": { - "failCommands": [ - "commitTransaction" - ], - "errorCode": 11601, - "closeConnection": false - } - }, - "operations": [ - { - "name": "startTransaction", - "object": "session0" - }, - { - "name": "insertOne", - "object": "collection", - "arguments": { - "session": "session0", - "document": { - "_id": 1 - } - }, - "result": { - "insertedId": 1 - } - }, - { - "name": "commitTransaction", - "object": "session0", - "result": { - "errorCodeName": "Interrupted", - "errorLabelsOmit": [ - "RetryableWriteError", - "TransientTransactionError", - "UnknownTransactionCommitResult" - ] - } - } - ], - "expectations": [ - { - "command_started_event": { - "command": { - "insert": "test", - "documents": [ - { - "_id": 1 - } - ], - "ordered": true, - "readConcern": null, - "lsid": "session0", - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": true, - "autocommit": false, - "writeConcern": null - }, - "command_name": "insert", - "database_name": "transaction-tests" - } - }, - { - "command_started_event": { - "command": { - "commitTransaction": 1, - "lsid": "session0", - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": null, - "autocommit": false, - "writeConcern": null - }, - "command_name": "commitTransaction", - "database_name": "admin" - } - } - ], - "outcome": { - "collection": { - "data": [] - } - } - }, - { - "description": "commitTransaction is not retried after UnsatisfiableWriteConcern error", - "failPoint": { - "configureFailPoint": "failCommand", - "mode": { - "times": 1 - }, - "data": { - "failCommands": [ - "commitTransaction" - ], - "writeConcernError": { - "code": 100, - "errmsg": "Not enough data-bearing nodes" - } - } - }, - "operations": [ - { - "name": "startTransaction", - "object": "session0", - "arguments": { - "options": { - "writeConcern": { - "w": "majority" - } - } - } - }, - { - "name": "insertOne", - "object": "collection", - "arguments": { - "session": "session0", - "document": { - "_id": 1 - } - }, - "result": { - "insertedId": 1 - } - }, - { - "name": "commitTransaction", - "object": "session0", - "result": { - "errorLabelsOmit": [ - "RetryableWriteError", - "TransientTransactionError", - "UnknownTransactionCommitResult" - ] - } - } - ], - "expectations": [ - { - "command_started_event": { - "command": { - "insert": "test", - "documents": [ - { - "_id": 1 - } - ], - "ordered": true, - "readConcern": null, - "lsid": "session0", - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": true, - "autocommit": false, - "writeConcern": null - }, - "command_name": "insert", - "database_name": "transaction-tests" - } - }, - { - "command_started_event": { - "command": { - "commitTransaction": 1, - "lsid": "session0", - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": null, - "autocommit": false, - "writeConcern": { - "w": "majority" - } - }, - "command_name": "commitTransaction", - "database_name": "admin" - } - } - ], - "outcome": { - "collection": { - "data": [ - { - "_id": 1 - } - ] - } - } - } - ] -} diff --git a/source/transactions/tests/legacy/retryable-commit.yml b/source/transactions/tests/legacy/retryable-commit.yml deleted file mode 100644 index 06f2e6de7c..0000000000 --- a/source/transactions/tests/legacy/retryable-commit.yml +++ /dev/null @@ -1,137 +0,0 @@ -runOn: - - - minServerVersion: "4.0" - topology: ["replicaset"] - - - minServerVersion: "4.1.8" - topology: ["sharded", "load-balanced"] - -database_name: &database_name "transaction-tests" -collection_name: &collection_name "test" - -data: [] - -tests: - - description: commitTransaction fails after Interrupted - - failPoint: - configureFailPoint: failCommand - mode: { times: 1 } - data: - failCommands: ["commitTransaction"] - errorCode: 11601 - closeConnection: false - - operations: - - name: startTransaction - object: session0 - - name: insertOne - object: collection - arguments: - session: session0 - document: - _id: 1 - result: - insertedId: 1 - - name: commitTransaction - object: session0 - result: - errorCodeName: Interrupted - errorLabelsOmit: ["RetryableWriteError", "TransientTransactionError", "UnknownTransactionCommitResult"] - - expectations: - - command_started_event: - command: - insert: *collection_name - documents: - - _id: 1 - ordered: true - readConcern: - lsid: session0 - txnNumber: - $numberLong: "1" - startTransaction: true - autocommit: false - writeConcern: - command_name: insert - database_name: *database_name - - command_started_event: - command: - commitTransaction: 1 - lsid: session0 - txnNumber: - $numberLong: "1" - startTransaction: - autocommit: false - writeConcern: - command_name: commitTransaction - database_name: admin - - outcome: - collection: - data: [] - - - description: commitTransaction is not retried after UnsatisfiableWriteConcern error - - failPoint: - configureFailPoint: failCommand - mode: { times: 1 } - data: - failCommands: ["commitTransaction"] - writeConcernError: - code: 100 - errmsg: Not enough data-bearing nodes - - operations: - - name: startTransaction - object: session0 - arguments: - options: - writeConcern: - w: majority - - name: insertOne - object: collection - arguments: - session: session0 - document: - _id: 1 - result: - insertedId: 1 - - name: commitTransaction - object: session0 - result: - errorLabelsOmit: ["RetryableWriteError", "TransientTransactionError", "UnknownTransactionCommitResult"] - - expectations: - - command_started_event: - command: - insert: *collection_name - documents: - - _id: 1 - ordered: true - readConcern: - lsid: session0 - txnNumber: - $numberLong: "1" - startTransaction: true - autocommit: false - writeConcern: - command_name: insert - database_name: *database_name - - command_started_event: - command: - commitTransaction: 1 - lsid: session0 - txnNumber: - $numberLong: "1" - startTransaction: - autocommit: false - writeConcern: - w: majority - command_name: commitTransaction - database_name: admin - - outcome: - collection: - data: - - _id: 1 diff --git a/source/transactions/tests/legacy/retryable-writes.json b/source/transactions/tests/legacy/retryable-writes.json deleted file mode 100644 index 93ad04ef8f..0000000000 --- a/source/transactions/tests/legacy/retryable-writes.json +++ /dev/null @@ -1,344 +0,0 @@ -{ - "runOn": [ - { - "minServerVersion": "4.0", - "topology": [ - "replicaset" - ] - }, - { - "minServerVersion": "4.1.8", - "topology": [ - "sharded", - "load-balanced" - ] - } - ], - "database_name": "transaction-tests", - "collection_name": "test", - "data": [], - "tests": [ - { - "description": "increment txnNumber", - "clientOptions": { - "retryWrites": true - }, - "operations": [ - { - "name": "startTransaction", - "object": "session0" - }, - { - "name": "insertOne", - "object": "collection", - "arguments": { - "session": "session0", - "document": { - "_id": 1 - } - }, - "result": { - "insertedId": 1 - } - }, - { - "name": "commitTransaction", - "object": "session0" - }, - { - "name": "insertOne", - "object": "collection", - "arguments": { - "session": "session0", - "document": { - "_id": 2 - } - }, - "result": { - "insertedId": 2 - } - }, - { - "name": "startTransaction", - "object": "session0" - }, - { - "name": "insertOne", - "object": "collection", - "arguments": { - "session": "session0", - "document": { - "_id": 3 - } - }, - "result": { - "insertedId": 3 - } - }, - { - "name": "abortTransaction", - "object": "session0" - }, - { - "name": "insertMany", - "object": "collection", - "arguments": { - "documents": [ - { - "_id": 4 - }, - { - "_id": 5 - } - ], - "session": "session0" - }, - "result": { - "insertedIds": { - "0": 4, - "1": 5 - } - } - } - ], - "expectations": [ - { - "command_started_event": { - "command": { - "insert": "test", - "documents": [ - { - "_id": 1 - } - ], - "ordered": true, - "readConcern": null, - "lsid": "session0", - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": true, - "autocommit": false, - "writeConcern": null - }, - "command_name": "insert", - "database_name": "transaction-tests" - } - }, - { - "command_started_event": { - "command": { - "commitTransaction": 1, - "lsid": "session0", - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": null, - "autocommit": false, - "writeConcern": null - }, - "command_name": "commitTransaction", - "database_name": "admin" - } - }, - { - "command_started_event": { - "command": { - "insert": "test", - "documents": [ - { - "_id": 2 - } - ], - "ordered": true, - "readConcern": null, - "lsid": "session0", - "txnNumber": { - "$numberLong": "2" - }, - "startTransaction": null, - "autocommit": null, - "writeConcern": null - }, - "command_name": "insert", - "database_name": "transaction-tests" - } - }, - { - "command_started_event": { - "command": { - "insert": "test", - "documents": [ - { - "_id": 3 - } - ], - "ordered": true, - "readConcern": { - "afterClusterTime": 42 - }, - "lsid": "session0", - "txnNumber": { - "$numberLong": "3" - }, - "startTransaction": true, - "autocommit": false, - "writeConcern": null - }, - "command_name": "insert", - "database_name": "transaction-tests" - } - }, - { - "command_started_event": { - "command": { - "abortTransaction": 1, - "lsid": "session0", - "txnNumber": { - "$numberLong": "3" - }, - "startTransaction": null, - "autocommit": false, - "writeConcern": null - }, - "command_name": "abortTransaction", - "database_name": "admin" - } - }, - { - "command_started_event": { - "command": { - "insert": "test", - "documents": [ - { - "_id": 4 - }, - { - "_id": 5 - } - ], - "ordered": true, - "readConcern": null, - "lsid": "session0", - "txnNumber": { - "$numberLong": "4" - }, - "startTransaction": null, - "autocommit": null, - "writeConcern": null - }, - "command_name": "insert", - "database_name": "transaction-tests" - } - } - ], - "outcome": { - "collection": { - "data": [ - { - "_id": 1 - }, - { - "_id": 2 - }, - { - "_id": 4 - }, - { - "_id": 5 - } - ] - } - } - }, - { - "description": "writes are not retried", - "clientOptions": { - "retryWrites": true - }, - "failPoint": { - "configureFailPoint": "failCommand", - "mode": { - "times": 1 - }, - "data": { - "failCommands": [ - "insert" - ], - "closeConnection": true - } - }, - "operations": [ - { - "name": "startTransaction", - "object": "session0" - }, - { - "name": "insertOne", - "object": "collection", - "arguments": { - "session": "session0", - "document": { - "_id": 1 - } - }, - "result": { - "errorLabelsContain": [ - "TransientTransactionError" - ] - } - }, - { - "name": "abortTransaction", - "object": "session0" - } - ], - "expectations": [ - { - "command_started_event": { - "command": { - "insert": "test", - "documents": [ - { - "_id": 1 - } - ], - "ordered": true, - "readConcern": null, - "lsid": "session0", - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": true, - "autocommit": false, - "writeConcern": null - }, - "command_name": "insert", - "database_name": "transaction-tests" - } - }, - { - "command_started_event": { - "command": { - "abortTransaction": 1, - "lsid": "session0", - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": null, - "autocommit": false, - "writeConcern": null - }, - "command_name": "abortTransaction", - "database_name": "admin" - } - } - ], - "outcome": { - "collection": { - "data": [] - } - } - } - ] -} diff --git a/source/transactions/tests/legacy/retryable-writes.yml b/source/transactions/tests/legacy/retryable-writes.yml deleted file mode 100644 index 20eea86a42..0000000000 --- a/source/transactions/tests/legacy/retryable-writes.yml +++ /dev/null @@ -1,216 +0,0 @@ -runOn: - - - minServerVersion: "4.0" - topology: ["replicaset"] - - - minServerVersion: "4.1.8" - topology: ["sharded", "load-balanced"] - -database_name: &database_name "transaction-tests" -collection_name: &collection_name "test" - -data: [] - -tests: - - description: increment txnNumber - - clientOptions: - retryWrites: true - - operations: - - name: startTransaction - object: session0 - - name: insertOne - object: collection - arguments: - session: session0 - document: - _id: 1 - result: - insertedId: 1 - - name: commitTransaction - object: session0 - # Retryable write should include the next txnNumber - - name: insertOne - object: collection - arguments: - session: session0 - document: - _id: 2 - result: - insertedId: 2 - # Next transaction should include the next txnNumber - - name: startTransaction - object: session0 - - name: insertOne - object: collection - arguments: - session: session0 - document: - _id: 3 - result: - insertedId: 3 - - name: abortTransaction - object: session0 - # Retryable write should include the next txnNumber - - name: insertMany - object: collection - arguments: - documents: - - _id: 4 - - _id: 5 - session: session0 - result: - insertedIds: {0: 4, 1: 5} - - expectations: - - command_started_event: - command: - insert: *collection_name - documents: - - _id: 1 - ordered: true - readConcern: - lsid: session0 - txnNumber: - $numberLong: "1" - startTransaction: true - autocommit: false - writeConcern: - command_name: insert - database_name: *database_name - - command_started_event: - command: - commitTransaction: 1 - lsid: session0 - txnNumber: - $numberLong: "1" - startTransaction: - autocommit: false - writeConcern: - command_name: commitTransaction - database_name: admin - - command_started_event: - command: - insert: *collection_name - documents: - - _id: 2 - ordered: true - readConcern: - lsid: session0 - txnNumber: - $numberLong: "2" - startTransaction: - autocommit: - writeConcern: - command_name: insert - database_name: *database_name - - command_started_event: - command: - insert: *collection_name - documents: - - _id: 3 - ordered: true - readConcern: - afterClusterTime: 42 - lsid: session0 - txnNumber: - $numberLong: "3" - startTransaction: true - autocommit: false - writeConcern: - command_name: insert - database_name: *database_name - - command_started_event: - command: - abortTransaction: 1 - lsid: session0 - txnNumber: - $numberLong: "3" - startTransaction: - autocommit: false - writeConcern: - command_name: abortTransaction - database_name: admin - - command_started_event: - command: - insert: *collection_name - documents: - - _id: 4 - - _id: 5 - ordered: true - readConcern: - lsid: session0 - txnNumber: - $numberLong: "4" - startTransaction: - autocommit: - writeConcern: - command_name: insert - database_name: *database_name - - outcome: - collection: - data: - - _id: 1 - - _id: 2 - - _id: 4 - - _id: 5 - - - description: writes are not retried - - clientOptions: - retryWrites: true - - failPoint: - configureFailPoint: failCommand - mode: { times: 1 } - data: - failCommands: ["insert"] - closeConnection: true - - operations: - - name: startTransaction - object: session0 - - name: insertOne - object: collection - arguments: - session: session0 - document: - _id: 1 - result: - errorLabelsContain: ["TransientTransactionError"] - - name: abortTransaction - object: session0 - - expectations: - - command_started_event: - command: - insert: *collection_name - documents: - - _id: 1 - ordered: true - readConcern: - lsid: session0 - txnNumber: - $numberLong: "1" - startTransaction: true - autocommit: false - writeConcern: - command_name: insert - database_name: *database_name - - command_started_event: - command: - abortTransaction: 1 - lsid: session0 - txnNumber: - $numberLong: "1" - startTransaction: - autocommit: false - writeConcern: - command_name: abortTransaction - database_name: admin - - outcome: - collection: - data: [] diff --git a/source/transactions/tests/legacy/run-command.json b/source/transactions/tests/legacy/run-command.json deleted file mode 100644 index 2f36786b3a..0000000000 --- a/source/transactions/tests/legacy/run-command.json +++ /dev/null @@ -1,307 +0,0 @@ -{ - "runOn": [ - { - "minServerVersion": "4.0", - "topology": [ - "replicaset" - ] - }, - { - "minServerVersion": "4.1.8", - "topology": [ - "sharded", - "load-balanced" - ] - } - ], - "database_name": "transaction-tests", - "collection_name": "test", - "data": [], - "tests": [ - { - "description": "run command with default read preference", - "operations": [ - { - "name": "startTransaction", - "object": "session0" - }, - { - "name": "runCommand", - "object": "database", - "command_name": "insert", - "arguments": { - "session": "session0", - "command": { - "insert": "test", - "documents": [ - { - "_id": 1 - } - ] - } - }, - "result": { - "n": 1 - } - }, - { - "name": "commitTransaction", - "object": "session0" - } - ], - "expectations": [ - { - "command_started_event": { - "command": { - "insert": "test", - "documents": [ - { - "_id": 1 - } - ], - "readConcern": null, - "lsid": "session0", - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": true, - "autocommit": false, - "writeConcern": null - }, - "command_name": "insert", - "database_name": "transaction-tests" - } - }, - { - "command_started_event": { - "command": { - "commitTransaction": 1, - "lsid": "session0", - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": null, - "autocommit": false, - "writeConcern": null - }, - "command_name": "commitTransaction", - "database_name": "admin" - } - } - ] - }, - { - "description": "run command with secondary read preference in client option and primary read preference in transaction options", - "clientOptions": { - "readPreference": "secondary" - }, - "operations": [ - { - "name": "startTransaction", - "object": "session0", - "arguments": { - "options": { - "readPreference": { - "mode": "Primary" - } - } - } - }, - { - "name": "runCommand", - "object": "database", - "command_name": "insert", - "arguments": { - "session": "session0", - "command": { - "insert": "test", - "documents": [ - { - "_id": 1 - } - ] - } - }, - "result": { - "n": 1 - } - }, - { - "name": "commitTransaction", - "object": "session0" - } - ], - "expectations": [ - { - "command_started_event": { - "command": { - "insert": "test", - "documents": [ - { - "_id": 1 - } - ], - "readConcern": null, - "lsid": "session0", - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": true, - "autocommit": false, - "writeConcern": null - }, - "command_name": "insert", - "database_name": "transaction-tests" - } - }, - { - "command_started_event": { - "command": { - "commitTransaction": 1, - "lsid": "session0", - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": null, - "autocommit": false, - "writeConcern": null - }, - "command_name": "commitTransaction", - "database_name": "admin" - } - } - ] - }, - { - "description": "run command with explicit primary read preference", - "operations": [ - { - "name": "startTransaction", - "object": "session0" - }, - { - "name": "runCommand", - "object": "database", - "command_name": "insert", - "arguments": { - "session": "session0", - "command": { - "insert": "test", - "documents": [ - { - "_id": 1 - } - ] - }, - "readPreference": { - "mode": "Primary" - } - }, - "result": { - "n": 1 - } - }, - { - "name": "commitTransaction", - "object": "session0" - } - ], - "expectations": [ - { - "command_started_event": { - "command": { - "insert": "test", - "documents": [ - { - "_id": 1 - } - ], - "readConcern": null, - "lsid": "session0", - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": true, - "autocommit": false, - "writeConcern": null - }, - "command_name": "insert", - "database_name": "transaction-tests" - } - }, - { - "command_started_event": { - "command": { - "commitTransaction": 1, - "lsid": "session0", - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": null, - "autocommit": false, - "writeConcern": null - }, - "command_name": "commitTransaction", - "database_name": "admin" - } - } - ] - }, - { - "description": "run command fails with explicit secondary read preference", - "operations": [ - { - "name": "startTransaction", - "object": "session0" - }, - { - "name": "runCommand", - "object": "database", - "command_name": "find", - "arguments": { - "session": "session0", - "command": { - "find": "test" - }, - "readPreference": { - "mode": "Secondary" - } - }, - "result": { - "errorContains": "read preference in a transaction must be primary" - } - } - ] - }, - { - "description": "run command fails with secondary read preference from transaction options", - "operations": [ - { - "name": "startTransaction", - "object": "session0", - "arguments": { - "options": { - "readPreference": { - "mode": "Secondary" - } - } - } - }, - { - "name": "runCommand", - "object": "database", - "command_name": "find", - "arguments": { - "session": "session0", - "command": { - "find": "test" - } - }, - "result": { - "errorContains": "read preference in a transaction must be primary" - } - } - ] - } - ] -} diff --git a/source/transactions/tests/legacy/run-command.yml b/source/transactions/tests/legacy/run-command.yml deleted file mode 100644 index 62385a0f29..0000000000 --- a/source/transactions/tests/legacy/run-command.yml +++ /dev/null @@ -1,197 +0,0 @@ -runOn: - - - minServerVersion: "4.0" - topology: ["replicaset"] - - - minServerVersion: "4.1.8" - topology: ["sharded", "load-balanced"] - -database_name: &database_name "transaction-tests" -collection_name: &collection_name "test" - -data: [] - -tests: - - description: run command with default read preference - - operations: - - name: startTransaction - object: session0 - - name: runCommand - object: database - command_name: insert - arguments: - session: session0 - command: - insert: *collection_name - documents: - - _id : 1 - result: - n: 1 - - name: commitTransaction - object: session0 - - expectations: - - command_started_event: - command: - insert: *collection_name - documents: - - _id : 1 - readConcern: - lsid: session0 - txnNumber: - $numberLong: "1" - startTransaction: true - autocommit: false - writeConcern: - command_name: insert - database_name: *database_name - - command_started_event: - command: - commitTransaction: 1 - lsid: session0 - txnNumber: - $numberLong: "1" - startTransaction: - autocommit: false - writeConcern: - command_name: commitTransaction - database_name: admin - - - description: run command with secondary read preference in client option and primary read preference in transaction options - - clientOptions: - readPreference: secondary - - operations: - - name: startTransaction - object: session0 - arguments: - options: - readPreference: - mode: Primary - - name: runCommand - object: database - command_name: insert - arguments: - session: session0 - command: - insert: *collection_name - documents: - - _id : 1 - result: - n: 1 - - name: commitTransaction - object: session0 - - expectations: - - command_started_event: - command: - insert: *collection_name - documents: - - _id : 1 - readConcern: - lsid: session0 - txnNumber: - $numberLong: "1" - startTransaction: true - autocommit: false - writeConcern: - command_name: insert - database_name: *database_name - - command_started_event: - command: - commitTransaction: 1 - lsid: session0 - txnNumber: - $numberLong: "1" - startTransaction: - autocommit: false - writeConcern: - command_name: commitTransaction - database_name: admin - - - description: run command with explicit primary read preference - - operations: - - name: startTransaction - object: session0 - - name: runCommand - object: database - command_name: insert - arguments: - session: session0 - command: - insert: *collection_name - documents: - - _id : 1 - readPreference: - mode: Primary - result: - n: 1 - - name: commitTransaction - object: session0 - - expectations: - - command_started_event: - command: - insert: *collection_name - documents: - - _id : 1 - readConcern: - lsid: session0 - txnNumber: - $numberLong: "1" - startTransaction: true - autocommit: false - writeConcern: - command_name: insert - database_name: *database_name - - command_started_event: - command: - commitTransaction: 1 - lsid: session0 - txnNumber: - $numberLong: "1" - startTransaction: - autocommit: false - writeConcern: - command_name: commitTransaction - database_name: admin - - - description: run command fails with explicit secondary read preference - - operations: - - name: startTransaction - object: session0 - - name: runCommand - object: database - command_name: find - arguments: - session: session0 - command: - find: *collection_name - readPreference: - mode: Secondary - result: - errorContains: read preference in a transaction must be primary - - - description: run command fails with secondary read preference from transaction options - - operations: - - name: startTransaction - object: session0 - arguments: - options: - readPreference: - mode: Secondary - - name: runCommand - object: database - command_name: find - arguments: - session: session0 - command: - find: *collection_name - result: - errorContains: read preference in a transaction must be primary - diff --git a/source/transactions/tests/legacy/transaction-options-repl.json b/source/transactions/tests/legacy/transaction-options-repl.json deleted file mode 100644 index 33324debb8..0000000000 --- a/source/transactions/tests/legacy/transaction-options-repl.json +++ /dev/null @@ -1,181 +0,0 @@ -{ - "runOn": [ - { - "minServerVersion": "4.0", - "topology": [ - "replicaset" - ] - } - ], - "database_name": "transaction-tests", - "collection_name": "test", - "data": [], - "tests": [ - { - "description": "readConcern snapshot in startTransaction options", - "sessionOptions": { - "session0": { - "defaultTransactionOptions": { - "readConcern": { - "level": "majority" - } - } - } - }, - "operations": [ - { - "name": "startTransaction", - "object": "session0", - "arguments": { - "options": { - "readConcern": { - "level": "snapshot" - } - } - } - }, - { - "name": "insertOne", - "object": "collection", - "arguments": { - "session": "session0", - "document": { - "_id": 1 - } - }, - "result": { - "insertedId": 1 - } - }, - { - "name": "commitTransaction", - "object": "session0" - }, - { - "name": "startTransaction", - "object": "session0", - "arguments": { - "options": { - "readConcern": { - "level": "snapshot" - } - } - } - }, - { - "name": "insertOne", - "object": "collection", - "arguments": { - "session": "session0", - "document": { - "_id": 2 - } - }, - "result": { - "insertedId": 2 - } - }, - { - "name": "abortTransaction", - "object": "session0" - } - ], - "expectations": [ - { - "command_started_event": { - "command": { - "insert": "test", - "documents": [ - { - "_id": 1 - } - ], - "ordered": true, - "lsid": "session0", - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": true, - "autocommit": false, - "readConcern": { - "level": "snapshot" - }, - "writeConcern": null - }, - "command_name": "insert", - "database_name": "transaction-tests" - } - }, - { - "command_started_event": { - "command": { - "commitTransaction": 1, - "lsid": "session0", - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": null, - "autocommit": false, - "readConcern": null, - "writeConcern": null - }, - "command_name": "commitTransaction", - "database_name": "admin" - } - }, - { - "command_started_event": { - "command": { - "insert": "test", - "documents": [ - { - "_id": 2 - } - ], - "ordered": true, - "lsid": "session0", - "txnNumber": { - "$numberLong": "2" - }, - "startTransaction": true, - "autocommit": false, - "readConcern": { - "level": "snapshot", - "afterClusterTime": 42 - }, - "writeConcern": null - }, - "command_name": "insert", - "database_name": "transaction-tests" - } - }, - { - "command_started_event": { - "command": { - "abortTransaction": 1, - "lsid": "session0", - "txnNumber": { - "$numberLong": "2" - }, - "startTransaction": null, - "autocommit": false, - "readConcern": null, - "writeConcern": null - }, - "command_name": "abortTransaction", - "database_name": "admin" - } - } - ], - "outcome": { - "collection": { - "data": [ - { - "_id": 1 - } - ] - } - } - } - ] -} diff --git a/source/transactions/tests/legacy/transaction-options-repl.yml b/source/transactions/tests/legacy/transaction-options-repl.yml deleted file mode 100644 index c1191c32b3..0000000000 --- a/source/transactions/tests/legacy/transaction-options-repl.yml +++ /dev/null @@ -1,117 +0,0 @@ -runOn: - - minServerVersion: "4.0" - topology: ["replicaset"] - -database_name: &database_name "transaction-tests" -collection_name: &collection_name "test" - -data: [] - -tests: - - - description: readConcern snapshot in startTransaction options - - sessionOptions: - session0: - defaultTransactionOptions: - readConcern: - level: majority # Overridden. - - operations: - - name: startTransaction - object: session0 - arguments: - options: - readConcern: - level: snapshot - - name: insertOne - object: collection - arguments: - session: session0 - document: - _id: 1 - result: - insertedId: 1 - - name: commitTransaction - object: session0 - # Now test abort. - - name: startTransaction - object: session0 - arguments: - options: - readConcern: - level: snapshot - - name: insertOne - object: collection - arguments: - session: session0 - document: - _id: 2 - result: - insertedId: 2 - - name: abortTransaction - object: session0 - - expectations: - - command_started_event: - command: - insert: *collection_name - documents: - - _id: 1 - ordered: true - lsid: session0 - txnNumber: - $numberLong: "1" - startTransaction: true - autocommit: false - readConcern: - level: snapshot - writeConcern: - command_name: insert - database_name: *database_name - - command_started_event: - command: - commitTransaction: 1 - lsid: session0 - txnNumber: - $numberLong: "1" - startTransaction: - autocommit: false - readConcern: - writeConcern: - command_name: commitTransaction - database_name: admin - - command_started_event: - command: - insert: *collection_name - documents: - - _id: 2 - ordered: true - lsid: session0 - txnNumber: - $numberLong: "2" - startTransaction: true - autocommit: false - readConcern: - level: snapshot - afterClusterTime: 42 - writeConcern: - command_name: insert - database_name: *database_name - - command_started_event: - command: - abortTransaction: 1 - lsid: session0 - txnNumber: - $numberLong: "2" - startTransaction: - autocommit: false - readConcern: - writeConcern: - command_name: abortTransaction - database_name: admin - - outcome: - collection: - data: - - _id: 1 diff --git a/source/transactions/tests/legacy/transaction-options.json b/source/transactions/tests/legacy/transaction-options.json deleted file mode 100644 index 6bcfae9d33..0000000000 --- a/source/transactions/tests/legacy/transaction-options.json +++ /dev/null @@ -1,1405 +0,0 @@ -{ - "runOn": [ - { - "minServerVersion": "4.0", - "topology": [ - "replicaset" - ] - }, - { - "minServerVersion": "4.1.8", - "topology": [ - "sharded", - "load-balanced" - ] - } - ], - "database_name": "transaction-tests", - "collection_name": "test", - "data": [], - "tests": [ - { - "description": "no transaction options set", - "operations": [ - { - "name": "startTransaction", - "object": "session0" - }, - { - "name": "insertOne", - "object": "collection", - "arguments": { - "session": "session0", - "document": { - "_id": 1 - } - }, - "result": { - "insertedId": 1 - } - }, - { - "name": "commitTransaction", - "object": "session0" - }, - { - "name": "startTransaction", - "object": "session0" - }, - { - "name": "insertOne", - "object": "collection", - "arguments": { - "session": "session0", - "document": { - "_id": 2 - } - }, - "result": { - "insertedId": 2 - } - }, - { - "name": "abortTransaction", - "object": "session0" - } - ], - "expectations": [ - { - "command_started_event": { - "command": { - "insert": "test", - "documents": [ - { - "_id": 1 - } - ], - "ordered": true, - "lsid": "session0", - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": true, - "autocommit": false, - "readConcern": null, - "writeConcern": null, - "maxTimeMS": null - }, - "command_name": "insert", - "database_name": "transaction-tests" - } - }, - { - "command_started_event": { - "command": { - "commitTransaction": 1, - "lsid": "session0", - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": null, - "autocommit": false, - "readConcern": null, - "writeConcern": null, - "maxTimeMS": null - }, - "command_name": "commitTransaction", - "database_name": "admin" - } - }, - { - "command_started_event": { - "command": { - "insert": "test", - "documents": [ - { - "_id": 2 - } - ], - "ordered": true, - "lsid": "session0", - "txnNumber": { - "$numberLong": "2" - }, - "startTransaction": true, - "autocommit": false, - "readConcern": { - "afterClusterTime": 42 - }, - "writeConcern": null, - "maxTimeMS": null - }, - "command_name": "insert", - "database_name": "transaction-tests" - } - }, - { - "command_started_event": { - "command": { - "abortTransaction": 1, - "lsid": "session0", - "txnNumber": { - "$numberLong": "2" - }, - "startTransaction": null, - "autocommit": false, - "readConcern": null, - "writeConcern": null, - "maxTimeMS": null - }, - "command_name": "abortTransaction", - "database_name": "admin" - } - } - ], - "outcome": { - "collection": { - "data": [ - { - "_id": 1 - } - ] - } - } - }, - { - "description": "transaction options inherited from client", - "clientOptions": { - "w": 1, - "readConcernLevel": "local" - }, - "operations": [ - { - "name": "startTransaction", - "object": "session0" - }, - { - "name": "insertOne", - "object": "collection", - "arguments": { - "session": "session0", - "document": { - "_id": 1 - } - }, - "result": { - "insertedId": 1 - } - }, - { - "name": "commitTransaction", - "object": "session0" - }, - { - "name": "startTransaction", - "object": "session0" - }, - { - "name": "insertOne", - "object": "collection", - "arguments": { - "session": "session0", - "document": { - "_id": 2 - } - }, - "result": { - "insertedId": 2 - } - }, - { - "name": "abortTransaction", - "object": "session0" - } - ], - "expectations": [ - { - "command_started_event": { - "command": { - "insert": "test", - "documents": [ - { - "_id": 1 - } - ], - "ordered": true, - "lsid": "session0", - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": true, - "autocommit": false, - "readConcern": { - "level": "local" - }, - "writeConcern": null, - "maxTimeMS": null - }, - "command_name": "insert", - "database_name": "transaction-tests" - } - }, - { - "command_started_event": { - "command": { - "commitTransaction": 1, - "lsid": "session0", - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": null, - "autocommit": false, - "readConcern": null, - "writeConcern": { - "w": 1 - }, - "maxTimeMS": null - }, - "command_name": "commitTransaction", - "database_name": "admin" - } - }, - { - "command_started_event": { - "command": { - "insert": "test", - "documents": [ - { - "_id": 2 - } - ], - "ordered": true, - "lsid": "session0", - "txnNumber": { - "$numberLong": "2" - }, - "startTransaction": true, - "autocommit": false, - "readConcern": { - "level": "local", - "afterClusterTime": 42 - }, - "writeConcern": null, - "maxTimeMS": null - }, - "command_name": "insert", - "database_name": "transaction-tests" - } - }, - { - "command_started_event": { - "command": { - "abortTransaction": 1, - "lsid": "session0", - "txnNumber": { - "$numberLong": "2" - }, - "startTransaction": null, - "autocommit": false, - "readConcern": null, - "writeConcern": { - "w": 1 - }, - "maxTimeMS": null - }, - "command_name": "abortTransaction", - "database_name": "admin" - } - } - ], - "outcome": { - "collection": { - "data": [ - { - "_id": 1 - } - ] - } - } - }, - { - "description": "transaction options inherited from defaultTransactionOptions", - "sessionOptions": { - "session0": { - "defaultTransactionOptions": { - "readConcern": { - "level": "majority" - }, - "writeConcern": { - "w": 1 - }, - "maxCommitTimeMS": 60000 - } - } - }, - "operations": [ - { - "name": "startTransaction", - "object": "session0" - }, - { - "name": "insertOne", - "object": "collection", - "arguments": { - "session": "session0", - "document": { - "_id": 1 - } - }, - "result": { - "insertedId": 1 - } - }, - { - "name": "commitTransaction", - "object": "session0" - }, - { - "name": "startTransaction", - "object": "session0" - }, - { - "name": "insertOne", - "object": "collection", - "arguments": { - "session": "session0", - "document": { - "_id": 2 - } - }, - "result": { - "insertedId": 2 - } - }, - { - "name": "abortTransaction", - "object": "session0" - } - ], - "expectations": [ - { - "command_started_event": { - "command": { - "insert": "test", - "documents": [ - { - "_id": 1 - } - ], - "ordered": true, - "lsid": "session0", - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": true, - "autocommit": false, - "readConcern": { - "level": "majority" - }, - "writeConcern": null - }, - "command_name": "insert", - "database_name": "transaction-tests" - } - }, - { - "command_started_event": { - "command": { - "commitTransaction": 1, - "lsid": "session0", - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": null, - "autocommit": false, - "readConcern": null, - "writeConcern": { - "w": 1 - }, - "maxTimeMS": 60000 - }, - "command_name": "commitTransaction", - "database_name": "admin" - } - }, - { - "command_started_event": { - "command": { - "insert": "test", - "documents": [ - { - "_id": 2 - } - ], - "ordered": true, - "lsid": "session0", - "txnNumber": { - "$numberLong": "2" - }, - "startTransaction": true, - "autocommit": false, - "readConcern": { - "level": "majority", - "afterClusterTime": 42 - }, - "writeConcern": null - }, - "command_name": "insert", - "database_name": "transaction-tests" - } - }, - { - "command_started_event": { - "command": { - "abortTransaction": 1, - "lsid": "session0", - "txnNumber": { - "$numberLong": "2" - }, - "startTransaction": null, - "autocommit": false, - "readConcern": null, - "writeConcern": { - "w": 1 - } - }, - "command_name": "abortTransaction", - "database_name": "admin" - } - } - ], - "outcome": { - "collection": { - "data": [ - { - "_id": 1 - } - ] - } - } - }, - { - "description": "startTransaction options override defaults", - "clientOptions": { - "readConcernLevel": "local", - "w": 1 - }, - "sessionOptions": { - "session0": { - "defaultTransactionOptions": { - "readConcern": { - "level": "snapshot" - }, - "writeConcern": { - "w": 1 - }, - "maxCommitTimeMS": 30000 - } - } - }, - "operations": [ - { - "name": "startTransaction", - "object": "session0", - "arguments": { - "options": { - "readConcern": { - "level": "majority" - }, - "writeConcern": { - "w": "majority" - }, - "maxCommitTimeMS": 60000 - } - } - }, - { - "name": "insertOne", - "object": "collection", - "arguments": { - "session": "session0", - "document": { - "_id": 1 - } - }, - "result": { - "insertedId": 1 - } - }, - { - "name": "commitTransaction", - "object": "session0" - }, - { - "name": "startTransaction", - "object": "session0", - "arguments": { - "options": { - "readConcern": { - "level": "majority" - }, - "writeConcern": { - "w": "majority" - } - } - } - }, - { - "name": "insertOne", - "object": "collection", - "arguments": { - "session": "session0", - "document": { - "_id": 2 - } - }, - "result": { - "insertedId": 2 - } - }, - { - "name": "abortTransaction", - "object": "session0" - } - ], - "expectations": [ - { - "command_started_event": { - "command": { - "insert": "test", - "documents": [ - { - "_id": 1 - } - ], - "ordered": true, - "lsid": "session0", - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": true, - "autocommit": false, - "readConcern": { - "level": "majority" - }, - "writeConcern": null, - "maxTimeMS": null - }, - "command_name": "insert", - "database_name": "transaction-tests" - } - }, - { - "command_started_event": { - "command": { - "commitTransaction": 1, - "lsid": "session0", - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": null, - "autocommit": false, - "readConcern": null, - "writeConcern": { - "w": "majority" - }, - "maxTimeMS": 60000 - }, - "command_name": "commitTransaction", - "database_name": "admin" - } - }, - { - "command_started_event": { - "command": { - "insert": "test", - "documents": [ - { - "_id": 2 - } - ], - "ordered": true, - "lsid": "session0", - "txnNumber": { - "$numberLong": "2" - }, - "startTransaction": true, - "autocommit": false, - "readConcern": { - "level": "majority", - "afterClusterTime": 42 - }, - "writeConcern": null, - "maxTimeMS": null - }, - "command_name": "insert", - "database_name": "transaction-tests" - } - }, - { - "command_started_event": { - "command": { - "abortTransaction": 1, - "lsid": "session0", - "txnNumber": { - "$numberLong": "2" - }, - "startTransaction": null, - "autocommit": false, - "readConcern": null, - "writeConcern": { - "w": "majority" - }, - "maxTimeMS": null - }, - "command_name": "abortTransaction", - "database_name": "admin" - } - } - ], - "outcome": { - "collection": { - "data": [ - { - "_id": 1 - } - ] - } - } - }, - { - "description": "defaultTransactionOptions override client options", - "clientOptions": { - "readConcernLevel": "local", - "w": 1 - }, - "sessionOptions": { - "session0": { - "defaultTransactionOptions": { - "readConcern": { - "level": "majority" - }, - "writeConcern": { - "w": "majority" - }, - "maxCommitTimeMS": 60000 - } - } - }, - "operations": [ - { - "name": "startTransaction", - "object": "session0" - }, - { - "name": "insertOne", - "object": "collection", - "arguments": { - "session": "session0", - "document": { - "_id": 1 - } - }, - "result": { - "insertedId": 1 - } - }, - { - "name": "commitTransaction", - "object": "session0" - }, - { - "name": "startTransaction", - "object": "session0" - }, - { - "name": "insertOne", - "object": "collection", - "arguments": { - "session": "session0", - "document": { - "_id": 2 - } - }, - "result": { - "insertedId": 2 - } - }, - { - "name": "abortTransaction", - "object": "session0" - } - ], - "expectations": [ - { - "command_started_event": { - "command": { - "insert": "test", - "documents": [ - { - "_id": 1 - } - ], - "ordered": true, - "lsid": "session0", - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": true, - "autocommit": false, - "readConcern": { - "level": "majority" - }, - "writeConcern": null, - "maxTimeMS": null - }, - "command_name": "insert", - "database_name": "transaction-tests" - } - }, - { - "command_started_event": { - "command": { - "commitTransaction": 1, - "lsid": "session0", - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": null, - "autocommit": false, - "readConcern": null, - "writeConcern": { - "w": "majority" - }, - "maxTimeMS": 60000 - }, - "command_name": "commitTransaction", - "database_name": "admin" - } - }, - { - "command_started_event": { - "command": { - "insert": "test", - "documents": [ - { - "_id": 2 - } - ], - "ordered": true, - "lsid": "session0", - "txnNumber": { - "$numberLong": "2" - }, - "startTransaction": true, - "autocommit": false, - "readConcern": { - "level": "majority", - "afterClusterTime": 42 - }, - "writeConcern": null, - "maxTimeMS": null - }, - "command_name": "insert", - "database_name": "transaction-tests" - } - }, - { - "command_started_event": { - "command": { - "abortTransaction": 1, - "lsid": "session0", - "txnNumber": { - "$numberLong": "2" - }, - "startTransaction": null, - "autocommit": false, - "readConcern": null, - "writeConcern": { - "w": "majority" - }, - "maxTimeMS": null - }, - "command_name": "abortTransaction", - "database_name": "admin" - } - } - ], - "outcome": { - "collection": { - "data": [ - { - "_id": 1 - } - ] - } - } - }, - { - "description": "readConcern local in defaultTransactionOptions", - "clientOptions": { - "w": 1 - }, - "sessionOptions": { - "session0": { - "defaultTransactionOptions": { - "readConcern": { - "level": "local" - } - } - } - }, - "operations": [ - { - "name": "startTransaction", - "object": "session0" - }, - { - "name": "insertOne", - "object": "collection", - "arguments": { - "session": "session0", - "document": { - "_id": 1 - } - }, - "result": { - "insertedId": 1 - } - }, - { - "name": "commitTransaction", - "object": "session0" - }, - { - "name": "startTransaction", - "object": "session0" - }, - { - "name": "insertOne", - "object": "collection", - "arguments": { - "session": "session0", - "document": { - "_id": 2 - } - }, - "result": { - "insertedId": 2 - } - }, - { - "name": "abortTransaction", - "object": "session0" - } - ], - "expectations": [ - { - "command_started_event": { - "command": { - "insert": "test", - "documents": [ - { - "_id": 1 - } - ], - "ordered": true, - "lsid": "session0", - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": true, - "autocommit": false, - "readConcern": { - "level": "local" - }, - "writeConcern": null - }, - "command_name": "insert", - "database_name": "transaction-tests" - } - }, - { - "command_started_event": { - "command": { - "commitTransaction": 1, - "lsid": "session0", - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": null, - "autocommit": false, - "readConcern": null, - "writeConcern": { - "w": 1 - } - }, - "command_name": "commitTransaction", - "database_name": "admin" - } - }, - { - "command_started_event": { - "command": { - "insert": "test", - "documents": [ - { - "_id": 2 - } - ], - "ordered": true, - "lsid": "session0", - "txnNumber": { - "$numberLong": "2" - }, - "startTransaction": true, - "autocommit": false, - "readConcern": { - "level": "local", - "afterClusterTime": 42 - }, - "writeConcern": null - }, - "command_name": "insert", - "database_name": "transaction-tests" - } - }, - { - "command_started_event": { - "command": { - "abortTransaction": 1, - "lsid": "session0", - "txnNumber": { - "$numberLong": "2" - }, - "startTransaction": null, - "autocommit": false, - "readConcern": null, - "writeConcern": { - "w": 1 - } - }, - "command_name": "abortTransaction", - "database_name": "admin" - } - } - ], - "outcome": { - "collection": { - "data": [ - { - "_id": 1 - } - ] - } - } - }, - { - "description": "client writeConcern ignored for bulk", - "clientOptions": { - "w": "majority" - }, - "operations": [ - { - "name": "startTransaction", - "object": "session0", - "arguments": { - "options": { - "writeConcern": { - "w": 1 - } - } - } - }, - { - "name": "bulkWrite", - "object": "collection", - "arguments": { - "requests": [ - { - "name": "insertOne", - "arguments": { - "document": { - "_id": 1 - } - } - } - ], - "session": "session0" - }, - "result": { - "deletedCount": 0, - "insertedCount": 1, - "insertedIds": { - "0": 1 - }, - "matchedCount": 0, - "modifiedCount": 0, - "upsertedCount": 0, - "upsertedIds": {} - } - }, - { - "name": "commitTransaction", - "object": "session0" - } - ], - "expectations": [ - { - "command_started_event": { - "command": { - "insert": "test", - "documents": [ - { - "_id": 1 - } - ], - "ordered": true, - "readConcern": null, - "lsid": "session0", - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": true, - "autocommit": false, - "writeConcern": null - }, - "command_name": "insert", - "database_name": "transaction-tests" - } - }, - { - "command_started_event": { - "command": { - "commitTransaction": 1, - "lsid": "session0", - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": null, - "autocommit": false, - "writeConcern": { - "w": 1 - } - }, - "command_name": "commitTransaction", - "database_name": "admin" - } - } - ], - "outcome": { - "collection": { - "data": [ - { - "_id": 1 - } - ] - } - } - }, - { - "description": "readPreference inherited from client", - "clientOptions": { - "readPreference": "secondary" - }, - "operations": [ - { - "name": "startTransaction", - "object": "session0" - }, - { - "name": "insertOne", - "object": "collection", - "arguments": { - "session": "session0", - "document": { - "_id": 1 - } - }, - "result": { - "insertedId": 1 - } - }, - { - "name": "find", - "object": "collection", - "arguments": { - "session": "session0", - "filter": { - "_id": 1 - } - }, - "result": { - "errorContains": "read preference in a transaction must be primary" - } - }, - { - "name": "commitTransaction", - "object": "session0" - } - ], - "expectations": [ - { - "command_started_event": { - "command": { - "insert": "test", - "documents": [ - { - "_id": 1 - } - ], - "ordered": true, - "lsid": "session0", - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": true, - "autocommit": false, - "readConcern": null, - "writeConcern": null - }, - "command_name": "insert", - "database_name": "transaction-tests" - } - }, - { - "command_started_event": { - "command": { - "commitTransaction": 1, - "lsid": "session0", - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": null, - "autocommit": false, - "readConcern": null, - "writeConcern": null - }, - "command_name": "commitTransaction", - "database_name": "admin" - } - } - ], - "outcome": { - "collection": { - "data": [ - { - "_id": 1 - } - ] - } - } - }, - { - "description": "readPreference inherited from defaultTransactionOptions", - "clientOptions": { - "readPreference": "primary" - }, - "sessionOptions": { - "session0": { - "defaultTransactionOptions": { - "readPreference": { - "mode": "Secondary" - } - } - } - }, - "operations": [ - { - "name": "startTransaction", - "object": "session0" - }, - { - "name": "insertOne", - "object": "collection", - "arguments": { - "session": "session0", - "document": { - "_id": 1 - } - }, - "result": { - "insertedId": 1 - } - }, - { - "name": "find", - "object": "collection", - "arguments": { - "session": "session0", - "filter": { - "_id": 1 - } - }, - "result": { - "errorContains": "read preference in a transaction must be primary" - } - }, - { - "name": "commitTransaction", - "object": "session0" - } - ], - "expectations": [ - { - "command_started_event": { - "command": { - "insert": "test", - "documents": [ - { - "_id": 1 - } - ], - "ordered": true, - "lsid": "session0", - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": true, - "autocommit": false, - "readConcern": null, - "writeConcern": null - }, - "command_name": "insert", - "database_name": "transaction-tests" - } - }, - { - "command_started_event": { - "command": { - "commitTransaction": 1, - "lsid": "session0", - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": null, - "autocommit": false, - "readConcern": null, - "writeConcern": null - }, - "command_name": "commitTransaction", - "database_name": "admin" - } - } - ], - "outcome": { - "collection": { - "data": [ - { - "_id": 1 - } - ] - } - } - }, - { - "description": "startTransaction overrides readPreference", - "clientOptions": { - "readPreference": "primary" - }, - "sessionOptions": { - "session0": { - "defaultTransactionOptions": { - "readPreference": { - "mode": "Primary" - } - } - } - }, - "operations": [ - { - "name": "startTransaction", - "object": "session0", - "arguments": { - "options": { - "readPreference": { - "mode": "Secondary" - } - } - } - }, - { - "name": "insertOne", - "object": "collection", - "arguments": { - "session": "session0", - "document": { - "_id": 1 - } - }, - "result": { - "insertedId": 1 - } - }, - { - "name": "find", - "object": "collection", - "arguments": { - "session": "session0", - "filter": { - "_id": 1 - } - }, - "result": { - "errorContains": "read preference in a transaction must be primary" - } - }, - { - "name": "commitTransaction", - "object": "session0" - } - ], - "expectations": [ - { - "command_started_event": { - "command": { - "insert": "test", - "documents": [ - { - "_id": 1 - } - ], - "ordered": true, - "lsid": "session0", - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": true, - "autocommit": false, - "readConcern": null, - "writeConcern": null - }, - "command_name": "insert", - "database_name": "transaction-tests" - } - }, - { - "command_started_event": { - "command": { - "commitTransaction": 1, - "lsid": "session0", - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": null, - "autocommit": false, - "readConcern": null, - "writeConcern": null - }, - "command_name": "commitTransaction", - "database_name": "admin" - } - } - ], - "outcome": { - "collection": { - "data": [ - { - "_id": 1 - } - ] - } - } - } - ] -} diff --git a/source/transactions/tests/legacy/transaction-options.yml b/source/transactions/tests/legacy/transaction-options.yml deleted file mode 100644 index e64625c371..0000000000 --- a/source/transactions/tests/legacy/transaction-options.yml +++ /dev/null @@ -1,803 +0,0 @@ -runOn: - - - minServerVersion: "4.0" - topology: ["replicaset"] - - - minServerVersion: "4.1.8" - topology: ["sharded", "load-balanced"] - -database_name: &database_name "transaction-tests" -collection_name: &collection_name "test" - -data: [] - -tests: - - description: no transaction options set - - operations: &commitAbortOperations - - name: startTransaction - object: session0 - - name: insertOne - object: collection - arguments: - session: session0 - document: - _id: 1 - result: - insertedId: 1 - - name: commitTransaction - object: session0 - # Now test abort. - - name: startTransaction - object: session0 - - name: insertOne - object: collection - arguments: - session: session0 - document: - _id: 2 - result: - insertedId: 2 - - name: abortTransaction - object: session0 - - expectations: - - command_started_event: - command: - insert: *collection_name - documents: - - _id: 1 - ordered: true - lsid: session0 - txnNumber: - $numberLong: "1" - startTransaction: true - autocommit: false - readConcern: - writeConcern: - maxTimeMS: - command_name: insert - database_name: *database_name - - command_started_event: - command: - commitTransaction: 1 - lsid: session0 - txnNumber: - $numberLong: "1" - startTransaction: - autocommit: false - readConcern: - writeConcern: - maxTimeMS: - command_name: commitTransaction - database_name: admin - - command_started_event: - command: - insert: *collection_name - documents: - - _id: 2 - ordered: true - lsid: session0 - txnNumber: - $numberLong: "2" - startTransaction: true - autocommit: false - readConcern: - afterClusterTime: 42 - writeConcern: - maxTimeMS: - command_name: insert - database_name: *database_name - - command_started_event: - command: - abortTransaction: 1 - lsid: session0 - txnNumber: - $numberLong: "2" - startTransaction: - autocommit: false - readConcern: - writeConcern: - maxTimeMS: - command_name: abortTransaction - database_name: admin - - outcome: &outcome - collection: - data: - - _id: 1 - - - description: transaction options inherited from client - - clientOptions: - w: 1 - readConcernLevel: local - - operations: *commitAbortOperations - - expectations: - - command_started_event: - command: - insert: *collection_name - documents: - - _id: 1 - ordered: true - lsid: session0 - txnNumber: - $numberLong: "1" - startTransaction: true - autocommit: false - readConcern: - level: local - writeConcern: - maxTimeMS: - command_name: insert - database_name: *database_name - - command_started_event: - command: - commitTransaction: 1 - lsid: session0 - txnNumber: - $numberLong: "1" - startTransaction: - autocommit: false - readConcern: - writeConcern: - w: 1 - maxTimeMS: - command_name: commitTransaction - database_name: admin - - command_started_event: - command: - insert: *collection_name - documents: - - _id: 2 - ordered: true - lsid: session0 - txnNumber: - $numberLong: "2" - startTransaction: true - autocommit: false - readConcern: - level: local - afterClusterTime: 42 - writeConcern: - maxTimeMS: - command_name: insert - database_name: *database_name - - command_started_event: - command: - abortTransaction: 1 - lsid: session0 - txnNumber: - $numberLong: "2" - startTransaction: - autocommit: false - readConcern: - writeConcern: - w: 1 - maxTimeMS: - command_name: abortTransaction - database_name: admin - - outcome: *outcome - - - description: transaction options inherited from defaultTransactionOptions - - sessionOptions: - session0: - defaultTransactionOptions: - readConcern: - level: majority - writeConcern: - w: 1 - maxCommitTimeMS: 60000 - - operations: *commitAbortOperations - - expectations: - - command_started_event: - command: - insert: *collection_name - documents: - - _id: 1 - ordered: true - lsid: session0 - txnNumber: - $numberLong: "1" - startTransaction: true - autocommit: false - readConcern: - level: majority - writeConcern: - command_name: insert - database_name: *database_name - - command_started_event: - command: - commitTransaction: 1 - lsid: session0 - txnNumber: - $numberLong: "1" - startTransaction: - autocommit: false - readConcern: - writeConcern: - w: 1 - maxTimeMS: 60000 - command_name: commitTransaction - database_name: admin - - command_started_event: - command: - insert: *collection_name - documents: - - _id: 2 - ordered: true - lsid: session0 - txnNumber: - $numberLong: "2" - startTransaction: true - autocommit: false - readConcern: - level: majority - afterClusterTime: 42 - writeConcern: - command_name: insert - database_name: *database_name - - command_started_event: - command: - abortTransaction: 1 - lsid: session0 - txnNumber: - $numberLong: "2" - startTransaction: - autocommit: false - readConcern: - writeConcern: - w: 1 - command_name: abortTransaction - database_name: admin - - outcome: *outcome - - - description: startTransaction options override defaults - - clientOptions: - readConcernLevel: local - w: 1 - - sessionOptions: - session0: - defaultTransactionOptions: - readConcern: - level: snapshot - writeConcern: - w: 1 - maxCommitTimeMS: 30000 - - operations: - - name: startTransaction - object: session0 - arguments: - options: - readConcern: - level: majority - writeConcern: - w: majority - maxCommitTimeMS: 60000 - - name: insertOne - object: collection - arguments: - session: session0 - document: - _id: 1 - result: - insertedId: 1 - - name: commitTransaction - object: session0 - - name: startTransaction - object: session0 - arguments: - options: - readConcern: - level: majority - writeConcern: - w: majority - - name: insertOne - object: collection - arguments: - session: session0 - document: - _id: 2 - result: - insertedId: 2 - - name: abortTransaction - object: session0 - - expectations: - - command_started_event: - command: - insert: *collection_name - documents: - - _id: 1 - ordered: true - lsid: session0 - txnNumber: - $numberLong: "1" - startTransaction: true - autocommit: false - readConcern: - level: majority - writeConcern: - maxTimeMS: - command_name: insert - database_name: *database_name - - command_started_event: - command: - commitTransaction: 1 - lsid: session0 - txnNumber: - $numberLong: "1" - startTransaction: - autocommit: false - readConcern: - writeConcern: - w: majority - maxTimeMS: 60000 - command_name: commitTransaction - database_name: admin - - command_started_event: - command: - insert: *collection_name - documents: - - _id: 2 - ordered: true - lsid: session0 - txnNumber: - $numberLong: "2" - startTransaction: true - autocommit: false - readConcern: - level: majority - afterClusterTime: 42 - writeConcern: - maxTimeMS: - command_name: insert - database_name: *database_name - - command_started_event: - command: - abortTransaction: 1 - lsid: session0 - txnNumber: - $numberLong: "2" - startTransaction: - autocommit: false - readConcern: - writeConcern: - w: majority - maxTimeMS: - command_name: abortTransaction - database_name: admin - - outcome: *outcome - - - description: defaultTransactionOptions override client options - - clientOptions: - readConcernLevel: local - w: 1 - - sessionOptions: - session0: - defaultTransactionOptions: - readConcern: - level: majority - writeConcern: - w: majority - maxCommitTimeMS: 60000 - - operations: *commitAbortOperations - - expectations: - - command_started_event: - command: - insert: *collection_name - documents: - - _id: 1 - ordered: true - lsid: session0 - txnNumber: - $numberLong: "1" - startTransaction: true - autocommit: false - readConcern: - level: majority - writeConcern: - maxTimeMS: - command_name: insert - database_name: *database_name - - command_started_event: - command: - commitTransaction: 1 - lsid: session0 - txnNumber: - $numberLong: "1" - startTransaction: - autocommit: false - readConcern: - writeConcern: - w: majority - maxTimeMS: 60000 - command_name: commitTransaction - database_name: admin - - command_started_event: - command: - insert: *collection_name - documents: - - _id: 2 - ordered: true - lsid: session0 - txnNumber: - $numberLong: "2" - startTransaction: true - autocommit: false - readConcern: - level: majority - afterClusterTime: 42 - writeConcern: - maxTimeMS: - command_name: insert - database_name: *database_name - - command_started_event: - command: - abortTransaction: 1 - lsid: session0 - txnNumber: - $numberLong: "2" - startTransaction: - autocommit: false - readConcern: - writeConcern: - w: majority - maxTimeMS: - command_name: abortTransaction - database_name: admin - - outcome: *outcome - - - description: readConcern local in defaultTransactionOptions - - clientOptions: - w: 1 - - sessionOptions: - session0: - defaultTransactionOptions: - readConcern: - level: local - - operations: *commitAbortOperations - - expectations: - - command_started_event: - command: - insert: *collection_name - documents: - - _id: 1 - ordered: true - lsid: session0 - txnNumber: - $numberLong: "1" - startTransaction: true - autocommit: false - readConcern: - level: local - writeConcern: - command_name: insert - database_name: *database_name - - command_started_event: - command: - commitTransaction: 1 - lsid: session0 - txnNumber: - $numberLong: "1" - startTransaction: - autocommit: false - readConcern: - writeConcern: - w: 1 - command_name: commitTransaction - database_name: admin - - command_started_event: - command: - insert: *collection_name - documents: - - _id: 2 - ordered: true - lsid: session0 - txnNumber: - $numberLong: "2" - startTransaction: true - autocommit: false - readConcern: - level: local - afterClusterTime: 42 - writeConcern: - command_name: insert - database_name: *database_name - - command_started_event: - command: - abortTransaction: 1 - lsid: session0 - txnNumber: - $numberLong: "2" - startTransaction: - autocommit: false - readConcern: - writeConcern: - w: 1 - command_name: abortTransaction - database_name: admin - - outcome: *outcome - - - description: client writeConcern ignored for bulk - - clientOptions: - w: majority - - operations: - - name: startTransaction - object: session0 - arguments: - options: - writeConcern: - w: 1 - - name: bulkWrite - object: collection - arguments: - requests: - - name: insertOne - arguments: - document: {_id: 1} - session: session0 - result: - deletedCount: 0 - insertedCount: 1 - insertedIds: {0: 1} - matchedCount: 0 - modifiedCount: 0 - upsertedCount: 0 - upsertedIds: {} - - name: commitTransaction - object: session0 - - expectations: - - command_started_event: - command: - insert: *collection_name - documents: - - _id: 1 - ordered: true - readConcern: - lsid: session0 - txnNumber: - $numberLong: "1" - startTransaction: true - autocommit: false - # No writeConcern. - writeConcern: - command_name: insert - database_name: *database_name - - command_started_event: - command: - commitTransaction: 1 - lsid: session0 - txnNumber: - $numberLong: "1" - startTransaction: - autocommit: false - writeConcern: - w: 1 - command_name: commitTransaction - database_name: admin - - outcome: *outcome - - - description: readPreference inherited from client - - clientOptions: - readPreference: secondary - - operations: - - name: startTransaction - object: session0 - - name: insertOne - object: collection - arguments: - session: session0 - document: - _id: 1 - result: - insertedId: 1 - - name: find - object: collection - arguments: - session: session0 - filter: - _id: 1 - result: - errorContains: read preference in a transaction must be primary - - name: commitTransaction - object: session0 - - expectations: - - command_started_event: - command: - insert: *collection_name - documents: - - _id: 1 - ordered: true - lsid: session0 - txnNumber: - $numberLong: "1" - startTransaction: true - autocommit: false - readConcern: - writeConcern: - command_name: insert - database_name: *database_name - - command_started_event: - command: - commitTransaction: 1 - lsid: session0 - txnNumber: - $numberLong: "1" - startTransaction: - autocommit: false - readConcern: - writeConcern: - command_name: commitTransaction - database_name: admin - - outcome: - collection: - data: - - _id: 1 - - - description: readPreference inherited from defaultTransactionOptions - - clientOptions: - readPreference: primary - - sessionOptions: - session0: - defaultTransactionOptions: - readPreference: - mode: Secondary - - operations: - - name: startTransaction - object: session0 - - name: insertOne - object: collection - arguments: - session: session0 - document: - _id: 1 - result: - insertedId: 1 - - name: find - object: collection - arguments: - session: session0 - filter: - _id: 1 - result: - errorContains: read preference in a transaction must be primary - - name: commitTransaction - object: session0 - - expectations: - - command_started_event: - command: - insert: *collection_name - documents: - - _id: 1 - ordered: true - lsid: session0 - txnNumber: - $numberLong: "1" - startTransaction: true - autocommit: false - readConcern: - writeConcern: - command_name: insert - database_name: *database_name - - command_started_event: - command: - commitTransaction: 1 - lsid: session0 - txnNumber: - $numberLong: "1" - startTransaction: - autocommit: false - readConcern: - writeConcern: - command_name: commitTransaction - database_name: admin - - outcome: - collection: - data: - - _id: 1 - - - description: startTransaction overrides readPreference - - clientOptions: - readPreference: primary - - sessionOptions: - session0: - defaultTransactionOptions: - readPreference: - mode: Primary - - operations: - - name: startTransaction - object: session0 - arguments: - options: - readPreference: - mode: Secondary - - name: insertOne - object: collection - arguments: - session: session0 - document: - _id: 1 - result: - insertedId: 1 - - name: find - object: collection - arguments: - session: session0 - filter: - _id: 1 - result: - errorContains: read preference in a transaction must be primary - - name: commitTransaction - object: session0 - - expectations: - - command_started_event: - command: - insert: *collection_name - documents: - - _id: 1 - ordered: true - lsid: session0 - txnNumber: - $numberLong: "1" - startTransaction: true - autocommit: false - readConcern: - writeConcern: - command_name: insert - database_name: *database_name - - command_started_event: - command: - commitTransaction: 1 - lsid: session0 - txnNumber: - $numberLong: "1" - startTransaction: - autocommit: false - readConcern: - writeConcern: - command_name: commitTransaction - database_name: admin - - outcome: - collection: - data: - - _id: 1 diff --git a/source/transactions/tests/legacy/update.json b/source/transactions/tests/legacy/update.json deleted file mode 100644 index df2c480e5f..0000000000 --- a/source/transactions/tests/legacy/update.json +++ /dev/null @@ -1,443 +0,0 @@ -{ - "runOn": [ - { - "minServerVersion": "4.0", - "topology": [ - "replicaset" - ] - }, - { - "minServerVersion": "4.1.8", - "topology": [ - "sharded", - "load-balanced" - ] - } - ], - "database_name": "transaction-tests", - "collection_name": "test", - "data": [ - { - "_id": 1 - }, - { - "_id": 2 - }, - { - "_id": 3 - } - ], - "tests": [ - { - "description": "update", - "operations": [ - { - "name": "startTransaction", - "object": "session0" - }, - { - "name": "updateOne", - "object": "collection", - "arguments": { - "session": "session0", - "filter": { - "_id": 4 - }, - "update": { - "$inc": { - "x": 1 - } - }, - "upsert": true - }, - "result": { - "matchedCount": 0, - "modifiedCount": 0, - "upsertedCount": 1, - "upsertedId": 4 - } - }, - { - "name": "replaceOne", - "object": "collection", - "arguments": { - "session": "session0", - "filter": { - "x": 1 - }, - "replacement": { - "y": 1 - } - }, - "result": { - "matchedCount": 1, - "modifiedCount": 1, - "upsertedCount": 0 - } - }, - { - "name": "updateMany", - "object": "collection", - "arguments": { - "session": "session0", - "filter": { - "_id": { - "$gte": 3 - } - }, - "update": { - "$set": { - "z": 1 - } - } - }, - "result": { - "matchedCount": 2, - "modifiedCount": 2, - "upsertedCount": 0 - } - }, - { - "name": "commitTransaction", - "object": "session0" - } - ], - "expectations": [ - { - "command_started_event": { - "command": { - "update": "test", - "updates": [ - { - "q": { - "_id": 4 - }, - "u": { - "$inc": { - "x": 1 - } - }, - "upsert": true - } - ], - "ordered": true, - "readConcern": null, - "lsid": "session0", - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": true, - "autocommit": false, - "writeConcern": null - }, - "command_name": "update", - "database_name": "transaction-tests" - } - }, - { - "command_started_event": { - "command": { - "update": "test", - "updates": [ - { - "q": { - "x": 1 - }, - "u": { - "y": 1 - } - } - ], - "ordered": true, - "lsid": "session0", - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": null, - "autocommit": false, - "writeConcern": null - }, - "command_name": "update", - "database_name": "transaction-tests" - } - }, - { - "command_started_event": { - "command": { - "update": "test", - "updates": [ - { - "q": { - "_id": { - "$gte": 3 - } - }, - "u": { - "$set": { - "z": 1 - } - }, - "multi": true - } - ], - "ordered": true, - "lsid": "session0", - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": null, - "autocommit": false, - "writeConcern": null - }, - "command_name": "update", - "database_name": "transaction-tests" - } - }, - { - "command_started_event": { - "command": { - "commitTransaction": 1, - "lsid": "session0", - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": null, - "autocommit": false, - "writeConcern": null - }, - "command_name": "commitTransaction", - "database_name": "admin" - } - } - ], - "outcome": { - "collection": { - "data": [ - { - "_id": 1 - }, - { - "_id": 2 - }, - { - "_id": 3, - "z": 1 - }, - { - "_id": 4, - "y": 1, - "z": 1 - } - ] - } - } - }, - { - "description": "collections writeConcern ignored for update", - "operations": [ - { - "name": "startTransaction", - "object": "session0", - "arguments": { - "options": { - "writeConcern": { - "w": "majority" - } - } - } - }, - { - "name": "updateOne", - "object": "collection", - "collectionOptions": { - "writeConcern": { - "w": "majority" - } - }, - "arguments": { - "session": "session0", - "filter": { - "_id": 4 - }, - "update": { - "$inc": { - "x": 1 - } - }, - "upsert": true - }, - "result": { - "matchedCount": 0, - "modifiedCount": 0, - "upsertedCount": 1, - "upsertedId": 4 - } - }, - { - "name": "replaceOne", - "object": "collection", - "collectionOptions": { - "writeConcern": { - "w": "majority" - } - }, - "arguments": { - "session": "session0", - "filter": { - "x": 1 - }, - "replacement": { - "y": 1 - } - }, - "result": { - "matchedCount": 1, - "modifiedCount": 1, - "upsertedCount": 0 - } - }, - { - "name": "updateMany", - "object": "collection", - "collectionOptions": { - "writeConcern": { - "w": "majority" - } - }, - "arguments": { - "session": "session0", - "filter": { - "_id": { - "$gte": 3 - } - }, - "update": { - "$set": { - "z": 1 - } - } - }, - "result": { - "matchedCount": 2, - "modifiedCount": 2, - "upsertedCount": 0 - } - }, - { - "name": "commitTransaction", - "object": "session0" - } - ], - "expectations": [ - { - "command_started_event": { - "command": { - "update": "test", - "updates": [ - { - "q": { - "_id": 4 - }, - "u": { - "$inc": { - "x": 1 - } - }, - "upsert": true - } - ], - "ordered": true, - "readConcern": null, - "lsid": "session0", - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": true, - "autocommit": false, - "writeConcern": null - }, - "command_name": "update", - "database_name": "transaction-tests" - } - }, - { - "command_started_event": { - "command": { - "update": "test", - "updates": [ - { - "q": { - "x": 1 - }, - "u": { - "y": 1 - } - } - ], - "ordered": true, - "lsid": "session0", - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": null, - "autocommit": false, - "writeConcern": null - }, - "command_name": "update", - "database_name": "transaction-tests" - } - }, - { - "command_started_event": { - "command": { - "update": "test", - "updates": [ - { - "q": { - "_id": { - "$gte": 3 - } - }, - "u": { - "$set": { - "z": 1 - } - }, - "multi": true - } - ], - "ordered": true, - "lsid": "session0", - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": null, - "autocommit": false, - "writeConcern": null - }, - "command_name": "update", - "database_name": "transaction-tests" - } - }, - { - "command_started_event": { - "command": { - "commitTransaction": 1, - "lsid": "session0", - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": null, - "autocommit": false, - "writeConcern": { - "w": "majority" - } - }, - "command_name": "commitTransaction", - "database_name": "admin" - } - } - ] - } - ] -} diff --git a/source/transactions/tests/legacy/update.yml b/source/transactions/tests/legacy/update.yml deleted file mode 100644 index b6167ac611..0000000000 --- a/source/transactions/tests/legacy/update.yml +++ /dev/null @@ -1,246 +0,0 @@ -runOn: - - - minServerVersion: "4.0" - topology: ["replicaset"] - - - minServerVersion: "4.1.8" - topology: ["sharded", "load-balanced"] - -database_name: &database_name "transaction-tests" -collection_name: &collection_name "test" - -data: - - _id: 1 - - _id: 2 - - _id: 3 - -tests: - - description: update - - operations: - - name: startTransaction - object: session0 - - name: updateOne - object: collection - arguments: - session: session0 - filter: {_id: 4} - update: - $inc: {x: 1} - upsert: true - result: - matchedCount: 0 - modifiedCount: 0 - upsertedCount: 1 - upsertedId: 4 - - name: replaceOne - object: collection - arguments: - session: session0 - filter: {x: 1} - replacement: {y: 1} - result: - matchedCount: 1 - modifiedCount: 1 - upsertedCount: 0 - - name: updateMany - object: collection - arguments: - session: session0 - filter: - _id: {$gte: 3} - update: - $set: {z: 1} - result: - matchedCount: 2 - modifiedCount: 2 - upsertedCount: 0 - - name: commitTransaction - object: session0 - - expectations: - - command_started_event: - command: - update: *collection_name - updates: - - q: {_id: 4} - u: {$inc: {x: 1}} - upsert: true - ordered: true - readConcern: - lsid: session0 - txnNumber: - $numberLong: "1" - startTransaction: true - autocommit: false - writeConcern: - command_name: update - database_name: *database_name - - command_started_event: - command: - update: *collection_name - updates: - - q: {x: 1} - u: {y: 1} - ordered: true - lsid: session0 - txnNumber: - $numberLong: "1" - startTransaction: - autocommit: false - writeConcern: - command_name: update - database_name: *database_name - - command_started_event: - command: - update: *collection_name - updates: - - q: {_id: {$gte: 3}} - u: {$set: {z: 1}} - multi: true - ordered: true - lsid: session0 - txnNumber: - $numberLong: "1" - startTransaction: - autocommit: false - writeConcern: - command_name: update - database_name: *database_name - - command_started_event: - command: - commitTransaction: 1 - lsid: session0 - txnNumber: - $numberLong: "1" - startTransaction: - autocommit: false - writeConcern: - command_name: commitTransaction - database_name: admin - - outcome: - collection: - data: - - {_id: 1} - - {_id: 2} - - {_id: 3, z: 1} - - {_id: 4, y: 1, z: 1} - - - description: collections writeConcern ignored for update - - operations: - - name: startTransaction - object: session0 - arguments: - options: - writeConcern: - w: majority - - name: updateOne - object: collection - collectionOptions: - writeConcern: - w: majority - arguments: - session: session0 - filter: {_id: 4} - update: - $inc: {x: 1} - upsert: true - result: - matchedCount: 0 - modifiedCount: 0 - upsertedCount: 1 - upsertedId: 4 - - name: replaceOne - object: collection - collectionOptions: - writeConcern: - w: majority - arguments: - session: session0 - filter: {x: 1} - replacement: {y: 1} - result: - matchedCount: 1 - modifiedCount: 1 - upsertedCount: 0 - - name: updateMany - object: collection - collectionOptions: - writeConcern: - w: majority - arguments: - session: session0 - filter: - _id: {$gte: 3} - update: - $set: {z: 1} - result: - matchedCount: 2 - modifiedCount: 2 - upsertedCount: 0 - - name: commitTransaction - object: session0 - - expectations: - - command_started_event: - command: - update: *collection_name - updates: - - q: {_id: 4} - u: {$inc: {x: 1}} - upsert: true - ordered: true - readConcern: - lsid: session0 - txnNumber: - $numberLong: "1" - startTransaction: true - autocommit: false - writeConcern: - command_name: update - database_name: *database_name - - command_started_event: - command: - update: *collection_name - updates: - - q: {x: 1} - u: {y: 1} - ordered: true - lsid: session0 - txnNumber: - $numberLong: "1" - startTransaction: - autocommit: false - writeConcern: - command_name: update - database_name: *database_name - - command_started_event: - command: - update: *collection_name - updates: - - q: {_id: {$gte: 3}} - u: {$set: {z: 1}} - multi: true - ordered: true - lsid: session0 - txnNumber: - $numberLong: "1" - startTransaction: - autocommit: false - writeConcern: - command_name: update - database_name: *database_name - - command_started_event: - command: - commitTransaction: 1 - lsid: session0 - txnNumber: - $numberLong: "1" - startTransaction: - autocommit: false - writeConcern: - w: majority - command_name: commitTransaction - database_name: admin diff --git a/source/transactions/tests/legacy/write-concern.json b/source/transactions/tests/legacy/write-concern.json deleted file mode 100644 index 5d17f741ee..0000000000 --- a/source/transactions/tests/legacy/write-concern.json +++ /dev/null @@ -1,1279 +0,0 @@ -{ - "runOn": [ - { - "minServerVersion": "4.0", - "topology": [ - "replicaset" - ] - }, - { - "minServerVersion": "4.1.8", - "topology": [ - "sharded", - "load-balanced" - ] - } - ], - "database_name": "transaction-tests", - "collection_name": "test", - "data": [ - { - "_id": 0 - } - ], - "tests": [ - { - "description": "commit with majority", - "operations": [ - { - "name": "startTransaction", - "object": "session0", - "arguments": { - "options": { - "writeConcern": { - "w": "majority" - } - } - } - }, - { - "name": "insertOne", - "object": "collection", - "arguments": { - "session": "session0", - "document": { - "_id": 1 - } - }, - "result": { - "insertedId": 1 - } - }, - { - "name": "commitTransaction", - "object": "session0" - } - ], - "expectations": [ - { - "command_started_event": { - "command": { - "insert": "test", - "documents": [ - { - "_id": 1 - } - ], - "ordered": true, - "lsid": "session0", - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": true, - "autocommit": false, - "readConcern": null, - "writeConcern": null - }, - "command_name": "insert", - "database_name": "transaction-tests" - } - }, - { - "command_started_event": { - "command": { - "commitTransaction": 1, - "lsid": "session0", - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": null, - "autocommit": false, - "writeConcern": { - "w": "majority" - } - }, - "command_name": "commitTransaction", - "database_name": "admin" - } - } - ], - "outcome": { - "collection": { - "data": [ - { - "_id": 0 - }, - { - "_id": 1 - } - ] - } - } - }, - { - "description": "commit with default", - "operations": [ - { - "name": "startTransaction", - "object": "session0" - }, - { - "name": "insertOne", - "object": "collection", - "arguments": { - "session": "session0", - "document": { - "_id": 1 - } - }, - "result": { - "insertedId": 1 - } - }, - { - "name": "commitTransaction", - "object": "session0" - } - ], - "expectations": [ - { - "command_started_event": { - "command": { - "insert": "test", - "documents": [ - { - "_id": 1 - } - ], - "ordered": true, - "lsid": "session0", - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": true, - "autocommit": false, - "readConcern": null, - "writeConcern": null - }, - "command_name": "insert", - "database_name": "transaction-tests" - } - }, - { - "command_started_event": { - "command": { - "commitTransaction": 1, - "lsid": "session0", - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": null, - "autocommit": false, - "writeConcern": null - }, - "command_name": "commitTransaction", - "database_name": "admin" - } - } - ], - "outcome": { - "collection": { - "data": [ - { - "_id": 0 - }, - { - "_id": 1 - } - ] - } - } - }, - { - "description": "abort with majority", - "operations": [ - { - "name": "startTransaction", - "object": "session0", - "arguments": { - "options": { - "writeConcern": { - "w": "majority" - } - } - } - }, - { - "name": "insertOne", - "object": "collection", - "arguments": { - "session": "session0", - "document": { - "_id": 1 - } - }, - "result": { - "insertedId": 1 - } - }, - { - "name": "abortTransaction", - "object": "session0" - } - ], - "expectations": [ - { - "command_started_event": { - "command": { - "insert": "test", - "documents": [ - { - "_id": 1 - } - ], - "ordered": true, - "lsid": "session0", - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": true, - "autocommit": false, - "readConcern": null, - "writeConcern": null - }, - "command_name": "insert", - "database_name": "transaction-tests" - } - }, - { - "command_started_event": { - "command": { - "abortTransaction": 1, - "lsid": "session0", - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": null, - "autocommit": false, - "writeConcern": { - "w": "majority" - } - }, - "command_name": "abortTransaction", - "database_name": "admin" - } - } - ], - "outcome": { - "collection": { - "data": [ - { - "_id": 0 - } - ] - } - } - }, - { - "description": "abort with default", - "operations": [ - { - "name": "startTransaction", - "object": "session0" - }, - { - "name": "insertOne", - "object": "collection", - "arguments": { - "session": "session0", - "document": { - "_id": 1 - } - }, - "result": { - "insertedId": 1 - } - }, - { - "name": "abortTransaction", - "object": "session0" - } - ], - "expectations": [ - { - "command_started_event": { - "command": { - "insert": "test", - "documents": [ - { - "_id": 1 - } - ], - "ordered": true, - "lsid": "session0", - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": true, - "autocommit": false, - "readConcern": null, - "writeConcern": null - }, - "command_name": "insert", - "database_name": "transaction-tests" - } - }, - { - "command_started_event": { - "command": { - "abortTransaction": 1, - "lsid": "session0", - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": null, - "autocommit": false, - "writeConcern": null - }, - "command_name": "abortTransaction", - "database_name": "admin" - } - } - ], - "outcome": { - "collection": { - "data": [ - { - "_id": 0 - } - ] - } - } - }, - { - "description": "start with unacknowledged write concern", - "operations": [ - { - "name": "startTransaction", - "object": "session0", - "arguments": { - "options": { - "writeConcern": { - "w": 0 - } - } - }, - "result": { - "errorContains": "transactions do not support unacknowledged write concern" - } - } - ] - }, - { - "description": "start with implicit unacknowledged write concern", - "clientOptions": { - "w": 0 - }, - "operations": [ - { - "name": "startTransaction", - "object": "session0", - "result": { - "errorContains": "transactions do not support unacknowledged write concern" - } - } - ] - }, - { - "description": "unacknowledged write concern coll insertOne", - "operations": [ - { - "name": "startTransaction", - "object": "session0" - }, - { - "name": "insertOne", - "object": "collection", - "collectionOptions": { - "writeConcern": { - "w": 0 - } - }, - "arguments": { - "session": "session0", - "document": { - "_id": 1 - } - }, - "result": { - "insertedId": 1 - } - }, - { - "name": "commitTransaction", - "object": "session0" - } - ], - "expectations": [ - { - "command_started_event": { - "command": { - "insert": "test", - "documents": [ - { - "_id": 1 - } - ], - "ordered": true, - "lsid": "session0", - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": true, - "autocommit": false, - "readConcern": null, - "writeConcern": null - }, - "command_name": "insert", - "database_name": "transaction-tests" - } - }, - { - "command_started_event": { - "command": { - "commitTransaction": 1, - "lsid": "session0", - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": null, - "autocommit": false, - "writeConcern": null - }, - "command_name": "commitTransaction", - "database_name": "admin" - } - } - ], - "outcome": { - "collection": { - "data": [ - { - "_id": 0 - }, - { - "_id": 1 - } - ] - } - } - }, - { - "description": "unacknowledged write concern coll insertMany", - "operations": [ - { - "name": "startTransaction", - "object": "session0" - }, - { - "name": "insertMany", - "object": "collection", - "collectionOptions": { - "writeConcern": { - "w": 0 - } - }, - "arguments": { - "session": "session0", - "documents": [ - { - "_id": 1 - }, - { - "_id": 2 - } - ] - }, - "result": { - "insertedIds": { - "0": 1, - "1": 2 - } - } - }, - { - "name": "commitTransaction", - "object": "session0" - } - ], - "expectations": [ - { - "command_started_event": { - "command": { - "insert": "test", - "documents": [ - { - "_id": 1 - }, - { - "_id": 2 - } - ], - "ordered": true, - "lsid": "session0", - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": true, - "autocommit": false, - "readConcern": null, - "writeConcern": null - }, - "command_name": "insert", - "database_name": "transaction-tests" - } - }, - { - "command_started_event": { - "command": { - "commitTransaction": 1, - "lsid": "session0", - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": null, - "autocommit": false, - "writeConcern": null - }, - "command_name": "commitTransaction", - "database_name": "admin" - } - } - ], - "outcome": { - "collection": { - "data": [ - { - "_id": 0 - }, - { - "_id": 1 - }, - { - "_id": 2 - } - ] - } - } - }, - { - "description": "unacknowledged write concern coll bulkWrite", - "operations": [ - { - "name": "startTransaction", - "object": "session0" - }, - { - "name": "bulkWrite", - "object": "collection", - "collectionOptions": { - "writeConcern": { - "w": 0 - } - }, - "arguments": { - "session": "session0", - "requests": [ - { - "name": "insertOne", - "arguments": { - "document": { - "_id": 1 - } - } - } - ] - }, - "result": { - "deletedCount": 0, - "insertedCount": 1, - "insertedIds": { - "0": 1 - }, - "matchedCount": 0, - "modifiedCount": 0, - "upsertedCount": 0, - "upsertedIds": {} - } - }, - { - "name": "commitTransaction", - "object": "session0" - } - ], - "expectations": [ - { - "command_started_event": { - "command": { - "insert": "test", - "documents": [ - { - "_id": 1 - } - ], - "ordered": true, - "lsid": "session0", - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": true, - "autocommit": false, - "readConcern": null, - "writeConcern": null - }, - "command_name": "insert", - "database_name": "transaction-tests" - } - }, - { - "command_started_event": { - "command": { - "commitTransaction": 1, - "lsid": "session0", - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": null, - "autocommit": false, - "writeConcern": null - }, - "command_name": "commitTransaction", - "database_name": "admin" - } - } - ], - "outcome": { - "collection": { - "data": [ - { - "_id": 0 - }, - { - "_id": 1 - } - ] - } - } - }, - { - "description": "unacknowledged write concern coll deleteOne", - "operations": [ - { - "name": "startTransaction", - "object": "session0" - }, - { - "name": "deleteOne", - "object": "collection", - "collectionOptions": { - "writeConcern": { - "w": 0 - } - }, - "arguments": { - "session": "session0", - "filter": { - "_id": 0 - } - }, - "result": { - "deletedCount": 1 - } - }, - { - "name": "commitTransaction", - "object": "session0" - } - ], - "expectations": [ - { - "command_started_event": { - "command": { - "delete": "test", - "deletes": [ - { - "q": { - "_id": 0 - }, - "limit": 1 - } - ], - "ordered": true, - "lsid": "session0", - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": true, - "autocommit": false, - "readConcern": null, - "writeConcern": null - }, - "command_name": "delete", - "database_name": "transaction-tests" - } - }, - { - "command_started_event": { - "command": { - "commitTransaction": 1, - "lsid": "session0", - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": null, - "autocommit": false, - "writeConcern": null - }, - "command_name": "commitTransaction", - "database_name": "admin" - } - } - ], - "outcome": { - "collection": { - "data": [] - } - } - }, - { - "description": "unacknowledged write concern coll deleteMany", - "operations": [ - { - "name": "startTransaction", - "object": "session0" - }, - { - "name": "deleteMany", - "object": "collection", - "collectionOptions": { - "writeConcern": { - "w": 0 - } - }, - "arguments": { - "session": "session0", - "filter": { - "_id": 0 - } - }, - "result": { - "deletedCount": 1 - } - }, - { - "name": "commitTransaction", - "object": "session0" - } - ], - "expectations": [ - { - "command_started_event": { - "command": { - "delete": "test", - "deletes": [ - { - "q": { - "_id": 0 - }, - "limit": 0 - } - ], - "ordered": true, - "lsid": "session0", - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": true, - "autocommit": false, - "readConcern": null, - "writeConcern": null - }, - "command_name": "delete", - "database_name": "transaction-tests" - } - }, - { - "command_started_event": { - "command": { - "commitTransaction": 1, - "lsid": "session0", - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": null, - "autocommit": false, - "writeConcern": null - }, - "command_name": "commitTransaction", - "database_name": "admin" - } - } - ], - "outcome": { - "collection": { - "data": [] - } - } - }, - { - "description": "unacknowledged write concern coll updateOne", - "operations": [ - { - "name": "startTransaction", - "object": "session0" - }, - { - "name": "updateOne", - "object": "collection", - "collectionOptions": { - "writeConcern": { - "w": 0 - } - }, - "arguments": { - "session": "session0", - "filter": { - "_id": 0 - }, - "update": { - "$inc": { - "x": 1 - } - }, - "upsert": true - }, - "result": { - "matchedCount": 1, - "modifiedCount": 1, - "upsertedCount": 0 - } - }, - { - "name": "commitTransaction", - "object": "session0" - } - ], - "expectations": [ - { - "command_started_event": { - "command": { - "update": "test", - "updates": [ - { - "q": { - "_id": 0 - }, - "u": { - "$inc": { - "x": 1 - } - }, - "upsert": true - } - ], - "ordered": true, - "lsid": "session0", - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": true, - "autocommit": false, - "readConcern": null, - "writeConcern": null - }, - "command_name": "update", - "database_name": "transaction-tests" - } - }, - { - "command_started_event": { - "command": { - "commitTransaction": 1, - "lsid": "session0", - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": null, - "autocommit": false, - "writeConcern": null - }, - "command_name": "commitTransaction", - "database_name": "admin" - } - } - ], - "outcome": { - "collection": { - "data": [ - { - "_id": 0, - "x": 1 - } - ] - } - } - }, - { - "description": "unacknowledged write concern coll updateMany", - "operations": [ - { - "name": "startTransaction", - "object": "session0" - }, - { - "name": "updateMany", - "object": "collection", - "collectionOptions": { - "writeConcern": { - "w": 0 - } - }, - "arguments": { - "session": "session0", - "filter": { - "_id": 0 - }, - "update": { - "$inc": { - "x": 1 - } - }, - "upsert": true - }, - "result": { - "matchedCount": 1, - "modifiedCount": 1, - "upsertedCount": 0 - } - }, - { - "name": "commitTransaction", - "object": "session0" - } - ], - "expectations": [ - { - "command_started_event": { - "command": { - "update": "test", - "updates": [ - { - "q": { - "_id": 0 - }, - "u": { - "$inc": { - "x": 1 - } - }, - "multi": true, - "upsert": true - } - ], - "ordered": true, - "lsid": "session0", - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": true, - "autocommit": false, - "readConcern": null, - "writeConcern": null - }, - "command_name": "update", - "database_name": "transaction-tests" - } - }, - { - "command_started_event": { - "command": { - "commitTransaction": 1, - "lsid": "session0", - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": null, - "autocommit": false, - "writeConcern": null - }, - "command_name": "commitTransaction", - "database_name": "admin" - } - } - ], - "outcome": { - "collection": { - "data": [ - { - "_id": 0, - "x": 1 - } - ] - } - } - }, - { - "description": "unacknowledged write concern coll findOneAndDelete", - "operations": [ - { - "name": "startTransaction", - "object": "session0" - }, - { - "name": "findOneAndDelete", - "object": "collection", - "collectionOptions": { - "writeConcern": { - "w": 0 - } - }, - "arguments": { - "session": "session0", - "filter": { - "_id": 0 - } - }, - "result": { - "_id": 0 - } - }, - { - "name": "commitTransaction", - "object": "session0" - } - ], - "expectations": [ - { - "command_started_event": { - "command": { - "findAndModify": "test", - "query": { - "_id": 0 - }, - "remove": true, - "lsid": "session0", - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": true, - "autocommit": false, - "readConcern": null, - "writeConcern": null - }, - "command_name": "findAndModify", - "database_name": "transaction-tests" - } - }, - { - "command_started_event": { - "command": { - "commitTransaction": 1, - "lsid": "session0", - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": null, - "autocommit": false, - "writeConcern": null - }, - "command_name": "commitTransaction", - "database_name": "admin" - } - } - ], - "outcome": { - "collection": { - "data": [] - } - } - }, - { - "description": "unacknowledged write concern coll findOneAndReplace", - "operations": [ - { - "name": "startTransaction", - "object": "session0" - }, - { - "name": "findOneAndReplace", - "object": "collection", - "collectionOptions": { - "writeConcern": { - "w": 0 - } - }, - "arguments": { - "session": "session0", - "filter": { - "_id": 0 - }, - "replacement": { - "x": 1 - }, - "returnDocument": "Before" - }, - "result": { - "_id": 0 - } - }, - { - "name": "commitTransaction", - "object": "session0" - } - ], - "expectations": [ - { - "command_started_event": { - "command": { - "findAndModify": "test", - "query": { - "_id": 0 - }, - "update": { - "x": 1 - }, - "new": false, - "lsid": "session0", - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": true, - "autocommit": false, - "readConcern": null, - "writeConcern": null - }, - "command_name": "findAndModify", - "database_name": "transaction-tests" - } - }, - { - "command_started_event": { - "command": { - "commitTransaction": 1, - "lsid": "session0", - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": null, - "autocommit": false, - "writeConcern": null - }, - "command_name": "commitTransaction", - "database_name": "admin" - } - } - ], - "outcome": { - "collection": { - "data": [ - { - "_id": 0, - "x": 1 - } - ] - } - } - }, - { - "description": "unacknowledged write concern coll findOneAndUpdate", - "operations": [ - { - "name": "startTransaction", - "object": "session0" - }, - { - "name": "findOneAndUpdate", - "object": "collection", - "collectionOptions": { - "writeConcern": { - "w": 0 - } - }, - "arguments": { - "session": "session0", - "filter": { - "_id": 0 - }, - "update": { - "$inc": { - "x": 1 - } - }, - "returnDocument": "Before" - }, - "result": { - "_id": 0 - } - }, - { - "name": "commitTransaction", - "object": "session0" - } - ], - "expectations": [ - { - "command_started_event": { - "command": { - "findAndModify": "test", - "query": { - "_id": 0 - }, - "update": { - "$inc": { - "x": 1 - } - }, - "new": false, - "lsid": "session0", - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": true, - "autocommit": false, - "readConcern": null, - "writeConcern": null - }, - "command_name": "findAndModify", - "database_name": "transaction-tests" - } - }, - { - "command_started_event": { - "command": { - "commitTransaction": 1, - "lsid": "session0", - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": null, - "autocommit": false, - "writeConcern": null - }, - "command_name": "commitTransaction", - "database_name": "admin" - } - } - ], - "outcome": { - "collection": { - "data": [ - { - "_id": 0, - "x": 1 - } - ] - } - } - } - ] -} diff --git a/source/transactions/tests/legacy/write-concern.yml b/source/transactions/tests/legacy/write-concern.yml deleted file mode 100644 index bafe87d9b6..0000000000 --- a/source/transactions/tests/legacy/write-concern.yml +++ /dev/null @@ -1,554 +0,0 @@ -# Assumes the default for transactions is the same as for all ops, tests -# setting the writeConcern to "majority". -runOn: - - - minServerVersion: "4.0" - topology: ["replicaset"] - - - minServerVersion: "4.1.8" - topology: ["sharded", "load-balanced"] - -database_name: &database_name "transaction-tests" -collection_name: &collection_name "test" - -data: &data - - _id: 0 - -tests: - - description: commit with majority - operations: - - name: startTransaction - object: session0 - arguments: - options: - writeConcern: - w: majority - - name: insertOne - object: collection - arguments: - session: session0 - document: - _id: 1 - result: - insertedId: 1 - - &commitTransaction - name: commitTransaction - object: session0 - - expectations: - - &insertOneEvent - command_started_event: - command: - insert: *collection_name - documents: - - _id: 1 - ordered: true - <<: &transactionCommandArgs - lsid: session0 - txnNumber: - $numberLong: "1" - startTransaction: true - autocommit: false - readConcern: - writeConcern: - command_name: insert - database_name: *database_name - - command_started_event: - command: - commitTransaction: 1 - lsid: session0 - txnNumber: - $numberLong: "1" - startTransaction: - autocommit: false - writeConcern: - w: majority - command_name: commitTransaction - database_name: admin - - outcome: - collection: - data: - - _id: 0 - - _id: 1 - - - description: commit with default - - operations: - - &startTransaction - name: startTransaction - object: session0 - - name: insertOne - object: collection - arguments: - session: session0 - document: - _id: 1 - result: - insertedId: 1 - - *commitTransaction - - expectations: - - command_started_event: - command: - insert: *collection_name - documents: - - _id: 1 - ordered: true - <<: *transactionCommandArgs - command_name: insert - database_name: *database_name - - &commitWithDefaultWCEvent - command_started_event: - command: - commitTransaction: 1 - lsid: session0 - txnNumber: - $numberLong: "1" - startTransaction: - autocommit: false - writeConcern: - command_name: commitTransaction - database_name: admin - - outcome: - collection: - data: - - _id: 0 - - _id: 1 - - - description: abort with majority - - operations: - - name: startTransaction - object: session0 - arguments: - options: - writeConcern: - w: majority - - name: insertOne - object: collection - arguments: - session: session0 - document: - _id: 1 - result: - insertedId: 1 - - name: abortTransaction - object: session0 - - expectations: - - command_started_event: - command: - insert: *collection_name - documents: - - _id: 1 - ordered: true - <<: *transactionCommandArgs - command_name: insert - database_name: *database_name - - command_started_event: - command: - abortTransaction: 1 - lsid: session0 - txnNumber: - $numberLong: "1" - startTransaction: - autocommit: false - writeConcern: - w: majority - command_name: abortTransaction - database_name: admin - - outcome: - collection: - data: *data - - - description: abort with default - - operations: - - name: startTransaction - object: session0 - - name: insertOne - object: collection - arguments: - session: session0 - document: - _id: 1 - result: - insertedId: 1 - - name: abortTransaction - object: session0 - - expectations: - - command_started_event: - command: - insert: *collection_name - documents: - - _id: 1 - ordered: true - <<: *transactionCommandArgs - command_name: insert - database_name: *database_name - - command_started_event: - command: - abortTransaction: 1 - lsid: session0 - txnNumber: - $numberLong: "1" - startTransaction: - autocommit: false - writeConcern: - command_name: abortTransaction - database_name: admin - - outcome: - collection: - data: *data - - - description: start with unacknowledged write concern - - operations: - - name: startTransaction - object: session0 - arguments: - options: - writeConcern: - w: 0 - result: - # Client-side error. - errorContains: transactions do not support unacknowledged write concern - - - description: start with implicit unacknowledged write concern - - clientOptions: - w: 0 - - operations: - - name: startTransaction - object: session0 - result: - # Client-side error. - errorContains: transactions do not support unacknowledged write concern - - - description: unacknowledged write concern coll insertOne - - operations: - - *startTransaction - - name: insertOne - <<: &collection_w0 - object: collection - collectionOptions: - writeConcern: { w: 0 } - arguments: - session: session0 - document: - _id: 1 - result: - insertedId: 1 - - *commitTransaction - - expectations: - - *insertOneEvent - - *commitWithDefaultWCEvent - - outcome: - collection: - data: - - _id: 0 - - _id: 1 - - - description: unacknowledged write concern coll insertMany - - operations: - - *startTransaction - - name: insertMany - <<: *collection_w0 - arguments: - session: session0 - documents: - - _id: 1 - - _id: 2 - result: - insertedIds: {0: 1, 1: 2} - - *commitTransaction - - expectations: - - command_started_event: - command: - insert: *collection_name - documents: - - _id: 1 - - _id: 2 - ordered: true - <<: *transactionCommandArgs - command_name: insert - database_name: *database_name - - *commitWithDefaultWCEvent - - outcome: - collection: - data: - - _id: 0 - - _id: 1 - - _id: 2 - - - description: unacknowledged write concern coll bulkWrite - - operations: - - *startTransaction - - name: bulkWrite - <<: *collection_w0 - arguments: - session: session0 - requests: - - name: insertOne - arguments: - document: {_id: 1} - result: - deletedCount: 0 - insertedCount: 1 - insertedIds: {0: 1} - matchedCount: 0 - modifiedCount: 0 - upsertedCount: 0 - upsertedIds: {} - - *commitTransaction - - expectations: - - *insertOneEvent - - *commitWithDefaultWCEvent - - outcome: - collection: - data: - - _id: 0 - - _id: 1 - - - - description: unacknowledged write concern coll deleteOne - - operations: - - *startTransaction - - name: deleteOne - <<: *collection_w0 - arguments: - session: session0 - filter: - _id: 0 - result: - deletedCount: 1 - - *commitTransaction - - expectations: - - command_started_event: - command: - delete: *collection_name - deletes: - - q: {_id: 0} - limit: 1 - ordered: true - <<: *transactionCommandArgs - command_name: delete - database_name: *database_name - - *commitWithDefaultWCEvent - - outcome: - collection: - data: [] - - - description: unacknowledged write concern coll deleteMany - - operations: - - *startTransaction - - name: deleteMany - <<: *collection_w0 - arguments: - session: session0 - filter: - _id: 0 - result: - deletedCount: 1 - - *commitTransaction - - expectations: - - command_started_event: - command: - delete: *collection_name - deletes: - - q: {_id: 0} - limit: 0 - ordered: true - <<: *transactionCommandArgs - command_name: delete - database_name: *database_name - - *commitWithDefaultWCEvent - - outcome: - collection: - data: [] - - - description: unacknowledged write concern coll updateOne - - operations: - - *startTransaction - - name: updateOne - <<: *collection_w0 - arguments: - session: session0 - filter: {_id: 0} - update: - $inc: {x: 1} - upsert: true - result: - matchedCount: 1 - modifiedCount: 1 - upsertedCount: 0 - - *commitTransaction - - expectations: - - command_started_event: - command: - update: *collection_name - updates: - - q: {_id: 0} - u: {$inc: {x: 1}} - upsert: true - ordered: true - <<: *transactionCommandArgs - command_name: update - database_name: *database_name - - *commitWithDefaultWCEvent - - outcome: - collection: - data: - - {_id: 0, x: 1} - - - description: unacknowledged write concern coll updateMany - - operations: - - *startTransaction - - name: updateMany - <<: *collection_w0 - arguments: - session: session0 - filter: {_id: 0} - update: - $inc: {x: 1} - upsert: true - result: - matchedCount: 1 - modifiedCount: 1 - upsertedCount: 0 - - *commitTransaction - - expectations: - - command_started_event: - command: - update: *collection_name - updates: - - q: {_id: 0} - u: {$inc: {x: 1}} - multi: true - upsert: true - ordered: true - <<: *transactionCommandArgs - command_name: update - database_name: *database_name - - *commitWithDefaultWCEvent - - outcome: - collection: - data: - - {_id: 0, x: 1} - - - description: unacknowledged write concern coll findOneAndDelete - - operations: - - *startTransaction - - name: findOneAndDelete - <<: *collection_w0 - arguments: - session: session0 - filter: {_id: 0} - result: {_id: 0} - - *commitTransaction - - expectations: - - command_started_event: - command: - findAndModify: *collection_name - query: {_id: 0} - remove: True - <<: *transactionCommandArgs - command_name: findAndModify - database_name: *database_name - - *commitWithDefaultWCEvent - - outcome: - collection: - data: [] - - - description: unacknowledged write concern coll findOneAndReplace - - operations: - - *startTransaction - - name: findOneAndReplace - <<: *collection_w0 - arguments: - session: session0 - filter: {_id: 0} - replacement: {x: 1} - returnDocument: Before - result: {_id: 0} - - *commitTransaction - - expectations: - - command_started_event: - command: - findAndModify: *collection_name - query: {_id: 0} - update: {x: 1} - new: false - <<: *transactionCommandArgs - command_name: findAndModify - database_name: *database_name - - *commitWithDefaultWCEvent - - outcome: - collection: - data: - - {_id: 0, x: 1} - - - description: unacknowledged write concern coll findOneAndUpdate - - operations: - - *startTransaction - - name: findOneAndUpdate - <<: *collection_w0 - arguments: - session: session0 - filter: {_id: 0} - update: - $inc: {x: 1} - returnDocument: Before - result: {_id: 0} - - *commitTransaction - - expectations: - - command_started_event: - command: - findAndModify: *collection_name - query: {_id: 0} - update: {$inc: {x: 1}} - new: false - <<: *transactionCommandArgs - command_name: findAndModify - database_name: *database_name - - *commitWithDefaultWCEvent - - outcome: - collection: - data: - - {_id: 0, x: 1} diff --git a/source/transactions/tests/unified/abort.json b/source/transactions/tests/unified/abort.json new file mode 100644 index 0000000000..c151a7d0c6 --- /dev/null +++ b/source/transactions/tests/unified/abort.json @@ -0,0 +1,828 @@ +{ + "description": "abort", + "schemaVersion": "1.3", + "runOnRequirements": [ + { + "minServerVersion": "4.0", + "topologies": [ + "replicaset" + ] + }, + { + "minServerVersion": "4.1.8", + "topologies": [ + "sharded", + "load-balanced" + ] + } + ], + "createEntities": [ + { + "client": { + "id": "client0", + "useMultipleMongoses": false, + "observeEvents": [ + "commandStartedEvent" + ] + } + }, + { + "database": { + "id": "database0", + "client": "client0", + "databaseName": "transaction-tests" + } + }, + { + "collection": { + "id": "collection0", + "database": "database0", + "collectionName": "test" + } + }, + { + "session": { + "id": "session0", + "client": "client0" + } + } + ], + "initialData": [ + { + "collectionName": "test", + "databaseName": "transaction-tests", + "documents": [] + } + ], + "tests": [ + { + "description": "abort", + "operations": [ + { + "object": "session0", + "name": "startTransaction" + }, + { + "object": "collection0", + "name": "insertOne", + "arguments": { + "session": "session0", + "document": { + "_id": 1 + } + }, + "expectResult": { + "$$unsetOrMatches": { + "insertedId": { + "$$unsetOrMatches": 1 + } + } + } + }, + { + "object": "session0", + "name": "abortTransaction" + }, + { + "object": "session0", + "name": "startTransaction" + }, + { + "object": "collection0", + "name": "insertOne", + "arguments": { + "session": "session0", + "document": { + "_id": 1 + } + }, + "expectResult": { + "$$unsetOrMatches": { + "insertedId": { + "$$unsetOrMatches": 1 + } + } + } + }, + { + "object": "session0", + "name": "abortTransaction" + } + ], + "expectEvents": [ + { + "client": "client0", + "events": [ + { + "commandStartedEvent": { + "command": { + "insert": "test", + "documents": [ + { + "_id": 1 + } + ], + "ordered": true, + "readConcern": { + "$$exists": false + }, + "lsid": { + "$$sessionLsid": "session0" + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": true, + "autocommit": false, + "writeConcern": { + "$$exists": false + } + }, + "commandName": "insert", + "databaseName": "transaction-tests" + } + }, + { + "commandStartedEvent": { + "command": { + "abortTransaction": 1, + "lsid": { + "$$sessionLsid": "session0" + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": { + "$$exists": false + }, + "autocommit": false, + "writeConcern": { + "$$exists": false + } + }, + "commandName": "abortTransaction", + "databaseName": "admin" + } + }, + { + "commandStartedEvent": { + "command": { + "insert": "test", + "documents": [ + { + "_id": 1 + } + ], + "ordered": true, + "readConcern": { + "afterClusterTime": { + "$$exists": true + } + }, + "lsid": { + "$$sessionLsid": "session0" + }, + "txnNumber": { + "$numberLong": "2" + }, + "startTransaction": true, + "autocommit": false, + "writeConcern": { + "$$exists": false + } + }, + "commandName": "insert", + "databaseName": "transaction-tests" + } + }, + { + "commandStartedEvent": { + "command": { + "abortTransaction": 1, + "lsid": { + "$$sessionLsid": "session0" + }, + "txnNumber": { + "$numberLong": "2" + }, + "startTransaction": { + "$$exists": false + }, + "autocommit": false, + "writeConcern": { + "$$exists": false + } + }, + "commandName": "abortTransaction", + "databaseName": "admin" + } + } + ] + } + ], + "outcome": [ + { + "collectionName": "test", + "databaseName": "transaction-tests", + "documents": [] + } + ] + }, + { + "description": "implicit abort", + "operations": [ + { + "object": "session0", + "name": "startTransaction" + }, + { + "object": "collection0", + "name": "insertOne", + "arguments": { + "session": "session0", + "document": { + "_id": 1 + } + }, + "expectResult": { + "$$unsetOrMatches": { + "insertedId": { + "$$unsetOrMatches": 1 + } + } + } + }, + { + "object": "session0", + "name": "endSession" + } + ], + "expectEvents": [ + { + "client": "client0", + "events": [ + { + "commandStartedEvent": { + "command": { + "insert": "test", + "documents": [ + { + "_id": 1 + } + ], + "ordered": true, + "readConcern": { + "$$exists": false + }, + "lsid": { + "$$sessionLsid": "session0" + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": true, + "autocommit": false, + "writeConcern": { + "$$exists": false + } + }, + "commandName": "insert", + "databaseName": "transaction-tests" + } + }, + { + "commandStartedEvent": { + "command": { + "abortTransaction": 1, + "lsid": { + "$$sessionLsid": "session0" + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": { + "$$exists": false + }, + "autocommit": false, + "writeConcern": { + "$$exists": false + } + }, + "commandName": "abortTransaction", + "databaseName": "admin" + } + } + ] + } + ], + "outcome": [ + { + "collectionName": "test", + "databaseName": "transaction-tests", + "documents": [] + } + ] + }, + { + "description": "two aborts", + "operations": [ + { + "object": "session0", + "name": "startTransaction" + }, + { + "object": "collection0", + "name": "insertOne", + "arguments": { + "session": "session0", + "document": { + "_id": 1 + } + }, + "expectResult": { + "$$unsetOrMatches": { + "insertedId": { + "$$unsetOrMatches": 1 + } + } + } + }, + { + "object": "session0", + "name": "abortTransaction" + }, + { + "object": "session0", + "name": "abortTransaction", + "expectError": { + "errorContains": "cannot call abortTransaction twice" + } + } + ], + "expectEvents": [ + { + "client": "client0", + "events": [ + { + "commandStartedEvent": { + "command": { + "insert": "test", + "documents": [ + { + "_id": 1 + } + ], + "ordered": true, + "readConcern": { + "$$exists": false + }, + "lsid": { + "$$sessionLsid": "session0" + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": true, + "autocommit": false, + "writeConcern": { + "$$exists": false + } + }, + "commandName": "insert", + "databaseName": "transaction-tests" + } + }, + { + "commandStartedEvent": { + "command": { + "abortTransaction": 1, + "lsid": { + "$$sessionLsid": "session0" + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": { + "$$exists": false + }, + "autocommit": false, + "writeConcern": { + "$$exists": false + } + }, + "commandName": "abortTransaction", + "databaseName": "admin" + } + } + ] + } + ], + "outcome": [ + { + "collectionName": "test", + "databaseName": "transaction-tests", + "documents": [] + } + ] + }, + { + "description": "abort without start", + "operations": [ + { + "object": "session0", + "name": "abortTransaction", + "expectError": { + "errorContains": "no transaction started" + } + } + ], + "expectEvents": [ + { + "client": "client0", + "events": [] + } + ], + "outcome": [ + { + "collectionName": "test", + "databaseName": "transaction-tests", + "documents": [] + } + ] + }, + { + "description": "abort directly after no-op commit", + "operations": [ + { + "object": "session0", + "name": "startTransaction" + }, + { + "object": "session0", + "name": "commitTransaction" + }, + { + "object": "session0", + "name": "abortTransaction", + "expectError": { + "errorContains": "Cannot call abortTransaction after calling commitTransaction" + } + } + ], + "expectEvents": [ + { + "client": "client0", + "events": [] + } + ], + "outcome": [ + { + "collectionName": "test", + "databaseName": "transaction-tests", + "documents": [] + } + ] + }, + { + "description": "abort directly after commit", + "operations": [ + { + "object": "session0", + "name": "startTransaction" + }, + { + "object": "collection0", + "name": "insertOne", + "arguments": { + "session": "session0", + "document": { + "_id": 1 + } + }, + "expectResult": { + "$$unsetOrMatches": { + "insertedId": { + "$$unsetOrMatches": 1 + } + } + } + }, + { + "object": "session0", + "name": "commitTransaction" + }, + { + "object": "session0", + "name": "abortTransaction", + "expectError": { + "errorContains": "Cannot call abortTransaction after calling commitTransaction" + } + } + ], + "expectEvents": [ + { + "client": "client0", + "events": [ + { + "commandStartedEvent": { + "command": { + "insert": "test", + "documents": [ + { + "_id": 1 + } + ], + "ordered": true, + "readConcern": { + "$$exists": false + }, + "lsid": { + "$$sessionLsid": "session0" + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": true, + "autocommit": false, + "writeConcern": { + "$$exists": false + } + }, + "commandName": "insert", + "databaseName": "transaction-tests" + } + }, + { + "commandStartedEvent": { + "command": { + "commitTransaction": 1, + "lsid": { + "$$sessionLsid": "session0" + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": { + "$$exists": false + }, + "autocommit": false, + "writeConcern": { + "$$exists": false + } + }, + "commandName": "commitTransaction", + "databaseName": "admin" + } + } + ] + } + ], + "outcome": [ + { + "collectionName": "test", + "databaseName": "transaction-tests", + "documents": [ + { + "_id": 1 + } + ] + } + ] + }, + { + "description": "abort ignores TransactionAborted", + "operations": [ + { + "object": "session0", + "name": "startTransaction" + }, + { + "object": "collection0", + "name": "insertOne", + "arguments": { + "session": "session0", + "document": { + "_id": 1 + } + }, + "expectResult": { + "$$unsetOrMatches": { + "insertedId": { + "$$unsetOrMatches": 1 + } + } + } + }, + { + "object": "collection0", + "name": "insertOne", + "arguments": { + "session": "session0", + "document": { + "_id": 1 + } + }, + "expectError": { + "errorLabelsOmit": [ + "TransientTransactionError", + "UnknownTransactionCommitResult" + ], + "errorContains": "E11000" + } + }, + { + "object": "collection0", + "name": "insertOne", + "arguments": { + "session": "session0", + "document": { + "_id": 1 + } + }, + "expectError": { + "errorCodeName": "NoSuchTransaction", + "errorLabelsContain": [ + "TransientTransactionError" + ], + "errorLabelsOmit": [ + "UnknownTransactionCommitResult" + ] + } + }, + { + "object": "session0", + "name": "abortTransaction" + } + ], + "expectEvents": [ + { + "client": "client0", + "events": [ + { + "commandStartedEvent": { + "command": { + "insert": "test", + "documents": [ + { + "_id": 1 + } + ], + "ordered": true, + "readConcern": { + "$$exists": false + }, + "lsid": { + "$$sessionLsid": "session0" + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": true, + "autocommit": false, + "writeConcern": { + "$$exists": false + } + }, + "commandName": "insert", + "databaseName": "transaction-tests" + } + }, + { + "commandStartedEvent": { + "command": { + "insert": "test", + "documents": [ + { + "_id": 1 + } + ], + "ordered": true, + "readConcern": { + "$$exists": false + }, + "lsid": { + "$$sessionLsid": "session0" + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": { + "$$exists": false + }, + "autocommit": false, + "writeConcern": { + "$$exists": false + } + }, + "commandName": "insert", + "databaseName": "transaction-tests" + } + }, + { + "commandStartedEvent": { + "command": { + "insert": "test", + "documents": [ + { + "_id": 1 + } + ], + "ordered": true, + "readConcern": { + "$$exists": false + }, + "lsid": { + "$$sessionLsid": "session0" + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": { + "$$exists": false + }, + "autocommit": false, + "writeConcern": { + "$$exists": false + } + }, + "commandName": "insert", + "databaseName": "transaction-tests" + } + }, + { + "commandStartedEvent": { + "command": { + "abortTransaction": 1, + "lsid": { + "$$sessionLsid": "session0" + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": { + "$$exists": false + }, + "autocommit": false, + "writeConcern": { + "$$exists": false + } + }, + "commandName": "abortTransaction", + "databaseName": "admin" + } + } + ] + } + ], + "outcome": [ + { + "collectionName": "test", + "databaseName": "transaction-tests", + "documents": [] + } + ] + }, + { + "description": "abort does not apply writeConcern", + "operations": [ + { + "object": "session0", + "name": "startTransaction", + "arguments": { + "writeConcern": { + "w": 10 + } + } + }, + { + "object": "collection0", + "name": "insertOne", + "arguments": { + "session": "session0", + "document": { + "_id": 1 + } + }, + "expectResult": { + "$$unsetOrMatches": { + "insertedId": { + "$$unsetOrMatches": 1 + } + } + } + }, + { + "object": "session0", + "name": "abortTransaction" + } + ], + "outcome": [ + { + "collectionName": "test", + "databaseName": "transaction-tests", + "documents": [] + } + ] + } + ] +} diff --git a/source/transactions/tests/unified/abort.yml b/source/transactions/tests/unified/abort.yml new file mode 100644 index 0000000000..194846c92f --- /dev/null +++ b/source/transactions/tests/unified/abort.yml @@ -0,0 +1,483 @@ +description: abort + +schemaVersion: '1.3' + +runOnRequirements: + - + minServerVersion: '4.0' + topologies: + - replicaset + - + minServerVersion: 4.1.8 + topologies: + - sharded + - load-balanced + +createEntities: + - + client: + id: &client0 client0 + useMultipleMongoses: false + observeEvents: + - commandStartedEvent + - + database: + id: &database0 database0 + client: *client0 + databaseName: &database_name transaction-tests + - + collection: + id: &collection0 collection0 + database: *database0 + collectionName: &collection_name test + - + session: + id: &session0 session0 + client: *client0 + +initialData: + - + collectionName: *collection_name + databaseName: *database_name + documents: [] + +tests: + - + description: abort + operations: + - + object: *session0 + name: startTransaction + - + object: *collection0 + name: insertOne + arguments: + session: *session0 + document: { _id: 1 } + expectResult: + $$unsetOrMatches: { insertedId: { $$unsetOrMatches: 1 } } + - + object: *session0 + name: abortTransaction + - + object: *session0 + name: startTransaction + - + object: *collection0 + name: insertOne + arguments: + session: *session0 + document: { _id: 1 } + expectResult: + $$unsetOrMatches: { insertedId: { $$unsetOrMatches: 1 } } + - + object: *session0 + name: abortTransaction + expectEvents: + - + client: *client0 + events: + - + commandStartedEvent: + command: + insert: *collection_name + documents: + - { _id: 1 } + ordered: true + readConcern: { $$exists: false } + lsid: { $$sessionLsid: *session0 } + txnNumber: { $numberLong: '1' } + startTransaction: true + autocommit: false + writeConcern: { $$exists: false } + commandName: insert + databaseName: *database_name + - + commandStartedEvent: + command: + abortTransaction: 1 + lsid: { $$sessionLsid: *session0 } + txnNumber: { $numberLong: '1' } + startTransaction: { $$exists: false } + autocommit: false + writeConcern: { $$exists: false } + commandName: abortTransaction + databaseName: admin + - + commandStartedEvent: + command: + insert: *collection_name + documents: + - { _id: 1 } + ordered: true + readConcern: + afterClusterTime: { $$exists: true } + lsid: { $$sessionLsid: *session0 } + txnNumber: { $numberLong: '2' } + startTransaction: true + autocommit: false + writeConcern: { $$exists: false } + commandName: insert + databaseName: *database_name + - + commandStartedEvent: + command: + abortTransaction: 1 + lsid: { $$sessionLsid: *session0 } + txnNumber: { $numberLong: '2' } + startTransaction: { $$exists: false } + autocommit: false + writeConcern: { $$exists: false } + commandName: abortTransaction + databaseName: admin + outcome: + - + collectionName: *collection_name + databaseName: *database_name + documents: [] + - + description: 'implicit abort' + operations: + # Start a transaction but don't commit - the driver calls abortTransaction from ClientSession.endSession() + - + object: *session0 + name: startTransaction + - + object: *collection0 + name: insertOne + arguments: + session: *session0 + document: { _id: 1 } + expectResult: + $$unsetOrMatches: { insertedId: { $$unsetOrMatches: 1 } } + # The original legacy test relied on the test runner to call endSession after all operations. Since the unified + # test runner has no such behavior, we manually call endSession as the last operation. + - + object: *session0 + name: endSession + expectEvents: + - + client: *client0 + events: + - + commandStartedEvent: + command: + insert: *collection_name + documents: + - { _id: 1 } + ordered: true + readConcern: { $$exists: false } + lsid: { $$sessionLsid: *session0 } + txnNumber: { $numberLong: '1' } + startTransaction: true + autocommit: false + writeConcern: { $$exists: false } + commandName: insert + databaseName: *database_name + - + commandStartedEvent: + command: + abortTransaction: 1 + lsid: { $$sessionLsid: *session0 } + txnNumber: { $numberLong: '1' } + startTransaction: { $$exists: false } + autocommit: false + writeConcern: { $$exists: false } + commandName: abortTransaction + databaseName: admin + outcome: + - + collectionName: *collection_name + databaseName: *database_name + documents: [] + - + description: 'two aborts' + operations: + - + object: *session0 + name: startTransaction + - + object: *collection0 + name: insertOne + arguments: + session: *session0 + document: { _id: 1 } + expectResult: + $$unsetOrMatches: { insertedId: { $$unsetOrMatches: 1 } } + - + object: *session0 + name: abortTransaction + - + object: *session0 + name: abortTransaction + expectError: + errorContains: 'cannot call abortTransaction twice' + expectEvents: + - + client: *client0 + events: + - + commandStartedEvent: + command: + insert: *collection_name + documents: + - { _id: 1 } + ordered: true + readConcern: { $$exists: false } + lsid: { $$sessionLsid: *session0 } + txnNumber: { $numberLong: '1' } + startTransaction: true + autocommit: false + writeConcern: { $$exists: false } + commandName: insert + databaseName: *database_name + - + commandStartedEvent: + command: + abortTransaction: 1 + lsid: { $$sessionLsid: *session0 } + txnNumber: { $numberLong: '1' } + startTransaction: { $$exists: false } + autocommit: false + writeConcern: { $$exists: false } + commandName: abortTransaction + databaseName: admin + outcome: + - + collectionName: *collection_name + databaseName: *database_name + documents: [] + - + description: 'abort without start' + operations: + - + object: *session0 + name: abortTransaction + expectError: + errorContains: 'no transaction started' + expectEvents: + - + client: *client0 + events: [] + outcome: + - + collectionName: *collection_name + databaseName: *database_name + documents: [] + - + description: 'abort directly after no-op commit' + operations: + - + object: *session0 + name: startTransaction + - + object: *session0 + name: commitTransaction + # Error calling abort after no-op commit + - + object: *session0 + name: abortTransaction + expectError: + errorContains: 'Cannot call abortTransaction after calling commitTransaction' + expectEvents: + - + client: *client0 + events: [] + outcome: + - + collectionName: *collection_name + databaseName: *database_name + documents: [] + - + description: 'abort directly after commit' + operations: + - + object: *session0 + name: startTransaction + - + object: *collection0 + name: insertOne + arguments: + session: *session0 + document: { _id: 1 } + expectResult: + $$unsetOrMatches: { insertedId: { $$unsetOrMatches: 1 } } + - + object: *session0 + name: commitTransaction + - + object: *session0 + name: abortTransaction + expectError: + errorContains: 'Cannot call abortTransaction after calling commitTransaction' + expectEvents: + - + client: *client0 + events: + - + commandStartedEvent: + command: + insert: *collection_name + documents: + - { _id: 1 } + ordered: true + readConcern: { $$exists: false } + lsid: { $$sessionLsid: *session0 } + txnNumber: { $numberLong: '1' } + startTransaction: true + autocommit: false + writeConcern: { $$exists: false } + commandName: insert + databaseName: *database_name + - + commandStartedEvent: + command: + commitTransaction: 1 + lsid: { $$sessionLsid: *session0 } + txnNumber: { $numberLong: '1' } + startTransaction: { $$exists: false } + autocommit: false + writeConcern: { $$exists: false } + commandName: commitTransaction + databaseName: admin + outcome: + - + collectionName: *collection_name + databaseName: *database_name + documents: + - { _id: 1 } + - + description: 'abort ignores TransactionAborted' + operations: + - + object: *session0 + name: startTransaction + - + object: *collection0 + name: insertOne + arguments: + session: *session0 + document: { _id: 1 } + expectResult: + $$unsetOrMatches: { insertedId: { $$unsetOrMatches: 1 } } + # Abort the server transaction with a duplicate key error + - + object: *collection0 + name: insertOne + arguments: + session: *session0 + document: { _id: 1 } + expectError: + errorLabelsOmit: + - TransientTransactionError + - UnknownTransactionCommitResult + # DuplicateKey error code included in the bulk write error message returned by the server + errorContains: E11000 + # Make sure the server aborted the transaction + - + object: *collection0 + name: insertOne + arguments: + session: *session0 + document: { _id: 1 } + expectError: + errorCodeName: NoSuchTransaction + errorLabelsContain: + - TransientTransactionError + errorLabelsOmit: + - UnknownTransactionCommitResult + # abortTransaction must ignore the TransactionAborted and succeed + - + object: *session0 + name: abortTransaction + expectEvents: + - + client: *client0 + events: + - + commandStartedEvent: + command: + insert: *collection_name + documents: + - { _id: 1 } + ordered: true + readConcern: { $$exists: false } + lsid: { $$sessionLsid: *session0 } + txnNumber: { $numberLong: '1' } + startTransaction: true + autocommit: false + writeConcern: { $$exists: false } + commandName: insert + databaseName: *database_name + - + commandStartedEvent: + command: + insert: *collection_name + documents: + - { _id: 1 } + ordered: true + readConcern: { $$exists: false } + lsid: { $$sessionLsid: *session0 } + txnNumber: { $numberLong: '1' } + startTransaction: { $$exists: false } + autocommit: false + writeConcern: { $$exists: false } + commandName: insert + databaseName: *database_name + - + commandStartedEvent: + command: + insert: *collection_name + documents: + - { _id: 1 } + ordered: true + readConcern: { $$exists: false } + lsid: { $$sessionLsid: *session0 } + txnNumber: { $numberLong: '1' } + startTransaction: { $$exists: false } + autocommit: false + writeConcern: { $$exists: false } + commandName: insert + databaseName: *database_name + - + commandStartedEvent: + command: + abortTransaction: 1 + lsid: { $$sessionLsid: *session0 } + txnNumber: { $numberLong: '1' } + startTransaction: { $$exists: false } + autocommit: false + writeConcern: { $$exists: false } + commandName: abortTransaction + databaseName: admin + outcome: + - + collectionName: *collection_name + databaseName: *database_name + documents: [] + - + description: 'abort does not apply writeConcern' + operations: + - + object: *session0 + name: startTransaction + arguments: + writeConcern: + w: 10 + - + object: *collection0 + name: insertOne + arguments: + session: *session0 + document: { _id: 1 } + expectResult: + $$unsetOrMatches: { insertedId: { $$unsetOrMatches: 1 } } + - + object: *session0 + name: abortTransaction + # No write concern error + outcome: + - + collectionName: *collection_name + databaseName: *database_name + documents: [] diff --git a/source/transactions/tests/unified/bulk.json b/source/transactions/tests/unified/bulk.json new file mode 100644 index 0000000000..ece162518f --- /dev/null +++ b/source/transactions/tests/unified/bulk.json @@ -0,0 +1,652 @@ +{ + "description": "bulk", + "schemaVersion": "1.3", + "runOnRequirements": [ + { + "minServerVersion": "4.0", + "topologies": [ + "replicaset" + ] + }, + { + "minServerVersion": "4.1.8", + "topologies": [ + "sharded", + "load-balanced" + ] + } + ], + "createEntities": [ + { + "client": { + "id": "client0", + "useMultipleMongoses": false, + "observeEvents": [ + "commandStartedEvent" + ] + } + }, + { + "database": { + "id": "database0", + "client": "client0", + "databaseName": "transaction-tests" + } + }, + { + "collection": { + "id": "collection0", + "database": "database0", + "collectionName": "test" + } + }, + { + "session": { + "id": "session0", + "client": "client0" + } + } + ], + "initialData": [ + { + "collectionName": "test", + "databaseName": "transaction-tests", + "documents": [] + } + ], + "tests": [ + { + "description": "bulk", + "operations": [ + { + "object": "session0", + "name": "startTransaction" + }, + { + "object": "collection0", + "name": "insertOne", + "arguments": { + "session": "session0", + "document": { + "_id": 1 + } + }, + "expectResult": { + "$$unsetOrMatches": { + "insertedId": { + "$$unsetOrMatches": 1 + } + } + } + }, + { + "object": "collection0", + "name": "deleteOne", + "arguments": { + "session": "session0", + "filter": { + "_id": 1 + } + }, + "expectResult": { + "deletedCount": 1 + } + }, + { + "object": "collection0", + "name": "bulkWrite", + "arguments": { + "session": "session0", + "requests": [ + { + "insertOne": { + "document": { + "_id": 1 + } + } + }, + { + "updateOne": { + "filter": { + "_id": 1 + }, + "update": { + "$set": { + "x": 1 + } + } + } + }, + { + "updateOne": { + "filter": { + "_id": 2 + }, + "update": { + "$set": { + "x": 2 + } + }, + "upsert": true + } + }, + { + "insertOne": { + "document": { + "_id": 3 + } + } + }, + { + "insertOne": { + "document": { + "_id": 4 + } + } + }, + { + "insertOne": { + "document": { + "_id": 5 + } + } + }, + { + "insertOne": { + "document": { + "_id": 6 + } + } + }, + { + "insertOne": { + "document": { + "_id": 7 + } + } + }, + { + "replaceOne": { + "filter": { + "_id": 1 + }, + "replacement": { + "y": 1 + } + } + }, + { + "replaceOne": { + "filter": { + "_id": 2 + }, + "replacement": { + "y": 2 + } + } + }, + { + "deleteOne": { + "filter": { + "_id": 3 + } + } + }, + { + "deleteOne": { + "filter": { + "_id": 4 + } + } + }, + { + "updateMany": { + "filter": { + "_id": { + "$gte": 2 + } + }, + "update": { + "$set": { + "z": 1 + } + } + } + }, + { + "deleteMany": { + "filter": { + "_id": { + "$gte": 6 + } + } + } + } + ] + }, + "expectResult": { + "deletedCount": 4, + "insertedCount": 6, + "insertedIds": { + "$$unsetOrMatches": { + "0": 1, + "3": 3, + "4": 4, + "5": 5, + "6": 6, + "7": 7 + } + }, + "matchedCount": 7, + "modifiedCount": 7, + "upsertedCount": 1, + "upsertedIds": { + "2": 2 + } + } + }, + { + "object": "session0", + "name": "commitTransaction" + } + ], + "expectEvents": [ + { + "client": "client0", + "events": [ + { + "commandStartedEvent": { + "command": { + "insert": "test", + "documents": [ + { + "_id": 1 + } + ], + "ordered": true, + "readConcern": { + "$$exists": false + }, + "lsid": { + "$$sessionLsid": "session0" + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": true, + "autocommit": false, + "writeConcern": { + "$$exists": false + } + }, + "commandName": "insert", + "databaseName": "transaction-tests" + } + }, + { + "commandStartedEvent": { + "command": { + "delete": "test", + "deletes": [ + { + "q": { + "_id": 1 + }, + "limit": 1 + } + ], + "ordered": true, + "lsid": { + "$$sessionLsid": "session0" + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": { + "$$exists": false + }, + "autocommit": false, + "writeConcern": { + "$$exists": false + } + }, + "commandName": "delete", + "databaseName": "transaction-tests" + } + }, + { + "commandStartedEvent": { + "command": { + "insert": "test", + "documents": [ + { + "_id": 1 + } + ], + "ordered": true, + "lsid": { + "$$sessionLsid": "session0" + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": { + "$$exists": false + }, + "autocommit": false, + "writeConcern": { + "$$exists": false + } + }, + "commandName": "insert", + "databaseName": "transaction-tests" + } + }, + { + "commandStartedEvent": { + "command": { + "update": "test", + "updates": [ + { + "q": { + "_id": 1 + }, + "u": { + "$set": { + "x": 1 + } + }, + "multi": { + "$$unsetOrMatches": false + }, + "upsert": { + "$$unsetOrMatches": false + } + }, + { + "q": { + "_id": 2 + }, + "u": { + "$set": { + "x": 2 + } + }, + "upsert": true, + "multi": { + "$$unsetOrMatches": false + } + } + ], + "ordered": true, + "lsid": { + "$$sessionLsid": "session0" + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": { + "$$exists": false + }, + "autocommit": false, + "writeConcern": { + "$$exists": false + } + }, + "commandName": "update", + "databaseName": "transaction-tests" + } + }, + { + "commandStartedEvent": { + "command": { + "insert": "test", + "documents": [ + { + "_id": 3 + }, + { + "_id": 4 + }, + { + "_id": 5 + }, + { + "_id": 6 + }, + { + "_id": 7 + } + ], + "ordered": true, + "lsid": { + "$$sessionLsid": "session0" + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": { + "$$exists": false + }, + "autocommit": false, + "writeConcern": { + "$$exists": false + } + }, + "commandName": "insert", + "databaseName": "transaction-tests" + } + }, + { + "commandStartedEvent": { + "command": { + "update": "test", + "updates": [ + { + "q": { + "_id": 1 + }, + "u": { + "y": 1 + }, + "multi": { + "$$unsetOrMatches": false + }, + "upsert": { + "$$unsetOrMatches": false + } + }, + { + "q": { + "_id": 2 + }, + "u": { + "y": 2 + }, + "multi": { + "$$unsetOrMatches": false + }, + "upsert": { + "$$unsetOrMatches": false + } + } + ], + "ordered": true, + "lsid": { + "$$sessionLsid": "session0" + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": { + "$$exists": false + }, + "autocommit": false, + "writeConcern": { + "$$exists": false + } + }, + "commandName": "update", + "databaseName": "transaction-tests" + } + }, + { + "commandStartedEvent": { + "command": { + "delete": "test", + "deletes": [ + { + "q": { + "_id": 3 + }, + "limit": 1 + }, + { + "q": { + "_id": 4 + }, + "limit": 1 + } + ], + "ordered": true, + "lsid": { + "$$sessionLsid": "session0" + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": { + "$$exists": false + }, + "autocommit": false, + "writeConcern": { + "$$exists": false + } + }, + "commandName": "delete", + "databaseName": "transaction-tests" + } + }, + { + "commandStartedEvent": { + "command": { + "update": "test", + "updates": [ + { + "q": { + "_id": { + "$gte": 2 + } + }, + "u": { + "$set": { + "z": 1 + } + }, + "multi": true, + "upsert": { + "$$unsetOrMatches": false + } + } + ], + "ordered": true, + "lsid": { + "$$sessionLsid": "session0" + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": { + "$$exists": false + }, + "autocommit": false, + "writeConcern": { + "$$exists": false + } + }, + "commandName": "update", + "databaseName": "transaction-tests" + } + }, + { + "commandStartedEvent": { + "command": { + "delete": "test", + "deletes": [ + { + "q": { + "_id": { + "$gte": 6 + } + }, + "limit": 0 + } + ], + "ordered": true, + "lsid": { + "$$sessionLsid": "session0" + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": { + "$$exists": false + }, + "autocommit": false, + "writeConcern": { + "$$exists": false + } + }, + "commandName": "delete", + "databaseName": "transaction-tests" + } + }, + { + "commandStartedEvent": { + "command": { + "commitTransaction": 1, + "lsid": { + "$$sessionLsid": "session0" + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": { + "$$exists": false + }, + "autocommit": false, + "writeConcern": { + "$$exists": false + } + }, + "commandName": "commitTransaction", + "databaseName": "admin" + } + } + ] + } + ], + "outcome": [ + { + "collectionName": "test", + "databaseName": "transaction-tests", + "documents": [ + { + "_id": 1, + "y": 1 + }, + { + "_id": 2, + "y": 2, + "z": 1 + }, + { + "_id": 5, + "z": 1 + } + ] + } + ] + } + ] +} diff --git a/source/transactions/tests/unified/bulk.yml b/source/transactions/tests/unified/bulk.yml new file mode 100644 index 0000000000..5f686498b4 --- /dev/null +++ b/source/transactions/tests/unified/bulk.yml @@ -0,0 +1,329 @@ +description: bulk + +schemaVersion: '1.3' + +runOnRequirements: + - + minServerVersion: '4.0' + topologies: + - replicaset + - + minServerVersion: 4.1.8 + topologies: + - sharded + - load-balanced + +createEntities: + - + client: + id: &client0 client0 + useMultipleMongoses: false + observeEvents: + - commandStartedEvent + - + database: + id: &database0 database0 + client: *client0 + databaseName: &database_name transaction-tests + - + collection: + id: &collection0 collection0 + database: *database0 + collectionName: &collection_name test + - + session: + id: &session0 session0 + client: *client0 + +initialData: + - + collectionName: *collection_name + databaseName: *database_name + documents: [] + +tests: + - + description: bulk + operations: + - + object: *session0 + name: startTransaction + - + object: *collection0 + name: insertOne + arguments: + session: *session0 + document: { _id: 1 } + expectResult: + $$unsetOrMatches: { insertedId: { $$unsetOrMatches: 1 } } + - + object: *collection0 + name: deleteOne + arguments: + session: *session0 + filter: { _id: 1 } + expectResult: + deletedCount: 1 + - + object: *collection0 + name: bulkWrite + arguments: + session: *session0 + requests: + - + insertOne: + document: { _id: 1 } + - + updateOne: + filter: { _id: 1 } + update: { $set: { x: 1 } } + - + updateOne: + filter: { _id: 2 } + update: { $set: { x: 2 } } + # Produces upsertedIds: {2: 2} in the result + upsert: true + - + insertOne: + document: { _id: 3 } + - + insertOne: + document: { _id: 4 } + - + insertOne: + document: { _id: 5 } + - + insertOne: + document: { _id: 6 } + - + insertOne: + document: { _id: 7 } + # Keep replaces segregated from updates, so that drivers that aren't able to coalesce + # adjacent updates and replaces into a single update command will still pass this test + - + replaceOne: + filter: { _id: 1 } + replacement: { y: 1 } + - + replaceOne: + filter: { _id: 2 } + replacement: { y: 2 } + - + deleteOne: + filter: { _id: 3 } + - + deleteOne: + filter: { _id: 4 } + - + updateMany: + filter: { _id: { $gte: 2 } } + update: { $set: { z: 1 } } + # Keep deleteMany segregated from deleteOne, so that drivers that aren't able to coalesce + # adjacent mixed deletes into a single delete command will still pass this test + - + deleteMany: + filter: { _id: { $gte: 6 } } + expectResult: + deletedCount: 4 + insertedCount: 6 + insertedIds: + $$unsetOrMatches: + '0': 1 + '3': 3 + '4': 4 + '5': 5 + '6': 6 + '7': 7 + matchedCount: 7 + modifiedCount: 7 + upsertedCount: 1 + upsertedIds: { '2': 2 } + - + object: *session0 + name: commitTransaction + expectEvents: + - + client: *client0 + events: + - + commandStartedEvent: + command: + insert: *collection_name + documents: + - { _id: 1 } + ordered: true + readConcern: { $$exists: false } + lsid: { $$sessionLsid: *session0 } + txnNumber: { $numberLong: '1' } + startTransaction: true + autocommit: false + writeConcern: { $$exists: false } + commandName: insert + databaseName: *database_name + - + commandStartedEvent: + command: + delete: *collection_name + deletes: + - + q: { _id: 1 } + limit: 1 + ordered: true + lsid: { $$sessionLsid: *session0 } + txnNumber: { $numberLong: '1' } + startTransaction: { $$exists: false } + autocommit: false + writeConcern: { $$exists: false } + commandName: delete + databaseName: *database_name + # Commands in the bulkWrite + - + commandStartedEvent: + command: + insert: *collection_name + documents: + - { _id: 1 } + ordered: true + lsid: { $$sessionLsid: *session0 } + txnNumber: { $numberLong: '1' } + startTransaction: { $$exists: false } + autocommit: false + writeConcern: { $$exists: false } + commandName: insert + databaseName: *database_name + - + commandStartedEvent: + command: + update: *collection_name + updates: + - + q: { _id: 1 } + u: { $set: { x: 1 } } + multi: { $$unsetOrMatches: false } + upsert: { $$unsetOrMatches: false } + - + q: { _id: 2 } + u: { $set: { x: 2 } } + upsert: true + multi: { $$unsetOrMatches: false } + ordered: true + lsid: { $$sessionLsid: *session0 } + txnNumber: { $numberLong: '1' } + startTransaction: { $$exists: false } + autocommit: false + writeConcern: { $$exists: false } + commandName: update + databaseName: *database_name + - + commandStartedEvent: + command: + insert: *collection_name + documents: + - { _id: 3 } + - { _id: 4 } + - { _id: 5 } + - { _id: 6 } + - { _id: 7 } + ordered: true + lsid: { $$sessionLsid: *session0 } + txnNumber: { $numberLong: '1' } + startTransaction: { $$exists: false } + autocommit: false + writeConcern: { $$exists: false } + commandName: insert + databaseName: *database_name + - + commandStartedEvent: + command: + update: *collection_name + updates: + - + q: { _id: 1 } + u: { y: 1 } + multi: { $$unsetOrMatches: false } + upsert: { $$unsetOrMatches: false } + - + q: { _id: 2 } + u: { y: 2 } + multi: { $$unsetOrMatches: false } + upsert: { $$unsetOrMatches: false } + ordered: true + lsid: { $$sessionLsid: *session0 } + txnNumber: { $numberLong: '1' } + startTransaction: { $$exists: false } + autocommit: false + writeConcern: { $$exists: false } + commandName: update + databaseName: *database_name + - + commandStartedEvent: + command: + delete: *collection_name + deletes: + - + q: { _id: 3 } + limit: 1 + - + q: { _id: 4 } + limit: 1 + ordered: true + lsid: { $$sessionLsid: *session0 } + txnNumber: { $numberLong: '1' } + startTransaction: { $$exists: false } + autocommit: false + writeConcern: { $$exists: false } + commandName: delete + databaseName: *database_name + - + commandStartedEvent: + command: + update: *collection_name + updates: + - + q: { _id: { $gte: 2 } } + u: { $set: { z: 1 } } + multi: true + upsert: { $$unsetOrMatches: false } + ordered: true + lsid: { $$sessionLsid: *session0 } + txnNumber: { $numberLong: '1' } + startTransaction: { $$exists: false } + autocommit: false + writeConcern: { $$exists: false } + commandName: update + databaseName: *database_name + - + commandStartedEvent: + command: + delete: *collection_name + deletes: + - + q: { _id: { $gte: 6 } } + limit: 0 + ordered: true + lsid: { $$sessionLsid: *session0 } + txnNumber: { $numberLong: '1' } + startTransaction: { $$exists: false } + autocommit: false + writeConcern: { $$exists: false } + commandName: delete + databaseName: *database_name + - + commandStartedEvent: + command: + commitTransaction: 1 + lsid: { $$sessionLsid: *session0 } + txnNumber: { $numberLong: '1' } + startTransaction: { $$exists: false } + autocommit: false + writeConcern: { $$exists: false } + commandName: commitTransaction + databaseName: admin + outcome: + - + collectionName: *collection_name + databaseName: *database_name + documents: + - { _id: 1, y: 1 } + - { _id: 2, y: 2, z: 1 } + - { _id: 5, z: 1 } diff --git a/source/transactions/tests/unified/causal-consistency.json b/source/transactions/tests/unified/causal-consistency.json new file mode 100644 index 0000000000..52a6cb8180 --- /dev/null +++ b/source/transactions/tests/unified/causal-consistency.json @@ -0,0 +1,426 @@ +{ + "description": "causal-consistency", + "schemaVersion": "1.3", + "runOnRequirements": [ + { + "minServerVersion": "4.0", + "topologies": [ + "replicaset" + ] + }, + { + "minServerVersion": "4.1.8", + "topologies": [ + "sharded", + "load-balanced" + ] + } + ], + "createEntities": [ + { + "client": { + "id": "client0", + "useMultipleMongoses": false, + "uriOptions": { + "retryWrites": false + }, + "observeEvents": [ + "commandStartedEvent" + ] + } + }, + { + "database": { + "id": "database0", + "client": "client0", + "databaseName": "transaction-tests" + } + }, + { + "collection": { + "id": "collection0", + "database": "database0", + "collectionName": "test" + } + }, + { + "session": { + "id": "session0", + "client": "client0" + } + }, + { + "session": { + "id": "session_no_cc", + "client": "client0", + "sessionOptions": { + "causalConsistency": false + } + } + } + ], + "initialData": [ + { + "collectionName": "test", + "databaseName": "transaction-tests", + "documents": [ + { + "_id": 1, + "count": 0 + } + ] + } + ], + "tests": [ + { + "description": "causal consistency", + "operations": [ + { + "object": "collection0", + "name": "updateOne", + "arguments": { + "session": "session0", + "filter": { + "_id": 1 + }, + "update": { + "$inc": { + "count": 1 + } + } + }, + "expectResult": { + "matchedCount": 1, + "modifiedCount": 1, + "upsertedCount": 0 + } + }, + { + "object": "session0", + "name": "startTransaction" + }, + { + "object": "collection0", + "name": "updateOne", + "arguments": { + "session": "session0", + "filter": { + "_id": 1 + }, + "update": { + "$inc": { + "count": 1 + } + } + }, + "expectResult": { + "matchedCount": 1, + "modifiedCount": 1, + "upsertedCount": 0 + } + }, + { + "object": "session0", + "name": "commitTransaction" + } + ], + "expectEvents": [ + { + "client": "client0", + "events": [ + { + "commandStartedEvent": { + "command": { + "update": "test", + "updates": [ + { + "q": { + "_id": 1 + }, + "u": { + "$inc": { + "count": 1 + } + }, + "multi": { + "$$unsetOrMatches": false + }, + "upsert": { + "$$unsetOrMatches": false + } + } + ], + "ordered": true, + "lsid": { + "$$sessionLsid": "session0" + }, + "readConcern": { + "$$exists": false + }, + "txnNumber": { + "$$exists": false + }, + "startTransaction": { + "$$exists": false + }, + "autocommit": { + "$$exists": false + }, + "writeConcern": { + "$$exists": false + } + }, + "commandName": "update", + "databaseName": "transaction-tests" + } + }, + { + "commandStartedEvent": { + "command": { + "update": "test", + "updates": [ + { + "q": { + "_id": 1 + }, + "u": { + "$inc": { + "count": 1 + } + }, + "multi": { + "$$unsetOrMatches": false + }, + "upsert": { + "$$unsetOrMatches": false + } + } + ], + "ordered": true, + "readConcern": { + "afterClusterTime": { + "$$exists": true + } + }, + "lsid": { + "$$sessionLsid": "session0" + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": true, + "autocommit": false, + "writeConcern": { + "$$exists": false + } + }, + "commandName": "update", + "databaseName": "transaction-tests" + } + }, + { + "commandStartedEvent": { + "command": { + "commitTransaction": 1, + "lsid": { + "$$sessionLsid": "session0" + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": { + "$$exists": false + }, + "autocommit": false, + "writeConcern": { + "$$exists": false + } + }, + "commandName": "commitTransaction", + "databaseName": "admin" + } + } + ] + } + ], + "outcome": [ + { + "collectionName": "test", + "databaseName": "transaction-tests", + "documents": [ + { + "_id": 1, + "count": 2 + } + ] + } + ] + }, + { + "description": "causal consistency disabled", + "operations": [ + { + "object": "collection0", + "name": "insertOne", + "arguments": { + "session": "session_no_cc", + "document": { + "_id": 2 + } + }, + "expectResult": { + "$$unsetOrMatches": { + "insertedId": { + "$$unsetOrMatches": 2 + } + } + } + }, + { + "object": "session_no_cc", + "name": "startTransaction" + }, + { + "object": "collection0", + "name": "updateOne", + "arguments": { + "session": "session_no_cc", + "filter": { + "_id": 1 + }, + "update": { + "$inc": { + "count": 1 + } + } + }, + "expectResult": { + "matchedCount": 1, + "modifiedCount": 1, + "upsertedCount": 0 + } + }, + { + "object": "session_no_cc", + "name": "commitTransaction" + } + ], + "expectEvents": [ + { + "client": "client0", + "events": [ + { + "commandStartedEvent": { + "command": { + "insert": "test", + "documents": [ + { + "_id": 2 + } + ], + "ordered": true, + "readConcern": { + "$$exists": false + }, + "lsid": { + "$$sessionLsid": "session_no_cc" + }, + "txnNumber": { + "$$exists": false + }, + "autocommit": { + "$$exists": false + }, + "writeConcern": { + "$$exists": false + } + }, + "commandName": "insert", + "databaseName": "transaction-tests" + } + }, + { + "commandStartedEvent": { + "command": { + "update": "test", + "updates": [ + { + "q": { + "_id": 1 + }, + "u": { + "$inc": { + "count": 1 + } + }, + "multi": { + "$$unsetOrMatches": false + }, + "upsert": { + "$$unsetOrMatches": false + } + } + ], + "ordered": true, + "readConcern": { + "$$exists": false + }, + "lsid": { + "$$sessionLsid": "session_no_cc" + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": true, + "autocommit": false, + "writeConcern": { + "$$exists": false + } + }, + "commandName": "update", + "databaseName": "transaction-tests" + } + }, + { + "commandStartedEvent": { + "command": { + "commitTransaction": 1, + "lsid": { + "$$sessionLsid": "session_no_cc" + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": { + "$$exists": false + }, + "autocommit": false, + "writeConcern": { + "$$exists": false + } + }, + "commandName": "commitTransaction", + "databaseName": "admin" + } + } + ] + } + ], + "outcome": [ + { + "collectionName": "test", + "databaseName": "transaction-tests", + "documents": [ + { + "_id": 1, + "count": 1 + }, + { + "_id": 2 + } + ] + } + ] + } + ] +} diff --git a/source/transactions/tests/unified/causal-consistency.yml b/source/transactions/tests/unified/causal-consistency.yml new file mode 100644 index 0000000000..c3e75523de --- /dev/null +++ b/source/transactions/tests/unified/causal-consistency.yml @@ -0,0 +1,222 @@ +description: causal-consistency + +schemaVersion: '1.3' + +runOnRequirements: + - + minServerVersion: '4.0' + topologies: + - replicaset + - + minServerVersion: 4.1.8 + topologies: + - sharded + - load-balanced + +createEntities: + - + client: + id: &client0 client0 + useMultipleMongoses: false + uriOptions: + retryWrites: false + observeEvents: + - commandStartedEvent + - + database: + id: &database0 database0 + client: *client0 + databaseName: &database_name transaction-tests + - + collection: + id: &collection0 collection0 + database: *database0 + collectionName: &collection_name test + - + session: + id: &session0 session0 + client: *client0 + - + session: + id: &session_no_cc session_no_cc + client: *client0 + sessionOptions: + causalConsistency: false + +initialData: + - + collectionName: *collection_name + databaseName: *database_name + documents: + - { _id: 1, count: 0 } + +tests: + - + description: 'causal consistency' + operations: + # Update a document without a transaction + - &updateOne + object: *collection0 + name: updateOne + arguments: + session: *session0 + filter: { _id: 1 } + update: { $inc: { count: 1 } } + expectResult: + matchedCount: 1 + modifiedCount: 1 + upsertedCount: 0 + # Updating the same document inside a transaction. + # Casual consistency ensures that the transaction snapshot is causally after the first updateOne. + - + object: *session0 + name: startTransaction + - *updateOne + - + object: *session0 + name: commitTransaction + expectEvents: + - + client: *client0 + events: + - + commandStartedEvent: + command: + update: *collection_name + updates: + - + q: { _id: 1 } + u: { $inc: { count: 1 } } + multi: { $$unsetOrMatches: false } + upsert: { $$unsetOrMatches: false } + ordered: true + lsid: { $$sessionLsid: *session0 } + readConcern: { $$exists: false } + txnNumber: { $$exists: false } + startTransaction: { $$exists: false } + autocommit: { $$exists: false } + writeConcern: { $$exists: false } + commandName: update + databaseName: *database_name + - + commandStartedEvent: + command: + update: *collection_name + updates: + - + q: { _id: 1 } + u: { $inc: { count: 1 } } + multi: { $$unsetOrMatches: false } + upsert: { $$unsetOrMatches: false } + ordered: true + readConcern: + afterClusterTime: { $$exists: true } + lsid: { $$sessionLsid: *session0 } + txnNumber: { $numberLong: '1' } + startTransaction: true + autocommit: false + writeConcern: { $$exists: false } + commandName: update + databaseName: *database_name + - + commandStartedEvent: + command: + commitTransaction: 1 + lsid: { $$sessionLsid: *session0 } + txnNumber: { $numberLong: '1' } + startTransaction: { $$exists: false } + autocommit: false + writeConcern: { $$exists: false } + commandName: commitTransaction + databaseName: admin + outcome: + - + collectionName: *collection_name + databaseName: *database_name + documents: + - { _id: 1, count: 2 } + - + description: 'causal consistency disabled' + operations: + # Insert a document without a transaction + - + object: *collection0 + name: insertOne + arguments: + session: *session_no_cc + document: { _id: 2 } + expectResult: + $$unsetOrMatches: { insertedId: { $$unsetOrMatches: 2 } } + - + object: *session_no_cc + name: startTransaction + - + object: *collection0 + name: updateOne + arguments: + session: *session_no_cc + filter: { _id: 1 } + update: { $inc: { count: 1 } } + expectResult: + matchedCount: 1 + modifiedCount: 1 + upsertedCount: 0 + - + object: *session_no_cc + name: commitTransaction + expectEvents: + - + client: *client0 + events: + - + commandStartedEvent: + command: + insert: *collection_name + documents: + - { _id: 2 } + ordered: true + readConcern: { $$exists: false } + lsid: { $$sessionLsid: *session_no_cc } + txnNumber: { $$exists: false } + autocommit: { $$exists: false } + writeConcern: { $$exists: false } + commandName: insert + databaseName: *database_name + - + commandStartedEvent: + command: + update: *collection_name + updates: + - + q: { _id: 1 } + u: { $inc: { count: 1 } } + multi: { $$unsetOrMatches: false } + upsert: { $$unsetOrMatches: false } + ordered: true + # No afterClusterTime + readConcern: { $$exists: false } + lsid: { $$sessionLsid: *session_no_cc } + txnNumber: { $numberLong: '1' } + startTransaction: true + autocommit: false + writeConcern: { $$exists: false } + commandName: update + databaseName: *database_name + - + commandStartedEvent: + command: + commitTransaction: 1 + lsid: { $$sessionLsid: *session_no_cc } + txnNumber: { $numberLong: '1' } + startTransaction: { $$exists: false } + autocommit: false + writeConcern: { $$exists: false } + commandName: commitTransaction + databaseName: admin + outcome: + - + collectionName: *collection_name + databaseName: *database_name + documents: + - { _id: 1, count: 1 } + - { _id: 2 } diff --git a/source/transactions/tests/unified/commit.json b/source/transactions/tests/unified/commit.json new file mode 100644 index 0000000000..ab778d8df2 --- /dev/null +++ b/source/transactions/tests/unified/commit.json @@ -0,0 +1,1234 @@ +{ + "description": "commit", + "schemaVersion": "1.3", + "runOnRequirements": [ + { + "minServerVersion": "4.0", + "topologies": [ + "replicaset" + ] + }, + { + "minServerVersion": "4.1.8", + "topologies": [ + "sharded", + "load-balanced" + ] + } + ], + "createEntities": [ + { + "client": { + "id": "client0", + "useMultipleMongoses": false, + "observeEvents": [ + "commandStartedEvent" + ] + } + }, + { + "database": { + "id": "database0", + "client": "client0", + "databaseName": "transaction-tests" + } + }, + { + "collection": { + "id": "collection0", + "database": "database0", + "collectionName": "test" + } + }, + { + "session": { + "id": "session0", + "client": "client0" + } + }, + { + "client": { + "id": "client1", + "useMultipleMongoses": false, + "uriOptions": { + "retryWrites": false + }, + "observeEvents": [ + "commandStartedEvent" + ] + } + }, + { + "database": { + "id": "database1", + "client": "client1", + "databaseName": "transaction-tests" + } + }, + { + "collection": { + "id": "collection1", + "database": "database1", + "collectionName": "test" + } + }, + { + "session": { + "id": "session1", + "client": "client1" + } + } + ], + "initialData": [ + { + "collectionName": "test", + "databaseName": "transaction-tests", + "documents": [] + } + ], + "tests": [ + { + "description": "commit", + "operations": [ + { + "object": "session0", + "name": "startTransaction" + }, + { + "object": "collection0", + "name": "insertOne", + "arguments": { + "session": "session0", + "document": { + "_id": 1 + } + }, + "expectResult": { + "$$unsetOrMatches": { + "insertedId": { + "$$unsetOrMatches": 1 + } + } + } + }, + { + "object": "session0", + "name": "commitTransaction" + }, + { + "object": "session0", + "name": "startTransaction" + }, + { + "object": "collection0", + "name": "insertOne", + "arguments": { + "session": "session0", + "document": { + "_id": 2 + } + }, + "expectResult": { + "$$unsetOrMatches": { + "insertedId": { + "$$unsetOrMatches": 2 + } + } + } + }, + { + "object": "session0", + "name": "commitTransaction" + } + ], + "expectEvents": [ + { + "client": "client0", + "events": [ + { + "commandStartedEvent": { + "command": { + "insert": "test", + "documents": [ + { + "_id": 1 + } + ], + "ordered": true, + "readConcern": { + "$$exists": false + }, + "lsid": { + "$$sessionLsid": "session0" + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": true, + "autocommit": false, + "writeConcern": { + "$$exists": false + } + }, + "commandName": "insert", + "databaseName": "transaction-tests" + } + }, + { + "commandStartedEvent": { + "command": { + "commitTransaction": 1, + "lsid": { + "$$sessionLsid": "session0" + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": { + "$$exists": false + }, + "autocommit": false, + "writeConcern": { + "$$exists": false + } + }, + "commandName": "commitTransaction", + "databaseName": "admin" + } + }, + { + "commandStartedEvent": { + "command": { + "insert": "test", + "documents": [ + { + "_id": 2 + } + ], + "ordered": true, + "readConcern": { + "afterClusterTime": { + "$$exists": true + } + }, + "lsid": { + "$$sessionLsid": "session0" + }, + "txnNumber": { + "$numberLong": "2" + }, + "startTransaction": true, + "autocommit": false, + "writeConcern": { + "$$exists": false + } + }, + "commandName": "insert", + "databaseName": "transaction-tests" + } + }, + { + "commandStartedEvent": { + "command": { + "commitTransaction": 1, + "lsid": { + "$$sessionLsid": "session0" + }, + "txnNumber": { + "$numberLong": "2" + }, + "startTransaction": { + "$$exists": false + }, + "autocommit": false, + "writeConcern": { + "$$exists": false + } + }, + "commandName": "commitTransaction", + "databaseName": "admin" + } + } + ] + } + ], + "outcome": [ + { + "collectionName": "test", + "databaseName": "transaction-tests", + "documents": [ + { + "_id": 1 + }, + { + "_id": 2 + } + ] + } + ] + }, + { + "description": "rerun commit after empty transaction", + "operations": [ + { + "object": "session0", + "name": "startTransaction" + }, + { + "object": "session0", + "name": "commitTransaction" + }, + { + "object": "session0", + "name": "commitTransaction" + }, + { + "object": "session0", + "name": "startTransaction" + }, + { + "object": "collection0", + "name": "insertOne", + "arguments": { + "session": "session0", + "document": { + "_id": 1 + } + }, + "expectResult": { + "$$unsetOrMatches": { + "insertedId": { + "$$unsetOrMatches": 1 + } + } + } + }, + { + "object": "session0", + "name": "commitTransaction" + } + ], + "expectEvents": [ + { + "client": "client0", + "events": [ + { + "commandStartedEvent": { + "command": { + "insert": "test", + "documents": [ + { + "_id": 1 + } + ], + "ordered": true, + "readConcern": { + "$$exists": false + }, + "lsid": { + "$$sessionLsid": "session0" + }, + "txnNumber": { + "$numberLong": "2" + }, + "startTransaction": true, + "autocommit": false, + "writeConcern": { + "$$exists": false + } + }, + "commandName": "insert", + "databaseName": "transaction-tests" + } + }, + { + "commandStartedEvent": { + "command": { + "commitTransaction": 1, + "lsid": { + "$$sessionLsid": "session0" + }, + "txnNumber": { + "$numberLong": "2" + }, + "startTransaction": { + "$$exists": false + }, + "autocommit": false, + "writeConcern": { + "$$exists": false + } + }, + "commandName": "commitTransaction", + "databaseName": "admin" + } + } + ] + } + ], + "outcome": [ + { + "collectionName": "test", + "databaseName": "transaction-tests", + "documents": [ + { + "_id": 1 + } + ] + } + ] + }, + { + "description": "multiple commits in a row", + "operations": [ + { + "object": "session0", + "name": "startTransaction" + }, + { + "object": "collection0", + "name": "insertOne", + "arguments": { + "session": "session0", + "document": { + "_id": 1 + } + }, + "expectResult": { + "$$unsetOrMatches": { + "insertedId": { + "$$unsetOrMatches": 1 + } + } + } + }, + { + "object": "session0", + "name": "commitTransaction" + }, + { + "object": "session0", + "name": "commitTransaction" + }, + { + "object": "session0", + "name": "commitTransaction" + } + ], + "expectEvents": [ + { + "client": "client0", + "events": [ + { + "commandStartedEvent": { + "command": { + "insert": "test", + "documents": [ + { + "_id": 1 + } + ], + "ordered": true, + "readConcern": { + "$$exists": false + }, + "lsid": { + "$$sessionLsid": "session0" + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": true, + "autocommit": false, + "writeConcern": { + "$$exists": false + } + }, + "commandName": "insert", + "databaseName": "transaction-tests" + } + }, + { + "commandStartedEvent": { + "command": { + "commitTransaction": 1, + "lsid": { + "$$sessionLsid": "session0" + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": { + "$$exists": false + }, + "autocommit": false, + "writeConcern": { + "$$exists": false + } + }, + "commandName": "commitTransaction", + "databaseName": "admin" + } + }, + { + "commandStartedEvent": { + "command": { + "commitTransaction": 1, + "lsid": { + "$$sessionLsid": "session0" + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": { + "$$exists": false + }, + "autocommit": false, + "writeConcern": { + "w": "majority", + "wtimeout": 10000 + } + }, + "commandName": "commitTransaction", + "databaseName": "admin" + } + }, + { + "commandStartedEvent": { + "command": { + "commitTransaction": 1, + "lsid": { + "$$sessionLsid": "session0" + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": { + "$$exists": false + }, + "autocommit": false, + "writeConcern": { + "w": "majority", + "wtimeout": 10000 + } + }, + "commandName": "commitTransaction", + "databaseName": "admin" + } + } + ] + } + ], + "outcome": [ + { + "collectionName": "test", + "databaseName": "transaction-tests", + "documents": [ + { + "_id": 1 + } + ] + } + ] + }, + { + "description": "write concern error on commit", + "operations": [ + { + "object": "session0", + "name": "startTransaction", + "arguments": { + "writeConcern": { + "w": 10 + } + } + }, + { + "object": "collection0", + "name": "insertOne", + "arguments": { + "session": "session0", + "document": { + "_id": 1 + } + }, + "expectResult": { + "$$unsetOrMatches": { + "insertedId": { + "$$unsetOrMatches": 1 + } + } + } + }, + { + "object": "session0", + "name": "commitTransaction", + "expectError": { + "errorLabelsOmit": [ + "TransientTransactionError", + "UnknownTransactionCommitResult" + ] + } + } + ], + "outcome": [ + { + "collectionName": "test", + "databaseName": "transaction-tests", + "documents": [ + { + "_id": 1 + } + ] + } + ] + }, + { + "description": "commit without start", + "operations": [ + { + "object": "session0", + "name": "commitTransaction", + "expectError": { + "errorContains": "no transaction started" + } + } + ], + "expectEvents": [ + { + "client": "client0", + "events": [] + } + ], + "outcome": [ + { + "collectionName": "test", + "databaseName": "transaction-tests", + "documents": [] + } + ] + }, + { + "description": "commit after no-op abort", + "operations": [ + { + "object": "session0", + "name": "startTransaction" + }, + { + "object": "session0", + "name": "abortTransaction" + }, + { + "object": "session0", + "name": "commitTransaction", + "expectError": { + "errorContains": "Cannot call commitTransaction after calling abortTransaction" + } + } + ], + "expectEvents": [ + { + "client": "client0", + "events": [] + } + ], + "outcome": [ + { + "collectionName": "test", + "databaseName": "transaction-tests", + "documents": [] + } + ] + }, + { + "description": "commit after abort", + "operations": [ + { + "object": "session0", + "name": "startTransaction" + }, + { + "object": "collection0", + "name": "insertOne", + "arguments": { + "session": "session0", + "document": { + "_id": 1 + } + }, + "expectResult": { + "$$unsetOrMatches": { + "insertedId": { + "$$unsetOrMatches": 1 + } + } + } + }, + { + "object": "session0", + "name": "abortTransaction" + }, + { + "object": "session0", + "name": "commitTransaction", + "expectError": { + "errorContains": "Cannot call commitTransaction after calling abortTransaction" + } + } + ], + "expectEvents": [ + { + "client": "client0", + "events": [ + { + "commandStartedEvent": { + "command": { + "insert": "test", + "documents": [ + { + "_id": 1 + } + ], + "ordered": true, + "readConcern": { + "$$exists": false + }, + "lsid": { + "$$sessionLsid": "session0" + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": true, + "autocommit": false, + "writeConcern": { + "$$exists": false + } + }, + "commandName": "insert", + "databaseName": "transaction-tests" + } + }, + { + "commandStartedEvent": { + "command": { + "abortTransaction": 1, + "lsid": { + "$$sessionLsid": "session0" + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": { + "$$exists": false + }, + "autocommit": false, + "writeConcern": { + "$$exists": false + } + }, + "commandName": "abortTransaction", + "databaseName": "admin" + } + } + ] + } + ] + }, + { + "description": "multiple commits after empty transaction", + "operations": [ + { + "object": "session0", + "name": "startTransaction" + }, + { + "object": "collection0", + "name": "insertOne", + "arguments": { + "session": "session0", + "document": { + "_id": 1 + } + }, + "expectResult": { + "$$unsetOrMatches": { + "insertedId": { + "$$unsetOrMatches": 1 + } + } + } + }, + { + "object": "session0", + "name": "abortTransaction" + }, + { + "object": "session0", + "name": "startTransaction" + }, + { + "object": "session0", + "name": "commitTransaction" + }, + { + "object": "session0", + "name": "commitTransaction" + }, + { + "object": "session0", + "name": "startTransaction" + }, + { + "object": "collection0", + "name": "insertOne", + "arguments": { + "session": "session0", + "document": { + "_id": 1 + } + }, + "expectResult": { + "$$unsetOrMatches": { + "insertedId": { + "$$unsetOrMatches": 1 + } + } + } + }, + { + "object": "session0", + "name": "abortTransaction" + } + ], + "expectEvents": [ + { + "client": "client0", + "events": [ + { + "commandStartedEvent": { + "command": { + "insert": "test", + "documents": [ + { + "_id": 1 + } + ], + "ordered": true, + "readConcern": { + "$$exists": false + }, + "lsid": { + "$$sessionLsid": "session0" + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": true, + "autocommit": false, + "writeConcern": { + "$$exists": false + } + }, + "commandName": "insert", + "databaseName": "transaction-tests" + } + }, + { + "commandStartedEvent": { + "command": { + "abortTransaction": 1, + "lsid": { + "$$sessionLsid": "session0" + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": { + "$$exists": false + }, + "autocommit": false, + "writeConcern": { + "$$exists": false + } + }, + "commandName": "abortTransaction", + "databaseName": "admin" + } + }, + { + "commandStartedEvent": { + "command": { + "insert": "test", + "documents": [ + { + "_id": 1 + } + ], + "ordered": true, + "readConcern": { + "afterClusterTime": { + "$$exists": true + } + }, + "lsid": { + "$$sessionLsid": "session0" + }, + "txnNumber": { + "$numberLong": "3" + }, + "startTransaction": true, + "autocommit": false, + "writeConcern": { + "$$exists": false + } + }, + "commandName": "insert", + "databaseName": "transaction-tests" + } + }, + { + "commandStartedEvent": { + "command": { + "abortTransaction": 1, + "lsid": { + "$$sessionLsid": "session0" + }, + "txnNumber": { + "$numberLong": "3" + }, + "startTransaction": { + "$$exists": false + }, + "autocommit": false, + "writeConcern": { + "$$exists": false + } + }, + "commandName": "abortTransaction", + "databaseName": "admin" + } + } + ] + } + ], + "outcome": [ + { + "collectionName": "test", + "databaseName": "transaction-tests", + "documents": [] + } + ] + }, + { + "description": "reset session state commit", + "operations": [ + { + "object": "session1", + "name": "startTransaction" + }, + { + "object": "collection1", + "name": "insertOne", + "arguments": { + "session": "session1", + "document": { + "_id": 1 + } + }, + "expectResult": { + "$$unsetOrMatches": { + "insertedId": { + "$$unsetOrMatches": 1 + } + } + } + }, + { + "object": "session1", + "name": "commitTransaction" + }, + { + "object": "collection1", + "name": "insertOne", + "arguments": { + "session": "session1", + "document": { + "_id": 2 + } + }, + "expectResult": { + "$$unsetOrMatches": { + "insertedId": { + "$$unsetOrMatches": 2 + } + } + } + }, + { + "object": "session1", + "name": "commitTransaction", + "expectError": { + "errorContains": "no transaction started" + } + } + ], + "expectEvents": [ + { + "client": "client1", + "events": [ + { + "commandStartedEvent": { + "command": { + "insert": "test", + "documents": [ + { + "_id": 1 + } + ], + "ordered": true, + "readConcern": { + "$$exists": false + }, + "lsid": { + "$$sessionLsid": "session1" + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": true, + "autocommit": false, + "writeConcern": { + "$$exists": false + } + }, + "commandName": "insert", + "databaseName": "transaction-tests" + } + }, + { + "commandStartedEvent": { + "command": { + "commitTransaction": 1, + "lsid": { + "$$sessionLsid": "session1" + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": { + "$$exists": false + }, + "autocommit": false, + "writeConcern": { + "$$exists": false + } + }, + "commandName": "commitTransaction", + "databaseName": "admin" + } + }, + { + "commandStartedEvent": { + "command": { + "insert": "test", + "documents": [ + { + "_id": 2 + } + ], + "ordered": true, + "readConcern": { + "$$exists": false + }, + "lsid": { + "$$sessionLsid": "session1" + }, + "txnNumber": { + "$$exists": false + }, + "startTransaction": { + "$$exists": false + }, + "autocommit": { + "$$exists": false + } + }, + "commandName": "insert", + "databaseName": "transaction-tests" + } + } + ] + } + ], + "outcome": [ + { + "collectionName": "test", + "databaseName": "transaction-tests", + "documents": [ + { + "_id": 1 + }, + { + "_id": 2 + } + ] + } + ] + }, + { + "description": "reset session state abort", + "operations": [ + { + "object": "session1", + "name": "startTransaction" + }, + { + "object": "collection1", + "name": "insertOne", + "arguments": { + "session": "session1", + "document": { + "_id": 1 + } + }, + "expectResult": { + "$$unsetOrMatches": { + "insertedId": { + "$$unsetOrMatches": 1 + } + } + } + }, + { + "object": "session1", + "name": "abortTransaction" + }, + { + "object": "collection1", + "name": "insertOne", + "arguments": { + "session": "session1", + "document": { + "_id": 2 + } + }, + "expectResult": { + "$$unsetOrMatches": { + "insertedId": { + "$$unsetOrMatches": 2 + } + } + } + }, + { + "object": "session1", + "name": "abortTransaction", + "expectError": { + "errorContains": "no transaction started" + } + } + ], + "expectEvents": [ + { + "client": "client1", + "events": [ + { + "commandStartedEvent": { + "command": { + "insert": "test", + "documents": [ + { + "_id": 1 + } + ], + "ordered": true, + "readConcern": { + "$$exists": false + }, + "lsid": { + "$$sessionLsid": "session1" + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": true, + "autocommit": false, + "writeConcern": { + "$$exists": false + } + }, + "commandName": "insert", + "databaseName": "transaction-tests" + } + }, + { + "commandStartedEvent": { + "command": { + "abortTransaction": 1, + "lsid": { + "$$sessionLsid": "session1" + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": { + "$$exists": false + }, + "autocommit": false, + "writeConcern": { + "$$exists": false + } + }, + "commandName": "abortTransaction", + "databaseName": "admin" + } + }, + { + "commandStartedEvent": { + "command": { + "insert": "test", + "documents": [ + { + "_id": 2 + } + ], + "ordered": true, + "readConcern": { + "$$exists": false + }, + "lsid": { + "$$sessionLsid": "session1" + }, + "txnNumber": { + "$$exists": false + }, + "startTransaction": { + "$$exists": false + }, + "autocommit": { + "$$exists": false + } + }, + "commandName": "insert", + "databaseName": "transaction-tests" + } + } + ] + } + ], + "outcome": [ + { + "collectionName": "test", + "databaseName": "transaction-tests", + "documents": [ + { + "_id": 2 + } + ] + } + ] + } + ] +} diff --git a/source/transactions/tests/unified/commit.yml b/source/transactions/tests/unified/commit.yml new file mode 100644 index 0000000000..d9af084894 --- /dev/null +++ b/source/transactions/tests/unified/commit.yml @@ -0,0 +1,713 @@ +description: commit + +schemaVersion: '1.3' + +runOnRequirements: + - + minServerVersion: '4.0' + topologies: + - replicaset + - + minServerVersion: 4.1.8 + topologies: + - sharded + - load-balanced + +createEntities: + - + client: + id: &client0 client0 + useMultipleMongoses: false + observeEvents: + - commandStartedEvent + - + database: + id: &database0 database0 + client: *client0 + databaseName: &database_name transaction-tests + - + collection: + id: &collection0 collection0 + database: *database0 + collectionName: &collection_name test + - + session: + id: &session0 session0 + client: *client0 + # Define a second set of entities for a retryWrites=false client + - + client: + id: &client1 client1 + useMultipleMongoses: false + uriOptions: + retryWrites: false + observeEvents: + - commandStartedEvent + - + database: + id: &database1 database1 + client: *client1 + databaseName: *database_name + - + collection: + id: &collection1 collection1 + database: *database1 + collectionName: *collection_name + - + session: + id: &session1 session1 + client: *client1 + +initialData: + - + collectionName: *collection_name + databaseName: *database_name + documents: [] + +tests: + - + description: commit + operations: + - + object: *session0 + name: startTransaction + - + object: *collection0 + name: insertOne + arguments: + session: *session0 + document: { _id: 1 } + expectResult: + $$unsetOrMatches: { insertedId: { $$unsetOrMatches: 1 } } + - + object: *session0 + name: commitTransaction + # Again, to verify that txnNumber is incremented + - + object: *session0 + name: startTransaction + - + object: *collection0 + name: insertOne + arguments: + session: *session0 + document: { _id: 2 } + expectResult: + $$unsetOrMatches: { insertedId: { $$unsetOrMatches: 2 } } + - + object: *session0 + name: commitTransaction + expectEvents: + - + client: *client0 + events: + - + commandStartedEvent: + command: + insert: *collection_name + documents: + - { _id: 1 } + ordered: true + readConcern: { $$exists: false } + lsid: { $$sessionLsid: *session0 } + txnNumber: { $numberLong: '1' } + startTransaction: true + autocommit: false + writeConcern: { $$exists: false } + commandName: insert + databaseName: *database_name + - + commandStartedEvent: + command: + commitTransaction: 1 + lsid: { $$sessionLsid: *session0 } + txnNumber: { $numberLong: '1' } + startTransaction: { $$exists: false } + autocommit: false + writeConcern: { $$exists: false } + commandName: commitTransaction + databaseName: admin + - + commandStartedEvent: + command: + insert: *collection_name + documents: + - { _id: 2 } + ordered: true + readConcern: + afterClusterTime: { $$exists: true } + lsid: { $$sessionLsid: *session0 } + txnNumber: { $numberLong: '2' } + startTransaction: true + autocommit: false + writeConcern: { $$exists: false } + commandName: insert + databaseName: *database_name + - + commandStartedEvent: + command: + commitTransaction: 1 + lsid: { $$sessionLsid: *session0 } + txnNumber: { $numberLong: '2' } + startTransaction: { $$exists: false } + autocommit: false + writeConcern: { $$exists: false } + commandName: commitTransaction + databaseName: admin + outcome: + - + collectionName: *collection_name + databaseName: *database_name + documents: + - { _id: 1 } + - { _id: 2 } + - + description: 'rerun commit after empty transaction' + operations: + - + object: *session0 + name: startTransaction + - + object: *session0 + name: commitTransaction + # Rerun the commit (which does not increment the txnNumber) + - + object: *session0 + name: commitTransaction + - + object: *session0 + name: startTransaction + - + object: *collection0 + name: insertOne + arguments: + session: *session0 + document: { _id: 1 } + expectResult: + $$unsetOrMatches: { insertedId: { $$unsetOrMatches: 1 } } + - + object: *session0 + name: commitTransaction + expectEvents: + - + client: *client0 + events: + - + commandStartedEvent: + command: + insert: *collection_name + documents: + - { _id: 1 } + ordered: true + readConcern: { $$exists: false } + lsid: { $$sessionLsid: *session0 } + txnNumber: { $numberLong: '2' } + startTransaction: true + autocommit: false + writeConcern: { $$exists: false } + commandName: insert + databaseName: *database_name + - + commandStartedEvent: + command: + commitTransaction: 1 + lsid: { $$sessionLsid: *session0 } + txnNumber: { $numberLong: '2' } + startTransaction: { $$exists: false } + autocommit: false + writeConcern: { $$exists: false } + commandName: commitTransaction + databaseName: admin + outcome: + - + collectionName: *collection_name + databaseName: *database_name + documents: + - { _id: 1 } + - + description: 'multiple commits in a row' + operations: + - + object: *session0 + name: startTransaction + - + object: *collection0 + name: insertOne + arguments: + session: *session0 + document: { _id: 1 } + expectResult: + $$unsetOrMatches: { insertedId: { $$unsetOrMatches: 1 } } + - + object: *session0 + name: commitTransaction + - + object: *session0 + name: commitTransaction + - + object: *session0 + name: commitTransaction + expectEvents: + - + client: *client0 + events: + - + commandStartedEvent: + command: + insert: *collection_name + documents: + - { _id: 1 } + ordered: true + readConcern: { $$exists: false } + lsid: { $$sessionLsid: *session0 } + txnNumber: { $numberLong: '1' } + startTransaction: true + autocommit: false + writeConcern: { $$exists: false } + commandName: insert + databaseName: *database_name + - + commandStartedEvent: + command: + commitTransaction: 1 + lsid: { $$sessionLsid: *session0 } + txnNumber: { $numberLong: '1' } + startTransaction: { $$exists: false } + autocommit: false + writeConcern: { $$exists: false } + commandName: commitTransaction + databaseName: admin + - + commandStartedEvent: + command: + commitTransaction: 1 + lsid: { $$sessionLsid: *session0 } + txnNumber: { $numberLong: '1' } + startTransaction: { $$exists: false } + autocommit: false + # commitTransaction applies w:majority on retries + writeConcern: + w: majority + wtimeout: 10000 + commandName: commitTransaction + databaseName: admin + - + commandStartedEvent: + command: + commitTransaction: 1 + lsid: { $$sessionLsid: *session0 } + txnNumber: { $numberLong: '1' } + startTransaction: { $$exists: false } + autocommit: false + writeConcern: + w: majority + wtimeout: 10000 + commandName: commitTransaction + databaseName: admin + outcome: + - + collectionName: *collection_name + databaseName: *database_name + documents: + - { _id: 1 } + - + description: 'write concern error on commit' + operations: + - + object: *session0 + name: startTransaction + arguments: + writeConcern: + w: 10 + - + object: *collection0 + name: insertOne + arguments: + session: *session0 + document: { _id: 1 } + expectResult: + $$unsetOrMatches: { insertedId: { $$unsetOrMatches: 1 } } + - + object: *session0 + name: commitTransaction + expectError: + # { + # 'ok': 1.0, + # 'writeConcernError': { + # 'code': 100, + # 'codeName': 'UnsatisfiableWriteConcern', + # 'errmsg': 'Not enough data-bearing nodes' + # } + # } + errorLabelsOmit: + - TransientTransactionError + - UnknownTransactionCommitResult + outcome: + - + collectionName: *collection_name + databaseName: *database_name + documents: + - { _id: 1 } + - + description: 'commit without start' + operations: + - + object: *session0 + name: commitTransaction + expectError: + errorContains: 'no transaction started' + expectEvents: + - + client: *client0 + events: [] + outcome: + - + collectionName: *collection_name + databaseName: *database_name + documents: [] + - + description: 'commit after no-op abort' + operations: + - + object: *session0 + name: startTransaction + - + object: *session0 + name: abortTransaction + - + object: *session0 + name: commitTransaction + expectError: + errorContains: 'Cannot call commitTransaction after calling abortTransaction' + expectEvents: + - + client: *client0 + events: [] + outcome: + - + collectionName: *collection_name + databaseName: *database_name + documents: [] + - + description: 'commit after abort' + operations: + - + object: *session0 + name: startTransaction + - + object: *collection0 + name: insertOne + arguments: + session: *session0 + document: { _id: 1 } + expectResult: + $$unsetOrMatches: { insertedId: { $$unsetOrMatches: 1 } } + - + object: *session0 + name: abortTransaction + - + object: *session0 + name: commitTransaction + expectError: + errorContains: 'Cannot call commitTransaction after calling abortTransaction' + expectEvents: + - + client: *client0 + events: + - + commandStartedEvent: + command: + insert: *collection_name + documents: + - { _id: 1 } + ordered: true + readConcern: { $$exists: false } + lsid: { $$sessionLsid: *session0 } + txnNumber: { $numberLong: '1' } + startTransaction: true + autocommit: false + writeConcern: { $$exists: false } + commandName: insert + databaseName: *database_name + - + commandStartedEvent: + command: + abortTransaction: 1 + lsid: { $$sessionLsid: *session0 } + txnNumber: { $numberLong: '1' } + startTransaction: { $$exists: false } + autocommit: false + writeConcern: { $$exists: false } + commandName: abortTransaction + databaseName: admin + - + description: 'multiple commits after empty transaction' + operations: + - + object: *session0 + name: startTransaction + - + object: *collection0 + name: insertOne + arguments: + session: *session0 + document: { _id: 1 } + expectResult: + $$unsetOrMatches: { insertedId: { $$unsetOrMatches: 1 } } + - + object: *session0 + name: abortTransaction + # Increments txnNumber + - + object: *session0 + name: startTransaction + # These commits aren't sent to server, transaction is empty + - + object: *session0 + name: commitTransaction + - + object: *session0 + name: commitTransaction + # Verify that previous, empty transaction incremented txnNumber + - + object: *session0 + name: startTransaction + - + object: *collection0 + name: insertOne + arguments: + session: *session0 + document: { _id: 1 } + expectResult: + $$unsetOrMatches: { insertedId: { $$unsetOrMatches: 1 } } + - + object: *session0 + name: abortTransaction + expectEvents: + - + client: *client0 + events: + - + commandStartedEvent: + command: + insert: *collection_name + documents: + - { _id: 1 } + ordered: true + readConcern: { $$exists: false } + lsid: { $$sessionLsid: *session0 } + txnNumber: { $numberLong: '1' } + startTransaction: true + autocommit: false + writeConcern: { $$exists: false } + commandName: insert + databaseName: *database_name + - + commandStartedEvent: + command: + abortTransaction: 1 + lsid: { $$sessionLsid: *session0 } + txnNumber: { $numberLong: '1' } + startTransaction: { $$exists: false } + autocommit: false + writeConcern: { $$exists: false } + commandName: abortTransaction + databaseName: admin + - + commandStartedEvent: + command: + insert: *collection_name + documents: + - { _id: 1 } + ordered: true + readConcern: + afterClusterTime: { $$exists: true } + lsid: { $$sessionLsid: *session0 } + # txnNumber 2 was skipped + txnNumber: { $numberLong: '3' } + startTransaction: true + autocommit: false + writeConcern: { $$exists: false } + commandName: insert + databaseName: *database_name + - + commandStartedEvent: + command: + abortTransaction: 1 + lsid: { $$sessionLsid: *session0 } + txnNumber: { $numberLong: '3' } + startTransaction: { $$exists: false } + autocommit: false + writeConcern: { $$exists: false } + commandName: abortTransaction + databaseName: admin + outcome: + - + collectionName: *collection_name + databaseName: *database_name + documents: [] + - + description: 'reset session state commit' + operations: + - + object: *session1 + name: startTransaction + - + object: *collection1 + name: insertOne + arguments: + session: *session1 + document: { _id: 1 } + expectResult: + $$unsetOrMatches: { insertedId: { $$unsetOrMatches: 1 } } + - + object: *session1 + name: commitTransaction + # Running any operation after an ended transaction resets the session state to "no transaction" + - + object: *collection1 + name: insertOne + arguments: + session: *session1 + document: { _id: 2 } + expectResult: + $$unsetOrMatches: { insertedId: { $$unsetOrMatches: 2 } } + # Calling commit again should error instead of re-running the commit + - + object: *session1 + name: commitTransaction + expectError: + errorContains: 'no transaction started' + expectEvents: + - + client: *client1 + events: + - + commandStartedEvent: + command: + insert: *collection_name + documents: + - { _id: 1 } + ordered: true + readConcern: { $$exists: false } + lsid: { $$sessionLsid: *session1 } + txnNumber: { $numberLong: '1' } + startTransaction: true + autocommit: false + writeConcern: { $$exists: false } + commandName: insert + databaseName: *database_name + - + commandStartedEvent: + command: + commitTransaction: 1 + lsid: { $$sessionLsid: *session1 } + txnNumber: { $numberLong: '1' } + startTransaction: { $$exists: false } + autocommit: false + writeConcern: { $$exists: false } + commandName: commitTransaction + databaseName: admin + - + commandStartedEvent: + command: + insert: *collection_name + documents: + - { _id: 2 } + ordered: true + readConcern: { $$exists: false } + lsid: { $$sessionLsid: *session1 } + txnNumber: { $$exists: false } + startTransaction: { $$exists: false } + autocommit: { $$exists: false } + commandName: insert + databaseName: *database_name + outcome: + - + collectionName: *collection_name + databaseName: *database_name + documents: + - { _id: 1 } + - { _id: 2 } + - + description: 'reset session state abort' + operations: + - + object: *session1 + name: startTransaction + - + object: *collection1 + name: insertOne + arguments: + session: *session1 + document: { _id: 1 } + expectResult: + $$unsetOrMatches: { insertedId: { $$unsetOrMatches: 1 } } + - + object: *session1 + name: abortTransaction + # Running any operation after an ended transaction resets the session state to "no transaction" + - + object: *collection1 + name: insertOne + arguments: + session: *session1 + document: { _id: 2 } + expectResult: + $$unsetOrMatches: { insertedId: { $$unsetOrMatches: 2 } } + # Calling abort should error with "no transaction started" instead of "cannot call abortTransaction twice" + - + object: *session1 + name: abortTransaction + expectError: + errorContains: 'no transaction started' + expectEvents: + - + client: *client1 + events: + - + commandStartedEvent: + command: + insert: *collection_name + documents: + - { _id: 1 } + ordered: true + readConcern: { $$exists: false } + lsid: { $$sessionLsid: *session1 } + txnNumber: { $numberLong: '1' } + startTransaction: true + autocommit: false + writeConcern: { $$exists: false } + commandName: insert + databaseName: *database_name + - + commandStartedEvent: + command: + abortTransaction: 1 + lsid: { $$sessionLsid: *session1 } + txnNumber: { $numberLong: '1' } + startTransaction: { $$exists: false } + autocommit: false + writeConcern: { $$exists: false } + commandName: abortTransaction + databaseName: admin + - + commandStartedEvent: + command: + insert: *collection_name + documents: + - { _id: 2 } + ordered: true + readConcern: { $$exists: false } + lsid: { $$sessionLsid: *session1 } + txnNumber: { $$exists: false } + startTransaction: { $$exists: false } + autocommit: { $$exists: false } + commandName: insert + databaseName: *database_name + outcome: + - + collectionName: *collection_name + databaseName: *database_name + documents: + - { _id: 2 } diff --git a/source/transactions/tests/unified/count.json b/source/transactions/tests/unified/count.json new file mode 100644 index 0000000000..404b06beb6 --- /dev/null +++ b/source/transactions/tests/unified/count.json @@ -0,0 +1,177 @@ +{ + "description": "count", + "schemaVersion": "1.3", + "runOnRequirements": [ + { + "minServerVersion": "4.0.2", + "topologies": [ + "replicaset" + ] + }, + { + "minServerVersion": "4.1.8", + "topologies": [ + "sharded", + "load-balanced" + ] + } + ], + "createEntities": [ + { + "client": { + "id": "client0", + "useMultipleMongoses": false, + "observeEvents": [ + "commandStartedEvent" + ] + } + }, + { + "database": { + "id": "database0", + "client": "client0", + "databaseName": "transaction-tests" + } + }, + { + "collection": { + "id": "collection0", + "database": "database0", + "collectionName": "test" + } + }, + { + "session": { + "id": "session0", + "client": "client0" + } + } + ], + "initialData": [ + { + "collectionName": "test", + "databaseName": "transaction-tests", + "documents": [ + { + "_id": 1 + }, + { + "_id": 2 + }, + { + "_id": 3 + }, + { + "_id": 4 + } + ] + } + ], + "tests": [ + { + "description": "count", + "operations": [ + { + "object": "session0", + "name": "startTransaction" + }, + { + "object": "collection0", + "name": "count", + "arguments": { + "session": "session0", + "filter": { + "_id": 1 + } + }, + "expectError": { + "errorCodeName": "OperationNotSupportedInTransaction", + "errorLabelsOmit": [ + "TransientTransactionError", + "UnknownTransactionCommitResult" + ] + } + }, + { + "object": "session0", + "name": "abortTransaction" + } + ], + "expectEvents": [ + { + "client": "client0", + "events": [ + { + "commandStartedEvent": { + "command": { + "count": "test", + "query": { + "_id": 1 + }, + "readConcern": { + "$$exists": false + }, + "lsid": { + "$$sessionLsid": "session0" + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": true, + "autocommit": false, + "writeConcern": { + "$$exists": false + } + }, + "commandName": "count", + "databaseName": "transaction-tests" + } + }, + { + "commandStartedEvent": { + "command": { + "abortTransaction": 1, + "lsid": { + "$$sessionLsid": "session0" + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": { + "$$exists": false + }, + "autocommit": false, + "writeConcern": { + "$$exists": false + } + }, + "commandName": "abortTransaction", + "databaseName": "admin" + } + } + ] + } + ], + "outcome": [ + { + "collectionName": "test", + "databaseName": "transaction-tests", + "documents": [ + { + "_id": 1 + }, + { + "_id": 2 + }, + { + "_id": 3 + }, + { + "_id": 4 + } + ] + } + ] + } + ] +} diff --git a/source/transactions/tests/unified/count.yml b/source/transactions/tests/unified/count.yml new file mode 100644 index 0000000000..c78d5b2ae3 --- /dev/null +++ b/source/transactions/tests/unified/count.yml @@ -0,0 +1,102 @@ +description: count + +schemaVersion: '1.3' + +runOnRequirements: + # SERVER-35388 introduced OperationNotSupportedInTransaction in 4.0.2 + - + minServerVersion: 4.0.2 + topologies: + - replicaset + - + minServerVersion: 4.1.8 + topologies: + - sharded + - load-balanced + +createEntities: + - + client: + id: &client0 client0 + useMultipleMongoses: false + observeEvents: + - commandStartedEvent + - + database: + id: &database0 database0 + client: *client0 + databaseName: &database_name transaction-tests + - + collection: + id: &collection0 collection0 + database: *database0 + collectionName: &collection_name test + - + session: + id: &session0 session0 + client: *client0 + +initialData: + - + collectionName: *collection_name + databaseName: *database_name + documents: &data + - { _id: 1 } + - { _id: 2 } + - { _id: 3 } + - { _id: 4 } + +tests: + - + description: count + operations: + - + object: *session0 + name: startTransaction + - + object: *collection0 + name: count + arguments: + session: *session0 + filter: { _id: 1 } + expectError: + errorCodeName: OperationNotSupportedInTransaction + errorLabelsOmit: + - TransientTransactionError + - UnknownTransactionCommitResult + - + object: *session0 + name: abortTransaction + expectEvents: + - + client: *client0 + events: + - + commandStartedEvent: + command: + count: *collection_name + query: { _id: 1 } + readConcern: { $$exists: false } + lsid: { $$sessionLsid: *session0 } + txnNumber: { $numberLong: '1' } + startTransaction: true + autocommit: false + writeConcern: { $$exists: false } + commandName: count + databaseName: *database_name + - + commandStartedEvent: + command: + abortTransaction: 1 + lsid: { $$sessionLsid: *session0 } + txnNumber: { $numberLong: '1' } + startTransaction: { $$exists: false } + autocommit: false + writeConcern: { $$exists: false } + commandName: abortTransaction + databaseName: admin + outcome: + - + collectionName: *collection_name + databaseName: *database_name + documents: *data \ No newline at end of file diff --git a/source/transactions/tests/unified/create-collection.json b/source/transactions/tests/unified/create-collection.json new file mode 100644 index 0000000000..e190088b3b --- /dev/null +++ b/source/transactions/tests/unified/create-collection.json @@ -0,0 +1,282 @@ +{ + "description": "create-collection", + "schemaVersion": "1.3", + "runOnRequirements": [ + { + "minServerVersion": "4.3.4", + "topologies": [ + "replicaset", + "sharded", + "load-balanced" + ] + } + ], + "createEntities": [ + { + "client": { + "id": "client0", + "useMultipleMongoses": false, + "observeEvents": [ + "commandStartedEvent" + ] + } + }, + { + "database": { + "id": "database0", + "client": "client0", + "databaseName": "transaction-tests" + } + }, + { + "collection": { + "id": "collection0", + "database": "database0", + "collectionName": "test" + } + }, + { + "session": { + "id": "session0", + "client": "client0" + } + } + ], + "initialData": [ + { + "collectionName": "test", + "databaseName": "transaction-tests", + "documents": [] + } + ], + "tests": [ + { + "description": "explicitly create collection using create command", + "operations": [ + { + "object": "database0", + "name": "dropCollection", + "arguments": { + "collection": "test" + } + }, + { + "object": "session0", + "name": "startTransaction" + }, + { + "object": "database0", + "name": "createCollection", + "arguments": { + "session": "session0", + "collection": "test" + } + }, + { + "object": "testRunner", + "name": "assertCollectionNotExists", + "arguments": { + "databaseName": "transaction-tests", + "collectionName": "test" + } + }, + { + "object": "session0", + "name": "commitTransaction" + }, + { + "object": "testRunner", + "name": "assertCollectionExists", + "arguments": { + "databaseName": "transaction-tests", + "collectionName": "test" + } + } + ], + "expectEvents": [ + { + "client": "client0", + "events": [ + { + "commandStartedEvent": { + "command": { + "drop": "test", + "writeConcern": { + "$$exists": false + } + }, + "commandName": "drop", + "databaseName": "transaction-tests" + } + }, + { + "commandStartedEvent": { + "command": { + "create": "test", + "lsid": { + "$$sessionLsid": "session0" + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": true, + "autocommit": false, + "writeConcern": { + "$$exists": false + } + }, + "commandName": "create", + "databaseName": "transaction-tests" + } + }, + { + "commandStartedEvent": { + "command": { + "commitTransaction": 1, + "lsid": { + "$$sessionLsid": "session0" + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": { + "$$exists": false + }, + "autocommit": false, + "writeConcern": { + "$$exists": false + } + }, + "commandName": "commitTransaction", + "databaseName": "admin" + } + } + ] + } + ] + }, + { + "description": "implicitly create collection using insert", + "operations": [ + { + "object": "database0", + "name": "dropCollection", + "arguments": { + "collection": "test" + } + }, + { + "object": "session0", + "name": "startTransaction" + }, + { + "object": "collection0", + "name": "insertOne", + "arguments": { + "session": "session0", + "document": { + "_id": 1 + } + }, + "expectResult": { + "$$unsetOrMatches": { + "insertedId": { + "$$unsetOrMatches": 1 + } + } + } + }, + { + "object": "testRunner", + "name": "assertCollectionNotExists", + "arguments": { + "databaseName": "transaction-tests", + "collectionName": "test" + } + }, + { + "object": "session0", + "name": "commitTransaction" + }, + { + "object": "testRunner", + "name": "assertCollectionExists", + "arguments": { + "databaseName": "transaction-tests", + "collectionName": "test" + } + } + ], + "expectEvents": [ + { + "client": "client0", + "events": [ + { + "commandStartedEvent": { + "command": { + "drop": "test", + "writeConcern": { + "$$exists": false + } + }, + "commandName": "drop", + "databaseName": "transaction-tests" + } + }, + { + "commandStartedEvent": { + "command": { + "insert": "test", + "documents": [ + { + "_id": 1 + } + ], + "ordered": true, + "readConcern": { + "$$exists": false + }, + "lsid": { + "$$sessionLsid": "session0" + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": true, + "autocommit": false, + "writeConcern": { + "$$exists": false + } + }, + "commandName": "insert", + "databaseName": "transaction-tests" + } + }, + { + "commandStartedEvent": { + "command": { + "commitTransaction": 1, + "lsid": { + "$$sessionLsid": "session0" + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": { + "$$exists": false + }, + "autocommit": false, + "writeConcern": { + "$$exists": false + } + }, + "commandName": "commitTransaction", + "databaseName": "admin" + } + } + ] + } + ] + } + ] +} diff --git a/source/transactions/tests/unified/create-collection.yml b/source/transactions/tests/unified/create-collection.yml new file mode 100644 index 0000000000..f795716865 --- /dev/null +++ b/source/transactions/tests/unified/create-collection.yml @@ -0,0 +1,177 @@ +description: create-collection + +schemaVersion: '1.3' + +runOnRequirements: + - + minServerVersion: 4.3.4 + topologies: + - replicaset + - sharded + - load-balanced + +createEntities: + - + client: + id: &client0 client0 + useMultipleMongoses: false + observeEvents: + - commandStartedEvent + - + database: + id: &database0 database0 + client: *client0 + databaseName: &database_name transaction-tests + - + collection: + id: &collection0 collection0 + database: *database0 + collectionName: &collection_name test + - + session: + id: &session0 session0 + client: *client0 + +initialData: + - + collectionName: *collection_name + databaseName: *database_name + documents: [] + +tests: + - + description: 'explicitly create collection using create command' + operations: + - + object: *database0 + name: dropCollection + arguments: + collection: *collection_name + - + object: *session0 + name: startTransaction + - + object: *database0 + name: createCollection + arguments: + session: *session0 + collection: *collection_name + - + object: testRunner + name: assertCollectionNotExists + arguments: + databaseName: *database_name + collectionName: *collection_name + - + object: *session0 + name: commitTransaction + - + object: testRunner + name: assertCollectionExists + arguments: + databaseName: *database_name + collectionName: *collection_name + expectEvents: + - + client: *client0 + events: + - + commandStartedEvent: + command: + drop: *collection_name + writeConcern: { $$exists: false } + commandName: drop + databaseName: *database_name + - + commandStartedEvent: + command: + create: *collection_name + lsid: { $$sessionLsid: *session0 } + txnNumber: { $numberLong: '1' } + startTransaction: true + autocommit: false + writeConcern: { $$exists: false } + commandName: create + databaseName: *database_name + - + commandStartedEvent: + command: + commitTransaction: 1 + lsid: { $$sessionLsid: *session0 } + txnNumber: { $numberLong: '1' } + startTransaction: { $$exists: false } + autocommit: false + writeConcern: { $$exists: false } + commandName: commitTransaction + databaseName: admin + - + description: 'implicitly create collection using insert' + operations: + - + object: *database0 + name: dropCollection + arguments: + collection: *collection_name + - + object: *session0 + name: startTransaction + - + object: *collection0 + name: insertOne + arguments: + session: *session0 + document: { _id: 1 } + expectResult: + $$unsetOrMatches: { insertedId: { $$unsetOrMatches: 1 } } + - + object: testRunner + name: assertCollectionNotExists + arguments: + databaseName: *database_name + collectionName: *collection_name + - + object: *session0 + name: commitTransaction + - + object: testRunner + name: assertCollectionExists + arguments: + databaseName: *database_name + collectionName: *collection_name + expectEvents: + - + client: *client0 + events: + - + commandStartedEvent: + command: + drop: *collection_name + writeConcern: { $$exists: false } + commandName: drop + databaseName: *database_name + - + commandStartedEvent: + command: + insert: *collection_name + documents: + - { _id: 1 } + ordered: true + readConcern: { $$exists: false } + lsid: { $$sessionLsid: *session0 } + txnNumber: { $numberLong: '1' } + startTransaction: true + autocommit: false + writeConcern: { $$exists: false } + commandName: insert + databaseName: *database_name + - + commandStartedEvent: + command: + commitTransaction: 1 + lsid: { $$sessionLsid: *session0 } + txnNumber: { $numberLong: '1' } + startTransaction: { $$exists: false } + autocommit: false + writeConcern: { $$exists: false } + commandName: commitTransaction + databaseName: admin diff --git a/source/transactions/tests/unified/create-index.json b/source/transactions/tests/unified/create-index.json new file mode 100644 index 0000000000..98d6e11547 --- /dev/null +++ b/source/transactions/tests/unified/create-index.json @@ -0,0 +1,313 @@ +{ + "description": "create-index", + "schemaVersion": "1.3", + "runOnRequirements": [ + { + "minServerVersion": "4.3.4", + "topologies": [ + "replicaset", + "sharded", + "load-balanced" + ] + } + ], + "createEntities": [ + { + "client": { + "id": "client0", + "useMultipleMongoses": false, + "observeEvents": [ + "commandStartedEvent" + ] + } + }, + { + "database": { + "id": "database0", + "client": "client0", + "databaseName": "transaction-tests" + } + }, + { + "collection": { + "id": "collection0", + "database": "database0", + "collectionName": "test" + } + }, + { + "session": { + "id": "session0", + "client": "client0" + } + } + ], + "initialData": [ + { + "collectionName": "test", + "databaseName": "transaction-tests", + "documents": [] + } + ], + "tests": [ + { + "description": "create index on a non-existing collection", + "operations": [ + { + "object": "database0", + "name": "dropCollection", + "arguments": { + "collection": "test" + } + }, + { + "object": "session0", + "name": "startTransaction" + }, + { + "object": "collection0", + "name": "createIndex", + "arguments": { + "session": "session0", + "name": "t_1", + "keys": { + "x": 1 + } + } + }, + { + "object": "testRunner", + "name": "assertIndexNotExists", + "arguments": { + "databaseName": "transaction-tests", + "collectionName": "test", + "indexName": "t_1" + } + }, + { + "object": "session0", + "name": "commitTransaction" + }, + { + "object": "testRunner", + "name": "assertIndexExists", + "arguments": { + "databaseName": "transaction-tests", + "collectionName": "test", + "indexName": "t_1" + } + } + ], + "expectEvents": [ + { + "client": "client0", + "events": [ + { + "commandStartedEvent": { + "command": { + "drop": "test", + "writeConcern": { + "$$exists": false + } + }, + "commandName": "drop", + "databaseName": "transaction-tests" + } + }, + { + "commandStartedEvent": { + "command": { + "createIndexes": "test", + "indexes": [ + { + "name": "t_1", + "key": { + "x": 1 + } + } + ], + "lsid": { + "$$sessionLsid": "session0" + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": true, + "autocommit": false, + "writeConcern": { + "$$exists": false + } + }, + "commandName": "createIndexes", + "databaseName": "transaction-tests" + } + }, + { + "commandStartedEvent": { + "command": { + "commitTransaction": 1, + "lsid": { + "$$sessionLsid": "session0" + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": { + "$$exists": false + }, + "autocommit": false, + "writeConcern": { + "$$exists": false + } + }, + "commandName": "commitTransaction", + "databaseName": "admin" + } + } + ] + } + ] + }, + { + "description": "create index on a collection created within the same transaction", + "operations": [ + { + "object": "database0", + "name": "dropCollection", + "arguments": { + "collection": "test" + } + }, + { + "object": "session0", + "name": "startTransaction" + }, + { + "object": "database0", + "name": "createCollection", + "arguments": { + "session": "session0", + "collection": "test" + } + }, + { + "object": "collection0", + "name": "createIndex", + "arguments": { + "session": "session0", + "name": "t_1", + "keys": { + "x": 1 + } + } + }, + { + "object": "testRunner", + "name": "assertIndexNotExists", + "arguments": { + "databaseName": "transaction-tests", + "collectionName": "test", + "indexName": "t_1" + } + }, + { + "object": "session0", + "name": "commitTransaction" + }, + { + "object": "testRunner", + "name": "assertIndexExists", + "arguments": { + "databaseName": "transaction-tests", + "collectionName": "test", + "indexName": "t_1" + } + } + ], + "expectEvents": [ + { + "client": "client0", + "events": [ + { + "commandStartedEvent": { + "command": { + "drop": "test", + "writeConcern": { + "$$exists": false + } + }, + "commandName": "drop", + "databaseName": "transaction-tests" + } + }, + { + "commandStartedEvent": { + "command": { + "create": "test", + "lsid": { + "$$sessionLsid": "session0" + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": true, + "autocommit": false, + "writeConcern": { + "$$exists": false + } + }, + "commandName": "create", + "databaseName": "transaction-tests" + } + }, + { + "commandStartedEvent": { + "command": { + "createIndexes": "test", + "indexes": [ + { + "name": "t_1", + "key": { + "x": 1 + } + } + ], + "lsid": { + "$$sessionLsid": "session0" + }, + "writeConcern": { + "$$exists": false + } + }, + "commandName": "createIndexes", + "databaseName": "transaction-tests" + } + }, + { + "commandStartedEvent": { + "command": { + "commitTransaction": 1, + "lsid": { + "$$sessionLsid": "session0" + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": { + "$$exists": false + }, + "autocommit": false, + "writeConcern": { + "$$exists": false + } + }, + "commandName": "commitTransaction", + "databaseName": "admin" + } + } + ] + } + ] + } + ] +} diff --git a/source/transactions/tests/unified/create-index.yml b/source/transactions/tests/unified/create-index.yml new file mode 100644 index 0000000000..4465d0922e --- /dev/null +++ b/source/transactions/tests/unified/create-index.yml @@ -0,0 +1,202 @@ +description: create-index + +schemaVersion: '1.3' + +runOnRequirements: + - + minServerVersion: 4.3.4 + topologies: + - replicaset + - sharded + - load-balanced + +createEntities: + - + client: + id: &client0 client0 + useMultipleMongoses: false + observeEvents: + - commandStartedEvent + - + database: + id: &database0 database0 + client: *client0 + databaseName: &database_name transaction-tests + - + collection: + id: &collection0 collection0 + database: *database0 + collectionName: &collection_name test + - + session: + id: &session0 session0 + client: *client0 + +initialData: + - + collectionName: *collection_name + databaseName: *database_name + documents: [] +tests: + - + description: 'create index on a non-existing collection' + operations: + - + object: *database0 + name: dropCollection + arguments: + collection: *collection_name + - + object: *session0 + name: startTransaction + - + object: *collection0 + name: createIndex + arguments: + session: *session0 + name: &index_name t_1 + keys: + x: 1 + - + object: testRunner + name: assertIndexNotExists + arguments: + databaseName: *database_name + collectionName: *collection_name + indexName: *index_name + - + object: *session0 + name: commitTransaction + - + object: testRunner + name: assertIndexExists + arguments: + databaseName: *database_name + collectionName: *collection_name + indexName: *index_name + expectEvents: + - + client: *client0 + events: + - + commandStartedEvent: + command: + drop: *collection_name + writeConcern: { $$exists: false } + commandName: drop + databaseName: *database_name + - + commandStartedEvent: + command: + createIndexes: *collection_name + indexes: + - + name: *index_name + key: + x: 1 + lsid: { $$sessionLsid: *session0 } + txnNumber: { $numberLong: '1' } + startTransaction: true + autocommit: false + writeConcern: { $$exists: false } + commandName: createIndexes + databaseName: *database_name + - + commandStartedEvent: + command: + commitTransaction: 1 + lsid: { $$sessionLsid: *session0 } + txnNumber: { $numberLong: '1' } + startTransaction: { $$exists: false } + autocommit: false + writeConcern: { $$exists: false } + commandName: commitTransaction + databaseName: admin + - + description: 'create index on a collection created within the same transaction' + operations: + - + object: *database0 + name: dropCollection + arguments: + collection: *collection_name + - + object: *session0 + name: startTransaction + - + object: *database0 + name: createCollection + arguments: + session: *session0 + collection: *collection_name + - + object: *collection0 + name: createIndex + arguments: + session: *session0 + name: *index_name + keys: + x: 1 + - + object: testRunner + name: assertIndexNotExists + arguments: + databaseName: *database_name + collectionName: *collection_name + indexName: *index_name + - + object: *session0 + name: commitTransaction + - + object: testRunner + name: assertIndexExists + arguments: + databaseName: *database_name + collectionName: *collection_name + indexName: *index_name + expectEvents: + - + client: *client0 + events: + - + commandStartedEvent: + command: + drop: *collection_name + writeConcern: { $$exists: false } + commandName: drop + databaseName: *database_name + - + commandStartedEvent: + command: + create: *collection_name + lsid: { $$sessionLsid: *session0 } + txnNumber: { $numberLong: '1' } + startTransaction: true + autocommit: false + writeConcern: { $$exists: false } + commandName: create + databaseName: *database_name + - + commandStartedEvent: + command: + createIndexes: *collection_name + indexes: + - + name: *index_name + key: + x: 1 + lsid: { $$sessionLsid: *session0 } + writeConcern: { $$exists: false } + commandName: createIndexes + databaseName: *database_name + - + commandStartedEvent: + command: + commitTransaction: 1 + lsid: { $$sessionLsid: *session0 } + txnNumber: { $numberLong: '1' } + startTransaction: { $$exists: false } + autocommit: false + writeConcern: { $$exists: false } + commandName: commitTransaction + databaseName: admin diff --git a/source/transactions/tests/unified/delete.json b/source/transactions/tests/unified/delete.json new file mode 100644 index 0000000000..4c1cae0a4e --- /dev/null +++ b/source/transactions/tests/unified/delete.json @@ -0,0 +1,425 @@ +{ + "description": "delete", + "schemaVersion": "1.9", + "runOnRequirements": [ + { + "minServerVersion": "4.0", + "topologies": [ + "replicaset" + ] + }, + { + "minServerVersion": "4.1.8", + "topologies": [ + "sharded", + "load-balanced" + ] + } + ], + "createEntities": [ + { + "client": { + "id": "client0", + "useMultipleMongoses": false, + "observeEvents": [ + "commandStartedEvent" + ] + } + }, + { + "database": { + "id": "database0", + "client": "client0", + "databaseName": "transaction-tests" + } + }, + { + "collection": { + "id": "collection0", + "database": "database0", + "collectionName": "test" + } + }, + { + "session": { + "id": "session0", + "client": "client0" + } + } + ], + "initialData": [ + { + "collectionName": "test", + "databaseName": "transaction-tests", + "documents": [ + { + "_id": 1 + }, + { + "_id": 2 + }, + { + "_id": 3 + }, + { + "_id": 4 + }, + { + "_id": 5 + } + ] + } + ], + "tests": [ + { + "description": "delete", + "operations": [ + { + "object": "session0", + "name": "startTransaction" + }, + { + "object": "collection0", + "name": "deleteOne", + "arguments": { + "session": "session0", + "filter": { + "_id": 1 + } + }, + "expectResult": { + "deletedCount": 1 + } + }, + { + "object": "collection0", + "name": "deleteMany", + "arguments": { + "session": "session0", + "filter": { + "_id": { + "$lte": 3 + } + } + }, + "expectResult": { + "deletedCount": 2 + } + }, + { + "object": "collection0", + "name": "deleteOne", + "arguments": { + "session": "session0", + "filter": { + "_id": 4 + } + }, + "expectResult": { + "deletedCount": 1 + } + }, + { + "object": "session0", + "name": "commitTransaction" + } + ], + "expectEvents": [ + { + "client": "client0", + "events": [ + { + "commandStartedEvent": { + "command": { + "delete": "test", + "deletes": [ + { + "q": { + "_id": 1 + }, + "limit": 1 + } + ], + "ordered": true, + "readConcern": { + "$$exists": false + }, + "lsid": { + "$$sessionLsid": "session0" + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": true, + "autocommit": false, + "writeConcern": { + "$$exists": false + } + }, + "commandName": "delete", + "databaseName": "transaction-tests" + } + }, + { + "commandStartedEvent": { + "command": { + "delete": "test", + "deletes": [ + { + "q": { + "_id": { + "$lte": 3 + } + }, + "limit": 0 + } + ], + "ordered": true, + "lsid": { + "$$sessionLsid": "session0" + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": { + "$$exists": false + }, + "autocommit": false, + "writeConcern": { + "$$exists": false + } + }, + "commandName": "delete", + "databaseName": "transaction-tests" + } + }, + { + "commandStartedEvent": { + "command": { + "delete": "test", + "deletes": [ + { + "q": { + "_id": 4 + }, + "limit": 1 + } + ], + "ordered": true, + "lsid": { + "$$sessionLsid": "session0" + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": { + "$$exists": false + }, + "autocommit": false, + "writeConcern": { + "$$exists": false + } + }, + "commandName": "delete", + "databaseName": "transaction-tests" + } + }, + { + "commandStartedEvent": { + "command": { + "commitTransaction": 1, + "lsid": { + "$$sessionLsid": "session0" + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": { + "$$exists": false + }, + "autocommit": false, + "writeConcern": { + "$$exists": false + } + }, + "commandName": "commitTransaction", + "databaseName": "admin" + } + } + ] + } + ], + "outcome": [ + { + "collectionName": "test", + "databaseName": "transaction-tests", + "documents": [ + { + "_id": 5 + } + ] + } + ] + }, + { + "description": "collection writeConcern ignored for delete", + "operations": [ + { + "object": "testRunner", + "name": "createEntities", + "arguments": { + "entities": [ + { + "collection": { + "id": "collection_wc_majority", + "database": "database0", + "collectionName": "test", + "collectionOptions": { + "writeConcern": { + "w": "majority" + } + } + } + } + ] + } + }, + { + "object": "session0", + "name": "startTransaction", + "arguments": { + "writeConcern": { + "w": "majority" + } + } + }, + { + "object": "collection_wc_majority", + "name": "deleteOne", + "arguments": { + "session": "session0", + "filter": { + "_id": 1 + } + }, + "expectResult": { + "deletedCount": 1 + } + }, + { + "object": "collection_wc_majority", + "name": "deleteMany", + "arguments": { + "session": "session0", + "filter": { + "_id": { + "$lte": 3 + } + } + }, + "expectResult": { + "deletedCount": 2 + } + }, + { + "object": "session0", + "name": "commitTransaction" + } + ], + "expectEvents": [ + { + "client": "client0", + "events": [ + { + "commandStartedEvent": { + "command": { + "delete": "test", + "deletes": [ + { + "q": { + "_id": 1 + }, + "limit": 1 + } + ], + "ordered": true, + "readConcern": { + "$$exists": false + }, + "lsid": { + "$$sessionLsid": "session0" + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": true, + "autocommit": false, + "writeConcern": { + "$$exists": false + } + }, + "commandName": "delete", + "databaseName": "transaction-tests" + } + }, + { + "commandStartedEvent": { + "command": { + "delete": "test", + "deletes": [ + { + "q": { + "_id": { + "$lte": 3 + } + }, + "limit": 0 + } + ], + "ordered": true, + "lsid": { + "$$sessionLsid": "session0" + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": { + "$$exists": false + }, + "autocommit": false, + "writeConcern": { + "$$exists": false + } + }, + "commandName": "delete", + "databaseName": "transaction-tests" + } + }, + { + "commandStartedEvent": { + "command": { + "commitTransaction": 1, + "lsid": { + "$$sessionLsid": "session0" + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": { + "$$exists": false + }, + "autocommit": false, + "writeConcern": { + "w": "majority" + } + }, + "commandName": "commitTransaction", + "databaseName": "admin" + } + } + ] + } + ] + } + ] +} diff --git a/source/transactions/tests/unified/delete.yml b/source/transactions/tests/unified/delete.yml new file mode 100644 index 0000000000..49bbf16137 --- /dev/null +++ b/source/transactions/tests/unified/delete.yml @@ -0,0 +1,240 @@ +description: delete + +schemaVersion: '1.9' + +runOnRequirements: + - + minServerVersion: '4.0' + topologies: + - replicaset + - + minServerVersion: 4.1.8 + topologies: + - sharded + - load-balanced + +createEntities: + - + client: + id: &client0 client0 + useMultipleMongoses: false + observeEvents: + - commandStartedEvent + - + database: + id: &database0 database0 + client: *client0 + databaseName: &database_name transaction-tests + - + collection: + id: &collection0 collection0 + database: *database0 + collectionName: &collection_name test + - + session: + id: &session0 session0 + client: *client0 + +initialData: + - + collectionName: *collection_name + databaseName: *database_name + documents: + - { _id: 1 } + - { _id: 2 } + - { _id: 3 } + - { _id: 4 } + - { _id: 5 } + +tests: + - + description: delete + operations: + - + object: *session0 + name: startTransaction + - + object: *collection0 + name: deleteOne + arguments: + session: *session0 + filter: { _id: 1 } + expectResult: + deletedCount: 1 + - + object: *collection0 + name: deleteMany + arguments: + session: *session0 + filter: { _id: { $lte: 3 } } + expectResult: + deletedCount: 2 + - + object: *collection0 + name: deleteOne + arguments: + session: *session0 + filter: { _id: 4 } + expectResult: + deletedCount: 1 + - + object: *session0 + name: commitTransaction + expectEvents: + - + client: *client0 + events: + - + commandStartedEvent: + command: + delete: *collection_name + deletes: + - + q: { _id: 1 } + limit: 1 + ordered: true + readConcern: { $$exists: false } + lsid: { $$sessionLsid: *session0 } + txnNumber: { $numberLong: '1' } + startTransaction: true + autocommit: false + writeConcern: { $$exists: false } + commandName: delete + databaseName: *database_name + - + commandStartedEvent: + command: + delete: *collection_name + deletes: + - + q: { _id: { $lte: 3 } } + limit: 0 + ordered: true + lsid: { $$sessionLsid: *session0 } + txnNumber: { $numberLong: '1' } + startTransaction: { $$exists: false } + autocommit: false + writeConcern: { $$exists: false } + commandName: delete + databaseName: *database_name + - + commandStartedEvent: + command: + delete: *collection_name + deletes: + - + q: { _id: 4 } + limit: 1 + ordered: true + lsid: { $$sessionLsid: *session0 } + txnNumber: { $numberLong: '1' } + startTransaction: { $$exists: false } + autocommit: false + writeConcern: { $$exists: false } + commandName: delete + databaseName: *database_name + - + commandStartedEvent: + command: + commitTransaction: 1 + lsid: { $$sessionLsid: *session0 } + txnNumber: { $numberLong: '1' } + startTransaction: { $$exists: false } + autocommit: false + writeConcern: { $$exists: false } + commandName: commitTransaction + databaseName: admin + outcome: + - + collectionName: *collection_name + databaseName: *database_name + documents: + - { _id: 5 } + - + description: 'collection writeConcern ignored for delete' + operations: + - + object: testRunner + name: createEntities + arguments: + entities: + - collection: + id: &collection_wc_majority collection_wc_majority + database: *database0 + collectionName: *collection_name + collectionOptions: + writeConcern: { w: majority } + - + object: *session0 + name: startTransaction + arguments: + writeConcern: + w: majority + - + object: *collection_wc_majority + name: deleteOne + arguments: + session: *session0 + filter: { _id: 1 } + expectResult: + deletedCount: 1 + - + object: *collection_wc_majority + name: deleteMany + arguments: + session: *session0 + filter: { _id: { $lte: 3 } } + expectResult: + deletedCount: 2 + - + object: *session0 + name: commitTransaction + expectEvents: + - + client: *client0 + events: + - + commandStartedEvent: + command: + delete: *collection_name + deletes: + - + q: { _id: 1 } + limit: 1 + ordered: true + readConcern: { $$exists: false } + lsid: { $$sessionLsid: *session0 } + txnNumber: { $numberLong: '1' } + startTransaction: true + autocommit: false + writeConcern: { $$exists: false } + commandName: delete + databaseName: *database_name + - + commandStartedEvent: + command: + delete: *collection_name + deletes: + - + q: { _id: { $lte: 3 } } + limit: 0 + ordered: true + lsid: { $$sessionLsid: *session0 } + txnNumber: { $numberLong: '1' } + startTransaction: { $$exists: false } + autocommit: false + writeConcern: { $$exists: false } + commandName: delete + databaseName: *database_name + - + commandStartedEvent: + command: + commitTransaction: 1 + lsid: { $$sessionLsid: *session0 } + txnNumber: { $numberLong: '1' } + startTransaction: { $$exists: false } + autocommit: false + writeConcern: + w: majority + commandName: commitTransaction + databaseName: admin diff --git a/source/transactions/tests/unified/error-labels-blockConnection.json b/source/transactions/tests/unified/error-labels-blockConnection.json new file mode 100644 index 0000000000..8da04d1005 --- /dev/null +++ b/source/transactions/tests/unified/error-labels-blockConnection.json @@ -0,0 +1,235 @@ +{ + "description": "error-labels-blockConnection", + "schemaVersion": "1.3", + "runOnRequirements": [ + { + "minServerVersion": "4.2", + "topologies": [ + "replicaset", + "sharded", + "load-balanced" + ] + } + ], + "createEntities": [ + { + "client": { + "id": "client0", + "useMultipleMongoses": false, + "uriOptions": { + "socketTimeoutMS": 100 + }, + "observeEvents": [ + "commandStartedEvent" + ] + } + }, + { + "database": { + "id": "database0", + "client": "client0", + "databaseName": "transaction-tests" + } + }, + { + "collection": { + "id": "collection0", + "database": "database0", + "collectionName": "test" + } + }, + { + "session": { + "id": "session0", + "client": "client0" + } + } + ], + "initialData": [ + { + "collectionName": "test", + "databaseName": "transaction-tests", + "documents": [] + } + ], + "tests": [ + { + "description": "add RetryableWriteError and UnknownTransactionCommitResult labels to connection errors", + "operations": [ + { + "object": "testRunner", + "name": "failPoint", + "arguments": { + "client": "client0", + "failPoint": { + "configureFailPoint": "failCommand", + "mode": { + "times": 2 + }, + "data": { + "failCommands": [ + "commitTransaction" + ], + "blockConnection": true, + "blockTimeMS": 150 + } + } + } + }, + { + "object": "session0", + "name": "startTransaction" + }, + { + "object": "collection0", + "name": "insertOne", + "arguments": { + "session": "session0", + "document": { + "_id": 1 + } + }, + "expectResult": { + "$$unsetOrMatches": { + "insertedId": { + "$$unsetOrMatches": 1 + } + } + } + }, + { + "object": "session0", + "name": "commitTransaction", + "expectError": { + "errorLabelsContain": [ + "RetryableWriteError", + "UnknownTransactionCommitResult" + ], + "errorLabelsOmit": [ + "TransientTransactionError" + ] + } + }, + { + "object": "session0", + "name": "commitTransaction" + } + ], + "expectEvents": [ + { + "client": "client0", + "events": [ + { + "commandStartedEvent": { + "command": { + "insert": "test", + "documents": [ + { + "_id": 1 + } + ], + "ordered": true, + "readConcern": { + "$$exists": false + }, + "lsid": { + "$$sessionLsid": "session0" + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": true, + "autocommit": false, + "writeConcern": { + "$$exists": false + } + }, + "commandName": "insert", + "databaseName": "transaction-tests" + } + }, + { + "commandStartedEvent": { + "command": { + "commitTransaction": 1, + "lsid": { + "$$sessionLsid": "session0" + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": { + "$$exists": false + }, + "autocommit": false, + "writeConcern": { + "$$exists": false + } + }, + "commandName": "commitTransaction", + "databaseName": "admin" + } + }, + { + "commandStartedEvent": { + "command": { + "commitTransaction": 1, + "lsid": { + "$$sessionLsid": "session0" + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": { + "$$exists": false + }, + "autocommit": false, + "writeConcern": { + "w": "majority", + "wtimeout": 10000 + } + }, + "commandName": "commitTransaction", + "databaseName": "admin" + } + }, + { + "commandStartedEvent": { + "command": { + "commitTransaction": 1, + "lsid": { + "$$sessionLsid": "session0" + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": { + "$$exists": false + }, + "autocommit": false, + "writeConcern": { + "w": "majority", + "wtimeout": 10000 + } + }, + "commandName": "commitTransaction", + "databaseName": "admin" + } + } + ] + } + ], + "outcome": [ + { + "collectionName": "test", + "databaseName": "transaction-tests", + "documents": [ + { + "_id": 1 + } + ] + } + ] + } + ] +} diff --git a/source/transactions/tests/unified/error-labels-blockConnection.yml b/source/transactions/tests/unified/error-labels-blockConnection.yml new file mode 100644 index 0000000000..7fed7fc92b --- /dev/null +++ b/source/transactions/tests/unified/error-labels-blockConnection.yml @@ -0,0 +1,158 @@ +# This file contains a single test that should be in error-labels.yml. The test +# was moved from error-labels.yml during the spec work for client-side +# operations timeout because it uses the blockConnection parameter in +# failCommand, which is only available in server versions 4.2+. It should be +# merged back into error-labels.yml when that test file is ported to the +# unified test format as the format allows for per-test runOn requirements. +description: error-labels-blockConnection + +schemaVersion: '1.3' + +runOnRequirements: + - + minServerVersion: '4.2' + topologies: + - replicaset + - sharded + - load-balanced + +createEntities: + - + client: + id: &client0 client0 + useMultipleMongoses: false + uriOptions: + socketTimeoutMS: 100 + observeEvents: + - commandStartedEvent + - + database: + id: &database0 database0 + client: *client0 + databaseName: &database_name transaction-tests + - + collection: + id: &collection0 collection0 + database: *database0 + collectionName: &collection_name test + - + session: + id: &session0 session0 + client: *client0 + +initialData: + - + collectionName: *collection_name + databaseName: *database_name + documents: [] + +tests: + # This test previously used failCommand with closeConnection=true to force a + # network error, but this does not work after CSOT is implemented because + # network errors are retried indefinitely. It has been changed to use + # socketTimeoutMS with blockConnection to force a network error because + # drivers only retry socketTimeoutMS-related errors once rather than + # indefinitely. + - + description: 'add RetryableWriteError and UnknownTransactionCommitResult labels to connection errors' + operations: + - + object: testRunner + name: failPoint + arguments: + client: *client0 + failPoint: + # Drivers stop retrying after two socket timeouts that occur due to the use of socketTimeoutMS + configureFailPoint: failCommand + mode: { times: 2 } + data: + failCommands: + - commitTransaction + blockConnection: true + blockTimeMS: 150 + - + object: *session0 + name: startTransaction + - + object: *collection0 + name: insertOne + arguments: + session: *session0 + document: { _id: 1 } + expectResult: + $$unsetOrMatches: { insertedId: { $$unsetOrMatches: 1 } } + - + object: *session0 + name: commitTransaction + expectError: + errorLabelsContain: + - RetryableWriteError + - UnknownTransactionCommitResult + errorLabelsOmit: + - TransientTransactionError + - + object: *session0 + name: commitTransaction + expectEvents: + - + client: *client0 + events: + - + commandStartedEvent: + command: + insert: *collection_name + documents: + - { _id: 1 } + ordered: true + readConcern: { $$exists: false } + lsid: { $$sessionLsid: *session0 } + txnNumber: { $numberLong: '1' } + startTransaction: true + autocommit: false + writeConcern: { $$exists: false } + commandName: insert + databaseName: *database_name + - + commandStartedEvent: + command: + commitTransaction: 1 + lsid: { $$sessionLsid: *session0 } + txnNumber: { $numberLong: '1' } + startTransaction: { $$exists: false } + autocommit: false + writeConcern: { $$exists: false } + commandName: commitTransaction + databaseName: admin + - + commandStartedEvent: + command: + commitTransaction: 1 + lsid: { $$sessionLsid: *session0 } + txnNumber: { $numberLong: '1' } + startTransaction: { $$exists: false } + autocommit: false + # commitTransaction applies w:majority on retries + writeConcern: + w: majority + wtimeout: 10000 + commandName: commitTransaction + databaseName: admin + - + commandStartedEvent: + command: + commitTransaction: 1 + lsid: { $$sessionLsid: *session0 } + txnNumber: { $numberLong: '1' } + startTransaction: { $$exists: false } + autocommit: false + writeConcern: + w: majority + wtimeout: 10000 + commandName: commitTransaction + databaseName: admin + outcome: + - + collectionName: *collection_name + databaseName: *database_name + documents: + - { _id: 1 } diff --git a/source/transactions/tests/unified/error-labels-errorLabels.json b/source/transactions/tests/unified/error-labels-errorLabels.json new file mode 100644 index 0000000000..1f95ad3419 --- /dev/null +++ b/source/transactions/tests/unified/error-labels-errorLabels.json @@ -0,0 +1,423 @@ +{ + "description": "error-labels-errorLabels", + "schemaVersion": "1.4", + "runOnRequirements": [ + { + "minServerVersion": "4.3.1", + "serverless": "forbid", + "topologies": [ + "replicaset", + "sharded", + "load-balanced" + ] + } + ], + "createEntities": [ + { + "client": { + "id": "client0", + "useMultipleMongoses": false, + "observeEvents": [ + "commandStartedEvent" + ] + } + }, + { + "database": { + "id": "database0", + "client": "client0", + "databaseName": "transaction-tests" + } + }, + { + "collection": { + "id": "collection0", + "database": "database0", + "collectionName": "test" + } + }, + { + "session": { + "id": "session0", + "client": "client0" + } + } + ], + "initialData": [ + { + "collectionName": "test", + "databaseName": "transaction-tests", + "documents": [] + } + ], + "tests": [ + { + "description": "add RetryableWriteError and UnknownTransactionCommitResult labels to retryable commit errors", + "operations": [ + { + "object": "testRunner", + "name": "failPoint", + "arguments": { + "client": "client0", + "failPoint": { + "configureFailPoint": "failCommand", + "mode": { + "times": 2 + }, + "data": { + "failCommands": [ + "commitTransaction" + ], + "errorCode": 11602, + "errorLabels": [ + "RetryableWriteError" + ] + } + } + } + }, + { + "object": "session0", + "name": "startTransaction" + }, + { + "object": "collection0", + "name": "insertOne", + "arguments": { + "session": "session0", + "document": { + "_id": 1 + } + }, + "expectResult": { + "$$unsetOrMatches": { + "insertedId": { + "$$unsetOrMatches": 1 + } + } + } + }, + { + "object": "session0", + "name": "commitTransaction", + "expectError": { + "errorLabelsContain": [ + "RetryableWriteError", + "UnknownTransactionCommitResult" + ], + "errorLabelsOmit": [ + "TransientTransactionError" + ] + } + }, + { + "object": "session0", + "name": "commitTransaction" + } + ], + "expectEvents": [ + { + "client": "client0", + "events": [ + { + "commandStartedEvent": { + "command": { + "insert": "test", + "documents": [ + { + "_id": 1 + } + ], + "ordered": true, + "readConcern": { + "$$exists": false + }, + "lsid": { + "$$sessionLsid": "session0" + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": true, + "autocommit": false, + "writeConcern": { + "$$exists": false + } + }, + "commandName": "insert", + "databaseName": "transaction-tests" + } + }, + { + "commandStartedEvent": { + "command": { + "commitTransaction": 1, + "lsid": { + "$$sessionLsid": "session0" + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": { + "$$exists": false + }, + "autocommit": false, + "writeConcern": { + "$$exists": false + } + }, + "commandName": "commitTransaction", + "databaseName": "admin" + } + }, + { + "commandStartedEvent": { + "command": { + "commitTransaction": 1, + "lsid": { + "$$sessionLsid": "session0" + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": { + "$$exists": false + }, + "autocommit": false, + "writeConcern": { + "w": "majority", + "wtimeout": 10000 + } + }, + "commandName": "commitTransaction", + "databaseName": "admin" + } + }, + { + "commandStartedEvent": { + "command": { + "commitTransaction": 1, + "lsid": { + "$$sessionLsid": "session0" + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": { + "$$exists": false + }, + "autocommit": false, + "writeConcern": { + "w": "majority", + "wtimeout": 10000 + } + }, + "commandName": "commitTransaction", + "databaseName": "admin" + } + } + ] + } + ], + "outcome": [ + { + "collectionName": "test", + "databaseName": "transaction-tests", + "documents": [ + { + "_id": 1 + } + ] + } + ] + }, + { + "description": "add RetryableWriteError and UnknownTransactionCommitResult labels to writeConcernError ShutdownInProgress", + "operations": [ + { + "object": "testRunner", + "name": "failPoint", + "arguments": { + "client": "client0", + "failPoint": { + "configureFailPoint": "failCommand", + "mode": { + "times": 2 + }, + "data": { + "failCommands": [ + "commitTransaction" + ], + "errorLabels": [ + "RetryableWriteError" + ], + "writeConcernError": { + "code": 91, + "errmsg": "Replication is being shut down" + } + } + } + } + }, + { + "object": "session0", + "name": "startTransaction", + "arguments": { + "writeConcern": { + "w": "majority" + } + } + }, + { + "object": "collection0", + "name": "insertOne", + "arguments": { + "session": "session0", + "document": { + "_id": 1 + } + }, + "expectResult": { + "$$unsetOrMatches": { + "insertedId": { + "$$unsetOrMatches": 1 + } + } + } + }, + { + "object": "session0", + "name": "commitTransaction", + "expectError": { + "errorLabelsContain": [ + "RetryableWriteError", + "UnknownTransactionCommitResult" + ], + "errorLabelsOmit": [ + "TransientTransactionError" + ] + } + }, + { + "object": "session0", + "name": "commitTransaction" + } + ], + "expectEvents": [ + { + "client": "client0", + "events": [ + { + "commandStartedEvent": { + "command": { + "insert": "test", + "documents": [ + { + "_id": 1 + } + ], + "ordered": true, + "readConcern": { + "$$exists": false + }, + "lsid": { + "$$sessionLsid": "session0" + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": true, + "autocommit": false, + "writeConcern": { + "$$exists": false + } + }, + "commandName": "insert", + "databaseName": "transaction-tests" + } + }, + { + "commandStartedEvent": { + "command": { + "commitTransaction": 1, + "lsid": { + "$$sessionLsid": "session0" + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": { + "$$exists": false + }, + "autocommit": false, + "writeConcern": { + "w": "majority" + } + }, + "commandName": "commitTransaction", + "databaseName": "admin" + } + }, + { + "commandStartedEvent": { + "command": { + "commitTransaction": 1, + "lsid": { + "$$sessionLsid": "session0" + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": { + "$$exists": false + }, + "autocommit": false, + "writeConcern": { + "w": "majority", + "wtimeout": 10000 + } + }, + "commandName": "commitTransaction", + "databaseName": "admin" + } + }, + { + "commandStartedEvent": { + "command": { + "commitTransaction": 1, + "lsid": { + "$$sessionLsid": "session0" + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": { + "$$exists": false + }, + "autocommit": false, + "writeConcern": { + "w": "majority", + "wtimeout": 10000 + } + }, + "commandName": "commitTransaction", + "databaseName": "admin" + } + } + ] + } + ], + "outcome": [ + { + "collectionName": "test", + "databaseName": "transaction-tests", + "documents": [ + { + "_id": 1 + } + ] + } + ] + } + ] +} diff --git a/source/transactions/tests/unified/error-labels-errorLabels.yml b/source/transactions/tests/unified/error-labels-errorLabels.yml new file mode 100644 index 0000000000..4af816549d --- /dev/null +++ b/source/transactions/tests/unified/error-labels-errorLabels.yml @@ -0,0 +1,257 @@ +description: error-labels-errorLabels + +schemaVersion: '1.4' + +runOnRequirements: + - + minServerVersion: 4.3.1 # failCommand errorLabels option + # serverless proxy doesn't append error labels to errors in transactions + # caused by failpoints (CLOUDP-88216) + serverless: forbid + topologies: + - replicaset + - sharded + - load-balanced + +createEntities: + - + client: + id: &client0 client0 + useMultipleMongoses: false + observeEvents: + - commandStartedEvent + - + database: + id: &database0 database0 + client: *client0 + databaseName: &database_name transaction-tests + - + collection: + id: &collection0 collection0 + database: *database0 + collectionName: &collection_name test + - + session: + id: &session0 session0 + client: *client0 + +initialData: + - + collectionName: *collection_name + databaseName: *database_name + documents: [] + +tests: + - + description: 'add RetryableWriteError and UnknownTransactionCommitResult labels to retryable commit errors' + operations: + - + object: testRunner + name: failPoint + arguments: + client: *client0 + failPoint: + configureFailPoint: failCommand + mode: { times: 2 } + data: + failCommands: + - commitTransaction + errorCode: 11602 # InterruptedDueToReplStateChange + errorLabels: + - RetryableWriteError + - + object: *session0 + name: startTransaction + - + object: *collection0 + name: insertOne + arguments: + session: *session0 + document: { _id: 1 } + expectResult: + $$unsetOrMatches: { insertedId: { $$unsetOrMatches: 1 } } + - + object: *session0 + name: commitTransaction + expectError: + errorLabelsContain: + - RetryableWriteError + - UnknownTransactionCommitResult + errorLabelsOmit: + - TransientTransactionError + - + object: *session0 + name: commitTransaction + expectEvents: + - + client: *client0 + events: + - + commandStartedEvent: + command: + insert: *collection_name + documents: + - { _id: 1 } + ordered: true + readConcern: { $$exists: false } + lsid: { $$sessionLsid: *session0 } + txnNumber: { $numberLong: '1' } + startTransaction: true + autocommit: false + writeConcern: { $$exists: false } + commandName: insert + databaseName: *database_name + - + commandStartedEvent: + command: + commitTransaction: 1 + lsid: { $$sessionLsid: *session0 } + txnNumber: { $numberLong: '1' } + startTransaction: { $$exists: false } + autocommit: false + writeConcern: { $$exists: false } + commandName: commitTransaction + databaseName: admin + - + commandStartedEvent: + command: + commitTransaction: 1 + lsid: { $$sessionLsid: *session0 } + txnNumber: { $numberLong: '1' } + startTransaction: { $$exists: false } + autocommit: false + # commitTransaction applies w:majority on retries + writeConcern: + w: majority + wtimeout: 10000 + commandName: commitTransaction + databaseName: admin + - + commandStartedEvent: + command: + commitTransaction: 1 + lsid: { $$sessionLsid: *session0 } + txnNumber: { $numberLong: '1' } + startTransaction: { $$exists: false } + autocommit: false + writeConcern: + w: majority + wtimeout: 10000 + commandName: commitTransaction + databaseName: admin + outcome: + - + collectionName: *collection_name + databaseName: *database_name + documents: + - { _id: 1 } + - + description: 'add RetryableWriteError and UnknownTransactionCommitResult labels to writeConcernError ShutdownInProgress' + operations: + - + object: testRunner + name: failPoint + arguments: + client: *client0 + failPoint: + configureFailPoint: failCommand + mode: { times: 2 } + data: + failCommands: + - commitTransaction + errorLabels: + - RetryableWriteError + writeConcernError: + code: 91 + errmsg: 'Replication is being shut down' + - + object: *session0 + name: startTransaction + arguments: + writeConcern: + w: majority + - + object: *collection0 + name: insertOne + arguments: + session: *session0 + document: { _id: 1 } + expectResult: + $$unsetOrMatches: { insertedId: { $$unsetOrMatches: 1 } } + - + object: *session0 + name: commitTransaction + expectError: + errorLabelsContain: + - RetryableWriteError + - UnknownTransactionCommitResult + errorLabelsOmit: + - TransientTransactionError + - + object: *session0 + name: commitTransaction + expectEvents: + - + client: *client0 + events: + - + commandStartedEvent: + command: + insert: *collection_name + documents: + - { _id: 1 } + ordered: true + readConcern: { $$exists: false } + lsid: { $$sessionLsid: *session0 } + txnNumber: { $numberLong: '1' } + startTransaction: true + autocommit: false + writeConcern: { $$exists: false } + commandName: insert + databaseName: *database_name + - + commandStartedEvent: + command: + commitTransaction: 1 + lsid: { $$sessionLsid: *session0 } + txnNumber: { $numberLong: '1' } + startTransaction: { $$exists: false } + autocommit: false + writeConcern: + w: majority + commandName: commitTransaction + databaseName: admin + - + commandStartedEvent: + command: + commitTransaction: 1 + lsid: { $$sessionLsid: *session0 } + txnNumber: { $numberLong: '1' } + startTransaction: { $$exists: false } + autocommit: false + # commitTransaction applies w:majority on retries + writeConcern: + w: majority + wtimeout: 10000 + commandName: commitTransaction + databaseName: admin + - + commandStartedEvent: + command: + commitTransaction: 1 + lsid: { $$sessionLsid: *session0 } + txnNumber: { $numberLong: '1' } + startTransaction: { $$exists: false } + autocommit: false + # commitTransaction applies w:majority on retries + writeConcern: + w: majority + wtimeout: 10000 + commandName: commitTransaction + databaseName: admin + outcome: + - + collectionName: *collection_name + databaseName: *database_name + documents: + - { _id: 1 } diff --git a/source/transactions/tests/unified/error-labels.json b/source/transactions/tests/unified/error-labels.json new file mode 100644 index 0000000000..be8df10ed3 --- /dev/null +++ b/source/transactions/tests/unified/error-labels.json @@ -0,0 +1,2264 @@ +{ + "description": "error-labels", + "schemaVersion": "1.4", + "runOnRequirements": [ + { + "minServerVersion": "4.0", + "topologies": [ + "replicaset" + ] + }, + { + "minServerVersion": "4.1.8", + "serverless": "forbid", + "topologies": [ + "sharded", + "load-balanced" + ] + } + ], + "createEntities": [ + { + "client": { + "id": "client0", + "useMultipleMongoses": false, + "observeEvents": [ + "commandStartedEvent" + ] + } + }, + { + "database": { + "id": "database0", + "client": "client0", + "databaseName": "transaction-tests" + } + }, + { + "collection": { + "id": "collection0", + "database": "database0", + "collectionName": "test" + } + }, + { + "session": { + "id": "session0", + "client": "client0" + } + } + ], + "initialData": [ + { + "collectionName": "test", + "databaseName": "transaction-tests", + "documents": [] + } + ], + "tests": [ + { + "description": "DuplicateKey errors do not contain transient label", + "operations": [ + { + "object": "session0", + "name": "startTransaction" + }, + { + "object": "collection0", + "name": "insertMany", + "arguments": { + "session": "session0", + "documents": [ + { + "_id": 1 + }, + { + "_id": 1 + } + ] + }, + "expectError": { + "errorLabelsOmit": [ + "TransientTransactionError", + "UnknownTransactionCommitResult" + ], + "errorContains": "E11000" + } + }, + { + "object": "session0", + "name": "abortTransaction" + } + ], + "expectEvents": [ + { + "client": "client0", + "events": [ + { + "commandStartedEvent": { + "command": { + "insert": "test", + "documents": [ + { + "_id": 1 + }, + { + "_id": 1 + } + ], + "ordered": true, + "readConcern": { + "$$exists": false + }, + "lsid": { + "$$sessionLsid": "session0" + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": true, + "autocommit": false, + "writeConcern": { + "$$exists": false + } + }, + "commandName": "insert", + "databaseName": "transaction-tests" + } + }, + { + "commandStartedEvent": { + "command": { + "abortTransaction": 1, + "lsid": { + "$$sessionLsid": "session0" + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": { + "$$exists": false + }, + "autocommit": false, + "writeConcern": { + "$$exists": false + } + }, + "commandName": "abortTransaction", + "databaseName": "admin" + } + } + ] + } + ], + "outcome": [ + { + "collectionName": "test", + "databaseName": "transaction-tests", + "documents": [] + } + ] + }, + { + "description": "NotWritablePrimary errors contain transient label", + "operations": [ + { + "object": "testRunner", + "name": "failPoint", + "arguments": { + "client": "client0", + "failPoint": { + "configureFailPoint": "failCommand", + "mode": { + "times": 1 + }, + "data": { + "failCommands": [ + "insert" + ], + "errorCode": 10107 + } + } + } + }, + { + "object": "session0", + "name": "startTransaction" + }, + { + "object": "collection0", + "name": "insertOne", + "arguments": { + "session": "session0", + "document": { + "_id": 1 + } + }, + "expectError": { + "errorLabelsContain": [ + "TransientTransactionError" + ], + "errorLabelsOmit": [ + "RetryableWriteError", + "UnknownTransactionCommitResult" + ] + } + }, + { + "object": "session0", + "name": "abortTransaction" + } + ], + "expectEvents": [ + { + "client": "client0", + "events": [ + { + "commandStartedEvent": { + "command": { + "insert": "test", + "documents": [ + { + "_id": 1 + } + ], + "ordered": true, + "readConcern": { + "$$exists": false + }, + "lsid": { + "$$sessionLsid": "session0" + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": true, + "autocommit": false, + "writeConcern": { + "$$exists": false + } + }, + "commandName": "insert", + "databaseName": "transaction-tests" + } + }, + { + "commandStartedEvent": { + "command": { + "abortTransaction": 1, + "lsid": { + "$$sessionLsid": "session0" + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": { + "$$exists": false + }, + "autocommit": false, + "writeConcern": { + "$$exists": false + } + }, + "commandName": "abortTransaction", + "databaseName": "admin" + } + } + ] + } + ], + "outcome": [ + { + "collectionName": "test", + "databaseName": "transaction-tests", + "documents": [] + } + ] + }, + { + "description": "WriteConflict errors contain transient label", + "operations": [ + { + "object": "testRunner", + "name": "failPoint", + "arguments": { + "client": "client0", + "failPoint": { + "configureFailPoint": "failCommand", + "mode": { + "times": 1 + }, + "data": { + "failCommands": [ + "insert" + ], + "errorCode": 112 + } + } + } + }, + { + "object": "session0", + "name": "startTransaction" + }, + { + "object": "collection0", + "name": "insertOne", + "arguments": { + "session": "session0", + "document": { + "_id": 1 + } + }, + "expectError": { + "errorLabelsContain": [ + "TransientTransactionError" + ], + "errorLabelsOmit": [ + "RetryableWriteError", + "UnknownTransactionCommitResult" + ] + } + }, + { + "object": "session0", + "name": "abortTransaction" + } + ], + "expectEvents": [ + { + "client": "client0", + "events": [ + { + "commandStartedEvent": { + "command": { + "insert": "test", + "documents": [ + { + "_id": 1 + } + ], + "ordered": true, + "readConcern": { + "$$exists": false + }, + "lsid": { + "$$sessionLsid": "session0" + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": true, + "autocommit": false, + "writeConcern": { + "$$exists": false + } + }, + "commandName": "insert", + "databaseName": "transaction-tests" + } + }, + { + "commandStartedEvent": { + "command": { + "abortTransaction": 1, + "lsid": { + "$$sessionLsid": "session0" + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": { + "$$exists": false + }, + "autocommit": false, + "writeConcern": { + "$$exists": false + } + }, + "commandName": "abortTransaction", + "databaseName": "admin" + } + } + ] + } + ], + "outcome": [ + { + "collectionName": "test", + "databaseName": "transaction-tests", + "documents": [] + } + ] + }, + { + "description": "NoSuchTransaction errors contain transient label", + "operations": [ + { + "object": "testRunner", + "name": "failPoint", + "arguments": { + "client": "client0", + "failPoint": { + "configureFailPoint": "failCommand", + "mode": { + "times": 1 + }, + "data": { + "failCommands": [ + "insert" + ], + "errorCode": 251 + } + } + } + }, + { + "object": "session0", + "name": "startTransaction" + }, + { + "object": "collection0", + "name": "insertOne", + "arguments": { + "session": "session0", + "document": { + "_id": 1 + } + }, + "expectError": { + "errorLabelsContain": [ + "TransientTransactionError" + ], + "errorLabelsOmit": [ + "RetryableWriteError", + "UnknownTransactionCommitResult" + ] + } + }, + { + "object": "session0", + "name": "abortTransaction" + } + ], + "expectEvents": [ + { + "client": "client0", + "events": [ + { + "commandStartedEvent": { + "command": { + "insert": "test", + "documents": [ + { + "_id": 1 + } + ], + "ordered": true, + "readConcern": { + "$$exists": false + }, + "lsid": { + "$$sessionLsid": "session0" + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": true, + "autocommit": false, + "writeConcern": { + "$$exists": false + } + }, + "commandName": "insert", + "databaseName": "transaction-tests" + } + }, + { + "commandStartedEvent": { + "command": { + "abortTransaction": 1, + "lsid": { + "$$sessionLsid": "session0" + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": { + "$$exists": false + }, + "autocommit": false, + "writeConcern": { + "$$exists": false + } + }, + "commandName": "abortTransaction", + "databaseName": "admin" + } + } + ] + } + ], + "outcome": [ + { + "collectionName": "test", + "databaseName": "transaction-tests", + "documents": [] + } + ] + }, + { + "description": "NoSuchTransaction errors on commit contain transient label", + "operations": [ + { + "object": "testRunner", + "name": "failPoint", + "arguments": { + "client": "client0", + "failPoint": { + "configureFailPoint": "failCommand", + "mode": { + "times": 1 + }, + "data": { + "failCommands": [ + "commitTransaction" + ], + "errorCode": 251 + } + } + } + }, + { + "object": "session0", + "name": "startTransaction" + }, + { + "object": "collection0", + "name": "insertOne", + "arguments": { + "session": "session0", + "document": { + "_id": 1 + } + }, + "expectResult": { + "$$unsetOrMatches": { + "insertedId": { + "$$unsetOrMatches": 1 + } + } + } + }, + { + "object": "session0", + "name": "commitTransaction", + "expectError": { + "errorLabelsContain": [ + "TransientTransactionError" + ], + "errorLabelsOmit": [ + "RetryableWriteError", + "UnknownTransactionCommitResult" + ] + } + } + ], + "expectEvents": [ + { + "client": "client0", + "events": [ + { + "commandStartedEvent": { + "command": { + "insert": "test", + "documents": [ + { + "_id": 1 + } + ], + "ordered": true, + "readConcern": { + "$$exists": false + }, + "lsid": { + "$$sessionLsid": "session0" + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": true, + "autocommit": false, + "writeConcern": { + "$$exists": false + } + }, + "commandName": "insert", + "databaseName": "transaction-tests" + } + }, + { + "commandStartedEvent": { + "command": { + "commitTransaction": 1, + "lsid": { + "$$sessionLsid": "session0" + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": { + "$$exists": false + }, + "autocommit": false, + "writeConcern": { + "$$exists": false + } + }, + "commandName": "commitTransaction", + "databaseName": "admin" + } + } + ] + } + ], + "outcome": [ + { + "collectionName": "test", + "databaseName": "transaction-tests", + "documents": [] + } + ] + }, + { + "description": "add TransientTransactionError label to connection errors, but do not add RetryableWriteError label", + "operations": [ + { + "object": "testRunner", + "name": "failPoint", + "arguments": { + "client": "client0", + "failPoint": { + "configureFailPoint": "failCommand", + "mode": { + "times": 4 + }, + "data": { + "failCommands": [ + "insert", + "find", + "aggregate", + "distinct" + ], + "closeConnection": true + } + } + } + }, + { + "object": "session0", + "name": "startTransaction" + }, + { + "object": "collection0", + "name": "insertOne", + "arguments": { + "session": "session0", + "document": { + "_id": 1 + } + }, + "expectError": { + "errorLabelsContain": [ + "TransientTransactionError" + ], + "errorLabelsOmit": [ + "RetryableWriteError", + "UnknownTransactionCommitResult" + ] + } + }, + { + "object": "collection0", + "name": "find", + "arguments": { + "filter": {}, + "session": "session0" + }, + "expectError": { + "errorLabelsContain": [ + "TransientTransactionError" + ], + "errorLabelsOmit": [ + "RetryableWriteError", + "UnknownTransactionCommitResult" + ] + } + }, + { + "object": "collection0", + "name": "aggregate", + "arguments": { + "pipeline": [ + { + "$project": { + "_id": 1 + } + } + ], + "session": "session0" + }, + "expectError": { + "errorLabelsContain": [ + "TransientTransactionError" + ], + "errorLabelsOmit": [ + "RetryableWriteError", + "UnknownTransactionCommitResult" + ] + } + }, + { + "object": "collection0", + "name": "distinct", + "arguments": { + "fieldName": "_id", + "filter": {}, + "session": "session0" + }, + "expectError": { + "errorLabelsContain": [ + "TransientTransactionError" + ], + "errorLabelsOmit": [ + "RetryableWriteError", + "UnknownTransactionCommitResult" + ] + } + }, + { + "object": "session0", + "name": "abortTransaction" + } + ], + "expectEvents": [ + { + "client": "client0", + "events": [ + { + "commandStartedEvent": { + "command": { + "insert": "test", + "documents": [ + { + "_id": 1 + } + ], + "ordered": true, + "readConcern": { + "$$exists": false + }, + "lsid": { + "$$sessionLsid": "session0" + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": true, + "autocommit": false, + "writeConcern": { + "$$exists": false + } + }, + "commandName": "insert", + "databaseName": "transaction-tests" + } + }, + { + "commandStartedEvent": { + "command": { + "find": "test", + "readConcern": { + "$$exists": false + }, + "lsid": { + "$$sessionLsid": "session0" + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": { + "$$exists": false + }, + "autocommit": false + }, + "commandName": "find", + "databaseName": "transaction-tests" + } + }, + { + "commandStartedEvent": { + "command": { + "aggregate": "test", + "pipeline": [ + { + "$project": { + "_id": 1 + } + } + ], + "cursor": {}, + "readConcern": { + "$$exists": false + }, + "lsid": { + "$$sessionLsid": "session0" + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": { + "$$exists": false + }, + "autocommit": false + }, + "commandName": "aggregate", + "databaseName": "transaction-tests" + } + }, + { + "commandStartedEvent": { + "command": { + "distinct": "test", + "key": "_id", + "lsid": { + "$$sessionLsid": "session0" + }, + "readConcern": { + "$$exists": false + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": { + "$$exists": false + }, + "autocommit": false + }, + "commandName": "distinct", + "databaseName": "transaction-tests" + } + }, + { + "commandStartedEvent": { + "command": { + "abortTransaction": 1, + "lsid": { + "$$sessionLsid": "session0" + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": { + "$$exists": false + }, + "autocommit": false, + "writeConcern": { + "$$exists": false + } + }, + "commandName": "abortTransaction", + "databaseName": "admin" + } + } + ] + } + ], + "outcome": [ + { + "collectionName": "test", + "databaseName": "transaction-tests", + "documents": [] + } + ] + }, + { + "description": "add RetryableWriteError and UnknownTransactionCommitResult labels to connection errors", + "operations": [ + { + "object": "testRunner", + "name": "failPoint", + "arguments": { + "client": "client0", + "failPoint": { + "configureFailPoint": "failCommand", + "mode": { + "times": 2 + }, + "data": { + "failCommands": [ + "commitTransaction" + ], + "closeConnection": true + } + } + } + }, + { + "object": "session0", + "name": "startTransaction" + }, + { + "object": "collection0", + "name": "insertOne", + "arguments": { + "session": "session0", + "document": { + "_id": 1 + } + }, + "expectResult": { + "$$unsetOrMatches": { + "insertedId": { + "$$unsetOrMatches": 1 + } + } + } + }, + { + "object": "session0", + "name": "commitTransaction", + "expectError": { + "errorLabelsContain": [ + "RetryableWriteError", + "UnknownTransactionCommitResult" + ], + "errorLabelsOmit": [ + "TransientTransactionError" + ] + } + }, + { + "object": "session0", + "name": "commitTransaction" + } + ], + "expectEvents": [ + { + "client": "client0", + "events": [ + { + "commandStartedEvent": { + "command": { + "insert": "test", + "documents": [ + { + "_id": 1 + } + ], + "ordered": true, + "readConcern": { + "$$exists": false + }, + "lsid": { + "$$sessionLsid": "session0" + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": true, + "autocommit": false, + "writeConcern": { + "$$exists": false + } + }, + "commandName": "insert", + "databaseName": "transaction-tests" + } + }, + { + "commandStartedEvent": { + "command": { + "commitTransaction": 1, + "lsid": { + "$$sessionLsid": "session0" + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": { + "$$exists": false + }, + "autocommit": false, + "writeConcern": { + "$$exists": false + } + }, + "commandName": "commitTransaction", + "databaseName": "admin" + } + }, + { + "commandStartedEvent": { + "command": { + "commitTransaction": 1, + "lsid": { + "$$sessionLsid": "session0" + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": { + "$$exists": false + }, + "autocommit": false, + "writeConcern": { + "w": "majority", + "wtimeout": 10000 + } + }, + "commandName": "commitTransaction", + "databaseName": "admin" + } + }, + { + "commandStartedEvent": { + "command": { + "commitTransaction": 1, + "lsid": { + "$$sessionLsid": "session0" + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": { + "$$exists": false + }, + "autocommit": false, + "writeConcern": { + "w": "majority", + "wtimeout": 10000 + } + }, + "commandName": "commitTransaction", + "databaseName": "admin" + } + } + ] + } + ], + "outcome": [ + { + "collectionName": "test", + "databaseName": "transaction-tests", + "documents": [ + { + "_id": 1 + } + ] + } + ] + }, + { + "description": "do not add RetryableWriteError label to writeConcernError ShutdownInProgress that occurs within transaction", + "operations": [ + { + "object": "testRunner", + "name": "failPoint", + "arguments": { + "client": "client0", + "failPoint": { + "configureFailPoint": "failCommand", + "mode": { + "times": 1 + }, + "data": { + "failCommands": [ + "insert" + ], + "writeConcernError": { + "code": 91, + "errmsg": "Replication is being shut down" + } + } + } + } + }, + { + "object": "session0", + "name": "startTransaction", + "arguments": { + "writeConcern": { + "w": "majority" + } + } + }, + { + "object": "collection0", + "name": "insertOne", + "arguments": { + "session": "session0", + "document": { + "_id": 1 + } + }, + "expectError": { + "errorLabelsOmit": [ + "RetryableWriteError", + "TransientTransactionError", + "UnknownTransactionCommitResult" + ] + } + }, + { + "object": "session0", + "name": "abortTransaction" + } + ], + "expectEvents": [ + { + "client": "client0", + "events": [ + { + "commandStartedEvent": { + "command": { + "insert": "test", + "documents": [ + { + "_id": 1 + } + ], + "ordered": true, + "readConcern": { + "$$exists": false + }, + "lsid": { + "$$sessionLsid": "session0" + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": true, + "autocommit": false + }, + "commandName": "insert", + "databaseName": "transaction-tests" + } + }, + { + "commandStartedEvent": { + "command": { + "abortTransaction": 1, + "lsid": { + "$$sessionLsid": "session0" + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": { + "$$exists": false + }, + "autocommit": false + }, + "commandName": "abortTransaction", + "databaseName": "admin" + } + } + ] + } + ], + "outcome": [ + { + "collectionName": "test", + "databaseName": "transaction-tests", + "documents": [] + } + ] + }, + { + "description": "add UnknownTransactionCommitResult label to writeConcernError WriteConcernFailed", + "operations": [ + { + "object": "testRunner", + "name": "failPoint", + "arguments": { + "client": "client0", + "failPoint": { + "configureFailPoint": "failCommand", + "mode": { + "times": 1 + }, + "data": { + "failCommands": [ + "commitTransaction" + ], + "writeConcernError": { + "code": 64, + "errmsg": "multiple errors reported" + } + } + } + } + }, + { + "object": "session0", + "name": "startTransaction", + "arguments": { + "writeConcern": { + "w": "majority" + } + } + }, + { + "object": "collection0", + "name": "insertOne", + "arguments": { + "session": "session0", + "document": { + "_id": 1 + } + }, + "expectResult": { + "$$unsetOrMatches": { + "insertedId": { + "$$unsetOrMatches": 1 + } + } + } + }, + { + "object": "session0", + "name": "commitTransaction", + "expectError": { + "errorLabelsContain": [ + "UnknownTransactionCommitResult" + ], + "errorLabelsOmit": [ + "RetryableWriteError", + "TransientTransactionError" + ] + } + }, + { + "object": "session0", + "name": "commitTransaction" + } + ], + "expectEvents": [ + { + "client": "client0", + "events": [ + { + "commandStartedEvent": { + "command": { + "insert": "test", + "documents": [ + { + "_id": 1 + } + ], + "ordered": true, + "readConcern": { + "$$exists": false + }, + "lsid": { + "$$sessionLsid": "session0" + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": true, + "autocommit": false, + "writeConcern": { + "$$exists": false + } + }, + "commandName": "insert", + "databaseName": "transaction-tests" + } + }, + { + "commandStartedEvent": { + "command": { + "commitTransaction": 1, + "lsid": { + "$$sessionLsid": "session0" + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": { + "$$exists": false + }, + "autocommit": false, + "writeConcern": { + "w": "majority" + } + }, + "commandName": "commitTransaction", + "databaseName": "admin" + } + }, + { + "commandStartedEvent": { + "command": { + "commitTransaction": 1, + "lsid": { + "$$sessionLsid": "session0" + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": { + "$$exists": false + }, + "autocommit": false, + "writeConcern": { + "w": "majority", + "wtimeout": 10000 + } + }, + "commandName": "commitTransaction", + "databaseName": "admin" + } + } + ] + } + ], + "outcome": [ + { + "collectionName": "test", + "databaseName": "transaction-tests", + "documents": [ + { + "_id": 1 + } + ] + } + ] + }, + { + "description": "add UnknownTransactionCommitResult label to writeConcernError WriteConcernFailed with wtimeout", + "operations": [ + { + "object": "testRunner", + "name": "failPoint", + "arguments": { + "client": "client0", + "failPoint": { + "configureFailPoint": "failCommand", + "mode": { + "times": 1 + }, + "data": { + "failCommands": [ + "commitTransaction" + ], + "writeConcernError": { + "code": 64, + "codeName": "WriteConcernFailed", + "errmsg": "waiting for replication timed out", + "errInfo": { + "wtimeout": true + } + } + } + } + } + }, + { + "object": "session0", + "name": "startTransaction", + "arguments": { + "writeConcern": { + "w": "majority" + } + } + }, + { + "object": "collection0", + "name": "insertOne", + "arguments": { + "session": "session0", + "document": { + "_id": 1 + } + }, + "expectResult": { + "$$unsetOrMatches": { + "insertedId": { + "$$unsetOrMatches": 1 + } + } + } + }, + { + "object": "session0", + "name": "commitTransaction", + "expectError": { + "errorLabelsContain": [ + "UnknownTransactionCommitResult" + ], + "errorLabelsOmit": [ + "RetryableWriteError", + "TransientTransactionError" + ] + } + }, + { + "object": "session0", + "name": "commitTransaction" + } + ], + "expectEvents": [ + { + "client": "client0", + "events": [ + { + "commandStartedEvent": { + "command": { + "insert": "test", + "documents": [ + { + "_id": 1 + } + ], + "ordered": true, + "readConcern": { + "$$exists": false + }, + "lsid": { + "$$sessionLsid": "session0" + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": true, + "autocommit": false, + "writeConcern": { + "$$exists": false + } + }, + "commandName": "insert", + "databaseName": "transaction-tests" + } + }, + { + "commandStartedEvent": { + "command": { + "commitTransaction": 1, + "lsid": { + "$$sessionLsid": "session0" + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": { + "$$exists": false + }, + "autocommit": false, + "writeConcern": { + "w": "majority" + } + }, + "commandName": "commitTransaction", + "databaseName": "admin" + } + }, + { + "commandStartedEvent": { + "command": { + "commitTransaction": 1, + "lsid": { + "$$sessionLsid": "session0" + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": { + "$$exists": false + }, + "autocommit": false, + "writeConcern": { + "w": "majority", + "wtimeout": 10000 + } + }, + "commandName": "commitTransaction", + "databaseName": "admin" + } + } + ] + } + ], + "outcome": [ + { + "collectionName": "test", + "databaseName": "transaction-tests", + "documents": [ + { + "_id": 1 + } + ] + } + ] + }, + { + "description": "omit UnknownTransactionCommitResult label from writeConcernError UnsatisfiableWriteConcern", + "operations": [ + { + "object": "testRunner", + "name": "failPoint", + "arguments": { + "client": "client0", + "failPoint": { + "configureFailPoint": "failCommand", + "mode": { + "times": 1 + }, + "data": { + "failCommands": [ + "commitTransaction" + ], + "writeConcernError": { + "code": 100, + "errmsg": "Not enough data-bearing nodes" + } + } + } + } + }, + { + "object": "session0", + "name": "startTransaction", + "arguments": { + "writeConcern": { + "w": "majority" + } + } + }, + { + "object": "collection0", + "name": "insertOne", + "arguments": { + "session": "session0", + "document": { + "_id": 1 + } + }, + "expectResult": { + "$$unsetOrMatches": { + "insertedId": { + "$$unsetOrMatches": 1 + } + } + } + }, + { + "object": "session0", + "name": "commitTransaction", + "expectError": { + "errorLabelsOmit": [ + "RetryableWriteError", + "TransientTransactionError", + "UnknownTransactionCommitResult" + ] + } + } + ], + "expectEvents": [ + { + "client": "client0", + "events": [ + { + "commandStartedEvent": { + "command": { + "insert": "test", + "documents": [ + { + "_id": 1 + } + ], + "ordered": true, + "readConcern": { + "$$exists": false + }, + "lsid": { + "$$sessionLsid": "session0" + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": true, + "autocommit": false, + "writeConcern": { + "$$exists": false + } + }, + "commandName": "insert", + "databaseName": "transaction-tests" + } + }, + { + "commandStartedEvent": { + "command": { + "commitTransaction": 1, + "lsid": { + "$$sessionLsid": "session0" + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": { + "$$exists": false + }, + "autocommit": false, + "writeConcern": { + "w": "majority" + } + }, + "commandName": "commitTransaction", + "databaseName": "admin" + } + } + ] + } + ], + "outcome": [ + { + "collectionName": "test", + "databaseName": "transaction-tests", + "documents": [ + { + "_id": 1 + } + ] + } + ] + }, + { + "description": "omit UnknownTransactionCommitResult label from writeConcernError UnknownReplWriteConcern", + "operations": [ + { + "object": "testRunner", + "name": "failPoint", + "arguments": { + "client": "client0", + "failPoint": { + "configureFailPoint": "failCommand", + "mode": { + "times": 1 + }, + "data": { + "failCommands": [ + "commitTransaction" + ], + "writeConcernError": { + "code": 79, + "errmsg": "No write concern mode named 'blah' found in replica set configuration" + } + } + } + } + }, + { + "object": "session0", + "name": "startTransaction", + "arguments": { + "writeConcern": { + "w": "majority" + } + } + }, + { + "object": "collection0", + "name": "insertOne", + "arguments": { + "session": "session0", + "document": { + "_id": 1 + } + }, + "expectResult": { + "$$unsetOrMatches": { + "insertedId": { + "$$unsetOrMatches": 1 + } + } + } + }, + { + "object": "session0", + "name": "commitTransaction", + "expectError": { + "errorLabelsOmit": [ + "RetryableWriteConcern", + "TransientTransactionError", + "UnknownTransactionCommitResult" + ] + } + } + ], + "expectEvents": [ + { + "client": "client0", + "events": [ + { + "commandStartedEvent": { + "command": { + "insert": "test", + "documents": [ + { + "_id": 1 + } + ], + "ordered": true, + "readConcern": { + "$$exists": false + }, + "lsid": { + "$$sessionLsid": "session0" + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": true, + "autocommit": false, + "writeConcern": { + "$$exists": false + } + }, + "commandName": "insert", + "databaseName": "transaction-tests" + } + }, + { + "commandStartedEvent": { + "command": { + "commitTransaction": 1, + "lsid": { + "$$sessionLsid": "session0" + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": { + "$$exists": false + }, + "autocommit": false, + "writeConcern": { + "w": "majority" + } + }, + "commandName": "commitTransaction", + "databaseName": "admin" + } + } + ] + } + ], + "outcome": [ + { + "collectionName": "test", + "databaseName": "transaction-tests", + "documents": [ + { + "_id": 1 + } + ] + } + ] + }, + { + "description": "do not add UnknownTransactionCommitResult label to MaxTimeMSExpired inside transactions", + "operations": [ + { + "object": "testRunner", + "name": "failPoint", + "arguments": { + "client": "client0", + "failPoint": { + "configureFailPoint": "failCommand", + "mode": { + "times": 1 + }, + "data": { + "failCommands": [ + "aggregate" + ], + "errorCode": 50 + } + } + } + }, + { + "object": "session0", + "name": "startTransaction" + }, + { + "object": "collection0", + "name": "insertOne", + "arguments": { + "session": "session0", + "document": { + "_id": 1 + } + }, + "expectResult": { + "$$unsetOrMatches": { + "insertedId": { + "$$unsetOrMatches": 1 + } + } + } + }, + { + "object": "collection0", + "name": "aggregate", + "arguments": { + "pipeline": [ + { + "$project": { + "_id": 1 + } + } + ], + "maxTimeMS": 60000, + "session": "session0" + }, + "expectError": { + "errorLabelsOmit": [ + "RetryableWriteError", + "UnknownTransactionCommitResult", + "TransientTransactionError" + ] + } + }, + { + "object": "session0", + "name": "abortTransaction" + } + ], + "expectEvents": [ + { + "client": "client0", + "events": [ + { + "commandStartedEvent": { + "command": { + "insert": "test", + "documents": [ + { + "_id": 1 + } + ], + "ordered": true, + "readConcern": { + "$$exists": false + }, + "lsid": { + "$$sessionLsid": "session0" + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": true, + "autocommit": false, + "writeConcern": { + "$$exists": false + } + }, + "commandName": "insert", + "databaseName": "transaction-tests" + } + }, + { + "commandStartedEvent": { + "command": { + "aggregate": "test", + "pipeline": [ + { + "$project": { + "_id": 1 + } + } + ], + "cursor": {}, + "readConcern": { + "$$exists": false + }, + "lsid": { + "$$sessionLsid": "session0" + }, + "txnNumber": { + "$numberLong": "1" + }, + "autocommit": false, + "maxTimeMS": 60000 + }, + "commandName": "aggregate", + "databaseName": "transaction-tests" + } + }, + { + "commandStartedEvent": { + "command": { + "abortTransaction": 1, + "lsid": { + "$$sessionLsid": "session0" + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": { + "$$exists": false + }, + "autocommit": false, + "writeConcern": { + "$$exists": false + } + }, + "commandName": "abortTransaction", + "databaseName": "admin" + } + } + ] + } + ], + "outcome": [ + { + "collectionName": "test", + "databaseName": "transaction-tests", + "documents": [] + } + ] + }, + { + "description": "add UnknownTransactionCommitResult label to MaxTimeMSExpired", + "operations": [ + { + "object": "testRunner", + "name": "failPoint", + "arguments": { + "client": "client0", + "failPoint": { + "configureFailPoint": "failCommand", + "mode": { + "times": 1 + }, + "data": { + "failCommands": [ + "commitTransaction" + ], + "errorCode": 50 + } + } + } + }, + { + "object": "session0", + "name": "startTransaction", + "arguments": { + "writeConcern": { + "w": "majority" + }, + "maxCommitTimeMS": 60000 + } + }, + { + "object": "collection0", + "name": "insertOne", + "arguments": { + "session": "session0", + "document": { + "_id": 1 + } + }, + "expectResult": { + "$$unsetOrMatches": { + "insertedId": { + "$$unsetOrMatches": 1 + } + } + } + }, + { + "object": "session0", + "name": "commitTransaction", + "expectError": { + "errorLabelsContain": [ + "UnknownTransactionCommitResult" + ], + "errorLabelsOmit": [ + "RetryableWriteError", + "TransientTransactionError" + ] + } + }, + { + "object": "session0", + "name": "commitTransaction" + } + ], + "expectEvents": [ + { + "client": "client0", + "events": [ + { + "commandStartedEvent": { + "command": { + "insert": "test", + "documents": [ + { + "_id": 1 + } + ], + "ordered": true, + "readConcern": { + "$$exists": false + }, + "lsid": { + "$$sessionLsid": "session0" + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": true, + "autocommit": false, + "writeConcern": { + "$$exists": false + } + }, + "commandName": "insert", + "databaseName": "transaction-tests" + } + }, + { + "commandStartedEvent": { + "command": { + "commitTransaction": 1, + "lsid": { + "$$sessionLsid": "session0" + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": { + "$$exists": false + }, + "autocommit": false, + "writeConcern": { + "w": "majority" + }, + "maxTimeMS": 60000 + }, + "commandName": "commitTransaction", + "databaseName": "admin" + } + }, + { + "commandStartedEvent": { + "command": { + "commitTransaction": 1, + "lsid": { + "$$sessionLsid": "session0" + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": { + "$$exists": false + }, + "autocommit": false, + "writeConcern": { + "w": "majority", + "wtimeout": 10000 + }, + "maxTimeMS": 60000 + }, + "commandName": "commitTransaction", + "databaseName": "admin" + } + } + ] + } + ], + "outcome": [ + { + "collectionName": "test", + "databaseName": "transaction-tests", + "documents": [ + { + "_id": 1 + } + ] + } + ] + }, + { + "description": "add UnknownTransactionCommitResult label to writeConcernError MaxTimeMSExpired", + "operations": [ + { + "object": "testRunner", + "name": "failPoint", + "arguments": { + "client": "client0", + "failPoint": { + "configureFailPoint": "failCommand", + "mode": { + "times": 1 + }, + "data": { + "failCommands": [ + "commitTransaction" + ], + "writeConcernError": { + "code": 50, + "errmsg": "operation exceeded time limit" + } + } + } + } + }, + { + "object": "session0", + "name": "startTransaction", + "arguments": { + "writeConcern": { + "w": "majority" + }, + "maxCommitTimeMS": 60000 + } + }, + { + "object": "collection0", + "name": "insertOne", + "arguments": { + "session": "session0", + "document": { + "_id": 1 + } + }, + "expectResult": { + "$$unsetOrMatches": { + "insertedId": { + "$$unsetOrMatches": 1 + } + } + } + }, + { + "object": "session0", + "name": "commitTransaction", + "expectError": { + "errorLabelsContain": [ + "UnknownTransactionCommitResult" + ], + "errorLabelsOmit": [ + "RetryableWriteError", + "TransientTransactionError" + ] + } + }, + { + "object": "session0", + "name": "commitTransaction" + } + ], + "expectEvents": [ + { + "client": "client0", + "events": [ + { + "commandStartedEvent": { + "command": { + "insert": "test", + "documents": [ + { + "_id": 1 + } + ], + "ordered": true, + "readConcern": { + "$$exists": false + }, + "lsid": { + "$$sessionLsid": "session0" + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": true, + "autocommit": false, + "writeConcern": { + "$$exists": false + } + }, + "commandName": "insert", + "databaseName": "transaction-tests" + } + }, + { + "commandStartedEvent": { + "command": { + "commitTransaction": 1, + "lsid": { + "$$sessionLsid": "session0" + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": { + "$$exists": false + }, + "autocommit": false, + "writeConcern": { + "w": "majority" + }, + "maxTimeMS": 60000 + }, + "commandName": "commitTransaction", + "databaseName": "admin" + } + }, + { + "commandStartedEvent": { + "command": { + "commitTransaction": 1, + "lsid": { + "$$sessionLsid": "session0" + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": { + "$$exists": false + }, + "autocommit": false, + "writeConcern": { + "w": "majority", + "wtimeout": 10000 + }, + "maxTimeMS": 60000 + }, + "commandName": "commitTransaction", + "databaseName": "admin" + } + } + ] + } + ], + "outcome": [ + { + "collectionName": "test", + "databaseName": "transaction-tests", + "documents": [ + { + "_id": 1 + } + ] + } + ] + } + ] +} diff --git a/source/transactions/tests/unified/error-labels.yml b/source/transactions/tests/unified/error-labels.yml new file mode 100644 index 0000000000..6eb8d7d75e --- /dev/null +++ b/source/transactions/tests/unified/error-labels.yml @@ -0,0 +1,1315 @@ +description: error-labels + +schemaVersion: '1.4' + +runOnRequirements: + - + minServerVersion: '4.0' + topologies: + - replicaset + - + minServerVersion: 4.1.8 + # serverless proxy doesn't append error labels to errors in transactions + # caused by failpoints (CLOUDP-88216) + serverless: forbid + topologies: + - sharded + - load-balanced + +createEntities: + - + client: + id: &client0 client0 + useMultipleMongoses: false + observeEvents: + - commandStartedEvent + - + database: + id: &database0 database0 + client: *client0 + databaseName: &database_name transaction-tests + - + collection: + id: &collection0 collection0 + database: *database0 + collectionName: &collection_name test + - + session: + id: &session0 session0 + client: *client0 + +initialData: + - + collectionName: *collection_name + databaseName: *database_name + documents: [] + +tests: + - + description: 'DuplicateKey errors do not contain transient label' + operations: + - + object: *session0 + name: startTransaction + - + object: *collection0 + name: insertMany + arguments: + session: *session0 + documents: + - { _id: 1 } + - { _id: 1 } + expectError: + errorLabelsOmit: + - TransientTransactionError + - UnknownTransactionCommitResult + # DuplicateKey error code included in the bulk write error message + # returned by the server + errorContains: E11000 + - + object: *session0 + name: abortTransaction + expectEvents: + - + client: *client0 + events: + - + commandStartedEvent: + command: + insert: *collection_name + documents: + - { _id: 1 } + - { _id: 1 } + ordered: true + readConcern: { $$exists: false } + lsid: { $$sessionLsid: *session0 } + txnNumber: { $numberLong: '1' } + startTransaction: true + autocommit: false + writeConcern: { $$exists: false } + commandName: insert + databaseName: *database_name + - + commandStartedEvent: + command: + abortTransaction: 1 + lsid: { $$sessionLsid: *session0 } + txnNumber: { $numberLong: '1' } + startTransaction: { $$exists: false } + autocommit: false + writeConcern: { $$exists: false } + commandName: abortTransaction + databaseName: admin + outcome: + - + collectionName: *collection_name + databaseName: *database_name + documents: [] + - + description: 'NotWritablePrimary errors contain transient label' + operations: + - + object: testRunner + name: failPoint + arguments: + client: *client0 + failPoint: + configureFailPoint: failCommand + mode: { times: 1 } + data: + failCommands: + - insert + errorCode: 10107 # NotWritablePrimary + - + object: *session0 + name: startTransaction + - + object: *collection0 + name: insertOne + arguments: + session: *session0 + document: { _id: 1 } + expectError: + # Note, the server will return the errorLabel in this case + errorLabelsContain: + - TransientTransactionError + errorLabelsOmit: + - RetryableWriteError + - UnknownTransactionCommitResult + - + object: *session0 + name: abortTransaction + expectEvents: + - + client: *client0 + events: + - + commandStartedEvent: + command: + insert: *collection_name + documents: + - { _id: 1 } + ordered: true + readConcern: { $$exists: false } + lsid: { $$sessionLsid: *session0 } + txnNumber: { $numberLong: '1' } + startTransaction: true + autocommit: false + writeConcern: { $$exists: false } + commandName: insert + databaseName: *database_name + - + commandStartedEvent: + command: + abortTransaction: 1 + lsid: { $$sessionLsid: *session0 } + txnNumber: { $numberLong: '1' } + startTransaction: { $$exists: false } + autocommit: false + writeConcern: { $$exists: false } + commandName: abortTransaction + databaseName: admin + outcome: + - + collectionName: *collection_name + databaseName: *database_name + documents: [] + - + description: 'WriteConflict errors contain transient label' + operations: + - + object: testRunner + name: failPoint + arguments: + client: *client0 + failPoint: + configureFailPoint: failCommand + mode: { times: 1 } + data: + failCommands: + - insert + errorCode: 112 # WriteConflict + - + object: *session0 + name: startTransaction + - + object: *collection0 + name: insertOne + arguments: + session: *session0 + document: { _id: 1 } + expectError: + # Note, the server will return the errorLabel in this case + errorLabelsContain: + - TransientTransactionError + errorLabelsOmit: + - RetryableWriteError + - UnknownTransactionCommitResult + - + object: *session0 + name: abortTransaction + expectEvents: + - + client: *client0 + events: + - + commandStartedEvent: + command: + insert: *collection_name + documents: + - { _id: 1 } + ordered: true + readConcern: { $$exists: false } + lsid: { $$sessionLsid: *session0 } + txnNumber: { $numberLong: '1' } + startTransaction: true + autocommit: false + writeConcern: { $$exists: false } + commandName: insert + databaseName: *database_name + - + commandStartedEvent: + command: + abortTransaction: 1 + lsid: { $$sessionLsid: *session0 } + txnNumber: { $numberLong: '1' } + startTransaction: { $$exists: false } + autocommit: false + writeConcern: { $$exists: false } + commandName: abortTransaction + databaseName: admin + outcome: + - + collectionName: *collection_name + databaseName: *database_name + documents: [] + - + description: 'NoSuchTransaction errors contain transient label' + operations: + - + object: testRunner + name: failPoint + arguments: + client: *client0 + failPoint: + configureFailPoint: failCommand + mode: { times: 1 } + data: + failCommands: + - insert + errorCode: 251 # NoSuchTransaction + - + object: *session0 + name: startTransaction + - + object: *collection0 + name: insertOne + arguments: + session: *session0 + document: { _id: 1 } + expectError: + # Note, the server will return the errorLabel in this case + errorLabelsContain: + - TransientTransactionError + errorLabelsOmit: + - RetryableWriteError + - UnknownTransactionCommitResult + - + object: *session0 + name: abortTransaction + expectEvents: + - + client: *client0 + events: + - + commandStartedEvent: + command: + insert: *collection_name + documents: + - { _id: 1 } + ordered: true + readConcern: { $$exists: false } + lsid: { $$sessionLsid: *session0 } + txnNumber: { $numberLong: '1' } + startTransaction: true + autocommit: false + writeConcern: { $$exists: false } + commandName: insert + databaseName: *database_name + - + commandStartedEvent: + command: + abortTransaction: 1 + lsid: { $$sessionLsid: *session0 } + txnNumber: { $numberLong: '1' } + startTransaction: { $$exists: false } + autocommit: false + writeConcern: { $$exists: false } + commandName: abortTransaction + databaseName: admin + outcome: + - + collectionName: *collection_name + databaseName: *database_name + documents: [] + - + description: 'NoSuchTransaction errors on commit contain transient label' + operations: + - + object: testRunner + name: failPoint + arguments: + client: *client0 + failPoint: + configureFailPoint: failCommand + mode: { times: 1 } + data: + failCommands: + - commitTransaction + errorCode: 251 # NoSuchTransaction + - + object: *session0 + name: startTransaction + - + object: *collection0 + name: insertOne + arguments: + session: *session0 + document: { _id: 1 } + expectResult: + $$unsetOrMatches: { insertedId: { $$unsetOrMatches: 1 } } + - + object: *session0 + name: commitTransaction + expectError: + # Note, the server will return the errorLabel in this case + errorLabelsContain: + - TransientTransactionError + errorLabelsOmit: + - RetryableWriteError + - UnknownTransactionCommitResult + expectEvents: + - + client: *client0 + events: + - + commandStartedEvent: + command: + insert: *collection_name + documents: + - { _id: 1 } + ordered: true + readConcern: { $$exists: false } + lsid: { $$sessionLsid: *session0 } + txnNumber: { $numberLong: '1' } + startTransaction: true + autocommit: false + writeConcern: { $$exists: false } + commandName: insert + databaseName: *database_name + - + commandStartedEvent: + command: + commitTransaction: 1 + lsid: { $$sessionLsid: *session0 } + txnNumber: { $numberLong: '1' } + startTransaction: { $$exists: false } + autocommit: false + writeConcern: { $$exists: false } + commandName: commitTransaction + databaseName: admin + outcome: + - + collectionName: *collection_name + databaseName: *database_name + documents: [] + - + description: 'add TransientTransactionError label to connection errors, but do not add RetryableWriteError label' + operations: + - + object: testRunner + name: failPoint + arguments: + client: *client0 + failPoint: + configureFailPoint: failCommand + mode: { times: 4 } + data: + failCommands: + - insert + - find + - aggregate + - distinct + closeConnection: true + - + object: *session0 + name: startTransaction + - + object: *collection0 + name: insertOne + arguments: + session: *session0 + document: { _id: 1 } + expectError: &transient_label_only + errorLabelsContain: + - TransientTransactionError + # While a connection error would normally be retryable, these are not because they occur within a transaction. + # Ensure the driver does not add the RetryableWriteError label to these errors. + errorLabelsOmit: + - RetryableWriteError + - UnknownTransactionCommitResult + - + object: *collection0 + name: find + arguments: + filter: {} + session: *session0 + expectError: *transient_label_only + - + object: *collection0 + name: aggregate + arguments: + pipeline: + - { $project: { _id: 1 } } + session: *session0 + expectError: *transient_label_only + - + object: *collection0 + name: distinct + arguments: + fieldName: _id + filter: {} + session: *session0 + expectError: *transient_label_only + - + object: *session0 + name: abortTransaction + expectEvents: + - + client: *client0 + events: + - + commandStartedEvent: + command: + insert: *collection_name + documents: + - { _id: 1 } + ordered: true + readConcern: { $$exists: false } + lsid: { $$sessionLsid: *session0 } + txnNumber: { $numberLong: '1' } + startTransaction: true + autocommit: false + writeConcern: { $$exists: false } + commandName: insert + databaseName: *database_name + - + commandStartedEvent: + command: + find: *collection_name + readConcern: { $$exists: false } + lsid: { $$sessionLsid: *session0 } + txnNumber: { $numberLong: '1' } + startTransaction: { $$exists: false } + autocommit: false + commandName: find + databaseName: *database_name + - + commandStartedEvent: + command: + aggregate: *collection_name + pipeline: + - { $project: { _id: 1 } } + cursor: { } + readConcern: { $$exists: false } + lsid: { $$sessionLsid: *session0 } + txnNumber: { $numberLong: '1' } + startTransaction: { $$exists: false } + autocommit: false + commandName: aggregate + databaseName: *database_name + - + commandStartedEvent: + command: + distinct: *collection_name + key: _id + lsid: { $$sessionLsid: *session0 } + readConcern: { $$exists: false } + txnNumber: { $numberLong: '1' } + startTransaction: { $$exists: false } + autocommit: false + commandName: distinct + databaseName: *database_name + - + commandStartedEvent: + command: + abortTransaction: 1 + lsid: { $$sessionLsid: *session0 } + txnNumber: { $numberLong: '1' } + startTransaction: { $$exists: false } + autocommit: false + writeConcern: { $$exists: false } + commandName: abortTransaction + databaseName: admin + outcome: + - + collectionName: *collection_name + databaseName: *database_name + documents: [] + - + description: 'add RetryableWriteError and UnknownTransactionCommitResult labels to connection errors' + operations: + - + object: testRunner + name: failPoint + arguments: + client: *client0 + failPoint: + configureFailPoint: failCommand + mode: { times: 2 } + data: + failCommands: + - commitTransaction + closeConnection: true + - + object: *session0 + name: startTransaction + - + object: *collection0 + name: insertOne + arguments: + session: *session0 + document: { _id: 1 } + expectResult: + $$unsetOrMatches: { insertedId: { $$unsetOrMatches: 1 } } + - + object: *session0 + name: commitTransaction + expectError: + errorLabelsContain: + - RetryableWriteError + - UnknownTransactionCommitResult + errorLabelsOmit: + - TransientTransactionError + - + object: *session0 + name: commitTransaction + expectEvents: + - + client: *client0 + events: + - + commandStartedEvent: + command: + insert: *collection_name + documents: + - { _id: 1 } + ordered: true + readConcern: { $$exists: false } + lsid: { $$sessionLsid: *session0 } + txnNumber: { $numberLong: '1' } + startTransaction: true + autocommit: false + writeConcern: { $$exists: false } + commandName: insert + databaseName: *database_name + - + commandStartedEvent: + command: + commitTransaction: 1 + lsid: { $$sessionLsid: *session0 } + txnNumber: { $numberLong: '1' } + startTransaction: { $$exists: false } + autocommit: false + writeConcern: { $$exists: false } + commandName: commitTransaction + databaseName: admin + - + commandStartedEvent: + command: + commitTransaction: 1 + lsid: { $$sessionLsid: *session0 } + txnNumber: { $numberLong: '1' } + startTransaction: { $$exists: false } + autocommit: false + # commitTransaction applies w:majority on retries + writeConcern: + w: majority + wtimeout: 10000 + commandName: commitTransaction + databaseName: admin + - + commandStartedEvent: + command: + commitTransaction: 1 + lsid: { $$sessionLsid: *session0 } + txnNumber: { $numberLong: '1' } + startTransaction: { $$exists: false } + autocommit: false + writeConcern: + w: majority + wtimeout: 10000 + commandName: commitTransaction + databaseName: admin + outcome: + - + collectionName: *collection_name + databaseName: *database_name + documents: + - { _id: 1 } + - + description: 'do not add RetryableWriteError label to writeConcernError ShutdownInProgress that occurs within transaction' + operations: + - + object: testRunner + name: failPoint + arguments: + client: *client0 + failPoint: + configureFailPoint: failCommand + mode: { times: 1 } + data: + failCommands: + - insert + writeConcernError: + code: 91 + errmsg: 'Replication is being shut down' + - + object: *session0 + name: startTransaction + arguments: + writeConcern: + w: majority + - + object: *collection0 + name: insertOne + arguments: + session: *session0 + document: { _id: 1 } + expectError: + errorLabelsOmit: + - RetryableWriteError + - TransientTransactionError + - UnknownTransactionCommitResult + - + object: *session0 + name: abortTransaction + expectEvents: + - + client: *client0 + events: + - + commandStartedEvent: + command: + insert: *collection_name + documents: + - { _id: 1 } + ordered: true + readConcern: { $$exists: false } + lsid: { $$sessionLsid: *session0 } + txnNumber: { $numberLong: '1' } + startTransaction: true + autocommit: false + commandName: insert + databaseName: *database_name + - + commandStartedEvent: + command: + abortTransaction: 1 + lsid: { $$sessionLsid: *session0 } + txnNumber: { $numberLong: '1' } + startTransaction: { $$exists: false } + autocommit: false + commandName: abortTransaction + databaseName: admin + outcome: + - + collectionName: *collection_name + databaseName: *database_name + documents: [] + - + description: 'add UnknownTransactionCommitResult label to writeConcernError WriteConcernFailed' + operations: + - + object: testRunner + name: failPoint + arguments: + client: *client0 + failPoint: + configureFailPoint: failCommand + mode: { times: 1 } + data: + failCommands: + - commitTransaction + writeConcernError: + code: 64 # WriteConcernFailed without wtimeout + errmsg: 'multiple errors reported' + - + object: *session0 + name: startTransaction + arguments: + writeConcern: + w: majority + - + object: *collection0 + name: insertOne + arguments: + session: *session0 + document: { _id: 1 } + expectResult: + $$unsetOrMatches: { insertedId: { $$unsetOrMatches: 1 } } + - + object: *session0 + name: commitTransaction + expectError: + errorLabelsContain: + - UnknownTransactionCommitResult + errorLabelsOmit: + - RetryableWriteError + - TransientTransactionError + - + object: *session0 + name: commitTransaction + expectEvents: + - + client: *client0 + events: + - + commandStartedEvent: + command: + insert: *collection_name + documents: + - { _id: 1 } + ordered: true + readConcern: { $$exists: false } + lsid: { $$sessionLsid: *session0 } + txnNumber: { $numberLong: '1' } + startTransaction: true + autocommit: false + writeConcern: { $$exists: false } + commandName: insert + databaseName: *database_name + - + commandStartedEvent: + command: + commitTransaction: 1 + lsid: { $$sessionLsid: *session0 } + txnNumber: { $numberLong: '1' } + startTransaction: { $$exists: false } + autocommit: false + writeConcern: + w: majority + commandName: commitTransaction + databaseName: admin + - + commandStartedEvent: + command: + commitTransaction: 1 + lsid: { $$sessionLsid: *session0 } + txnNumber: { $numberLong: '1' } + startTransaction: { $$exists: false } + autocommit: false + # commitTransaction applies w:majority on retries + writeConcern: + w: majority + wtimeout: 10000 + commandName: commitTransaction + databaseName: admin + outcome: + - + collectionName: *collection_name + databaseName: *database_name + documents: + - { _id: 1 } + - + description: 'add UnknownTransactionCommitResult label to writeConcernError WriteConcernFailed with wtimeout' + operations: + - + object: testRunner + name: failPoint + arguments: + client: *client0 + failPoint: + configureFailPoint: failCommand + mode: { times: 1 } + data: + failCommands: + - commitTransaction + writeConcernError: + code: 64 + codeName: WriteConcernFailed + errmsg: 'waiting for replication timed out' + errInfo: + wtimeout: true + - + object: *session0 + name: startTransaction + arguments: + writeConcern: + w: majority + - + object: *collection0 + name: insertOne + arguments: + session: *session0 + document: { _id: 1 } + expectResult: + $$unsetOrMatches: { insertedId: { $$unsetOrMatches: 1 } } + - + object: *session0 + name: commitTransaction + expectError: + errorLabelsContain: + - UnknownTransactionCommitResult + errorLabelsOmit: + - RetryableWriteError + - TransientTransactionError + - + object: *session0 + name: commitTransaction + expectEvents: + - + client: *client0 + events: + - + commandStartedEvent: + command: + insert: *collection_name + documents: + - { _id: 1 } + ordered: true + readConcern: { $$exists: false } + lsid: { $$sessionLsid: *session0 } + txnNumber: { $numberLong: '1' } + startTransaction: true + autocommit: false + writeConcern: { $$exists: false } + commandName: insert + databaseName: *database_name + - + commandStartedEvent: + command: + commitTransaction: 1 + lsid: { $$sessionLsid: *session0 } + txnNumber: { $numberLong: '1' } + startTransaction: { $$exists: false } + autocommit: false + writeConcern: + w: majority + commandName: commitTransaction + databaseName: admin + - + commandStartedEvent: + command: + commitTransaction: 1 + lsid: { $$sessionLsid: *session0 } + txnNumber: { $numberLong: '1' } + startTransaction: { $$exists: false } + autocommit: false + # commitTransaction applies w:majority on retries + writeConcern: + w: majority + wtimeout: 10000 + commandName: commitTransaction + databaseName: admin + outcome: + - + collectionName: *collection_name + databaseName: *database_name + documents: + - { _id: 1 } + - + description: 'omit UnknownTransactionCommitResult label from writeConcernError UnsatisfiableWriteConcern' + operations: + - + object: testRunner + name: failPoint + arguments: + client: *client0 + failPoint: + configureFailPoint: failCommand + mode: { times: 1 } + data: + failCommands: + - commitTransaction + writeConcernError: + code: 100 # UnsatisfiableWriteConcern + errmsg: 'Not enough data-bearing nodes' + - + object: *session0 + name: startTransaction + arguments: + writeConcern: + w: majority + - + object: *collection0 + name: insertOne + arguments: + session: *session0 + document: { _id: 1 } + expectResult: + $$unsetOrMatches: { insertedId: { $$unsetOrMatches: 1 } } + - + object: *session0 + name: commitTransaction + expectError: + errorLabelsOmit: + - RetryableWriteError + - TransientTransactionError + - UnknownTransactionCommitResult + expectEvents: + - + client: *client0 + events: + - + commandStartedEvent: + command: + insert: *collection_name + documents: + - { _id: 1 } + ordered: true + readConcern: { $$exists: false } + lsid: { $$sessionLsid: *session0 } + txnNumber: { $numberLong: '1' } + startTransaction: true + autocommit: false + writeConcern: { $$exists: false } + commandName: insert + databaseName: *database_name + - + commandStartedEvent: + command: + commitTransaction: 1 + lsid: { $$sessionLsid: *session0 } + txnNumber: { $numberLong: '1' } + startTransaction: { $$exists: false } + autocommit: false + writeConcern: + w: majority + commandName: commitTransaction + databaseName: admin + outcome: + - + collectionName: *collection_name + databaseName: *database_name + documents: + - { _id: 1 } + - + description: 'omit UnknownTransactionCommitResult label from writeConcernError UnknownReplWriteConcern' + operations: + - + object: testRunner + name: failPoint + arguments: + client: *client0 + failPoint: + configureFailPoint: failCommand + mode: { times: 1 } + data: + failCommands: + - commitTransaction + writeConcernError: + code: 79 # UnknownReplWriteConcern + errmsg: "No write concern mode named 'blah' found in replica set configuration" + - + object: *session0 + name: startTransaction + arguments: + writeConcern: + w: majority + - + object: *collection0 + name: insertOne + arguments: + session: *session0 + document: { _id: 1 } + expectResult: + $$unsetOrMatches: { insertedId: { $$unsetOrMatches: 1 } } + - + object: *session0 + name: commitTransaction + expectError: + errorLabelsOmit: + - RetryableWriteConcern + - TransientTransactionError + - UnknownTransactionCommitResult + expectEvents: + - + client: *client0 + events: + - + commandStartedEvent: + command: + insert: *collection_name + documents: + - { _id: 1 } + ordered: true + readConcern: { $$exists: false } + lsid: { $$sessionLsid: *session0 } + txnNumber: { $numberLong: '1' } + startTransaction: true + autocommit: false + writeConcern: { $$exists: false } + commandName: insert + databaseName: *database_name + - + commandStartedEvent: + command: + commitTransaction: 1 + lsid: { $$sessionLsid: *session0 } + txnNumber: { $numberLong: '1' } + startTransaction: { $$exists: false } + autocommit: false + writeConcern: + w: majority + commandName: commitTransaction + databaseName: admin + outcome: + - + collectionName: *collection_name + databaseName: *database_name + documents: + - { _id: 1 } + - + description: 'do not add UnknownTransactionCommitResult label to MaxTimeMSExpired inside transactions' + operations: + - + object: testRunner + name: failPoint + arguments: + client: *client0 + failPoint: + configureFailPoint: failCommand + mode: { times: 1 } + data: + failCommands: + - aggregate + errorCode: 50 # MaxTimeMSExpired + - + object: *session0 + name: startTransaction + - + object: *collection0 + name: insertOne + arguments: + session: *session0 + document: { _id: 1 } + expectResult: + $$unsetOrMatches: { insertedId: { $$unsetOrMatches: 1 } } + - + object: *collection0 + name: aggregate + arguments: + pipeline: + - { $project: { _id: 1 } } + maxTimeMS: 60000 + session: *session0 + expectError: + errorLabelsOmit: + - RetryableWriteError + - UnknownTransactionCommitResult + - TransientTransactionError + - + object: *session0 + name: abortTransaction + expectEvents: + - + client: *client0 + events: + - + commandStartedEvent: + command: + insert: *collection_name + documents: + - { _id: 1 } + ordered: true + readConcern: { $$exists: false } + lsid: { $$sessionLsid: *session0 } + txnNumber: { $numberLong: '1' } + startTransaction: true + autocommit: false + writeConcern: { $$exists: false } + commandName: insert + databaseName: *database_name + - + commandStartedEvent: + command: + aggregate: *collection_name + pipeline: + - { $project: { _id: 1 } } + cursor: { } + readConcern: { $$exists: false } + lsid: { $$sessionLsid: *session0 } + txnNumber: { $numberLong: '1' } + autocommit: false + maxTimeMS: 60000 + commandName: aggregate + databaseName: *database_name + - + commandStartedEvent: + command: + abortTransaction: 1 + lsid: { $$sessionLsid: *session0 } + txnNumber: { $numberLong: '1' } + startTransaction: { $$exists: false } + autocommit: false + writeConcern: { $$exists: false } + commandName: abortTransaction + databaseName: admin + outcome: + - + collectionName: *collection_name + databaseName: *database_name + documents: [] + - + description: 'add UnknownTransactionCommitResult label to MaxTimeMSExpired' + operations: + - + object: testRunner + name: failPoint + arguments: + client: *client0 + failPoint: + configureFailPoint: failCommand + mode: { times: 1 } + data: + failCommands: + - commitTransaction + errorCode: 50 # MaxTimeMSExpired + - + object: *session0 + name: startTransaction + arguments: + writeConcern: + w: majority + maxCommitTimeMS: 60000 + - + object: *collection0 + name: insertOne + arguments: + session: *session0 + document: { _id: 1 } + expectResult: + $$unsetOrMatches: { insertedId: { $$unsetOrMatches: 1 } } + - + object: *session0 + name: commitTransaction + expectError: + errorLabelsContain: + - UnknownTransactionCommitResult + errorLabelsOmit: + - RetryableWriteError + - TransientTransactionError + - + object: *session0 + name: commitTransaction + expectEvents: + - + client: *client0 + events: + - + commandStartedEvent: + command: + insert: *collection_name + documents: + - { _id: 1 } + ordered: true + readConcern: { $$exists: false } + lsid: { $$sessionLsid: *session0 } + txnNumber: { $numberLong: '1' } + startTransaction: true + autocommit: false + writeConcern: { $$exists: false } + commandName: insert + databaseName: *database_name + - + commandStartedEvent: + command: + commitTransaction: 1 + lsid: { $$sessionLsid: *session0 } + txnNumber: { $numberLong: '1' } + startTransaction: { $$exists: false } + autocommit: false + writeConcern: + w: majority + maxTimeMS: 60000 + commandName: commitTransaction + databaseName: admin + - + commandStartedEvent: + command: + commitTransaction: 1 + lsid: { $$sessionLsid: *session0 } + txnNumber: { $numberLong: '1' } + startTransaction: { $$exists: false } + autocommit: false + # commitTransaction applies w:majority on retries + writeConcern: + w: majority + wtimeout: 10000 + maxTimeMS: 60000 + commandName: commitTransaction + databaseName: admin + outcome: + - + collectionName: *collection_name + databaseName: *database_name + documents: + - { _id: 1 } + - + description: 'add UnknownTransactionCommitResult label to writeConcernError MaxTimeMSExpired' + operations: + - + object: testRunner + name: failPoint + arguments: + client: *client0 + failPoint: + configureFailPoint: failCommand + mode: { times: 1 } + data: + failCommands: + - commitTransaction + writeConcernError: + code: 50 # MaxTimeMSExpired + errmsg: 'operation exceeded time limit' + - + object: *session0 + name: startTransaction + arguments: + writeConcern: + w: majority + maxCommitTimeMS: 60000 + - + object: *collection0 + name: insertOne + arguments: + session: *session0 + document: { _id: 1 } + expectResult: + $$unsetOrMatches: { insertedId: { $$unsetOrMatches: 1 } } + - + object: *session0 + name: commitTransaction + expectError: + errorLabelsContain: + - UnknownTransactionCommitResult + errorLabelsOmit: + - RetryableWriteError + - TransientTransactionError + - + object: *session0 + name: commitTransaction + expectEvents: + - + client: *client0 + events: + - + commandStartedEvent: + command: + insert: *collection_name + documents: + - { _id: 1 } + ordered: true + readConcern: { $$exists: false } + lsid: { $$sessionLsid: *session0 } + txnNumber: { $numberLong: '1' } + startTransaction: true + autocommit: false + writeConcern: { $$exists: false } + commandName: insert + databaseName: *database_name + - + commandStartedEvent: + command: + commitTransaction: 1 + lsid: { $$sessionLsid: *session0 } + txnNumber: { $numberLong: '1' } + startTransaction: { $$exists: false } + autocommit: false + writeConcern: + w: majority + maxTimeMS: 60000 + commandName: commitTransaction + databaseName: admin + - + commandStartedEvent: + command: + commitTransaction: 1 + lsid: { $$sessionLsid: *session0 } + txnNumber: { $numberLong: '1' } + startTransaction: { $$exists: false } + autocommit: false + # commitTransaction applies w:majority on retries + writeConcern: + w: majority + wtimeout: 10000 + maxTimeMS: 60000 + commandName: commitTransaction + databaseName: admin + outcome: + - + collectionName: *collection_name + databaseName: *database_name + documents: + - { _id: 1 } diff --git a/source/transactions/tests/legacy/errors-client.json b/source/transactions/tests/unified/errors-client.json similarity index 53% rename from source/transactions/tests/legacy/errors-client.json rename to source/transactions/tests/unified/errors-client.json index d163e91ec5..00f1497c2d 100644 --- a/source/transactions/tests/legacy/errors-client.json +++ b/source/transactions/tests/unified/errors-client.json @@ -1,33 +1,70 @@ { - "runOn": [ + "description": "errors-client", + "schemaVersion": "1.3", + "runOnRequirements": [ { "minServerVersion": "4.0", - "topology": [ + "topologies": [ "replicaset" ] }, { "minServerVersion": "4.1.8", - "topology": [ + "topologies": [ "sharded", "load-balanced" ] } ], - "database_name": "transaction-tests", - "collection_name": "test", - "data": [], + "createEntities": [ + { + "client": { + "id": "client0", + "useMultipleMongoses": false, + "observeEvents": [ + "commandStartedEvent" + ] + } + }, + { + "database": { + "id": "database0", + "client": "client0", + "databaseName": "transaction-tests" + } + }, + { + "collection": { + "id": "collection0", + "database": "database0", + "collectionName": "test" + } + }, + { + "session": { + "id": "session0", + "client": "client0" + } + } + ], + "initialData": [ + { + "collectionName": "test", + "databaseName": "transaction-tests", + "documents": [] + } + ], "tests": [ { "description": "Client side error in command starting transaction", "operations": [ { - "name": "startTransaction", - "object": "session0" + "object": "session0", + "name": "startTransaction" }, { + "object": "collection0", "name": "updateOne", - "object": "collection", "arguments": { "session": "session0", "filter": { @@ -37,11 +74,13 @@ "x": 1 } }, - "error": true + "expectError": { + "isError": true + } }, { - "name": "assertSessionTransactionState", "object": "testRunner", + "name": "assertSessionTransactionState", "arguments": { "session": "session0", "state": "starting" @@ -53,25 +92,29 @@ "description": "Client side error when transaction is in progress", "operations": [ { - "name": "startTransaction", - "object": "session0" + "object": "session0", + "name": "startTransaction" }, { + "object": "collection0", "name": "insertOne", - "object": "collection", "arguments": { "session": "session0", "document": { "_id": 1 } }, - "result": { - "insertedId": 1 + "expectResult": { + "$$unsetOrMatches": { + "insertedId": { + "$$unsetOrMatches": 1 + } + } } }, { + "object": "collection0", "name": "updateOne", - "object": "collection", "arguments": { "session": "session0", "filter": { @@ -81,11 +124,13 @@ "x": 1 } }, - "error": true + "expectError": { + "isError": true + } }, { - "name": "assertSessionTransactionState", "object": "testRunner", + "name": "assertSessionTransactionState", "arguments": { "session": "session0", "state": "in_progress" diff --git a/source/transactions/tests/unified/errors-client.yml b/source/transactions/tests/unified/errors-client.yml new file mode 100644 index 0000000000..d3f451b98c --- /dev/null +++ b/source/transactions/tests/unified/errors-client.yml @@ -0,0 +1,96 @@ +description: errors-client + +schemaVersion: '1.3' + +runOnRequirements: + - + minServerVersion: '4.0' + topologies: + - replicaset + - + minServerVersion: 4.1.8 + topologies: + - sharded + - load-balanced + +createEntities: + - + client: + id: &client0 client0 + useMultipleMongoses: false + observeEvents: + - commandStartedEvent + - + database: + id: &database0 database0 + client: *client0 + databaseName: &database_name transaction-tests + - + collection: + id: &collection0 collection0 + database: *database0 + collectionName: &collection_name test + - + session: + id: &session0 session0 + client: *client0 + +initialData: + - + collectionName: *collection_name + databaseName: *database_name + documents: [] + +tests: + - + description: 'Client side error in command starting transaction' + operations: + - + object: *session0 + name: startTransaction + - + object: *collection0 + name: updateOne + arguments: + session: *session0 + filter: { _id: 1 } + update: + x: 1 + expectError: + isError: true + - + object: testRunner + name: assertSessionTransactionState + arguments: + session: *session0 + state: starting + - + description: 'Client side error when transaction is in progress' + operations: + - + object: *session0 + name: startTransaction + - + object: *collection0 + name: insertOne + arguments: + session: *session0 + document: { _id: 1 } + expectResult: + $$unsetOrMatches: { insertedId: { $$unsetOrMatches: 1 } } + - + object: *collection0 + name: updateOne + arguments: + session: *session0 + filter: { _id: 1 } + update: + x: 1 + expectError: + isError: true + - + object: testRunner + name: assertSessionTransactionState + arguments: + session: *session0 + state: in_progress diff --git a/source/transactions/tests/legacy/errors.json b/source/transactions/tests/unified/errors.json similarity index 53% rename from source/transactions/tests/legacy/errors.json rename to source/transactions/tests/unified/errors.json index 356e3eec0d..94a9cac207 100644 --- a/source/transactions/tests/legacy/errors.json +++ b/source/transactions/tests/unified/errors.json @@ -1,53 +1,101 @@ { - "runOn": [ + "description": "errors", + "schemaVersion": "1.3", + "runOnRequirements": [ { "minServerVersion": "4.0", - "topology": [ + "topologies": [ "replicaset" ] }, { "minServerVersion": "4.1.8", - "topology": [ + "topologies": [ "sharded", "load-balanced" ] } ], - "database_name": "transaction-tests", - "collection_name": "test", - "data": [], + "createEntities": [ + { + "client": { + "id": "client0", + "useMultipleMongoses": false, + "observeEvents": [ + "commandStartedEvent" + ] + } + }, + { + "database": { + "id": "database0", + "client": "client0", + "databaseName": "transaction-tests" + } + }, + { + "collection": { + "id": "collection0", + "database": "database0", + "collectionName": "test" + } + }, + { + "session": { + "id": "session0", + "client": "client0" + } + }, + { + "session": { + "id": "session1", + "client": "client0" + } + } + ], + "initialData": [ + { + "collectionName": "test", + "databaseName": "transaction-tests", + "documents": [] + } + ], "tests": [ { "description": "start insert start", "operations": [ { - "name": "startTransaction", - "object": "session0" + "object": "session0", + "name": "startTransaction" }, { + "object": "collection0", "name": "insertOne", - "object": "collection", "arguments": { "session": "session0", "document": { "_id": 1 } }, - "result": { - "insertedId": 1 + "expectResult": { + "$$unsetOrMatches": { + "insertedId": { + "$$unsetOrMatches": 1 + } + } } }, { - "name": "startTransaction", "object": "session0", - "result": { + "name": "startTransaction", + "expectError": { + "isClientError": true, "errorContains": "transaction already in progress" } }, { - "name": "commitTransaction", - "object": "session0" + "object": "session0", + "name": "commitTransaction" } ] }, @@ -55,13 +103,14 @@ "description": "start twice", "operations": [ { - "name": "startTransaction", - "object": "session0" + "object": "session0", + "name": "startTransaction" }, { - "name": "startTransaction", "object": "session0", - "result": { + "name": "startTransaction", + "expectError": { + "isClientError": true, "errorContains": "transaction already in progress" } } @@ -71,34 +120,39 @@ "description": "commit and start twice", "operations": [ { - "name": "startTransaction", - "object": "session0" + "object": "session0", + "name": "startTransaction" }, { + "object": "collection0", "name": "insertOne", - "object": "collection", "arguments": { "session": "session0", "document": { "_id": 1 } }, - "result": { - "insertedId": 1 + "expectResult": { + "$$unsetOrMatches": { + "insertedId": { + "$$unsetOrMatches": 1 + } + } } }, { - "name": "commitTransaction", - "object": "session0" + "object": "session0", + "name": "commitTransaction" }, { - "name": "startTransaction", - "object": "session0" + "object": "session0", + "name": "startTransaction" }, { - "name": "startTransaction", "object": "session0", - "result": { + "name": "startTransaction", + "expectError": { + "isClientError": true, "errorContains": "transaction already in progress" } } @@ -108,36 +162,40 @@ "description": "write conflict commit", "operations": [ { - "name": "startTransaction", - "object": "session0" + "object": "session0", + "name": "startTransaction" }, { + "object": "collection0", "name": "insertOne", - "object": "collection", "arguments": { "session": "session0", "document": { "_id": 1 } }, - "result": { - "insertedId": 1 + "expectResult": { + "$$unsetOrMatches": { + "insertedId": { + "$$unsetOrMatches": 1 + } + } } }, { - "name": "startTransaction", - "object": "session1" + "object": "session1", + "name": "startTransaction" }, { + "object": "collection0", "name": "insertOne", - "object": "collection", "arguments": { "session": "session1", "document": { "_id": 1 } }, - "result": { + "expectError": { "errorCodeName": "WriteConflict", "errorLabelsContain": [ "TransientTransactionError" @@ -148,13 +206,13 @@ } }, { - "name": "commitTransaction", - "object": "session0" + "object": "session0", + "name": "commitTransaction" }, { - "name": "commitTransaction", "object": "session1", - "result": { + "name": "commitTransaction", + "expectError": { "errorCodeName": "NoSuchTransaction", "errorLabelsContain": [ "TransientTransactionError" @@ -170,36 +228,40 @@ "description": "write conflict abort", "operations": [ { - "name": "startTransaction", - "object": "session0" + "object": "session0", + "name": "startTransaction" }, { + "object": "collection0", "name": "insertOne", - "object": "collection", "arguments": { "session": "session0", "document": { "_id": 1 } }, - "result": { - "insertedId": 1 + "expectResult": { + "$$unsetOrMatches": { + "insertedId": { + "$$unsetOrMatches": 1 + } + } } }, { - "name": "startTransaction", - "object": "session1" + "object": "session1", + "name": "startTransaction" }, { + "object": "collection0", "name": "insertOne", - "object": "collection", "arguments": { "session": "session1", "document": { "_id": 1 } }, - "result": { + "expectError": { "errorCodeName": "WriteConflict", "errorLabelsContain": [ "TransientTransactionError" @@ -210,12 +272,12 @@ } }, { - "name": "commitTransaction", - "object": "session0" + "object": "session0", + "name": "commitTransaction" }, { - "name": "abortTransaction", - "object": "session1" + "object": "session1", + "name": "abortTransaction" } ] } diff --git a/source/transactions/tests/unified/errors.yml b/source/transactions/tests/unified/errors.yml new file mode 100644 index 0000000000..ce6ecfcff7 --- /dev/null +++ b/source/transactions/tests/unified/errors.yml @@ -0,0 +1,187 @@ +description: errors + +schemaVersion: '1.3' + +runOnRequirements: + - + minServerVersion: '4.0' + topologies: + - replicaset + - + minServerVersion: 4.1.8 + topologies: + - sharded + - load-balanced + +createEntities: + - + client: + id: &client0 client0 + useMultipleMongoses: false + observeEvents: + - commandStartedEvent + - + database: + id: &database0 database0 + client: *client0 + databaseName: &database_name transaction-tests + - + collection: + id: &collection0 collection0 + database: *database0 + collectionName: &collection_name test + - + session: + id: &session0 session0 + client: *client0 + - + session: + id: &session1 session1 + client: *client0 + +initialData: + - + collectionName: *collection_name + databaseName: *database_name + documents: [] + +tests: + - + description: 'start insert start' + operations: + - + object: *session0 + name: startTransaction + - + object: *collection0 + name: insertOne + arguments: + session: *session0 + document: { _id: 1 } + expectResult: + $$unsetOrMatches: { insertedId: { $$unsetOrMatches: 1 } } + - + object: *session0 + name: startTransaction + expectError: + isClientError: true + errorContains: 'transaction already in progress' + # Just to clean up + - + object: *session0 + name: commitTransaction + - + description: 'start twice' + operations: + - + object: *session0 + name: startTransaction + - + object: *session0 + name: startTransaction + expectError: + isClientError: true + errorContains: 'transaction already in progress' + - + description: 'commit and start twice' + operations: + - + object: *session0 + name: startTransaction + - + object: *collection0 + name: insertOne + arguments: + session: *session0 + document: { _id: 1 } + expectResult: + $$unsetOrMatches: { insertedId: { $$unsetOrMatches: 1 } } + - + object: *session0 + name: commitTransaction + - + object: *session0 + name: startTransaction + - + object: *session0 + name: startTransaction + expectError: + isClientError: true + errorContains: 'transaction already in progress' + - + description: 'write conflict commit' + operations: + - + object: *session0 + name: startTransaction + - + object: *collection0 + name: insertOne + arguments: + session: *session0 + document: { _id: 1 } + expectResult: + $$unsetOrMatches: { insertedId: { $$unsetOrMatches: 1 } } + - + object: *session1 + name: startTransaction + - + object: *collection0 + name: insertOne + arguments: + session: *session1 + document: { _id: 1 } + expectError: + errorCodeName: WriteConflict + errorLabelsContain: + - TransientTransactionError + errorLabelsOmit: + - UnknownTransactionCommitResult + - + object: *session0 + name: commitTransaction + - + object: *session1 + name: commitTransaction + expectError: + errorCodeName: NoSuchTransaction + errorLabelsContain: + - TransientTransactionError + errorLabelsOmit: + - UnknownTransactionCommitResult + - + description: 'write conflict abort' + operations: + - + object: *session0 + name: startTransaction + - + object: *collection0 + name: insertOne + arguments: + session: *session0 + document: { _id: 1 } + expectResult: + $$unsetOrMatches: { insertedId: { $$unsetOrMatches: 1 } } + - + object: *session1 + name: startTransaction + - + object: *collection0 + name: insertOne + arguments: + session: *session1 + document: { _id: 1 } + expectError: + errorCodeName: WriteConflict + errorLabelsContain: + - TransientTransactionError + errorLabelsOmit: + - UnknownTransactionCommitResult + - + object: *session0 + name: commitTransaction + # Driver ignores "NoSuchTransaction" error + - + object: *session1 + name: abortTransaction diff --git a/source/transactions/tests/unified/findOneAndDelete.json b/source/transactions/tests/unified/findOneAndDelete.json new file mode 100644 index 0000000000..7db9c872af --- /dev/null +++ b/source/transactions/tests/unified/findOneAndDelete.json @@ -0,0 +1,317 @@ +{ + "description": "findOneAndDelete", + "schemaVersion": "1.9", + "runOnRequirements": [ + { + "minServerVersion": "4.0", + "topologies": [ + "replicaset" + ] + }, + { + "minServerVersion": "4.1.8", + "topologies": [ + "sharded", + "load-balanced" + ] + } + ], + "createEntities": [ + { + "client": { + "id": "client0", + "useMultipleMongoses": false, + "observeEvents": [ + "commandStartedEvent" + ] + } + }, + { + "database": { + "id": "database0", + "client": "client0", + "databaseName": "transaction-tests" + } + }, + { + "collection": { + "id": "collection0", + "database": "database0", + "collectionName": "test" + } + }, + { + "session": { + "id": "session0", + "client": "client0" + } + } + ], + "initialData": [ + { + "collectionName": "test", + "databaseName": "transaction-tests", + "documents": [ + { + "_id": 1 + }, + { + "_id": 2 + }, + { + "_id": 3 + } + ] + } + ], + "tests": [ + { + "description": "findOneAndDelete", + "operations": [ + { + "object": "session0", + "name": "startTransaction" + }, + { + "object": "collection0", + "name": "findOneAndDelete", + "arguments": { + "session": "session0", + "filter": { + "_id": 3 + } + }, + "expectResult": { + "_id": 3 + } + }, + { + "object": "collection0", + "name": "findOneAndDelete", + "arguments": { + "session": "session0", + "filter": { + "_id": 4 + } + } + }, + { + "object": "session0", + "name": "commitTransaction" + } + ], + "expectEvents": [ + { + "client": "client0", + "events": [ + { + "commandStartedEvent": { + "command": { + "findAndModify": "test", + "query": { + "_id": 3 + }, + "remove": true, + "lsid": { + "$$sessionLsid": "session0" + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": true, + "autocommit": false, + "readConcern": { + "$$exists": false + }, + "writeConcern": { + "$$exists": false + } + }, + "commandName": "findAndModify", + "databaseName": "transaction-tests" + } + }, + { + "commandStartedEvent": { + "command": { + "findAndModify": "test", + "query": { + "_id": 4 + }, + "remove": true, + "lsid": { + "$$sessionLsid": "session0" + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": { + "$$exists": false + }, + "autocommit": false, + "readConcern": { + "$$exists": false + }, + "writeConcern": { + "$$exists": false + } + }, + "commandName": "findAndModify", + "databaseName": "transaction-tests" + } + }, + { + "commandStartedEvent": { + "command": { + "commitTransaction": 1, + "lsid": { + "$$sessionLsid": "session0" + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": { + "$$exists": false + }, + "autocommit": false, + "readConcern": { + "$$exists": false + }, + "writeConcern": { + "$$exists": false + } + }, + "commandName": "commitTransaction", + "databaseName": "admin" + } + } + ] + } + ], + "outcome": [ + { + "collectionName": "test", + "databaseName": "transaction-tests", + "documents": [ + { + "_id": 1 + }, + { + "_id": 2 + } + ] + } + ] + }, + { + "description": "collection writeConcern ignored for findOneAndDelete", + "operations": [ + { + "object": "testRunner", + "name": "createEntities", + "arguments": { + "entities": [ + { + "collection": { + "id": "collection_wc_majority", + "database": "database0", + "collectionName": "test", + "collectionOptions": { + "writeConcern": { + "w": "majority" + } + } + } + } + ] + } + }, + { + "object": "session0", + "name": "startTransaction", + "arguments": { + "writeConcern": { + "w": "majority" + } + } + }, + { + "object": "collection_wc_majority", + "name": "findOneAndDelete", + "arguments": { + "session": "session0", + "filter": { + "_id": 3 + } + }, + "expectResult": { + "_id": 3 + } + }, + { + "object": "session0", + "name": "commitTransaction" + } + ], + "expectEvents": [ + { + "client": "client0", + "events": [ + { + "commandStartedEvent": { + "command": { + "findAndModify": "test", + "query": { + "_id": 3 + }, + "remove": true, + "lsid": { + "$$sessionLsid": "session0" + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": true, + "autocommit": false, + "readConcern": { + "$$exists": false + }, + "writeConcern": { + "$$exists": false + } + }, + "commandName": "findAndModify", + "databaseName": "transaction-tests" + } + }, + { + "commandStartedEvent": { + "command": { + "commitTransaction": 1, + "lsid": { + "$$sessionLsid": "session0" + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": { + "$$exists": false + }, + "autocommit": false, + "readConcern": { + "$$exists": false + }, + "writeConcern": { + "w": "majority" + } + }, + "commandName": "commitTransaction", + "databaseName": "admin" + } + } + ] + } + ] + } + ] +} diff --git a/source/transactions/tests/unified/findOneAndDelete.yml b/source/transactions/tests/unified/findOneAndDelete.yml new file mode 100644 index 0000000000..446318970f --- /dev/null +++ b/source/transactions/tests/unified/findOneAndDelete.yml @@ -0,0 +1,183 @@ +description: findOneAndDelete + +schemaVersion: '1.9' + +runOnRequirements: + - + minServerVersion: '4.0' + topologies: + - replicaset + - + minServerVersion: 4.1.8 + topologies: + - sharded + - load-balanced + +createEntities: + - + client: + id: &client0 client0 + useMultipleMongoses: false + observeEvents: + - commandStartedEvent + - + database: + id: &database0 database0 + client: *client0 + databaseName: &database_name transaction-tests + - + collection: + id: &collection0 collection0 + database: *database0 + collectionName: &collection_name test + - + session: + id: &session0 session0 + client: *client0 + +initialData: + - + collectionName: *collection_name + databaseName: *database_name + documents: + - { _id: 1 } + - { _id: 2 } + - { _id: 3 } + +tests: + - + description: findOneAndDelete + operations: + - + object: *session0 + name: startTransaction + - + object: *collection0 + name: findOneAndDelete + arguments: + session: *session0 + filter: { _id: 3 } + expectResult: + _id: 3 + - + object: *collection0 + name: findOneAndDelete + arguments: + session: *session0 + filter: { _id: 4 } + - + object: *session0 + name: commitTransaction + expectEvents: + - + client: *client0 + events: + - + commandStartedEvent: + command: + findAndModify: *collection_name + query: { _id: 3 } + remove: true + lsid: { $$sessionLsid: *session0 } + txnNumber: { $numberLong: '1' } + startTransaction: true + autocommit: false + readConcern: { $$exists: false } + writeConcern: { $$exists: false } + commandName: findAndModify + databaseName: *database_name + - + commandStartedEvent: + command: + findAndModify: *collection_name + query: { _id: 4 } + remove: true + lsid: { $$sessionLsid: *session0 } + txnNumber: { $numberLong: '1' } + startTransaction: { $$exists: false } + autocommit: false + readConcern: { $$exists: false } + writeConcern: { $$exists: false } + commandName: findAndModify + databaseName: *database_name + - + commandStartedEvent: + command: + commitTransaction: 1 + lsid: { $$sessionLsid: *session0 } + txnNumber: { $numberLong: '1' } + startTransaction: { $$exists: false } + autocommit: false + readConcern: { $$exists: false } + writeConcern: { $$exists: false } + commandName: commitTransaction + databaseName: admin + outcome: + - + collectionName: *collection_name + databaseName: *database_name + documents: + - { _id: 1 } + - { _id: 2 } + - + description: 'collection writeConcern ignored for findOneAndDelete' + operations: + - + object: testRunner + name: createEntities + arguments: + entities: + - collection: + id: &collection_wc_majority collection_wc_majority + database: *database0 + collectionName: *collection_name + collectionOptions: + writeConcern: { w: majority } + - + object: *session0 + name: startTransaction + arguments: + writeConcern: + w: majority + - + object: *collection_wc_majority + name: findOneAndDelete + arguments: + session: *session0 + filter: { _id: 3 } + expectResult: + _id: 3 + - + object: *session0 + name: commitTransaction + expectEvents: + - + client: *client0 + events: + - + commandStartedEvent: + command: + findAndModify: *collection_name + query: { _id: 3 } + remove: true + lsid: { $$sessionLsid: *session0 } + txnNumber: { $numberLong: '1' } + startTransaction: true + autocommit: false + readConcern: { $$exists: false } + writeConcern: { $$exists: false } + commandName: findAndModify + databaseName: *database_name + - + commandStartedEvent: + command: + commitTransaction: 1 + lsid: { $$sessionLsid: *session0 } + txnNumber: { $numberLong: '1' } + startTransaction: { $$exists: false } + autocommit: false + readConcern: { $$exists: false } + writeConcern: + w: majority + commandName: commitTransaction + databaseName: admin diff --git a/source/transactions/tests/unified/findOneAndReplace.json b/source/transactions/tests/unified/findOneAndReplace.json new file mode 100644 index 0000000000..d9248244b3 --- /dev/null +++ b/source/transactions/tests/unified/findOneAndReplace.json @@ -0,0 +1,352 @@ +{ + "description": "findOneAndReplace", + "schemaVersion": "1.9", + "runOnRequirements": [ + { + "minServerVersion": "4.0", + "topologies": [ + "replicaset" + ] + }, + { + "minServerVersion": "4.1.8", + "topologies": [ + "sharded", + "load-balanced" + ] + } + ], + "createEntities": [ + { + "client": { + "id": "client0", + "useMultipleMongoses": false, + "observeEvents": [ + "commandStartedEvent" + ] + } + }, + { + "database": { + "id": "database0", + "client": "client0", + "databaseName": "transaction-tests" + } + }, + { + "collection": { + "id": "collection0", + "database": "database0", + "collectionName": "test" + } + }, + { + "session": { + "id": "session0", + "client": "client0" + } + } + ], + "initialData": [ + { + "collectionName": "test", + "databaseName": "transaction-tests", + "documents": [ + { + "_id": 1 + }, + { + "_id": 2 + }, + { + "_id": 3 + } + ] + } + ], + "tests": [ + { + "description": "findOneAndReplace", + "operations": [ + { + "object": "session0", + "name": "startTransaction" + }, + { + "object": "collection0", + "name": "findOneAndReplace", + "arguments": { + "session": "session0", + "filter": { + "_id": 3 + }, + "replacement": { + "x": 1 + }, + "returnDocument": "Before" + }, + "expectResult": { + "_id": 3 + } + }, + { + "object": "collection0", + "name": "findOneAndReplace", + "arguments": { + "session": "session0", + "filter": { + "_id": 4 + }, + "replacement": { + "x": 1 + }, + "upsert": true, + "returnDocument": "After" + }, + "expectResult": { + "_id": 4, + "x": 1 + } + }, + { + "object": "session0", + "name": "commitTransaction" + } + ], + "expectEvents": [ + { + "client": "client0", + "events": [ + { + "commandStartedEvent": { + "command": { + "findAndModify": "test", + "query": { + "_id": 3 + }, + "update": { + "x": 1 + }, + "new": false, + "lsid": { + "$$sessionLsid": "session0" + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": true, + "autocommit": false, + "readConcern": { + "$$exists": false + }, + "writeConcern": { + "$$exists": false + } + }, + "commandName": "findAndModify", + "databaseName": "transaction-tests" + } + }, + { + "commandStartedEvent": { + "command": { + "findAndModify": "test", + "query": { + "_id": 4 + }, + "update": { + "x": 1 + }, + "new": true, + "upsert": true, + "lsid": { + "$$sessionLsid": "session0" + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": { + "$$exists": false + }, + "autocommit": false, + "readConcern": { + "$$exists": false + }, + "writeConcern": { + "$$exists": false + } + }, + "commandName": "findAndModify", + "databaseName": "transaction-tests" + } + }, + { + "commandStartedEvent": { + "command": { + "commitTransaction": 1, + "lsid": { + "$$sessionLsid": "session0" + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": { + "$$exists": false + }, + "autocommit": false, + "readConcern": { + "$$exists": false + }, + "writeConcern": { + "$$exists": false + } + }, + "commandName": "commitTransaction", + "databaseName": "admin" + } + } + ] + } + ], + "outcome": [ + { + "collectionName": "test", + "databaseName": "transaction-tests", + "documents": [ + { + "_id": 1 + }, + { + "_id": 2 + }, + { + "_id": 3, + "x": 1 + }, + { + "_id": 4, + "x": 1 + } + ] + } + ] + }, + { + "description": "collection writeConcern ignored for findOneAndReplace", + "operations": [ + { + "object": "testRunner", + "name": "createEntities", + "arguments": { + "entities": [ + { + "collection": { + "id": "collection_wc_majority", + "database": "database0", + "collectionName": "test", + "collectionOptions": { + "writeConcern": { + "w": "majority" + } + } + } + } + ] + } + }, + { + "object": "session0", + "name": "startTransaction", + "arguments": { + "writeConcern": { + "w": "majority" + } + } + }, + { + "object": "collection_wc_majority", + "name": "findOneAndReplace", + "arguments": { + "session": "session0", + "filter": { + "_id": 3 + }, + "replacement": { + "x": 1 + }, + "returnDocument": "Before" + }, + "expectResult": { + "_id": 3 + } + }, + { + "object": "session0", + "name": "commitTransaction" + } + ], + "expectEvents": [ + { + "client": "client0", + "events": [ + { + "commandStartedEvent": { + "command": { + "findAndModify": "test", + "query": { + "_id": 3 + }, + "update": { + "x": 1 + }, + "new": false, + "lsid": { + "$$sessionLsid": "session0" + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": true, + "autocommit": false, + "readConcern": { + "$$exists": false + }, + "writeConcern": { + "$$exists": false + } + }, + "commandName": "findAndModify", + "databaseName": "transaction-tests" + } + }, + { + "commandStartedEvent": { + "command": { + "commitTransaction": 1, + "lsid": { + "$$sessionLsid": "session0" + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": { + "$$exists": false + }, + "autocommit": false, + "readConcern": { + "$$exists": false + }, + "writeConcern": { + "w": "majority" + } + }, + "commandName": "commitTransaction", + "databaseName": "admin" + } + } + ] + } + ] + } + ] +} diff --git a/source/transactions/tests/unified/findOneAndReplace.yml b/source/transactions/tests/unified/findOneAndReplace.yml new file mode 100644 index 0000000000..2b4a9920d6 --- /dev/null +++ b/source/transactions/tests/unified/findOneAndReplace.yml @@ -0,0 +1,202 @@ +description: findOneAndReplace + +schemaVersion: '1.9' + +runOnRequirements: + - + minServerVersion: '4.0' + topologies: + - replicaset + - + minServerVersion: 4.1.8 + topologies: + - sharded + - load-balanced + +createEntities: + - + client: + id: &client0 client0 + useMultipleMongoses: false + observeEvents: + - commandStartedEvent + - + database: + id: &database0 database0 + client: *client0 + databaseName: &database_name transaction-tests + - + collection: + id: &collection0 collection0 + database: *database0 + collectionName: &collection_name test + - + session: + id: &session0 session0 + client: *client0 + +initialData: + - + collectionName: *collection_name + databaseName: *database_name + documents: + - { _id: 1 } + - { _id: 2 } + - { _id: 3 } + +tests: + - + description: findOneAndReplace + operations: + - + object: *session0 + name: startTransaction + - + object: *collection0 + name: findOneAndReplace + arguments: + session: *session0 + filter: { _id: 3 } + replacement: + x: 1 + returnDocument: Before + expectResult: + _id: 3 + - + object: *collection0 + name: findOneAndReplace + arguments: + session: *session0 + filter: { _id: 4 } + replacement: + x: 1 + upsert: true + returnDocument: After + expectResult: + _id: 4 + x: 1 + - + object: *session0 + name: commitTransaction + expectEvents: + - + client: *client0 + events: + - + commandStartedEvent: + command: + findAndModify: *collection_name + query: { _id: 3 } + update: { x: 1 } + new: false + lsid: { $$sessionLsid: *session0 } + txnNumber: { $numberLong: '1' } + startTransaction: true + autocommit: false + readConcern: { $$exists: false } + writeConcern: { $$exists: false } + commandName: findAndModify + databaseName: *database_name + - + commandStartedEvent: + command: + findAndModify: *collection_name + query: { _id: 4 } + update: { x: 1 } + new: true + upsert: true + lsid: { $$sessionLsid: *session0 } + txnNumber: { $numberLong: '1' } + startTransaction: { $$exists: false } + autocommit: false + readConcern: { $$exists: false } + writeConcern: { $$exists: false } + commandName: findAndModify + databaseName: *database_name + - + commandStartedEvent: + command: + commitTransaction: 1 + lsid: { $$sessionLsid: *session0 } + txnNumber: { $numberLong: '1' } + startTransaction: { $$exists: false } + autocommit: false + readConcern: { $$exists: false } + writeConcern: { $$exists: false } + commandName: commitTransaction + databaseName: admin + outcome: + - + collectionName: *collection_name + databaseName: *database_name + documents: + - { _id: 1 } + - { _id: 2 } + - { _id: 3, x: 1 } + - { _id: 4, x: 1 } + - + description: 'collection writeConcern ignored for findOneAndReplace' + operations: + - + object: testRunner + name: createEntities + arguments: + entities: + - collection: + id: &collection_wc_majority collection_wc_majority + database: *database0 + collectionName: *collection_name + collectionOptions: + writeConcern: { w: majority } + - + object: *session0 + name: startTransaction + arguments: + writeConcern: + w: majority + - + object: *collection_wc_majority + name: findOneAndReplace + arguments: + session: *session0 + filter: { _id: 3 } + replacement: + x: 1 + returnDocument: Before + expectResult: + _id: 3 + - + object: *session0 + name: commitTransaction + expectEvents: + - + client: *client0 + events: + - + commandStartedEvent: + command: + findAndModify: *collection_name + query: { _id: 3 } + update: { x: 1 } + new: false + lsid: { $$sessionLsid: *session0 } + txnNumber: { $numberLong: '1' } + startTransaction: true + autocommit: false + readConcern: { $$exists: false } + writeConcern: { $$exists: false } + commandName: findAndModify + databaseName: *database_name + - + commandStartedEvent: + command: + commitTransaction: 1 + lsid: { $$sessionLsid: *session0 } + txnNumber: { $numberLong: '1' } + startTransaction: { $$exists: false } + autocommit: false + readConcern: { $$exists: false } + writeConcern: + w: majority + commandName: commitTransaction + databaseName: admin diff --git a/source/transactions/tests/unified/findOneAndUpdate.json b/source/transactions/tests/unified/findOneAndUpdate.json new file mode 100644 index 0000000000..34a40bb570 --- /dev/null +++ b/source/transactions/tests/unified/findOneAndUpdate.json @@ -0,0 +1,538 @@ +{ + "description": "findOneAndUpdate", + "schemaVersion": "1.9", + "runOnRequirements": [ + { + "minServerVersion": "4.0", + "topologies": [ + "replicaset" + ] + }, + { + "minServerVersion": "4.1.8", + "topologies": [ + "sharded", + "load-balanced" + ] + } + ], + "createEntities": [ + { + "client": { + "id": "client0", + "useMultipleMongoses": false, + "observeEvents": [ + "commandStartedEvent" + ] + } + }, + { + "database": { + "id": "database0", + "client": "client0", + "databaseName": "transaction-tests" + } + }, + { + "collection": { + "id": "collection0", + "database": "database0", + "collectionName": "test" + } + }, + { + "session": { + "id": "session0", + "client": "client0" + } + } + ], + "initialData": [ + { + "collectionName": "test", + "databaseName": "transaction-tests", + "documents": [ + { + "_id": 1 + }, + { + "_id": 2 + }, + { + "_id": 3 + } + ] + } + ], + "tests": [ + { + "description": "findOneAndUpdate", + "operations": [ + { + "object": "session0", + "name": "startTransaction" + }, + { + "object": "collection0", + "name": "findOneAndUpdate", + "arguments": { + "session": "session0", + "filter": { + "_id": 3 + }, + "update": { + "$inc": { + "x": 1 + } + }, + "returnDocument": "Before" + }, + "expectResult": { + "_id": 3 + } + }, + { + "object": "collection0", + "name": "findOneAndUpdate", + "arguments": { + "session": "session0", + "filter": { + "_id": 4 + }, + "update": { + "$inc": { + "x": 1 + } + }, + "upsert": true, + "returnDocument": "After" + }, + "expectResult": { + "_id": 4, + "x": 1 + } + }, + { + "object": "session0", + "name": "commitTransaction" + }, + { + "object": "session0", + "name": "startTransaction" + }, + { + "object": "collection0", + "name": "findOneAndUpdate", + "arguments": { + "session": "session0", + "filter": { + "_id": 3 + }, + "update": { + "$inc": { + "x": 1 + } + }, + "returnDocument": "Before" + }, + "expectResult": { + "_id": 3, + "x": 1 + } + }, + { + "object": "session0", + "name": "commitTransaction" + }, + { + "object": "session0", + "name": "startTransaction" + }, + { + "object": "collection0", + "name": "findOneAndUpdate", + "arguments": { + "session": "session0", + "filter": { + "_id": 3 + }, + "update": { + "$inc": { + "x": 1 + } + }, + "returnDocument": "Before" + }, + "expectResult": { + "_id": 3, + "x": 2 + } + }, + { + "object": "session0", + "name": "abortTransaction" + } + ], + "expectEvents": [ + { + "client": "client0", + "events": [ + { + "commandStartedEvent": { + "command": { + "findAndModify": "test", + "query": { + "_id": 3 + }, + "update": { + "$inc": { + "x": 1 + } + }, + "new": false, + "lsid": { + "$$sessionLsid": "session0" + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": true, + "autocommit": false, + "readConcern": { + "$$exists": false + }, + "writeConcern": { + "$$exists": false + } + }, + "commandName": "findAndModify", + "databaseName": "transaction-tests" + } + }, + { + "commandStartedEvent": { + "command": { + "findAndModify": "test", + "query": { + "_id": 4 + }, + "update": { + "$inc": { + "x": 1 + } + }, + "new": true, + "upsert": true, + "lsid": { + "$$sessionLsid": "session0" + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": { + "$$exists": false + }, + "autocommit": false, + "readConcern": { + "$$exists": false + }, + "writeConcern": { + "$$exists": false + } + }, + "commandName": "findAndModify", + "databaseName": "transaction-tests" + } + }, + { + "commandStartedEvent": { + "command": { + "commitTransaction": 1, + "lsid": { + "$$sessionLsid": "session0" + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": { + "$$exists": false + }, + "autocommit": false, + "readConcern": { + "$$exists": false + }, + "writeConcern": { + "$$exists": false + } + }, + "commandName": "commitTransaction", + "databaseName": "admin" + } + }, + { + "commandStartedEvent": { + "command": { + "findAndModify": "test", + "query": { + "_id": 3 + }, + "update": { + "$inc": { + "x": 1 + } + }, + "new": false, + "lsid": { + "$$sessionLsid": "session0" + }, + "txnNumber": { + "$numberLong": "2" + }, + "startTransaction": true, + "autocommit": false, + "readConcern": { + "afterClusterTime": { + "$$exists": true + } + }, + "writeConcern": { + "$$exists": false + } + }, + "commandName": "findAndModify", + "databaseName": "transaction-tests" + } + }, + { + "commandStartedEvent": { + "command": { + "commitTransaction": 1, + "lsid": { + "$$sessionLsid": "session0" + }, + "txnNumber": { + "$numberLong": "2" + }, + "startTransaction": { + "$$exists": false + }, + "autocommit": false, + "readConcern": { + "$$exists": false + }, + "writeConcern": { + "$$exists": false + } + }, + "commandName": "commitTransaction", + "databaseName": "admin" + } + }, + { + "commandStartedEvent": { + "command": { + "findAndModify": "test", + "query": { + "_id": 3 + }, + "update": { + "$inc": { + "x": 1 + } + }, + "new": false, + "lsid": { + "$$sessionLsid": "session0" + }, + "txnNumber": { + "$numberLong": "3" + }, + "startTransaction": true, + "autocommit": false, + "readConcern": { + "afterClusterTime": { + "$$exists": true + } + }, + "writeConcern": { + "$$exists": false + } + }, + "commandName": "findAndModify", + "databaseName": "transaction-tests" + } + }, + { + "commandStartedEvent": { + "command": { + "abortTransaction": 1, + "lsid": { + "$$sessionLsid": "session0" + }, + "txnNumber": { + "$numberLong": "3" + }, + "startTransaction": { + "$$exists": false + }, + "autocommit": false, + "readConcern": { + "$$exists": false + }, + "writeConcern": { + "$$exists": false + } + }, + "commandName": "abortTransaction", + "databaseName": "admin" + } + } + ] + } + ], + "outcome": [ + { + "collectionName": "test", + "databaseName": "transaction-tests", + "documents": [ + { + "_id": 1 + }, + { + "_id": 2 + }, + { + "_id": 3, + "x": 2 + }, + { + "_id": 4, + "x": 1 + } + ] + } + ] + }, + { + "description": "collection writeConcern ignored for findOneAndUpdate", + "operations": [ + { + "object": "testRunner", + "name": "createEntities", + "arguments": { + "entities": [ + { + "collection": { + "id": "collection_wc_majority", + "database": "database0", + "collectionName": "test", + "collectionOptions": { + "writeConcern": { + "w": "majority" + } + } + } + } + ] + } + }, + { + "object": "session0", + "name": "startTransaction", + "arguments": { + "writeConcern": { + "w": "majority" + } + } + }, + { + "object": "collection_wc_majority", + "name": "findOneAndUpdate", + "arguments": { + "session": "session0", + "filter": { + "_id": 3 + }, + "update": { + "$inc": { + "x": 1 + } + }, + "returnDocument": "Before" + }, + "expectResult": { + "_id": 3 + } + }, + { + "object": "session0", + "name": "commitTransaction" + } + ], + "expectEvents": [ + { + "client": "client0", + "events": [ + { + "commandStartedEvent": { + "command": { + "findAndModify": "test", + "query": { + "_id": 3 + }, + "update": { + "$inc": { + "x": 1 + } + }, + "new": false, + "lsid": { + "$$sessionLsid": "session0" + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": true, + "autocommit": false, + "readConcern": { + "$$exists": false + }, + "writeConcern": { + "$$exists": false + } + }, + "commandName": "findAndModify", + "databaseName": "transaction-tests" + } + }, + { + "commandStartedEvent": { + "command": { + "commitTransaction": 1, + "lsid": { + "$$sessionLsid": "session0" + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": { + "$$exists": false + }, + "autocommit": false, + "readConcern": { + "$$exists": false + }, + "writeConcern": { + "w": "majority" + } + }, + "commandName": "commitTransaction", + "databaseName": "admin" + } + } + ] + } + ] + } + ] +} diff --git a/source/transactions/tests/unified/findOneAndUpdate.yml b/source/transactions/tests/unified/findOneAndUpdate.yml new file mode 100644 index 0000000000..1865cabb0d --- /dev/null +++ b/source/transactions/tests/unified/findOneAndUpdate.yml @@ -0,0 +1,301 @@ +description: findOneAndUpdate + +schemaVersion: '1.9' + +runOnRequirements: + - + minServerVersion: '4.0' + topologies: + - replicaset + - + minServerVersion: 4.1.8 + topologies: + - sharded + - load-balanced + +createEntities: + - + client: + id: &client0 client0 + useMultipleMongoses: false + observeEvents: + - commandStartedEvent + - + database: + id: &database0 database0 + client: *client0 + databaseName: &database_name transaction-tests + - + collection: + id: &collection0 collection0 + database: *database0 + collectionName: &collection_name test + - + session: + id: &session0 session0 + client: *client0 + +initialData: + - + collectionName: *collection_name + databaseName: *database_name + documents: + - { _id: 1 } + - { _id: 2 } + - { _id: 3 } + +tests: + - + description: findOneAndUpdate + operations: + - + object: *session0 + name: startTransaction + - + object: *collection0 + name: findOneAndUpdate + arguments: + session: *session0 + filter: { _id: 3 } + update: + $inc: + x: 1 + returnDocument: Before + expectResult: + _id: 3 + - + object: *collection0 + name: findOneAndUpdate + arguments: + session: *session0 + filter: { _id: 4 } + update: + $inc: + x: 1 + upsert: true + returnDocument: After + expectResult: + _id: 4 + x: 1 + - + object: *session0 + name: commitTransaction + - + object: *session0 + name: startTransaction + # Test a second time to ensure txnNumber is incremented + - + object: *collection0 + name: findOneAndUpdate + arguments: + session: *session0 + filter: { _id: 3 } + update: + $inc: + x: 1 + returnDocument: Before + expectResult: + _id: 3 + x: 1 + - + object: *session0 + name: commitTransaction + # Test a third time to ensure abort works + - + object: *session0 + name: startTransaction + - + object: *collection0 + name: findOneAndUpdate + arguments: + session: *session0 + filter: { _id: 3 } + update: + $inc: + x: 1 + returnDocument: Before + expectResult: + _id: 3 + x: 2 + - + object: *session0 + name: abortTransaction + expectEvents: + - + client: *client0 + events: + - + commandStartedEvent: + command: + findAndModify: *collection_name + query: { _id: 3 } + update: { $inc: { x: 1 } } + new: false + lsid: { $$sessionLsid: *session0 } + txnNumber: { $numberLong: '1' } + startTransaction: true + autocommit: false + readConcern: { $$exists: false } + writeConcern: { $$exists: false } + commandName: findAndModify + databaseName: *database_name + - + commandStartedEvent: + command: + findAndModify: *collection_name + query: { _id: 4 } + update: { $inc: { x: 1 } } + new: true + upsert: true + lsid: { $$sessionLsid: *session0 } + txnNumber: { $numberLong: '1' } + startTransaction: { $$exists: false } + autocommit: false + readConcern: { $$exists: false } + writeConcern: { $$exists: false } + commandName: findAndModify + databaseName: *database_name + - + commandStartedEvent: + command: + commitTransaction: 1 + lsid: { $$sessionLsid: *session0 } + txnNumber: { $numberLong: '1' } + startTransaction: { $$exists: false } + autocommit: false + readConcern: { $$exists: false } + writeConcern: { $$exists: false } + commandName: commitTransaction + databaseName: admin + - + commandStartedEvent: + command: + findAndModify: *collection_name + query: { _id: 3 } + update: { $inc: { x: 1 } } + new: false + lsid: { $$sessionLsid: *session0 } + txnNumber: { $numberLong: '2' } + startTransaction: true + autocommit: false + readConcern: + afterClusterTime: { $$exists: true } + writeConcern: { $$exists: false } + commandName: findAndModify + databaseName: *database_name + - + commandStartedEvent: + command: + commitTransaction: 1 + lsid: { $$sessionLsid: *session0 } + txnNumber: { $numberLong: '2' } + startTransaction: { $$exists: false } + autocommit: false + readConcern: { $$exists: false } + writeConcern: { $$exists: false } + commandName: commitTransaction + databaseName: admin + - + commandStartedEvent: + command: + findAndModify: *collection_name + query: { _id: 3 } + update: { $inc: { x: 1 } } + new: false + lsid: { $$sessionLsid: *session0 } + txnNumber: { $numberLong: '3' } + startTransaction: true + autocommit: false + readConcern: + afterClusterTime: { $$exists: true } + writeConcern: { $$exists: false } + commandName: findAndModify + databaseName: *database_name + - + commandStartedEvent: + command: + abortTransaction: 1 + lsid: { $$sessionLsid: *session0 } + txnNumber: { $numberLong: '3' } + startTransaction: { $$exists: false } + autocommit: false + readConcern: { $$exists: false } + writeConcern: { $$exists: false } + commandName: abortTransaction + databaseName: admin + outcome: + - + collectionName: *collection_name + databaseName: *database_name + documents: + - { _id: 1 } + - { _id: 2 } + - { _id: 3, x: 2 } + - { _id: 4, x: 1 } + - + description: 'collection writeConcern ignored for findOneAndUpdate' + operations: + - + object: testRunner + name: createEntities + arguments: + entities: + - collection: + id: &collection_wc_majority collection_wc_majority + database: *database0 + collectionName: *collection_name + collectionOptions: + writeConcern: { w: majority } + - + object: *session0 + name: startTransaction + arguments: + writeConcern: + w: majority + - + object: *collection_wc_majority + name: findOneAndUpdate + arguments: + session: *session0 + filter: { _id: 3 } + update: + $inc: + x: 1 + returnDocument: Before + expectResult: + _id: 3 + - + object: *session0 + name: commitTransaction + expectEvents: + - + client: *client0 + events: + - + commandStartedEvent: + command: + findAndModify: *collection_name + query: { _id: 3 } + update: { $inc: { x: 1 } } + new: false + lsid: { $$sessionLsid: *session0 } + txnNumber: { $numberLong: '1' } + startTransaction: true + autocommit: false + readConcern: { $$exists: false } + writeConcern: { $$exists: false } + commandName: findAndModify + databaseName: *database_name + - + commandStartedEvent: + command: + commitTransaction: 1 + lsid: { $$sessionLsid: *session0 } + txnNumber: { $numberLong: '1' } + startTransaction: { $$exists: false } + autocommit: false + readConcern: { $$exists: false } + writeConcern: + w: majority + commandName: commitTransaction + databaseName: admin diff --git a/source/transactions/tests/unified/insert.json b/source/transactions/tests/unified/insert.json new file mode 100644 index 0000000000..9a80d8bf4b --- /dev/null +++ b/source/transactions/tests/unified/insert.json @@ -0,0 +1,895 @@ +{ + "description": "insert", + "schemaVersion": "1.9", + "runOnRequirements": [ + { + "minServerVersion": "4.0", + "topologies": [ + "replicaset" + ] + }, + { + "minServerVersion": "4.1.8", + "topologies": [ + "sharded", + "load-balanced" + ] + } + ], + "createEntities": [ + { + "client": { + "id": "client0", + "useMultipleMongoses": false, + "observeEvents": [ + "commandStartedEvent" + ] + } + }, + { + "database": { + "id": "database0", + "client": "client0", + "databaseName": "transaction-tests" + } + }, + { + "collection": { + "id": "collection0", + "database": "database0", + "collectionName": "test" + } + }, + { + "session": { + "id": "session0", + "client": "client0" + } + }, + { + "session": { + "id": "session1", + "client": "client0" + } + } + ], + "initialData": [ + { + "collectionName": "test", + "databaseName": "transaction-tests", + "documents": [] + } + ], + "tests": [ + { + "description": "insert", + "operations": [ + { + "object": "session0", + "name": "startTransaction" + }, + { + "object": "collection0", + "name": "insertOne", + "arguments": { + "session": "session0", + "document": { + "_id": 1 + } + }, + "expectResult": { + "$$unsetOrMatches": { + "insertedId": { + "$$unsetOrMatches": 1 + } + } + } + }, + { + "object": "collection0", + "name": "insertMany", + "arguments": { + "documents": [ + { + "_id": 2 + }, + { + "_id": 3 + } + ], + "session": "session0" + }, + "expectResult": { + "$$unsetOrMatches": { + "insertedIds": { + "$$unsetOrMatches": { + "0": 2, + "1": 3 + } + } + } + } + }, + { + "object": "collection0", + "name": "insertOne", + "arguments": { + "session": "session0", + "document": { + "_id": 4 + } + }, + "expectResult": { + "$$unsetOrMatches": { + "insertedId": { + "$$unsetOrMatches": 4 + } + } + } + }, + { + "object": "session0", + "name": "commitTransaction" + }, + { + "object": "session0", + "name": "startTransaction" + }, + { + "object": "collection0", + "name": "insertOne", + "arguments": { + "session": "session0", + "document": { + "_id": 5 + } + }, + "expectResult": { + "$$unsetOrMatches": { + "insertedId": { + "$$unsetOrMatches": 5 + } + } + } + }, + { + "object": "session0", + "name": "commitTransaction" + } + ], + "expectEvents": [ + { + "client": "client0", + "events": [ + { + "commandStartedEvent": { + "command": { + "insert": "test", + "documents": [ + { + "_id": 1 + } + ], + "ordered": true, + "readConcern": { + "$$exists": false + }, + "lsid": { + "$$sessionLsid": "session0" + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": true, + "autocommit": false, + "writeConcern": { + "$$exists": false + } + }, + "commandName": "insert", + "databaseName": "transaction-tests" + } + }, + { + "commandStartedEvent": { + "command": { + "insert": "test", + "documents": [ + { + "_id": 2 + }, + { + "_id": 3 + } + ], + "ordered": true, + "lsid": { + "$$sessionLsid": "session0" + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": { + "$$exists": false + }, + "autocommit": false, + "writeConcern": { + "$$exists": false + } + }, + "commandName": "insert", + "databaseName": "transaction-tests" + } + }, + { + "commandStartedEvent": { + "command": { + "insert": "test", + "documents": [ + { + "_id": 4 + } + ], + "ordered": true, + "lsid": { + "$$sessionLsid": "session0" + }, + "txnNumber": { + "$numberLong": "1" + }, + "autocommit": false, + "writeConcern": { + "$$exists": false + } + }, + "commandName": "insert", + "databaseName": "transaction-tests" + } + }, + { + "commandStartedEvent": { + "command": { + "commitTransaction": 1, + "lsid": { + "$$sessionLsid": "session0" + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": { + "$$exists": false + }, + "autocommit": false, + "writeConcern": { + "$$exists": false + } + }, + "commandName": "commitTransaction", + "databaseName": "admin" + } + }, + { + "commandStartedEvent": { + "command": { + "insert": "test", + "documents": [ + { + "_id": 5 + } + ], + "ordered": true, + "readConcern": { + "afterClusterTime": { + "$$exists": true + } + }, + "lsid": { + "$$sessionLsid": "session0" + }, + "txnNumber": { + "$numberLong": "2" + }, + "startTransaction": true, + "autocommit": false, + "writeConcern": { + "$$exists": false + } + }, + "commandName": "insert", + "databaseName": "transaction-tests" + } + }, + { + "commandStartedEvent": { + "command": { + "commitTransaction": 1, + "lsid": { + "$$sessionLsid": "session0" + }, + "txnNumber": { + "$numberLong": "2" + }, + "startTransaction": { + "$$exists": false + }, + "autocommit": false, + "writeConcern": { + "$$exists": false + } + }, + "commandName": "commitTransaction", + "databaseName": "admin" + } + } + ] + } + ], + "outcome": [ + { + "collectionName": "test", + "databaseName": "transaction-tests", + "documents": [ + { + "_id": 1 + }, + { + "_id": 2 + }, + { + "_id": 3 + }, + { + "_id": 4 + }, + { + "_id": 5 + } + ] + } + ] + }, + { + "description": "insert with session1", + "operations": [ + { + "object": "session1", + "name": "startTransaction" + }, + { + "object": "collection0", + "name": "insertOne", + "arguments": { + "session": "session1", + "document": { + "_id": 1 + } + }, + "expectResult": { + "$$unsetOrMatches": { + "insertedId": { + "$$unsetOrMatches": 1 + } + } + } + }, + { + "object": "collection0", + "name": "insertMany", + "arguments": { + "documents": [ + { + "_id": 2 + }, + { + "_id": 3 + } + ], + "session": "session1" + }, + "expectResult": { + "$$unsetOrMatches": { + "insertedIds": { + "$$unsetOrMatches": { + "0": 2, + "1": 3 + } + } + } + } + }, + { + "object": "session1", + "name": "commitTransaction" + }, + { + "object": "session1", + "name": "startTransaction" + }, + { + "object": "collection0", + "name": "insertOne", + "arguments": { + "session": "session1", + "document": { + "_id": 4 + } + }, + "expectResult": { + "$$unsetOrMatches": { + "insertedId": { + "$$unsetOrMatches": 4 + } + } + } + }, + { + "object": "session1", + "name": "abortTransaction" + } + ], + "expectEvents": [ + { + "client": "client0", + "events": [ + { + "commandStartedEvent": { + "command": { + "insert": "test", + "documents": [ + { + "_id": 1 + } + ], + "ordered": true, + "readConcern": { + "$$exists": false + }, + "lsid": { + "$$sessionLsid": "session1" + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": true, + "autocommit": false, + "writeConcern": { + "$$exists": false + } + }, + "commandName": "insert", + "databaseName": "transaction-tests" + } + }, + { + "commandStartedEvent": { + "command": { + "insert": "test", + "documents": [ + { + "_id": 2 + }, + { + "_id": 3 + } + ], + "ordered": true, + "lsid": { + "$$sessionLsid": "session1" + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": { + "$$exists": false + }, + "autocommit": false, + "writeConcern": { + "$$exists": false + } + }, + "commandName": "insert", + "databaseName": "transaction-tests" + } + }, + { + "commandStartedEvent": { + "command": { + "commitTransaction": 1, + "lsid": { + "$$sessionLsid": "session1" + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": { + "$$exists": false + }, + "autocommit": false, + "writeConcern": { + "$$exists": false + } + }, + "commandName": "commitTransaction", + "databaseName": "admin" + } + }, + { + "commandStartedEvent": { + "command": { + "insert": "test", + "documents": [ + { + "_id": 4 + } + ], + "ordered": true, + "readConcern": { + "afterClusterTime": { + "$$exists": true + } + }, + "lsid": { + "$$sessionLsid": "session1" + }, + "txnNumber": { + "$numberLong": "2" + }, + "startTransaction": true, + "autocommit": false, + "writeConcern": { + "$$exists": false + } + }, + "commandName": "insert", + "databaseName": "transaction-tests" + } + }, + { + "commandStartedEvent": { + "command": { + "abortTransaction": 1, + "lsid": { + "$$sessionLsid": "session1" + }, + "txnNumber": { + "$numberLong": "2" + }, + "startTransaction": { + "$$exists": false + }, + "autocommit": false, + "writeConcern": { + "$$exists": false + } + }, + "commandName": "abortTransaction", + "databaseName": "admin" + } + } + ] + } + ], + "outcome": [ + { + "collectionName": "test", + "databaseName": "transaction-tests", + "documents": [ + { + "_id": 1 + }, + { + "_id": 2 + }, + { + "_id": 3 + } + ] + } + ] + }, + { + "description": "collection writeConcern without transaction", + "operations": [ + { + "object": "testRunner", + "name": "createEntities", + "arguments": { + "entities": [ + { + "client": { + "id": "client1", + "useMultipleMongoses": false, + "uriOptions": { + "retryWrites": false + }, + "observeEvents": [ + "commandStartedEvent" + ] + } + }, + { + "database": { + "id": "database1", + "client": "client1", + "databaseName": "transaction-tests" + } + }, + { + "collection": { + "id": "collection_wc_majority", + "database": "database1", + "collectionName": "test", + "collectionOptions": { + "writeConcern": { + "w": "majority" + } + } + } + }, + { + "session": { + "id": "session2", + "client": "client1" + } + } + ] + } + }, + { + "object": "collection_wc_majority", + "name": "insertOne", + "arguments": { + "session": "session2", + "document": { + "_id": 1 + } + }, + "expectResult": { + "$$unsetOrMatches": { + "insertedId": { + "$$unsetOrMatches": 1 + } + } + } + } + ], + "expectEvents": [ + { + "client": "client1", + "events": [ + { + "commandStartedEvent": { + "command": { + "insert": "test", + "documents": [ + { + "_id": 1 + } + ], + "ordered": true, + "readConcern": { + "$$exists": false + }, + "lsid": { + "$$sessionLsid": "session2" + }, + "txnNumber": { + "$$exists": false + }, + "startTransaction": { + "$$exists": false + }, + "autocommit": { + "$$exists": false + }, + "writeConcern": { + "w": "majority" + } + }, + "commandName": "insert", + "databaseName": "transaction-tests" + } + } + ] + } + ], + "outcome": [ + { + "collectionName": "test", + "databaseName": "transaction-tests", + "documents": [ + { + "_id": 1 + } + ] + } + ] + }, + { + "description": "collection writeConcern ignored for insert", + "operations": [ + { + "object": "testRunner", + "name": "createEntities", + "arguments": { + "entities": [ + { + "collection": { + "id": "collection_wc_majority", + "database": "database0", + "collectionName": "test", + "collectionOptions": { + "writeConcern": { + "w": "majority" + } + } + } + } + ] + } + }, + { + "object": "session0", + "name": "startTransaction", + "arguments": { + "writeConcern": { + "w": "majority" + } + } + }, + { + "object": "collection_wc_majority", + "name": "insertOne", + "arguments": { + "session": "session0", + "document": { + "_id": 1 + } + }, + "expectResult": { + "$$unsetOrMatches": { + "insertedId": { + "$$unsetOrMatches": 1 + } + } + } + }, + { + "object": "collection_wc_majority", + "name": "insertMany", + "arguments": { + "documents": [ + { + "_id": 2 + }, + { + "_id": 3 + } + ], + "session": "session0" + }, + "expectResult": { + "$$unsetOrMatches": { + "insertedIds": { + "$$unsetOrMatches": { + "0": 2, + "1": 3 + } + } + } + } + }, + { + "object": "session0", + "name": "commitTransaction" + } + ], + "expectEvents": [ + { + "client": "client0", + "events": [ + { + "commandStartedEvent": { + "command": { + "insert": "test", + "documents": [ + { + "_id": 1 + } + ], + "ordered": true, + "readConcern": { + "$$exists": false + }, + "lsid": { + "$$sessionLsid": "session0" + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": true, + "autocommit": false, + "writeConcern": { + "$$exists": false + } + }, + "commandName": "insert", + "databaseName": "transaction-tests" + } + }, + { + "commandStartedEvent": { + "command": { + "insert": "test", + "documents": [ + { + "_id": 2 + }, + { + "_id": 3 + } + ], + "ordered": true, + "lsid": { + "$$sessionLsid": "session0" + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": { + "$$exists": false + }, + "autocommit": false, + "writeConcern": { + "$$exists": false + } + }, + "commandName": "insert", + "databaseName": "transaction-tests" + } + }, + { + "commandStartedEvent": { + "command": { + "commitTransaction": 1, + "lsid": { + "$$sessionLsid": "session0" + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": { + "$$exists": false + }, + "autocommit": false, + "writeConcern": { + "w": "majority" + } + }, + "commandName": "commitTransaction", + "databaseName": "admin" + } + } + ] + } + ], + "outcome": [ + { + "collectionName": "test", + "databaseName": "transaction-tests", + "documents": [ + { + "_id": 1 + }, + { + "_id": 2 + }, + { + "_id": 3 + } + ] + } + ] + } + ] +} diff --git a/source/transactions/tests/unified/insert.yml b/source/transactions/tests/unified/insert.yml new file mode 100644 index 0000000000..1e97069715 --- /dev/null +++ b/source/transactions/tests/unified/insert.yml @@ -0,0 +1,485 @@ +description: insert + +schemaVersion: '1.9' + +runOnRequirements: + - + minServerVersion: '4.0' + topologies: + - replicaset + - + minServerVersion: 4.1.8 + topologies: + - sharded + - load-balanced + +createEntities: + - + client: + id: &client0 client0 + useMultipleMongoses: false + observeEvents: + - commandStartedEvent + - + database: + id: &database0 database0 + client: *client0 + databaseName: &database_name transaction-tests + - + collection: + id: &collection0 collection0 + database: *database0 + collectionName: &collection_name test + - + session: + id: &session0 session0 + client: *client0 + - + session: + id: &session1 session1 + client: *client0 + +initialData: + - + collectionName: *collection_name + databaseName: *database_name + documents: [] + +tests: + - + description: insert + operations: + - + object: *session0 + name: startTransaction + - + object: *collection0 + name: insertOne + arguments: + session: *session0 + document: { _id: 1 } + expectResult: + $$unsetOrMatches: { insertedId: { $$unsetOrMatches: 1 } } + - + object: *collection0 + name: insertMany + arguments: + documents: + - { _id: 2 } + - { _id: 3 } + session: *session0 + expectResult: + $$unsetOrMatches: + insertedIds: + $$unsetOrMatches: + '0': 2 + '1': 3 + - + object: *collection0 + name: insertOne + arguments: + session: *session0 + document: { _id: 4 } + expectResult: + $$unsetOrMatches: { insertedId: { $$unsetOrMatches: 4 } } + - + object: *session0 + name: commitTransaction + - + object: *session0 + name: startTransaction + - + object: *collection0 + name: insertOne + arguments: + session: *session0 + document: { _id: 5 } + expectResult: + $$unsetOrMatches: { insertedId: { $$unsetOrMatches: 5 } } + - + object: *session0 + name: commitTransaction + expectEvents: + - + client: *client0 + events: + - + commandStartedEvent: + command: + insert: *collection_name + documents: + - { _id: 1 } + ordered: true + readConcern: { $$exists: false } + lsid: { $$sessionLsid: *session0 } + txnNumber: { $numberLong: '1' } + startTransaction: true + autocommit: false + writeConcern: { $$exists: false } + commandName: insert + databaseName: *database_name + - + commandStartedEvent: + command: + insert: *collection_name + documents: + - { _id: 2 } + - { _id: 3 } + ordered: true + lsid: { $$sessionLsid: *session0 } + txnNumber: { $numberLong: '1' } + startTransaction: { $$exists: false } + autocommit: false + writeConcern: { $$exists: false } + commandName: insert + databaseName: *database_name + - + commandStartedEvent: + command: + insert: *collection_name + documents: + - { _id: 4 } + ordered: true + lsid: { $$sessionLsid: *session0 } + txnNumber: { $numberLong: '1' } + autocommit: false + writeConcern: { $$exists: false } + commandName: insert + databaseName: *database_name + - + commandStartedEvent: + command: + commitTransaction: 1 + lsid: { $$sessionLsid: *session0 } + txnNumber: { $numberLong: '1' } + startTransaction: { $$exists: false } + autocommit: false + writeConcern: { $$exists: false } + commandName: commitTransaction + databaseName: admin + - + commandStartedEvent: + command: + insert: *collection_name + documents: + - { _id: 5 } + ordered: true + readConcern: + afterClusterTime: { $$exists: true } + lsid: { $$sessionLsid: *session0 } + txnNumber: { $numberLong: '2' } + startTransaction: true + autocommit: false + writeConcern: { $$exists: false } + commandName: insert + databaseName: *database_name + - + commandStartedEvent: + command: + commitTransaction: 1 + lsid: { $$sessionLsid: *session0 } + txnNumber: { $numberLong: '2' } + startTransaction: { $$exists: false } + autocommit: false + writeConcern: { $$exists: false } + commandName: commitTransaction + databaseName: admin + outcome: + - + collectionName: *collection_name + databaseName: *database_name + documents: + - { _id: 1 } + - { _id: 2 } + - { _id: 3 } + - { _id: 4 } + - { _id: 5 } + # This test proves that the driver uses "session1" correctly in operations + # and APM expectations + - + description: 'insert with session1' + operations: + - + object: *session1 + name: startTransaction + - + object: *collection0 + name: insertOne + arguments: + session: *session1 + document: { _id: 1 } + expectResult: + $$unsetOrMatches: { insertedId: { $$unsetOrMatches: 1 } } + - + object: *collection0 + name: insertMany + arguments: + documents: + - { _id: 2 } + - { _id: 3 } + session: *session1 + expectResult: + $$unsetOrMatches: + insertedIds: + $$unsetOrMatches: + '0': 2 + '1': 3 + - + object: *session1 + name: commitTransaction + - + object: *session1 + name: startTransaction + - + object: *collection0 + name: insertOne + arguments: + session: *session1 + document: { _id: 4 } + expectResult: + $$unsetOrMatches: { insertedId: { $$unsetOrMatches: 4 } } + - + object: *session1 + name: abortTransaction + expectEvents: + - + client: *client0 + events: + - + commandStartedEvent: + command: + insert: *collection_name + documents: + - { _id: 1 } + ordered: true + readConcern: { $$exists: false } + lsid: { $$sessionLsid: *session1 } + txnNumber: { $numberLong: '1' } + startTransaction: true + autocommit: false + writeConcern: { $$exists: false } + commandName: insert + databaseName: *database_name + - + commandStartedEvent: + command: + insert: *collection_name + documents: + - { _id: 2 } + - { _id: 3 } + ordered: true + lsid: { $$sessionLsid: *session1 } + txnNumber: { $numberLong: '1' } + startTransaction: { $$exists: false } + autocommit: false + writeConcern: { $$exists: false } + commandName: insert + databaseName: *database_name + - + commandStartedEvent: + command: + commitTransaction: 1 + lsid: { $$sessionLsid: *session1 } + txnNumber: { $numberLong: '1' } + startTransaction: { $$exists: false } + autocommit: false + writeConcern: { $$exists: false } + commandName: commitTransaction + databaseName: admin + - + commandStartedEvent: + command: + insert: *collection_name + documents: + - { _id: 4 } + ordered: true + readConcern: + afterClusterTime: { $$exists: true } + lsid: { $$sessionLsid: *session1 } + txnNumber: { $numberLong: '2' } + startTransaction: true + autocommit: false + writeConcern: { $$exists: false } + commandName: insert + databaseName: *database_name + - + commandStartedEvent: + command: + abortTransaction: 1 + lsid: { $$sessionLsid: *session1 } + txnNumber: { $numberLong: '2' } + startTransaction: { $$exists: false } + autocommit: false + writeConcern: { $$exists: false } + commandName: abortTransaction + databaseName: admin + outcome: + - + collectionName: *collection_name + databaseName: *database_name + documents: + - { _id: 1 } + - { _id: 2 } + - { _id: 3 } + # This test proves that the driver parses the collectionOptions writeConcern + - + description: 'collection writeConcern without transaction' + operations: + - + object: testRunner + name: createEntities + arguments: + entities: + - client: + id: &client1 client1 + useMultipleMongoses: false + uriOptions: + retryWrites: false + observeEvents: + - commandStartedEvent + - database: + id: &database1 database1 + client: *client1 + databaseName: *database_name + - collection: + id: &collection_wc_majority collection_wc_majority + database: *database1 + collectionName: *collection_name + collectionOptions: + writeConcern: { w: majority } + - session: + id: &session2 session2 + client: *client1 + - + object: *collection_wc_majority + name: insertOne + arguments: + session: *session2 + document: { _id: 1 } + expectResult: + $$unsetOrMatches: { insertedId: { $$unsetOrMatches: 1 } } + expectEvents: + - + client: *client1 + events: + - + commandStartedEvent: + command: + insert: *collection_name + documents: + - { _id: 1 } + ordered: true + readConcern: { $$exists: false } + lsid: { $$sessionLsid: *session2 } + txnNumber: { $$exists: false } + startTransaction: { $$exists: false } + autocommit: { $$exists: false } + writeConcern: + w: majority + commandName: insert + databaseName: *database_name + outcome: + - + collectionName: *collection_name + databaseName: *database_name + documents: + - { _id: 1 } + - + description: 'collection writeConcern ignored for insert' + operations: + - + object: testRunner + name: createEntities + arguments: + entities: + - collection: + id: &collection_wc_majority collection_wc_majority + database: *database0 + collectionName: *collection_name + collectionOptions: + writeConcern: { w: majority } + - + object: *session0 + name: startTransaction + arguments: + writeConcern: + w: majority + - + object: *collection_wc_majority + name: insertOne + arguments: + session: *session0 + document: { _id: 1 } + expectResult: + $$unsetOrMatches: { insertedId: { $$unsetOrMatches: 1 } } + - + object: *collection_wc_majority + name: insertMany + arguments: + documents: + - { _id: 2 } + - { _id: 3 } + session: *session0 + expectResult: + $$unsetOrMatches: + insertedIds: + $$unsetOrMatches: + '0': 2 + '1': 3 + - + object: *session0 + name: commitTransaction + expectEvents: + - + client: *client0 + events: + - + commandStartedEvent: + command: + insert: *collection_name + documents: + - { _id: 1 } + ordered: true + readConcern: { $$exists: false } + lsid: { $$sessionLsid: *session0 } + txnNumber: { $numberLong: '1' } + startTransaction: true + autocommit: false + writeConcern: { $$exists: false } + commandName: insert + databaseName: *database_name + - + commandStartedEvent: + command: + insert: *collection_name + documents: + - { _id: 2 } + - { _id: 3 } + ordered: true + lsid: { $$sessionLsid: *session0 } + txnNumber: { $numberLong: '1' } + startTransaction: { $$exists: false } + autocommit: false + writeConcern: { $$exists: false } + commandName: insert + databaseName: *database_name + - + commandStartedEvent: + command: + commitTransaction: 1 + lsid: { $$sessionLsid: *session0 } + txnNumber: { $numberLong: '1' } + startTransaction: { $$exists: false } + autocommit: false + writeConcern: + w: majority + commandName: commitTransaction + databaseName: admin + outcome: + - + collectionName: *collection_name + databaseName: *database_name + documents: + - { _id: 1 } + - { _id: 2 } + - { _id: 3 } diff --git a/source/transactions/tests/legacy/isolation.json b/source/transactions/tests/unified/isolation.json similarity index 53% rename from source/transactions/tests/legacy/isolation.json rename to source/transactions/tests/unified/isolation.json index fc33781473..5d0a0139fb 100644 --- a/source/transactions/tests/legacy/isolation.json +++ b/source/transactions/tests/unified/isolation.json @@ -1,226 +1,281 @@ { - "runOn": [ + "description": "isolation", + "schemaVersion": "1.3", + "runOnRequirements": [ { "minServerVersion": "4.0", - "topology": [ + "topologies": [ "replicaset" ] }, { "minServerVersion": "4.1.8", - "topology": [ + "topologies": [ "sharded", "load-balanced" ] } ], - "database_name": "transaction-tests", - "collection_name": "test", - "data": [], + "createEntities": [ + { + "client": { + "id": "client0", + "useMultipleMongoses": false, + "observeEvents": [ + "commandStartedEvent" + ] + } + }, + { + "database": { + "id": "database0", + "client": "client0", + "databaseName": "transaction-tests" + } + }, + { + "collection": { + "id": "collection0", + "database": "database0", + "collectionName": "test" + } + }, + { + "session": { + "id": "session0", + "client": "client0" + } + }, + { + "session": { + "id": "session1", + "client": "client0" + } + } + ], + "initialData": [ + { + "collectionName": "test", + "databaseName": "transaction-tests", + "documents": [] + } + ], "tests": [ { "description": "one transaction", "operations": [ { - "name": "startTransaction", - "object": "session0" + "object": "session0", + "name": "startTransaction" }, { + "object": "collection0", "name": "insertOne", - "object": "collection", "arguments": { "session": "session0", "document": { "_id": 1 } }, - "result": { - "insertedId": 1 + "expectResult": { + "$$unsetOrMatches": { + "insertedId": { + "$$unsetOrMatches": 1 + } + } } }, { + "object": "collection0", "name": "find", - "object": "collection", "arguments": { "session": "session0", "filter": { "_id": 1 } }, - "result": [ + "expectResult": [ { "_id": 1 } ] }, { + "object": "collection0", "name": "find", - "object": "collection", "arguments": { "session": "session1", "filter": { "_id": 1 } }, - "result": [] + "expectResult": [] }, { + "object": "collection0", "name": "find", - "object": "collection", "arguments": { "filter": { "_id": 1 } }, - "result": [] + "expectResult": [] }, { - "name": "commitTransaction", - "object": "session0" + "object": "session0", + "name": "commitTransaction" }, { + "object": "collection0", "name": "find", - "object": "collection", "arguments": { "session": "session1", "filter": { "_id": 1 } }, - "result": [ + "expectResult": [ { "_id": 1 } ] }, { + "object": "collection0", "name": "find", - "object": "collection", "arguments": { "filter": { "_id": 1 } }, - "result": [ + "expectResult": [ { "_id": 1 } ] } ], - "outcome": { - "collection": { - "data": [ + "outcome": [ + { + "collectionName": "test", + "databaseName": "transaction-tests", + "documents": [ { "_id": 1 } ] } - } + ] }, { "description": "two transactions", "operations": [ { - "name": "startTransaction", - "object": "session0" + "object": "session0", + "name": "startTransaction" }, { - "name": "startTransaction", - "object": "session1" + "object": "session1", + "name": "startTransaction" }, { + "object": "collection0", "name": "insertOne", - "object": "collection", "arguments": { "session": "session0", "document": { "_id": 1 } }, - "result": { - "insertedId": 1 + "expectResult": { + "$$unsetOrMatches": { + "insertedId": { + "$$unsetOrMatches": 1 + } + } } }, { + "object": "collection0", "name": "find", - "object": "collection", "arguments": { "session": "session0", "filter": { "_id": 1 } }, - "result": [ + "expectResult": [ { "_id": 1 } ] }, { + "object": "collection0", "name": "find", - "object": "collection", "arguments": { "session": "session1", "filter": { "_id": 1 } }, - "result": [] + "expectResult": [] }, { + "object": "collection0", "name": "find", - "object": "collection", "arguments": { "filter": { "_id": 1 } }, - "result": [] + "expectResult": [] }, { - "name": "commitTransaction", - "object": "session0" + "object": "session0", + "name": "commitTransaction" }, { + "object": "collection0", "name": "find", - "object": "collection", "arguments": { "session": "session1", "filter": { "_id": 1 } }, - "result": [] + "expectResult": [] }, { + "object": "collection0", "name": "find", - "object": "collection", "arguments": { "filter": { "_id": 1 } }, - "result": [ + "expectResult": [ { "_id": 1 } ] }, { - "name": "commitTransaction", - "object": "session1" + "object": "session1", + "name": "commitTransaction" } ], - "outcome": { - "collection": { - "data": [ + "outcome": [ + { + "collectionName": "test", + "databaseName": "transaction-tests", + "documents": [ { "_id": 1 } ] } - } + ] } ] } diff --git a/source/transactions/tests/unified/isolation.yml b/source/transactions/tests/unified/isolation.yml new file mode 100644 index 0000000000..ff8b14f873 --- /dev/null +++ b/source/transactions/tests/unified/isolation.yml @@ -0,0 +1,174 @@ +# Test snapshot isolation. +# This test doesn't check contents of command-started events. +description: isolation + +schemaVersion: '1.3' + +runOnRequirements: + - + minServerVersion: '4.0' + topologies: + - replicaset + - + minServerVersion: 4.1.8 + topologies: + - sharded + - load-balanced + +createEntities: + - + client: + id: &client0 client0 + useMultipleMongoses: false + observeEvents: + - commandStartedEvent + - + database: + id: &database0 database0 + client: *client0 + databaseName: &database_name transaction-tests + - + collection: + id: &collection0 collection0 + database: *database0 + collectionName: &collection_name test + - + session: + id: &session0 session0 + client: *client0 + - + session: + id: &session1 session1 + client: *client0 + +initialData: + - + collectionName: *collection_name + databaseName: *database_name + documents: [] + +tests: + - + description: 'one transaction' + operations: + - + object: *session0 + name: startTransaction + - + object: *collection0 + name: insertOne + arguments: + session: *session0 + document: { _id: 1 } + expectResult: + $$unsetOrMatches: { insertedId: { $$unsetOrMatches: 1 } } + - + object: *collection0 + name: find + arguments: + session: *session0 + filter: { _id: 1 } + expectResult: + - { _id: 1 } + - + object: *collection0 + name: find + arguments: + session: *session1 + filter: { _id: 1 } + expectResult: [] + - + object: *collection0 + name: find + arguments: + filter: { _id: 1 } + expectResult: [] + - + object: *session0 + name: commitTransaction + - + object: *collection0 + name: find + arguments: + session: *session1 + filter: { _id: 1 } + expectResult: + - { _id: 1 } + - + object: *collection0 + name: find + arguments: + filter: { _id: 1 } + expectResult: + - { _id: 1 } + outcome: + - + collectionName: *collection_name + databaseName: *database_name + documents: + - { _id: 1 } + - + description: 'two transactions' + operations: + - + object: *session0 + name: startTransaction + - + object: *session1 + name: startTransaction + - + object: *collection0 + name: insertOne + arguments: + session: *session0 + document: { _id: 1 } + expectResult: + $$unsetOrMatches: { insertedId: { $$unsetOrMatches: 1 } } + - + object: *collection0 + name: find + arguments: + session: *session0 + filter: { _id: 1 } + expectResult: + - { _id: 1 } + - + object: *collection0 + name: find + arguments: + session: *session1 + filter: { _id: 1 } + expectResult: [] + - + object: *collection0 + name: find + arguments: + filter: { _id: 1 } + expectResult: [] + - + object: *session0 + name: commitTransaction + # Snapshot isolation in session1, not read-committed. + - + object: *collection0 + name: find + arguments: + session: *session1 + filter: { _id: 1 } + expectResult: [] + - + object: *collection0 + name: find + arguments: + filter: { _id: 1 } + expectResult: + - { _id: 1 } + - + object: *session1 + name: commitTransaction + outcome: + - + collectionName: *collection_name + databaseName: *database_name + documents: + - { _id: 1 } diff --git a/source/transactions/tests/unified/mongos-pin-auto-tests.py b/source/transactions/tests/unified/mongos-pin-auto-tests.py new file mode 100644 index 0000000000..99a34b485d --- /dev/null +++ b/source/transactions/tests/unified/mongos-pin-auto-tests.py @@ -0,0 +1,337 @@ +import itertools +import sys + +# Require Python 3.7+ for ordered dictionaries so that the order of the +# generated tests remain the same. +# Usage: +# python3.7 mongos-pin-auto-tests.py > mongos-pin-auto.yml +if sys.version_info[:2] < (3, 7): + print('ERROR: This script requires Python >= 3.7, not:') + print(sys.version) + print('Usage: python3.7 mongos-pin-auto-tests.py > mongos-pin-auto.yml') + exit(1) + +HEADER = '''# Autogenerated tests that transient errors in a transaction unpin the session. +# See mongos-pin-auto-tests.py + +description: mongos-pin-auto + +schemaVersion: '1.4' + +runOnRequirements: + - minServerVersion: "4.1.8" + # Note: tests utilize targetedFailPoint, which is incompatible with + # load-balanced and useMultipleMongoses:true + topologies: [ sharded ] + # serverless proxy doesn't append error labels to errors in transactions + # caused by failpoints (CLOUDP-88216) + serverless: "forbid" + +createEntities: + - client: + id: &client0 client0 + useMultipleMongoses: true + observeEvents: [ commandStartedEvent ] + - database: + id: &database0 database0 + client: *client0 + databaseName: &database_name transaction-tests + - collection: + id: &collection0 collection0 + database: *database0 + collectionName: &collection_name test + - session: + id: &session0 session0 + client: *client0 + +initialData: + - collectionName: *collection_name + databaseName: *database_name + documents: &data + - { _id: 1 } + - { _id: 2 } + +tests: + - description: remain pinned after non-transient Interrupted error on insertOne + operations: + - &startTransaction + object: session0 + name: startTransaction + - &initialCommand + object: *collection0 + name: insertOne + arguments: + session: *session0 + document: { _id: 3 } + expectResult: { $$unsetOrMatches: { insertedId: { $$unsetOrMatches: 3 } } } + - object: testRunner + name: targetedFailPoint + arguments: + session: *session0 + failPoint: + configureFailPoint: failCommand + mode: { times: 1 } + data: + failCommands: [ "insert" ] + errorCode: 11601 + - object: *collection0 + name: insertOne + arguments: + session: *session0 + document: { _id: 4 } + expectError: + errorLabelsOmit: ["TransientTransactionError", "UnknownTransactionCommitResult"] + errorCodeName: Interrupted + - &assertSessionPinned + object: testRunner + name: assertSessionPinned + arguments: + session: *session0 + - &commitTransaction + object: *session0 + name: commitTransaction + expectEvents: + - client: *client0 + events: + - commandStartedEvent: + command: + insert: *collection_name + documents: + - { _id: 3 } + ordered: true + readConcern: { $$exists: false } + lsid: { $$sessionLsid: *session0 } + txnNumber: { $numberLong: '1' } + startTransaction: true + autocommit: false + writeConcern: { $$exists: false } + commandName: insert + databaseName: *database_name + - commandStartedEvent: + command: + insert: *collection_name + documents: + - { _id: 4 } + ordered: true + readConcern: { $$exists: false } + lsid: { $$sessionLsid: *session0 } + txnNumber: { $numberLong: '1' } + startTransaction: { $$exists: false } + autocommit: false + writeConcern: { $$exists: false } + commandName: insert + databaseName: *database_name + - commandStartedEvent: + command: + commitTransaction: 1 + lsid: { $$sessionLsid: *session0 } + txnNumber: { $numberLong: '1' } + startTransaction: { $$exists: false } + autocommit: false + writeConcern: { $$exists: false } + recoveryToken: { $$exists: true } + commandName: commitTransaction + databaseName: admin + outcome: + - collectionName: *collection_name + databaseName: *database_name + documents: + - { _id: 1 } + - { _id: 2 } + - { _id: 3 } + + - description: 'unpin after transient error within a transaction' + operations: + - *startTransaction + - *initialCommand + - object: testRunner + name: targetedFailPoint + arguments: + session: *session0 + failPoint: + configureFailPoint: failCommand + mode: { times: 1 } + data: + failCommands: [ "insert" ] + closeConnection: true + - object: *collection0 + name: insertOne + arguments: + session: *session0 + document: { _id: 4 } + expectError: + errorLabelsContain: ["TransientTransactionError"] + errorLabelsOmit: ["UnknownTransactionCommitResult"] + - &assertSessionUnpinned + object: testRunner + name: assertSessionUnpinned + arguments: + session: *session0 + - &abortTransaction + object: *session0 + name: abortTransaction + expectEvents: + - client: *client0 + events: + - commandStartedEvent: + command: + insert: *collection_name + documents: + - { _id: 3 } + ordered: true + readConcern: { $$exists: false } + lsid: { $$sessionLsid: *session0 } + txnNumber: { $numberLong: '1' } + startTransaction: true + autocommit: false + writeConcern: { $$exists: false } + commandName: insert + databaseName: *database_name + - commandStartedEvent: + command: + insert: *collection_name + documents: + - { _id: 4 } + ordered: true + readConcern: { $$exists: false } + lsid: { $$sessionLsid: *session0 } + txnNumber: { $numberLong: '1' } + startTransaction: { $$exists: false } + autocommit: false + writeConcern: { $$exists: false } + commandName: insert + databaseName: *database_name + - commandStartedEvent: + command: + abortTransaction: 1 + lsid: { $$sessionLsid: *session0 } + txnNumber: { $numberLong: '1' } + startTransaction: { $$exists: false } + autocommit: false + writeConcern: { $$exists: false } + recoveryToken: { $$exists: true } + commandName: abortTransaction + databaseName: admin + outcome: &outcome + - collectionName: *collection_name + databaseName: *database_name + documents: *data + + # The rest of the tests in this file test every operation type against + # multiple types of transient errors (connection and error code).''' + +TEMPLATE = ''' + - description: {test_name} {error_name} error on {op_name} {command_name} + operations: + - *startTransaction + - *initialCommand + - name: targetedFailPoint + object: testRunner + arguments: + session: *session0 + failPoint: + configureFailPoint: failCommand + mode: {{times: 1}} + data: + failCommands: ["{command_name}"] + {error_data} + - name: {op_name} + object: {object_name} + arguments: + session: *session0 + {op_args} + expectError: + {error_labels}: ["TransientTransactionError"] + - *{assertion} + - *abortTransaction + outcome: *outcome +''' + + +# Maps from op_name to (command_name, object_name, op_args) +OPS = { + # Write ops: + 'insertOne': ('insert', '*collection0', r'document: { _id: 4 }'), + 'insertMany': ('insert', '*collection0', r'documents: [ { _id: 4 }, { _id: 5 } ]'), + 'updateOne': ('update', '*collection0', r'''filter: { _id: 1 } + update: { $inc: { x: 1 } }'''), + 'replaceOne': ('update', '*collection0', r'''filter: { _id: 1 } + replacement: { y: 1 }'''), + 'updateMany': ('update', '*collection0', r'''filter: { _id: { $gte: 1 } } + update: {$set: { z: 1 } }'''), + 'deleteOne': ('delete', '*collection0', r'filter: { _id: 1 }'), + 'deleteMany': ('delete', '*collection0', r'filter: { _id: { $gte: 1 } }'), + 'findOneAndDelete': ('findAndModify', '*collection0', r'filter: { _id: 1 }'), + 'findOneAndUpdate': ('findAndModify', '*collection0', r'''filter: { _id: 1 } + update: { $inc: { x: 1 } } + returnDocument: Before'''), + 'findOneAndReplace': ('findAndModify', '*collection0', r'''filter: { _id: 1 } + replacement: { y: 1 } + returnDocument: Before'''), + # Bulk write insert/update/delete: + 'bulkWrite insert': ('insert', '*collection0', r'''requests: + - insertOne: + document: { _id: 1 }'''), + 'bulkWrite update': ('update', '*collection0', r'''requests: + - updateOne: + filter: { _id: 1 } + update: { $set: { x: 1 } }'''), + 'bulkWrite delete': ('delete', '*collection0', r'''requests: + - deleteOne: + filter: { _id: 1 }'''), + # Read ops: + 'find': ('find', '*collection0', r'filter: { _id: 1 }'), + 'countDocuments': ('aggregate', '*collection0', r'filter: {}'), + 'aggregate': ('aggregate', '*collection0', r'pipeline: []'), + 'distinct': ('distinct', '*collection0', r'''fieldName: _id + filter: {}'''), + # runCommand: + 'runCommand': ('insert', '*database0', r'''commandName: insert + command: + insert: *collection_name + documents: + - { _id : 1 }'''), +} + +# Maps from error_name to error_data. +NON_TRANSIENT_ERRORS = { + 'Interrupted': 'errorCode: 11601', +} + +# Maps from error_name to error_data. +TRANSIENT_ERRORS = { + 'connection': 'closeConnection: true', + 'ShutdownInProgress': 'errorCode: 91', +} + + +def create_pin_test(op_name, error_name): + test_name = 'remain pinned after non-transient' + assertion = 'assertSessionPinned' + error_labels = 'errorLabelsOmit' + command_name, object_name, op_args = OPS[op_name] + error_data = NON_TRANSIENT_ERRORS[error_name] + if op_name.startswith('bulkWrite'): + op_name = 'bulkWrite' + return TEMPLATE.format(**locals()) + + +def create_unpin_test(op_name, error_name): + test_name = 'unpin after transient' + assertion = 'assertSessionUnpinned' + error_labels = 'errorLabelsContain' + command_name, object_name, op_args = OPS[op_name] + error_data = TRANSIENT_ERRORS[error_name] + if op_name.startswith('bulkWrite'): + op_name = 'bulkWrite' + return TEMPLATE.format(**locals()) + + +tests = [] +for op_name, error_name in itertools.product(OPS, NON_TRANSIENT_ERRORS): + tests.append(create_pin_test(op_name, error_name)) +for op_name, error_name in itertools.product(OPS, TRANSIENT_ERRORS): + tests.append(create_unpin_test(op_name, error_name)) + +print(HEADER) +print(''.join(tests)) diff --git a/source/transactions/tests/legacy/mongos-pin-auto.json b/source/transactions/tests/unified/mongos-pin-auto.json similarity index 69% rename from source/transactions/tests/legacy/mongos-pin-auto.json rename to source/transactions/tests/unified/mongos-pin-auto.json index 36965dcb7f..93eac8bb77 100644 --- a/source/transactions/tests/legacy/mongos-pin-auto.json +++ b/source/transactions/tests/unified/mongos-pin-auto.json @@ -1,49 +1,88 @@ { - "runOn": [ + "description": "mongos-pin-auto", + "schemaVersion": "1.4", + "runOnRequirements": [ { "minServerVersion": "4.1.8", - "topology": [ - "sharded", - "load-balanced" + "topologies": [ + "sharded" ], "serverless": "forbid" } ], - "database_name": "transaction-tests", - "collection_name": "test", - "data": [ + "createEntities": [ { - "_id": 1 + "client": { + "id": "client0", + "useMultipleMongoses": true, + "observeEvents": [ + "commandStartedEvent" + ] + } + }, + { + "database": { + "id": "database0", + "client": "client0", + "databaseName": "transaction-tests" + } }, { - "_id": 2 + "collection": { + "id": "collection0", + "database": "database0", + "collectionName": "test" + } + }, + { + "session": { + "id": "session0", + "client": "client0" + } + } + ], + "initialData": [ + { + "collectionName": "test", + "databaseName": "transaction-tests", + "documents": [ + { + "_id": 1 + }, + { + "_id": 2 + } + ] } ], "tests": [ { "description": "remain pinned after non-transient Interrupted error on insertOne", - "useMultipleMongoses": true, "operations": [ { - "name": "startTransaction", - "object": "session0" + "object": "session0", + "name": "startTransaction" }, { + "object": "collection0", "name": "insertOne", - "object": "collection", "arguments": { "session": "session0", "document": { "_id": 3 } }, - "result": { - "insertedId": 3 + "expectResult": { + "$$unsetOrMatches": { + "insertedId": { + "$$unsetOrMatches": 3 + } + } } }, { - "name": "targetedFailPoint", "object": "testRunner", + "name": "targetedFailPoint", "arguments": { "session": "session0", "failPoint": { @@ -61,15 +100,15 @@ } }, { + "object": "collection0", "name": "insertOne", - "object": "collection", "arguments": { "session": "session0", "document": { "_id": 4 } }, - "result": { + "expectError": { "errorLabelsOmit": [ "TransientTransactionError", "UnknownTransactionCommitResult" @@ -78,85 +117,114 @@ } }, { - "name": "assertSessionPinned", "object": "testRunner", + "name": "assertSessionPinned", "arguments": { "session": "session0" } }, { - "name": "commitTransaction", - "object": "session0" + "object": "session0", + "name": "commitTransaction" } ], - "expectations": [ + "expectEvents": [ { - "command_started_event": { - "command": { - "insert": "test", - "documents": [ - { - "_id": 3 - } - ], - "ordered": true, - "readConcern": null, - "lsid": "session0", - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": true, - "autocommit": false, - "writeConcern": null - }, - "command_name": "insert", - "database_name": "transaction-tests" - } - }, - { - "command_started_event": { - "command": { - "insert": "test", - "documents": [ - { - "_id": 4 - } - ], - "ordered": true, - "readConcern": null, - "lsid": "session0", - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": null, - "autocommit": false, - "writeConcern": null + "client": "client0", + "events": [ + { + "commandStartedEvent": { + "command": { + "insert": "test", + "documents": [ + { + "_id": 3 + } + ], + "ordered": true, + "readConcern": { + "$$exists": false + }, + "lsid": { + "$$sessionLsid": "session0" + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": true, + "autocommit": false, + "writeConcern": { + "$$exists": false + } + }, + "commandName": "insert", + "databaseName": "transaction-tests" + } }, - "command_name": "insert", - "database_name": "transaction-tests" - } - }, - { - "command_started_event": { - "command": { - "commitTransaction": 1, - "lsid": "session0", - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": null, - "autocommit": false, - "writeConcern": null, - "recoveryToken": 42 + { + "commandStartedEvent": { + "command": { + "insert": "test", + "documents": [ + { + "_id": 4 + } + ], + "ordered": true, + "readConcern": { + "$$exists": false + }, + "lsid": { + "$$sessionLsid": "session0" + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": { + "$$exists": false + }, + "autocommit": false, + "writeConcern": { + "$$exists": false + } + }, + "commandName": "insert", + "databaseName": "transaction-tests" + } }, - "command_name": "commitTransaction", - "database_name": "admin" - } + { + "commandStartedEvent": { + "command": { + "commitTransaction": 1, + "lsid": { + "$$sessionLsid": "session0" + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": { + "$$exists": false + }, + "autocommit": false, + "writeConcern": { + "$$exists": false + }, + "recoveryToken": { + "$$exists": true + } + }, + "commandName": "commitTransaction", + "databaseName": "admin" + } + } + ] } ], - "outcome": { - "collection": { - "data": [ + "outcome": [ + { + "collectionName": "test", + "databaseName": "transaction-tests", + "documents": [ { "_id": 1 }, @@ -168,32 +236,35 @@ } ] } - } + ] }, { "description": "unpin after transient error within a transaction", - "useMultipleMongoses": true, "operations": [ { - "name": "startTransaction", - "object": "session0" + "object": "session0", + "name": "startTransaction" }, { + "object": "collection0", "name": "insertOne", - "object": "collection", "arguments": { "session": "session0", "document": { "_id": 3 } }, - "result": { - "insertedId": 3 + "expectResult": { + "$$unsetOrMatches": { + "insertedId": { + "$$unsetOrMatches": 3 + } + } } }, { - "name": "targetedFailPoint", "object": "testRunner", + "name": "targetedFailPoint", "arguments": { "session": "session0", "failPoint": { @@ -211,15 +282,15 @@ } }, { + "object": "collection0", "name": "insertOne", - "object": "collection", "arguments": { "session": "session0", "document": { "_id": 4 } }, - "result": { + "expectError": { "errorLabelsContain": [ "TransientTransactionError" ], @@ -229,85 +300,114 @@ } }, { - "name": "assertSessionUnpinned", "object": "testRunner", + "name": "assertSessionUnpinned", "arguments": { "session": "session0" } }, { - "name": "abortTransaction", - "object": "session0" + "object": "session0", + "name": "abortTransaction" } ], - "expectations": [ - { - "command_started_event": { - "command": { - "insert": "test", - "documents": [ - { - "_id": 3 - } - ], - "ordered": true, - "readConcern": null, - "lsid": "session0", - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": true, - "autocommit": false, - "writeConcern": null - }, - "command_name": "insert", - "database_name": "transaction-tests" - } - }, + "expectEvents": [ { - "command_started_event": { - "command": { - "insert": "test", - "documents": [ - { - "_id": 4 - } - ], - "ordered": true, - "readConcern": null, - "lsid": "session0", - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": null, - "autocommit": false, - "writeConcern": null + "client": "client0", + "events": [ + { + "commandStartedEvent": { + "command": { + "insert": "test", + "documents": [ + { + "_id": 3 + } + ], + "ordered": true, + "readConcern": { + "$$exists": false + }, + "lsid": { + "$$sessionLsid": "session0" + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": true, + "autocommit": false, + "writeConcern": { + "$$exists": false + } + }, + "commandName": "insert", + "databaseName": "transaction-tests" + } }, - "command_name": "insert", - "database_name": "transaction-tests" - } - }, - { - "command_started_event": { - "command": { - "abortTransaction": 1, - "lsid": "session0", - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": null, - "autocommit": false, - "writeConcern": null, - "recoveryToken": 42 + { + "commandStartedEvent": { + "command": { + "insert": "test", + "documents": [ + { + "_id": 4 + } + ], + "ordered": true, + "readConcern": { + "$$exists": false + }, + "lsid": { + "$$sessionLsid": "session0" + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": { + "$$exists": false + }, + "autocommit": false, + "writeConcern": { + "$$exists": false + } + }, + "commandName": "insert", + "databaseName": "transaction-tests" + } }, - "command_name": "abortTransaction", - "database_name": "admin" - } + { + "commandStartedEvent": { + "command": { + "abortTransaction": 1, + "lsid": { + "$$sessionLsid": "session0" + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": { + "$$exists": false + }, + "autocommit": false, + "writeConcern": { + "$$exists": false + }, + "recoveryToken": { + "$$exists": true + } + }, + "commandName": "abortTransaction", + "databaseName": "admin" + } + } + ] } ], - "outcome": { - "collection": { - "data": [ + "outcome": [ + { + "collectionName": "test", + "databaseName": "transaction-tests", + "documents": [ { "_id": 1 }, @@ -316,27 +416,30 @@ } ] } - } + ] }, { "description": "remain pinned after non-transient Interrupted error on insertOne insert", - "useMultipleMongoses": true, "operations": [ { - "name": "startTransaction", - "object": "session0" + "object": "session0", + "name": "startTransaction" }, { + "object": "collection0", "name": "insertOne", - "object": "collection", "arguments": { "session": "session0", "document": { "_id": 3 } }, - "result": { - "insertedId": 3 + "expectResult": { + "$$unsetOrMatches": { + "insertedId": { + "$$unsetOrMatches": 3 + } + } } }, { @@ -360,34 +463,36 @@ }, { "name": "insertOne", - "object": "collection", + "object": "collection0", "arguments": { "session": "session0", "document": { "_id": 4 } }, - "result": { + "expectError": { "errorLabelsOmit": [ "TransientTransactionError" ] } }, { - "name": "assertSessionPinned", "object": "testRunner", + "name": "assertSessionPinned", "arguments": { "session": "session0" } }, { - "name": "abortTransaction", - "object": "session0" + "object": "session0", + "name": "abortTransaction" } ], - "outcome": { - "collection": { - "data": [ + "outcome": [ + { + "collectionName": "test", + "databaseName": "transaction-tests", + "documents": [ { "_id": 1 }, @@ -396,27 +501,30 @@ } ] } - } + ] }, { "description": "remain pinned after non-transient Interrupted error on insertMany insert", - "useMultipleMongoses": true, "operations": [ { - "name": "startTransaction", - "object": "session0" + "object": "session0", + "name": "startTransaction" }, { + "object": "collection0", "name": "insertOne", - "object": "collection", "arguments": { "session": "session0", "document": { "_id": 3 } }, - "result": { - "insertedId": 3 + "expectResult": { + "$$unsetOrMatches": { + "insertedId": { + "$$unsetOrMatches": 3 + } + } } }, { @@ -440,7 +548,7 @@ }, { "name": "insertMany", - "object": "collection", + "object": "collection0", "arguments": { "session": "session0", "documents": [ @@ -452,27 +560,29 @@ } ] }, - "result": { + "expectError": { "errorLabelsOmit": [ "TransientTransactionError" ] } }, { - "name": "assertSessionPinned", "object": "testRunner", + "name": "assertSessionPinned", "arguments": { "session": "session0" } }, { - "name": "abortTransaction", - "object": "session0" + "object": "session0", + "name": "abortTransaction" } ], - "outcome": { - "collection": { - "data": [ + "outcome": [ + { + "collectionName": "test", + "databaseName": "transaction-tests", + "documents": [ { "_id": 1 }, @@ -481,27 +591,30 @@ } ] } - } + ] }, { "description": "remain pinned after non-transient Interrupted error on updateOne update", - "useMultipleMongoses": true, "operations": [ { - "name": "startTransaction", - "object": "session0" + "object": "session0", + "name": "startTransaction" }, { + "object": "collection0", "name": "insertOne", - "object": "collection", "arguments": { "session": "session0", "document": { "_id": 3 } }, - "result": { - "insertedId": 3 + "expectResult": { + "$$unsetOrMatches": { + "insertedId": { + "$$unsetOrMatches": 3 + } + } } }, { @@ -525,7 +638,7 @@ }, { "name": "updateOne", - "object": "collection", + "object": "collection0", "arguments": { "session": "session0", "filter": { @@ -537,27 +650,29 @@ } } }, - "result": { + "expectError": { "errorLabelsOmit": [ "TransientTransactionError" ] } }, { - "name": "assertSessionPinned", "object": "testRunner", + "name": "assertSessionPinned", "arguments": { "session": "session0" } }, { - "name": "abortTransaction", - "object": "session0" + "object": "session0", + "name": "abortTransaction" } ], - "outcome": { - "collection": { - "data": [ + "outcome": [ + { + "collectionName": "test", + "databaseName": "transaction-tests", + "documents": [ { "_id": 1 }, @@ -566,27 +681,30 @@ } ] } - } + ] }, { "description": "remain pinned after non-transient Interrupted error on replaceOne update", - "useMultipleMongoses": true, "operations": [ { - "name": "startTransaction", - "object": "session0" + "object": "session0", + "name": "startTransaction" }, { + "object": "collection0", "name": "insertOne", - "object": "collection", "arguments": { "session": "session0", "document": { "_id": 3 } }, - "result": { - "insertedId": 3 + "expectResult": { + "$$unsetOrMatches": { + "insertedId": { + "$$unsetOrMatches": 3 + } + } } }, { @@ -610,7 +728,7 @@ }, { "name": "replaceOne", - "object": "collection", + "object": "collection0", "arguments": { "session": "session0", "filter": { @@ -620,27 +738,29 @@ "y": 1 } }, - "result": { + "expectError": { "errorLabelsOmit": [ "TransientTransactionError" ] } }, { - "name": "assertSessionPinned", "object": "testRunner", + "name": "assertSessionPinned", "arguments": { "session": "session0" } }, { - "name": "abortTransaction", - "object": "session0" + "object": "session0", + "name": "abortTransaction" } ], - "outcome": { - "collection": { - "data": [ + "outcome": [ + { + "collectionName": "test", + "databaseName": "transaction-tests", + "documents": [ { "_id": 1 }, @@ -649,27 +769,30 @@ } ] } - } + ] }, { "description": "remain pinned after non-transient Interrupted error on updateMany update", - "useMultipleMongoses": true, "operations": [ { - "name": "startTransaction", - "object": "session0" + "object": "session0", + "name": "startTransaction" }, { + "object": "collection0", "name": "insertOne", - "object": "collection", "arguments": { "session": "session0", "document": { "_id": 3 } }, - "result": { - "insertedId": 3 + "expectResult": { + "$$unsetOrMatches": { + "insertedId": { + "$$unsetOrMatches": 3 + } + } } }, { @@ -693,7 +816,7 @@ }, { "name": "updateMany", - "object": "collection", + "object": "collection0", "arguments": { "session": "session0", "filter": { @@ -707,27 +830,29 @@ } } }, - "result": { + "expectError": { "errorLabelsOmit": [ "TransientTransactionError" ] } }, { - "name": "assertSessionPinned", "object": "testRunner", + "name": "assertSessionPinned", "arguments": { "session": "session0" } }, { - "name": "abortTransaction", - "object": "session0" + "object": "session0", + "name": "abortTransaction" } ], - "outcome": { - "collection": { - "data": [ + "outcome": [ + { + "collectionName": "test", + "databaseName": "transaction-tests", + "documents": [ { "_id": 1 }, @@ -736,27 +861,30 @@ } ] } - } + ] }, { "description": "remain pinned after non-transient Interrupted error on deleteOne delete", - "useMultipleMongoses": true, "operations": [ { - "name": "startTransaction", - "object": "session0" + "object": "session0", + "name": "startTransaction" }, { + "object": "collection0", "name": "insertOne", - "object": "collection", "arguments": { "session": "session0", "document": { "_id": 3 } }, - "result": { - "insertedId": 3 + "expectResult": { + "$$unsetOrMatches": { + "insertedId": { + "$$unsetOrMatches": 3 + } + } } }, { @@ -780,34 +908,36 @@ }, { "name": "deleteOne", - "object": "collection", + "object": "collection0", "arguments": { "session": "session0", "filter": { "_id": 1 } }, - "result": { + "expectError": { "errorLabelsOmit": [ "TransientTransactionError" ] } }, { - "name": "assertSessionPinned", "object": "testRunner", + "name": "assertSessionPinned", "arguments": { "session": "session0" } }, { - "name": "abortTransaction", - "object": "session0" + "object": "session0", + "name": "abortTransaction" } ], - "outcome": { - "collection": { - "data": [ + "outcome": [ + { + "collectionName": "test", + "databaseName": "transaction-tests", + "documents": [ { "_id": 1 }, @@ -816,27 +946,30 @@ } ] } - } + ] }, { "description": "remain pinned after non-transient Interrupted error on deleteMany delete", - "useMultipleMongoses": true, "operations": [ { - "name": "startTransaction", - "object": "session0" + "object": "session0", + "name": "startTransaction" }, { + "object": "collection0", "name": "insertOne", - "object": "collection", "arguments": { "session": "session0", "document": { "_id": 3 } }, - "result": { - "insertedId": 3 + "expectResult": { + "$$unsetOrMatches": { + "insertedId": { + "$$unsetOrMatches": 3 + } + } } }, { @@ -860,7 +993,7 @@ }, { "name": "deleteMany", - "object": "collection", + "object": "collection0", "arguments": { "session": "session0", "filter": { @@ -869,27 +1002,29 @@ } } }, - "result": { + "expectError": { "errorLabelsOmit": [ "TransientTransactionError" ] } }, { - "name": "assertSessionPinned", "object": "testRunner", + "name": "assertSessionPinned", "arguments": { "session": "session0" } }, { - "name": "abortTransaction", - "object": "session0" + "object": "session0", + "name": "abortTransaction" } ], - "outcome": { - "collection": { - "data": [ + "outcome": [ + { + "collectionName": "test", + "databaseName": "transaction-tests", + "documents": [ { "_id": 1 }, @@ -898,27 +1033,30 @@ } ] } - } + ] }, { "description": "remain pinned after non-transient Interrupted error on findOneAndDelete findAndModify", - "useMultipleMongoses": true, "operations": [ { - "name": "startTransaction", - "object": "session0" + "object": "session0", + "name": "startTransaction" }, { + "object": "collection0", "name": "insertOne", - "object": "collection", "arguments": { "session": "session0", "document": { "_id": 3 } }, - "result": { - "insertedId": 3 + "expectResult": { + "$$unsetOrMatches": { + "insertedId": { + "$$unsetOrMatches": 3 + } + } } }, { @@ -942,34 +1080,36 @@ }, { "name": "findOneAndDelete", - "object": "collection", + "object": "collection0", "arguments": { "session": "session0", "filter": { "_id": 1 } }, - "result": { + "expectError": { "errorLabelsOmit": [ "TransientTransactionError" ] } }, { - "name": "assertSessionPinned", "object": "testRunner", + "name": "assertSessionPinned", "arguments": { "session": "session0" } }, { - "name": "abortTransaction", - "object": "session0" + "object": "session0", + "name": "abortTransaction" } ], - "outcome": { - "collection": { - "data": [ + "outcome": [ + { + "collectionName": "test", + "databaseName": "transaction-tests", + "documents": [ { "_id": 1 }, @@ -978,27 +1118,30 @@ } ] } - } + ] }, { "description": "remain pinned after non-transient Interrupted error on findOneAndUpdate findAndModify", - "useMultipleMongoses": true, "operations": [ { - "name": "startTransaction", - "object": "session0" + "object": "session0", + "name": "startTransaction" }, { + "object": "collection0", "name": "insertOne", - "object": "collection", "arguments": { "session": "session0", "document": { "_id": 3 } }, - "result": { - "insertedId": 3 + "expectResult": { + "$$unsetOrMatches": { + "insertedId": { + "$$unsetOrMatches": 3 + } + } } }, { @@ -1022,7 +1165,7 @@ }, { "name": "findOneAndUpdate", - "object": "collection", + "object": "collection0", "arguments": { "session": "session0", "filter": { @@ -1035,27 +1178,29 @@ }, "returnDocument": "Before" }, - "result": { + "expectError": { "errorLabelsOmit": [ "TransientTransactionError" ] } }, { - "name": "assertSessionPinned", "object": "testRunner", + "name": "assertSessionPinned", "arguments": { "session": "session0" } }, { - "name": "abortTransaction", - "object": "session0" + "object": "session0", + "name": "abortTransaction" } ], - "outcome": { - "collection": { - "data": [ + "outcome": [ + { + "collectionName": "test", + "databaseName": "transaction-tests", + "documents": [ { "_id": 1 }, @@ -1064,27 +1209,30 @@ } ] } - } + ] }, { "description": "remain pinned after non-transient Interrupted error on findOneAndReplace findAndModify", - "useMultipleMongoses": true, "operations": [ { - "name": "startTransaction", - "object": "session0" + "object": "session0", + "name": "startTransaction" }, { + "object": "collection0", "name": "insertOne", - "object": "collection", "arguments": { "session": "session0", "document": { "_id": 3 } }, - "result": { - "insertedId": 3 + "expectResult": { + "$$unsetOrMatches": { + "insertedId": { + "$$unsetOrMatches": 3 + } + } } }, { @@ -1108,7 +1256,7 @@ }, { "name": "findOneAndReplace", - "object": "collection", + "object": "collection0", "arguments": { "session": "session0", "filter": { @@ -1119,27 +1267,29 @@ }, "returnDocument": "Before" }, - "result": { + "expectError": { "errorLabelsOmit": [ "TransientTransactionError" ] } }, { - "name": "assertSessionPinned", "object": "testRunner", + "name": "assertSessionPinned", "arguments": { "session": "session0" } }, { - "name": "abortTransaction", - "object": "session0" + "object": "session0", + "name": "abortTransaction" } ], - "outcome": { - "collection": { - "data": [ + "outcome": [ + { + "collectionName": "test", + "databaseName": "transaction-tests", + "documents": [ { "_id": 1 }, @@ -1148,27 +1298,30 @@ } ] } - } + ] }, { "description": "remain pinned after non-transient Interrupted error on bulkWrite insert", - "useMultipleMongoses": true, "operations": [ { - "name": "startTransaction", - "object": "session0" + "object": "session0", + "name": "startTransaction" }, { + "object": "collection0", "name": "insertOne", - "object": "collection", "arguments": { "session": "session0", "document": { "_id": 3 } }, - "result": { - "insertedId": 3 + "expectResult": { + "$$unsetOrMatches": { + "insertedId": { + "$$unsetOrMatches": 3 + } + } } }, { @@ -1192,13 +1345,12 @@ }, { "name": "bulkWrite", - "object": "collection", + "object": "collection0", "arguments": { "session": "session0", "requests": [ { - "name": "insertOne", - "arguments": { + "insertOne": { "document": { "_id": 1 } @@ -1206,27 +1358,29 @@ } ] }, - "result": { + "expectError": { "errorLabelsOmit": [ "TransientTransactionError" ] } }, { - "name": "assertSessionPinned", "object": "testRunner", + "name": "assertSessionPinned", "arguments": { "session": "session0" } }, { - "name": "abortTransaction", - "object": "session0" + "object": "session0", + "name": "abortTransaction" } ], - "outcome": { - "collection": { - "data": [ + "outcome": [ + { + "collectionName": "test", + "databaseName": "transaction-tests", + "documents": [ { "_id": 1 }, @@ -1235,27 +1389,30 @@ } ] } - } + ] }, { "description": "remain pinned after non-transient Interrupted error on bulkWrite update", - "useMultipleMongoses": true, "operations": [ { - "name": "startTransaction", - "object": "session0" + "object": "session0", + "name": "startTransaction" }, { + "object": "collection0", "name": "insertOne", - "object": "collection", "arguments": { "session": "session0", "document": { "_id": 3 } }, - "result": { - "insertedId": 3 + "expectResult": { + "$$unsetOrMatches": { + "insertedId": { + "$$unsetOrMatches": 3 + } + } } }, { @@ -1279,13 +1436,12 @@ }, { "name": "bulkWrite", - "object": "collection", + "object": "collection0", "arguments": { "session": "session0", "requests": [ { - "name": "updateOne", - "arguments": { + "updateOne": { "filter": { "_id": 1 }, @@ -1298,27 +1454,29 @@ } ] }, - "result": { + "expectError": { "errorLabelsOmit": [ "TransientTransactionError" ] } }, { - "name": "assertSessionPinned", "object": "testRunner", + "name": "assertSessionPinned", "arguments": { "session": "session0" } }, { - "name": "abortTransaction", - "object": "session0" + "object": "session0", + "name": "abortTransaction" } ], - "outcome": { - "collection": { - "data": [ + "outcome": [ + { + "collectionName": "test", + "databaseName": "transaction-tests", + "documents": [ { "_id": 1 }, @@ -1327,27 +1485,30 @@ } ] } - } + ] }, { "description": "remain pinned after non-transient Interrupted error on bulkWrite delete", - "useMultipleMongoses": true, "operations": [ { - "name": "startTransaction", - "object": "session0" + "object": "session0", + "name": "startTransaction" }, { + "object": "collection0", "name": "insertOne", - "object": "collection", "arguments": { "session": "session0", "document": { "_id": 3 } }, - "result": { - "insertedId": 3 + "expectResult": { + "$$unsetOrMatches": { + "insertedId": { + "$$unsetOrMatches": 3 + } + } } }, { @@ -1371,13 +1532,12 @@ }, { "name": "bulkWrite", - "object": "collection", + "object": "collection0", "arguments": { "session": "session0", "requests": [ { - "name": "deleteOne", - "arguments": { + "deleteOne": { "filter": { "_id": 1 } @@ -1385,27 +1545,29 @@ } ] }, - "result": { + "expectError": { "errorLabelsOmit": [ "TransientTransactionError" ] } }, { - "name": "assertSessionPinned", "object": "testRunner", + "name": "assertSessionPinned", "arguments": { "session": "session0" } }, { - "name": "abortTransaction", - "object": "session0" + "object": "session0", + "name": "abortTransaction" } ], - "outcome": { - "collection": { - "data": [ + "outcome": [ + { + "collectionName": "test", + "databaseName": "transaction-tests", + "documents": [ { "_id": 1 }, @@ -1414,27 +1576,30 @@ } ] } - } + ] }, { "description": "remain pinned after non-transient Interrupted error on find find", - "useMultipleMongoses": true, "operations": [ { - "name": "startTransaction", - "object": "session0" + "object": "session0", + "name": "startTransaction" }, { + "object": "collection0", "name": "insertOne", - "object": "collection", "arguments": { "session": "session0", "document": { "_id": 3 } }, - "result": { - "insertedId": 3 + "expectResult": { + "$$unsetOrMatches": { + "insertedId": { + "$$unsetOrMatches": 3 + } + } } }, { @@ -1458,34 +1623,36 @@ }, { "name": "find", - "object": "collection", + "object": "collection0", "arguments": { "session": "session0", "filter": { "_id": 1 } }, - "result": { + "expectError": { "errorLabelsOmit": [ "TransientTransactionError" ] } }, { - "name": "assertSessionPinned", "object": "testRunner", + "name": "assertSessionPinned", "arguments": { "session": "session0" } }, { - "name": "abortTransaction", - "object": "session0" + "object": "session0", + "name": "abortTransaction" } ], - "outcome": { - "collection": { - "data": [ + "outcome": [ + { + "collectionName": "test", + "databaseName": "transaction-tests", + "documents": [ { "_id": 1 }, @@ -1494,27 +1661,30 @@ } ] } - } + ] }, { "description": "remain pinned after non-transient Interrupted error on countDocuments aggregate", - "useMultipleMongoses": true, "operations": [ { - "name": "startTransaction", - "object": "session0" + "object": "session0", + "name": "startTransaction" }, { + "object": "collection0", "name": "insertOne", - "object": "collection", "arguments": { "session": "session0", "document": { "_id": 3 } }, - "result": { - "insertedId": 3 + "expectResult": { + "$$unsetOrMatches": { + "insertedId": { + "$$unsetOrMatches": 3 + } + } } }, { @@ -1538,32 +1708,34 @@ }, { "name": "countDocuments", - "object": "collection", + "object": "collection0", "arguments": { "session": "session0", "filter": {} }, - "result": { + "expectError": { "errorLabelsOmit": [ "TransientTransactionError" ] } }, { - "name": "assertSessionPinned", "object": "testRunner", + "name": "assertSessionPinned", "arguments": { "session": "session0" } }, { - "name": "abortTransaction", - "object": "session0" + "object": "session0", + "name": "abortTransaction" } ], - "outcome": { - "collection": { - "data": [ + "outcome": [ + { + "collectionName": "test", + "databaseName": "transaction-tests", + "documents": [ { "_id": 1 }, @@ -1572,27 +1744,30 @@ } ] } - } + ] }, { "description": "remain pinned after non-transient Interrupted error on aggregate aggregate", - "useMultipleMongoses": true, "operations": [ { - "name": "startTransaction", - "object": "session0" + "object": "session0", + "name": "startTransaction" }, { + "object": "collection0", "name": "insertOne", - "object": "collection", "arguments": { "session": "session0", "document": { "_id": 3 } }, - "result": { - "insertedId": 3 + "expectResult": { + "$$unsetOrMatches": { + "insertedId": { + "$$unsetOrMatches": 3 + } + } } }, { @@ -1616,32 +1791,34 @@ }, { "name": "aggregate", - "object": "collection", + "object": "collection0", "arguments": { "session": "session0", "pipeline": [] }, - "result": { + "expectError": { "errorLabelsOmit": [ "TransientTransactionError" ] } }, { - "name": "assertSessionPinned", "object": "testRunner", + "name": "assertSessionPinned", "arguments": { "session": "session0" } }, { - "name": "abortTransaction", - "object": "session0" + "object": "session0", + "name": "abortTransaction" } ], - "outcome": { - "collection": { - "data": [ + "outcome": [ + { + "collectionName": "test", + "databaseName": "transaction-tests", + "documents": [ { "_id": 1 }, @@ -1650,27 +1827,30 @@ } ] } - } + ] }, { "description": "remain pinned after non-transient Interrupted error on distinct distinct", - "useMultipleMongoses": true, "operations": [ { - "name": "startTransaction", - "object": "session0" + "object": "session0", + "name": "startTransaction" }, { + "object": "collection0", "name": "insertOne", - "object": "collection", "arguments": { "session": "session0", "document": { "_id": 3 } }, - "result": { - "insertedId": 3 + "expectResult": { + "$$unsetOrMatches": { + "insertedId": { + "$$unsetOrMatches": 3 + } + } } }, { @@ -1694,32 +1874,35 @@ }, { "name": "distinct", - "object": "collection", + "object": "collection0", "arguments": { "session": "session0", - "fieldName": "_id" + "fieldName": "_id", + "filter": {} }, - "result": { + "expectError": { "errorLabelsOmit": [ "TransientTransactionError" ] } }, { - "name": "assertSessionPinned", "object": "testRunner", + "name": "assertSessionPinned", "arguments": { "session": "session0" } }, { - "name": "abortTransaction", - "object": "session0" + "object": "session0", + "name": "abortTransaction" } ], - "outcome": { - "collection": { - "data": [ + "outcome": [ + { + "collectionName": "test", + "databaseName": "transaction-tests", + "documents": [ { "_id": 1 }, @@ -1728,27 +1911,30 @@ } ] } - } + ] }, { "description": "remain pinned after non-transient Interrupted error on runCommand insert", - "useMultipleMongoses": true, "operations": [ { - "name": "startTransaction", - "object": "session0" + "object": "session0", + "name": "startTransaction" }, { + "object": "collection0", "name": "insertOne", - "object": "collection", "arguments": { "session": "session0", "document": { "_id": 3 } }, - "result": { - "insertedId": 3 + "expectResult": { + "$$unsetOrMatches": { + "insertedId": { + "$$unsetOrMatches": 3 + } + } } }, { @@ -1772,10 +1958,10 @@ }, { "name": "runCommand", - "object": "database", - "command_name": "insert", + "object": "database0", "arguments": { "session": "session0", + "commandName": "insert", "command": { "insert": "test", "documents": [ @@ -1785,27 +1971,29 @@ ] } }, - "result": { + "expectError": { "errorLabelsOmit": [ "TransientTransactionError" ] } }, { - "name": "assertSessionPinned", "object": "testRunner", + "name": "assertSessionPinned", "arguments": { "session": "session0" } }, { - "name": "abortTransaction", - "object": "session0" + "object": "session0", + "name": "abortTransaction" } ], - "outcome": { - "collection": { - "data": [ + "outcome": [ + { + "collectionName": "test", + "databaseName": "transaction-tests", + "documents": [ { "_id": 1 }, @@ -1814,27 +2002,30 @@ } ] } - } + ] }, { "description": "unpin after transient connection error on insertOne insert", - "useMultipleMongoses": true, "operations": [ { - "name": "startTransaction", - "object": "session0" + "object": "session0", + "name": "startTransaction" }, { + "object": "collection0", "name": "insertOne", - "object": "collection", "arguments": { "session": "session0", "document": { "_id": 3 } }, - "result": { - "insertedId": 3 + "expectResult": { + "$$unsetOrMatches": { + "insertedId": { + "$$unsetOrMatches": 3 + } + } } }, { @@ -1858,34 +2049,36 @@ }, { "name": "insertOne", - "object": "collection", + "object": "collection0", "arguments": { "session": "session0", "document": { "_id": 4 } }, - "result": { + "expectError": { "errorLabelsContain": [ "TransientTransactionError" ] } }, { - "name": "assertSessionUnpinned", "object": "testRunner", + "name": "assertSessionUnpinned", "arguments": { "session": "session0" } }, { - "name": "abortTransaction", - "object": "session0" + "object": "session0", + "name": "abortTransaction" } ], - "outcome": { - "collection": { - "data": [ + "outcome": [ + { + "collectionName": "test", + "databaseName": "transaction-tests", + "documents": [ { "_id": 1 }, @@ -1894,27 +2087,30 @@ } ] } - } + ] }, { "description": "unpin after transient ShutdownInProgress error on insertOne insert", - "useMultipleMongoses": true, "operations": [ { - "name": "startTransaction", - "object": "session0" + "object": "session0", + "name": "startTransaction" }, { + "object": "collection0", "name": "insertOne", - "object": "collection", "arguments": { "session": "session0", "document": { "_id": 3 } }, - "result": { - "insertedId": 3 + "expectResult": { + "$$unsetOrMatches": { + "insertedId": { + "$$unsetOrMatches": 3 + } + } } }, { @@ -1938,34 +2134,36 @@ }, { "name": "insertOne", - "object": "collection", + "object": "collection0", "arguments": { "session": "session0", "document": { "_id": 4 } }, - "result": { + "expectError": { "errorLabelsContain": [ "TransientTransactionError" ] } }, { - "name": "assertSessionUnpinned", "object": "testRunner", + "name": "assertSessionUnpinned", "arguments": { "session": "session0" } }, { - "name": "abortTransaction", - "object": "session0" + "object": "session0", + "name": "abortTransaction" } ], - "outcome": { - "collection": { - "data": [ + "outcome": [ + { + "collectionName": "test", + "databaseName": "transaction-tests", + "documents": [ { "_id": 1 }, @@ -1974,27 +2172,30 @@ } ] } - } + ] }, { "description": "unpin after transient connection error on insertMany insert", - "useMultipleMongoses": true, "operations": [ { - "name": "startTransaction", - "object": "session0" + "object": "session0", + "name": "startTransaction" }, { + "object": "collection0", "name": "insertOne", - "object": "collection", "arguments": { "session": "session0", "document": { "_id": 3 } }, - "result": { - "insertedId": 3 + "expectResult": { + "$$unsetOrMatches": { + "insertedId": { + "$$unsetOrMatches": 3 + } + } } }, { @@ -2018,7 +2219,7 @@ }, { "name": "insertMany", - "object": "collection", + "object": "collection0", "arguments": { "session": "session0", "documents": [ @@ -2030,27 +2231,29 @@ } ] }, - "result": { + "expectError": { "errorLabelsContain": [ "TransientTransactionError" ] } }, { - "name": "assertSessionUnpinned", "object": "testRunner", + "name": "assertSessionUnpinned", "arguments": { "session": "session0" } }, { - "name": "abortTransaction", - "object": "session0" + "object": "session0", + "name": "abortTransaction" } ], - "outcome": { - "collection": { - "data": [ + "outcome": [ + { + "collectionName": "test", + "databaseName": "transaction-tests", + "documents": [ { "_id": 1 }, @@ -2059,27 +2262,30 @@ } ] } - } + ] }, { "description": "unpin after transient ShutdownInProgress error on insertMany insert", - "useMultipleMongoses": true, "operations": [ { - "name": "startTransaction", - "object": "session0" + "object": "session0", + "name": "startTransaction" }, { + "object": "collection0", "name": "insertOne", - "object": "collection", "arguments": { "session": "session0", "document": { "_id": 3 } }, - "result": { - "insertedId": 3 + "expectResult": { + "$$unsetOrMatches": { + "insertedId": { + "$$unsetOrMatches": 3 + } + } } }, { @@ -2103,7 +2309,7 @@ }, { "name": "insertMany", - "object": "collection", + "object": "collection0", "arguments": { "session": "session0", "documents": [ @@ -2115,27 +2321,29 @@ } ] }, - "result": { + "expectError": { "errorLabelsContain": [ "TransientTransactionError" ] } }, { - "name": "assertSessionUnpinned", "object": "testRunner", + "name": "assertSessionUnpinned", "arguments": { "session": "session0" } }, { - "name": "abortTransaction", - "object": "session0" + "object": "session0", + "name": "abortTransaction" } ], - "outcome": { - "collection": { - "data": [ + "outcome": [ + { + "collectionName": "test", + "databaseName": "transaction-tests", + "documents": [ { "_id": 1 }, @@ -2144,27 +2352,30 @@ } ] } - } + ] }, { "description": "unpin after transient connection error on updateOne update", - "useMultipleMongoses": true, "operations": [ { - "name": "startTransaction", - "object": "session0" + "object": "session0", + "name": "startTransaction" }, { + "object": "collection0", "name": "insertOne", - "object": "collection", "arguments": { "session": "session0", "document": { "_id": 3 } }, - "result": { - "insertedId": 3 + "expectResult": { + "$$unsetOrMatches": { + "insertedId": { + "$$unsetOrMatches": 3 + } + } } }, { @@ -2188,7 +2399,7 @@ }, { "name": "updateOne", - "object": "collection", + "object": "collection0", "arguments": { "session": "session0", "filter": { @@ -2200,27 +2411,29 @@ } } }, - "result": { + "expectError": { "errorLabelsContain": [ "TransientTransactionError" ] } }, { - "name": "assertSessionUnpinned", "object": "testRunner", + "name": "assertSessionUnpinned", "arguments": { "session": "session0" } }, { - "name": "abortTransaction", - "object": "session0" + "object": "session0", + "name": "abortTransaction" } ], - "outcome": { - "collection": { - "data": [ + "outcome": [ + { + "collectionName": "test", + "databaseName": "transaction-tests", + "documents": [ { "_id": 1 }, @@ -2229,27 +2442,30 @@ } ] } - } + ] }, { "description": "unpin after transient ShutdownInProgress error on updateOne update", - "useMultipleMongoses": true, "operations": [ { - "name": "startTransaction", - "object": "session0" + "object": "session0", + "name": "startTransaction" }, { + "object": "collection0", "name": "insertOne", - "object": "collection", "arguments": { "session": "session0", "document": { "_id": 3 } }, - "result": { - "insertedId": 3 + "expectResult": { + "$$unsetOrMatches": { + "insertedId": { + "$$unsetOrMatches": 3 + } + } } }, { @@ -2273,7 +2489,7 @@ }, { "name": "updateOne", - "object": "collection", + "object": "collection0", "arguments": { "session": "session0", "filter": { @@ -2285,27 +2501,29 @@ } } }, - "result": { + "expectError": { "errorLabelsContain": [ "TransientTransactionError" ] } }, { - "name": "assertSessionUnpinned", "object": "testRunner", + "name": "assertSessionUnpinned", "arguments": { "session": "session0" } }, { - "name": "abortTransaction", - "object": "session0" + "object": "session0", + "name": "abortTransaction" } ], - "outcome": { - "collection": { - "data": [ + "outcome": [ + { + "collectionName": "test", + "databaseName": "transaction-tests", + "documents": [ { "_id": 1 }, @@ -2314,27 +2532,30 @@ } ] } - } + ] }, { "description": "unpin after transient connection error on replaceOne update", - "useMultipleMongoses": true, "operations": [ { - "name": "startTransaction", - "object": "session0" + "object": "session0", + "name": "startTransaction" }, { + "object": "collection0", "name": "insertOne", - "object": "collection", "arguments": { "session": "session0", "document": { "_id": 3 } }, - "result": { - "insertedId": 3 + "expectResult": { + "$$unsetOrMatches": { + "insertedId": { + "$$unsetOrMatches": 3 + } + } } }, { @@ -2358,7 +2579,7 @@ }, { "name": "replaceOne", - "object": "collection", + "object": "collection0", "arguments": { "session": "session0", "filter": { @@ -2368,27 +2589,29 @@ "y": 1 } }, - "result": { + "expectError": { "errorLabelsContain": [ "TransientTransactionError" ] } }, { - "name": "assertSessionUnpinned", "object": "testRunner", + "name": "assertSessionUnpinned", "arguments": { "session": "session0" } }, { - "name": "abortTransaction", - "object": "session0" + "object": "session0", + "name": "abortTransaction" } ], - "outcome": { - "collection": { - "data": [ + "outcome": [ + { + "collectionName": "test", + "databaseName": "transaction-tests", + "documents": [ { "_id": 1 }, @@ -2397,27 +2620,30 @@ } ] } - } + ] }, { "description": "unpin after transient ShutdownInProgress error on replaceOne update", - "useMultipleMongoses": true, "operations": [ { - "name": "startTransaction", - "object": "session0" + "object": "session0", + "name": "startTransaction" }, { + "object": "collection0", "name": "insertOne", - "object": "collection", "arguments": { "session": "session0", "document": { "_id": 3 } }, - "result": { - "insertedId": 3 + "expectResult": { + "$$unsetOrMatches": { + "insertedId": { + "$$unsetOrMatches": 3 + } + } } }, { @@ -2441,7 +2667,7 @@ }, { "name": "replaceOne", - "object": "collection", + "object": "collection0", "arguments": { "session": "session0", "filter": { @@ -2451,27 +2677,29 @@ "y": 1 } }, - "result": { + "expectError": { "errorLabelsContain": [ "TransientTransactionError" ] } }, { - "name": "assertSessionUnpinned", "object": "testRunner", + "name": "assertSessionUnpinned", "arguments": { "session": "session0" } }, { - "name": "abortTransaction", - "object": "session0" + "object": "session0", + "name": "abortTransaction" } ], - "outcome": { - "collection": { - "data": [ + "outcome": [ + { + "collectionName": "test", + "databaseName": "transaction-tests", + "documents": [ { "_id": 1 }, @@ -2480,27 +2708,30 @@ } ] } - } + ] }, { "description": "unpin after transient connection error on updateMany update", - "useMultipleMongoses": true, "operations": [ { - "name": "startTransaction", - "object": "session0" + "object": "session0", + "name": "startTransaction" }, { + "object": "collection0", "name": "insertOne", - "object": "collection", "arguments": { "session": "session0", "document": { "_id": 3 } }, - "result": { - "insertedId": 3 + "expectResult": { + "$$unsetOrMatches": { + "insertedId": { + "$$unsetOrMatches": 3 + } + } } }, { @@ -2524,7 +2755,7 @@ }, { "name": "updateMany", - "object": "collection", + "object": "collection0", "arguments": { "session": "session0", "filter": { @@ -2538,27 +2769,29 @@ } } }, - "result": { + "expectError": { "errorLabelsContain": [ "TransientTransactionError" ] } }, { - "name": "assertSessionUnpinned", "object": "testRunner", + "name": "assertSessionUnpinned", "arguments": { "session": "session0" } }, { - "name": "abortTransaction", - "object": "session0" + "object": "session0", + "name": "abortTransaction" } ], - "outcome": { - "collection": { - "data": [ + "outcome": [ + { + "collectionName": "test", + "databaseName": "transaction-tests", + "documents": [ { "_id": 1 }, @@ -2567,27 +2800,30 @@ } ] } - } + ] }, { "description": "unpin after transient ShutdownInProgress error on updateMany update", - "useMultipleMongoses": true, "operations": [ { - "name": "startTransaction", - "object": "session0" + "object": "session0", + "name": "startTransaction" }, { + "object": "collection0", "name": "insertOne", - "object": "collection", "arguments": { "session": "session0", "document": { "_id": 3 } }, - "result": { - "insertedId": 3 + "expectResult": { + "$$unsetOrMatches": { + "insertedId": { + "$$unsetOrMatches": 3 + } + } } }, { @@ -2611,7 +2847,7 @@ }, { "name": "updateMany", - "object": "collection", + "object": "collection0", "arguments": { "session": "session0", "filter": { @@ -2625,27 +2861,29 @@ } } }, - "result": { + "expectError": { "errorLabelsContain": [ "TransientTransactionError" ] } }, { - "name": "assertSessionUnpinned", "object": "testRunner", + "name": "assertSessionUnpinned", "arguments": { "session": "session0" } }, { - "name": "abortTransaction", - "object": "session0" + "object": "session0", + "name": "abortTransaction" } ], - "outcome": { - "collection": { - "data": [ + "outcome": [ + { + "collectionName": "test", + "databaseName": "transaction-tests", + "documents": [ { "_id": 1 }, @@ -2654,27 +2892,30 @@ } ] } - } + ] }, { "description": "unpin after transient connection error on deleteOne delete", - "useMultipleMongoses": true, "operations": [ { - "name": "startTransaction", - "object": "session0" + "object": "session0", + "name": "startTransaction" }, { + "object": "collection0", "name": "insertOne", - "object": "collection", "arguments": { "session": "session0", "document": { "_id": 3 } }, - "result": { - "insertedId": 3 + "expectResult": { + "$$unsetOrMatches": { + "insertedId": { + "$$unsetOrMatches": 3 + } + } } }, { @@ -2698,34 +2939,36 @@ }, { "name": "deleteOne", - "object": "collection", + "object": "collection0", "arguments": { "session": "session0", "filter": { "_id": 1 } }, - "result": { + "expectError": { "errorLabelsContain": [ "TransientTransactionError" ] } }, { - "name": "assertSessionUnpinned", "object": "testRunner", + "name": "assertSessionUnpinned", "arguments": { "session": "session0" } }, { - "name": "abortTransaction", - "object": "session0" + "object": "session0", + "name": "abortTransaction" } ], - "outcome": { - "collection": { - "data": [ + "outcome": [ + { + "collectionName": "test", + "databaseName": "transaction-tests", + "documents": [ { "_id": 1 }, @@ -2734,27 +2977,30 @@ } ] } - } + ] }, { "description": "unpin after transient ShutdownInProgress error on deleteOne delete", - "useMultipleMongoses": true, "operations": [ { - "name": "startTransaction", - "object": "session0" + "object": "session0", + "name": "startTransaction" }, { + "object": "collection0", "name": "insertOne", - "object": "collection", "arguments": { "session": "session0", "document": { "_id": 3 } }, - "result": { - "insertedId": 3 + "expectResult": { + "$$unsetOrMatches": { + "insertedId": { + "$$unsetOrMatches": 3 + } + } } }, { @@ -2778,34 +3024,36 @@ }, { "name": "deleteOne", - "object": "collection", + "object": "collection0", "arguments": { "session": "session0", "filter": { "_id": 1 } }, - "result": { + "expectError": { "errorLabelsContain": [ "TransientTransactionError" ] } }, { - "name": "assertSessionUnpinned", "object": "testRunner", + "name": "assertSessionUnpinned", "arguments": { "session": "session0" } }, { - "name": "abortTransaction", - "object": "session0" + "object": "session0", + "name": "abortTransaction" } ], - "outcome": { - "collection": { - "data": [ + "outcome": [ + { + "collectionName": "test", + "databaseName": "transaction-tests", + "documents": [ { "_id": 1 }, @@ -2814,27 +3062,30 @@ } ] } - } + ] }, { "description": "unpin after transient connection error on deleteMany delete", - "useMultipleMongoses": true, "operations": [ { - "name": "startTransaction", - "object": "session0" + "object": "session0", + "name": "startTransaction" }, { + "object": "collection0", "name": "insertOne", - "object": "collection", "arguments": { "session": "session0", "document": { "_id": 3 } }, - "result": { - "insertedId": 3 + "expectResult": { + "$$unsetOrMatches": { + "insertedId": { + "$$unsetOrMatches": 3 + } + } } }, { @@ -2858,7 +3109,7 @@ }, { "name": "deleteMany", - "object": "collection", + "object": "collection0", "arguments": { "session": "session0", "filter": { @@ -2867,27 +3118,29 @@ } } }, - "result": { + "expectError": { "errorLabelsContain": [ "TransientTransactionError" ] } }, { - "name": "assertSessionUnpinned", "object": "testRunner", + "name": "assertSessionUnpinned", "arguments": { "session": "session0" } }, { - "name": "abortTransaction", - "object": "session0" + "object": "session0", + "name": "abortTransaction" } ], - "outcome": { - "collection": { - "data": [ + "outcome": [ + { + "collectionName": "test", + "databaseName": "transaction-tests", + "documents": [ { "_id": 1 }, @@ -2896,27 +3149,30 @@ } ] } - } + ] }, { "description": "unpin after transient ShutdownInProgress error on deleteMany delete", - "useMultipleMongoses": true, "operations": [ { - "name": "startTransaction", - "object": "session0" + "object": "session0", + "name": "startTransaction" }, { + "object": "collection0", "name": "insertOne", - "object": "collection", "arguments": { "session": "session0", "document": { "_id": 3 } }, - "result": { - "insertedId": 3 + "expectResult": { + "$$unsetOrMatches": { + "insertedId": { + "$$unsetOrMatches": 3 + } + } } }, { @@ -2940,7 +3196,7 @@ }, { "name": "deleteMany", - "object": "collection", + "object": "collection0", "arguments": { "session": "session0", "filter": { @@ -2949,27 +3205,29 @@ } } }, - "result": { + "expectError": { "errorLabelsContain": [ "TransientTransactionError" ] } }, { - "name": "assertSessionUnpinned", "object": "testRunner", + "name": "assertSessionUnpinned", "arguments": { "session": "session0" } }, { - "name": "abortTransaction", - "object": "session0" + "object": "session0", + "name": "abortTransaction" } ], - "outcome": { - "collection": { - "data": [ + "outcome": [ + { + "collectionName": "test", + "databaseName": "transaction-tests", + "documents": [ { "_id": 1 }, @@ -2978,27 +3236,30 @@ } ] } - } + ] }, { "description": "unpin after transient connection error on findOneAndDelete findAndModify", - "useMultipleMongoses": true, "operations": [ { - "name": "startTransaction", - "object": "session0" + "object": "session0", + "name": "startTransaction" }, { + "object": "collection0", "name": "insertOne", - "object": "collection", "arguments": { "session": "session0", "document": { "_id": 3 } }, - "result": { - "insertedId": 3 + "expectResult": { + "$$unsetOrMatches": { + "insertedId": { + "$$unsetOrMatches": 3 + } + } } }, { @@ -3022,34 +3283,36 @@ }, { "name": "findOneAndDelete", - "object": "collection", + "object": "collection0", "arguments": { "session": "session0", "filter": { "_id": 1 } }, - "result": { + "expectError": { "errorLabelsContain": [ "TransientTransactionError" ] } }, { - "name": "assertSessionUnpinned", "object": "testRunner", + "name": "assertSessionUnpinned", "arguments": { "session": "session0" } }, { - "name": "abortTransaction", - "object": "session0" + "object": "session0", + "name": "abortTransaction" } ], - "outcome": { - "collection": { - "data": [ + "outcome": [ + { + "collectionName": "test", + "databaseName": "transaction-tests", + "documents": [ { "_id": 1 }, @@ -3058,27 +3321,30 @@ } ] } - } + ] }, { "description": "unpin after transient ShutdownInProgress error on findOneAndDelete findAndModify", - "useMultipleMongoses": true, "operations": [ { - "name": "startTransaction", - "object": "session0" + "object": "session0", + "name": "startTransaction" }, { + "object": "collection0", "name": "insertOne", - "object": "collection", "arguments": { "session": "session0", "document": { "_id": 3 } }, - "result": { - "insertedId": 3 + "expectResult": { + "$$unsetOrMatches": { + "insertedId": { + "$$unsetOrMatches": 3 + } + } } }, { @@ -3102,34 +3368,36 @@ }, { "name": "findOneAndDelete", - "object": "collection", + "object": "collection0", "arguments": { "session": "session0", "filter": { "_id": 1 } }, - "result": { + "expectError": { "errorLabelsContain": [ "TransientTransactionError" ] } }, { - "name": "assertSessionUnpinned", "object": "testRunner", + "name": "assertSessionUnpinned", "arguments": { "session": "session0" } }, { - "name": "abortTransaction", - "object": "session0" + "object": "session0", + "name": "abortTransaction" } ], - "outcome": { - "collection": { - "data": [ + "outcome": [ + { + "collectionName": "test", + "databaseName": "transaction-tests", + "documents": [ { "_id": 1 }, @@ -3138,27 +3406,30 @@ } ] } - } + ] }, { "description": "unpin after transient connection error on findOneAndUpdate findAndModify", - "useMultipleMongoses": true, "operations": [ { - "name": "startTransaction", - "object": "session0" + "object": "session0", + "name": "startTransaction" }, { + "object": "collection0", "name": "insertOne", - "object": "collection", "arguments": { "session": "session0", "document": { "_id": 3 } }, - "result": { - "insertedId": 3 + "expectResult": { + "$$unsetOrMatches": { + "insertedId": { + "$$unsetOrMatches": 3 + } + } } }, { @@ -3182,7 +3453,7 @@ }, { "name": "findOneAndUpdate", - "object": "collection", + "object": "collection0", "arguments": { "session": "session0", "filter": { @@ -3195,27 +3466,29 @@ }, "returnDocument": "Before" }, - "result": { + "expectError": { "errorLabelsContain": [ "TransientTransactionError" ] } }, { - "name": "assertSessionUnpinned", "object": "testRunner", + "name": "assertSessionUnpinned", "arguments": { "session": "session0" } }, { - "name": "abortTransaction", - "object": "session0" + "object": "session0", + "name": "abortTransaction" } ], - "outcome": { - "collection": { - "data": [ + "outcome": [ + { + "collectionName": "test", + "databaseName": "transaction-tests", + "documents": [ { "_id": 1 }, @@ -3224,27 +3497,30 @@ } ] } - } + ] }, { "description": "unpin after transient ShutdownInProgress error on findOneAndUpdate findAndModify", - "useMultipleMongoses": true, "operations": [ { - "name": "startTransaction", - "object": "session0" + "object": "session0", + "name": "startTransaction" }, { + "object": "collection0", "name": "insertOne", - "object": "collection", "arguments": { "session": "session0", "document": { "_id": 3 } }, - "result": { - "insertedId": 3 + "expectResult": { + "$$unsetOrMatches": { + "insertedId": { + "$$unsetOrMatches": 3 + } + } } }, { @@ -3268,7 +3544,7 @@ }, { "name": "findOneAndUpdate", - "object": "collection", + "object": "collection0", "arguments": { "session": "session0", "filter": { @@ -3281,27 +3557,29 @@ }, "returnDocument": "Before" }, - "result": { + "expectError": { "errorLabelsContain": [ "TransientTransactionError" ] } }, { - "name": "assertSessionUnpinned", "object": "testRunner", + "name": "assertSessionUnpinned", "arguments": { "session": "session0" } }, { - "name": "abortTransaction", - "object": "session0" + "object": "session0", + "name": "abortTransaction" } ], - "outcome": { - "collection": { - "data": [ + "outcome": [ + { + "collectionName": "test", + "databaseName": "transaction-tests", + "documents": [ { "_id": 1 }, @@ -3310,27 +3588,30 @@ } ] } - } + ] }, { "description": "unpin after transient connection error on findOneAndReplace findAndModify", - "useMultipleMongoses": true, "operations": [ { - "name": "startTransaction", - "object": "session0" + "object": "session0", + "name": "startTransaction" }, { + "object": "collection0", "name": "insertOne", - "object": "collection", "arguments": { "session": "session0", "document": { "_id": 3 } }, - "result": { - "insertedId": 3 + "expectResult": { + "$$unsetOrMatches": { + "insertedId": { + "$$unsetOrMatches": 3 + } + } } }, { @@ -3354,7 +3635,7 @@ }, { "name": "findOneAndReplace", - "object": "collection", + "object": "collection0", "arguments": { "session": "session0", "filter": { @@ -3365,27 +3646,29 @@ }, "returnDocument": "Before" }, - "result": { + "expectError": { "errorLabelsContain": [ "TransientTransactionError" ] } }, { - "name": "assertSessionUnpinned", "object": "testRunner", + "name": "assertSessionUnpinned", "arguments": { "session": "session0" } }, { - "name": "abortTransaction", - "object": "session0" + "object": "session0", + "name": "abortTransaction" } ], - "outcome": { - "collection": { - "data": [ + "outcome": [ + { + "collectionName": "test", + "databaseName": "transaction-tests", + "documents": [ { "_id": 1 }, @@ -3394,27 +3677,30 @@ } ] } - } + ] }, { "description": "unpin after transient ShutdownInProgress error on findOneAndReplace findAndModify", - "useMultipleMongoses": true, "operations": [ { - "name": "startTransaction", - "object": "session0" + "object": "session0", + "name": "startTransaction" }, { + "object": "collection0", "name": "insertOne", - "object": "collection", "arguments": { "session": "session0", "document": { "_id": 3 } }, - "result": { - "insertedId": 3 + "expectResult": { + "$$unsetOrMatches": { + "insertedId": { + "$$unsetOrMatches": 3 + } + } } }, { @@ -3438,7 +3724,7 @@ }, { "name": "findOneAndReplace", - "object": "collection", + "object": "collection0", "arguments": { "session": "session0", "filter": { @@ -3449,27 +3735,29 @@ }, "returnDocument": "Before" }, - "result": { + "expectError": { "errorLabelsContain": [ "TransientTransactionError" ] } }, { - "name": "assertSessionUnpinned", "object": "testRunner", + "name": "assertSessionUnpinned", "arguments": { "session": "session0" } }, { - "name": "abortTransaction", - "object": "session0" + "object": "session0", + "name": "abortTransaction" } ], - "outcome": { - "collection": { - "data": [ + "outcome": [ + { + "collectionName": "test", + "databaseName": "transaction-tests", + "documents": [ { "_id": 1 }, @@ -3478,27 +3766,30 @@ } ] } - } + ] }, { "description": "unpin after transient connection error on bulkWrite insert", - "useMultipleMongoses": true, "operations": [ { - "name": "startTransaction", - "object": "session0" + "object": "session0", + "name": "startTransaction" }, { + "object": "collection0", "name": "insertOne", - "object": "collection", "arguments": { "session": "session0", "document": { "_id": 3 } }, - "result": { - "insertedId": 3 + "expectResult": { + "$$unsetOrMatches": { + "insertedId": { + "$$unsetOrMatches": 3 + } + } } }, { @@ -3522,13 +3813,12 @@ }, { "name": "bulkWrite", - "object": "collection", + "object": "collection0", "arguments": { "session": "session0", "requests": [ { - "name": "insertOne", - "arguments": { + "insertOne": { "document": { "_id": 1 } @@ -3536,27 +3826,29 @@ } ] }, - "result": { + "expectError": { "errorLabelsContain": [ "TransientTransactionError" ] } }, { - "name": "assertSessionUnpinned", "object": "testRunner", + "name": "assertSessionUnpinned", "arguments": { "session": "session0" } }, { - "name": "abortTransaction", - "object": "session0" + "object": "session0", + "name": "abortTransaction" } ], - "outcome": { - "collection": { - "data": [ + "outcome": [ + { + "collectionName": "test", + "databaseName": "transaction-tests", + "documents": [ { "_id": 1 }, @@ -3565,27 +3857,30 @@ } ] } - } + ] }, { "description": "unpin after transient ShutdownInProgress error on bulkWrite insert", - "useMultipleMongoses": true, "operations": [ { - "name": "startTransaction", - "object": "session0" + "object": "session0", + "name": "startTransaction" }, { + "object": "collection0", "name": "insertOne", - "object": "collection", "arguments": { "session": "session0", "document": { "_id": 3 } }, - "result": { - "insertedId": 3 + "expectResult": { + "$$unsetOrMatches": { + "insertedId": { + "$$unsetOrMatches": 3 + } + } } }, { @@ -3609,13 +3904,12 @@ }, { "name": "bulkWrite", - "object": "collection", + "object": "collection0", "arguments": { "session": "session0", "requests": [ { - "name": "insertOne", - "arguments": { + "insertOne": { "document": { "_id": 1 } @@ -3623,27 +3917,29 @@ } ] }, - "result": { + "expectError": { "errorLabelsContain": [ "TransientTransactionError" ] } }, { - "name": "assertSessionUnpinned", "object": "testRunner", + "name": "assertSessionUnpinned", "arguments": { "session": "session0" } }, { - "name": "abortTransaction", - "object": "session0" + "object": "session0", + "name": "abortTransaction" } ], - "outcome": { - "collection": { - "data": [ + "outcome": [ + { + "collectionName": "test", + "databaseName": "transaction-tests", + "documents": [ { "_id": 1 }, @@ -3652,27 +3948,30 @@ } ] } - } + ] }, { "description": "unpin after transient connection error on bulkWrite update", - "useMultipleMongoses": true, "operations": [ { - "name": "startTransaction", - "object": "session0" + "object": "session0", + "name": "startTransaction" }, { + "object": "collection0", "name": "insertOne", - "object": "collection", "arguments": { "session": "session0", "document": { "_id": 3 } }, - "result": { - "insertedId": 3 + "expectResult": { + "$$unsetOrMatches": { + "insertedId": { + "$$unsetOrMatches": 3 + } + } } }, { @@ -3696,13 +3995,12 @@ }, { "name": "bulkWrite", - "object": "collection", + "object": "collection0", "arguments": { "session": "session0", "requests": [ { - "name": "updateOne", - "arguments": { + "updateOne": { "filter": { "_id": 1 }, @@ -3715,27 +4013,29 @@ } ] }, - "result": { + "expectError": { "errorLabelsContain": [ "TransientTransactionError" ] } }, { - "name": "assertSessionUnpinned", "object": "testRunner", + "name": "assertSessionUnpinned", "arguments": { "session": "session0" } }, { - "name": "abortTransaction", - "object": "session0" + "object": "session0", + "name": "abortTransaction" } ], - "outcome": { - "collection": { - "data": [ + "outcome": [ + { + "collectionName": "test", + "databaseName": "transaction-tests", + "documents": [ { "_id": 1 }, @@ -3744,27 +4044,30 @@ } ] } - } + ] }, { "description": "unpin after transient ShutdownInProgress error on bulkWrite update", - "useMultipleMongoses": true, "operations": [ { - "name": "startTransaction", - "object": "session0" + "object": "session0", + "name": "startTransaction" }, { + "object": "collection0", "name": "insertOne", - "object": "collection", "arguments": { "session": "session0", "document": { "_id": 3 } }, - "result": { - "insertedId": 3 + "expectResult": { + "$$unsetOrMatches": { + "insertedId": { + "$$unsetOrMatches": 3 + } + } } }, { @@ -3788,13 +4091,12 @@ }, { "name": "bulkWrite", - "object": "collection", + "object": "collection0", "arguments": { "session": "session0", "requests": [ { - "name": "updateOne", - "arguments": { + "updateOne": { "filter": { "_id": 1 }, @@ -3807,27 +4109,29 @@ } ] }, - "result": { + "expectError": { "errorLabelsContain": [ "TransientTransactionError" ] } }, { - "name": "assertSessionUnpinned", "object": "testRunner", + "name": "assertSessionUnpinned", "arguments": { "session": "session0" } }, { - "name": "abortTransaction", - "object": "session0" + "object": "session0", + "name": "abortTransaction" } ], - "outcome": { - "collection": { - "data": [ + "outcome": [ + { + "collectionName": "test", + "databaseName": "transaction-tests", + "documents": [ { "_id": 1 }, @@ -3836,27 +4140,30 @@ } ] } - } + ] }, { "description": "unpin after transient connection error on bulkWrite delete", - "useMultipleMongoses": true, "operations": [ { - "name": "startTransaction", - "object": "session0" + "object": "session0", + "name": "startTransaction" }, { + "object": "collection0", "name": "insertOne", - "object": "collection", "arguments": { "session": "session0", "document": { "_id": 3 } }, - "result": { - "insertedId": 3 + "expectResult": { + "$$unsetOrMatches": { + "insertedId": { + "$$unsetOrMatches": 3 + } + } } }, { @@ -3880,13 +4187,12 @@ }, { "name": "bulkWrite", - "object": "collection", + "object": "collection0", "arguments": { "session": "session0", "requests": [ { - "name": "deleteOne", - "arguments": { + "deleteOne": { "filter": { "_id": 1 } @@ -3894,27 +4200,29 @@ } ] }, - "result": { + "expectError": { "errorLabelsContain": [ "TransientTransactionError" ] } }, { - "name": "assertSessionUnpinned", "object": "testRunner", + "name": "assertSessionUnpinned", "arguments": { "session": "session0" } }, { - "name": "abortTransaction", - "object": "session0" + "object": "session0", + "name": "abortTransaction" } ], - "outcome": { - "collection": { - "data": [ + "outcome": [ + { + "collectionName": "test", + "databaseName": "transaction-tests", + "documents": [ { "_id": 1 }, @@ -3923,27 +4231,30 @@ } ] } - } + ] }, { "description": "unpin after transient ShutdownInProgress error on bulkWrite delete", - "useMultipleMongoses": true, "operations": [ { - "name": "startTransaction", - "object": "session0" + "object": "session0", + "name": "startTransaction" }, { + "object": "collection0", "name": "insertOne", - "object": "collection", "arguments": { "session": "session0", "document": { "_id": 3 } }, - "result": { - "insertedId": 3 + "expectResult": { + "$$unsetOrMatches": { + "insertedId": { + "$$unsetOrMatches": 3 + } + } } }, { @@ -3967,13 +4278,12 @@ }, { "name": "bulkWrite", - "object": "collection", + "object": "collection0", "arguments": { "session": "session0", "requests": [ { - "name": "deleteOne", - "arguments": { + "deleteOne": { "filter": { "_id": 1 } @@ -3981,27 +4291,29 @@ } ] }, - "result": { + "expectError": { "errorLabelsContain": [ "TransientTransactionError" ] } }, { - "name": "assertSessionUnpinned", "object": "testRunner", + "name": "assertSessionUnpinned", "arguments": { "session": "session0" } }, { - "name": "abortTransaction", - "object": "session0" + "object": "session0", + "name": "abortTransaction" } ], - "outcome": { - "collection": { - "data": [ + "outcome": [ + { + "collectionName": "test", + "databaseName": "transaction-tests", + "documents": [ { "_id": 1 }, @@ -4010,27 +4322,30 @@ } ] } - } + ] }, { "description": "unpin after transient connection error on find find", - "useMultipleMongoses": true, "operations": [ { - "name": "startTransaction", - "object": "session0" + "object": "session0", + "name": "startTransaction" }, { + "object": "collection0", "name": "insertOne", - "object": "collection", "arguments": { "session": "session0", "document": { "_id": 3 } }, - "result": { - "insertedId": 3 + "expectResult": { + "$$unsetOrMatches": { + "insertedId": { + "$$unsetOrMatches": 3 + } + } } }, { @@ -4054,34 +4369,36 @@ }, { "name": "find", - "object": "collection", + "object": "collection0", "arguments": { "session": "session0", "filter": { "_id": 1 } }, - "result": { + "expectError": { "errorLabelsContain": [ "TransientTransactionError" ] } }, { - "name": "assertSessionUnpinned", "object": "testRunner", + "name": "assertSessionUnpinned", "arguments": { "session": "session0" } }, { - "name": "abortTransaction", - "object": "session0" + "object": "session0", + "name": "abortTransaction" } ], - "outcome": { - "collection": { - "data": [ + "outcome": [ + { + "collectionName": "test", + "databaseName": "transaction-tests", + "documents": [ { "_id": 1 }, @@ -4090,27 +4407,30 @@ } ] } - } + ] }, { "description": "unpin after transient ShutdownInProgress error on find find", - "useMultipleMongoses": true, "operations": [ { - "name": "startTransaction", - "object": "session0" + "object": "session0", + "name": "startTransaction" }, { + "object": "collection0", "name": "insertOne", - "object": "collection", "arguments": { "session": "session0", "document": { "_id": 3 } }, - "result": { - "insertedId": 3 + "expectResult": { + "$$unsetOrMatches": { + "insertedId": { + "$$unsetOrMatches": 3 + } + } } }, { @@ -4134,34 +4454,36 @@ }, { "name": "find", - "object": "collection", + "object": "collection0", "arguments": { "session": "session0", "filter": { "_id": 1 } }, - "result": { + "expectError": { "errorLabelsContain": [ "TransientTransactionError" ] } }, { - "name": "assertSessionUnpinned", "object": "testRunner", + "name": "assertSessionUnpinned", "arguments": { "session": "session0" } }, { - "name": "abortTransaction", - "object": "session0" + "object": "session0", + "name": "abortTransaction" } ], - "outcome": { - "collection": { - "data": [ + "outcome": [ + { + "collectionName": "test", + "databaseName": "transaction-tests", + "documents": [ { "_id": 1 }, @@ -4170,27 +4492,30 @@ } ] } - } + ] }, { "description": "unpin after transient connection error on countDocuments aggregate", - "useMultipleMongoses": true, "operations": [ { - "name": "startTransaction", - "object": "session0" + "object": "session0", + "name": "startTransaction" }, { + "object": "collection0", "name": "insertOne", - "object": "collection", "arguments": { "session": "session0", "document": { "_id": 3 } }, - "result": { - "insertedId": 3 + "expectResult": { + "$$unsetOrMatches": { + "insertedId": { + "$$unsetOrMatches": 3 + } + } } }, { @@ -4214,32 +4539,34 @@ }, { "name": "countDocuments", - "object": "collection", + "object": "collection0", "arguments": { "session": "session0", "filter": {} }, - "result": { + "expectError": { "errorLabelsContain": [ "TransientTransactionError" ] } }, { - "name": "assertSessionUnpinned", "object": "testRunner", + "name": "assertSessionUnpinned", "arguments": { "session": "session0" } }, { - "name": "abortTransaction", - "object": "session0" + "object": "session0", + "name": "abortTransaction" } ], - "outcome": { - "collection": { - "data": [ + "outcome": [ + { + "collectionName": "test", + "databaseName": "transaction-tests", + "documents": [ { "_id": 1 }, @@ -4248,27 +4575,30 @@ } ] } - } + ] }, { "description": "unpin after transient ShutdownInProgress error on countDocuments aggregate", - "useMultipleMongoses": true, "operations": [ { - "name": "startTransaction", - "object": "session0" + "object": "session0", + "name": "startTransaction" }, { + "object": "collection0", "name": "insertOne", - "object": "collection", "arguments": { "session": "session0", "document": { "_id": 3 } }, - "result": { - "insertedId": 3 + "expectResult": { + "$$unsetOrMatches": { + "insertedId": { + "$$unsetOrMatches": 3 + } + } } }, { @@ -4292,32 +4622,34 @@ }, { "name": "countDocuments", - "object": "collection", + "object": "collection0", "arguments": { "session": "session0", "filter": {} }, - "result": { + "expectError": { "errorLabelsContain": [ "TransientTransactionError" ] } }, { - "name": "assertSessionUnpinned", "object": "testRunner", + "name": "assertSessionUnpinned", "arguments": { "session": "session0" } }, { - "name": "abortTransaction", - "object": "session0" + "object": "session0", + "name": "abortTransaction" } ], - "outcome": { - "collection": { - "data": [ + "outcome": [ + { + "collectionName": "test", + "databaseName": "transaction-tests", + "documents": [ { "_id": 1 }, @@ -4326,27 +4658,30 @@ } ] } - } + ] }, { "description": "unpin after transient connection error on aggregate aggregate", - "useMultipleMongoses": true, "operations": [ { - "name": "startTransaction", - "object": "session0" + "object": "session0", + "name": "startTransaction" }, { + "object": "collection0", "name": "insertOne", - "object": "collection", "arguments": { "session": "session0", "document": { "_id": 3 } }, - "result": { - "insertedId": 3 + "expectResult": { + "$$unsetOrMatches": { + "insertedId": { + "$$unsetOrMatches": 3 + } + } } }, { @@ -4370,32 +4705,34 @@ }, { "name": "aggregate", - "object": "collection", + "object": "collection0", "arguments": { "session": "session0", "pipeline": [] }, - "result": { + "expectError": { "errorLabelsContain": [ "TransientTransactionError" ] } }, { - "name": "assertSessionUnpinned", "object": "testRunner", + "name": "assertSessionUnpinned", "arguments": { "session": "session0" } }, { - "name": "abortTransaction", - "object": "session0" + "object": "session0", + "name": "abortTransaction" } ], - "outcome": { - "collection": { - "data": [ + "outcome": [ + { + "collectionName": "test", + "databaseName": "transaction-tests", + "documents": [ { "_id": 1 }, @@ -4404,27 +4741,30 @@ } ] } - } + ] }, { "description": "unpin after transient ShutdownInProgress error on aggregate aggregate", - "useMultipleMongoses": true, "operations": [ { - "name": "startTransaction", - "object": "session0" + "object": "session0", + "name": "startTransaction" }, { + "object": "collection0", "name": "insertOne", - "object": "collection", "arguments": { "session": "session0", "document": { "_id": 3 } }, - "result": { - "insertedId": 3 + "expectResult": { + "$$unsetOrMatches": { + "insertedId": { + "$$unsetOrMatches": 3 + } + } } }, { @@ -4448,32 +4788,34 @@ }, { "name": "aggregate", - "object": "collection", + "object": "collection0", "arguments": { "session": "session0", "pipeline": [] }, - "result": { + "expectError": { "errorLabelsContain": [ "TransientTransactionError" ] } }, { - "name": "assertSessionUnpinned", "object": "testRunner", + "name": "assertSessionUnpinned", "arguments": { "session": "session0" } }, { - "name": "abortTransaction", - "object": "session0" + "object": "session0", + "name": "abortTransaction" } ], - "outcome": { - "collection": { - "data": [ + "outcome": [ + { + "collectionName": "test", + "databaseName": "transaction-tests", + "documents": [ { "_id": 1 }, @@ -4482,27 +4824,30 @@ } ] } - } + ] }, { "description": "unpin after transient connection error on distinct distinct", - "useMultipleMongoses": true, "operations": [ { - "name": "startTransaction", - "object": "session0" + "object": "session0", + "name": "startTransaction" }, { + "object": "collection0", "name": "insertOne", - "object": "collection", "arguments": { "session": "session0", "document": { "_id": 3 } }, - "result": { - "insertedId": 3 + "expectResult": { + "$$unsetOrMatches": { + "insertedId": { + "$$unsetOrMatches": 3 + } + } } }, { @@ -4526,32 +4871,35 @@ }, { "name": "distinct", - "object": "collection", + "object": "collection0", "arguments": { "session": "session0", - "fieldName": "_id" + "fieldName": "_id", + "filter": {} }, - "result": { + "expectError": { "errorLabelsContain": [ "TransientTransactionError" ] } }, { - "name": "assertSessionUnpinned", "object": "testRunner", + "name": "assertSessionUnpinned", "arguments": { "session": "session0" } }, { - "name": "abortTransaction", - "object": "session0" + "object": "session0", + "name": "abortTransaction" } ], - "outcome": { - "collection": { - "data": [ + "outcome": [ + { + "collectionName": "test", + "databaseName": "transaction-tests", + "documents": [ { "_id": 1 }, @@ -4560,27 +4908,30 @@ } ] } - } + ] }, { "description": "unpin after transient ShutdownInProgress error on distinct distinct", - "useMultipleMongoses": true, "operations": [ { - "name": "startTransaction", - "object": "session0" + "object": "session0", + "name": "startTransaction" }, { + "object": "collection0", "name": "insertOne", - "object": "collection", "arguments": { "session": "session0", "document": { "_id": 3 } }, - "result": { - "insertedId": 3 + "expectResult": { + "$$unsetOrMatches": { + "insertedId": { + "$$unsetOrMatches": 3 + } + } } }, { @@ -4604,32 +4955,35 @@ }, { "name": "distinct", - "object": "collection", + "object": "collection0", "arguments": { "session": "session0", - "fieldName": "_id" + "fieldName": "_id", + "filter": {} }, - "result": { + "expectError": { "errorLabelsContain": [ "TransientTransactionError" ] } }, { - "name": "assertSessionUnpinned", "object": "testRunner", + "name": "assertSessionUnpinned", "arguments": { "session": "session0" } }, { - "name": "abortTransaction", - "object": "session0" + "object": "session0", + "name": "abortTransaction" } ], - "outcome": { - "collection": { - "data": [ + "outcome": [ + { + "collectionName": "test", + "databaseName": "transaction-tests", + "documents": [ { "_id": 1 }, @@ -4638,27 +4992,30 @@ } ] } - } + ] }, { "description": "unpin after transient connection error on runCommand insert", - "useMultipleMongoses": true, "operations": [ { - "name": "startTransaction", - "object": "session0" + "object": "session0", + "name": "startTransaction" }, { + "object": "collection0", "name": "insertOne", - "object": "collection", "arguments": { "session": "session0", "document": { "_id": 3 } }, - "result": { - "insertedId": 3 + "expectResult": { + "$$unsetOrMatches": { + "insertedId": { + "$$unsetOrMatches": 3 + } + } } }, { @@ -4682,10 +5039,10 @@ }, { "name": "runCommand", - "object": "database", - "command_name": "insert", + "object": "database0", "arguments": { "session": "session0", + "commandName": "insert", "command": { "insert": "test", "documents": [ @@ -4695,27 +5052,29 @@ ] } }, - "result": { + "expectError": { "errorLabelsContain": [ "TransientTransactionError" ] } }, { - "name": "assertSessionUnpinned", "object": "testRunner", + "name": "assertSessionUnpinned", "arguments": { "session": "session0" } }, { - "name": "abortTransaction", - "object": "session0" + "object": "session0", + "name": "abortTransaction" } ], - "outcome": { - "collection": { - "data": [ + "outcome": [ + { + "collectionName": "test", + "databaseName": "transaction-tests", + "documents": [ { "_id": 1 }, @@ -4724,27 +5083,30 @@ } ] } - } + ] }, { "description": "unpin after transient ShutdownInProgress error on runCommand insert", - "useMultipleMongoses": true, "operations": [ { - "name": "startTransaction", - "object": "session0" + "object": "session0", + "name": "startTransaction" }, { + "object": "collection0", "name": "insertOne", - "object": "collection", "arguments": { "session": "session0", "document": { "_id": 3 } }, - "result": { - "insertedId": 3 + "expectResult": { + "$$unsetOrMatches": { + "insertedId": { + "$$unsetOrMatches": 3 + } + } } }, { @@ -4768,10 +5130,10 @@ }, { "name": "runCommand", - "object": "database", - "command_name": "insert", + "object": "database0", "arguments": { "session": "session0", + "commandName": "insert", "command": { "insert": "test", "documents": [ @@ -4781,27 +5143,29 @@ ] } }, - "result": { + "expectError": { "errorLabelsContain": [ "TransientTransactionError" ] } }, { - "name": "assertSessionUnpinned", "object": "testRunner", + "name": "assertSessionUnpinned", "arguments": { "session": "session0" } }, { - "name": "abortTransaction", - "object": "session0" + "object": "session0", + "name": "abortTransaction" } ], - "outcome": { - "collection": { - "data": [ + "outcome": [ + { + "collectionName": "test", + "databaseName": "transaction-tests", + "documents": [ { "_id": 1 }, @@ -4810,7 +5174,7 @@ } ] } - } + ] } ] } diff --git a/source/transactions/tests/legacy/mongos-pin-auto.yml b/source/transactions/tests/unified/mongos-pin-auto.yml similarity index 71% rename from source/transactions/tests/legacy/mongos-pin-auto.yml rename to source/transactions/tests/unified/mongos-pin-auto.yml index f5a5fe1571..7a76347555 100644 --- a/source/transactions/tests/legacy/mongos-pin-auto.yml +++ b/source/transactions/tests/unified/mongos-pin-auto.yml @@ -1,219 +1,220 @@ # Autogenerated tests that transient errors in a transaction unpin the session. # See mongos-pin-auto-tests.py -runOn: - - - minServerVersion: "4.1.8" - topology: ["sharded", "load-balanced"] - # serverless proxy doesn't append error labels to errors in transactions - # caused by failpoints (CLOUDP-88216) - serverless: "forbid" -database_name: &database_name "transaction-tests" -collection_name: &collection_name "test" - -data: &data - - {_id: 1} - - {_id: 2} +description: mongos-pin-auto + +schemaVersion: '1.4' + +runOnRequirements: + - minServerVersion: "4.1.8" + # Note: tests utilize targetedFailPoint, which is incompatible with + # load-balanced and useMultipleMongoses:true + topologies: [ sharded ] + # serverless proxy doesn't append error labels to errors in transactions + # caused by failpoints (CLOUDP-88216) + serverless: "forbid" + +createEntities: + - client: + id: &client0 client0 + useMultipleMongoses: true + observeEvents: [ commandStartedEvent ] + - database: + id: &database0 database0 + client: *client0 + databaseName: &database_name transaction-tests + - collection: + id: &collection0 collection0 + database: *database0 + collectionName: &collection_name test + - session: + id: &session0 session0 + client: *client0 + +initialData: + - collectionName: *collection_name + databaseName: *database_name + documents: &data + - { _id: 1 } + - { _id: 2 } tests: - description: remain pinned after non-transient Interrupted error on insertOne - useMultipleMongoses: true operations: - &startTransaction - name: startTransaction object: session0 + name: startTransaction - &initialCommand + object: *collection0 name: insertOne - object: collection arguments: - session: session0 - document: {_id: 3} - result: - insertedId: 3 - - name: targetedFailPoint - object: testRunner + session: *session0 + document: { _id: 3 } + expectResult: { $$unsetOrMatches: { insertedId: { $$unsetOrMatches: 3 } } } + - object: testRunner + name: targetedFailPoint arguments: - session: session0 + session: *session0 failPoint: configureFailPoint: failCommand - mode: {times: 1} + mode: { times: 1 } data: - failCommands: ["insert"] + failCommands: [ "insert" ] errorCode: 11601 - - name: insertOne - object: collection + - object: *collection0 + name: insertOne arguments: - session: session0 - document: - _id: 4 - result: + session: *session0 + document: { _id: 4 } + expectError: errorLabelsOmit: ["TransientTransactionError", "UnknownTransactionCommitResult"] errorCodeName: Interrupted - &assertSessionPinned - name: assertSessionPinned object: testRunner + name: assertSessionPinned arguments: - session: session0 + session: *session0 - &commitTransaction + object: *session0 name: commitTransaction - object: session0 - - expectations: - - command_started_event: - command: - insert: *collection_name - documents: - - _id: 3 - ordered: true - readConcern: - lsid: session0 - txnNumber: - $numberLong: "1" - startTransaction: true - autocommit: false - writeConcern: - command_name: insert - database_name: *database_name - - command_started_event: - command: - insert: *collection_name - documents: - - _id: 4 - ordered: true - readConcern: - lsid: session0 - txnNumber: - $numberLong: "1" - startTransaction: - autocommit: false - writeConcern: - command_name: insert - database_name: *database_name - - command_started_event: - command: - commitTransaction: 1 - lsid: session0 - txnNumber: - $numberLong: "1" - startTransaction: - autocommit: false - writeConcern: - recoveryToken: 42 - command_name: commitTransaction - database_name: admin - - outcome: &outcome - collection: - data: - - {_id: 1} - - {_id: 2} - - {_id: 3} - - - description: unpin after transient error within a transaction - useMultipleMongoses: true + expectEvents: + - client: *client0 + events: + - commandStartedEvent: + command: + insert: *collection_name + documents: + - { _id: 3 } + ordered: true + readConcern: { $$exists: false } + lsid: { $$sessionLsid: *session0 } + txnNumber: { $numberLong: '1' } + startTransaction: true + autocommit: false + writeConcern: { $$exists: false } + commandName: insert + databaseName: *database_name + - commandStartedEvent: + command: + insert: *collection_name + documents: + - { _id: 4 } + ordered: true + readConcern: { $$exists: false } + lsid: { $$sessionLsid: *session0 } + txnNumber: { $numberLong: '1' } + startTransaction: { $$exists: false } + autocommit: false + writeConcern: { $$exists: false } + commandName: insert + databaseName: *database_name + - commandStartedEvent: + command: + commitTransaction: 1 + lsid: { $$sessionLsid: *session0 } + txnNumber: { $numberLong: '1' } + startTransaction: { $$exists: false } + autocommit: false + writeConcern: { $$exists: false } + recoveryToken: { $$exists: true } + commandName: commitTransaction + databaseName: admin + outcome: + - collectionName: *collection_name + databaseName: *database_name + documents: + - { _id: 1 } + - { _id: 2 } + - { _id: 3 } + + - description: 'unpin after transient error within a transaction' operations: - - &startTransaction - name: startTransaction - object: session0 - - &initialCommand - name: insertOne - object: collection - arguments: - session: session0 - document: - _id: 3 - result: - insertedId: 3 - - name: targetedFailPoint - object: testRunner + - *startTransaction + - *initialCommand + - object: testRunner + name: targetedFailPoint arguments: - session: session0 + session: *session0 failPoint: configureFailPoint: failCommand mode: { times: 1 } data: - failCommands: ["insert"] + failCommands: [ "insert" ] closeConnection: true - - name: insertOne - object: collection + - object: *collection0 + name: insertOne arguments: - session: session0 - document: - _id: 4 - result: + session: *session0 + document: { _id: 4 } + expectError: errorLabelsContain: ["TransientTransactionError"] errorLabelsOmit: ["UnknownTransactionCommitResult"] - # Session unpins from the first mongos after the insert error and - # abortTransaction succeeds immediately on any mongos. - &assertSessionUnpinned - name: assertSessionUnpinned object: testRunner + name: assertSessionUnpinned arguments: - session: session0 + session: *session0 - &abortTransaction + object: *session0 name: abortTransaction - object: session0 - - expectations: - - command_started_event: - command: - insert: *collection_name - documents: - - _id: 3 - ordered: true - readConcern: - lsid: session0 - txnNumber: - $numberLong: "1" - startTransaction: true - autocommit: false - writeConcern: - command_name: insert - database_name: *database_name - - command_started_event: - command: - insert: *collection_name - documents: - - _id: 4 - ordered: true - readConcern: - lsid: session0 - txnNumber: - $numberLong: "1" - startTransaction: - autocommit: false - writeConcern: - command_name: insert - database_name: *database_name - - command_started_event: - command: - abortTransaction: 1 - lsid: session0 - txnNumber: - $numberLong: "1" - startTransaction: - autocommit: false - writeConcern: - recoveryToken: 42 - command_name: abortTransaction - database_name: admin - + expectEvents: + - client: *client0 + events: + - commandStartedEvent: + command: + insert: *collection_name + documents: + - { _id: 3 } + ordered: true + readConcern: { $$exists: false } + lsid: { $$sessionLsid: *session0 } + txnNumber: { $numberLong: '1' } + startTransaction: true + autocommit: false + writeConcern: { $$exists: false } + commandName: insert + databaseName: *database_name + - commandStartedEvent: + command: + insert: *collection_name + documents: + - { _id: 4 } + ordered: true + readConcern: { $$exists: false } + lsid: { $$sessionLsid: *session0 } + txnNumber: { $numberLong: '1' } + startTransaction: { $$exists: false } + autocommit: false + writeConcern: { $$exists: false } + commandName: insert + databaseName: *database_name + - commandStartedEvent: + command: + abortTransaction: 1 + lsid: { $$sessionLsid: *session0 } + txnNumber: { $numberLong: '1' } + startTransaction: { $$exists: false } + autocommit: false + writeConcern: { $$exists: false } + recoveryToken: { $$exists: true } + commandName: abortTransaction + databaseName: admin outcome: &outcome - collection: - data: *data + - collectionName: *collection_name + databaseName: *database_name + documents: *data # The rest of the tests in this file test every operation type against # multiple types of transient errors (connection and error code). - description: remain pinned after non-transient Interrupted error on insertOne insert - useMultipleMongoses: true operations: - *startTransaction - *initialCommand - name: targetedFailPoint object: testRunner arguments: - session: session0 + session: *session0 failPoint: configureFailPoint: failCommand mode: {times: 1} @@ -221,25 +222,24 @@ tests: failCommands: ["insert"] errorCode: 11601 - name: insertOne - object: collection + object: *collection0 arguments: - session: session0 - document: {_id: 4} - result: + session: *session0 + document: { _id: 4 } + expectError: errorLabelsOmit: ["TransientTransactionError"] - *assertSessionPinned - *abortTransaction outcome: *outcome - description: remain pinned after non-transient Interrupted error on insertMany insert - useMultipleMongoses: true operations: - *startTransaction - *initialCommand - name: targetedFailPoint object: testRunner arguments: - session: session0 + session: *session0 failPoint: configureFailPoint: failCommand mode: {times: 1} @@ -247,25 +247,24 @@ tests: failCommands: ["insert"] errorCode: 11601 - name: insertMany - object: collection + object: *collection0 arguments: - session: session0 - documents: [{_id: 4}, {_id: 5}] - result: + session: *session0 + documents: [ { _id: 4 }, { _id: 5 } ] + expectError: errorLabelsOmit: ["TransientTransactionError"] - *assertSessionPinned - *abortTransaction outcome: *outcome - description: remain pinned after non-transient Interrupted error on updateOne update - useMultipleMongoses: true operations: - *startTransaction - *initialCommand - name: targetedFailPoint object: testRunner arguments: - session: session0 + session: *session0 failPoint: configureFailPoint: failCommand mode: {times: 1} @@ -273,26 +272,25 @@ tests: failCommands: ["update"] errorCode: 11601 - name: updateOne - object: collection + object: *collection0 arguments: - session: session0 - filter: {_id: 1} - update: {$inc: {x: 1}} - result: + session: *session0 + filter: { _id: 1 } + update: { $inc: { x: 1 } } + expectError: errorLabelsOmit: ["TransientTransactionError"] - *assertSessionPinned - *abortTransaction outcome: *outcome - description: remain pinned after non-transient Interrupted error on replaceOne update - useMultipleMongoses: true operations: - *startTransaction - *initialCommand - name: targetedFailPoint object: testRunner arguments: - session: session0 + session: *session0 failPoint: configureFailPoint: failCommand mode: {times: 1} @@ -300,26 +298,25 @@ tests: failCommands: ["update"] errorCode: 11601 - name: replaceOne - object: collection + object: *collection0 arguments: - session: session0 - filter: {_id: 1} - replacement: {y: 1} - result: + session: *session0 + filter: { _id: 1 } + replacement: { y: 1 } + expectError: errorLabelsOmit: ["TransientTransactionError"] - *assertSessionPinned - *abortTransaction outcome: *outcome - description: remain pinned after non-transient Interrupted error on updateMany update - useMultipleMongoses: true operations: - *startTransaction - *initialCommand - name: targetedFailPoint object: testRunner arguments: - session: session0 + session: *session0 failPoint: configureFailPoint: failCommand mode: {times: 1} @@ -327,26 +324,25 @@ tests: failCommands: ["update"] errorCode: 11601 - name: updateMany - object: collection + object: *collection0 arguments: - session: session0 - filter: {_id: {$gte: 1}} - update: {$set: {z: 1}} - result: + session: *session0 + filter: { _id: { $gte: 1 } } + update: {$set: { z: 1 } } + expectError: errorLabelsOmit: ["TransientTransactionError"] - *assertSessionPinned - *abortTransaction outcome: *outcome - description: remain pinned after non-transient Interrupted error on deleteOne delete - useMultipleMongoses: true operations: - *startTransaction - *initialCommand - name: targetedFailPoint object: testRunner arguments: - session: session0 + session: *session0 failPoint: configureFailPoint: failCommand mode: {times: 1} @@ -354,25 +350,24 @@ tests: failCommands: ["delete"] errorCode: 11601 - name: deleteOne - object: collection + object: *collection0 arguments: - session: session0 - filter: {_id: 1} - result: + session: *session0 + filter: { _id: 1 } + expectError: errorLabelsOmit: ["TransientTransactionError"] - *assertSessionPinned - *abortTransaction outcome: *outcome - description: remain pinned after non-transient Interrupted error on deleteMany delete - useMultipleMongoses: true operations: - *startTransaction - *initialCommand - name: targetedFailPoint object: testRunner arguments: - session: session0 + session: *session0 failPoint: configureFailPoint: failCommand mode: {times: 1} @@ -380,25 +375,24 @@ tests: failCommands: ["delete"] errorCode: 11601 - name: deleteMany - object: collection + object: *collection0 arguments: - session: session0 - filter: {_id: {$gte: 1}} - result: + session: *session0 + filter: { _id: { $gte: 1 } } + expectError: errorLabelsOmit: ["TransientTransactionError"] - *assertSessionPinned - *abortTransaction outcome: *outcome - description: remain pinned after non-transient Interrupted error on findOneAndDelete findAndModify - useMultipleMongoses: true operations: - *startTransaction - *initialCommand - name: targetedFailPoint object: testRunner arguments: - session: session0 + session: *session0 failPoint: configureFailPoint: failCommand mode: {times: 1} @@ -406,25 +400,24 @@ tests: failCommands: ["findAndModify"] errorCode: 11601 - name: findOneAndDelete - object: collection + object: *collection0 arguments: - session: session0 - filter: {_id: 1} - result: + session: *session0 + filter: { _id: 1 } + expectError: errorLabelsOmit: ["TransientTransactionError"] - *assertSessionPinned - *abortTransaction outcome: *outcome - description: remain pinned after non-transient Interrupted error on findOneAndUpdate findAndModify - useMultipleMongoses: true operations: - *startTransaction - *initialCommand - name: targetedFailPoint object: testRunner arguments: - session: session0 + session: *session0 failPoint: configureFailPoint: failCommand mode: {times: 1} @@ -432,27 +425,26 @@ tests: failCommands: ["findAndModify"] errorCode: 11601 - name: findOneAndUpdate - object: collection + object: *collection0 arguments: - session: session0 - filter: {_id: 1} - update: {$inc: {x: 1}} + session: *session0 + filter: { _id: 1 } + update: { $inc: { x: 1 } } returnDocument: Before - result: + expectError: errorLabelsOmit: ["TransientTransactionError"] - *assertSessionPinned - *abortTransaction outcome: *outcome - description: remain pinned after non-transient Interrupted error on findOneAndReplace findAndModify - useMultipleMongoses: true operations: - *startTransaction - *initialCommand - name: targetedFailPoint object: testRunner arguments: - session: session0 + session: *session0 failPoint: configureFailPoint: failCommand mode: {times: 1} @@ -460,27 +452,26 @@ tests: failCommands: ["findAndModify"] errorCode: 11601 - name: findOneAndReplace - object: collection + object: *collection0 arguments: - session: session0 - filter: {_id: 1} - replacement: {y: 1} + session: *session0 + filter: { _id: 1 } + replacement: { y: 1 } returnDocument: Before - result: + expectError: errorLabelsOmit: ["TransientTransactionError"] - *assertSessionPinned - *abortTransaction outcome: *outcome - description: remain pinned after non-transient Interrupted error on bulkWrite insert - useMultipleMongoses: true operations: - *startTransaction - *initialCommand - name: targetedFailPoint object: testRunner arguments: - session: session0 + session: *session0 failPoint: configureFailPoint: failCommand mode: {times: 1} @@ -488,28 +479,26 @@ tests: failCommands: ["insert"] errorCode: 11601 - name: bulkWrite - object: collection + object: *collection0 arguments: - session: session0 + session: *session0 requests: - - name: insertOne - arguments: - document: {_id: 1} - result: + - insertOne: + document: { _id: 1 } + expectError: errorLabelsOmit: ["TransientTransactionError"] - *assertSessionPinned - *abortTransaction outcome: *outcome - description: remain pinned after non-transient Interrupted error on bulkWrite update - useMultipleMongoses: true operations: - *startTransaction - *initialCommand - name: targetedFailPoint object: testRunner arguments: - session: session0 + session: *session0 failPoint: configureFailPoint: failCommand mode: {times: 1} @@ -517,29 +506,27 @@ tests: failCommands: ["update"] errorCode: 11601 - name: bulkWrite - object: collection + object: *collection0 arguments: - session: session0 + session: *session0 requests: - - name: updateOne - arguments: - filter: {_id: 1} - update: {$set: {x: 1}} - result: + - updateOne: + filter: { _id: 1 } + update: { $set: { x: 1 } } + expectError: errorLabelsOmit: ["TransientTransactionError"] - *assertSessionPinned - *abortTransaction outcome: *outcome - description: remain pinned after non-transient Interrupted error on bulkWrite delete - useMultipleMongoses: true operations: - *startTransaction - *initialCommand - name: targetedFailPoint object: testRunner arguments: - session: session0 + session: *session0 failPoint: configureFailPoint: failCommand mode: {times: 1} @@ -547,28 +534,26 @@ tests: failCommands: ["delete"] errorCode: 11601 - name: bulkWrite - object: collection + object: *collection0 arguments: - session: session0 + session: *session0 requests: - - name: deleteOne - arguments: - filter: {_id: 1} - result: + - deleteOne: + filter: { _id: 1 } + expectError: errorLabelsOmit: ["TransientTransactionError"] - *assertSessionPinned - *abortTransaction outcome: *outcome - description: remain pinned after non-transient Interrupted error on find find - useMultipleMongoses: true operations: - *startTransaction - *initialCommand - name: targetedFailPoint object: testRunner arguments: - session: session0 + session: *session0 failPoint: configureFailPoint: failCommand mode: {times: 1} @@ -576,25 +561,24 @@ tests: failCommands: ["find"] errorCode: 11601 - name: find - object: collection + object: *collection0 arguments: - session: session0 - filter: {_id: 1} - result: + session: *session0 + filter: { _id: 1 } + expectError: errorLabelsOmit: ["TransientTransactionError"] - *assertSessionPinned - *abortTransaction outcome: *outcome - description: remain pinned after non-transient Interrupted error on countDocuments aggregate - useMultipleMongoses: true operations: - *startTransaction - *initialCommand - name: targetedFailPoint object: testRunner arguments: - session: session0 + session: *session0 failPoint: configureFailPoint: failCommand mode: {times: 1} @@ -602,25 +586,24 @@ tests: failCommands: ["aggregate"] errorCode: 11601 - name: countDocuments - object: collection + object: *collection0 arguments: - session: session0 + session: *session0 filter: {} - result: + expectError: errorLabelsOmit: ["TransientTransactionError"] - *assertSessionPinned - *abortTransaction outcome: *outcome - description: remain pinned after non-transient Interrupted error on aggregate aggregate - useMultipleMongoses: true operations: - *startTransaction - *initialCommand - name: targetedFailPoint object: testRunner arguments: - session: session0 + session: *session0 failPoint: configureFailPoint: failCommand mode: {times: 1} @@ -628,25 +611,24 @@ tests: failCommands: ["aggregate"] errorCode: 11601 - name: aggregate - object: collection + object: *collection0 arguments: - session: session0 + session: *session0 pipeline: [] - result: + expectError: errorLabelsOmit: ["TransientTransactionError"] - *assertSessionPinned - *abortTransaction outcome: *outcome - description: remain pinned after non-transient Interrupted error on distinct distinct - useMultipleMongoses: true operations: - *startTransaction - *initialCommand - name: targetedFailPoint object: testRunner arguments: - session: session0 + session: *session0 failPoint: configureFailPoint: failCommand mode: {times: 1} @@ -654,25 +636,25 @@ tests: failCommands: ["distinct"] errorCode: 11601 - name: distinct - object: collection + object: *collection0 arguments: - session: session0 + session: *session0 fieldName: _id - result: + filter: {} + expectError: errorLabelsOmit: ["TransientTransactionError"] - *assertSessionPinned - *abortTransaction outcome: *outcome - description: remain pinned after non-transient Interrupted error on runCommand insert - useMultipleMongoses: true operations: - *startTransaction - *initialCommand - name: targetedFailPoint object: testRunner arguments: - session: session0 + session: *session0 failPoint: configureFailPoint: failCommand mode: {times: 1} @@ -680,29 +662,28 @@ tests: failCommands: ["insert"] errorCode: 11601 - name: runCommand - object: database - command_name: insert + object: *database0 arguments: - session: session0 + session: *session0 + commandName: insert command: insert: *collection_name documents: - - _id : 1 - result: + - { _id : 1 } + expectError: errorLabelsOmit: ["TransientTransactionError"] - *assertSessionPinned - *abortTransaction outcome: *outcome - description: unpin after transient connection error on insertOne insert - useMultipleMongoses: true operations: - *startTransaction - *initialCommand - name: targetedFailPoint object: testRunner arguments: - session: session0 + session: *session0 failPoint: configureFailPoint: failCommand mode: {times: 1} @@ -710,25 +691,24 @@ tests: failCommands: ["insert"] closeConnection: true - name: insertOne - object: collection + object: *collection0 arguments: - session: session0 - document: {_id: 4} - result: + session: *session0 + document: { _id: 4 } + expectError: errorLabelsContain: ["TransientTransactionError"] - *assertSessionUnpinned - *abortTransaction outcome: *outcome - description: unpin after transient ShutdownInProgress error on insertOne insert - useMultipleMongoses: true operations: - *startTransaction - *initialCommand - name: targetedFailPoint object: testRunner arguments: - session: session0 + session: *session0 failPoint: configureFailPoint: failCommand mode: {times: 1} @@ -736,25 +716,24 @@ tests: failCommands: ["insert"] errorCode: 91 - name: insertOne - object: collection + object: *collection0 arguments: - session: session0 - document: {_id: 4} - result: + session: *session0 + document: { _id: 4 } + expectError: errorLabelsContain: ["TransientTransactionError"] - *assertSessionUnpinned - *abortTransaction outcome: *outcome - description: unpin after transient connection error on insertMany insert - useMultipleMongoses: true operations: - *startTransaction - *initialCommand - name: targetedFailPoint object: testRunner arguments: - session: session0 + session: *session0 failPoint: configureFailPoint: failCommand mode: {times: 1} @@ -762,25 +741,24 @@ tests: failCommands: ["insert"] closeConnection: true - name: insertMany - object: collection + object: *collection0 arguments: - session: session0 - documents: [{_id: 4}, {_id: 5}] - result: + session: *session0 + documents: [ { _id: 4 }, { _id: 5 } ] + expectError: errorLabelsContain: ["TransientTransactionError"] - *assertSessionUnpinned - *abortTransaction outcome: *outcome - description: unpin after transient ShutdownInProgress error on insertMany insert - useMultipleMongoses: true operations: - *startTransaction - *initialCommand - name: targetedFailPoint object: testRunner arguments: - session: session0 + session: *session0 failPoint: configureFailPoint: failCommand mode: {times: 1} @@ -788,25 +766,24 @@ tests: failCommands: ["insert"] errorCode: 91 - name: insertMany - object: collection + object: *collection0 arguments: - session: session0 - documents: [{_id: 4}, {_id: 5}] - result: + session: *session0 + documents: [ { _id: 4 }, { _id: 5 } ] + expectError: errorLabelsContain: ["TransientTransactionError"] - *assertSessionUnpinned - *abortTransaction outcome: *outcome - description: unpin after transient connection error on updateOne update - useMultipleMongoses: true operations: - *startTransaction - *initialCommand - name: targetedFailPoint object: testRunner arguments: - session: session0 + session: *session0 failPoint: configureFailPoint: failCommand mode: {times: 1} @@ -814,26 +791,25 @@ tests: failCommands: ["update"] closeConnection: true - name: updateOne - object: collection + object: *collection0 arguments: - session: session0 - filter: {_id: 1} - update: {$inc: {x: 1}} - result: + session: *session0 + filter: { _id: 1 } + update: { $inc: { x: 1 } } + expectError: errorLabelsContain: ["TransientTransactionError"] - *assertSessionUnpinned - *abortTransaction outcome: *outcome - description: unpin after transient ShutdownInProgress error on updateOne update - useMultipleMongoses: true operations: - *startTransaction - *initialCommand - name: targetedFailPoint object: testRunner arguments: - session: session0 + session: *session0 failPoint: configureFailPoint: failCommand mode: {times: 1} @@ -841,26 +817,25 @@ tests: failCommands: ["update"] errorCode: 91 - name: updateOne - object: collection + object: *collection0 arguments: - session: session0 - filter: {_id: 1} - update: {$inc: {x: 1}} - result: + session: *session0 + filter: { _id: 1 } + update: { $inc: { x: 1 } } + expectError: errorLabelsContain: ["TransientTransactionError"] - *assertSessionUnpinned - *abortTransaction outcome: *outcome - description: unpin after transient connection error on replaceOne update - useMultipleMongoses: true operations: - *startTransaction - *initialCommand - name: targetedFailPoint object: testRunner arguments: - session: session0 + session: *session0 failPoint: configureFailPoint: failCommand mode: {times: 1} @@ -868,26 +843,25 @@ tests: failCommands: ["update"] closeConnection: true - name: replaceOne - object: collection + object: *collection0 arguments: - session: session0 - filter: {_id: 1} - replacement: {y: 1} - result: + session: *session0 + filter: { _id: 1 } + replacement: { y: 1 } + expectError: errorLabelsContain: ["TransientTransactionError"] - *assertSessionUnpinned - *abortTransaction outcome: *outcome - description: unpin after transient ShutdownInProgress error on replaceOne update - useMultipleMongoses: true operations: - *startTransaction - *initialCommand - name: targetedFailPoint object: testRunner arguments: - session: session0 + session: *session0 failPoint: configureFailPoint: failCommand mode: {times: 1} @@ -895,26 +869,25 @@ tests: failCommands: ["update"] errorCode: 91 - name: replaceOne - object: collection + object: *collection0 arguments: - session: session0 - filter: {_id: 1} - replacement: {y: 1} - result: + session: *session0 + filter: { _id: 1 } + replacement: { y: 1 } + expectError: errorLabelsContain: ["TransientTransactionError"] - *assertSessionUnpinned - *abortTransaction outcome: *outcome - description: unpin after transient connection error on updateMany update - useMultipleMongoses: true operations: - *startTransaction - *initialCommand - name: targetedFailPoint object: testRunner arguments: - session: session0 + session: *session0 failPoint: configureFailPoint: failCommand mode: {times: 1} @@ -922,26 +895,25 @@ tests: failCommands: ["update"] closeConnection: true - name: updateMany - object: collection + object: *collection0 arguments: - session: session0 - filter: {_id: {$gte: 1}} - update: {$set: {z: 1}} - result: + session: *session0 + filter: { _id: { $gte: 1 } } + update: {$set: { z: 1 } } + expectError: errorLabelsContain: ["TransientTransactionError"] - *assertSessionUnpinned - *abortTransaction outcome: *outcome - description: unpin after transient ShutdownInProgress error on updateMany update - useMultipleMongoses: true operations: - *startTransaction - *initialCommand - name: targetedFailPoint object: testRunner arguments: - session: session0 + session: *session0 failPoint: configureFailPoint: failCommand mode: {times: 1} @@ -949,26 +921,25 @@ tests: failCommands: ["update"] errorCode: 91 - name: updateMany - object: collection + object: *collection0 arguments: - session: session0 - filter: {_id: {$gte: 1}} - update: {$set: {z: 1}} - result: + session: *session0 + filter: { _id: { $gte: 1 } } + update: {$set: { z: 1 } } + expectError: errorLabelsContain: ["TransientTransactionError"] - *assertSessionUnpinned - *abortTransaction outcome: *outcome - description: unpin after transient connection error on deleteOne delete - useMultipleMongoses: true operations: - *startTransaction - *initialCommand - name: targetedFailPoint object: testRunner arguments: - session: session0 + session: *session0 failPoint: configureFailPoint: failCommand mode: {times: 1} @@ -976,25 +947,24 @@ tests: failCommands: ["delete"] closeConnection: true - name: deleteOne - object: collection + object: *collection0 arguments: - session: session0 - filter: {_id: 1} - result: + session: *session0 + filter: { _id: 1 } + expectError: errorLabelsContain: ["TransientTransactionError"] - *assertSessionUnpinned - *abortTransaction outcome: *outcome - description: unpin after transient ShutdownInProgress error on deleteOne delete - useMultipleMongoses: true operations: - *startTransaction - *initialCommand - name: targetedFailPoint object: testRunner arguments: - session: session0 + session: *session0 failPoint: configureFailPoint: failCommand mode: {times: 1} @@ -1002,25 +972,24 @@ tests: failCommands: ["delete"] errorCode: 91 - name: deleteOne - object: collection + object: *collection0 arguments: - session: session0 - filter: {_id: 1} - result: + session: *session0 + filter: { _id: 1 } + expectError: errorLabelsContain: ["TransientTransactionError"] - *assertSessionUnpinned - *abortTransaction outcome: *outcome - description: unpin after transient connection error on deleteMany delete - useMultipleMongoses: true operations: - *startTransaction - *initialCommand - name: targetedFailPoint object: testRunner arguments: - session: session0 + session: *session0 failPoint: configureFailPoint: failCommand mode: {times: 1} @@ -1028,25 +997,24 @@ tests: failCommands: ["delete"] closeConnection: true - name: deleteMany - object: collection + object: *collection0 arguments: - session: session0 - filter: {_id: {$gte: 1}} - result: + session: *session0 + filter: { _id: { $gte: 1 } } + expectError: errorLabelsContain: ["TransientTransactionError"] - *assertSessionUnpinned - *abortTransaction outcome: *outcome - description: unpin after transient ShutdownInProgress error on deleteMany delete - useMultipleMongoses: true operations: - *startTransaction - *initialCommand - name: targetedFailPoint object: testRunner arguments: - session: session0 + session: *session0 failPoint: configureFailPoint: failCommand mode: {times: 1} @@ -1054,25 +1022,24 @@ tests: failCommands: ["delete"] errorCode: 91 - name: deleteMany - object: collection + object: *collection0 arguments: - session: session0 - filter: {_id: {$gte: 1}} - result: + session: *session0 + filter: { _id: { $gte: 1 } } + expectError: errorLabelsContain: ["TransientTransactionError"] - *assertSessionUnpinned - *abortTransaction outcome: *outcome - description: unpin after transient connection error on findOneAndDelete findAndModify - useMultipleMongoses: true operations: - *startTransaction - *initialCommand - name: targetedFailPoint object: testRunner arguments: - session: session0 + session: *session0 failPoint: configureFailPoint: failCommand mode: {times: 1} @@ -1080,25 +1047,24 @@ tests: failCommands: ["findAndModify"] closeConnection: true - name: findOneAndDelete - object: collection + object: *collection0 arguments: - session: session0 - filter: {_id: 1} - result: + session: *session0 + filter: { _id: 1 } + expectError: errorLabelsContain: ["TransientTransactionError"] - *assertSessionUnpinned - *abortTransaction outcome: *outcome - description: unpin after transient ShutdownInProgress error on findOneAndDelete findAndModify - useMultipleMongoses: true operations: - *startTransaction - *initialCommand - name: targetedFailPoint object: testRunner arguments: - session: session0 + session: *session0 failPoint: configureFailPoint: failCommand mode: {times: 1} @@ -1106,25 +1072,24 @@ tests: failCommands: ["findAndModify"] errorCode: 91 - name: findOneAndDelete - object: collection + object: *collection0 arguments: - session: session0 - filter: {_id: 1} - result: + session: *session0 + filter: { _id: 1 } + expectError: errorLabelsContain: ["TransientTransactionError"] - *assertSessionUnpinned - *abortTransaction outcome: *outcome - description: unpin after transient connection error on findOneAndUpdate findAndModify - useMultipleMongoses: true operations: - *startTransaction - *initialCommand - name: targetedFailPoint object: testRunner arguments: - session: session0 + session: *session0 failPoint: configureFailPoint: failCommand mode: {times: 1} @@ -1132,27 +1097,26 @@ tests: failCommands: ["findAndModify"] closeConnection: true - name: findOneAndUpdate - object: collection + object: *collection0 arguments: - session: session0 - filter: {_id: 1} - update: {$inc: {x: 1}} + session: *session0 + filter: { _id: 1 } + update: { $inc: { x: 1 } } returnDocument: Before - result: + expectError: errorLabelsContain: ["TransientTransactionError"] - *assertSessionUnpinned - *abortTransaction outcome: *outcome - description: unpin after transient ShutdownInProgress error on findOneAndUpdate findAndModify - useMultipleMongoses: true operations: - *startTransaction - *initialCommand - name: targetedFailPoint object: testRunner arguments: - session: session0 + session: *session0 failPoint: configureFailPoint: failCommand mode: {times: 1} @@ -1160,27 +1124,26 @@ tests: failCommands: ["findAndModify"] errorCode: 91 - name: findOneAndUpdate - object: collection + object: *collection0 arguments: - session: session0 - filter: {_id: 1} - update: {$inc: {x: 1}} + session: *session0 + filter: { _id: 1 } + update: { $inc: { x: 1 } } returnDocument: Before - result: + expectError: errorLabelsContain: ["TransientTransactionError"] - *assertSessionUnpinned - *abortTransaction outcome: *outcome - description: unpin after transient connection error on findOneAndReplace findAndModify - useMultipleMongoses: true operations: - *startTransaction - *initialCommand - name: targetedFailPoint object: testRunner arguments: - session: session0 + session: *session0 failPoint: configureFailPoint: failCommand mode: {times: 1} @@ -1188,27 +1151,26 @@ tests: failCommands: ["findAndModify"] closeConnection: true - name: findOneAndReplace - object: collection + object: *collection0 arguments: - session: session0 - filter: {_id: 1} - replacement: {y: 1} + session: *session0 + filter: { _id: 1 } + replacement: { y: 1 } returnDocument: Before - result: + expectError: errorLabelsContain: ["TransientTransactionError"] - *assertSessionUnpinned - *abortTransaction outcome: *outcome - description: unpin after transient ShutdownInProgress error on findOneAndReplace findAndModify - useMultipleMongoses: true operations: - *startTransaction - *initialCommand - name: targetedFailPoint object: testRunner arguments: - session: session0 + session: *session0 failPoint: configureFailPoint: failCommand mode: {times: 1} @@ -1216,27 +1178,26 @@ tests: failCommands: ["findAndModify"] errorCode: 91 - name: findOneAndReplace - object: collection + object: *collection0 arguments: - session: session0 - filter: {_id: 1} - replacement: {y: 1} + session: *session0 + filter: { _id: 1 } + replacement: { y: 1 } returnDocument: Before - result: + expectError: errorLabelsContain: ["TransientTransactionError"] - *assertSessionUnpinned - *abortTransaction outcome: *outcome - description: unpin after transient connection error on bulkWrite insert - useMultipleMongoses: true operations: - *startTransaction - *initialCommand - name: targetedFailPoint object: testRunner arguments: - session: session0 + session: *session0 failPoint: configureFailPoint: failCommand mode: {times: 1} @@ -1244,28 +1205,26 @@ tests: failCommands: ["insert"] closeConnection: true - name: bulkWrite - object: collection + object: *collection0 arguments: - session: session0 + session: *session0 requests: - - name: insertOne - arguments: - document: {_id: 1} - result: + - insertOne: + document: { _id: 1 } + expectError: errorLabelsContain: ["TransientTransactionError"] - *assertSessionUnpinned - *abortTransaction outcome: *outcome - description: unpin after transient ShutdownInProgress error on bulkWrite insert - useMultipleMongoses: true operations: - *startTransaction - *initialCommand - name: targetedFailPoint object: testRunner arguments: - session: session0 + session: *session0 failPoint: configureFailPoint: failCommand mode: {times: 1} @@ -1273,28 +1232,26 @@ tests: failCommands: ["insert"] errorCode: 91 - name: bulkWrite - object: collection + object: *collection0 arguments: - session: session0 + session: *session0 requests: - - name: insertOne - arguments: - document: {_id: 1} - result: + - insertOne: + document: { _id: 1 } + expectError: errorLabelsContain: ["TransientTransactionError"] - *assertSessionUnpinned - *abortTransaction outcome: *outcome - description: unpin after transient connection error on bulkWrite update - useMultipleMongoses: true operations: - *startTransaction - *initialCommand - name: targetedFailPoint object: testRunner arguments: - session: session0 + session: *session0 failPoint: configureFailPoint: failCommand mode: {times: 1} @@ -1302,29 +1259,27 @@ tests: failCommands: ["update"] closeConnection: true - name: bulkWrite - object: collection + object: *collection0 arguments: - session: session0 + session: *session0 requests: - - name: updateOne - arguments: - filter: {_id: 1} - update: {$set: {x: 1}} - result: + - updateOne: + filter: { _id: 1 } + update: { $set: { x: 1 } } + expectError: errorLabelsContain: ["TransientTransactionError"] - *assertSessionUnpinned - *abortTransaction outcome: *outcome - description: unpin after transient ShutdownInProgress error on bulkWrite update - useMultipleMongoses: true operations: - *startTransaction - *initialCommand - name: targetedFailPoint object: testRunner arguments: - session: session0 + session: *session0 failPoint: configureFailPoint: failCommand mode: {times: 1} @@ -1332,29 +1287,27 @@ tests: failCommands: ["update"] errorCode: 91 - name: bulkWrite - object: collection + object: *collection0 arguments: - session: session0 + session: *session0 requests: - - name: updateOne - arguments: - filter: {_id: 1} - update: {$set: {x: 1}} - result: + - updateOne: + filter: { _id: 1 } + update: { $set: { x: 1 } } + expectError: errorLabelsContain: ["TransientTransactionError"] - *assertSessionUnpinned - *abortTransaction outcome: *outcome - description: unpin after transient connection error on bulkWrite delete - useMultipleMongoses: true operations: - *startTransaction - *initialCommand - name: targetedFailPoint object: testRunner arguments: - session: session0 + session: *session0 failPoint: configureFailPoint: failCommand mode: {times: 1} @@ -1362,28 +1315,26 @@ tests: failCommands: ["delete"] closeConnection: true - name: bulkWrite - object: collection + object: *collection0 arguments: - session: session0 + session: *session0 requests: - - name: deleteOne - arguments: - filter: {_id: 1} - result: + - deleteOne: + filter: { _id: 1 } + expectError: errorLabelsContain: ["TransientTransactionError"] - *assertSessionUnpinned - *abortTransaction outcome: *outcome - description: unpin after transient ShutdownInProgress error on bulkWrite delete - useMultipleMongoses: true operations: - *startTransaction - *initialCommand - name: targetedFailPoint object: testRunner arguments: - session: session0 + session: *session0 failPoint: configureFailPoint: failCommand mode: {times: 1} @@ -1391,28 +1342,26 @@ tests: failCommands: ["delete"] errorCode: 91 - name: bulkWrite - object: collection + object: *collection0 arguments: - session: session0 + session: *session0 requests: - - name: deleteOne - arguments: - filter: {_id: 1} - result: + - deleteOne: + filter: { _id: 1 } + expectError: errorLabelsContain: ["TransientTransactionError"] - *assertSessionUnpinned - *abortTransaction outcome: *outcome - description: unpin after transient connection error on find find - useMultipleMongoses: true operations: - *startTransaction - *initialCommand - name: targetedFailPoint object: testRunner arguments: - session: session0 + session: *session0 failPoint: configureFailPoint: failCommand mode: {times: 1} @@ -1420,25 +1369,24 @@ tests: failCommands: ["find"] closeConnection: true - name: find - object: collection + object: *collection0 arguments: - session: session0 - filter: {_id: 1} - result: + session: *session0 + filter: { _id: 1 } + expectError: errorLabelsContain: ["TransientTransactionError"] - *assertSessionUnpinned - *abortTransaction outcome: *outcome - description: unpin after transient ShutdownInProgress error on find find - useMultipleMongoses: true operations: - *startTransaction - *initialCommand - name: targetedFailPoint object: testRunner arguments: - session: session0 + session: *session0 failPoint: configureFailPoint: failCommand mode: {times: 1} @@ -1446,25 +1394,24 @@ tests: failCommands: ["find"] errorCode: 91 - name: find - object: collection + object: *collection0 arguments: - session: session0 - filter: {_id: 1} - result: + session: *session0 + filter: { _id: 1 } + expectError: errorLabelsContain: ["TransientTransactionError"] - *assertSessionUnpinned - *abortTransaction outcome: *outcome - description: unpin after transient connection error on countDocuments aggregate - useMultipleMongoses: true operations: - *startTransaction - *initialCommand - name: targetedFailPoint object: testRunner arguments: - session: session0 + session: *session0 failPoint: configureFailPoint: failCommand mode: {times: 1} @@ -1472,25 +1419,24 @@ tests: failCommands: ["aggregate"] closeConnection: true - name: countDocuments - object: collection + object: *collection0 arguments: - session: session0 + session: *session0 filter: {} - result: + expectError: errorLabelsContain: ["TransientTransactionError"] - *assertSessionUnpinned - *abortTransaction outcome: *outcome - description: unpin after transient ShutdownInProgress error on countDocuments aggregate - useMultipleMongoses: true operations: - *startTransaction - *initialCommand - name: targetedFailPoint object: testRunner arguments: - session: session0 + session: *session0 failPoint: configureFailPoint: failCommand mode: {times: 1} @@ -1498,25 +1444,24 @@ tests: failCommands: ["aggregate"] errorCode: 91 - name: countDocuments - object: collection + object: *collection0 arguments: - session: session0 + session: *session0 filter: {} - result: + expectError: errorLabelsContain: ["TransientTransactionError"] - *assertSessionUnpinned - *abortTransaction outcome: *outcome - description: unpin after transient connection error on aggregate aggregate - useMultipleMongoses: true operations: - *startTransaction - *initialCommand - name: targetedFailPoint object: testRunner arguments: - session: session0 + session: *session0 failPoint: configureFailPoint: failCommand mode: {times: 1} @@ -1524,25 +1469,24 @@ tests: failCommands: ["aggregate"] closeConnection: true - name: aggregate - object: collection + object: *collection0 arguments: - session: session0 + session: *session0 pipeline: [] - result: + expectError: errorLabelsContain: ["TransientTransactionError"] - *assertSessionUnpinned - *abortTransaction outcome: *outcome - description: unpin after transient ShutdownInProgress error on aggregate aggregate - useMultipleMongoses: true operations: - *startTransaction - *initialCommand - name: targetedFailPoint object: testRunner arguments: - session: session0 + session: *session0 failPoint: configureFailPoint: failCommand mode: {times: 1} @@ -1550,25 +1494,24 @@ tests: failCommands: ["aggregate"] errorCode: 91 - name: aggregate - object: collection + object: *collection0 arguments: - session: session0 + session: *session0 pipeline: [] - result: + expectError: errorLabelsContain: ["TransientTransactionError"] - *assertSessionUnpinned - *abortTransaction outcome: *outcome - description: unpin after transient connection error on distinct distinct - useMultipleMongoses: true operations: - *startTransaction - *initialCommand - name: targetedFailPoint object: testRunner arguments: - session: session0 + session: *session0 failPoint: configureFailPoint: failCommand mode: {times: 1} @@ -1576,25 +1519,25 @@ tests: failCommands: ["distinct"] closeConnection: true - name: distinct - object: collection + object: *collection0 arguments: - session: session0 + session: *session0 fieldName: _id - result: + filter: {} + expectError: errorLabelsContain: ["TransientTransactionError"] - *assertSessionUnpinned - *abortTransaction outcome: *outcome - description: unpin after transient ShutdownInProgress error on distinct distinct - useMultipleMongoses: true operations: - *startTransaction - *initialCommand - name: targetedFailPoint object: testRunner arguments: - session: session0 + session: *session0 failPoint: configureFailPoint: failCommand mode: {times: 1} @@ -1602,25 +1545,25 @@ tests: failCommands: ["distinct"] errorCode: 91 - name: distinct - object: collection + object: *collection0 arguments: - session: session0 + session: *session0 fieldName: _id - result: + filter: {} + expectError: errorLabelsContain: ["TransientTransactionError"] - *assertSessionUnpinned - *abortTransaction outcome: *outcome - description: unpin after transient connection error on runCommand insert - useMultipleMongoses: true operations: - *startTransaction - *initialCommand - name: targetedFailPoint object: testRunner arguments: - session: session0 + session: *session0 failPoint: configureFailPoint: failCommand mode: {times: 1} @@ -1628,29 +1571,28 @@ tests: failCommands: ["insert"] closeConnection: true - name: runCommand - object: database - command_name: insert + object: *database0 arguments: - session: session0 + session: *session0 + commandName: insert command: insert: *collection_name documents: - - _id : 1 - result: + - { _id : 1 } + expectError: errorLabelsContain: ["TransientTransactionError"] - *assertSessionUnpinned - *abortTransaction outcome: *outcome - description: unpin after transient ShutdownInProgress error on runCommand insert - useMultipleMongoses: true operations: - *startTransaction - *initialCommand - name: targetedFailPoint object: testRunner arguments: - session: session0 + session: *session0 failPoint: configureFailPoint: failCommand mode: {times: 1} @@ -1658,15 +1600,15 @@ tests: failCommands: ["insert"] errorCode: 91 - name: runCommand - object: database - command_name: insert + object: *database0 arguments: - session: session0 + session: *session0 + commandName: insert command: insert: *collection_name documents: - - _id : 1 - result: + - { _id : 1 } + expectError: errorLabelsContain: ["TransientTransactionError"] - *assertSessionUnpinned - *abortTransaction diff --git a/source/transactions/tests/unified/mongos-recovery-token-errorLabels.json b/source/transactions/tests/unified/mongos-recovery-token-errorLabels.json new file mode 100644 index 0000000000..13345c6a29 --- /dev/null +++ b/source/transactions/tests/unified/mongos-recovery-token-errorLabels.json @@ -0,0 +1,211 @@ +{ + "description": "mongos-recovery-token-errorLabels", + "schemaVersion": "1.4", + "runOnRequirements": [ + { + "minServerVersion": "4.3.1", + "serverless": "forbid", + "topologies": [ + "sharded" + ] + } + ], + "createEntities": [ + { + "client": { + "id": "client0", + "useMultipleMongoses": true, + "observeEvents": [ + "commandStartedEvent" + ] + } + }, + { + "database": { + "id": "database0", + "client": "client0", + "databaseName": "transaction-tests" + } + }, + { + "collection": { + "id": "collection0", + "database": "database0", + "collectionName": "test" + } + }, + { + "session": { + "id": "session0", + "client": "client0" + } + } + ], + "initialData": [ + { + "collectionName": "test", + "databaseName": "transaction-tests", + "documents": [] + } + ], + "tests": [ + { + "description": "commitTransaction retry succeeds on new mongos", + "operations": [ + { + "object": "session0", + "name": "startTransaction", + "arguments": { + "writeConcern": { + "w": "majority" + } + } + }, + { + "object": "collection0", + "name": "insertOne", + "arguments": { + "session": "session0", + "document": { + "_id": 1 + } + }, + "expectResult": { + "$$unsetOrMatches": { + "insertedId": { + "$$unsetOrMatches": 1 + } + } + } + }, + { + "object": "testRunner", + "name": "targetedFailPoint", + "arguments": { + "session": "session0", + "failPoint": { + "configureFailPoint": "failCommand", + "mode": { + "times": 1 + }, + "data": { + "failCommands": [ + "commitTransaction" + ], + "errorLabels": [ + "RetryableWriteError" + ], + "writeConcernError": { + "code": 91, + "errmsg": "Replication is being shut down" + } + } + } + } + }, + { + "object": "session0", + "name": "commitTransaction" + } + ], + "expectEvents": [ + { + "client": "client0", + "events": [ + { + "commandStartedEvent": { + "command": { + "insert": "test", + "documents": [ + { + "_id": 1 + } + ], + "ordered": true, + "readConcern": { + "$$exists": false + }, + "lsid": { + "$$sessionLsid": "session0" + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": true, + "autocommit": false, + "writeConcern": { + "$$exists": false + } + }, + "commandName": "insert", + "databaseName": "transaction-tests" + } + }, + { + "commandStartedEvent": { + "command": { + "commitTransaction": 1, + "lsid": { + "$$sessionLsid": "session0" + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": { + "$$exists": false + }, + "autocommit": false, + "writeConcern": { + "w": "majority" + }, + "recoveryToken": { + "$$exists": true + } + }, + "commandName": "commitTransaction", + "databaseName": "admin" + } + }, + { + "commandStartedEvent": { + "command": { + "commitTransaction": 1, + "lsid": { + "$$sessionLsid": "session0" + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": { + "$$exists": false + }, + "autocommit": false, + "writeConcern": { + "w": "majority", + "wtimeout": 10000 + }, + "recoveryToken": { + "$$exists": true + } + }, + "commandName": "commitTransaction", + "databaseName": "admin" + } + } + ] + } + ], + "outcome": [ + { + "collectionName": "test", + "databaseName": "transaction-tests", + "documents": [ + { + "_id": 1 + } + ] + } + ] + } + ] +} diff --git a/source/transactions/tests/unified/mongos-recovery-token-errorLabels.yml b/source/transactions/tests/unified/mongos-recovery-token-errorLabels.yml new file mode 100644 index 0000000000..e93c89b6d6 --- /dev/null +++ b/source/transactions/tests/unified/mongos-recovery-token-errorLabels.yml @@ -0,0 +1,136 @@ +description: mongos-recovery-token-errorLabels + +schemaVersion: '1.4' + +runOnRequirements: + - + minServerVersion: 4.3.1 # failCommand errorLabels option + # serverless proxy doesn't use recovery tokens + serverless: forbid + # Note: test utilizes targetedFailPoint, which is incompatible with + # load-balanced and useMultipleMongoses:true + topologies: [ sharded ] + +createEntities: + - + client: + id: &client0 client0 + useMultipleMongoses: true + observeEvents: + - commandStartedEvent + - + database: + id: &database0 database0 + client: *client0 + databaseName: &database_name transaction-tests + - + collection: + id: &collection0 collection0 + database: *database0 + collectionName: &collection_name test + - + session: + id: &session0 session0 + client: *client0 + +initialData: + - + collectionName: *collection_name + databaseName: *database_name + documents: [] + +tests: + - + description: 'commitTransaction retry succeeds on new mongos' + operations: + - + object: *session0 + name: startTransaction + arguments: + writeConcern: + w: majority + - + object: *collection0 + name: insertOne + arguments: + session: *session0 + document: { _id: 1 } + expectResult: + $$unsetOrMatches: { insertedId: { $$unsetOrMatches: 1 } } + # Enable the fail point only on the mongos that session0 is pinned to + - + object: testRunner + name: targetedFailPoint + arguments: + session: *session0 + failPoint: + configureFailPoint: failCommand + mode: { times: 1 } + data: + failCommands: + - commitTransaction + errorLabels: + - RetryableWriteError + writeConcernError: + code: 91 + errmsg: 'Replication is being shut down' + # The client sees a retryable writeConcernError on the first + # commitTransaction due to the fail point but it actually succeeds on the + # server (SERVER-39346). The retry will succeed both on a new mongos and + # on the original. + - + object: *session0 + name: commitTransaction + expectEvents: + - + client: *client0 + events: + - + commandStartedEvent: + command: + insert: *collection_name + documents: + - { _id: 1 } + ordered: true + readConcern: { $$exists: false } + lsid: { $$sessionLsid: *session0 } + txnNumber: { $numberLong: '1' } + startTransaction: true + autocommit: false + writeConcern: { $$exists: false } + commandName: insert + databaseName: *database_name + - + commandStartedEvent: + command: + commitTransaction: 1 + lsid: { $$sessionLsid: *session0 } + txnNumber: { $numberLong: '1' } + startTransaction: { $$exists: false } + autocommit: false + writeConcern: + w: majority + recoveryToken: { $$exists: true } + commandName: commitTransaction + databaseName: admin + - + commandStartedEvent: + command: + commitTransaction: 1 + lsid: { $$sessionLsid: *session0 } + txnNumber: { $numberLong: '1' } + startTransaction: { $$exists: false } + autocommit: false + # commitTransaction applies w:majority on retries + writeConcern: + w: majority + wtimeout: 10000 + recoveryToken: { $$exists: true } + commandName: commitTransaction + databaseName: admin + outcome: + - + collectionName: *collection_name + databaseName: *database_name + documents: + - { _id: 1 } diff --git a/source/transactions/tests/unified/mongos-recovery-token.json b/source/transactions/tests/unified/mongos-recovery-token.json new file mode 100644 index 0000000000..00909c4218 --- /dev/null +++ b/source/transactions/tests/unified/mongos-recovery-token.json @@ -0,0 +1,566 @@ +{ + "description": "mongos-recovery-token", + "schemaVersion": "1.9", + "runOnRequirements": [ + { + "minServerVersion": "4.1.8", + "serverless": "forbid", + "topologies": [ + "sharded", + "load-balanced" + ] + } + ], + "createEntities": [ + { + "client": { + "id": "client0", + "useMultipleMongoses": true, + "observeEvents": [ + "commandStartedEvent" + ] + } + }, + { + "database": { + "id": "database0", + "client": "client0", + "databaseName": "transaction-tests" + } + }, + { + "collection": { + "id": "collection0", + "database": "database0", + "collectionName": "test" + } + }, + { + "session": { + "id": "session0", + "client": "client0" + } + } + ], + "initialData": [ + { + "collectionName": "test", + "databaseName": "transaction-tests", + "documents": [] + } + ], + "tests": [ + { + "description": "commitTransaction explicit retries include recoveryToken", + "operations": [ + { + "object": "session0", + "name": "startTransaction" + }, + { + "object": "collection0", + "name": "insertOne", + "arguments": { + "session": "session0", + "document": { + "_id": 1 + } + }, + "expectResult": { + "$$unsetOrMatches": { + "insertedId": { + "$$unsetOrMatches": 1 + } + } + } + }, + { + "object": "session0", + "name": "commitTransaction" + }, + { + "object": "session0", + "name": "commitTransaction" + }, + { + "object": "session0", + "name": "commitTransaction" + } + ], + "expectEvents": [ + { + "client": "client0", + "events": [ + { + "commandStartedEvent": { + "command": { + "insert": "test", + "documents": [ + { + "_id": 1 + } + ], + "ordered": true, + "readConcern": { + "$$exists": false + }, + "lsid": { + "$$sessionLsid": "session0" + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": true, + "autocommit": false, + "writeConcern": { + "$$exists": false + } + }, + "commandName": "insert", + "databaseName": "transaction-tests" + } + }, + { + "commandStartedEvent": { + "command": { + "commitTransaction": 1, + "lsid": { + "$$sessionLsid": "session0" + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": { + "$$exists": false + }, + "autocommit": false, + "writeConcern": { + "$$exists": false + }, + "recoveryToken": { + "$$exists": true + } + }, + "commandName": "commitTransaction", + "databaseName": "admin" + } + }, + { + "commandStartedEvent": { + "command": { + "commitTransaction": 1, + "lsid": { + "$$sessionLsid": "session0" + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": { + "$$exists": false + }, + "autocommit": false, + "writeConcern": { + "w": "majority", + "wtimeout": 10000 + }, + "recoveryToken": { + "$$exists": true + } + }, + "commandName": "commitTransaction", + "databaseName": "admin" + } + }, + { + "commandStartedEvent": { + "command": { + "commitTransaction": 1, + "lsid": { + "$$sessionLsid": "session0" + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": { + "$$exists": false + }, + "autocommit": false, + "writeConcern": { + "w": "majority", + "wtimeout": 10000 + }, + "recoveryToken": { + "$$exists": true + } + }, + "commandName": "commitTransaction", + "databaseName": "admin" + } + } + ] + } + ], + "outcome": [ + { + "collectionName": "test", + "databaseName": "transaction-tests", + "documents": [ + { + "_id": 1 + } + ] + } + ] + }, + { + "description": "commitTransaction retry fails on new mongos", + "runOnRequirements": [ + { + "topologies": [ + "sharded" + ] + } + ], + "operations": [ + { + "object": "testRunner", + "name": "createEntities", + "arguments": { + "entities": [ + { + "client": { + "id": "client1", + "useMultipleMongoses": true, + "uriOptions": { + "heartbeatFrequencyMS": 30000 + }, + "observeEvents": [ + "commandStartedEvent" + ] + } + }, + { + "database": { + "id": "database1", + "client": "client1", + "databaseName": "transaction-tests" + } + }, + { + "collection": { + "id": "collection1", + "database": "database1", + "collectionName": "test" + } + }, + { + "session": { + "id": "session1", + "client": "client1" + } + } + ] + } + }, + { + "object": "session1", + "name": "startTransaction" + }, + { + "object": "collection1", + "name": "insertOne", + "arguments": { + "session": "session1", + "document": { + "_id": 1 + } + }, + "expectResult": { + "$$unsetOrMatches": { + "insertedId": { + "$$unsetOrMatches": 1 + } + } + } + }, + { + "object": "testRunner", + "name": "targetedFailPoint", + "arguments": { + "session": "session1", + "failPoint": { + "configureFailPoint": "failCommand", + "mode": { + "times": 7 + }, + "data": { + "failCommands": [ + "commitTransaction", + "isMaster", + "hello" + ], + "closeConnection": true + } + } + } + }, + { + "object": "session1", + "name": "commitTransaction", + "expectError": { + "errorLabelsContain": [ + "TransientTransactionError" + ], + "errorLabelsOmit": [ + "UnknownTransactionCommitResult" + ], + "errorCodeName": "NoSuchTransaction" + } + } + ], + "expectEvents": [ + { + "client": "client1", + "events": [ + { + "commandStartedEvent": { + "command": { + "insert": "test", + "documents": [ + { + "_id": 1 + } + ], + "ordered": true, + "readConcern": { + "$$exists": false + }, + "lsid": { + "$$sessionLsid": "session1" + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": true, + "autocommit": false, + "writeConcern": { + "$$exists": false + } + }, + "commandName": "insert", + "databaseName": "transaction-tests" + } + }, + { + "commandStartedEvent": { + "command": { + "commitTransaction": 1, + "lsid": { + "$$sessionLsid": "session1" + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": { + "$$exists": false + }, + "autocommit": false, + "writeConcern": { + "$$exists": false + }, + "recoveryToken": { + "$$exists": true + } + }, + "commandName": "commitTransaction", + "databaseName": "admin" + } + }, + { + "commandStartedEvent": { + "command": { + "commitTransaction": 1, + "lsid": { + "$$sessionLsid": "session1" + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": { + "$$exists": false + }, + "autocommit": false, + "writeConcern": { + "w": "majority", + "wtimeout": 10000 + }, + "recoveryToken": { + "$$exists": true + } + }, + "commandName": "commitTransaction", + "databaseName": "admin" + } + } + ] + } + ], + "outcome": [ + { + "collectionName": "test", + "databaseName": "transaction-tests", + "documents": [] + } + ] + }, + { + "description": "abortTransaction sends recoveryToken", + "runOnRequirements": [ + { + "topologies": [ + "sharded" + ] + } + ], + "operations": [ + { + "object": "session0", + "name": "startTransaction" + }, + { + "object": "collection0", + "name": "insertOne", + "arguments": { + "session": "session0", + "document": { + "_id": 1 + } + }, + "expectResult": { + "$$unsetOrMatches": { + "insertedId": { + "$$unsetOrMatches": 1 + } + } + } + }, + { + "object": "testRunner", + "name": "targetedFailPoint", + "arguments": { + "session": "session0", + "failPoint": { + "configureFailPoint": "failCommand", + "mode": { + "times": 1 + }, + "data": { + "failCommands": [ + "abortTransaction" + ], + "closeConnection": true + } + } + } + }, + { + "object": "session0", + "name": "abortTransaction" + } + ], + "expectEvents": [ + { + "client": "client0", + "events": [ + { + "commandStartedEvent": { + "command": { + "insert": "test", + "documents": [ + { + "_id": 1 + } + ], + "ordered": true, + "readConcern": { + "$$exists": false + }, + "lsid": { + "$$sessionLsid": "session0" + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": true, + "autocommit": false, + "writeConcern": { + "$$exists": false + } + }, + "commandName": "insert", + "databaseName": "transaction-tests" + } + }, + { + "commandStartedEvent": { + "command": { + "abortTransaction": 1, + "lsid": { + "$$sessionLsid": "session0" + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": { + "$$exists": false + }, + "autocommit": false, + "writeConcern": { + "$$exists": false + }, + "recoveryToken": { + "$$exists": true + } + }, + "commandName": "abortTransaction", + "databaseName": "admin" + } + }, + { + "commandStartedEvent": { + "command": { + "abortTransaction": 1, + "lsid": { + "$$sessionLsid": "session0" + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": { + "$$exists": false + }, + "autocommit": false, + "writeConcern": { + "$$exists": false + }, + "recoveryToken": { + "$$exists": true + } + }, + "commandName": "abortTransaction", + "databaseName": "admin" + } + } + ] + } + ], + "outcome": [ + { + "collectionName": "test", + "databaseName": "transaction-tests", + "documents": [] + } + ] + } + ] +} diff --git a/source/transactions/tests/unified/mongos-recovery-token.yml b/source/transactions/tests/unified/mongos-recovery-token.yml new file mode 100644 index 0000000000..f8606f0782 --- /dev/null +++ b/source/transactions/tests/unified/mongos-recovery-token.yml @@ -0,0 +1,351 @@ +description: mongos-recovery-token + +schemaVersion: '1.9' + +runOnRequirements: + - + minServerVersion: 4.1.8 + # serverless proxy doesn't use recovery tokens + serverless: forbid + topologies: + - sharded + - load-balanced + +createEntities: + - + client: + id: &client0 client0 + useMultipleMongoses: true + observeEvents: + - commandStartedEvent + - + database: + id: &database0 database0 + client: *client0 + databaseName: &database_name transaction-tests + - + collection: + id: &collection0 collection0 + database: *database0 + collectionName: &collection_name test + - + session: + id: &session0 session0 + client: *client0 + +initialData: + - + collectionName: *collection_name + databaseName: *database_name + documents: [] + +tests: + - + description: 'commitTransaction explicit retries include recoveryToken' + operations: + - + object: *session0 + name: startTransaction + - + object: *collection0 + name: insertOne + arguments: + session: *session0 + document: { _id: 1 } + expectResult: + $$unsetOrMatches: { insertedId: { $$unsetOrMatches: 1 } } + - + object: *session0 + name: commitTransaction + - + object: *session0 + name: commitTransaction + - + object: *session0 + name: commitTransaction + expectEvents: + - + client: *client0 + events: + - + commandStartedEvent: + command: + insert: *collection_name + documents: + - { _id: 1 } + ordered: true + readConcern: { $$exists: false } + lsid: { $$sessionLsid: *session0 } + txnNumber: { $numberLong: '1' } + startTransaction: true + autocommit: false + writeConcern: { $$exists: false } + commandName: insert + databaseName: *database_name + - + commandStartedEvent: + command: + commitTransaction: 1 + lsid: { $$sessionLsid: *session0 } + txnNumber: { $numberLong: '1' } + startTransaction: { $$exists: false } + autocommit: false + writeConcern: { $$exists: false } + recoveryToken: { $$exists: true } + commandName: commitTransaction + databaseName: admin + - + commandStartedEvent: + command: + commitTransaction: 1 + lsid: { $$sessionLsid: *session0 } + txnNumber: { $numberLong: '1' } + startTransaction: { $$exists: false } + autocommit: false + # commitTransaction applies w:majority on retries + writeConcern: + w: majority + wtimeout: 10000 + recoveryToken: { $$exists: true } + commandName: commitTransaction + databaseName: admin + - + commandStartedEvent: + command: + commitTransaction: 1 + lsid: { $$sessionLsid: *session0 } + txnNumber: { $numberLong: '1' } + startTransaction: { $$exists: false } + autocommit: false + # commitTransaction applies w:majority on retries + writeConcern: + w: majority + wtimeout: 10000 + recoveryToken: { $$exists: true } + commandName: commitTransaction + databaseName: admin + outcome: + - + collectionName: *collection_name + databaseName: *database_name + documents: + - { _id: 1 } + - + description: 'commitTransaction retry fails on new mongos' + # Note: test utilizes targetedFailPoint, which is incompatible with + # load-balanced and useMultipleMongoses:true + runOnRequirements: + - topologies: [ sharded ] + operations: + - + object: testRunner + name: createEntities + arguments: + entities: + - client: + id: &client1 client1 + useMultipleMongoses: true + uriOptions: + # Increase heartbeatFrequencyMS to avoid the race condition where an in + # flight heartbeat refreshes the first mongoes' SDAM state in between + # the initial commitTransaction and the retry attempt. + heartbeatFrequencyMS: 30000 + observeEvents: + - commandStartedEvent + - database: + id: &database1 database1 + client: *client1 + databaseName: *database_name + - collection: + id: &collection1 collection1 + database: *database1 + collectionName: *collection_name + - session: + id: &session1 session1 + client: *client1 + - + object: *session1 + name: startTransaction + - + object: *collection1 + name: insertOne + arguments: + session: *session1 + document: { _id: 1 } + expectResult: + $$unsetOrMatches: { insertedId: { $$unsetOrMatches: 1 } } + # Enable the fail point only on the Mongos that session0 is pinned to. + # Fail hello/legacy hello to prevent the heartbeat requested directly after the + # retryable commit error from racing with server selection for the retry. + # Note: times: 7 is slightly artbitrary but it accounts for one failed + # commit and some SDAM heartbeats. A test runner will have multiple + # clients connected to this server so this fail point configuration + # is also racy. + - + object: testRunner + name: targetedFailPoint + arguments: + session: *session1 + failPoint: + configureFailPoint: failCommand + mode: { times: 7 } + data: + failCommands: + - commitTransaction + - isMaster + - hello + closeConnection: true + # The first commitTransaction sees a retryable connection error due to + # the fail point and also fails on the server. The retry attempt on a + # new mongos will wait for the transaction to timeout and will fail + # because the transaction was aborted. Note that the retry attempt should + # not select the original mongos because that server's SDAM state is + # reset by the connection error, heartbeatFrequencyMS is high, and + # subsequent heartbeats should fail. + - + object: *session1 + name: commitTransaction + expectError: + errorLabelsContain: + - TransientTransactionError + errorLabelsOmit: + - UnknownTransactionCommitResult + errorCodeName: NoSuchTransaction + expectEvents: + - + client: *client1 + events: + - + commandStartedEvent: + command: + insert: *collection_name + documents: + - { _id: 1 } + ordered: true + readConcern: { $$exists: false } + lsid: { $$sessionLsid: *session1 } + txnNumber: { $numberLong: '1' } + startTransaction: true + autocommit: false + writeConcern: { $$exists: false } + commandName: insert + databaseName: *database_name + - + commandStartedEvent: + command: + commitTransaction: 1 + lsid: { $$sessionLsid: *session1 } + txnNumber: { $numberLong: '1' } + startTransaction: { $$exists: false } + autocommit: false + writeConcern: { $$exists: false } + recoveryToken: { $$exists: true } + commandName: commitTransaction + databaseName: admin + - + commandStartedEvent: + command: + commitTransaction: 1 + lsid: { $$sessionLsid: *session1 } + txnNumber: { $numberLong: '1' } + startTransaction: { $$exists: false } + autocommit: false + # commitTransaction applies w:majority on retries + writeConcern: + w: majority + wtimeout: 10000 + recoveryToken: { $$exists: true } + commandName: commitTransaction + databaseName: admin + outcome: + - + collectionName: *collection_name + databaseName: *database_name + documents: [] + - + description: 'abortTransaction sends recoveryToken' + # Note: test utilizes targetedFailPoint, which is incompatible with + # load-balanced and useMultipleMongoses:true + runOnRequirements: + - topologies: [ sharded ] + operations: + - + object: *session0 + name: startTransaction + - + object: *collection0 + name: insertOne + arguments: + session: *session0 + document: { _id: 1 } + expectResult: + $$unsetOrMatches: { insertedId: { $$unsetOrMatches: 1 } } + # Enable the fail point only on the mongos that session0 is pinned to + - + object: testRunner + name: targetedFailPoint + arguments: + session: *session0 + failPoint: + configureFailPoint: failCommand + mode: { times: 1 } + data: + failCommands: + - abortTransaction + closeConnection: true + # The first abortTransaction sees a retryable connection error due to + # the fail point. The retry attempt on a new mongos will send the + # recoveryToken. Note that the retry attempt will also fail because the + # server does not yet support aborting from a new mongos, however this + # operation should "succeed" since abortTransaction ignores errors. + - + object: *session0 + name: abortTransaction + expectEvents: + - + client: *client0 + events: + - + commandStartedEvent: + command: + insert: *collection_name + documents: + - { _id: 1 } + ordered: true + readConcern: { $$exists: false } + lsid: { $$sessionLsid: *session0 } + txnNumber: { $numberLong: '1' } + startTransaction: true + autocommit: false + writeConcern: { $$exists: false } + commandName: insert + databaseName: *database_name + - + commandStartedEvent: + command: + abortTransaction: 1 + lsid: { $$sessionLsid: *session0 } + txnNumber: { $numberLong: '1' } + startTransaction: { $$exists: false } + autocommit: false + writeConcern: { $$exists: false } + recoveryToken: { $$exists: true } + commandName: abortTransaction + databaseName: admin + - + commandStartedEvent: + command: + abortTransaction: 1 + lsid: { $$sessionLsid: *session0 } + txnNumber: { $numberLong: '1' } + startTransaction: { $$exists: false } + autocommit: false + writeConcern: { $$exists: false } + recoveryToken: { $$exists: true } + commandName: abortTransaction + databaseName: admin + outcome: + - + collectionName: *collection_name + databaseName: *database_name + documents: [] diff --git a/source/transactions/tests/unified/mongos-unpin.json b/source/transactions/tests/unified/mongos-unpin.json index 356f4fd9b8..4d1ebc87bc 100644 --- a/source/transactions/tests/unified/mongos-unpin.json +++ b/source/transactions/tests/unified/mongos-unpin.json @@ -52,7 +52,10 @@ "description": "unpin after TransientTransactionError error on commit", "runOnRequirements": [ { - "serverless": "forbid" + "serverless": "forbid", + "topologies": [ + "sharded" + ] } ], "operations": [ @@ -163,7 +166,10 @@ "description": "unpin after non-transient error on abort", "runOnRequirements": [ { - "serverless": "forbid" + "serverless": "forbid", + "topologies": [ + "sharded" + ] } ], "operations": [ @@ -233,6 +239,13 @@ }, { "description": "unpin after TransientTransactionError error on abort", + "runOnRequirements": [ + { + "topologies": [ + "sharded" + ] + } + ], "operations": [ { "name": "startTransaction", diff --git a/source/transactions/tests/unified/mongos-unpin.yml b/source/transactions/tests/unified/mongos-unpin.yml index 5f7e78e5e8..44844a1858 100644 --- a/source/transactions/tests/unified/mongos-unpin.yml +++ b/source/transactions/tests/unified/mongos-unpin.yml @@ -35,9 +35,13 @@ _yamlAnchors: tests: - description: unpin after TransientTransactionError error on commit runOnRequirements: + - # serverless proxy doesn't append error labels to errors in transactions # caused by failpoints (CLOUDP-88216) - - serverless: "forbid" + serverless: "forbid" + # Note: test utilizes targetedFailPoint, which is incompatible with + # load-balanced and useMultipleMongoses:true + topologies: [ sharded ] operations: - &startTransaction name: startTransaction @@ -87,9 +91,13 @@ tests: - description: unpin after non-transient error on abort runOnRequirements: + - # serverless proxy doesn't append error labels to errors in transactions # caused by failpoints (CLOUDP-88216) - - serverless: "forbid" + serverless: "forbid" + # Note: test utilizes targetedFailPoint, which is incompatible with + # load-balanced and useMultipleMongoses:true + topologies: [ sharded ] operations: - *startTransaction - *insertOne @@ -112,6 +120,11 @@ tests: - *abortTransaction - description: unpin after TransientTransactionError error on abort + runOnRequirements: + - + # Note: test utilizes targetedFailPoint, which is incompatible with + # load-balanced and useMultipleMongoses:true + topologies: [ sharded ] operations: - *startTransaction - *insertOne diff --git a/source/transactions/tests/legacy/pin-mongos.json b/source/transactions/tests/unified/pin-mongos.json similarity index 51% rename from source/transactions/tests/legacy/pin-mongos.json rename to source/transactions/tests/unified/pin-mongos.json index 6e1d143d5c..5f2ecca5c1 100644 --- a/source/transactions/tests/legacy/pin-mongos.json +++ b/source/transactions/tests/unified/pin-mongos.json @@ -1,129 +1,167 @@ { - "runOn": [ + "description": "pin-mongos", + "schemaVersion": "1.9", + "runOnRequirements": [ { "minServerVersion": "4.1.8", - "topology": [ + "serverless": "forbid", + "topologies": [ "sharded", "load-balanced" - ], - "serverless": "forbid" + ] } ], - "database_name": "transaction-tests", - "collection_name": "test", - "data": [ + "createEntities": [ { - "_id": 1 + "client": { + "id": "client0", + "useMultipleMongoses": true, + "observeEvents": [ + "commandStartedEvent" + ] + } }, { - "_id": 2 + "database": { + "id": "database0", + "client": "client0", + "databaseName": "transaction-tests" + } + }, + { + "collection": { + "id": "collection0", + "database": "database0", + "collectionName": "test" + } + }, + { + "session": { + "id": "session0", + "client": "client0" + } + } + ], + "initialData": [ + { + "collectionName": "test", + "databaseName": "transaction-tests", + "documents": [ + { + "_id": 1 + }, + { + "_id": 2 + } + ] } ], "tests": [ { "description": "countDocuments", - "useMultipleMongoses": true, "operations": [ { - "name": "startTransaction", - "object": "session0" + "object": "session0", + "name": "startTransaction" }, { + "object": "collection0", "name": "countDocuments", - "object": "collection", "arguments": { "filter": { "_id": 2 }, "session": "session0" }, - "result": 1 + "expectResult": 1 }, { + "object": "collection0", "name": "countDocuments", - "object": "collection", "arguments": { "filter": { "_id": 2 }, "session": "session0" }, - "result": 1 + "expectResult": 1 }, { + "object": "collection0", "name": "countDocuments", - "object": "collection", "arguments": { "filter": { "_id": 2 }, "session": "session0" }, - "result": 1 + "expectResult": 1 }, { + "object": "collection0", "name": "countDocuments", - "object": "collection", "arguments": { "filter": { "_id": 2 }, "session": "session0" }, - "result": 1 + "expectResult": 1 }, { + "object": "collection0", "name": "countDocuments", - "object": "collection", "arguments": { "filter": { "_id": 2 }, "session": "session0" }, - "result": 1 + "expectResult": 1 }, { + "object": "collection0", "name": "countDocuments", - "object": "collection", "arguments": { "filter": { "_id": 2 }, "session": "session0" }, - "result": 1 + "expectResult": 1 }, { + "object": "collection0", "name": "countDocuments", - "object": "collection", "arguments": { "filter": { "_id": 2 }, "session": "session0" }, - "result": 1 + "expectResult": 1 }, { + "object": "collection0", "name": "countDocuments", - "object": "collection", "arguments": { "filter": { "_id": 2 }, "session": "session0" }, - "result": 1 + "expectResult": 1 }, { - "name": "commitTransaction", - "object": "session0" + "object": "session0", + "name": "commitTransaction" } ], - "outcome": { - "collection": { - "data": [ + "outcome": [ + { + "collectionName": "test", + "databaseName": "transaction-tests", + "documents": [ { "_id": 1 }, @@ -132,120 +170,129 @@ } ] } - } + ] }, { "description": "distinct", - "useMultipleMongoses": true, "operations": [ { - "name": "startTransaction", - "object": "session0" + "object": "session0", + "name": "startTransaction" }, { + "object": "collection0", "name": "distinct", - "object": "collection", "arguments": { "fieldName": "_id", + "filter": {}, "session": "session0" }, - "result": [ + "expectResult": [ 1, 2 ] }, { + "object": "collection0", "name": "distinct", - "object": "collection", "arguments": { "fieldName": "_id", + "filter": {}, "session": "session0" }, - "result": [ + "expectResult": [ 1, 2 ] }, { + "object": "collection0", "name": "distinct", - "object": "collection", "arguments": { "fieldName": "_id", + "filter": {}, "session": "session0" }, - "result": [ + "expectResult": [ 1, 2 ] }, { + "object": "collection0", "name": "distinct", - "object": "collection", "arguments": { "fieldName": "_id", + "filter": {}, "session": "session0" }, - "result": [ + "expectResult": [ 1, 2 ] }, { + "object": "collection0", "name": "distinct", - "object": "collection", "arguments": { "fieldName": "_id", + "filter": {}, "session": "session0" }, - "result": [ + "expectResult": [ 1, 2 ] }, { + "object": "collection0", "name": "distinct", - "object": "collection", "arguments": { "fieldName": "_id", + "filter": {}, "session": "session0" }, - "result": [ + "expectResult": [ 1, 2 ] }, { + "object": "collection0", "name": "distinct", - "object": "collection", "arguments": { "fieldName": "_id", + "filter": {}, "session": "session0" }, - "result": [ + "expectResult": [ 1, 2 ] }, { + "object": "collection0", "name": "distinct", - "object": "collection", "arguments": { "fieldName": "_id", + "filter": {}, "session": "session0" }, - "result": [ + "expectResult": [ 1, 2 ] }, { - "name": "commitTransaction", - "object": "session0" + "object": "session0", + "name": "commitTransaction" } ], - "outcome": { - "collection": { - "data": [ + "outcome": [ + { + "collectionName": "test", + "databaseName": "transaction-tests", + "documents": [ { "_id": 1 }, @@ -254,144 +301,145 @@ } ] } - } + ] }, { "description": "find", - "useMultipleMongoses": true, "operations": [ { - "name": "startTransaction", - "object": "session0" + "object": "session0", + "name": "startTransaction" }, { + "object": "collection0", "name": "find", - "object": "collection", "arguments": { "filter": { "_id": 2 }, "session": "session0" }, - "result": [ + "expectResult": [ { "_id": 2 } ] }, { + "object": "collection0", "name": "find", - "object": "collection", "arguments": { "filter": { "_id": 2 }, "session": "session0" }, - "result": [ + "expectResult": [ { "_id": 2 } ] }, { + "object": "collection0", "name": "find", - "object": "collection", "arguments": { "filter": { "_id": 2 }, "session": "session0" }, - "result": [ + "expectResult": [ { "_id": 2 } ] }, { + "object": "collection0", "name": "find", - "object": "collection", "arguments": { "filter": { "_id": 2 }, "session": "session0" }, - "result": [ + "expectResult": [ { "_id": 2 } ] }, { + "object": "collection0", "name": "find", - "object": "collection", "arguments": { "filter": { "_id": 2 }, "session": "session0" }, - "result": [ + "expectResult": [ { "_id": 2 } ] }, { + "object": "collection0", "name": "find", - "object": "collection", "arguments": { "filter": { "_id": 2 }, "session": "session0" }, - "result": [ + "expectResult": [ { "_id": 2 } ] }, { + "object": "collection0", "name": "find", - "object": "collection", "arguments": { "filter": { "_id": 2 }, "session": "session0" }, - "result": [ + "expectResult": [ { "_id": 2 } ] }, { + "object": "collection0", "name": "find", - "object": "collection", "arguments": { "filter": { "_id": 2 }, "session": "session0" }, - "result": [ + "expectResult": [ { "_id": 2 } ] }, { - "name": "commitTransaction", - "object": "session0" + "object": "session0", + "name": "commitTransaction" } ], - "outcome": { - "collection": { - "data": [ + "outcome": [ + { + "collectionName": "test", + "databaseName": "transaction-tests", + "documents": [ { "_id": 1 }, @@ -400,128 +448,161 @@ } ] } - } + ] }, { "description": "insertOne", - "useMultipleMongoses": true, "operations": [ { - "name": "startTransaction", - "object": "session0" + "object": "session0", + "name": "startTransaction" }, { + "object": "collection0", "name": "insertOne", - "object": "collection", "arguments": { "document": { "_id": 3 }, "session": "session0" }, - "result": { - "insertedId": 3 + "expectResult": { + "$$unsetOrMatches": { + "insertedId": { + "$$unsetOrMatches": 3 + } + } } }, { + "object": "collection0", "name": "insertOne", - "object": "collection", "arguments": { "document": { "_id": 4 }, "session": "session0" }, - "result": { - "insertedId": 4 + "expectResult": { + "$$unsetOrMatches": { + "insertedId": { + "$$unsetOrMatches": 4 + } + } } }, { + "object": "collection0", "name": "insertOne", - "object": "collection", "arguments": { "document": { "_id": 5 }, "session": "session0" }, - "result": { - "insertedId": 5 + "expectResult": { + "$$unsetOrMatches": { + "insertedId": { + "$$unsetOrMatches": 5 + } + } } }, { + "object": "collection0", "name": "insertOne", - "object": "collection", "arguments": { "document": { "_id": 6 }, "session": "session0" }, - "result": { - "insertedId": 6 + "expectResult": { + "$$unsetOrMatches": { + "insertedId": { + "$$unsetOrMatches": 6 + } + } } }, { + "object": "collection0", "name": "insertOne", - "object": "collection", "arguments": { "document": { "_id": 7 }, "session": "session0" }, - "result": { - "insertedId": 7 + "expectResult": { + "$$unsetOrMatches": { + "insertedId": { + "$$unsetOrMatches": 7 + } + } } }, { + "object": "collection0", "name": "insertOne", - "object": "collection", "arguments": { "document": { "_id": 8 }, "session": "session0" }, - "result": { - "insertedId": 8 + "expectResult": { + "$$unsetOrMatches": { + "insertedId": { + "$$unsetOrMatches": 8 + } + } } }, { + "object": "collection0", "name": "insertOne", - "object": "collection", "arguments": { "document": { "_id": 9 }, "session": "session0" }, - "result": { - "insertedId": 9 + "expectResult": { + "$$unsetOrMatches": { + "insertedId": { + "$$unsetOrMatches": 9 + } + } } }, { + "object": "collection0", "name": "insertOne", - "object": "collection", "arguments": { "document": { "_id": 10 }, "session": "session0" }, - "result": { - "insertedId": 10 + "expectResult": { + "$$unsetOrMatches": { + "insertedId": { + "$$unsetOrMatches": 10 + } + } } }, { - "name": "commitTransaction", - "object": "session0" + "object": "session0", + "name": "commitTransaction" } ], - "outcome": { - "collection": { - "data": [ + "outcome": [ + { + "collectionName": "test", + "databaseName": "transaction-tests", + "documents": [ { "_id": 1 }, @@ -554,144 +635,165 @@ } ] } - } + ] }, { "description": "mixed read write operations", - "useMultipleMongoses": true, "operations": [ { - "name": "startTransaction", - "object": "session0" + "object": "session0", + "name": "startTransaction" }, { + "object": "collection0", "name": "insertOne", - "object": "collection", "arguments": { "document": { "_id": 3 }, "session": "session0" }, - "result": { - "insertedId": 3 + "expectResult": { + "$$unsetOrMatches": { + "insertedId": { + "$$unsetOrMatches": 3 + } + } } }, { + "object": "collection0", "name": "countDocuments", - "object": "collection", "arguments": { "filter": { "_id": 3 }, "session": "session0" }, - "result": 1 + "expectResult": 1 }, { + "object": "collection0", "name": "countDocuments", - "object": "collection", "arguments": { "filter": { "_id": 3 }, "session": "session0" }, - "result": 1 + "expectResult": 1 }, { + "object": "collection0", "name": "countDocuments", - "object": "collection", "arguments": { "filter": { "_id": 3 }, "session": "session0" }, - "result": 1 + "expectResult": 1 }, { + "object": "collection0", "name": "countDocuments", - "object": "collection", "arguments": { "filter": { "_id": 3 }, "session": "session0" }, - "result": 1 + "expectResult": 1 }, { + "object": "collection0", "name": "countDocuments", - "object": "collection", "arguments": { "filter": { "_id": 3 }, "session": "session0" }, - "result": 1 + "expectResult": 1 }, { + "object": "collection0", "name": "insertOne", - "object": "collection", "arguments": { "document": { "_id": 4 }, "session": "session0" }, - "result": { - "insertedId": 4 + "expectResult": { + "$$unsetOrMatches": { + "insertedId": { + "$$unsetOrMatches": 4 + } + } } }, { + "object": "collection0", "name": "insertOne", - "object": "collection", "arguments": { "document": { "_id": 5 }, "session": "session0" }, - "result": { - "insertedId": 5 + "expectResult": { + "$$unsetOrMatches": { + "insertedId": { + "$$unsetOrMatches": 5 + } + } } }, { + "object": "collection0", "name": "insertOne", - "object": "collection", "arguments": { "document": { "_id": 6 }, "session": "session0" }, - "result": { - "insertedId": 6 + "expectResult": { + "$$unsetOrMatches": { + "insertedId": { + "$$unsetOrMatches": 6 + } + } } }, { + "object": "collection0", "name": "insertOne", - "object": "collection", "arguments": { "document": { "_id": 7 }, "session": "session0" }, - "result": { - "insertedId": 7 + "expectResult": { + "$$unsetOrMatches": { + "insertedId": { + "$$unsetOrMatches": 7 + } + } } }, { - "name": "commitTransaction", - "object": "session0" + "object": "session0", + "name": "commitTransaction" } ], - "outcome": { - "collection": { - "data": [ + "outcome": [ + { + "collectionName": "test", + "databaseName": "transaction-tests", + "documents": [ { "_id": 1 }, @@ -715,19 +817,18 @@ } ] } - } + ] }, { "description": "multiple commits", - "useMultipleMongoses": true, "operations": [ { - "name": "startTransaction", - "object": "session0" + "object": "session0", + "name": "startTransaction" }, { + "object": "collection0", "name": "insertMany", - "object": "collection", "arguments": { "documents": [ { @@ -739,78 +840,84 @@ ], "session": "session0" }, - "result": { - "insertedIds": { - "0": 3, - "1": 4 + "expectResult": { + "$$unsetOrMatches": { + "insertedIds": { + "$$unsetOrMatches": { + "0": 3, + "1": 4 + } + } } } }, { - "name": "assertSessionPinned", "object": "testRunner", + "name": "assertSessionPinned", "arguments": { "session": "session0" } }, { - "name": "commitTransaction", - "object": "session0" + "object": "session0", + "name": "commitTransaction" }, { - "name": "assertSessionPinned", "object": "testRunner", + "name": "assertSessionPinned", "arguments": { "session": "session0" } }, { - "name": "commitTransaction", - "object": "session0" + "object": "session0", + "name": "commitTransaction" }, { - "name": "commitTransaction", - "object": "session0" + "object": "session0", + "name": "commitTransaction" }, { - "name": "commitTransaction", - "object": "session0" + "object": "session0", + "name": "commitTransaction" }, { - "name": "commitTransaction", - "object": "session0" + "object": "session0", + "name": "commitTransaction" }, { - "name": "commitTransaction", - "object": "session0" + "object": "session0", + "name": "commitTransaction" }, { - "name": "commitTransaction", - "object": "session0" + "object": "session0", + "name": "commitTransaction" }, { - "name": "commitTransaction", - "object": "session0" + "object": "session0", + "name": "commitTransaction" }, { - "name": "commitTransaction", - "object": "session0" + "object": "session0", + "name": "commitTransaction" }, { - "name": "commitTransaction", - "object": "session0" + "object": "session0", + "name": "commitTransaction" }, { - "name": "assertSessionPinned", "object": "testRunner", + "name": "assertSessionPinned", "arguments": { "session": "session0" } } ], - "outcome": { - "collection": { - "data": [ + "outcome": [ + { + "collectionName": "test", + "databaseName": "transaction-tests", + "documents": [ { "_id": 1 }, @@ -825,19 +932,25 @@ } ] } - } + ] }, { "description": "remain pinned after non-transient error on commit", - "useMultipleMongoses": true, + "runOnRequirements": [ + { + "topologies": [ + "sharded" + ] + } + ], "operations": [ { - "name": "startTransaction", - "object": "session0" + "object": "session0", + "name": "startTransaction" }, { + "object": "collection0", "name": "insertMany", - "object": "collection", "arguments": { "documents": [ { @@ -849,23 +962,27 @@ ], "session": "session0" }, - "result": { - "insertedIds": { - "0": 3, - "1": 4 + "expectResult": { + "$$unsetOrMatches": { + "insertedIds": { + "$$unsetOrMatches": { + "0": 3, + "1": 4 + } + } } } }, { - "name": "assertSessionPinned", "object": "testRunner", + "name": "assertSessionPinned", "arguments": { "session": "session0" } }, { - "name": "targetedFailPoint", "object": "testRunner", + "name": "targetedFailPoint", "arguments": { "session": "session0", "failPoint": { @@ -883,9 +1000,9 @@ } }, { - "name": "commitTransaction", "object": "session0", - "result": { + "name": "commitTransaction", + "expectError": { "errorLabelsOmit": [ "TransientTransactionError" ], @@ -893,27 +1010,29 @@ } }, { - "name": "assertSessionPinned", "object": "testRunner", + "name": "assertSessionPinned", "arguments": { "session": "session0" } }, { - "name": "commitTransaction", - "object": "session0" + "object": "session0", + "name": "commitTransaction" }, { - "name": "assertSessionPinned", "object": "testRunner", + "name": "assertSessionPinned", "arguments": { "session": "session0" } } ], - "outcome": { - "collection": { - "data": [ + "outcome": [ + { + "collectionName": "test", + "databaseName": "transaction-tests", + "documents": [ { "_id": 1 }, @@ -928,32 +1047,42 @@ } ] } - } + ] }, { "description": "unpin after transient error within a transaction", - "useMultipleMongoses": true, + "runOnRequirements": [ + { + "topologies": [ + "sharded" + ] + } + ], "operations": [ { - "name": "startTransaction", - "object": "session0" + "object": "session0", + "name": "startTransaction" }, { + "object": "collection0", "name": "insertOne", - "object": "collection", "arguments": { "session": "session0", "document": { "_id": 3 } }, - "result": { - "insertedId": 3 + "expectResult": { + "$$unsetOrMatches": { + "insertedId": { + "$$unsetOrMatches": 3 + } + } } }, { - "name": "targetedFailPoint", "object": "testRunner", + "name": "targetedFailPoint", "arguments": { "session": "session0", "failPoint": { @@ -971,15 +1100,15 @@ } }, { + "object": "collection0", "name": "insertOne", - "object": "collection", "arguments": { "session": "session0", "document": { "_id": 4 } }, - "result": { + "expectError": { "errorLabelsContain": [ "TransientTransactionError" ], @@ -989,78 +1118,107 @@ } }, { - "name": "abortTransaction", - "object": "session0" + "object": "session0", + "name": "abortTransaction" } ], - "expectations": [ - { - "command_started_event": { - "command": { - "insert": "test", - "documents": [ - { - "_id": 3 - } - ], - "ordered": true, - "readConcern": null, - "lsid": "session0", - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": true, - "autocommit": false, - "writeConcern": null - }, - "command_name": "insert", - "database_name": "transaction-tests" - } - }, + "expectEvents": [ { - "command_started_event": { - "command": { - "insert": "test", - "documents": [ - { - "_id": 4 - } - ], - "ordered": true, - "readConcern": null, - "lsid": "session0", - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": null, - "autocommit": false, - "writeConcern": null + "client": "client0", + "events": [ + { + "commandStartedEvent": { + "command": { + "insert": "test", + "documents": [ + { + "_id": 3 + } + ], + "ordered": true, + "readConcern": { + "$$exists": false + }, + "lsid": { + "$$sessionLsid": "session0" + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": true, + "autocommit": false, + "writeConcern": { + "$$exists": false + } + }, + "commandName": "insert", + "databaseName": "transaction-tests" + } }, - "command_name": "insert", - "database_name": "transaction-tests" - } - }, - { - "command_started_event": { - "command": { - "abortTransaction": 1, - "lsid": "session0", - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": null, - "autocommit": false, - "writeConcern": null, - "recoveryToken": 42 + { + "commandStartedEvent": { + "command": { + "insert": "test", + "documents": [ + { + "_id": 4 + } + ], + "ordered": true, + "readConcern": { + "$$exists": false + }, + "lsid": { + "$$sessionLsid": "session0" + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": { + "$$exists": false + }, + "autocommit": false, + "writeConcern": { + "$$exists": false + } + }, + "commandName": "insert", + "databaseName": "transaction-tests" + } }, - "command_name": "abortTransaction", - "database_name": "admin" - } + { + "commandStartedEvent": { + "command": { + "abortTransaction": 1, + "lsid": { + "$$sessionLsid": "session0" + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": { + "$$exists": false + }, + "autocommit": false, + "writeConcern": { + "$$exists": false + }, + "recoveryToken": { + "$$exists": true + } + }, + "commandName": "abortTransaction", + "databaseName": "admin" + } + } + ] } ], - "outcome": { - "collection": { - "data": [ + "outcome": [ + { + "collectionName": "test", + "databaseName": "transaction-tests", + "documents": [ { "_id": 1 }, @@ -1069,37 +1227,84 @@ } ] } - } + ] }, { "description": "unpin after transient error within a transaction and commit", - "useMultipleMongoses": true, - "clientOptions": { - "heartbeatFrequencyMS": 30000 - }, + "runOnRequirements": [ + { + "topologies": [ + "sharded" + ] + } + ], "operations": [ { - "name": "startTransaction", - "object": "session0" + "object": "testRunner", + "name": "createEntities", + "arguments": { + "entities": [ + { + "client": { + "id": "client1", + "useMultipleMongoses": true, + "uriOptions": { + "heartbeatFrequencyMS": 30000 + }, + "observeEvents": [ + "commandStartedEvent" + ] + } + }, + { + "database": { + "id": "database1", + "client": "client1", + "databaseName": "transaction-tests" + } + }, + { + "collection": { + "id": "collection1", + "database": "database1", + "collectionName": "test" + } + }, + { + "session": { + "id": "session1", + "client": "client1" + } + } + ] + } + }, + { + "object": "session1", + "name": "startTransaction" }, { + "object": "collection1", "name": "insertOne", - "object": "collection", "arguments": { - "session": "session0", + "session": "session1", "document": { "_id": 3 } }, - "result": { - "insertedId": 3 + "expectResult": { + "$$unsetOrMatches": { + "insertedId": { + "$$unsetOrMatches": 3 + } + } } }, { - "name": "targetedFailPoint", "object": "testRunner", + "name": "targetedFailPoint", "arguments": { - "session": "session0", + "session": "session1", "failPoint": { "configureFailPoint": "failCommand", "mode": { @@ -1117,15 +1322,15 @@ } }, { + "object": "collection1", "name": "insertOne", - "object": "collection", "arguments": { - "session": "session0", + "session": "session1", "document": { "_id": 4 } }, - "result": { + "expectError": { "errorLabelsContain": [ "TransientTransactionError" ], @@ -1135,9 +1340,9 @@ } }, { + "object": "session1", "name": "commitTransaction", - "object": "session0", - "result": { + "expectError": { "errorLabelsContain": [ "TransientTransactionError" ], @@ -1148,74 +1353,103 @@ } } ], - "expectations": [ - { - "command_started_event": { - "command": { - "insert": "test", - "documents": [ - { - "_id": 3 - } - ], - "ordered": true, - "readConcern": null, - "lsid": "session0", - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": true, - "autocommit": false, - "writeConcern": null - }, - "command_name": "insert", - "database_name": "transaction-tests" - } - }, + "expectEvents": [ { - "command_started_event": { - "command": { - "insert": "test", - "documents": [ - { - "_id": 4 - } - ], - "ordered": true, - "readConcern": null, - "lsid": "session0", - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": null, - "autocommit": false, - "writeConcern": null + "client": "client1", + "events": [ + { + "commandStartedEvent": { + "command": { + "insert": "test", + "documents": [ + { + "_id": 3 + } + ], + "ordered": true, + "readConcern": { + "$$exists": false + }, + "lsid": { + "$$sessionLsid": "session1" + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": true, + "autocommit": false, + "writeConcern": { + "$$exists": false + } + }, + "commandName": "insert", + "databaseName": "transaction-tests" + } }, - "command_name": "insert", - "database_name": "transaction-tests" - } - }, - { - "command_started_event": { - "command": { - "commitTransaction": 1, - "lsid": "session0", - "txnNumber": { - "$numberLong": "1" - }, - "startTransaction": null, - "autocommit": false, - "writeConcern": null, - "recoveryToken": 42 + { + "commandStartedEvent": { + "command": { + "insert": "test", + "documents": [ + { + "_id": 4 + } + ], + "ordered": true, + "readConcern": { + "$$exists": false + }, + "lsid": { + "$$sessionLsid": "session1" + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": { + "$$exists": false + }, + "autocommit": false, + "writeConcern": { + "$$exists": false + } + }, + "commandName": "insert", + "databaseName": "transaction-tests" + } }, - "command_name": "commitTransaction", - "database_name": "admin" - } + { + "commandStartedEvent": { + "command": { + "commitTransaction": 1, + "lsid": { + "$$sessionLsid": "session1" + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": { + "$$exists": false + }, + "autocommit": false, + "writeConcern": { + "$$exists": false + }, + "recoveryToken": { + "$$exists": true + } + }, + "commandName": "commitTransaction", + "databaseName": "admin" + } + } + ] } ], - "outcome": { - "collection": { - "data": [ + "outcome": [ + { + "collectionName": "test", + "databaseName": "transaction-tests", + "documents": [ { "_id": 1 }, @@ -1224,7 +1458,7 @@ } ] } - } + ] } ] } diff --git a/source/transactions/tests/unified/pin-mongos.yml b/source/transactions/tests/unified/pin-mongos.yml new file mode 100644 index 0000000000..596dc2d00d --- /dev/null +++ b/source/transactions/tests/unified/pin-mongos.yml @@ -0,0 +1,658 @@ +# Test that all the operations go to the same mongos. +# +# In tests that don't include command-started events the assertion is implicit: +# that all the read operations succeed. If the driver does not properly pin to +# a single mongos then one of the operations in a transaction will eventually +# be sent to a different mongos, which is unaware of the transaction, and the +# mongos will return a command error. An example of such an error is: +# { +# 'ok': 0.0, +# 'errmsg': 'cannot continue txnId -1 for session 28938f50-9d29-4ca5-8de5-ddaf261267c4 - 47DEQpj8HBSa+/TImW+5JCeuQeRkm5NMpJWZG3hSuFU= with txnId 1', +# 'code': 251, +# 'codeName': 'NoSuchTransaction', +# 'errorLabels': ['TransientTransactionError'] +# } +description: pin-mongos + +schemaVersion: '1.9' + +runOnRequirements: + - + minServerVersion: 4.1.8 + # serverless proxy doesn't append error labels to errors in transactions + # caused by failpoints (CLOUDP-88216) + serverless: forbid + topologies: + - sharded + - load-balanced + +createEntities: + - + client: + id: &client0 client0 + useMultipleMongoses: true + observeEvents: + - commandStartedEvent + - + database: + id: &database0 database0 + client: *client0 + databaseName: &database_name transaction-tests + - + collection: + id: &collection0 collection0 + database: *database0 + collectionName: &collection_name test + - + session: + id: &session0 session0 + client: *client0 + +initialData: + - + collectionName: *collection_name + databaseName: *database_name + documents: &data + - { _id: 1 } + - { _id: 2 } + +tests: + - + description: countDocuments + operations: + - &startTransaction + object: *session0 + name: startTransaction + - &countDocuments + object: *collection0 + name: countDocuments + arguments: + filter: { _id: 2 } + session: *session0 + expectResult: 1 + - *countDocuments + - *countDocuments + - *countDocuments + - *countDocuments + - *countDocuments + - *countDocuments + - *countDocuments + - &commitTransaction + object: *session0 + name: commitTransaction + outcome: + - + collectionName: *collection_name + databaseName: *database_name + documents: *data + - + description: distinct + operations: + - *startTransaction + - &distinct + object: *collection0 + name: distinct + arguments: + fieldName: _id + filter: {} + session: *session0 + expectResult: [ 1, 2 ] + - *distinct + - *distinct + - *distinct + - *distinct + - *distinct + - *distinct + - *distinct + - *commitTransaction + outcome: + - + collectionName: *collection_name + databaseName: *database_name + documents: *data + - + description: find + operations: + - + object: *session0 + name: startTransaction + - &find + object: *collection0 + name: find + arguments: + filter: { _id: 2 } + session: *session0 + expectResult: + - { _id: 2 } + - *find + - *find + - *find + - *find + - *find + - *find + - *find + - *commitTransaction + outcome: + - + collectionName: *collection_name + databaseName: *database_name + documents: *data + - + description: insertOne + operations: + - + object: *session0 + name: startTransaction + - + object: *collection0 + name: insertOne + arguments: + document: { _id: 3 } + session: *session0 + expectResult: + $$unsetOrMatches: { insertedId: { $$unsetOrMatches: 3 } } + - + object: *collection0 + name: insertOne + arguments: + document: { _id: 4 } + session: *session0 + expectResult: + $$unsetOrMatches: { insertedId: { $$unsetOrMatches: 4 } } + - + object: *collection0 + name: insertOne + arguments: + document: { _id: 5 } + session: *session0 + expectResult: + $$unsetOrMatches: { insertedId: { $$unsetOrMatches: 5 } } + - + object: *collection0 + name: insertOne + arguments: + document: { _id: 6 } + session: *session0 + expectResult: + $$unsetOrMatches: { insertedId: { $$unsetOrMatches: 6 } } + - + object: *collection0 + name: insertOne + arguments: + document: { _id: 7 } + session: *session0 + expectResult: + $$unsetOrMatches: { insertedId: { $$unsetOrMatches: 7 } } + - + object: *collection0 + name: insertOne + arguments: + document: { _id: 8 } + session: *session0 + expectResult: + $$unsetOrMatches: { insertedId: { $$unsetOrMatches: 8 } } + - + object: *collection0 + name: insertOne + arguments: + document: { _id: 9 } + session: *session0 + expectResult: + $$unsetOrMatches: { insertedId: { $$unsetOrMatches: 9 } } + - + object: *collection0 + name: insertOne + arguments: + document: { _id: 10 } + session: *session0 + expectResult: + $$unsetOrMatches: { insertedId: { $$unsetOrMatches: 10 } } + - *commitTransaction + outcome: + - + collectionName: *collection_name + databaseName: *database_name + documents: + - { _id: 1 } + - { _id: 2 } + - { _id: 3 } + - { _id: 4 } + - { _id: 5 } + - { _id: 6 } + - { _id: 7 } + - { _id: 8 } + - { _id: 9 } + - { _id: 10 } + - + description: 'mixed read write operations' + operations: + - + object: *session0 + name: startTransaction + - + object: *collection0 + name: insertOne + arguments: + document: { _id: 3 } + session: *session0 + expectResult: + $$unsetOrMatches: { insertedId: { $$unsetOrMatches: 3 } } + - &countDocuments + object: *collection0 + name: countDocuments + arguments: + filter: { _id: 3 } + session: *session0 + expectResult: 1 + - *countDocuments + - *countDocuments + - *countDocuments + - *countDocuments + - + object: *collection0 + name: insertOne + arguments: + document: { _id: 4 } + session: *session0 + expectResult: + $$unsetOrMatches: { insertedId: { $$unsetOrMatches: 4 } } + - + object: *collection0 + name: insertOne + arguments: + document: { _id: 5 } + session: *session0 + expectResult: + $$unsetOrMatches: { insertedId: { $$unsetOrMatches: 5 } } + - + object: *collection0 + name: insertOne + arguments: + document: { _id: 6 } + session: *session0 + expectResult: + $$unsetOrMatches: { insertedId: { $$unsetOrMatches: 6 } } + - + object: *collection0 + name: insertOne + arguments: + document: { _id: 7 } + session: *session0 + expectResult: + $$unsetOrMatches: { insertedId: { $$unsetOrMatches: 7 } } + - *commitTransaction + outcome: + - + collectionName: *collection_name + databaseName: *database_name + documents: + - { _id: 1 } + - { _id: 2 } + - { _id: 3 } + - { _id: 4 } + - { _id: 5 } + - { _id: 6 } + - { _id: 7 } + - + description: 'multiple commits' + operations: + - + object: *session0 + name: startTransaction + - + object: *collection0 + name: insertMany + arguments: + documents: + - { _id: 3 } + - { _id: 4 } + session: *session0 + expectResult: + $$unsetOrMatches: + insertedIds: + $$unsetOrMatches: + '0': 3 + '1': 4 + # Session is pinned and remains pinned after successful commits + - &assertSessionPinned + object: testRunner + name: assertSessionPinned + arguments: + session: *session0 + - *commitTransaction + - *assertSessionPinned + - *commitTransaction + - *commitTransaction + - *commitTransaction + - *commitTransaction + - *commitTransaction + - *commitTransaction + - *commitTransaction + - *commitTransaction + - *commitTransaction + - *assertSessionPinned + outcome: + - + collectionName: *collection_name + databaseName: *database_name + documents: + - { _id: 1 } + - { _id: 2 } + - { _id: 3 } + - { _id: 4 } + - + description: 'remain pinned after non-transient error on commit' + # Note: test utilizes targetedFailPoint, which is incompatible with + # load-balanced and useMultipleMongoses:true + runOnRequirements: + - topologies: [ sharded ] + operations: + - + object: *session0 + name: startTransaction + - + object: *collection0 + name: insertMany + arguments: + documents: + - { _id: 3 } + - { _id: 4 } + session: *session0 + expectResult: + $$unsetOrMatches: + insertedIds: + $$unsetOrMatches: + '0': 3 + '1': 4 + - *assertSessionPinned + # Fail the commit with a non-transient error + - + object: testRunner + name: targetedFailPoint + arguments: + session: *session0 + failPoint: + configureFailPoint: failCommand + mode: { times: 1 } + data: + failCommands: + - commitTransaction + errorCode: 51 # ManualInterventionRequired + - + object: *session0 + name: commitTransaction + expectError: + errorLabelsOmit: + - TransientTransactionError + errorCode: 51 + - *assertSessionPinned + # The next commit should succeed + - + object: *session0 + name: commitTransaction + - *assertSessionPinned + outcome: + - + collectionName: *collection_name + databaseName: *database_name + documents: + - { _id: 1 } + - { _id: 2 } + - { _id: 3 } + - { _id: 4 } + - + description: 'unpin after transient error within a transaction' + # Note: test utilizes targetedFailPoint, which is incompatible with + # load-balanced and useMultipleMongoses:true + runOnRequirements: + - topologies: [ sharded ] + operations: + - + object: *session0 + name: startTransaction + - + object: *collection0 + name: insertOne + arguments: + session: *session0 + document: { _id: 3 } + expectResult: + $$unsetOrMatches: { insertedId: { $$unsetOrMatches: 3 } } + # Enable the fail point only on the mongos that session0 is pinned to + - + object: testRunner + name: targetedFailPoint + arguments: + session: *session0 + failPoint: + configureFailPoint: failCommand + mode: { times: 1 } + data: + failCommands: + - insert + closeConnection: true + - + object: *collection0 + name: insertOne + arguments: + session: *session0 + document: { _id: 4 } + expectError: + errorLabelsContain: + - TransientTransactionError + errorLabelsOmit: + - UnknownTransactionCommitResult + # Session unpins from the first mongos after the insert error and + # abortTransaction succeeds immediately on any mongos. + - + object: *session0 + name: abortTransaction + expectEvents: + - + client: *client0 + events: + - + commandStartedEvent: + command: + insert: *collection_name + documents: + - { _id: 3 } + ordered: true + readConcern: { $$exists: false } + lsid: { $$sessionLsid: *session0 } + txnNumber: { $numberLong: '1' } + startTransaction: true + autocommit: false + writeConcern: { $$exists: false } + commandName: insert + databaseName: *database_name + - + commandStartedEvent: + command: + insert: *collection_name + documents: + - { _id: 4 } + ordered: true + readConcern: { $$exists: false } + lsid: { $$sessionLsid: *session0 } + txnNumber: { $numberLong: '1' } + startTransaction: { $$exists: false } + autocommit: false + writeConcern: { $$exists: false } + commandName: insert + databaseName: *database_name + - + commandStartedEvent: + command: + abortTransaction: 1 + lsid: { $$sessionLsid: *session0 } + txnNumber: { $numberLong: '1' } + startTransaction: { $$exists: false } + autocommit: false + writeConcern: { $$exists: false } + recoveryToken: { $$exists: true } + commandName: abortTransaction + databaseName: admin + outcome: + - + collectionName: *collection_name + databaseName: *database_name + documents: + - { _id: 1 } + - { _id: 2 } + # Applications should not run commitTransaction after transient errors but + # the transactions API allows it and this test confirms unpinning behavior. + # In a sharded cluster, a transient error within a transaction unpins the + # session. This way a subsequent abort can "succeed" immediately instead of + # blocking for serverSelectionTimeoutMS in the case the mongos went down. + # However since the abortTransaction helper ignores errors, this test uses + # commitTransaction to prove the session was unpinned. + - + description: 'unpin after transient error within a transaction and commit' + # Note: test utilizes targetedFailPoint, which is incompatible with + # load-balanced and useMultipleMongoses:true + runOnRequirements: + - topologies: [ sharded ] + operations: + - + object: testRunner + name: createEntities + arguments: + entities: + - client: + id: &client1 client1 + useMultipleMongoses: true + uriOptions: + # Increase heartbeatFrequencyMS to avoid the race condition where an in + # flight heartbeat refreshes the first mongoes' SDAM state in between + # the insert connection error and the single commit attempt. + heartbeatFrequencyMS: 30000 + observeEvents: + - commandStartedEvent + - database: + id: &database1 database1 + client: *client1 + databaseName: *database_name + - collection: + id: &collection1 collection1 + database: *database1 + collectionName: *collection_name + - session: + id: &session1 session1 + client: *client1 + - + object: *session1 + name: startTransaction + - + object: *collection1 + name: insertOne + arguments: + session: *session1 + document: { _id: 3 } + expectResult: + $$unsetOrMatches: { insertedId: { $$unsetOrMatches: 3 } } + # Enable the fail point only on the Mongos that session0 is pinned to. + # Fail hello/legacy hello to prevent the heartbeat requested directly after the + # insert error from racing with server selection for the commit. + # Note: times: 7 is slightly artbitrary but it accounts for one failed + # insert and some SDAM heartbeats. A test runner will have multiple + # clients connected to this server so this fail point configuration + # is also racy. + - + object: testRunner + name: targetedFailPoint + arguments: + session: *session1 + failPoint: + configureFailPoint: failCommand + mode: { times: 7 } + data: + failCommands: + - insert + - isMaster + - hello + closeConnection: true + - + object: *collection1 + name: insertOne + arguments: + session: *session1 + document: { _id: 4 } + expectError: + errorLabelsContain: + - TransientTransactionError + errorLabelsOmit: + - UnknownTransactionCommitResult + # Session unpins from the first mongos after the insert error and + # commitTransaction selects the second mongos which is unaware of the + # transaction and therefore fails with NoSuchTransaction error. If this + # commit succeeds it indicates a bug, either: + # - the driver mistakenly remained pinned even after the insert error, or + # - the test client was initialized with a single mongos seed + # + # Note that the commit attempt should not select the original mongos + # because that server's SDAM state is reset by the connection error, + # heartbeatFrequencyMS is high, and subsequent heartbeats + # should fail. + - + object: *session1 + name: commitTransaction + expectError: + errorLabelsContain: + - TransientTransactionError + errorLabelsOmit: + - UnknownTransactionCommitResult + errorCodeName: NoSuchTransaction + expectEvents: + - + client: *client1 + events: + - + commandStartedEvent: + command: + insert: *collection_name + documents: + - { _id: 3 } + ordered: true + readConcern: { $$exists: false } + lsid: { $$sessionLsid: *session1 } + txnNumber: { $numberLong: '1' } + startTransaction: true + autocommit: false + writeConcern: { $$exists: false } + commandName: insert + databaseName: *database_name + - + commandStartedEvent: + command: + insert: *collection_name + documents: + - { _id: 4 } + ordered: true + readConcern: { $$exists: false } + lsid: { $$sessionLsid: *session1 } + txnNumber: { $numberLong: '1' } + startTransaction: { $$exists: false } + autocommit: false + writeConcern: { $$exists: false } + commandName: insert + databaseName: *database_name + - + commandStartedEvent: + command: + commitTransaction: 1 + lsid: { $$sessionLsid: *session1 } + txnNumber: { $numberLong: '1' } + startTransaction: { $$exists: false } + autocommit: false + writeConcern: { $$exists: false } + recoveryToken: { $$exists: true } + commandName: commitTransaction + databaseName: admin + outcome: + - + collectionName: *collection_name + databaseName: *database_name + documents: + - { _id: 1 } + - { _id: 2 } diff --git a/source/transactions/tests/unified/read-concern.json b/source/transactions/tests/unified/read-concern.json new file mode 100644 index 0000000000..b3bd967c09 --- /dev/null +++ b/source/transactions/tests/unified/read-concern.json @@ -0,0 +1,1924 @@ +{ + "description": "read-concern", + "schemaVersion": "1.3", + "runOnRequirements": [ + { + "minServerVersion": "4.0", + "topologies": [ + "replicaset" + ] + }, + { + "minServerVersion": "4.1.8", + "topologies": [ + "sharded", + "load-balanced" + ] + } + ], + "createEntities": [ + { + "client": { + "id": "client0", + "useMultipleMongoses": false, + "observeEvents": [ + "commandStartedEvent" + ] + } + }, + { + "database": { + "id": "database0", + "client": "client0", + "databaseName": "transaction-tests" + } + }, + { + "database": { + "id": "database_rc_majority", + "client": "client0", + "databaseName": "transaction-tests", + "databaseOptions": { + "readConcern": { + "level": "majority" + } + } + } + }, + { + "collection": { + "id": "collection_rc_majority", + "database": "database0", + "collectionName": "test", + "collectionOptions": { + "readConcern": { + "level": "majority" + } + } + } + }, + { + "session": { + "id": "session0", + "client": "client0" + } + } + ], + "initialData": [ + { + "collectionName": "test", + "databaseName": "transaction-tests", + "documents": [ + { + "_id": 1 + }, + { + "_id": 2 + }, + { + "_id": 3 + }, + { + "_id": 4 + } + ] + } + ], + "tests": [ + { + "description": "only first countDocuments includes readConcern", + "operations": [ + { + "object": "session0", + "name": "startTransaction", + "arguments": { + "readConcern": { + "level": "majority" + } + } + }, + { + "object": "collection_rc_majority", + "name": "countDocuments", + "arguments": { + "filter": { + "_id": { + "$gte": 2 + } + }, + "session": "session0" + }, + "expectResult": 3 + }, + { + "object": "collection_rc_majority", + "name": "countDocuments", + "arguments": { + "filter": { + "_id": { + "$gte": 2 + } + }, + "session": "session0" + }, + "expectResult": 3 + }, + { + "object": "session0", + "name": "commitTransaction" + } + ], + "expectEvents": [ + { + "client": "client0", + "events": [ + { + "commandStartedEvent": { + "command": { + "aggregate": "test", + "pipeline": [ + { + "$match": { + "_id": { + "$gte": 2 + } + } + }, + { + "$group": { + "_id": 1, + "n": { + "$sum": 1 + } + } + } + ], + "cursor": {}, + "lsid": { + "$$sessionLsid": "session0" + }, + "readConcern": { + "level": "majority" + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": true, + "autocommit": false + }, + "commandName": "aggregate", + "databaseName": "transaction-tests" + } + }, + { + "commandStartedEvent": { + "command": { + "aggregate": "test", + "pipeline": [ + { + "$match": { + "_id": { + "$gte": 2 + } + } + }, + { + "$group": { + "_id": 1, + "n": { + "$sum": 1 + } + } + } + ], + "cursor": {}, + "lsid": { + "$$sessionLsid": "session0" + }, + "readConcern": { + "$$exists": false + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": { + "$$exists": false + }, + "autocommit": false + }, + "commandName": "aggregate", + "databaseName": "transaction-tests" + } + }, + { + "commandStartedEvent": { + "command": { + "commitTransaction": 1, + "lsid": { + "$$sessionLsid": "session0" + }, + "readConcern": { + "$$exists": false + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": { + "$$exists": false + }, + "autocommit": false, + "writeConcern": { + "$$exists": false + } + }, + "commandName": "commitTransaction", + "databaseName": "admin" + } + } + ] + } + ], + "outcome": [ + { + "collectionName": "test", + "databaseName": "transaction-tests", + "documents": [ + { + "_id": 1 + }, + { + "_id": 2 + }, + { + "_id": 3 + }, + { + "_id": 4 + } + ] + } + ] + }, + { + "description": "only first find includes readConcern", + "operations": [ + { + "object": "session0", + "name": "startTransaction", + "arguments": { + "readConcern": { + "level": "majority" + } + } + }, + { + "object": "collection_rc_majority", + "name": "find", + "arguments": { + "batchSize": 3, + "filter": {}, + "session": "session0" + }, + "expectResult": [ + { + "_id": 1 + }, + { + "_id": 2 + }, + { + "_id": 3 + }, + { + "_id": 4 + } + ] + }, + { + "object": "collection_rc_majority", + "name": "find", + "arguments": { + "batchSize": 3, + "filter": {}, + "session": "session0" + }, + "expectResult": [ + { + "_id": 1 + }, + { + "_id": 2 + }, + { + "_id": 3 + }, + { + "_id": 4 + } + ] + }, + { + "object": "session0", + "name": "commitTransaction" + } + ], + "expectEvents": [ + { + "client": "client0", + "events": [ + { + "commandStartedEvent": { + "command": { + "find": "test", + "batchSize": 3, + "lsid": { + "$$sessionLsid": "session0" + }, + "readConcern": { + "level": "majority" + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": true, + "autocommit": false + }, + "commandName": "find", + "databaseName": "transaction-tests" + } + }, + { + "commandStartedEvent": { + "command": { + "getMore": { + "$$type": [ + "int", + "long" + ] + }, + "collection": "test", + "batchSize": 3, + "lsid": { + "$$sessionLsid": "session0" + }, + "readConcern": { + "$$exists": false + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": { + "$$exists": false + }, + "autocommit": false + }, + "commandName": "getMore", + "databaseName": "transaction-tests" + } + }, + { + "commandStartedEvent": { + "command": { + "find": "test", + "batchSize": 3, + "lsid": { + "$$sessionLsid": "session0" + }, + "readConcern": { + "$$exists": false + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": { + "$$exists": false + }, + "autocommit": false + }, + "commandName": "find", + "databaseName": "transaction-tests" + } + }, + { + "commandStartedEvent": { + "command": { + "getMore": { + "$$type": [ + "int", + "long" + ] + }, + "collection": "test", + "batchSize": 3, + "lsid": { + "$$sessionLsid": "session0" + }, + "readConcern": { + "$$exists": false + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": { + "$$exists": false + }, + "autocommit": false + }, + "commandName": "getMore", + "databaseName": "transaction-tests" + } + }, + { + "commandStartedEvent": { + "command": { + "commitTransaction": 1, + "lsid": { + "$$sessionLsid": "session0" + }, + "readConcern": { + "$$exists": false + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": { + "$$exists": false + }, + "autocommit": false, + "writeConcern": { + "$$exists": false + } + }, + "commandName": "commitTransaction", + "databaseName": "admin" + } + } + ] + } + ], + "outcome": [ + { + "collectionName": "test", + "databaseName": "transaction-tests", + "documents": [ + { + "_id": 1 + }, + { + "_id": 2 + }, + { + "_id": 3 + }, + { + "_id": 4 + } + ] + } + ] + }, + { + "description": "only first aggregate includes readConcern", + "operations": [ + { + "object": "session0", + "name": "startTransaction", + "arguments": { + "readConcern": { + "level": "majority" + } + } + }, + { + "object": "collection_rc_majority", + "name": "aggregate", + "arguments": { + "pipeline": [ + { + "$project": { + "_id": 1 + } + } + ], + "batchSize": 3, + "session": "session0" + }, + "expectResult": [ + { + "_id": 1 + }, + { + "_id": 2 + }, + { + "_id": 3 + }, + { + "_id": 4 + } + ] + }, + { + "object": "collection_rc_majority", + "name": "aggregate", + "arguments": { + "pipeline": [ + { + "$project": { + "_id": 1 + } + } + ], + "batchSize": 3, + "session": "session0" + }, + "expectResult": [ + { + "_id": 1 + }, + { + "_id": 2 + }, + { + "_id": 3 + }, + { + "_id": 4 + } + ] + }, + { + "object": "session0", + "name": "commitTransaction" + } + ], + "expectEvents": [ + { + "client": "client0", + "events": [ + { + "commandStartedEvent": { + "command": { + "aggregate": "test", + "pipeline": [ + { + "$project": { + "_id": 1 + } + } + ], + "cursor": { + "batchSize": 3 + }, + "lsid": { + "$$sessionLsid": "session0" + }, + "readConcern": { + "level": "majority" + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": true, + "autocommit": false + }, + "commandName": "aggregate", + "databaseName": "transaction-tests" + } + }, + { + "commandStartedEvent": { + "command": { + "getMore": { + "$$type": [ + "int", + "long" + ] + }, + "collection": "test", + "batchSize": 3, + "lsid": { + "$$sessionLsid": "session0" + }, + "readConcern": { + "$$exists": false + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": { + "$$exists": false + }, + "autocommit": false + }, + "commandName": "getMore", + "databaseName": "transaction-tests" + } + }, + { + "commandStartedEvent": { + "command": { + "aggregate": "test", + "pipeline": [ + { + "$project": { + "_id": 1 + } + } + ], + "cursor": { + "batchSize": 3 + }, + "lsid": { + "$$sessionLsid": "session0" + }, + "readConcern": { + "$$exists": false + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": { + "$$exists": false + }, + "autocommit": false + }, + "commandName": "aggregate", + "databaseName": "transaction-tests" + } + }, + { + "commandStartedEvent": { + "command": { + "getMore": { + "$$type": [ + "int", + "long" + ] + }, + "collection": "test", + "batchSize": 3, + "lsid": { + "$$sessionLsid": "session0" + }, + "readConcern": { + "$$exists": false + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": { + "$$exists": false + }, + "autocommit": false + }, + "commandName": "getMore", + "databaseName": "transaction-tests" + } + }, + { + "commandStartedEvent": { + "command": { + "commitTransaction": 1, + "lsid": { + "$$sessionLsid": "session0" + }, + "readConcern": { + "$$exists": false + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": { + "$$exists": false + }, + "autocommit": false, + "writeConcern": { + "$$exists": false + } + }, + "commandName": "commitTransaction", + "databaseName": "admin" + } + } + ] + } + ], + "outcome": [ + { + "collectionName": "test", + "databaseName": "transaction-tests", + "documents": [ + { + "_id": 1 + }, + { + "_id": 2 + }, + { + "_id": 3 + }, + { + "_id": 4 + } + ] + } + ] + }, + { + "description": "only first distinct includes readConcern", + "operations": [ + { + "object": "session0", + "name": "startTransaction", + "arguments": { + "readConcern": { + "level": "majority" + } + } + }, + { + "object": "collection_rc_majority", + "name": "distinct", + "arguments": { + "fieldName": "_id", + "filter": {}, + "session": "session0" + }, + "expectResult": [ + 1, + 2, + 3, + 4 + ] + }, + { + "object": "collection_rc_majority", + "name": "distinct", + "arguments": { + "fieldName": "_id", + "filter": {}, + "session": "session0" + }, + "expectResult": [ + 1, + 2, + 3, + 4 + ] + }, + { + "object": "session0", + "name": "commitTransaction" + } + ], + "expectEvents": [ + { + "client": "client0", + "events": [ + { + "commandStartedEvent": { + "command": { + "distinct": "test", + "key": "_id", + "lsid": { + "$$sessionLsid": "session0" + }, + "readConcern": { + "level": "majority" + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": true, + "autocommit": false, + "writeConcern": { + "$$exists": false + } + }, + "commandName": "distinct", + "databaseName": "transaction-tests" + } + }, + { + "commandStartedEvent": { + "command": { + "distinct": "test", + "key": "_id", + "lsid": { + "$$sessionLsid": "session0" + }, + "readConcern": { + "$$exists": false + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": { + "$$exists": false + }, + "autocommit": false, + "writeConcern": { + "$$exists": false + } + }, + "commandName": "distinct", + "databaseName": "transaction-tests" + } + }, + { + "commandStartedEvent": { + "command": { + "commitTransaction": 1, + "lsid": { + "$$sessionLsid": "session0" + }, + "readConcern": { + "$$exists": false + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": { + "$$exists": false + }, + "autocommit": false, + "writeConcern": { + "$$exists": false + } + }, + "commandName": "commitTransaction", + "databaseName": "admin" + } + } + ] + } + ], + "outcome": [ + { + "collectionName": "test", + "databaseName": "transaction-tests", + "documents": [ + { + "_id": 1 + }, + { + "_id": 2 + }, + { + "_id": 3 + }, + { + "_id": 4 + } + ] + } + ] + }, + { + "description": "only first runCommand includes readConcern", + "operations": [ + { + "object": "session0", + "name": "startTransaction", + "arguments": { + "readConcern": { + "level": "majority" + } + } + }, + { + "object": "database0", + "name": "runCommand", + "arguments": { + "session": "session0", + "command": { + "find": "test" + }, + "commandName": "find" + } + }, + { + "object": "database0", + "name": "runCommand", + "arguments": { + "session": "session0", + "command": { + "find": "test" + }, + "commandName": "find" + } + }, + { + "object": "session0", + "name": "commitTransaction" + } + ], + "expectEvents": [ + { + "client": "client0", + "events": [ + { + "commandStartedEvent": { + "command": { + "find": "test", + "lsid": { + "$$sessionLsid": "session0" + }, + "readConcern": { + "level": "majority" + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": true, + "autocommit": false, + "writeConcern": { + "$$exists": false + } + }, + "commandName": "find", + "databaseName": "transaction-tests" + } + }, + { + "commandStartedEvent": { + "command": { + "find": "test", + "lsid": { + "$$sessionLsid": "session0" + }, + "readConcern": { + "$$exists": false + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": { + "$$exists": false + }, + "autocommit": false, + "writeConcern": { + "$$exists": false + } + }, + "commandName": "find", + "databaseName": "transaction-tests" + } + }, + { + "commandStartedEvent": { + "command": { + "commitTransaction": 1, + "lsid": { + "$$sessionLsid": "session0" + }, + "readConcern": { + "$$exists": false + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": { + "$$exists": false + }, + "autocommit": false, + "writeConcern": { + "$$exists": false + } + }, + "commandName": "commitTransaction", + "databaseName": "admin" + } + } + ] + } + ], + "outcome": [ + { + "collectionName": "test", + "databaseName": "transaction-tests", + "documents": [ + { + "_id": 1 + }, + { + "_id": 2 + }, + { + "_id": 3 + }, + { + "_id": 4 + } + ] + } + ] + }, + { + "description": "countDocuments ignores collection readConcern", + "operations": [ + { + "object": "session0", + "name": "startTransaction" + }, + { + "object": "collection_rc_majority", + "name": "countDocuments", + "arguments": { + "filter": { + "_id": { + "$gte": 2 + } + }, + "session": "session0" + }, + "expectResult": 3 + }, + { + "object": "collection_rc_majority", + "name": "countDocuments", + "arguments": { + "filter": { + "_id": { + "$gte": 2 + } + }, + "session": "session0" + }, + "expectResult": 3 + }, + { + "object": "session0", + "name": "commitTransaction" + } + ], + "expectEvents": [ + { + "client": "client0", + "events": [ + { + "commandStartedEvent": { + "command": { + "aggregate": "test", + "pipeline": [ + { + "$match": { + "_id": { + "$gte": 2 + } + } + }, + { + "$group": { + "_id": 1, + "n": { + "$sum": 1 + } + } + } + ], + "cursor": {}, + "lsid": { + "$$sessionLsid": "session0" + }, + "readConcern": { + "$$exists": false + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": true, + "autocommit": false + }, + "commandName": "aggregate", + "databaseName": "transaction-tests" + } + }, + { + "commandStartedEvent": { + "command": { + "aggregate": "test", + "pipeline": [ + { + "$match": { + "_id": { + "$gte": 2 + } + } + }, + { + "$group": { + "_id": 1, + "n": { + "$sum": 1 + } + } + } + ], + "cursor": {}, + "lsid": { + "$$sessionLsid": "session0" + }, + "readConcern": { + "$$exists": false + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": { + "$$exists": false + }, + "autocommit": false + }, + "commandName": "aggregate", + "databaseName": "transaction-tests" + } + }, + { + "commandStartedEvent": { + "command": { + "commitTransaction": 1, + "lsid": { + "$$sessionLsid": "session0" + }, + "readConcern": { + "$$exists": false + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": { + "$$exists": false + }, + "autocommit": false, + "writeConcern": { + "$$exists": false + } + }, + "commandName": "commitTransaction", + "databaseName": "admin" + } + } + ] + } + ], + "outcome": [ + { + "collectionName": "test", + "databaseName": "transaction-tests", + "documents": [ + { + "_id": 1 + }, + { + "_id": 2 + }, + { + "_id": 3 + }, + { + "_id": 4 + } + ] + } + ] + }, + { + "description": "find ignores collection readConcern", + "operations": [ + { + "object": "session0", + "name": "startTransaction" + }, + { + "object": "collection_rc_majority", + "name": "find", + "arguments": { + "batchSize": 3, + "filter": {}, + "session": "session0" + }, + "expectResult": [ + { + "_id": 1 + }, + { + "_id": 2 + }, + { + "_id": 3 + }, + { + "_id": 4 + } + ] + }, + { + "object": "collection_rc_majority", + "name": "find", + "arguments": { + "batchSize": 3, + "filter": {}, + "session": "session0" + }, + "expectResult": [ + { + "_id": 1 + }, + { + "_id": 2 + }, + { + "_id": 3 + }, + { + "_id": 4 + } + ] + }, + { + "object": "session0", + "name": "commitTransaction" + } + ], + "expectEvents": [ + { + "client": "client0", + "events": [ + { + "commandStartedEvent": { + "command": { + "find": "test", + "batchSize": 3, + "lsid": { + "$$sessionLsid": "session0" + }, + "readConcern": { + "$$exists": false + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": true, + "autocommit": false + }, + "commandName": "find", + "databaseName": "transaction-tests" + } + }, + { + "commandStartedEvent": { + "command": { + "getMore": { + "$$type": [ + "int", + "long" + ] + }, + "collection": "test", + "batchSize": 3, + "lsid": { + "$$sessionLsid": "session0" + }, + "readConcern": { + "$$exists": false + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": { + "$$exists": false + }, + "autocommit": false + }, + "commandName": "getMore", + "databaseName": "transaction-tests" + } + }, + { + "commandStartedEvent": { + "command": { + "find": "test", + "batchSize": 3, + "lsid": { + "$$sessionLsid": "session0" + }, + "readConcern": { + "$$exists": false + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": { + "$$exists": false + }, + "autocommit": false + }, + "commandName": "find", + "databaseName": "transaction-tests" + } + }, + { + "commandStartedEvent": { + "command": { + "getMore": { + "$$type": [ + "int", + "long" + ] + }, + "collection": "test", + "batchSize": 3, + "lsid": { + "$$sessionLsid": "session0" + }, + "readConcern": { + "$$exists": false + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": { + "$$exists": false + }, + "autocommit": false + }, + "commandName": "getMore", + "databaseName": "transaction-tests" + } + }, + { + "commandStartedEvent": { + "command": { + "commitTransaction": 1, + "lsid": { + "$$sessionLsid": "session0" + }, + "readConcern": { + "$$exists": false + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": { + "$$exists": false + }, + "autocommit": false, + "writeConcern": { + "$$exists": false + } + }, + "commandName": "commitTransaction", + "databaseName": "admin" + } + } + ] + } + ], + "outcome": [ + { + "collectionName": "test", + "databaseName": "transaction-tests", + "documents": [ + { + "_id": 1 + }, + { + "_id": 2 + }, + { + "_id": 3 + }, + { + "_id": 4 + } + ] + } + ] + }, + { + "description": "aggregate ignores collection readConcern", + "operations": [ + { + "object": "session0", + "name": "startTransaction" + }, + { + "object": "collection_rc_majority", + "name": "aggregate", + "arguments": { + "pipeline": [ + { + "$project": { + "_id": 1 + } + } + ], + "batchSize": 3, + "session": "session0" + }, + "expectResult": [ + { + "_id": 1 + }, + { + "_id": 2 + }, + { + "_id": 3 + }, + { + "_id": 4 + } + ] + }, + { + "object": "collection_rc_majority", + "name": "aggregate", + "arguments": { + "pipeline": [ + { + "$project": { + "_id": 1 + } + } + ], + "batchSize": 3, + "session": "session0" + }, + "expectResult": [ + { + "_id": 1 + }, + { + "_id": 2 + }, + { + "_id": 3 + }, + { + "_id": 4 + } + ] + }, + { + "object": "session0", + "name": "commitTransaction" + } + ], + "expectEvents": [ + { + "client": "client0", + "events": [ + { + "commandStartedEvent": { + "command": { + "aggregate": "test", + "pipeline": [ + { + "$project": { + "_id": 1 + } + } + ], + "cursor": { + "batchSize": 3 + }, + "lsid": { + "$$sessionLsid": "session0" + }, + "readConcern": { + "$$exists": false + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": true, + "autocommit": false + }, + "commandName": "aggregate", + "databaseName": "transaction-tests" + } + }, + { + "commandStartedEvent": { + "command": { + "getMore": { + "$$type": [ + "int", + "long" + ] + }, + "collection": "test", + "batchSize": 3, + "lsid": { + "$$sessionLsid": "session0" + }, + "readConcern": { + "$$exists": false + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": { + "$$exists": false + }, + "autocommit": false + }, + "commandName": "getMore", + "databaseName": "transaction-tests" + } + }, + { + "commandStartedEvent": { + "command": { + "aggregate": "test", + "pipeline": [ + { + "$project": { + "_id": 1 + } + } + ], + "cursor": { + "batchSize": 3 + }, + "lsid": { + "$$sessionLsid": "session0" + }, + "readConcern": { + "$$exists": false + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": { + "$$exists": false + }, + "autocommit": false + }, + "commandName": "aggregate", + "databaseName": "transaction-tests" + } + }, + { + "commandStartedEvent": { + "command": { + "getMore": { + "$$type": [ + "int", + "long" + ] + }, + "collection": "test", + "batchSize": 3, + "lsid": { + "$$sessionLsid": "session0" + }, + "readConcern": { + "$$exists": false + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": { + "$$exists": false + }, + "autocommit": false + }, + "commandName": "getMore", + "databaseName": "transaction-tests" + } + }, + { + "commandStartedEvent": { + "command": { + "commitTransaction": 1, + "lsid": { + "$$sessionLsid": "session0" + }, + "readConcern": { + "$$exists": false + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": { + "$$exists": false + }, + "autocommit": false, + "writeConcern": { + "$$exists": false + } + }, + "commandName": "commitTransaction", + "databaseName": "admin" + } + } + ] + } + ], + "outcome": [ + { + "collectionName": "test", + "databaseName": "transaction-tests", + "documents": [ + { + "_id": 1 + }, + { + "_id": 2 + }, + { + "_id": 3 + }, + { + "_id": 4 + } + ] + } + ] + }, + { + "description": "distinct ignores collection readConcern", + "operations": [ + { + "object": "session0", + "name": "startTransaction" + }, + { + "object": "collection_rc_majority", + "name": "distinct", + "arguments": { + "fieldName": "_id", + "filter": {}, + "session": "session0" + }, + "expectResult": [ + 1, + 2, + 3, + 4 + ] + }, + { + "object": "collection_rc_majority", + "name": "distinct", + "arguments": { + "fieldName": "_id", + "filter": {}, + "session": "session0" + }, + "expectResult": [ + 1, + 2, + 3, + 4 + ] + }, + { + "object": "session0", + "name": "commitTransaction" + } + ], + "expectEvents": [ + { + "client": "client0", + "events": [ + { + "commandStartedEvent": { + "command": { + "distinct": "test", + "key": "_id", + "lsid": { + "$$sessionLsid": "session0" + }, + "readConcern": { + "$$exists": false + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": true, + "autocommit": false, + "writeConcern": { + "$$exists": false + } + }, + "commandName": "distinct", + "databaseName": "transaction-tests" + } + }, + { + "commandStartedEvent": { + "command": { + "distinct": "test", + "key": "_id", + "lsid": { + "$$sessionLsid": "session0" + }, + "readConcern": { + "$$exists": false + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": { + "$$exists": false + }, + "autocommit": false, + "writeConcern": { + "$$exists": false + } + }, + "commandName": "distinct", + "databaseName": "transaction-tests" + } + }, + { + "commandStartedEvent": { + "command": { + "commitTransaction": 1, + "lsid": { + "$$sessionLsid": "session0" + }, + "readConcern": { + "$$exists": false + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": { + "$$exists": false + }, + "autocommit": false, + "writeConcern": { + "$$exists": false + } + }, + "commandName": "commitTransaction", + "databaseName": "admin" + } + } + ] + } + ], + "outcome": [ + { + "collectionName": "test", + "databaseName": "transaction-tests", + "documents": [ + { + "_id": 1 + }, + { + "_id": 2 + }, + { + "_id": 3 + }, + { + "_id": 4 + } + ] + } + ] + }, + { + "description": "runCommand ignores database readConcern", + "operations": [ + { + "object": "session0", + "name": "startTransaction" + }, + { + "object": "database_rc_majority", + "name": "runCommand", + "arguments": { + "session": "session0", + "command": { + "find": "test" + }, + "commandName": "find" + } + }, + { + "object": "database0", + "name": "runCommand", + "arguments": { + "session": "session0", + "command": { + "find": "test" + }, + "commandName": "find" + } + }, + { + "object": "session0", + "name": "commitTransaction" + } + ], + "expectEvents": [ + { + "client": "client0", + "events": [ + { + "commandStartedEvent": { + "command": { + "find": "test", + "lsid": { + "$$sessionLsid": "session0" + }, + "readConcern": { + "$$exists": false + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": true, + "autocommit": false, + "writeConcern": { + "$$exists": false + } + }, + "commandName": "find", + "databaseName": "transaction-tests" + } + }, + { + "commandStartedEvent": { + "command": { + "find": "test", + "lsid": { + "$$sessionLsid": "session0" + }, + "readConcern": { + "$$exists": false + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": { + "$$exists": false + }, + "autocommit": false, + "writeConcern": { + "$$exists": false + } + }, + "commandName": "find", + "databaseName": "transaction-tests" + } + }, + { + "commandStartedEvent": { + "command": { + "commitTransaction": 1, + "lsid": { + "$$sessionLsid": "session0" + }, + "readConcern": { + "$$exists": false + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": { + "$$exists": false + }, + "autocommit": false, + "writeConcern": { + "$$exists": false + } + }, + "commandName": "commitTransaction", + "databaseName": "admin" + } + } + ] + } + ], + "outcome": [ + { + "collectionName": "test", + "databaseName": "transaction-tests", + "documents": [ + { + "_id": 1 + }, + { + "_id": 2 + }, + { + "_id": 3 + }, + { + "_id": 4 + } + ] + } + ] + } + ] +} diff --git a/source/transactions/tests/unified/read-concern.yml b/source/transactions/tests/unified/read-concern.yml new file mode 100644 index 0000000000..3eff32a0dc --- /dev/null +++ b/source/transactions/tests/unified/read-concern.yml @@ -0,0 +1,634 @@ +description: read-concern + +schemaVersion: '1.3' + +runOnRequirements: + - + minServerVersion: '4.0' + topologies: + - replicaset + - + minServerVersion: 4.1.8 + topologies: + - sharded + - load-balanced + +createEntities: + - + client: + id: &client0 client0 + useMultipleMongoses: false + observeEvents: + - commandStartedEvent + - + database: + id: &database0 database0 + client: *client0 + databaseName: &database_name transaction-tests + - + database: + id: &database_rc_majority database_rc_majority + client: *client0 + databaseName: &database_name transaction-tests + databaseOptions: + readConcern: { level: majority } + - + collection: + id: &collection_rc_majority collection_rc_majority + database: *database0 + collectionName: &collection_name test + collectionOptions: + readConcern: { level: majority } + - + session: + id: &session0 session0 + client: *client0 + +initialData: + - + collectionName: *collection_name + databaseName: *database_name + documents: &data + - { _id: 1 } + - { _id: 2 } + - { _id: 3 } + - { _id: 4 } + +tests: + - + description: 'only first countDocuments includes readConcern' + operations: + - &startTransaction + object: *session0 + name: startTransaction + arguments: + readConcern: + level: majority + - &countDocuments + object: *collection_rc_majority + name: countDocuments + arguments: + filter: { _id: { $gte: 2 } } + session: *session0 + expectResult: 3 + - *countDocuments + - &commitTransaction + object: *session0 + name: commitTransaction + expectEvents: + - + client: *client0 + events: + - + commandStartedEvent: + command: + aggregate: *collection_name + pipeline: + - { $match: { _id: { $gte: 2 } } } + - { $group: { _id: 1, n: { $sum: 1 } } } + cursor: { } + lsid: { $$sessionLsid: *session0 } + readConcern: + level: majority + txnNumber: { $numberLong: '1' } + startTransaction: true + autocommit: false + commandName: aggregate + databaseName: *database_name + - + commandStartedEvent: + command: + aggregate: *collection_name + pipeline: + - { $match: { _id: { $gte: 2 } } } + - { $group: { _id: 1, n: { $sum: 1 } } } + cursor: { } + lsid: { $$sessionLsid: *session0 } + readConcern: { $$exists: false } + txnNumber: { $numberLong: '1' } + startTransaction: { $$exists: false } + autocommit: false + commandName: aggregate + databaseName: *database_name + - &commitTransactionEvent + commandStartedEvent: + command: + commitTransaction: 1 + lsid: { $$sessionLsid: *session0 } + readConcern: { $$exists: false } + txnNumber: { $numberLong: '1' } + startTransaction: { $$exists: false } + autocommit: false + writeConcern: { $$exists: false } + commandName: commitTransaction + databaseName: admin + outcome: &outcome + - + collectionName: *collection_name + databaseName: *database_name + documents: *data + - + description: 'only first find includes readConcern' + operations: + - *startTransaction + - &find + object: *collection_rc_majority + name: find + arguments: + batchSize: 3 + filter: {} + session: *session0 + expectResult: *data + - *find + - *commitTransaction + expectEvents: + - + client: *client0 + events: + - + commandStartedEvent: + command: + find: *collection_name + batchSize: 3 + lsid: { $$sessionLsid: *session0 } + readConcern: + level: majority + txnNumber: { $numberLong: '1' } + startTransaction: true + autocommit: false + commandName: find + databaseName: *database_name + - + commandStartedEvent: + command: + getMore: { $$type: [ int, long ] } + collection: *collection_name + batchSize: 3 + lsid: { $$sessionLsid: *session0 } + readConcern: { $$exists: false } + txnNumber: { $numberLong: '1' } + startTransaction: { $$exists: false } + autocommit: false + commandName: getMore + databaseName: *database_name + - + commandStartedEvent: + command: + find: *collection_name + batchSize: 3 + lsid: { $$sessionLsid: *session0 } + readConcern: { $$exists: false } + txnNumber: { $numberLong: '1' } + startTransaction: { $$exists: false } + autocommit: false + commandName: find + databaseName: *database_name + - + commandStartedEvent: + command: + getMore: { $$type: [ int, long ] } + collection: *collection_name + batchSize: 3 + lsid: { $$sessionLsid: *session0 } + readConcern: { $$exists: false } + txnNumber: { $numberLong: '1' } + startTransaction: { $$exists: false } + autocommit: false + commandName: getMore + databaseName: *database_name + - *commitTransactionEvent + outcome: &outcome + - + collectionName: *collection_name + databaseName: *database_name + documents: *data + - + description: 'only first aggregate includes readConcern' + operations: + - *startTransaction + - &aggregate + object: *collection_rc_majority + name: aggregate + arguments: + pipeline: + - { $project: { _id: 1 } } + batchSize: 3 + session: *session0 + expectResult: *data + - *aggregate + - *commitTransaction + expectEvents: + - + client: *client0 + events: + - + commandStartedEvent: + command: + aggregate: *collection_name + pipeline: + - { $project: { _id: 1 } } + cursor: + batchSize: 3 + lsid: { $$sessionLsid: *session0 } + readConcern: + level: majority + txnNumber: { $numberLong: '1' } + startTransaction: true + autocommit: false + commandName: aggregate + databaseName: *database_name + - + commandStartedEvent: + command: + getMore: { $$type: [ int, long ] } + collection: *collection_name + batchSize: 3 + lsid: { $$sessionLsid: *session0 } + readConcern: { $$exists: false } + txnNumber: { $numberLong: '1' } + startTransaction: { $$exists: false } + autocommit: false + commandName: getMore + databaseName: *database_name + - + commandStartedEvent: + command: + aggregate: *collection_name + pipeline: + - { $project: { _id: 1 } } + cursor: + batchSize: 3 + lsid: { $$sessionLsid: *session0 } + readConcern: { $$exists: false } + txnNumber: { $numberLong: '1' } + startTransaction: { $$exists: false } + autocommit: false + commandName: aggregate + databaseName: *database_name + - + commandStartedEvent: + command: + getMore: { $$type: [ int, long ] } + collection: *collection_name + batchSize: 3 + lsid: { $$sessionLsid: *session0 } + readConcern: { $$exists: false } + txnNumber: { $numberLong: '1' } + startTransaction: { $$exists: false } + autocommit: false + commandName: getMore + databaseName: *database_name + - *commitTransactionEvent + outcome: *outcome + - + description: 'only first distinct includes readConcern' + operations: + - *startTransaction + - &distinct + object: *collection_rc_majority + name: distinct + arguments: + fieldName: _id + filter: {} + session: *session0 + expectResult: [ 1, 2, 3, 4 ] + - *distinct + - *commitTransaction + expectEvents: + - + client: *client0 + events: + - + commandStartedEvent: + command: + distinct: *collection_name + key: _id + lsid: { $$sessionLsid: *session0 } + readConcern: + level: majority + txnNumber: { $numberLong: '1' } + startTransaction: true + autocommit: false + writeConcern: { $$exists: false } + commandName: distinct + databaseName: *database_name + - + commandStartedEvent: + command: + distinct: *collection_name + key: _id + lsid: { $$sessionLsid: *session0 } + readConcern: { $$exists: false } + txnNumber: { $numberLong: '1' } + startTransaction: { $$exists: false } + autocommit: false + writeConcern: { $$exists: false } + commandName: distinct + databaseName: *database_name + - *commitTransactionEvent + outcome: *outcome + - + description: 'only first runCommand includes readConcern' + operations: + - *startTransaction + - &runCommand + object: *database0 + name: runCommand + arguments: + session: *session0 + command: + find: *collection_name + commandName: find + - *runCommand + - *commitTransaction + expectEvents: + - + client: *client0 + events: + - + commandStartedEvent: + command: + find: *collection_name + lsid: { $$sessionLsid: *session0 } + readConcern: + level: majority + txnNumber: { $numberLong: '1' } + startTransaction: true + autocommit: false + writeConcern: { $$exists: false } + commandName: find + databaseName: *database_name + - + commandStartedEvent: + command: + find: *collection_name + lsid: { $$sessionLsid: *session0 } + readConcern: { $$exists: false } + txnNumber: { $numberLong: '1' } + startTransaction: { $$exists: false } + autocommit: false + writeConcern: { $$exists: false } + commandName: find + databaseName: *database_name + - *commitTransactionEvent + outcome: *outcome + - + description: 'countDocuments ignores collection readConcern' + operations: + - &startTransactionNoReadConcern + object: *session0 + name: startTransaction + - *countDocuments + - *countDocuments + - *commitTransaction + expectEvents: + - + client: *client0 + events: + - + commandStartedEvent: + command: + aggregate: *collection_name + pipeline: + - { $match: { _id: { $gte: 2 } } } + - { $group: { _id: 1, n: { $sum: 1 } } } + cursor: { } + lsid: { $$sessionLsid: *session0 } + readConcern: { $$exists: false } + txnNumber: { $numberLong: '1' } + startTransaction: true + autocommit: false + commandName: aggregate + databaseName: *database_name + - + commandStartedEvent: + command: + aggregate: *collection_name + pipeline: + - { $match: { _id: { $gte: 2 } } } + - { $group: { _id: 1, n: { $sum: 1 } } } + cursor: { } + lsid: { $$sessionLsid: *session0 } + readConcern: { $$exists: false } + txnNumber: { $numberLong: '1' } + startTransaction: { $$exists: false } + autocommit: false + commandName: aggregate + databaseName: *database_name + - *commitTransactionEvent + outcome: *outcome + - + description: 'find ignores collection readConcern' + operations: + - *startTransactionNoReadConcern + - *find + - *find + - *commitTransaction + expectEvents: + - + client: *client0 + events: + - + commandStartedEvent: + command: + find: *collection_name + batchSize: 3 + lsid: { $$sessionLsid: *session0 } + readConcern: { $$exists: false } + txnNumber: { $numberLong: '1' } + startTransaction: true + autocommit: false + commandName: find + databaseName: *database_name + - + commandStartedEvent: + command: + getMore: { $$type: [ int, long ] } + collection: *collection_name + batchSize: 3 + lsid: { $$sessionLsid: *session0 } + readConcern: { $$exists: false } + txnNumber: { $numberLong: '1' } + startTransaction: { $$exists: false } + autocommit: false + commandName: getMore + databaseName: *database_name + - + commandStartedEvent: + command: + find: *collection_name + batchSize: 3 + lsid: { $$sessionLsid: *session0 } + readConcern: { $$exists: false } + txnNumber: { $numberLong: '1' } + startTransaction: { $$exists: false } + autocommit: false + commandName: find + databaseName: *database_name + - + commandStartedEvent: + command: + getMore: { $$type: [ int, long ] } + collection: *collection_name + batchSize: 3 + lsid: { $$sessionLsid: *session0 } + readConcern: { $$exists: false } + txnNumber: { $numberLong: '1' } + startTransaction: { $$exists: false } + autocommit: false + commandName: getMore + databaseName: *database_name + - *commitTransactionEvent + outcome: *outcome + - + description: 'aggregate ignores collection readConcern' + operations: + - *startTransactionNoReadConcern + - *aggregate + - *aggregate + - *commitTransaction + expectEvents: + - + client: *client0 + events: + - + commandStartedEvent: + command: + aggregate: *collection_name + pipeline: + - { $project: { _id: 1 } } + cursor: + batchSize: 3 + lsid: { $$sessionLsid: *session0 } + readConcern: { $$exists: false } + txnNumber: { $numberLong: '1' } + startTransaction: true + autocommit: false + commandName: aggregate + databaseName: *database_name + - + commandStartedEvent: + command: + getMore: { $$type: [ int, long ] } + collection: *collection_name + batchSize: 3 + lsid: { $$sessionLsid: *session0 } + readConcern: { $$exists: false } + txnNumber: { $numberLong: '1' } + startTransaction: { $$exists: false } + autocommit: false + commandName: getMore + databaseName: *database_name + - + commandStartedEvent: + command: + aggregate: *collection_name + pipeline: + - { $project: { _id: 1 } } + cursor: + batchSize: 3 + lsid: { $$sessionLsid: *session0 } + readConcern: { $$exists: false } + txnNumber: { $numberLong: '1' } + startTransaction: { $$exists: false } + autocommit: false + commandName: aggregate + databaseName: *database_name + - + commandStartedEvent: + command: + getMore: { $$type: [ int, long ] } + collection: *collection_name + batchSize: 3 + lsid: { $$sessionLsid: *session0 } + readConcern: { $$exists: false } + txnNumber: { $numberLong: '1' } + startTransaction: { $$exists: false } + autocommit: false + commandName: getMore + databaseName: *database_name + - *commitTransactionEvent + outcome: *outcome + - + description: 'distinct ignores collection readConcern' + operations: + - *startTransactionNoReadConcern + - *distinct + - *distinct + - *commitTransaction + expectEvents: + - + client: *client0 + events: + - + commandStartedEvent: + command: + distinct: *collection_name + key: _id + lsid: { $$sessionLsid: *session0 } + readConcern: { $$exists: false } + txnNumber: { $numberLong: '1' } + startTransaction: true + autocommit: false + writeConcern: { $$exists: false } + commandName: distinct + databaseName: *database_name + - + commandStartedEvent: + command: + distinct: *collection_name + key: _id + lsid: { $$sessionLsid: *session0 } + readConcern: { $$exists: false } + txnNumber: { $numberLong: '1' } + startTransaction: { $$exists: false } + autocommit: false + writeConcern: { $$exists: false } + commandName: distinct + databaseName: *database_name + - *commitTransactionEvent + outcome: *outcome + - + description: 'runCommand ignores database readConcern' + operations: + - *startTransactionNoReadConcern + - + object: *database_rc_majority + name: runCommand + arguments: + session: *session0 + command: + find: *collection_name + commandName: find + - *runCommand + - *commitTransaction + expectEvents: + - + client: *client0 + events: + - + commandStartedEvent: + command: + find: *collection_name + lsid: { $$sessionLsid: *session0 } + readConcern: { $$exists: false } + txnNumber: { $numberLong: '1' } + startTransaction: true + autocommit: false + writeConcern: { $$exists: false } + commandName: find + databaseName: *database_name + - + commandStartedEvent: + command: + find: *collection_name + lsid: { $$sessionLsid: *session0 } + readConcern: { $$exists: false } + txnNumber: { $numberLong: '1' } + startTransaction: { $$exists: false } + autocommit: false + writeConcern: { $$exists: false } + commandName: find + databaseName: *database_name + - *commitTransactionEvent + outcome: *outcome \ No newline at end of file diff --git a/source/transactions/tests/legacy/read-pref.json b/source/transactions/tests/unified/read-pref.json similarity index 63% rename from source/transactions/tests/legacy/read-pref.json rename to source/transactions/tests/unified/read-pref.json index f06a72246a..eda00bd10d 100644 --- a/source/transactions/tests/legacy/read-pref.json +++ b/source/transactions/tests/unified/read-pref.json @@ -1,33 +1,84 @@ { - "runOn": [ + "description": "read-pref", + "schemaVersion": "1.3", + "runOnRequirements": [ { "minServerVersion": "4.0", - "topology": [ + "topologies": [ "replicaset" ] }, { "minServerVersion": "4.1.8", - "topology": [ + "topologies": [ "sharded", "load-balanced" ] } ], - "database_name": "transaction-tests", - "collection_name": "test", - "data": [], + "createEntities": [ + { + "client": { + "id": "client0", + "useMultipleMongoses": false, + "observeEvents": [ + "commandStartedEvent" + ] + } + }, + { + "database": { + "id": "database0", + "client": "client0", + "databaseName": "transaction-tests" + } + }, + { + "collection": { + "id": "collection0", + "database": "database0", + "collectionName": "test" + } + }, + { + "collection": { + "id": "collection_rp_primary", + "database": "database0", + "collectionName": "test" + } + }, + { + "collection": { + "id": "collection_rp_secondary", + "database": "database0", + "collectionName": "test" + } + }, + { + "session": { + "id": "session0", + "client": "client0" + } + } + ], + "initialData": [ + { + "collectionName": "test", + "databaseName": "transaction-tests", + "documents": [] + } + ], "tests": [ { "description": "default readPreference", "operations": [ { - "name": "startTransaction", - "object": "session0" + "object": "session0", + "name": "startTransaction" }, { + "object": "collection0", "name": "insertMany", - "object": "collection", "arguments": { "documents": [ { @@ -45,23 +96,22 @@ ], "session": "session0" }, - "result": { - "insertedIds": { - "0": 1, - "1": 2, - "2": 3, - "3": 4 + "expectResult": { + "$$unsetOrMatches": { + "insertedIds": { + "$$unsetOrMatches": { + "0": 1, + "1": 2, + "2": 3, + "3": 4 + } + } } } }, { + "object": "collection_rp_secondary", "name": "aggregate", - "object": "collection", - "collectionOptions": { - "readPreference": { - "mode": "Secondary" - } - }, "arguments": { "session": "session0", "pipeline": [ @@ -75,25 +125,21 @@ } ] }, - "result": [ + "expectResult": [ { "count": 1 } ] }, { + "object": "collection_rp_secondary", "name": "find", - "object": "collection", - "collectionOptions": { - "readPreference": { - "mode": "Secondary" - } - }, "arguments": { - "session": "session0", - "batchSize": 3 + "batchSize": 3, + "filter": {}, + "session": "session0" }, - "result": [ + "expectResult": [ { "_id": 1 }, @@ -109,13 +155,8 @@ ] }, { + "object": "collection_rp_secondary", "name": "aggregate", - "object": "collection", - "collectionOptions": { - "readPreference": { - "mode": "Secondary" - } - }, "arguments": { "pipeline": [ { @@ -127,7 +168,7 @@ "batchSize": 3, "session": "session0" }, - "result": [ + "expectResult": [ { "_id": 1 }, @@ -143,13 +184,15 @@ ] }, { - "name": "commitTransaction", - "object": "session0" + "object": "session0", + "name": "commitTransaction" } ], - "outcome": { - "collection": { - "data": [ + "outcome": [ + { + "collectionName": "test", + "databaseName": "transaction-tests", + "documents": [ { "_id": 1 }, @@ -164,25 +207,23 @@ } ] } - } + ] }, { "description": "primary readPreference", "operations": [ { - "name": "startTransaction", "object": "session0", + "name": "startTransaction", "arguments": { - "options": { - "readPreference": { - "mode": "Primary" - } + "readPreference": { + "mode": "primary" } } }, { + "object": "collection0", "name": "insertMany", - "object": "collection", "arguments": { "documents": [ { @@ -200,23 +241,22 @@ ], "session": "session0" }, - "result": { - "insertedIds": { - "0": 1, - "1": 2, - "2": 3, - "3": 4 + "expectResult": { + "$$unsetOrMatches": { + "insertedIds": { + "$$unsetOrMatches": { + "0": 1, + "1": 2, + "2": 3, + "3": 4 + } + } } } }, { + "object": "collection_rp_secondary", "name": "aggregate", - "object": "collection", - "collectionOptions": { - "readPreference": { - "mode": "Secondary" - } - }, "arguments": { "session": "session0", "pipeline": [ @@ -230,25 +270,21 @@ } ] }, - "result": [ + "expectResult": [ { "count": 1 } ] }, { + "object": "collection_rp_secondary", "name": "find", - "object": "collection", - "collectionOptions": { - "readPreference": { - "mode": "Secondary" - } - }, "arguments": { - "session": "session0", - "batchSize": 3 + "batchSize": 3, + "filter": {}, + "session": "session0" }, - "result": [ + "expectResult": [ { "_id": 1 }, @@ -264,13 +300,8 @@ ] }, { + "object": "collection_rp_secondary", "name": "aggregate", - "object": "collection", - "collectionOptions": { - "readPreference": { - "mode": "Secondary" - } - }, "arguments": { "pipeline": [ { @@ -282,7 +313,7 @@ "batchSize": 3, "session": "session0" }, - "result": [ + "expectResult": [ { "_id": 1 }, @@ -298,13 +329,15 @@ ] }, { - "name": "commitTransaction", - "object": "session0" + "object": "session0", + "name": "commitTransaction" } ], - "outcome": { - "collection": { - "data": [ + "outcome": [ + { + "collectionName": "test", + "databaseName": "transaction-tests", + "documents": [ { "_id": 1 }, @@ -319,25 +352,23 @@ } ] } - } + ] }, { "description": "secondary readPreference", "operations": [ { - "name": "startTransaction", "object": "session0", + "name": "startTransaction", "arguments": { - "options": { - "readPreference": { - "mode": "Secondary" - } + "readPreference": { + "mode": "secondary" } } }, { + "object": "collection0", "name": "insertMany", - "object": "collection", "arguments": { "documents": [ { @@ -355,23 +386,22 @@ ], "session": "session0" }, - "result": { - "insertedIds": { - "0": 1, - "1": 2, - "2": 3, - "3": 4 + "expectResult": { + "$$unsetOrMatches": { + "insertedIds": { + "$$unsetOrMatches": { + "0": 1, + "1": 2, + "2": 3, + "3": 4 + } + } } } }, { + "object": "collection_rp_primary", "name": "aggregate", - "object": "collection", - "collectionOptions": { - "readPreference": { - "mode": "Primary" - } - }, "arguments": { "session": "session0", "pipeline": [ @@ -385,34 +415,25 @@ } ] }, - "result": { + "expectError": { "errorContains": "read preference in a transaction must be primary" } }, { + "object": "collection_rp_primary", "name": "find", - "object": "collection", - "collectionOptions": { - "readPreference": { - "mode": "Primary" - } - }, "arguments": { - "session": "session0", - "batchSize": 3 + "batchSize": 3, + "filter": {}, + "session": "session0" }, - "result": { + "expectError": { "errorContains": "read preference in a transaction must be primary" } }, { + "object": "collection_rp_primary", "name": "aggregate", - "object": "collection", - "collectionOptions": { - "readPreference": { - "mode": "Primary" - } - }, "arguments": { "pipeline": [ { @@ -424,38 +445,38 @@ "batchSize": 3, "session": "session0" }, - "result": { + "expectError": { "errorContains": "read preference in a transaction must be primary" } }, { - "name": "abortTransaction", - "object": "session0" + "object": "session0", + "name": "abortTransaction" } ], - "outcome": { - "collection": { - "data": [] + "outcome": [ + { + "collectionName": "test", + "databaseName": "transaction-tests", + "documents": [] } - } + ] }, { "description": "primaryPreferred readPreference", "operations": [ { - "name": "startTransaction", "object": "session0", + "name": "startTransaction", "arguments": { - "options": { - "readPreference": { - "mode": "PrimaryPreferred" - } + "readPreference": { + "mode": "primaryPreferred" } } }, { + "object": "collection0", "name": "insertMany", - "object": "collection", "arguments": { "documents": [ { @@ -473,23 +494,22 @@ ], "session": "session0" }, - "result": { - "insertedIds": { - "0": 1, - "1": 2, - "2": 3, - "3": 4 + "expectResult": { + "$$unsetOrMatches": { + "insertedIds": { + "$$unsetOrMatches": { + "0": 1, + "1": 2, + "2": 3, + "3": 4 + } + } } } }, { + "object": "collection_rp_primary", "name": "aggregate", - "object": "collection", - "collectionOptions": { - "readPreference": { - "mode": "Primary" - } - }, "arguments": { "session": "session0", "pipeline": [ @@ -503,34 +523,25 @@ } ] }, - "result": { + "expectError": { "errorContains": "read preference in a transaction must be primary" } }, { + "object": "collection_rp_primary", "name": "find", - "object": "collection", - "collectionOptions": { - "readPreference": { - "mode": "Primary" - } - }, "arguments": { - "session": "session0", - "batchSize": 3 + "batchSize": 3, + "filter": {}, + "session": "session0" }, - "result": { + "expectError": { "errorContains": "read preference in a transaction must be primary" } }, { + "object": "collection_rp_primary", "name": "aggregate", - "object": "collection", - "collectionOptions": { - "readPreference": { - "mode": "Primary" - } - }, "arguments": { "pipeline": [ { @@ -542,38 +553,38 @@ "batchSize": 3, "session": "session0" }, - "result": { + "expectError": { "errorContains": "read preference in a transaction must be primary" } }, { - "name": "abortTransaction", - "object": "session0" + "object": "session0", + "name": "abortTransaction" } ], - "outcome": { - "collection": { - "data": [] + "outcome": [ + { + "collectionName": "test", + "databaseName": "transaction-tests", + "documents": [] } - } + ] }, { "description": "nearest readPreference", "operations": [ { - "name": "startTransaction", "object": "session0", + "name": "startTransaction", "arguments": { - "options": { - "readPreference": { - "mode": "Nearest" - } + "readPreference": { + "mode": "nearest" } } }, { + "object": "collection0", "name": "insertMany", - "object": "collection", "arguments": { "documents": [ { @@ -591,23 +602,22 @@ ], "session": "session0" }, - "result": { - "insertedIds": { - "0": 1, - "1": 2, - "2": 3, - "3": 4 + "expectResult": { + "$$unsetOrMatches": { + "insertedIds": { + "$$unsetOrMatches": { + "0": 1, + "1": 2, + "2": 3, + "3": 4 + } + } } } }, { + "object": "collection_rp_primary", "name": "aggregate", - "object": "collection", - "collectionOptions": { - "readPreference": { - "mode": "Primary" - } - }, "arguments": { "session": "session0", "pipeline": [ @@ -621,34 +631,25 @@ } ] }, - "result": { + "expectError": { "errorContains": "read preference in a transaction must be primary" } }, { + "object": "collection_rp_primary", "name": "find", - "object": "collection", - "collectionOptions": { - "readPreference": { - "mode": "Primary" - } - }, "arguments": { - "session": "session0", - "batchSize": 3 + "batchSize": 3, + "filter": {}, + "session": "session0" }, - "result": { + "expectError": { "errorContains": "read preference in a transaction must be primary" } }, { + "object": "collection_rp_primary", "name": "aggregate", - "object": "collection", - "collectionOptions": { - "readPreference": { - "mode": "Primary" - } - }, "arguments": { "pipeline": [ { @@ -660,62 +661,68 @@ "batchSize": 3, "session": "session0" }, - "result": { + "expectError": { "errorContains": "read preference in a transaction must be primary" } }, { - "name": "abortTransaction", - "object": "session0" + "object": "session0", + "name": "abortTransaction" } ], - "outcome": { - "collection": { - "data": [] + "outcome": [ + { + "collectionName": "test", + "databaseName": "transaction-tests", + "documents": [] } - } + ] }, { "description": "secondary write only", "operations": [ { - "name": "startTransaction", "object": "session0", + "name": "startTransaction", "arguments": { - "options": { - "readPreference": { - "mode": "Secondary" - } + "readPreference": { + "mode": "secondary" } } }, { + "object": "collection0", "name": "insertOne", - "object": "collection", "arguments": { "session": "session0", "document": { "_id": 1 } }, - "result": { - "insertedId": 1 + "expectResult": { + "$$unsetOrMatches": { + "insertedId": { + "$$unsetOrMatches": 1 + } + } } }, { - "name": "commitTransaction", - "object": "session0" + "object": "session0", + "name": "commitTransaction" } ], - "outcome": { - "collection": { - "data": [ + "outcome": [ + { + "collectionName": "test", + "databaseName": "transaction-tests", + "documents": [ { "_id": 1 } ] } - } + ] } ] } diff --git a/source/transactions/tests/unified/read-pref.yml b/source/transactions/tests/unified/read-pref.yml new file mode 100644 index 0000000000..5217fea471 --- /dev/null +++ b/source/transactions/tests/unified/read-pref.yml @@ -0,0 +1,394 @@ +# This test doesn't check contents of command-started events. +description: read-pref + +schemaVersion: '1.3' + +runOnRequirements: + - + minServerVersion: '4.0' + topologies: + - replicaset + - + minServerVersion: 4.1.8 + topologies: + - sharded + - load-balanced + +createEntities: + - + client: + id: &client0 client0 + useMultipleMongoses: false + observeEvents: + - commandStartedEvent + - + database: + id: &database0 database0 + client: *client0 + databaseName: &database_name transaction-tests + - + collection: + id: &collection0 collection0 + database: *database0 + collectionName: &collection_name test + - + collection: + id: &collection_rp_primary collection_rp_primary + database: *database0 + collectionName: *collection_name + - + collection: + id: &collection_rp_secondary collection_rp_secondary + database: *database0 + collectionName: *collection_name + - + session: + id: &session0 session0 + client: *client0 + +initialData: + - + collectionName: *collection_name + databaseName: *database_name + documents: [] + +tests: + - + description: 'default readPreference' + operations: + - + object: *session0 + name: startTransaction + - + object: *collection0 + name: insertMany + arguments: + documents: &insertedDocs + - { _id: 1 } + - { _id: 2 } + - { _id: 3 } + - { _id: 4 } + session: *session0 + expectResult: + $$unsetOrMatches: + insertedIds: + $$unsetOrMatches: + '0': 1 + '1': 2 + '2': 3 + '3': 4 + - + object: *collection_rp_secondary + name: aggregate + arguments: + session: *session0 + pipeline: + - { $match: { _id: 1 } } + - { $count: count } + expectResult: + - { count: 1 } + - + object: *collection_rp_secondary + name: find + arguments: + batchSize: 3 + filter: {} + session: *session0 + expectResult: *insertedDocs + - + object: *collection_rp_secondary + name: aggregate + arguments: + pipeline: + - { $project: { _id: 1 } } + batchSize: 3 + session: *session0 + expectResult: *insertedDocs + - + object: *session0 + name: commitTransaction + outcome: + - + collectionName: *collection_name + databaseName: *database_name + documents: *insertedDocs + - + description: 'primary readPreference' + operations: + - + object: *session0 + name: startTransaction + arguments: + readPreference: + mode: primary + - + object: *collection0 + name: insertMany + arguments: + documents: &insertedDocs + - { _id: 1 } + - { _id: 2 } + - { _id: 3 } + - { _id: 4 } + session: *session0 + expectResult: + $$unsetOrMatches: + insertedIds: + $$unsetOrMatches: + '0': 1 + '1': 2 + '2': 3 + '3': 4 + - + object: *collection_rp_secondary + name: aggregate + arguments: + session: *session0 + pipeline: + - { $match: { _id: 1 } } + - { $count: count } + expectResult: + - { count: 1 } + - + object: *collection_rp_secondary + name: find + arguments: + batchSize: 3 + filter: {} + session: *session0 + expectResult: *insertedDocs + - + object: *collection_rp_secondary + name: aggregate + arguments: + pipeline: + - { $project: { _id: 1 } } + batchSize: 3 + session: *session0 + expectResult: *insertedDocs + - + object: *session0 + name: commitTransaction + outcome: + - + collectionName: *collection_name + databaseName: *database_name + documents: *insertedDocs + - + description: 'secondary readPreference' + operations: + - + object: *session0 + name: startTransaction + arguments: + readPreference: + mode: secondary + - + object: *collection0 + name: insertMany + arguments: + documents: &insertedDocs + - { _id: 1 } + - { _id: 2 } + - { _id: 3 } + - { _id: 4 } + session: *session0 + expectResult: + $$unsetOrMatches: + insertedIds: + $$unsetOrMatches: + '0': 1 + '1': 2 + '2': 3 + '3': 4 + - + object: *collection_rp_primary + name: aggregate + arguments: + session: *session0 + pipeline: + - { $match: { _id: 1 } } + - { $count: count } + expectError: + errorContains: 'read preference in a transaction must be primary' + - + object: *collection_rp_primary + name: find + arguments: + batchSize: 3 + filter: {} + session: *session0 + expectError: + errorContains: 'read preference in a transaction must be primary' + - + object: *collection_rp_primary + name: aggregate + arguments: + pipeline: + - { $project: { _id: 1 } } + batchSize: 3 + session: *session0 + expectError: + errorContains: 'read preference in a transaction must be primary' + - + object: *session0 + name: abortTransaction + outcome: + - + collectionName: *collection_name + databaseName: *database_name + documents: [] + - + description: 'primaryPreferred readPreference' + operations: + - + object: *session0 + name: startTransaction + arguments: + readPreference: + mode: primaryPreferred + - + object: *collection0 + name: insertMany + arguments: + documents: &insertedDocs + - { _id: 1 } + - { _id: 2 } + - { _id: 3 } + - { _id: 4 } + session: *session0 + expectResult: + $$unsetOrMatches: + insertedIds: + $$unsetOrMatches: + '0': 1 + '1': 2 + '2': 3 + '3': 4 + - + object: *collection_rp_primary + name: aggregate + arguments: + session: *session0 + pipeline: + - { $match: { _id: 1 } } + - { $count: count } + expectError: + errorContains: 'read preference in a transaction must be primary' + - + object: *collection_rp_primary + name: find + arguments: + batchSize: 3 + filter: {} + session: *session0 + expectError: + errorContains: 'read preference in a transaction must be primary' + - + object: *collection_rp_primary + name: aggregate + arguments: + pipeline: + - { $project: { _id: 1 } } + batchSize: 3 + session: *session0 + expectError: + errorContains: 'read preference in a transaction must be primary' + - + object: *session0 + name: abortTransaction + outcome: + - + collectionName: *collection_name + databaseName: *database_name + documents: [] + - + description: 'nearest readPreference' + operations: + - + object: *session0 + name: startTransaction + arguments: + readPreference: + mode: nearest + - + object: *collection0 + name: insertMany + arguments: + documents: &insertedDocs + - { _id: 1 } + - { _id: 2 } + - { _id: 3 } + - { _id: 4 } + session: *session0 + expectResult: + $$unsetOrMatches: + insertedIds: + $$unsetOrMatches: + '0': 1 + '1': 2 + '2': 3 + '3': 4 + - + object: *collection_rp_primary + name: aggregate + arguments: + session: *session0 + pipeline: + - { $match: { _id: 1 } } + - { $count: count } + expectError: + errorContains: 'read preference in a transaction must be primary' + - + object: *collection_rp_primary + name: find + arguments: + batchSize: 3 + filter: {} + session: *session0 + expectError: + errorContains: 'read preference in a transaction must be primary' + - + object: *collection_rp_primary + name: aggregate + arguments: + pipeline: + - { $project: { _id: 1 } } + batchSize: 3 + session: *session0 + expectError: + errorContains: 'read preference in a transaction must be primary' + - + object: *session0 + name: abortTransaction + outcome: + - + collectionName: *collection_name + databaseName: *database_name + documents: [] + - + description: 'secondary write only' + operations: + - + object: *session0 + name: startTransaction + arguments: + readPreference: + mode: secondary + - + object: *collection0 + name: insertOne + arguments: + session: *session0 + document: { _id: 1 } + expectResult: + $$unsetOrMatches: { insertedId: { $$unsetOrMatches: 1 } } + - + object: *session0 + name: commitTransaction + outcome: + - + collectionName: *collection_name + databaseName: *database_name + documents: + - { _id: 1 } diff --git a/source/transactions/tests/unified/reads.json b/source/transactions/tests/unified/reads.json new file mode 100644 index 0000000000..52e8457634 --- /dev/null +++ b/source/transactions/tests/unified/reads.json @@ -0,0 +1,706 @@ +{ + "description": "reads", + "schemaVersion": "1.9", + "runOnRequirements": [ + { + "minServerVersion": "4.0", + "topologies": [ + "replicaset" + ] + }, + { + "minServerVersion": "4.1.8", + "topologies": [ + "sharded", + "load-balanced" + ] + } + ], + "createEntities": [ + { + "client": { + "id": "client0", + "useMultipleMongoses": false, + "observeEvents": [ + "commandStartedEvent" + ] + } + }, + { + "database": { + "id": "database0", + "client": "client0", + "databaseName": "transaction-tests" + } + }, + { + "collection": { + "id": "collection0", + "database": "database0", + "collectionName": "test" + } + }, + { + "session": { + "id": "session0", + "client": "client0" + } + } + ], + "initialData": [ + { + "collectionName": "test", + "databaseName": "transaction-tests", + "documents": [ + { + "_id": 1 + }, + { + "_id": 2 + }, + { + "_id": 3 + }, + { + "_id": 4 + } + ] + } + ], + "tests": [ + { + "description": "collection readConcern without transaction", + "operations": [ + { + "object": "testRunner", + "name": "createEntities", + "arguments": { + "entities": [ + { + "collection": { + "id": "collection1", + "database": "database0", + "collectionName": "test", + "collectionOptions": { + "readConcern": { + "level": "majority" + } + } + } + } + ] + } + }, + { + "object": "collection1", + "name": "find", + "arguments": { + "filter": {}, + "session": "session0" + }, + "expectResult": [ + { + "_id": 1 + }, + { + "_id": 2 + }, + { + "_id": 3 + }, + { + "_id": 4 + } + ] + } + ], + "expectEvents": [ + { + "client": "client0", + "events": [ + { + "commandStartedEvent": { + "command": { + "find": "test", + "readConcern": { + "level": "majority" + }, + "lsid": { + "$$sessionLsid": "session0" + }, + "txnNumber": { + "$$exists": false + }, + "startTransaction": { + "$$exists": false + }, + "autocommit": { + "$$exists": false + } + }, + "commandName": "find", + "databaseName": "transaction-tests" + } + } + ] + } + ], + "outcome": [ + { + "collectionName": "test", + "databaseName": "transaction-tests", + "documents": [ + { + "_id": 1 + }, + { + "_id": 2 + }, + { + "_id": 3 + }, + { + "_id": 4 + } + ] + } + ] + }, + { + "description": "find", + "operations": [ + { + "object": "session0", + "name": "startTransaction" + }, + { + "object": "collection0", + "name": "find", + "arguments": { + "batchSize": 3, + "filter": {}, + "session": "session0" + }, + "expectResult": [ + { + "_id": 1 + }, + { + "_id": 2 + }, + { + "_id": 3 + }, + { + "_id": 4 + } + ] + }, + { + "object": "collection0", + "name": "find", + "arguments": { + "batchSize": 3, + "filter": {}, + "session": "session0" + }, + "expectResult": [ + { + "_id": 1 + }, + { + "_id": 2 + }, + { + "_id": 3 + }, + { + "_id": 4 + } + ] + }, + { + "object": "session0", + "name": "commitTransaction" + } + ], + "expectEvents": [ + { + "client": "client0", + "events": [ + { + "commandStartedEvent": { + "command": { + "find": "test", + "batchSize": 3, + "readConcern": { + "$$exists": false + }, + "lsid": { + "$$sessionLsid": "session0" + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": true, + "autocommit": false + }, + "commandName": "find", + "databaseName": "transaction-tests" + } + }, + { + "commandStartedEvent": { + "command": { + "getMore": { + "$$type": [ + "int", + "long" + ] + }, + "collection": "test", + "batchSize": 3, + "lsid": { + "$$sessionLsid": "session0" + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": { + "$$exists": false + }, + "autocommit": false + }, + "commandName": "getMore", + "databaseName": "transaction-tests" + } + }, + { + "commandStartedEvent": { + "command": { + "find": "test", + "batchSize": 3, + "lsid": { + "$$sessionLsid": "session0" + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": { + "$$exists": false + }, + "autocommit": false + }, + "commandName": "find", + "databaseName": "transaction-tests" + } + }, + { + "commandStartedEvent": { + "command": { + "getMore": { + "$$type": [ + "int", + "long" + ] + }, + "collection": "test", + "batchSize": 3, + "lsid": { + "$$sessionLsid": "session0" + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": { + "$$exists": false + }, + "autocommit": false + }, + "commandName": "getMore", + "databaseName": "transaction-tests" + } + }, + { + "commandStartedEvent": { + "command": { + "commitTransaction": 1, + "lsid": { + "$$sessionLsid": "session0" + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": { + "$$exists": false + }, + "autocommit": false, + "writeConcern": { + "$$exists": false + } + }, + "commandName": "commitTransaction", + "databaseName": "admin" + } + } + ] + } + ], + "outcome": [ + { + "collectionName": "test", + "databaseName": "transaction-tests", + "documents": [ + { + "_id": 1 + }, + { + "_id": 2 + }, + { + "_id": 3 + }, + { + "_id": 4 + } + ] + } + ] + }, + { + "description": "aggregate", + "operations": [ + { + "object": "session0", + "name": "startTransaction" + }, + { + "object": "collection0", + "name": "aggregate", + "arguments": { + "pipeline": [ + { + "$project": { + "_id": 1 + } + } + ], + "batchSize": 3, + "session": "session0" + }, + "expectResult": [ + { + "_id": 1 + }, + { + "_id": 2 + }, + { + "_id": 3 + }, + { + "_id": 4 + } + ] + }, + { + "object": "collection0", + "name": "aggregate", + "arguments": { + "pipeline": [ + { + "$project": { + "_id": 1 + } + } + ], + "batchSize": 3, + "session": "session0" + }, + "expectResult": [ + { + "_id": 1 + }, + { + "_id": 2 + }, + { + "_id": 3 + }, + { + "_id": 4 + } + ] + }, + { + "object": "session0", + "name": "commitTransaction" + } + ], + "expectEvents": [ + { + "client": "client0", + "events": [ + { + "commandStartedEvent": { + "command": { + "aggregate": "test", + "pipeline": [ + { + "$project": { + "_id": 1 + } + } + ], + "cursor": { + "batchSize": 3 + }, + "readConcern": { + "$$exists": false + }, + "lsid": { + "$$sessionLsid": "session0" + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": true, + "autocommit": false + }, + "commandName": "aggregate", + "databaseName": "transaction-tests" + } + }, + { + "commandStartedEvent": { + "command": { + "getMore": { + "$$type": [ + "int", + "long" + ] + }, + "collection": "test", + "batchSize": 3, + "lsid": { + "$$sessionLsid": "session0" + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": { + "$$exists": false + }, + "autocommit": false + }, + "commandName": "getMore", + "databaseName": "transaction-tests" + } + }, + { + "commandStartedEvent": { + "command": { + "aggregate": "test", + "pipeline": [ + { + "$project": { + "_id": 1 + } + } + ], + "cursor": { + "batchSize": 3 + }, + "lsid": { + "$$sessionLsid": "session0" + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": { + "$$exists": false + }, + "autocommit": false + }, + "commandName": "aggregate", + "databaseName": "transaction-tests" + } + }, + { + "commandStartedEvent": { + "command": { + "getMore": { + "$$type": [ + "int", + "long" + ] + }, + "collection": "test", + "batchSize": 3, + "lsid": { + "$$sessionLsid": "session0" + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": { + "$$exists": false + }, + "autocommit": false + }, + "commandName": "getMore", + "databaseName": "transaction-tests" + } + }, + { + "commandStartedEvent": { + "command": { + "commitTransaction": 1, + "lsid": { + "$$sessionLsid": "session0" + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": { + "$$exists": false + }, + "autocommit": false, + "writeConcern": { + "$$exists": false + } + }, + "commandName": "commitTransaction", + "databaseName": "admin" + } + } + ] + } + ], + "outcome": [ + { + "collectionName": "test", + "databaseName": "transaction-tests", + "documents": [ + { + "_id": 1 + }, + { + "_id": 2 + }, + { + "_id": 3 + }, + { + "_id": 4 + } + ] + } + ] + }, + { + "description": "distinct", + "operations": [ + { + "object": "session0", + "name": "startTransaction" + }, + { + "object": "collection0", + "name": "distinct", + "arguments": { + "fieldName": "_id", + "filter": {}, + "session": "session0" + }, + "expectResult": [ + 1, + 2, + 3, + 4 + ] + }, + { + "object": "session0", + "name": "commitTransaction" + } + ], + "expectEvents": [ + { + "client": "client0", + "events": [ + { + "commandStartedEvent": { + "command": { + "distinct": "test", + "key": "_id", + "lsid": { + "$$sessionLsid": "session0" + }, + "readConcern": { + "$$exists": false + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": true, + "autocommit": false, + "writeConcern": { + "$$exists": false + } + }, + "commandName": "distinct", + "databaseName": "transaction-tests" + } + }, + { + "commandStartedEvent": { + "command": { + "commitTransaction": 1, + "lsid": { + "$$sessionLsid": "session0" + }, + "readConcern": { + "$$exists": false + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": { + "$$exists": false + }, + "autocommit": false, + "writeConcern": { + "$$exists": false + } + }, + "commandName": "commitTransaction", + "databaseName": "admin" + } + } + ] + } + ], + "outcome": [ + { + "collectionName": "test", + "databaseName": "transaction-tests", + "documents": [ + { + "_id": 1 + }, + { + "_id": 2 + }, + { + "_id": 3 + }, + { + "_id": 4 + } + ] + } + ] + } + ] +} diff --git a/source/transactions/tests/unified/reads.yml b/source/transactions/tests/unified/reads.yml new file mode 100644 index 0000000000..66d7e2f79d --- /dev/null +++ b/source/transactions/tests/unified/reads.yml @@ -0,0 +1,298 @@ +description: reads + +schemaVersion: '1.9' + +runOnRequirements: + - + minServerVersion: '4.0' + topologies: + - replicaset + - + minServerVersion: 4.1.8 + topologies: + - sharded + - load-balanced + +createEntities: + - + client: + id: &client0 client0 + useMultipleMongoses: false + observeEvents: + - commandStartedEvent + - + database: + id: &database0 database0 + client: *client0 + databaseName: &database_name transaction-tests + - + collection: + id: &collection0 collection0 + database: *database0 + collectionName: &collection_name test + - + session: + id: &session0 session0 + client: *client0 + +initialData: + - + collectionName: *collection_name + databaseName: *database_name + documents: &data + - { _id: 1 } + - { _id: 2 } + - { _id: 3 } + - { _id: 4 } + +tests: + - + description: 'collection readConcern without transaction' + operations: + - + object: testRunner + name: createEntities + arguments: + entities: + - collection: + id: &collection1 collection1 + database: *database0 + collectionName: *collection_name + collectionOptions: + readConcern: { level: majority } + - + object: *collection1 + name: find + arguments: + filter: {} + session: *session0 + expectResult: *data + expectEvents: + - + client: *client0 + events: + - + commandStartedEvent: + command: + find: *collection_name + readConcern: + level: majority + lsid: { $$sessionLsid: *session0 } + txnNumber: { $$exists: false } + startTransaction: { $$exists: false } + autocommit: { $$exists: false } + commandName: find + databaseName: *database_name + outcome: &outcome + - + collectionName: *collection_name + databaseName: *database_name + documents: *data + - + description: find + operations: + - &startTransaction + object: *session0 + name: startTransaction + - &find + object: *collection0 + name: find + arguments: + batchSize: 3 + filter: {} + session: *session0 + expectResult: *data + - *find + - &commitTransaction + object: *session0 + name: commitTransaction + expectEvents: + - + client: *client0 + events: + - + commandStartedEvent: + command: + find: *collection_name + batchSize: 3 + readConcern: { $$exists: false } + lsid: { $$sessionLsid: *session0 } + txnNumber: { $numberLong: '1' } + startTransaction: true + autocommit: false + commandName: find + databaseName: *database_name + - + commandStartedEvent: + command: + getMore: { $$type: [ int, long ] } + collection: *collection_name + batchSize: 3 + lsid: { $$sessionLsid: *session0 } + txnNumber: { $numberLong: '1' } + startTransaction: { $$exists: false } + autocommit: false + commandName: getMore + databaseName: *database_name + - + commandStartedEvent: + command: + find: *collection_name + batchSize: 3 + lsid: { $$sessionLsid: *session0 } + txnNumber: { $numberLong: '1' } + startTransaction: { $$exists: false } + autocommit: false + commandName: find + databaseName: *database_name + - + commandStartedEvent: + command: + getMore: { $$type: [ int, long ] } + collection: *collection_name + batchSize: 3 + lsid: { $$sessionLsid: *session0 } + txnNumber: { $numberLong: '1' } + startTransaction: { $$exists: false } + autocommit: false + commandName: getMore + databaseName: *database_name + - + commandStartedEvent: + command: + commitTransaction: 1 + lsid: { $$sessionLsid: *session0 } + txnNumber: { $numberLong: '1' } + startTransaction: { $$exists: false } + autocommit: false + writeConcern: { $$exists: false } + commandName: commitTransaction + databaseName: admin + outcome: *outcome + - + description: aggregate + operations: + - *startTransaction + - &aggregate + object: *collection0 + name: aggregate + arguments: + pipeline: + - { $project: { _id: 1 } } + batchSize: 3 + session: *session0 + expectResult: *data + - *aggregate + - *commitTransaction + expectEvents: + - + client: *client0 + events: + - + commandStartedEvent: + command: + aggregate: *collection_name + pipeline: + - { $project: { _id: 1 } } + cursor: + batchSize: 3 + readConcern: { $$exists: false } + lsid: { $$sessionLsid: *session0 } + txnNumber: { $numberLong: '1' } + startTransaction: true + autocommit: false + commandName: aggregate + databaseName: *database_name + - + commandStartedEvent: + command: + getMore: { $$type: [ int, long ] } + collection: *collection_name + batchSize: 3 + lsid: { $$sessionLsid: *session0 } + txnNumber: { $numberLong: '1' } + startTransaction: { $$exists: false } + autocommit: false + commandName: getMore + databaseName: *database_name + - + commandStartedEvent: + command: + aggregate: *collection_name + pipeline: + - { $project: { _id: 1 } } + cursor: + batchSize: 3 + lsid: { $$sessionLsid: *session0 } + txnNumber: { $numberLong: '1' } + startTransaction: { $$exists: false } + autocommit: false + commandName: aggregate + databaseName: *database_name + - + commandStartedEvent: + command: + getMore: { $$type: [ int, long ] } + collection: *collection_name + batchSize: 3 + lsid: { $$sessionLsid: *session0 } + txnNumber: { $numberLong: '1' } + startTransaction: { $$exists: false } + autocommit: false + commandName: getMore + databaseName: *database_name + - + commandStartedEvent: + command: + commitTransaction: 1 + lsid: { $$sessionLsid: *session0 } + txnNumber: { $numberLong: '1' } + startTransaction: { $$exists: false } + autocommit: false + writeConcern: { $$exists: false } + commandName: commitTransaction + databaseName: admin + outcome: *outcome + - + description: distinct + operations: + - *startTransaction + - + object: *collection0 + name: distinct + arguments: + fieldName: _id + filter: {} + session: *session0 + expectResult: [ 1, 2, 3, 4] + - *commitTransaction + expectEvents: + - + client: *client0 + events: + - + commandStartedEvent: + command: + distinct: *collection_name + key: _id + lsid: { $$sessionLsid: *session0 } + readConcern: { $$exists: false } + txnNumber: { $numberLong: '1' } + startTransaction: true + autocommit: false + writeConcern: { $$exists: false } + commandName: distinct + databaseName: *database_name + - + commandStartedEvent: + command: + commitTransaction: 1 + lsid: { $$sessionLsid: *session0 } + readConcern: { $$exists: false } + txnNumber: { $numberLong: '1' } + startTransaction: { $$exists: false } + autocommit: false + writeConcern: { $$exists: false } + commandName: commitTransaction + databaseName: admin + outcome: *outcome \ No newline at end of file diff --git a/source/transactions/tests/unified/retryable-abort-errorLabels.json b/source/transactions/tests/unified/retryable-abort-errorLabels.json new file mode 100644 index 0000000000..77a1b03eb0 --- /dev/null +++ b/source/transactions/tests/unified/retryable-abort-errorLabels.json @@ -0,0 +1,2436 @@ +{ + "description": "retryable-abort-errorLabels", + "schemaVersion": "1.3", + "runOnRequirements": [ + { + "minServerVersion": "4.3.1", + "topologies": [ + "replicaset", + "sharded", + "load-balanced" + ] + } + ], + "createEntities": [ + { + "client": { + "id": "client0", + "useMultipleMongoses": false, + "observeEvents": [ + "commandStartedEvent" + ] + } + }, + { + "database": { + "id": "database0", + "client": "client0", + "databaseName": "transaction-tests" + } + }, + { + "collection": { + "id": "collection0", + "database": "database0", + "collectionName": "test" + } + }, + { + "session": { + "id": "session0", + "client": "client0" + } + } + ], + "initialData": [ + { + "collectionName": "test", + "databaseName": "transaction-tests", + "documents": [] + } + ], + "tests": [ + { + "description": "abortTransaction only retries once with RetryableWriteError from server", + "operations": [ + { + "object": "testRunner", + "name": "failPoint", + "arguments": { + "client": "client0", + "failPoint": { + "configureFailPoint": "failCommand", + "mode": { + "times": 2 + }, + "data": { + "failCommands": [ + "abortTransaction" + ], + "errorCode": 112, + "errorLabels": [ + "RetryableWriteError" + ] + } + } + } + }, + { + "object": "session0", + "name": "startTransaction" + }, + { + "object": "collection0", + "name": "insertOne", + "arguments": { + "session": "session0", + "document": { + "_id": 1 + } + }, + "expectResult": { + "$$unsetOrMatches": { + "insertedId": { + "$$unsetOrMatches": 1 + } + } + } + }, + { + "object": "session0", + "name": "abortTransaction" + } + ], + "expectEvents": [ + { + "client": "client0", + "events": [ + { + "commandStartedEvent": { + "command": { + "insert": "test", + "documents": [ + { + "_id": 1 + } + ], + "ordered": true, + "readConcern": { + "$$exists": false + }, + "lsid": { + "$$sessionLsid": "session0" + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": true, + "autocommit": false, + "writeConcern": { + "$$exists": false + } + }, + "commandName": "insert", + "databaseName": "transaction-tests" + } + }, + { + "commandStartedEvent": { + "command": { + "abortTransaction": 1, + "lsid": { + "$$sessionLsid": "session0" + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": { + "$$exists": false + }, + "autocommit": false, + "writeConcern": { + "$$exists": false + } + }, + "commandName": "abortTransaction", + "databaseName": "admin" + } + }, + { + "commandStartedEvent": { + "command": { + "abortTransaction": 1, + "lsid": { + "$$sessionLsid": "session0" + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": { + "$$exists": false + }, + "autocommit": false, + "writeConcern": { + "$$exists": false + } + }, + "commandName": "abortTransaction", + "databaseName": "admin" + } + } + ] + } + ], + "outcome": [ + { + "collectionName": "test", + "databaseName": "transaction-tests", + "documents": [] + } + ] + }, + { + "description": "abortTransaction does not retry without RetryableWriteError label", + "operations": [ + { + "object": "testRunner", + "name": "failPoint", + "arguments": { + "client": "client0", + "failPoint": { + "configureFailPoint": "failCommand", + "mode": { + "times": 1 + }, + "data": { + "failCommands": [ + "abortTransaction" + ], + "errorCode": 11600, + "errorLabels": [] + } + } + } + }, + { + "object": "session0", + "name": "startTransaction" + }, + { + "object": "collection0", + "name": "insertOne", + "arguments": { + "session": "session0", + "document": { + "_id": 1 + } + }, + "expectResult": { + "$$unsetOrMatches": { + "insertedId": { + "$$unsetOrMatches": 1 + } + } + } + }, + { + "object": "session0", + "name": "abortTransaction" + } + ], + "expectEvents": [ + { + "client": "client0", + "events": [ + { + "commandStartedEvent": { + "command": { + "insert": "test", + "documents": [ + { + "_id": 1 + } + ], + "ordered": true, + "readConcern": { + "$$exists": false + }, + "lsid": { + "$$sessionLsid": "session0" + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": true, + "autocommit": false, + "writeConcern": { + "$$exists": false + } + }, + "commandName": "insert", + "databaseName": "transaction-tests" + } + }, + { + "commandStartedEvent": { + "command": { + "abortTransaction": 1, + "lsid": { + "$$sessionLsid": "session0" + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": { + "$$exists": false + }, + "autocommit": false, + "writeConcern": { + "$$exists": false + } + }, + "commandName": "abortTransaction", + "databaseName": "admin" + } + } + ] + } + ], + "outcome": [ + { + "collectionName": "test", + "databaseName": "transaction-tests", + "documents": [] + } + ] + }, + { + "description": "abortTransaction succeeds after NotWritablePrimary", + "operations": [ + { + "object": "testRunner", + "name": "failPoint", + "arguments": { + "client": "client0", + "failPoint": { + "configureFailPoint": "failCommand", + "mode": { + "times": 1 + }, + "data": { + "failCommands": [ + "abortTransaction" + ], + "errorCode": 10107, + "errorLabels": [ + "RetryableWriteError" + ], + "closeConnection": false + } + } + } + }, + { + "object": "session0", + "name": "startTransaction" + }, + { + "object": "collection0", + "name": "insertOne", + "arguments": { + "session": "session0", + "document": { + "_id": 1 + } + }, + "expectResult": { + "$$unsetOrMatches": { + "insertedId": { + "$$unsetOrMatches": 1 + } + } + } + }, + { + "object": "session0", + "name": "abortTransaction" + } + ], + "expectEvents": [ + { + "client": "client0", + "events": [ + { + "commandStartedEvent": { + "command": { + "insert": "test", + "documents": [ + { + "_id": 1 + } + ], + "ordered": true, + "readConcern": { + "$$exists": false + }, + "lsid": { + "$$sessionLsid": "session0" + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": true, + "autocommit": false, + "writeConcern": { + "$$exists": false + } + }, + "commandName": "insert", + "databaseName": "transaction-tests" + } + }, + { + "commandStartedEvent": { + "command": { + "abortTransaction": 1, + "lsid": { + "$$sessionLsid": "session0" + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": { + "$$exists": false + }, + "autocommit": false, + "writeConcern": { + "$$exists": false + } + }, + "commandName": "abortTransaction", + "databaseName": "admin" + } + }, + { + "commandStartedEvent": { + "command": { + "abortTransaction": 1, + "lsid": { + "$$sessionLsid": "session0" + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": { + "$$exists": false + }, + "autocommit": false, + "writeConcern": { + "$$exists": false + } + }, + "commandName": "abortTransaction", + "databaseName": "admin" + } + } + ] + } + ], + "outcome": [ + { + "collectionName": "test", + "databaseName": "transaction-tests", + "documents": [] + } + ] + }, + { + "description": "abortTransaction succeeds after NotPrimaryOrSecondary", + "operations": [ + { + "object": "testRunner", + "name": "failPoint", + "arguments": { + "client": "client0", + "failPoint": { + "configureFailPoint": "failCommand", + "mode": { + "times": 1 + }, + "data": { + "failCommands": [ + "abortTransaction" + ], + "errorCode": 13436, + "errorLabels": [ + "RetryableWriteError" + ], + "closeConnection": false + } + } + } + }, + { + "object": "session0", + "name": "startTransaction" + }, + { + "object": "collection0", + "name": "insertOne", + "arguments": { + "session": "session0", + "document": { + "_id": 1 + } + }, + "expectResult": { + "$$unsetOrMatches": { + "insertedId": { + "$$unsetOrMatches": 1 + } + } + } + }, + { + "object": "session0", + "name": "abortTransaction" + } + ], + "expectEvents": [ + { + "client": "client0", + "events": [ + { + "commandStartedEvent": { + "command": { + "insert": "test", + "documents": [ + { + "_id": 1 + } + ], + "ordered": true, + "readConcern": { + "$$exists": false + }, + "lsid": { + "$$sessionLsid": "session0" + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": true, + "autocommit": false, + "writeConcern": { + "$$exists": false + } + }, + "commandName": "insert", + "databaseName": "transaction-tests" + } + }, + { + "commandStartedEvent": { + "command": { + "abortTransaction": 1, + "lsid": { + "$$sessionLsid": "session0" + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": { + "$$exists": false + }, + "autocommit": false, + "writeConcern": { + "$$exists": false + } + }, + "commandName": "abortTransaction", + "databaseName": "admin" + } + }, + { + "commandStartedEvent": { + "command": { + "abortTransaction": 1, + "lsid": { + "$$sessionLsid": "session0" + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": { + "$$exists": false + }, + "autocommit": false, + "writeConcern": { + "$$exists": false + } + }, + "commandName": "abortTransaction", + "databaseName": "admin" + } + } + ] + } + ], + "outcome": [ + { + "collectionName": "test", + "databaseName": "transaction-tests", + "documents": [] + } + ] + }, + { + "description": "abortTransaction succeeds after NotPrimaryNoSecondaryOk", + "operations": [ + { + "object": "testRunner", + "name": "failPoint", + "arguments": { + "client": "client0", + "failPoint": { + "configureFailPoint": "failCommand", + "mode": { + "times": 1 + }, + "data": { + "failCommands": [ + "abortTransaction" + ], + "errorCode": 13435, + "errorLabels": [ + "RetryableWriteError" + ], + "closeConnection": false + } + } + } + }, + { + "object": "session0", + "name": "startTransaction" + }, + { + "object": "collection0", + "name": "insertOne", + "arguments": { + "session": "session0", + "document": { + "_id": 1 + } + }, + "expectResult": { + "$$unsetOrMatches": { + "insertedId": { + "$$unsetOrMatches": 1 + } + } + } + }, + { + "object": "session0", + "name": "abortTransaction" + } + ], + "expectEvents": [ + { + "client": "client0", + "events": [ + { + "commandStartedEvent": { + "command": { + "insert": "test", + "documents": [ + { + "_id": 1 + } + ], + "ordered": true, + "readConcern": { + "$$exists": false + }, + "lsid": { + "$$sessionLsid": "session0" + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": true, + "autocommit": false, + "writeConcern": { + "$$exists": false + } + }, + "commandName": "insert", + "databaseName": "transaction-tests" + } + }, + { + "commandStartedEvent": { + "command": { + "abortTransaction": 1, + "lsid": { + "$$sessionLsid": "session0" + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": { + "$$exists": false + }, + "autocommit": false, + "writeConcern": { + "$$exists": false + } + }, + "commandName": "abortTransaction", + "databaseName": "admin" + } + }, + { + "commandStartedEvent": { + "command": { + "abortTransaction": 1, + "lsid": { + "$$sessionLsid": "session0" + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": { + "$$exists": false + }, + "autocommit": false, + "writeConcern": { + "$$exists": false + } + }, + "commandName": "abortTransaction", + "databaseName": "admin" + } + } + ] + } + ], + "outcome": [ + { + "collectionName": "test", + "databaseName": "transaction-tests", + "documents": [] + } + ] + }, + { + "description": "abortTransaction succeeds after InterruptedDueToReplStateChange", + "operations": [ + { + "object": "testRunner", + "name": "failPoint", + "arguments": { + "client": "client0", + "failPoint": { + "configureFailPoint": "failCommand", + "mode": { + "times": 1 + }, + "data": { + "failCommands": [ + "abortTransaction" + ], + "errorCode": 11602, + "errorLabels": [ + "RetryableWriteError" + ], + "closeConnection": false + } + } + } + }, + { + "object": "session0", + "name": "startTransaction" + }, + { + "object": "collection0", + "name": "insertOne", + "arguments": { + "session": "session0", + "document": { + "_id": 1 + } + }, + "expectResult": { + "$$unsetOrMatches": { + "insertedId": { + "$$unsetOrMatches": 1 + } + } + } + }, + { + "object": "session0", + "name": "abortTransaction" + } + ], + "expectEvents": [ + { + "client": "client0", + "events": [ + { + "commandStartedEvent": { + "command": { + "insert": "test", + "documents": [ + { + "_id": 1 + } + ], + "ordered": true, + "readConcern": { + "$$exists": false + }, + "lsid": { + "$$sessionLsid": "session0" + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": true, + "autocommit": false, + "writeConcern": { + "$$exists": false + } + }, + "commandName": "insert", + "databaseName": "transaction-tests" + } + }, + { + "commandStartedEvent": { + "command": { + "abortTransaction": 1, + "lsid": { + "$$sessionLsid": "session0" + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": { + "$$exists": false + }, + "autocommit": false, + "writeConcern": { + "$$exists": false + } + }, + "commandName": "abortTransaction", + "databaseName": "admin" + } + }, + { + "commandStartedEvent": { + "command": { + "abortTransaction": 1, + "lsid": { + "$$sessionLsid": "session0" + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": { + "$$exists": false + }, + "autocommit": false, + "writeConcern": { + "$$exists": false + } + }, + "commandName": "abortTransaction", + "databaseName": "admin" + } + } + ] + } + ], + "outcome": [ + { + "collectionName": "test", + "databaseName": "transaction-tests", + "documents": [] + } + ] + }, + { + "description": "abortTransaction succeeds after InterruptedAtShutdown", + "operations": [ + { + "object": "testRunner", + "name": "failPoint", + "arguments": { + "client": "client0", + "failPoint": { + "configureFailPoint": "failCommand", + "mode": { + "times": 1 + }, + "data": { + "failCommands": [ + "abortTransaction" + ], + "errorCode": 11600, + "errorLabels": [ + "RetryableWriteError" + ], + "closeConnection": false + } + } + } + }, + { + "object": "session0", + "name": "startTransaction" + }, + { + "object": "collection0", + "name": "insertOne", + "arguments": { + "session": "session0", + "document": { + "_id": 1 + } + }, + "expectResult": { + "$$unsetOrMatches": { + "insertedId": { + "$$unsetOrMatches": 1 + } + } + } + }, + { + "object": "session0", + "name": "abortTransaction" + } + ], + "expectEvents": [ + { + "client": "client0", + "events": [ + { + "commandStartedEvent": { + "command": { + "insert": "test", + "documents": [ + { + "_id": 1 + } + ], + "ordered": true, + "readConcern": { + "$$exists": false + }, + "lsid": { + "$$sessionLsid": "session0" + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": true, + "autocommit": false, + "writeConcern": { + "$$exists": false + } + }, + "commandName": "insert", + "databaseName": "transaction-tests" + } + }, + { + "commandStartedEvent": { + "command": { + "abortTransaction": 1, + "lsid": { + "$$sessionLsid": "session0" + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": { + "$$exists": false + }, + "autocommit": false, + "writeConcern": { + "$$exists": false + } + }, + "commandName": "abortTransaction", + "databaseName": "admin" + } + }, + { + "commandStartedEvent": { + "command": { + "abortTransaction": 1, + "lsid": { + "$$sessionLsid": "session0" + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": { + "$$exists": false + }, + "autocommit": false, + "writeConcern": { + "$$exists": false + } + }, + "commandName": "abortTransaction", + "databaseName": "admin" + } + } + ] + } + ], + "outcome": [ + { + "collectionName": "test", + "databaseName": "transaction-tests", + "documents": [] + } + ] + }, + { + "description": "abortTransaction succeeds after PrimarySteppedDown", + "operations": [ + { + "object": "testRunner", + "name": "failPoint", + "arguments": { + "client": "client0", + "failPoint": { + "configureFailPoint": "failCommand", + "mode": { + "times": 1 + }, + "data": { + "failCommands": [ + "abortTransaction" + ], + "errorCode": 189, + "errorLabels": [ + "RetryableWriteError" + ], + "closeConnection": false + } + } + } + }, + { + "object": "session0", + "name": "startTransaction" + }, + { + "object": "collection0", + "name": "insertOne", + "arguments": { + "session": "session0", + "document": { + "_id": 1 + } + }, + "expectResult": { + "$$unsetOrMatches": { + "insertedId": { + "$$unsetOrMatches": 1 + } + } + } + }, + { + "object": "session0", + "name": "abortTransaction" + } + ], + "expectEvents": [ + { + "client": "client0", + "events": [ + { + "commandStartedEvent": { + "command": { + "insert": "test", + "documents": [ + { + "_id": 1 + } + ], + "ordered": true, + "readConcern": { + "$$exists": false + }, + "lsid": { + "$$sessionLsid": "session0" + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": true, + "autocommit": false, + "writeConcern": { + "$$exists": false + } + }, + "commandName": "insert", + "databaseName": "transaction-tests" + } + }, + { + "commandStartedEvent": { + "command": { + "abortTransaction": 1, + "lsid": { + "$$sessionLsid": "session0" + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": { + "$$exists": false + }, + "autocommit": false, + "writeConcern": { + "$$exists": false + } + }, + "commandName": "abortTransaction", + "databaseName": "admin" + } + }, + { + "commandStartedEvent": { + "command": { + "abortTransaction": 1, + "lsid": { + "$$sessionLsid": "session0" + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": { + "$$exists": false + }, + "autocommit": false, + "writeConcern": { + "$$exists": false + } + }, + "commandName": "abortTransaction", + "databaseName": "admin" + } + } + ] + } + ], + "outcome": [ + { + "collectionName": "test", + "databaseName": "transaction-tests", + "documents": [] + } + ] + }, + { + "description": "abortTransaction succeeds after ShutdownInProgress", + "operations": [ + { + "object": "testRunner", + "name": "failPoint", + "arguments": { + "client": "client0", + "failPoint": { + "configureFailPoint": "failCommand", + "mode": { + "times": 1 + }, + "data": { + "failCommands": [ + "abortTransaction" + ], + "errorCode": 91, + "errorLabels": [ + "RetryableWriteError" + ], + "closeConnection": false + } + } + } + }, + { + "object": "session0", + "name": "startTransaction" + }, + { + "object": "collection0", + "name": "insertOne", + "arguments": { + "session": "session0", + "document": { + "_id": 1 + } + }, + "expectResult": { + "$$unsetOrMatches": { + "insertedId": { + "$$unsetOrMatches": 1 + } + } + } + }, + { + "object": "session0", + "name": "abortTransaction" + } + ], + "expectEvents": [ + { + "client": "client0", + "events": [ + { + "commandStartedEvent": { + "command": { + "insert": "test", + "documents": [ + { + "_id": 1 + } + ], + "ordered": true, + "readConcern": { + "$$exists": false + }, + "lsid": { + "$$sessionLsid": "session0" + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": true, + "autocommit": false, + "writeConcern": { + "$$exists": false + } + }, + "commandName": "insert", + "databaseName": "transaction-tests" + } + }, + { + "commandStartedEvent": { + "command": { + "abortTransaction": 1, + "lsid": { + "$$sessionLsid": "session0" + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": { + "$$exists": false + }, + "autocommit": false, + "writeConcern": { + "$$exists": false + } + }, + "commandName": "abortTransaction", + "databaseName": "admin" + } + }, + { + "commandStartedEvent": { + "command": { + "abortTransaction": 1, + "lsid": { + "$$sessionLsid": "session0" + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": { + "$$exists": false + }, + "autocommit": false, + "writeConcern": { + "$$exists": false + } + }, + "commandName": "abortTransaction", + "databaseName": "admin" + } + } + ] + } + ], + "outcome": [ + { + "collectionName": "test", + "databaseName": "transaction-tests", + "documents": [] + } + ] + }, + { + "description": "abortTransaction succeeds after HostNotFound", + "operations": [ + { + "object": "testRunner", + "name": "failPoint", + "arguments": { + "client": "client0", + "failPoint": { + "configureFailPoint": "failCommand", + "mode": { + "times": 1 + }, + "data": { + "failCommands": [ + "abortTransaction" + ], + "errorCode": 7, + "errorLabels": [ + "RetryableWriteError" + ], + "closeConnection": false + } + } + } + }, + { + "object": "session0", + "name": "startTransaction" + }, + { + "object": "collection0", + "name": "insertOne", + "arguments": { + "session": "session0", + "document": { + "_id": 1 + } + }, + "expectResult": { + "$$unsetOrMatches": { + "insertedId": { + "$$unsetOrMatches": 1 + } + } + } + }, + { + "object": "session0", + "name": "abortTransaction" + } + ], + "expectEvents": [ + { + "client": "client0", + "events": [ + { + "commandStartedEvent": { + "command": { + "insert": "test", + "documents": [ + { + "_id": 1 + } + ], + "ordered": true, + "readConcern": { + "$$exists": false + }, + "lsid": { + "$$sessionLsid": "session0" + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": true, + "autocommit": false, + "writeConcern": { + "$$exists": false + } + }, + "commandName": "insert", + "databaseName": "transaction-tests" + } + }, + { + "commandStartedEvent": { + "command": { + "abortTransaction": 1, + "lsid": { + "$$sessionLsid": "session0" + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": { + "$$exists": false + }, + "autocommit": false, + "writeConcern": { + "$$exists": false + } + }, + "commandName": "abortTransaction", + "databaseName": "admin" + } + }, + { + "commandStartedEvent": { + "command": { + "abortTransaction": 1, + "lsid": { + "$$sessionLsid": "session0" + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": { + "$$exists": false + }, + "autocommit": false, + "writeConcern": { + "$$exists": false + } + }, + "commandName": "abortTransaction", + "databaseName": "admin" + } + } + ] + } + ], + "outcome": [ + { + "collectionName": "test", + "databaseName": "transaction-tests", + "documents": [] + } + ] + }, + { + "description": "abortTransaction succeeds after HostUnreachable", + "operations": [ + { + "object": "testRunner", + "name": "failPoint", + "arguments": { + "client": "client0", + "failPoint": { + "configureFailPoint": "failCommand", + "mode": { + "times": 1 + }, + "data": { + "failCommands": [ + "abortTransaction" + ], + "errorCode": 6, + "errorLabels": [ + "RetryableWriteError" + ], + "closeConnection": false + } + } + } + }, + { + "object": "session0", + "name": "startTransaction" + }, + { + "object": "collection0", + "name": "insertOne", + "arguments": { + "session": "session0", + "document": { + "_id": 1 + } + }, + "expectResult": { + "$$unsetOrMatches": { + "insertedId": { + "$$unsetOrMatches": 1 + } + } + } + }, + { + "object": "session0", + "name": "abortTransaction" + } + ], + "expectEvents": [ + { + "client": "client0", + "events": [ + { + "commandStartedEvent": { + "command": { + "insert": "test", + "documents": [ + { + "_id": 1 + } + ], + "ordered": true, + "readConcern": { + "$$exists": false + }, + "lsid": { + "$$sessionLsid": "session0" + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": true, + "autocommit": false, + "writeConcern": { + "$$exists": false + } + }, + "commandName": "insert", + "databaseName": "transaction-tests" + } + }, + { + "commandStartedEvent": { + "command": { + "abortTransaction": 1, + "lsid": { + "$$sessionLsid": "session0" + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": { + "$$exists": false + }, + "autocommit": false, + "writeConcern": { + "$$exists": false + } + }, + "commandName": "abortTransaction", + "databaseName": "admin" + } + }, + { + "commandStartedEvent": { + "command": { + "abortTransaction": 1, + "lsid": { + "$$sessionLsid": "session0" + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": { + "$$exists": false + }, + "autocommit": false, + "writeConcern": { + "$$exists": false + } + }, + "commandName": "abortTransaction", + "databaseName": "admin" + } + } + ] + } + ], + "outcome": [ + { + "collectionName": "test", + "databaseName": "transaction-tests", + "documents": [] + } + ] + }, + { + "description": "abortTransaction succeeds after SocketException", + "operations": [ + { + "object": "testRunner", + "name": "failPoint", + "arguments": { + "client": "client0", + "failPoint": { + "configureFailPoint": "failCommand", + "mode": { + "times": 1 + }, + "data": { + "failCommands": [ + "abortTransaction" + ], + "errorCode": 9001, + "errorLabels": [ + "RetryableWriteError" + ], + "closeConnection": false + } + } + } + }, + { + "object": "session0", + "name": "startTransaction" + }, + { + "object": "collection0", + "name": "insertOne", + "arguments": { + "session": "session0", + "document": { + "_id": 1 + } + }, + "expectResult": { + "$$unsetOrMatches": { + "insertedId": { + "$$unsetOrMatches": 1 + } + } + } + }, + { + "object": "session0", + "name": "abortTransaction" + } + ], + "expectEvents": [ + { + "client": "client0", + "events": [ + { + "commandStartedEvent": { + "command": { + "insert": "test", + "documents": [ + { + "_id": 1 + } + ], + "ordered": true, + "readConcern": { + "$$exists": false + }, + "lsid": { + "$$sessionLsid": "session0" + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": true, + "autocommit": false, + "writeConcern": { + "$$exists": false + } + }, + "commandName": "insert", + "databaseName": "transaction-tests" + } + }, + { + "commandStartedEvent": { + "command": { + "abortTransaction": 1, + "lsid": { + "$$sessionLsid": "session0" + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": { + "$$exists": false + }, + "autocommit": false, + "writeConcern": { + "$$exists": false + } + }, + "commandName": "abortTransaction", + "databaseName": "admin" + } + }, + { + "commandStartedEvent": { + "command": { + "abortTransaction": 1, + "lsid": { + "$$sessionLsid": "session0" + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": { + "$$exists": false + }, + "autocommit": false, + "writeConcern": { + "$$exists": false + } + }, + "commandName": "abortTransaction", + "databaseName": "admin" + } + } + ] + } + ], + "outcome": [ + { + "collectionName": "test", + "databaseName": "transaction-tests", + "documents": [] + } + ] + }, + { + "description": "abortTransaction succeeds after NetworkTimeout", + "operations": [ + { + "object": "testRunner", + "name": "failPoint", + "arguments": { + "client": "client0", + "failPoint": { + "configureFailPoint": "failCommand", + "mode": { + "times": 1 + }, + "data": { + "failCommands": [ + "abortTransaction" + ], + "errorCode": 89, + "errorLabels": [ + "RetryableWriteError" + ], + "closeConnection": false + } + } + } + }, + { + "object": "session0", + "name": "startTransaction" + }, + { + "object": "collection0", + "name": "insertOne", + "arguments": { + "session": "session0", + "document": { + "_id": 1 + } + }, + "expectResult": { + "$$unsetOrMatches": { + "insertedId": { + "$$unsetOrMatches": 1 + } + } + } + }, + { + "object": "session0", + "name": "abortTransaction" + } + ], + "expectEvents": [ + { + "client": "client0", + "events": [ + { + "commandStartedEvent": { + "command": { + "insert": "test", + "documents": [ + { + "_id": 1 + } + ], + "ordered": true, + "readConcern": { + "$$exists": false + }, + "lsid": { + "$$sessionLsid": "session0" + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": true, + "autocommit": false, + "writeConcern": { + "$$exists": false + } + }, + "commandName": "insert", + "databaseName": "transaction-tests" + } + }, + { + "commandStartedEvent": { + "command": { + "abortTransaction": 1, + "lsid": { + "$$sessionLsid": "session0" + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": { + "$$exists": false + }, + "autocommit": false, + "writeConcern": { + "$$exists": false + } + }, + "commandName": "abortTransaction", + "databaseName": "admin" + } + }, + { + "commandStartedEvent": { + "command": { + "abortTransaction": 1, + "lsid": { + "$$sessionLsid": "session0" + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": { + "$$exists": false + }, + "autocommit": false, + "writeConcern": { + "$$exists": false + } + }, + "commandName": "abortTransaction", + "databaseName": "admin" + } + } + ] + } + ], + "outcome": [ + { + "collectionName": "test", + "databaseName": "transaction-tests", + "documents": [] + } + ] + }, + { + "description": "abortTransaction succeeds after WriteConcernError InterruptedAtShutdown", + "operations": [ + { + "object": "testRunner", + "name": "failPoint", + "arguments": { + "client": "client0", + "failPoint": { + "configureFailPoint": "failCommand", + "mode": { + "times": 1 + }, + "data": { + "failCommands": [ + "abortTransaction" + ], + "errorLabels": [ + "RetryableWriteError" + ], + "writeConcernError": { + "code": 11600, + "errmsg": "Replication is being shut down" + } + } + } + } + }, + { + "object": "session0", + "name": "startTransaction", + "arguments": { + "writeConcern": { + "w": "majority" + } + } + }, + { + "object": "collection0", + "name": "insertOne", + "arguments": { + "session": "session0", + "document": { + "_id": 1 + } + }, + "expectResult": { + "$$unsetOrMatches": { + "insertedId": { + "$$unsetOrMatches": 1 + } + } + } + }, + { + "object": "session0", + "name": "abortTransaction" + } + ], + "expectEvents": [ + { + "client": "client0", + "events": [ + { + "commandStartedEvent": { + "command": { + "insert": "test", + "documents": [ + { + "_id": 1 + } + ], + "ordered": true, + "readConcern": { + "$$exists": false + }, + "lsid": { + "$$sessionLsid": "session0" + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": true, + "autocommit": false, + "writeConcern": { + "$$exists": false + } + }, + "commandName": "insert", + "databaseName": "transaction-tests" + } + }, + { + "commandStartedEvent": { + "command": { + "abortTransaction": 1, + "lsid": { + "$$sessionLsid": "session0" + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": { + "$$exists": false + }, + "autocommit": false, + "writeConcern": { + "w": "majority" + } + }, + "commandName": "abortTransaction", + "databaseName": "admin" + } + }, + { + "commandStartedEvent": { + "command": { + "abortTransaction": 1, + "lsid": { + "$$sessionLsid": "session0" + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": { + "$$exists": false + }, + "autocommit": false, + "writeConcern": { + "w": "majority" + } + }, + "commandName": "abortTransaction", + "databaseName": "admin" + } + } + ] + } + ], + "outcome": [ + { + "collectionName": "test", + "databaseName": "transaction-tests", + "documents": [] + } + ] + }, + { + "description": "abortTransaction succeeds after WriteConcernError InterruptedDueToReplStateChange", + "operations": [ + { + "object": "testRunner", + "name": "failPoint", + "arguments": { + "client": "client0", + "failPoint": { + "configureFailPoint": "failCommand", + "mode": { + "times": 1 + }, + "data": { + "failCommands": [ + "abortTransaction" + ], + "errorLabels": [ + "RetryableWriteError" + ], + "writeConcernError": { + "code": 11602, + "errmsg": "Replication is being shut down" + } + } + } + } + }, + { + "object": "session0", + "name": "startTransaction", + "arguments": { + "writeConcern": { + "w": "majority" + } + } + }, + { + "object": "collection0", + "name": "insertOne", + "arguments": { + "session": "session0", + "document": { + "_id": 1 + } + }, + "expectResult": { + "$$unsetOrMatches": { + "insertedId": { + "$$unsetOrMatches": 1 + } + } + } + }, + { + "object": "session0", + "name": "abortTransaction" + } + ], + "expectEvents": [ + { + "client": "client0", + "events": [ + { + "commandStartedEvent": { + "command": { + "insert": "test", + "documents": [ + { + "_id": 1 + } + ], + "ordered": true, + "readConcern": { + "$$exists": false + }, + "lsid": { + "$$sessionLsid": "session0" + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": true, + "autocommit": false, + "writeConcern": { + "$$exists": false + } + }, + "commandName": "insert", + "databaseName": "transaction-tests" + } + }, + { + "commandStartedEvent": { + "command": { + "abortTransaction": 1, + "lsid": { + "$$sessionLsid": "session0" + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": { + "$$exists": false + }, + "autocommit": false, + "writeConcern": { + "w": "majority" + } + }, + "commandName": "abortTransaction", + "databaseName": "admin" + } + }, + { + "commandStartedEvent": { + "command": { + "abortTransaction": 1, + "lsid": { + "$$sessionLsid": "session0" + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": { + "$$exists": false + }, + "autocommit": false, + "writeConcern": { + "w": "majority" + } + }, + "commandName": "abortTransaction", + "databaseName": "admin" + } + } + ] + } + ], + "outcome": [ + { + "collectionName": "test", + "databaseName": "transaction-tests", + "documents": [] + } + ] + }, + { + "description": "abortTransaction succeeds after WriteConcernError PrimarySteppedDown", + "operations": [ + { + "object": "testRunner", + "name": "failPoint", + "arguments": { + "client": "client0", + "failPoint": { + "configureFailPoint": "failCommand", + "mode": { + "times": 1 + }, + "data": { + "failCommands": [ + "abortTransaction" + ], + "errorLabels": [ + "RetryableWriteError" + ], + "writeConcernError": { + "code": 189, + "errmsg": "Replication is being shut down" + } + } + } + } + }, + { + "object": "session0", + "name": "startTransaction", + "arguments": { + "writeConcern": { + "w": "majority" + } + } + }, + { + "object": "collection0", + "name": "insertOne", + "arguments": { + "session": "session0", + "document": { + "_id": 1 + } + }, + "expectResult": { + "$$unsetOrMatches": { + "insertedId": { + "$$unsetOrMatches": 1 + } + } + } + }, + { + "object": "session0", + "name": "abortTransaction" + } + ], + "expectEvents": [ + { + "client": "client0", + "events": [ + { + "commandStartedEvent": { + "command": { + "insert": "test", + "documents": [ + { + "_id": 1 + } + ], + "ordered": true, + "readConcern": { + "$$exists": false + }, + "lsid": { + "$$sessionLsid": "session0" + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": true, + "autocommit": false, + "writeConcern": { + "$$exists": false + } + }, + "commandName": "insert", + "databaseName": "transaction-tests" + } + }, + { + "commandStartedEvent": { + "command": { + "abortTransaction": 1, + "lsid": { + "$$sessionLsid": "session0" + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": { + "$$exists": false + }, + "autocommit": false, + "writeConcern": { + "w": "majority" + } + }, + "commandName": "abortTransaction", + "databaseName": "admin" + } + }, + { + "commandStartedEvent": { + "command": { + "abortTransaction": 1, + "lsid": { + "$$sessionLsid": "session0" + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": { + "$$exists": false + }, + "autocommit": false, + "writeConcern": { + "w": "majority" + } + }, + "commandName": "abortTransaction", + "databaseName": "admin" + } + } + ] + } + ], + "outcome": [ + { + "collectionName": "test", + "databaseName": "transaction-tests", + "documents": [] + } + ] + }, + { + "description": "abortTransaction succeeds after WriteConcernError ShutdownInProgress", + "operations": [ + { + "object": "testRunner", + "name": "failPoint", + "arguments": { + "client": "client0", + "failPoint": { + "configureFailPoint": "failCommand", + "mode": { + "times": 1 + }, + "data": { + "failCommands": [ + "abortTransaction" + ], + "errorLabels": [ + "RetryableWriteError" + ], + "writeConcernError": { + "code": 91, + "errmsg": "Replication is being shut down" + } + } + } + } + }, + { + "object": "session0", + "name": "startTransaction", + "arguments": { + "writeConcern": { + "w": "majority" + } + } + }, + { + "object": "collection0", + "name": "insertOne", + "arguments": { + "session": "session0", + "document": { + "_id": 1 + } + }, + "expectResult": { + "$$unsetOrMatches": { + "insertedId": { + "$$unsetOrMatches": 1 + } + } + } + }, + { + "object": "session0", + "name": "abortTransaction" + } + ], + "expectEvents": [ + { + "client": "client0", + "events": [ + { + "commandStartedEvent": { + "command": { + "insert": "test", + "documents": [ + { + "_id": 1 + } + ], + "ordered": true, + "readConcern": { + "$$exists": false + }, + "lsid": { + "$$sessionLsid": "session0" + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": true, + "autocommit": false, + "writeConcern": { + "$$exists": false + } + }, + "commandName": "insert", + "databaseName": "transaction-tests" + } + }, + { + "commandStartedEvent": { + "command": { + "abortTransaction": 1, + "lsid": { + "$$sessionLsid": "session0" + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": { + "$$exists": false + }, + "autocommit": false, + "writeConcern": { + "w": "majority" + } + }, + "commandName": "abortTransaction", + "databaseName": "admin" + } + }, + { + "commandStartedEvent": { + "command": { + "abortTransaction": 1, + "lsid": { + "$$sessionLsid": "session0" + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": { + "$$exists": false + }, + "autocommit": false, + "writeConcern": { + "w": "majority" + } + }, + "commandName": "abortTransaction", + "databaseName": "admin" + } + } + ] + } + ], + "outcome": [ + { + "collectionName": "test", + "databaseName": "transaction-tests", + "documents": [] + } + ] + } + ] +} diff --git a/source/transactions/tests/unified/retryable-abort-errorLabels.yml b/source/transactions/tests/unified/retryable-abort-errorLabels.yml new file mode 100644 index 0000000000..8a4ddf994a --- /dev/null +++ b/source/transactions/tests/unified/retryable-abort-errorLabels.yml @@ -0,0 +1,1381 @@ +description: retryable-abort-errorLabels + +schemaVersion: '1.3' + +runOnRequirements: + - + minServerVersion: 4.3.1 # failCommand errorLabels option + topologies: + - replicaset + - sharded + - load-balanced + +createEntities: + - + client: + id: &client0 client0 + useMultipleMongoses: false + observeEvents: + - commandStartedEvent + - + database: + id: &database0 database0 + client: *client0 + databaseName: &database_name transaction-tests + - + collection: + id: &collection0 collection0 + database: *database0 + collectionName: &collection_name test + - + session: + id: &session0 session0 + client: *client0 + +initialData: + - + collectionName: *collection_name + databaseName: *database_name + documents: [] + +tests: + - + description: 'abortTransaction only retries once with RetryableWriteError from server' + operations: + - + object: testRunner + name: failPoint + arguments: + client: *client0 + failPoint: + configureFailPoint: failCommand + mode: { times: 2 } + data: + failCommands: + - abortTransaction + errorCode: 112 # WriteConflict, not a retryable error code + # Override server behavior: send RetryableWriteError label with non-retryable error code + errorLabels: + - RetryableWriteError + - + object: *session0 + name: startTransaction + - + object: *collection0 + name: insertOne + arguments: + session: *session0 + document: { _id: 1 } + expectResult: + $$unsetOrMatches: { insertedId: { $$unsetOrMatches: 1 } } + - + object: *session0 + name: abortTransaction + expectEvents: + - + client: *client0 + events: + - + commandStartedEvent: + command: + insert: *collection_name + documents: + - { _id: 1 } + ordered: true + readConcern: { $$exists: false } + lsid: { $$sessionLsid: *session0 } + txnNumber: { $numberLong: '1' } + startTransaction: true + autocommit: false + writeConcern: { $$exists: false } + commandName: insert + databaseName: *database_name + - + commandStartedEvent: + command: + abortTransaction: 1 + lsid: { $$sessionLsid: *session0 } + txnNumber: { $numberLong: '1' } + startTransaction: { $$exists: false } + autocommit: false + writeConcern: { $$exists: false } + commandName: abortTransaction + databaseName: admin + # Driver retries abort once + - + commandStartedEvent: + command: + abortTransaction: 1 + lsid: { $$sessionLsid: *session0 } + txnNumber: { $numberLong: '1' } + startTransaction: { $$exists: false } + autocommit: false + writeConcern: { $$exists: false } + commandName: abortTransaction + databaseName: admin + outcome: + - + collectionName: *collection_name + databaseName: *database_name + documents: [] + - + description: 'abortTransaction does not retry without RetryableWriteError label' + operations: + - + object: testRunner + name: failPoint + arguments: + client: *client0 + failPoint: + configureFailPoint: failCommand + mode: { times: 1 } + data: + failCommands: + - abortTransaction + errorCode: 11600 # InterruptedAtShutdown, normally a retryable error code + # Override server behavior: do not send RetryableWriteError label with retryable code + errorLabels: [] + - + object: *session0 + name: startTransaction + - + object: *collection0 + name: insertOne + arguments: + session: *session0 + document: { _id: 1 } + expectResult: + $$unsetOrMatches: { insertedId: { $$unsetOrMatches: 1 } } + - + object: *session0 + name: abortTransaction + expectEvents: + - + client: *client0 + events: + - + commandStartedEvent: + command: + insert: *collection_name + documents: + - { _id: 1 } + ordered: true + readConcern: { $$exists: false } + lsid: { $$sessionLsid: *session0 } + txnNumber: { $numberLong: '1' } + startTransaction: true + autocommit: false + writeConcern: { $$exists: false } + commandName: insert + databaseName: *database_name + - + commandStartedEvent: + command: + abortTransaction: 1 + lsid: { $$sessionLsid: *session0 } + txnNumber: { $numberLong: '1' } + startTransaction: { $$exists: false } + autocommit: false + writeConcern: { $$exists: false } + commandName: abortTransaction + databaseName: admin + # Driver does not retry abort + outcome: + - + collectionName: *collection_name + databaseName: *database_name + documents: [] + - + description: 'abortTransaction succeeds after NotWritablePrimary' + operations: + - + object: testRunner + name: failPoint + arguments: + client: *client0 + failPoint: + configureFailPoint: failCommand + mode: { times: 1 } + data: + failCommands: + - abortTransaction + errorCode: 10107 + errorLabels: + - RetryableWriteError + closeConnection: false + - + object: *session0 + name: startTransaction + - + object: *collection0 + name: insertOne + arguments: + session: *session0 + document: { _id: 1 } + expectResult: + $$unsetOrMatches: { insertedId: { $$unsetOrMatches: 1 } } + - + object: *session0 + name: abortTransaction + expectEvents: + - + client: *client0 + events: + - + commandStartedEvent: + command: + insert: *collection_name + documents: + - { _id: 1 } + ordered: true + readConcern: { $$exists: false } + lsid: { $$sessionLsid: *session0 } + txnNumber: { $numberLong: '1' } + startTransaction: true + autocommit: false + writeConcern: { $$exists: false } + commandName: insert + databaseName: *database_name + - + commandStartedEvent: + command: + abortTransaction: 1 + lsid: { $$sessionLsid: *session0 } + txnNumber: { $numberLong: '1' } + startTransaction: { $$exists: false } + autocommit: false + writeConcern: { $$exists: false } + commandName: abortTransaction + databaseName: admin + - + commandStartedEvent: + command: + abortTransaction: 1 + lsid: { $$sessionLsid: *session0 } + txnNumber: { $numberLong: '1' } + startTransaction: { $$exists: false } + autocommit: false + writeConcern: { $$exists: false } + commandName: abortTransaction + databaseName: admin + outcome: + - + collectionName: *collection_name + databaseName: *database_name + documents: [] + - + description: 'abortTransaction succeeds after NotPrimaryOrSecondary' + operations: + - + object: testRunner + name: failPoint + arguments: + client: *client0 + failPoint: + configureFailPoint: failCommand + mode: { times: 1 } + data: + failCommands: + - abortTransaction + errorCode: 13436 + errorLabels: + - RetryableWriteError + closeConnection: false + - + object: *session0 + name: startTransaction + - + object: *collection0 + name: insertOne + arguments: + session: *session0 + document: { _id: 1 } + expectResult: + $$unsetOrMatches: { insertedId: { $$unsetOrMatches: 1 } } + - + object: *session0 + name: abortTransaction + expectEvents: + - + client: *client0 + events: + - + commandStartedEvent: + command: + insert: *collection_name + documents: + - { _id: 1 } + ordered: true + readConcern: { $$exists: false } + lsid: { $$sessionLsid: *session0 } + txnNumber: { $numberLong: '1' } + startTransaction: true + autocommit: false + writeConcern: { $$exists: false } + commandName: insert + databaseName: *database_name + - + commandStartedEvent: + command: + abortTransaction: 1 + lsid: { $$sessionLsid: *session0 } + txnNumber: { $numberLong: '1' } + startTransaction: { $$exists: false } + autocommit: false + writeConcern: { $$exists: false } + commandName: abortTransaction + databaseName: admin + - + commandStartedEvent: + command: + abortTransaction: 1 + lsid: { $$sessionLsid: *session0 } + txnNumber: { $numberLong: '1' } + startTransaction: { $$exists: false } + autocommit: false + writeConcern: { $$exists: false } + commandName: abortTransaction + databaseName: admin + outcome: + - + collectionName: *collection_name + databaseName: *database_name + documents: [] + - + description: 'abortTransaction succeeds after NotPrimaryNoSecondaryOk' + operations: + - + object: testRunner + name: failPoint + arguments: + client: *client0 + failPoint: + configureFailPoint: failCommand + mode: { times: 1 } + data: + failCommands: + - abortTransaction + errorCode: 13435 + errorLabels: + - RetryableWriteError + closeConnection: false + - + object: *session0 + name: startTransaction + - + object: *collection0 + name: insertOne + arguments: + session: *session0 + document: { _id: 1 } + expectResult: + $$unsetOrMatches: { insertedId: { $$unsetOrMatches: 1 } } + - + object: *session0 + name: abortTransaction + expectEvents: + - + client: *client0 + events: + - + commandStartedEvent: + command: + insert: *collection_name + documents: + - { _id: 1 } + ordered: true + readConcern: { $$exists: false } + lsid: { $$sessionLsid: *session0 } + txnNumber: { $numberLong: '1' } + startTransaction: true + autocommit: false + writeConcern: { $$exists: false } + commandName: insert + databaseName: *database_name + - + commandStartedEvent: + command: + abortTransaction: 1 + lsid: { $$sessionLsid: *session0 } + txnNumber: { $numberLong: '1' } + startTransaction: { $$exists: false } + autocommit: false + writeConcern: { $$exists: false } + commandName: abortTransaction + databaseName: admin + - + commandStartedEvent: + command: + abortTransaction: 1 + lsid: { $$sessionLsid: *session0 } + txnNumber: { $numberLong: '1' } + startTransaction: { $$exists: false } + autocommit: false + writeConcern: { $$exists: false } + commandName: abortTransaction + databaseName: admin + outcome: + - + collectionName: *collection_name + databaseName: *database_name + documents: [] + - + description: 'abortTransaction succeeds after InterruptedDueToReplStateChange' + operations: + - + object: testRunner + name: failPoint + arguments: + client: *client0 + failPoint: + configureFailPoint: failCommand + mode: { times: 1 } + data: + failCommands: + - abortTransaction + errorCode: 11602 + errorLabels: + - RetryableWriteError + closeConnection: false + - + object: *session0 + name: startTransaction + - + object: *collection0 + name: insertOne + arguments: + session: *session0 + document: { _id: 1 } + expectResult: + $$unsetOrMatches: { insertedId: { $$unsetOrMatches: 1 } } + - + object: *session0 + name: abortTransaction + expectEvents: + - + client: *client0 + events: + - + commandStartedEvent: + command: + insert: *collection_name + documents: + - { _id: 1 } + ordered: true + readConcern: { $$exists: false } + lsid: { $$sessionLsid: *session0 } + txnNumber: { $numberLong: '1' } + startTransaction: true + autocommit: false + writeConcern: { $$exists: false } + commandName: insert + databaseName: *database_name + - + commandStartedEvent: + command: + abortTransaction: 1 + lsid: { $$sessionLsid: *session0 } + txnNumber: { $numberLong: '1' } + startTransaction: { $$exists: false } + autocommit: false + writeConcern: { $$exists: false } + commandName: abortTransaction + databaseName: admin + - + commandStartedEvent: + command: + abortTransaction: 1 + lsid: { $$sessionLsid: *session0 } + txnNumber: { $numberLong: '1' } + startTransaction: { $$exists: false } + autocommit: false + writeConcern: { $$exists: false } + commandName: abortTransaction + databaseName: admin + outcome: + - + collectionName: *collection_name + databaseName: *database_name + documents: [] + - + description: 'abortTransaction succeeds after InterruptedAtShutdown' + operations: + - + object: testRunner + name: failPoint + arguments: + client: *client0 + failPoint: + configureFailPoint: failCommand + mode: { times: 1 } + data: + failCommands: + - abortTransaction + errorCode: 11600 + errorLabels: + - RetryableWriteError + closeConnection: false + - + object: *session0 + name: startTransaction + - + object: *collection0 + name: insertOne + arguments: + session: *session0 + document: { _id: 1 } + expectResult: + $$unsetOrMatches: { insertedId: { $$unsetOrMatches: 1 } } + - + object: *session0 + name: abortTransaction + expectEvents: + - + client: *client0 + events: + - + commandStartedEvent: + command: + insert: *collection_name + documents: + - { _id: 1 } + ordered: true + readConcern: { $$exists: false } + lsid: { $$sessionLsid: *session0 } + txnNumber: { $numberLong: '1' } + startTransaction: true + autocommit: false + writeConcern: { $$exists: false } + commandName: insert + databaseName: *database_name + - + commandStartedEvent: + command: + abortTransaction: 1 + lsid: { $$sessionLsid: *session0 } + txnNumber: { $numberLong: '1' } + startTransaction: { $$exists: false } + autocommit: false + writeConcern: { $$exists: false } + commandName: abortTransaction + databaseName: admin + - + commandStartedEvent: + command: + abortTransaction: 1 + lsid: { $$sessionLsid: *session0 } + txnNumber: { $numberLong: '1' } + startTransaction: { $$exists: false } + autocommit: false + writeConcern: { $$exists: false } + commandName: abortTransaction + databaseName: admin + outcome: + - + collectionName: *collection_name + databaseName: *database_name + documents: [] + - + description: 'abortTransaction succeeds after PrimarySteppedDown' + operations: + - + object: testRunner + name: failPoint + arguments: + client: *client0 + failPoint: + configureFailPoint: failCommand + mode: { times: 1 } + data: + failCommands: + - abortTransaction + errorCode: 189 + errorLabels: + - RetryableWriteError + closeConnection: false + - + object: *session0 + name: startTransaction + - + object: *collection0 + name: insertOne + arguments: + session: *session0 + document: { _id: 1 } + expectResult: + $$unsetOrMatches: { insertedId: { $$unsetOrMatches: 1 } } + - + object: *session0 + name: abortTransaction + expectEvents: + - + client: *client0 + events: + - + commandStartedEvent: + command: + insert: *collection_name + documents: + - { _id: 1 } + ordered: true + readConcern: { $$exists: false } + lsid: { $$sessionLsid: *session0 } + txnNumber: { $numberLong: '1' } + startTransaction: true + autocommit: false + writeConcern: { $$exists: false } + commandName: insert + databaseName: *database_name + - + commandStartedEvent: + command: + abortTransaction: 1 + lsid: { $$sessionLsid: *session0 } + txnNumber: { $numberLong: '1' } + startTransaction: { $$exists: false } + autocommit: false + writeConcern: { $$exists: false } + commandName: abortTransaction + databaseName: admin + - + commandStartedEvent: + command: + abortTransaction: 1 + lsid: { $$sessionLsid: *session0 } + txnNumber: { $numberLong: '1' } + startTransaction: { $$exists: false } + autocommit: false + writeConcern: { $$exists: false } + commandName: abortTransaction + databaseName: admin + outcome: + - + collectionName: *collection_name + databaseName: *database_name + documents: [] + - + description: 'abortTransaction succeeds after ShutdownInProgress' + operations: + - + object: testRunner + name: failPoint + arguments: + client: *client0 + failPoint: + configureFailPoint: failCommand + mode: { times: 1 } + data: + failCommands: + - abortTransaction + errorCode: 91 + errorLabels: + - RetryableWriteError + closeConnection: false + - + object: *session0 + name: startTransaction + - + object: *collection0 + name: insertOne + arguments: + session: *session0 + document: { _id: 1 } + expectResult: + $$unsetOrMatches: { insertedId: { $$unsetOrMatches: 1 } } + - + object: *session0 + name: abortTransaction + expectEvents: + - + client: *client0 + events: + - + commandStartedEvent: + command: + insert: *collection_name + documents: + - { _id: 1 } + ordered: true + readConcern: { $$exists: false } + lsid: { $$sessionLsid: *session0 } + txnNumber: { $numberLong: '1' } + startTransaction: true + autocommit: false + writeConcern: { $$exists: false } + commandName: insert + databaseName: *database_name + - + commandStartedEvent: + command: + abortTransaction: 1 + lsid: { $$sessionLsid: *session0 } + txnNumber: { $numberLong: '1' } + startTransaction: { $$exists: false } + autocommit: false + writeConcern: { $$exists: false } + commandName: abortTransaction + databaseName: admin + - + commandStartedEvent: + command: + abortTransaction: 1 + lsid: { $$sessionLsid: *session0 } + txnNumber: { $numberLong: '1' } + startTransaction: { $$exists: false } + autocommit: false + writeConcern: { $$exists: false } + commandName: abortTransaction + databaseName: admin + outcome: + - + collectionName: *collection_name + databaseName: *database_name + documents: [] + - + description: 'abortTransaction succeeds after HostNotFound' + operations: + - + object: testRunner + name: failPoint + arguments: + client: *client0 + failPoint: + configureFailPoint: failCommand + mode: { times: 1 } + data: + failCommands: + - abortTransaction + errorCode: 7 + errorLabels: + - RetryableWriteError + closeConnection: false + - + object: *session0 + name: startTransaction + - + object: *collection0 + name: insertOne + arguments: + session: *session0 + document: { _id: 1 } + expectResult: + $$unsetOrMatches: { insertedId: { $$unsetOrMatches: 1 } } + - + object: *session0 + name: abortTransaction + expectEvents: + - + client: *client0 + events: + - + commandStartedEvent: + command: + insert: *collection_name + documents: + - { _id: 1 } + ordered: true + readConcern: { $$exists: false } + lsid: { $$sessionLsid: *session0 } + txnNumber: { $numberLong: '1' } + startTransaction: true + autocommit: false + writeConcern: { $$exists: false } + commandName: insert + databaseName: *database_name + - + commandStartedEvent: + command: + abortTransaction: 1 + lsid: { $$sessionLsid: *session0 } + txnNumber: { $numberLong: '1' } + startTransaction: { $$exists: false } + autocommit: false + writeConcern: { $$exists: false } + commandName: abortTransaction + databaseName: admin + - + commandStartedEvent: + command: + abortTransaction: 1 + lsid: { $$sessionLsid: *session0 } + txnNumber: { $numberLong: '1' } + startTransaction: { $$exists: false } + autocommit: false + writeConcern: { $$exists: false } + commandName: abortTransaction + databaseName: admin + outcome: + - + collectionName: *collection_name + databaseName: *database_name + documents: [] + - + description: 'abortTransaction succeeds after HostUnreachable' + operations: + - + object: testRunner + name: failPoint + arguments: + client: *client0 + failPoint: + configureFailPoint: failCommand + mode: { times: 1 } + data: + failCommands: + - abortTransaction + errorCode: 6 + errorLabels: + - RetryableWriteError + closeConnection: false + - + object: *session0 + name: startTransaction + - + object: *collection0 + name: insertOne + arguments: + session: *session0 + document: { _id: 1 } + expectResult: + $$unsetOrMatches: { insertedId: { $$unsetOrMatches: 1 } } + - + object: *session0 + name: abortTransaction + expectEvents: + - + client: *client0 + events: + - + commandStartedEvent: + command: + insert: *collection_name + documents: + - { _id: 1 } + ordered: true + readConcern: { $$exists: false } + lsid: { $$sessionLsid: *session0 } + txnNumber: { $numberLong: '1' } + startTransaction: true + autocommit: false + writeConcern: { $$exists: false } + commandName: insert + databaseName: *database_name + - + commandStartedEvent: + command: + abortTransaction: 1 + lsid: { $$sessionLsid: *session0 } + txnNumber: { $numberLong: '1' } + startTransaction: { $$exists: false } + autocommit: false + writeConcern: { $$exists: false } + commandName: abortTransaction + databaseName: admin + - + commandStartedEvent: + command: + abortTransaction: 1 + lsid: { $$sessionLsid: *session0 } + txnNumber: { $numberLong: '1' } + startTransaction: { $$exists: false } + autocommit: false + writeConcern: { $$exists: false } + commandName: abortTransaction + databaseName: admin + outcome: + - + collectionName: *collection_name + databaseName: *database_name + documents: [] + - + description: 'abortTransaction succeeds after SocketException' + operations: + - + object: testRunner + name: failPoint + arguments: + client: *client0 + failPoint: + configureFailPoint: failCommand + mode: { times: 1 } + data: + failCommands: + - abortTransaction + errorCode: 9001 + errorLabels: + - RetryableWriteError + closeConnection: false + - + object: *session0 + name: startTransaction + - + object: *collection0 + name: insertOne + arguments: + session: *session0 + document: { _id: 1 } + expectResult: + $$unsetOrMatches: { insertedId: { $$unsetOrMatches: 1 } } + - + object: *session0 + name: abortTransaction + expectEvents: + - + client: *client0 + events: + - + commandStartedEvent: + command: + insert: *collection_name + documents: + - { _id: 1 } + ordered: true + readConcern: { $$exists: false } + lsid: { $$sessionLsid: *session0 } + txnNumber: { $numberLong: '1' } + startTransaction: true + autocommit: false + writeConcern: { $$exists: false } + commandName: insert + databaseName: *database_name + - + commandStartedEvent: + command: + abortTransaction: 1 + lsid: { $$sessionLsid: *session0 } + txnNumber: { $numberLong: '1' } + startTransaction: { $$exists: false } + autocommit: false + writeConcern: { $$exists: false } + commandName: abortTransaction + databaseName: admin + - + commandStartedEvent: + command: + abortTransaction: 1 + lsid: { $$sessionLsid: *session0 } + txnNumber: { $numberLong: '1' } + startTransaction: { $$exists: false } + autocommit: false + writeConcern: { $$exists: false } + commandName: abortTransaction + databaseName: admin + outcome: + - + collectionName: *collection_name + databaseName: *database_name + documents: [] + - + description: 'abortTransaction succeeds after NetworkTimeout' + operations: + - + object: testRunner + name: failPoint + arguments: + client: *client0 + failPoint: + configureFailPoint: failCommand + mode: { times: 1 } + data: + failCommands: + - abortTransaction + errorCode: 89 + errorLabels: + - RetryableWriteError + closeConnection: false + - + object: *session0 + name: startTransaction + - + object: *collection0 + name: insertOne + arguments: + session: *session0 + document: { _id: 1 } + expectResult: + $$unsetOrMatches: { insertedId: { $$unsetOrMatches: 1 } } + - + object: *session0 + name: abortTransaction + expectEvents: + - + client: *client0 + events: + - + commandStartedEvent: + command: + insert: *collection_name + documents: + - { _id: 1 } + ordered: true + readConcern: { $$exists: false } + lsid: { $$sessionLsid: *session0 } + txnNumber: { $numberLong: '1' } + startTransaction: true + autocommit: false + writeConcern: { $$exists: false } + commandName: insert + databaseName: *database_name + - + commandStartedEvent: + command: + abortTransaction: 1 + lsid: { $$sessionLsid: *session0 } + txnNumber: { $numberLong: '1' } + startTransaction: { $$exists: false } + autocommit: false + writeConcern: { $$exists: false } + commandName: abortTransaction + databaseName: admin + - + commandStartedEvent: + command: + abortTransaction: 1 + lsid: { $$sessionLsid: *session0 } + txnNumber: { $numberLong: '1' } + startTransaction: { $$exists: false } + autocommit: false + writeConcern: { $$exists: false } + commandName: abortTransaction + databaseName: admin + outcome: + - + collectionName: *collection_name + databaseName: *database_name + documents: [] + - + description: 'abortTransaction succeeds after WriteConcernError InterruptedAtShutdown' + operations: + - + object: testRunner + name: failPoint + arguments: + client: *client0 + failPoint: + configureFailPoint: failCommand + mode: { times: 1 } + data: + failCommands: + - abortTransaction + errorLabels: + - RetryableWriteError + writeConcernError: + code: 11600 + errmsg: 'Replication is being shut down' + - + object: *session0 + name: startTransaction + arguments: + writeConcern: + w: majority + - + object: *collection0 + name: insertOne + arguments: + session: *session0 + document: { _id: 1 } + expectResult: + $$unsetOrMatches: { insertedId: { $$unsetOrMatches: 1 } } + - + object: *session0 + name: abortTransaction + expectEvents: + - + client: *client0 + events: + - + commandStartedEvent: + command: + insert: *collection_name + documents: + - { _id: 1 } + ordered: true + readConcern: { $$exists: false } + lsid: { $$sessionLsid: *session0 } + txnNumber: { $numberLong: '1' } + startTransaction: true + autocommit: false + writeConcern: { $$exists: false } + commandName: insert + databaseName: *database_name + - + commandStartedEvent: + command: + abortTransaction: 1 + lsid: { $$sessionLsid: *session0 } + txnNumber: { $numberLong: '1' } + startTransaction: { $$exists: false } + autocommit: false + writeConcern: + w: majority + commandName: abortTransaction + databaseName: admin + - + commandStartedEvent: + command: + abortTransaction: 1 + lsid: { $$sessionLsid: *session0 } + txnNumber: { $numberLong: '1' } + startTransaction: { $$exists: false } + autocommit: false + writeConcern: + w: majority + commandName: abortTransaction + databaseName: admin + outcome: + - + collectionName: *collection_name + databaseName: *database_name + documents: [] + - + description: 'abortTransaction succeeds after WriteConcernError InterruptedDueToReplStateChange' + operations: + - + object: testRunner + name: failPoint + arguments: + client: *client0 + failPoint: + configureFailPoint: failCommand + mode: { times: 1 } + data: + failCommands: + - abortTransaction + errorLabels: + - RetryableWriteError + writeConcernError: + code: 11602 + errmsg: 'Replication is being shut down' + - + object: *session0 + name: startTransaction + arguments: + writeConcern: + w: majority + - + object: *collection0 + name: insertOne + arguments: + session: *session0 + document: { _id: 1 } + expectResult: + $$unsetOrMatches: { insertedId: { $$unsetOrMatches: 1 } } + - + object: *session0 + name: abortTransaction + expectEvents: + - + client: *client0 + events: + - + commandStartedEvent: + command: + insert: *collection_name + documents: + - { _id: 1 } + ordered: true + readConcern: { $$exists: false } + lsid: { $$sessionLsid: *session0 } + txnNumber: { $numberLong: '1' } + startTransaction: true + autocommit: false + writeConcern: { $$exists: false } + commandName: insert + databaseName: *database_name + - + commandStartedEvent: + command: + abortTransaction: 1 + lsid: { $$sessionLsid: *session0 } + txnNumber: { $numberLong: '1' } + startTransaction: { $$exists: false } + autocommit: false + writeConcern: + w: majority + commandName: abortTransaction + databaseName: admin + - + commandStartedEvent: + command: + abortTransaction: 1 + lsid: { $$sessionLsid: *session0 } + txnNumber: { $numberLong: '1' } + startTransaction: { $$exists: false } + autocommit: false + writeConcern: + w: majority + commandName: abortTransaction + databaseName: admin + outcome: + - + collectionName: *collection_name + databaseName: *database_name + documents: [] + - + description: 'abortTransaction succeeds after WriteConcernError PrimarySteppedDown' + operations: + - + object: testRunner + name: failPoint + arguments: + client: *client0 + failPoint: + configureFailPoint: failCommand + mode: { times: 1 } + data: + failCommands: + - abortTransaction + errorLabels: + - RetryableWriteError + writeConcernError: + code: 189 + errmsg: 'Replication is being shut down' + - + object: *session0 + name: startTransaction + arguments: + writeConcern: + w: majority + - + object: *collection0 + name: insertOne + arguments: + session: *session0 + document: { _id: 1 } + expectResult: + $$unsetOrMatches: { insertedId: { $$unsetOrMatches: 1 } } + - + object: *session0 + name: abortTransaction + expectEvents: + - + client: *client0 + events: + - + commandStartedEvent: + command: + insert: *collection_name + documents: + - { _id: 1 } + ordered: true + readConcern: { $$exists: false } + lsid: { $$sessionLsid: *session0 } + txnNumber: { $numberLong: '1' } + startTransaction: true + autocommit: false + writeConcern: { $$exists: false } + commandName: insert + databaseName: *database_name + - + commandStartedEvent: + command: + abortTransaction: 1 + lsid: { $$sessionLsid: *session0 } + txnNumber: { $numberLong: '1' } + startTransaction: { $$exists: false } + autocommit: false + writeConcern: + w: majority + commandName: abortTransaction + databaseName: admin + - + commandStartedEvent: + command: + abortTransaction: 1 + lsid: { $$sessionLsid: *session0 } + txnNumber: { $numberLong: '1' } + startTransaction: { $$exists: false } + autocommit: false + writeConcern: + w: majority + commandName: abortTransaction + databaseName: admin + outcome: + - + collectionName: *collection_name + databaseName: *database_name + documents: [] + - + description: 'abortTransaction succeeds after WriteConcernError ShutdownInProgress' + operations: + - + object: testRunner + name: failPoint + arguments: + client: *client0 + failPoint: + configureFailPoint: failCommand + mode: { times: 1 } + data: + failCommands: + - abortTransaction + errorLabels: + - RetryableWriteError + writeConcernError: + code: 91 + errmsg: 'Replication is being shut down' + - + object: *session0 + name: startTransaction + arguments: + writeConcern: + w: majority + - + object: *collection0 + name: insertOne + arguments: + session: *session0 + document: { _id: 1 } + expectResult: + $$unsetOrMatches: { insertedId: { $$unsetOrMatches: 1 } } + - + object: *session0 + name: abortTransaction + expectEvents: + - + client: *client0 + events: + - + commandStartedEvent: + command: + insert: *collection_name + documents: + - { _id: 1 } + ordered: true + readConcern: { $$exists: false } + lsid: { $$sessionLsid: *session0 } + txnNumber: { $numberLong: '1' } + startTransaction: true + autocommit: false + writeConcern: { $$exists: false } + commandName: insert + databaseName: *database_name + - + commandStartedEvent: + command: + abortTransaction: 1 + lsid: { $$sessionLsid: *session0 } + txnNumber: { $numberLong: '1' } + startTransaction: { $$exists: false } + autocommit: false + writeConcern: + w: majority + commandName: abortTransaction + databaseName: admin + - + commandStartedEvent: + command: + abortTransaction: 1 + lsid: { $$sessionLsid: *session0 } + txnNumber: { $numberLong: '1' } + startTransaction: { $$exists: false } + autocommit: false + writeConcern: + w: majority + commandName: abortTransaction + databaseName: admin + outcome: + - + collectionName: *collection_name + databaseName: *database_name + documents: [] diff --git a/source/transactions/tests/unified/retryable-abort-handshake.yml b/source/transactions/tests/unified/retryable-abort-handshake.yml index d0e9ec86b4..2d91b75a99 100644 --- a/source/transactions/tests/unified/retryable-abort-handshake.yml +++ b/source/transactions/tests/unified/retryable-abort-handshake.yml @@ -106,8 +106,7 @@ tests: - commandStartedEvent: command: abortTransaction: 1 - lsid: - $$sessionLsid: *session0 + lsid: { $$sessionLsid: *session0 } commandName: abortTransaction databaseName: admin diff --git a/source/transactions/tests/unified/retryable-abort.json b/source/transactions/tests/unified/retryable-abort.json new file mode 100644 index 0000000000..381cfa91f8 --- /dev/null +++ b/source/transactions/tests/unified/retryable-abort.json @@ -0,0 +1,600 @@ +{ + "description": "retryable-abort", + "schemaVersion": "1.3", + "runOnRequirements": [ + { + "minServerVersion": "4.0", + "topologies": [ + "replicaset" + ] + }, + { + "minServerVersion": "4.1.8", + "topologies": [ + "sharded", + "load-balanced" + ] + } + ], + "createEntities": [ + { + "client": { + "id": "client0", + "useMultipleMongoses": false, + "observeEvents": [ + "commandStartedEvent" + ] + } + }, + { + "database": { + "id": "database0", + "client": "client0", + "databaseName": "transaction-tests" + } + }, + { + "collection": { + "id": "collection0", + "database": "database0", + "collectionName": "test" + } + }, + { + "session": { + "id": "session0", + "client": "client0" + } + }, + { + "client": { + "id": "client1", + "useMultipleMongoses": false, + "uriOptions": { + "retryWrites": false + }, + "observeEvents": [ + "commandStartedEvent" + ] + } + }, + { + "database": { + "id": "database1", + "client": "client1", + "databaseName": "transaction-tests" + } + }, + { + "collection": { + "id": "collection1", + "database": "database1", + "collectionName": "test" + } + }, + { + "session": { + "id": "session1", + "client": "client1" + } + } + ], + "initialData": [ + { + "collectionName": "test", + "databaseName": "transaction-tests", + "documents": [] + } + ], + "tests": [ + { + "description": "abortTransaction only performs a single retry", + "operations": [ + { + "object": "testRunner", + "name": "failPoint", + "arguments": { + "client": "client1", + "failPoint": { + "configureFailPoint": "failCommand", + "mode": { + "times": 2 + }, + "data": { + "failCommands": [ + "abortTransaction" + ], + "closeConnection": true + } + } + } + }, + { + "object": "session1", + "name": "startTransaction" + }, + { + "object": "collection1", + "name": "insertOne", + "arguments": { + "session": "session1", + "document": { + "_id": 1 + } + }, + "expectResult": { + "$$unsetOrMatches": { + "insertedId": { + "$$unsetOrMatches": 1 + } + } + } + }, + { + "object": "session1", + "name": "abortTransaction" + } + ], + "expectEvents": [ + { + "client": "client1", + "events": [ + { + "commandStartedEvent": { + "command": { + "insert": "test", + "documents": [ + { + "_id": 1 + } + ], + "ordered": true, + "readConcern": { + "$$exists": false + }, + "lsid": { + "$$sessionLsid": "session1" + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": true, + "autocommit": false, + "writeConcern": { + "$$exists": false + } + }, + "commandName": "insert", + "databaseName": "transaction-tests" + } + }, + { + "commandStartedEvent": { + "command": { + "abortTransaction": 1, + "lsid": { + "$$sessionLsid": "session1" + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": { + "$$exists": false + }, + "autocommit": false, + "writeConcern": { + "$$exists": false + } + }, + "commandName": "abortTransaction", + "databaseName": "admin" + } + }, + { + "commandStartedEvent": { + "command": { + "abortTransaction": 1, + "lsid": { + "$$sessionLsid": "session1" + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": { + "$$exists": false + }, + "autocommit": false, + "writeConcern": { + "$$exists": false + } + }, + "commandName": "abortTransaction", + "databaseName": "admin" + } + } + ] + } + ], + "outcome": [ + { + "collectionName": "test", + "databaseName": "transaction-tests", + "documents": [] + } + ] + }, + { + "description": "abortTransaction does not retry after Interrupted", + "operations": [ + { + "object": "testRunner", + "name": "failPoint", + "arguments": { + "client": "client0", + "failPoint": { + "configureFailPoint": "failCommand", + "mode": { + "times": 1 + }, + "data": { + "failCommands": [ + "abortTransaction" + ], + "errorCode": 11601, + "closeConnection": false + } + } + } + }, + { + "object": "session0", + "name": "startTransaction" + }, + { + "object": "collection0", + "name": "insertOne", + "arguments": { + "session": "session0", + "document": { + "_id": 1 + } + }, + "expectResult": { + "$$unsetOrMatches": { + "insertedId": { + "$$unsetOrMatches": 1 + } + } + } + }, + { + "object": "session0", + "name": "abortTransaction" + } + ], + "expectEvents": [ + { + "client": "client0", + "events": [ + { + "commandStartedEvent": { + "command": { + "insert": "test", + "documents": [ + { + "_id": 1 + } + ], + "ordered": true, + "readConcern": { + "$$exists": false + }, + "lsid": { + "$$sessionLsid": "session0" + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": true, + "autocommit": false, + "writeConcern": { + "$$exists": false + } + }, + "commandName": "insert", + "databaseName": "transaction-tests" + } + }, + { + "commandStartedEvent": { + "command": { + "abortTransaction": 1, + "lsid": { + "$$sessionLsid": "session0" + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": { + "$$exists": false + }, + "autocommit": false, + "writeConcern": { + "$$exists": false + } + }, + "commandName": "abortTransaction", + "databaseName": "admin" + } + } + ] + } + ], + "outcome": [ + { + "collectionName": "test", + "databaseName": "transaction-tests", + "documents": [] + } + ] + }, + { + "description": "abortTransaction does not retry after WriteConcernError Interrupted", + "operations": [ + { + "object": "testRunner", + "name": "failPoint", + "arguments": { + "client": "client0", + "failPoint": { + "configureFailPoint": "failCommand", + "mode": { + "times": 1 + }, + "data": { + "failCommands": [ + "abortTransaction" + ], + "writeConcernError": { + "code": 11601, + "errmsg": "operation was interrupted" + } + } + } + } + }, + { + "object": "session0", + "name": "startTransaction", + "arguments": { + "writeConcern": { + "w": "majority" + } + } + }, + { + "object": "collection0", + "name": "insertOne", + "arguments": { + "session": "session0", + "document": { + "_id": 1 + } + }, + "expectResult": { + "$$unsetOrMatches": { + "insertedId": { + "$$unsetOrMatches": 1 + } + } + } + }, + { + "object": "session0", + "name": "abortTransaction" + } + ], + "expectEvents": [ + { + "client": "client0", + "events": [ + { + "commandStartedEvent": { + "command": { + "insert": "test", + "documents": [ + { + "_id": 1 + } + ], + "ordered": true, + "readConcern": { + "$$exists": false + }, + "lsid": { + "$$sessionLsid": "session0" + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": true, + "autocommit": false, + "writeConcern": { + "$$exists": false + } + }, + "commandName": "insert", + "databaseName": "transaction-tests" + } + }, + { + "commandStartedEvent": { + "command": { + "abortTransaction": 1, + "lsid": { + "$$sessionLsid": "session0" + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": { + "$$exists": false + }, + "autocommit": false, + "writeConcern": { + "w": "majority" + } + }, + "commandName": "abortTransaction", + "databaseName": "admin" + } + } + ] + } + ], + "outcome": [ + { + "collectionName": "test", + "databaseName": "transaction-tests", + "documents": [] + } + ] + }, + { + "description": "abortTransaction succeeds after connection error", + "operations": [ + { + "object": "testRunner", + "name": "failPoint", + "arguments": { + "client": "client0", + "failPoint": { + "configureFailPoint": "failCommand", + "mode": { + "times": 1 + }, + "data": { + "failCommands": [ + "abortTransaction" + ], + "closeConnection": true + } + } + } + }, + { + "object": "session0", + "name": "startTransaction" + }, + { + "object": "collection0", + "name": "insertOne", + "arguments": { + "session": "session0", + "document": { + "_id": 1 + } + }, + "expectResult": { + "$$unsetOrMatches": { + "insertedId": { + "$$unsetOrMatches": 1 + } + } + } + }, + { + "object": "session0", + "name": "abortTransaction" + } + ], + "expectEvents": [ + { + "client": "client0", + "events": [ + { + "commandStartedEvent": { + "command": { + "insert": "test", + "documents": [ + { + "_id": 1 + } + ], + "ordered": true, + "readConcern": { + "$$exists": false + }, + "lsid": { + "$$sessionLsid": "session0" + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": true, + "autocommit": false, + "writeConcern": { + "$$exists": false + } + }, + "commandName": "insert", + "databaseName": "transaction-tests" + } + }, + { + "commandStartedEvent": { + "command": { + "abortTransaction": 1, + "lsid": { + "$$sessionLsid": "session0" + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": { + "$$exists": false + }, + "autocommit": false, + "writeConcern": { + "$$exists": false + } + }, + "commandName": "abortTransaction", + "databaseName": "admin" + } + }, + { + "commandStartedEvent": { + "command": { + "abortTransaction": 1, + "lsid": { + "$$sessionLsid": "session0" + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": { + "$$exists": false + }, + "autocommit": false, + "writeConcern": { + "$$exists": false + } + }, + "commandName": "abortTransaction", + "databaseName": "admin" + } + } + ] + } + ], + "outcome": [ + { + "collectionName": "test", + "databaseName": "transaction-tests", + "documents": [] + } + ] + } + ] +} diff --git a/source/transactions/tests/unified/retryable-abort.yml b/source/transactions/tests/unified/retryable-abort.yml new file mode 100644 index 0000000000..602c92aec0 --- /dev/null +++ b/source/transactions/tests/unified/retryable-abort.yml @@ -0,0 +1,352 @@ +description: retryable-abort + +schemaVersion: '1.3' + +runOnRequirements: + - + minServerVersion: '4.0' + topologies: + - replicaset + - + minServerVersion: 4.1.8 + topologies: + - sharded + - load-balanced + +createEntities: + - + client: + id: &client0 client0 + useMultipleMongoses: false + observeEvents: + - commandStartedEvent + - + database: + id: &database0 database0 + client: *client0 + databaseName: &database_name transaction-tests + - + collection: + id: &collection0 collection0 + database: *database0 + collectionName: &collection_name test + - + session: + id: &session0 session0 + client: *client0 + # Define a second set of entities for a retryWrites=false client + - + client: + id: &client1 client1 + useMultipleMongoses: false + uriOptions: + retryWrites: false + observeEvents: + - commandStartedEvent + - + database: + id: &database1 database1 + client: *client1 + databaseName: *database_name + - + collection: + id: &collection1 collection1 + database: *database1 + collectionName: *collection_name + - + session: + id: &session1 session1 + client: *client1 + +initialData: + - + collectionName: *collection_name + databaseName: *database_name + documents: [] + +tests: + - + description: 'abortTransaction only performs a single retry' + operations: + - + object: testRunner + name: failPoint + arguments: + client: *client1 + failPoint: + configureFailPoint: failCommand + mode: { times: 2 } + data: + failCommands: + - abortTransaction + closeConnection: true + - + object: *session1 + name: startTransaction + - + object: *collection1 + name: insertOne + arguments: + session: *session1 + document: { _id: 1 } + expectResult: + $$unsetOrMatches: { insertedId: { $$unsetOrMatches: 1 } } + - + object: *session1 + name: abortTransaction + expectEvents: + - + client: *client1 + events: + - + commandStartedEvent: + command: + insert: *collection_name + documents: + - { _id: 1 } + ordered: true + readConcern: { $$exists: false } + lsid: { $$sessionLsid: *session1 } + txnNumber: { $numberLong: '1' } + startTransaction: true + autocommit: false + writeConcern: { $$exists: false } + commandName: insert + databaseName: *database_name + - + commandStartedEvent: + command: + abortTransaction: 1 + lsid: { $$sessionLsid: *session1 } + txnNumber: { $numberLong: '1' } + startTransaction: { $$exists: false } + autocommit: false + writeConcern: { $$exists: false } + commandName: abortTransaction + databaseName: admin + - + commandStartedEvent: + command: + abortTransaction: 1 + lsid: { $$sessionLsid: *session1 } + txnNumber: { $numberLong: '1' } + startTransaction: { $$exists: false } + autocommit: false + writeConcern: { $$exists: false } + commandName: abortTransaction + databaseName: admin + outcome: + - + collectionName: *collection_name + databaseName: *database_name + documents: [] + - + description: 'abortTransaction does not retry after Interrupted' + operations: + - + object: testRunner + name: failPoint + arguments: + client: *client0 + failPoint: + configureFailPoint: failCommand + mode: { times: 1 } + data: + failCommands: + - abortTransaction + errorCode: 11601 + closeConnection: false + - + object: *session0 + name: startTransaction + - + object: *collection0 + name: insertOne + arguments: + session: *session0 + document: { _id: 1 } + expectResult: + $$unsetOrMatches: { insertedId: { $$unsetOrMatches: 1 } } + - + object: *session0 + name: abortTransaction + expectEvents: + - + client: *client0 + events: + - + commandStartedEvent: + command: + insert: *collection_name + documents: + - { _id: 1 } + ordered: true + readConcern: { $$exists: false } + lsid: { $$sessionLsid: *session0 } + txnNumber: { $numberLong: '1' } + startTransaction: true + autocommit: false + writeConcern: { $$exists: false } + commandName: insert + databaseName: *database_name + - + commandStartedEvent: + command: + abortTransaction: 1 + lsid: { $$sessionLsid: *session0 } + txnNumber: { $numberLong: '1' } + startTransaction: { $$exists: false } + autocommit: false + writeConcern: { $$exists: false } + commandName: abortTransaction + databaseName: admin + outcome: + - + collectionName: *collection_name + databaseName: *database_name + documents: [] + - + description: 'abortTransaction does not retry after WriteConcernError Interrupted' + operations: + - + object: testRunner + name: failPoint + arguments: + client: *client0 + failPoint: + configureFailPoint: failCommand + mode: { times: 1 } + data: + failCommands: + - abortTransaction + writeConcernError: + code: 11601 + errmsg: 'operation was interrupted' + - + object: *session0 + name: startTransaction + arguments: + writeConcern: + w: majority + - + object: *collection0 + name: insertOne + arguments: + session: *session0 + document: { _id: 1 } + expectResult: + $$unsetOrMatches: { insertedId: { $$unsetOrMatches: 1 } } + - + object: *session0 + name: abortTransaction + expectEvents: + - + client: *client0 + events: + - + commandStartedEvent: + command: + insert: *collection_name + documents: + - { _id: 1 } + ordered: true + readConcern: { $$exists: false } + lsid: { $$sessionLsid: *session0 } + txnNumber: { $numberLong: '1' } + startTransaction: true + autocommit: false + writeConcern: { $$exists: false } + commandName: insert + databaseName: *database_name + - + commandStartedEvent: + command: + abortTransaction: 1 + lsid: { $$sessionLsid: *session0 } + txnNumber: { $numberLong: '1' } + startTransaction: { $$exists: false } + autocommit: false + writeConcern: + w: majority + commandName: abortTransaction + databaseName: admin + outcome: + - + collectionName: *collection_name + databaseName: *database_name + documents: [] + - + description: 'abortTransaction succeeds after connection error' + operations: + - + object: testRunner + name: failPoint + arguments: + client: *client0 + failPoint: + configureFailPoint: failCommand + mode: { times: 1 } + data: + failCommands: + - abortTransaction + closeConnection: true + - + object: *session0 + name: startTransaction + - + object: *collection0 + name: insertOne + arguments: + session: *session0 + document: { _id: 1 } + expectResult: + $$unsetOrMatches: { insertedId: { $$unsetOrMatches: 1 } } + - + object: *session0 + name: abortTransaction + expectEvents: + - + client: *client0 + events: + - + commandStartedEvent: + command: + insert: *collection_name + documents: + - { _id: 1 } + ordered: true + readConcern: { $$exists: false } + lsid: { $$sessionLsid: *session0 } + txnNumber: { $numberLong: '1' } + startTransaction: true + autocommit: false + writeConcern: { $$exists: false } + commandName: insert + databaseName: *database_name + - + commandStartedEvent: + command: + abortTransaction: 1 + lsid: { $$sessionLsid: *session0 } + txnNumber: { $numberLong: '1' } + startTransaction: { $$exists: false } + autocommit: false + writeConcern: { $$exists: false } + commandName: abortTransaction + databaseName: admin + - + commandStartedEvent: + command: + abortTransaction: 1 + lsid: { $$sessionLsid: *session0 } + txnNumber: { $numberLong: '1' } + startTransaction: { $$exists: false } + autocommit: false + writeConcern: { $$exists: false } + commandName: abortTransaction + databaseName: admin + outcome: + - + collectionName: *collection_name + databaseName: *database_name + documents: [] diff --git a/source/transactions/tests/unified/retryable-commit-errorLabels.json b/source/transactions/tests/unified/retryable-commit-errorLabels.json new file mode 100644 index 0000000000..d3ce8b148e --- /dev/null +++ b/source/transactions/tests/unified/retryable-commit-errorLabels.json @@ -0,0 +1,2564 @@ +{ + "description": "retryable-commit-errorLabels", + "schemaVersion": "1.4", + "runOnRequirements": [ + { + "minServerVersion": "4.3.1", + "topologies": [ + "replicaset", + "sharded", + "load-balanced" + ] + } + ], + "createEntities": [ + { + "client": { + "id": "client0", + "useMultipleMongoses": false, + "observeEvents": [ + "commandStartedEvent" + ] + } + }, + { + "database": { + "id": "database0", + "client": "client0", + "databaseName": "transaction-tests" + } + }, + { + "collection": { + "id": "collection0", + "database": "database0", + "collectionName": "test" + } + }, + { + "session": { + "id": "session0", + "client": "client0" + } + }, + { + "client": { + "id": "client1", + "useMultipleMongoses": false, + "uriOptions": { + "retryWrites": false + }, + "observeEvents": [ + "commandStartedEvent" + ] + } + }, + { + "database": { + "id": "database1", + "client": "client1", + "databaseName": "transaction-tests" + } + }, + { + "collection": { + "id": "collection1", + "database": "database1", + "collectionName": "test" + } + }, + { + "session": { + "id": "session1", + "client": "client1" + } + } + ], + "initialData": [ + { + "collectionName": "test", + "databaseName": "transaction-tests", + "documents": [] + } + ], + "tests": [ + { + "description": "commitTransaction does not retry error without RetryableWriteError label", + "operations": [ + { + "object": "testRunner", + "name": "failPoint", + "arguments": { + "client": "client1", + "failPoint": { + "configureFailPoint": "failCommand", + "mode": { + "times": 1 + }, + "data": { + "failCommands": [ + "commitTransaction" + ], + "errorCode": 11600, + "errorLabels": [] + } + } + } + }, + { + "object": "session1", + "name": "startTransaction" + }, + { + "object": "collection1", + "name": "insertOne", + "arguments": { + "session": "session1", + "document": { + "_id": 1 + } + }, + "expectResult": { + "$$unsetOrMatches": { + "insertedId": { + "$$unsetOrMatches": 1 + } + } + } + }, + { + "object": "session1", + "name": "commitTransaction", + "expectError": { + "errorLabelsOmit": [ + "RetryableWriteError", + "TransientTransactionError" + ] + } + } + ], + "expectEvents": [ + { + "client": "client1", + "events": [ + { + "commandStartedEvent": { + "command": { + "insert": "test", + "documents": [ + { + "_id": 1 + } + ], + "ordered": true, + "readConcern": { + "$$exists": false + }, + "lsid": { + "$$sessionLsid": "session1" + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": true, + "autocommit": false, + "writeConcern": { + "$$exists": false + } + }, + "commandName": "insert", + "databaseName": "transaction-tests" + } + }, + { + "commandStartedEvent": { + "command": { + "commitTransaction": 1, + "lsid": { + "$$sessionLsid": "session1" + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": { + "$$exists": false + }, + "autocommit": false, + "writeConcern": { + "$$exists": false + } + }, + "commandName": "commitTransaction", + "databaseName": "admin" + } + } + ] + } + ], + "outcome": [ + { + "collectionName": "test", + "databaseName": "transaction-tests", + "documents": [] + } + ] + }, + { + "description": "commitTransaction retries once with RetryableWriteError from server", + "operations": [ + { + "object": "testRunner", + "name": "failPoint", + "arguments": { + "client": "client1", + "failPoint": { + "configureFailPoint": "failCommand", + "mode": { + "times": 1 + }, + "data": { + "failCommands": [ + "commitTransaction" + ], + "errorCode": 112, + "errorLabels": [ + "RetryableWriteError" + ] + } + } + } + }, + { + "object": "session1", + "name": "startTransaction" + }, + { + "object": "collection1", + "name": "insertOne", + "arguments": { + "session": "session1", + "document": { + "_id": 1 + } + }, + "expectResult": { + "$$unsetOrMatches": { + "insertedId": { + "$$unsetOrMatches": 1 + } + } + } + }, + { + "object": "session1", + "name": "commitTransaction" + } + ], + "expectEvents": [ + { + "client": "client1", + "events": [ + { + "commandStartedEvent": { + "command": { + "insert": "test", + "documents": [ + { + "_id": 1 + } + ], + "ordered": true, + "readConcern": { + "$$exists": false + }, + "lsid": { + "$$sessionLsid": "session1" + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": true, + "autocommit": false, + "writeConcern": { + "$$exists": false + } + }, + "commandName": "insert", + "databaseName": "transaction-tests" + } + }, + { + "commandStartedEvent": { + "command": { + "commitTransaction": 1, + "lsid": { + "$$sessionLsid": "session1" + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": { + "$$exists": false + }, + "autocommit": false, + "writeConcern": { + "$$exists": false + } + }, + "commandName": "commitTransaction", + "databaseName": "admin" + } + }, + { + "commandStartedEvent": { + "command": { + "commitTransaction": 1, + "lsid": { + "$$sessionLsid": "session1" + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": { + "$$exists": false + }, + "autocommit": false, + "writeConcern": { + "w": "majority", + "wtimeout": 10000 + } + }, + "commandName": "commitTransaction", + "databaseName": "admin" + } + } + ] + } + ], + "outcome": [ + { + "collectionName": "test", + "databaseName": "transaction-tests", + "documents": [ + { + "_id": 1 + } + ] + } + ] + }, + { + "description": "commitTransaction succeeds after NotWritablePrimary", + "operations": [ + { + "object": "testRunner", + "name": "failPoint", + "arguments": { + "client": "client0", + "failPoint": { + "configureFailPoint": "failCommand", + "mode": { + "times": 1 + }, + "data": { + "failCommands": [ + "commitTransaction" + ], + "errorCode": 10107, + "errorLabels": [ + "RetryableWriteError" + ], + "closeConnection": false + } + } + } + }, + { + "object": "session0", + "name": "startTransaction" + }, + { + "object": "collection0", + "name": "insertOne", + "arguments": { + "session": "session0", + "document": { + "_id": 1 + } + }, + "expectResult": { + "$$unsetOrMatches": { + "insertedId": { + "$$unsetOrMatches": 1 + } + } + } + }, + { + "object": "session0", + "name": "commitTransaction" + } + ], + "expectEvents": [ + { + "client": "client0", + "events": [ + { + "commandStartedEvent": { + "command": { + "insert": "test", + "documents": [ + { + "_id": 1 + } + ], + "ordered": true, + "readConcern": { + "$$exists": false + }, + "lsid": { + "$$sessionLsid": "session0" + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": true, + "autocommit": false, + "writeConcern": { + "$$exists": false + } + }, + "commandName": "insert", + "databaseName": "transaction-tests" + } + }, + { + "commandStartedEvent": { + "command": { + "commitTransaction": 1, + "lsid": { + "$$sessionLsid": "session0" + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": { + "$$exists": false + }, + "autocommit": false, + "writeConcern": { + "$$exists": false + } + }, + "commandName": "commitTransaction", + "databaseName": "admin" + } + }, + { + "commandStartedEvent": { + "command": { + "commitTransaction": 1, + "lsid": { + "$$sessionLsid": "session0" + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": { + "$$exists": false + }, + "autocommit": false, + "writeConcern": { + "w": "majority", + "wtimeout": 10000 + } + }, + "commandName": "commitTransaction", + "databaseName": "admin" + } + } + ] + } + ], + "outcome": [ + { + "collectionName": "test", + "databaseName": "transaction-tests", + "documents": [ + { + "_id": 1 + } + ] + } + ] + }, + { + "description": "commitTransaction succeeds after NotPrimaryOrSecondary", + "operations": [ + { + "object": "testRunner", + "name": "failPoint", + "arguments": { + "client": "client0", + "failPoint": { + "configureFailPoint": "failCommand", + "mode": { + "times": 1 + }, + "data": { + "failCommands": [ + "commitTransaction" + ], + "errorCode": 13436, + "errorLabels": [ + "RetryableWriteError" + ], + "closeConnection": false + } + } + } + }, + { + "object": "session0", + "name": "startTransaction" + }, + { + "object": "collection0", + "name": "insertOne", + "arguments": { + "session": "session0", + "document": { + "_id": 1 + } + }, + "expectResult": { + "$$unsetOrMatches": { + "insertedId": { + "$$unsetOrMatches": 1 + } + } + } + }, + { + "object": "session0", + "name": "commitTransaction" + } + ], + "expectEvents": [ + { + "client": "client0", + "events": [ + { + "commandStartedEvent": { + "command": { + "insert": "test", + "documents": [ + { + "_id": 1 + } + ], + "ordered": true, + "readConcern": { + "$$exists": false + }, + "lsid": { + "$$sessionLsid": "session0" + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": true, + "autocommit": false, + "writeConcern": { + "$$exists": false + } + }, + "commandName": "insert", + "databaseName": "transaction-tests" + } + }, + { + "commandStartedEvent": { + "command": { + "commitTransaction": 1, + "lsid": { + "$$sessionLsid": "session0" + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": { + "$$exists": false + }, + "autocommit": false, + "writeConcern": { + "$$exists": false + } + }, + "commandName": "commitTransaction", + "databaseName": "admin" + } + }, + { + "commandStartedEvent": { + "command": { + "commitTransaction": 1, + "lsid": { + "$$sessionLsid": "session0" + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": { + "$$exists": false + }, + "autocommit": false, + "writeConcern": { + "w": "majority", + "wtimeout": 10000 + } + }, + "commandName": "commitTransaction", + "databaseName": "admin" + } + } + ] + } + ], + "outcome": [ + { + "collectionName": "test", + "databaseName": "transaction-tests", + "documents": [ + { + "_id": 1 + } + ] + } + ] + }, + { + "description": "commitTransaction succeeds after NotPrimaryNoSecondaryOk", + "operations": [ + { + "object": "testRunner", + "name": "failPoint", + "arguments": { + "client": "client0", + "failPoint": { + "configureFailPoint": "failCommand", + "mode": { + "times": 1 + }, + "data": { + "failCommands": [ + "commitTransaction" + ], + "errorCode": 13435, + "errorLabels": [ + "RetryableWriteError" + ], + "closeConnection": false + } + } + } + }, + { + "object": "session0", + "name": "startTransaction" + }, + { + "object": "collection0", + "name": "insertOne", + "arguments": { + "session": "session0", + "document": { + "_id": 1 + } + }, + "expectResult": { + "$$unsetOrMatches": { + "insertedId": { + "$$unsetOrMatches": 1 + } + } + } + }, + { + "object": "session0", + "name": "commitTransaction" + } + ], + "expectEvents": [ + { + "client": "client0", + "events": [ + { + "commandStartedEvent": { + "command": { + "insert": "test", + "documents": [ + { + "_id": 1 + } + ], + "ordered": true, + "readConcern": { + "$$exists": false + }, + "lsid": { + "$$sessionLsid": "session0" + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": true, + "autocommit": false, + "writeConcern": { + "$$exists": false + } + }, + "commandName": "insert", + "databaseName": "transaction-tests" + } + }, + { + "commandStartedEvent": { + "command": { + "commitTransaction": 1, + "lsid": { + "$$sessionLsid": "session0" + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": { + "$$exists": false + }, + "autocommit": false, + "writeConcern": { + "$$exists": false + } + }, + "commandName": "commitTransaction", + "databaseName": "admin" + } + }, + { + "commandStartedEvent": { + "command": { + "commitTransaction": 1, + "lsid": { + "$$sessionLsid": "session0" + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": { + "$$exists": false + }, + "autocommit": false, + "writeConcern": { + "w": "majority", + "wtimeout": 10000 + } + }, + "commandName": "commitTransaction", + "databaseName": "admin" + } + } + ] + } + ], + "outcome": [ + { + "collectionName": "test", + "databaseName": "transaction-tests", + "documents": [ + { + "_id": 1 + } + ] + } + ] + }, + { + "description": "commitTransaction succeeds after InterruptedDueToReplStateChange", + "operations": [ + { + "object": "testRunner", + "name": "failPoint", + "arguments": { + "client": "client0", + "failPoint": { + "configureFailPoint": "failCommand", + "mode": { + "times": 1 + }, + "data": { + "failCommands": [ + "commitTransaction" + ], + "errorCode": 11602, + "errorLabels": [ + "RetryableWriteError" + ], + "closeConnection": false + } + } + } + }, + { + "object": "session0", + "name": "startTransaction" + }, + { + "object": "collection0", + "name": "insertOne", + "arguments": { + "session": "session0", + "document": { + "_id": 1 + } + }, + "expectResult": { + "$$unsetOrMatches": { + "insertedId": { + "$$unsetOrMatches": 1 + } + } + } + }, + { + "object": "session0", + "name": "commitTransaction" + } + ], + "expectEvents": [ + { + "client": "client0", + "events": [ + { + "commandStartedEvent": { + "command": { + "insert": "test", + "documents": [ + { + "_id": 1 + } + ], + "ordered": true, + "readConcern": { + "$$exists": false + }, + "lsid": { + "$$sessionLsid": "session0" + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": true, + "autocommit": false, + "writeConcern": { + "$$exists": false + } + }, + "commandName": "insert", + "databaseName": "transaction-tests" + } + }, + { + "commandStartedEvent": { + "command": { + "commitTransaction": 1, + "lsid": { + "$$sessionLsid": "session0" + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": { + "$$exists": false + }, + "autocommit": false, + "writeConcern": { + "$$exists": false + } + }, + "commandName": "commitTransaction", + "databaseName": "admin" + } + }, + { + "commandStartedEvent": { + "command": { + "commitTransaction": 1, + "lsid": { + "$$sessionLsid": "session0" + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": { + "$$exists": false + }, + "autocommit": false, + "writeConcern": { + "w": "majority", + "wtimeout": 10000 + } + }, + "commandName": "commitTransaction", + "databaseName": "admin" + } + } + ] + } + ], + "outcome": [ + { + "collectionName": "test", + "databaseName": "transaction-tests", + "documents": [ + { + "_id": 1 + } + ] + } + ] + }, + { + "description": "commitTransaction succeeds after PrimarySteppedDown", + "operations": [ + { + "object": "testRunner", + "name": "failPoint", + "arguments": { + "client": "client0", + "failPoint": { + "configureFailPoint": "failCommand", + "mode": { + "times": 1 + }, + "data": { + "failCommands": [ + "commitTransaction" + ], + "errorCode": 189, + "errorLabels": [ + "RetryableWriteError" + ], + "closeConnection": false + } + } + } + }, + { + "object": "session0", + "name": "startTransaction" + }, + { + "object": "collection0", + "name": "insertOne", + "arguments": { + "session": "session0", + "document": { + "_id": 1 + } + }, + "expectResult": { + "$$unsetOrMatches": { + "insertedId": { + "$$unsetOrMatches": 1 + } + } + } + }, + { + "object": "session0", + "name": "commitTransaction" + } + ], + "expectEvents": [ + { + "client": "client0", + "events": [ + { + "commandStartedEvent": { + "command": { + "insert": "test", + "documents": [ + { + "_id": 1 + } + ], + "ordered": true, + "readConcern": { + "$$exists": false + }, + "lsid": { + "$$sessionLsid": "session0" + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": true, + "autocommit": false, + "writeConcern": { + "$$exists": false + } + }, + "commandName": "insert", + "databaseName": "transaction-tests" + } + }, + { + "commandStartedEvent": { + "command": { + "commitTransaction": 1, + "lsid": { + "$$sessionLsid": "session0" + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": { + "$$exists": false + }, + "autocommit": false, + "writeConcern": { + "$$exists": false + } + }, + "commandName": "commitTransaction", + "databaseName": "admin" + } + }, + { + "commandStartedEvent": { + "command": { + "commitTransaction": 1, + "lsid": { + "$$sessionLsid": "session0" + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": { + "$$exists": false + }, + "autocommit": false, + "writeConcern": { + "w": "majority", + "wtimeout": 10000 + } + }, + "commandName": "commitTransaction", + "databaseName": "admin" + } + } + ] + } + ], + "outcome": [ + { + "collectionName": "test", + "databaseName": "transaction-tests", + "documents": [ + { + "_id": 1 + } + ] + } + ] + }, + { + "description": "commitTransaction succeeds after HostNotFound", + "operations": [ + { + "object": "testRunner", + "name": "failPoint", + "arguments": { + "client": "client0", + "failPoint": { + "configureFailPoint": "failCommand", + "mode": { + "times": 1 + }, + "data": { + "failCommands": [ + "commitTransaction" + ], + "errorCode": 7, + "errorLabels": [ + "RetryableWriteError" + ], + "closeConnection": false + } + } + } + }, + { + "object": "session0", + "name": "startTransaction" + }, + { + "object": "collection0", + "name": "insertOne", + "arguments": { + "session": "session0", + "document": { + "_id": 1 + } + }, + "expectResult": { + "$$unsetOrMatches": { + "insertedId": { + "$$unsetOrMatches": 1 + } + } + } + }, + { + "object": "session0", + "name": "commitTransaction" + } + ], + "expectEvents": [ + { + "client": "client0", + "events": [ + { + "commandStartedEvent": { + "command": { + "insert": "test", + "documents": [ + { + "_id": 1 + } + ], + "ordered": true, + "readConcern": { + "$$exists": false + }, + "lsid": { + "$$sessionLsid": "session0" + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": true, + "autocommit": false, + "writeConcern": { + "$$exists": false + } + }, + "commandName": "insert", + "databaseName": "transaction-tests" + } + }, + { + "commandStartedEvent": { + "command": { + "commitTransaction": 1, + "lsid": { + "$$sessionLsid": "session0" + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": { + "$$exists": false + }, + "autocommit": false, + "writeConcern": { + "$$exists": false + } + }, + "commandName": "commitTransaction", + "databaseName": "admin" + } + }, + { + "commandStartedEvent": { + "command": { + "commitTransaction": 1, + "lsid": { + "$$sessionLsid": "session0" + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": { + "$$exists": false + }, + "autocommit": false, + "writeConcern": { + "w": "majority", + "wtimeout": 10000 + } + }, + "commandName": "commitTransaction", + "databaseName": "admin" + } + } + ] + } + ], + "outcome": [ + { + "collectionName": "test", + "databaseName": "transaction-tests", + "documents": [ + { + "_id": 1 + } + ] + } + ] + }, + { + "description": "commitTransaction succeeds after HostUnreachable", + "operations": [ + { + "object": "testRunner", + "name": "failPoint", + "arguments": { + "client": "client0", + "failPoint": { + "configureFailPoint": "failCommand", + "mode": { + "times": 1 + }, + "data": { + "failCommands": [ + "commitTransaction" + ], + "errorCode": 6, + "errorLabels": [ + "RetryableWriteError" + ], + "closeConnection": false + } + } + } + }, + { + "object": "session0", + "name": "startTransaction" + }, + { + "object": "collection0", + "name": "insertOne", + "arguments": { + "session": "session0", + "document": { + "_id": 1 + } + }, + "expectResult": { + "$$unsetOrMatches": { + "insertedId": { + "$$unsetOrMatches": 1 + } + } + } + }, + { + "object": "session0", + "name": "commitTransaction" + } + ], + "expectEvents": [ + { + "client": "client0", + "events": [ + { + "commandStartedEvent": { + "command": { + "insert": "test", + "documents": [ + { + "_id": 1 + } + ], + "ordered": true, + "readConcern": { + "$$exists": false + }, + "lsid": { + "$$sessionLsid": "session0" + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": true, + "autocommit": false, + "writeConcern": { + "$$exists": false + } + }, + "commandName": "insert", + "databaseName": "transaction-tests" + } + }, + { + "commandStartedEvent": { + "command": { + "commitTransaction": 1, + "lsid": { + "$$sessionLsid": "session0" + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": { + "$$exists": false + }, + "autocommit": false, + "writeConcern": { + "$$exists": false + } + }, + "commandName": "commitTransaction", + "databaseName": "admin" + } + }, + { + "commandStartedEvent": { + "command": { + "commitTransaction": 1, + "lsid": { + "$$sessionLsid": "session0" + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": { + "$$exists": false + }, + "autocommit": false, + "writeConcern": { + "w": "majority", + "wtimeout": 10000 + } + }, + "commandName": "commitTransaction", + "databaseName": "admin" + } + } + ] + } + ], + "outcome": [ + { + "collectionName": "test", + "databaseName": "transaction-tests", + "documents": [ + { + "_id": 1 + } + ] + } + ] + }, + { + "description": "commitTransaction succeeds after SocketException", + "operations": [ + { + "object": "testRunner", + "name": "failPoint", + "arguments": { + "client": "client0", + "failPoint": { + "configureFailPoint": "failCommand", + "mode": { + "times": 1 + }, + "data": { + "failCommands": [ + "commitTransaction" + ], + "errorCode": 9001, + "errorLabels": [ + "RetryableWriteError" + ], + "closeConnection": false + } + } + } + }, + { + "object": "session0", + "name": "startTransaction" + }, + { + "object": "collection0", + "name": "insertOne", + "arguments": { + "session": "session0", + "document": { + "_id": 1 + } + }, + "expectResult": { + "$$unsetOrMatches": { + "insertedId": { + "$$unsetOrMatches": 1 + } + } + } + }, + { + "object": "session0", + "name": "commitTransaction" + } + ], + "expectEvents": [ + { + "client": "client0", + "events": [ + { + "commandStartedEvent": { + "command": { + "insert": "test", + "documents": [ + { + "_id": 1 + } + ], + "ordered": true, + "readConcern": { + "$$exists": false + }, + "lsid": { + "$$sessionLsid": "session0" + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": true, + "autocommit": false, + "writeConcern": { + "$$exists": false + } + }, + "commandName": "insert", + "databaseName": "transaction-tests" + } + }, + { + "commandStartedEvent": { + "command": { + "commitTransaction": 1, + "lsid": { + "$$sessionLsid": "session0" + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": { + "$$exists": false + }, + "autocommit": false, + "writeConcern": { + "$$exists": false + } + }, + "commandName": "commitTransaction", + "databaseName": "admin" + } + }, + { + "commandStartedEvent": { + "command": { + "commitTransaction": 1, + "lsid": { + "$$sessionLsid": "session0" + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": { + "$$exists": false + }, + "autocommit": false, + "writeConcern": { + "w": "majority", + "wtimeout": 10000 + } + }, + "commandName": "commitTransaction", + "databaseName": "admin" + } + } + ] + } + ], + "outcome": [ + { + "collectionName": "test", + "databaseName": "transaction-tests", + "documents": [ + { + "_id": 1 + } + ] + } + ] + }, + { + "description": "commitTransaction succeeds after NetworkTimeout", + "operations": [ + { + "object": "testRunner", + "name": "failPoint", + "arguments": { + "client": "client0", + "failPoint": { + "configureFailPoint": "failCommand", + "mode": { + "times": 1 + }, + "data": { + "failCommands": [ + "commitTransaction" + ], + "errorCode": 89, + "errorLabels": [ + "RetryableWriteError" + ], + "closeConnection": false + } + } + } + }, + { + "object": "session0", + "name": "startTransaction" + }, + { + "object": "collection0", + "name": "insertOne", + "arguments": { + "session": "session0", + "document": { + "_id": 1 + } + }, + "expectResult": { + "$$unsetOrMatches": { + "insertedId": { + "$$unsetOrMatches": 1 + } + } + } + }, + { + "object": "session0", + "name": "commitTransaction" + } + ], + "expectEvents": [ + { + "client": "client0", + "events": [ + { + "commandStartedEvent": { + "command": { + "insert": "test", + "documents": [ + { + "_id": 1 + } + ], + "ordered": true, + "readConcern": { + "$$exists": false + }, + "lsid": { + "$$sessionLsid": "session0" + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": true, + "autocommit": false, + "writeConcern": { + "$$exists": false + } + }, + "commandName": "insert", + "databaseName": "transaction-tests" + } + }, + { + "commandStartedEvent": { + "command": { + "commitTransaction": 1, + "lsid": { + "$$sessionLsid": "session0" + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": { + "$$exists": false + }, + "autocommit": false, + "writeConcern": { + "$$exists": false + } + }, + "commandName": "commitTransaction", + "databaseName": "admin" + } + }, + { + "commandStartedEvent": { + "command": { + "commitTransaction": 1, + "lsid": { + "$$sessionLsid": "session0" + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": { + "$$exists": false + }, + "autocommit": false, + "writeConcern": { + "w": "majority", + "wtimeout": 10000 + } + }, + "commandName": "commitTransaction", + "databaseName": "admin" + } + } + ] + } + ], + "outcome": [ + { + "collectionName": "test", + "databaseName": "transaction-tests", + "documents": [ + { + "_id": 1 + } + ] + } + ] + }, + { + "description": "commitTransaction succeeds after WriteConcernError InterruptedAtShutdown", + "operations": [ + { + "object": "testRunner", + "name": "failPoint", + "arguments": { + "client": "client0", + "failPoint": { + "configureFailPoint": "failCommand", + "mode": { + "times": 1 + }, + "data": { + "failCommands": [ + "commitTransaction" + ], + "errorLabels": [ + "RetryableWriteError" + ], + "writeConcernError": { + "code": 11600, + "errmsg": "Replication is being shut down" + } + } + } + } + }, + { + "object": "session0", + "name": "startTransaction", + "arguments": { + "writeConcern": { + "w": "majority" + } + } + }, + { + "object": "collection0", + "name": "insertOne", + "arguments": { + "session": "session0", + "document": { + "_id": 1 + } + }, + "expectResult": { + "$$unsetOrMatches": { + "insertedId": { + "$$unsetOrMatches": 1 + } + } + } + }, + { + "object": "session0", + "name": "commitTransaction" + } + ], + "expectEvents": [ + { + "client": "client0", + "events": [ + { + "commandStartedEvent": { + "command": { + "insert": "test", + "documents": [ + { + "_id": 1 + } + ], + "ordered": true, + "readConcern": { + "$$exists": false + }, + "lsid": { + "$$sessionLsid": "session0" + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": true, + "autocommit": false, + "writeConcern": { + "$$exists": false + } + }, + "commandName": "insert", + "databaseName": "transaction-tests" + } + }, + { + "commandStartedEvent": { + "command": { + "commitTransaction": 1, + "lsid": { + "$$sessionLsid": "session0" + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": { + "$$exists": false + }, + "autocommit": false, + "writeConcern": { + "w": "majority" + } + }, + "commandName": "commitTransaction", + "databaseName": "admin" + } + }, + { + "commandStartedEvent": { + "command": { + "commitTransaction": 1, + "lsid": { + "$$sessionLsid": "session0" + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": { + "$$exists": false + }, + "autocommit": false, + "writeConcern": { + "w": "majority", + "wtimeout": 10000 + } + }, + "commandName": "commitTransaction", + "databaseName": "admin" + } + } + ] + } + ], + "outcome": [ + { + "collectionName": "test", + "databaseName": "transaction-tests", + "documents": [ + { + "_id": 1 + } + ] + } + ] + }, + { + "description": "commitTransaction succeeds after WriteConcernError InterruptedDueToReplStateChange", + "operations": [ + { + "object": "testRunner", + "name": "failPoint", + "arguments": { + "client": "client0", + "failPoint": { + "configureFailPoint": "failCommand", + "mode": { + "times": 1 + }, + "data": { + "failCommands": [ + "commitTransaction" + ], + "errorLabels": [ + "RetryableWriteError" + ], + "writeConcernError": { + "code": 11602, + "errmsg": "Replication is being shut down" + } + } + } + } + }, + { + "object": "session0", + "name": "startTransaction", + "arguments": { + "writeConcern": { + "w": "majority" + } + } + }, + { + "object": "collection0", + "name": "insertOne", + "arguments": { + "session": "session0", + "document": { + "_id": 1 + } + }, + "expectResult": { + "$$unsetOrMatches": { + "insertedId": { + "$$unsetOrMatches": 1 + } + } + } + }, + { + "object": "session0", + "name": "commitTransaction" + } + ], + "expectEvents": [ + { + "client": "client0", + "events": [ + { + "commandStartedEvent": { + "command": { + "insert": "test", + "documents": [ + { + "_id": 1 + } + ], + "ordered": true, + "readConcern": { + "$$exists": false + }, + "lsid": { + "$$sessionLsid": "session0" + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": true, + "autocommit": false, + "writeConcern": { + "$$exists": false + } + }, + "commandName": "insert", + "databaseName": "transaction-tests" + } + }, + { + "commandStartedEvent": { + "command": { + "commitTransaction": 1, + "lsid": { + "$$sessionLsid": "session0" + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": { + "$$exists": false + }, + "autocommit": false, + "writeConcern": { + "w": "majority" + } + }, + "commandName": "commitTransaction", + "databaseName": "admin" + } + }, + { + "commandStartedEvent": { + "command": { + "commitTransaction": 1, + "lsid": { + "$$sessionLsid": "session0" + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": { + "$$exists": false + }, + "autocommit": false, + "writeConcern": { + "w": "majority", + "wtimeout": 10000 + } + }, + "commandName": "commitTransaction", + "databaseName": "admin" + } + } + ] + } + ], + "outcome": [ + { + "collectionName": "test", + "databaseName": "transaction-tests", + "documents": [ + { + "_id": 1 + } + ] + } + ] + }, + { + "description": "commitTransaction succeeds after WriteConcernError PrimarySteppedDown", + "operations": [ + { + "object": "testRunner", + "name": "failPoint", + "arguments": { + "client": "client0", + "failPoint": { + "configureFailPoint": "failCommand", + "mode": { + "times": 1 + }, + "data": { + "failCommands": [ + "commitTransaction" + ], + "errorLabels": [ + "RetryableWriteError" + ], + "writeConcernError": { + "code": 189, + "errmsg": "Replication is being shut down" + } + } + } + } + }, + { + "object": "session0", + "name": "startTransaction", + "arguments": { + "writeConcern": { + "w": "majority" + } + } + }, + { + "object": "collection0", + "name": "insertOne", + "arguments": { + "session": "session0", + "document": { + "_id": 1 + } + }, + "expectResult": { + "$$unsetOrMatches": { + "insertedId": { + "$$unsetOrMatches": 1 + } + } + } + }, + { + "object": "session0", + "name": "commitTransaction" + } + ], + "expectEvents": [ + { + "client": "client0", + "events": [ + { + "commandStartedEvent": { + "command": { + "insert": "test", + "documents": [ + { + "_id": 1 + } + ], + "ordered": true, + "readConcern": { + "$$exists": false + }, + "lsid": { + "$$sessionLsid": "session0" + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": true, + "autocommit": false, + "writeConcern": { + "$$exists": false + } + }, + "commandName": "insert", + "databaseName": "transaction-tests" + } + }, + { + "commandStartedEvent": { + "command": { + "commitTransaction": 1, + "lsid": { + "$$sessionLsid": "session0" + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": { + "$$exists": false + }, + "autocommit": false, + "writeConcern": { + "w": "majority" + } + }, + "commandName": "commitTransaction", + "databaseName": "admin" + } + }, + { + "commandStartedEvent": { + "command": { + "commitTransaction": 1, + "lsid": { + "$$sessionLsid": "session0" + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": { + "$$exists": false + }, + "autocommit": false, + "writeConcern": { + "w": "majority", + "wtimeout": 10000 + } + }, + "commandName": "commitTransaction", + "databaseName": "admin" + } + } + ] + } + ], + "outcome": [ + { + "collectionName": "test", + "databaseName": "transaction-tests", + "documents": [ + { + "_id": 1 + } + ] + } + ] + }, + { + "description": "commitTransaction succeeds after WriteConcernError ShutdownInProgress", + "operations": [ + { + "object": "testRunner", + "name": "failPoint", + "arguments": { + "client": "client0", + "failPoint": { + "configureFailPoint": "failCommand", + "mode": { + "times": 1 + }, + "data": { + "failCommands": [ + "commitTransaction" + ], + "errorLabels": [ + "RetryableWriteError" + ], + "writeConcernError": { + "code": 91, + "errmsg": "Replication is being shut down" + } + } + } + } + }, + { + "object": "session0", + "name": "startTransaction", + "arguments": { + "writeConcern": { + "w": "majority" + } + } + }, + { + "object": "collection0", + "name": "insertOne", + "arguments": { + "session": "session0", + "document": { + "_id": 1 + } + }, + "expectResult": { + "$$unsetOrMatches": { + "insertedId": { + "$$unsetOrMatches": 1 + } + } + } + }, + { + "object": "session0", + "name": "commitTransaction" + } + ], + "expectEvents": [ + { + "client": "client0", + "events": [ + { + "commandStartedEvent": { + "command": { + "insert": "test", + "documents": [ + { + "_id": 1 + } + ], + "ordered": true, + "readConcern": { + "$$exists": false + }, + "lsid": { + "$$sessionLsid": "session0" + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": true, + "autocommit": false, + "writeConcern": { + "$$exists": false + } + }, + "commandName": "insert", + "databaseName": "transaction-tests" + } + }, + { + "commandStartedEvent": { + "command": { + "commitTransaction": 1, + "lsid": { + "$$sessionLsid": "session0" + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": { + "$$exists": false + }, + "autocommit": false, + "writeConcern": { + "w": "majority" + } + }, + "commandName": "commitTransaction", + "databaseName": "admin" + } + }, + { + "commandStartedEvent": { + "command": { + "commitTransaction": 1, + "lsid": { + "$$sessionLsid": "session0" + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": { + "$$exists": false + }, + "autocommit": false, + "writeConcern": { + "w": "majority", + "wtimeout": 10000 + } + }, + "commandName": "commitTransaction", + "databaseName": "admin" + } + } + ] + } + ], + "outcome": [ + { + "collectionName": "test", + "databaseName": "transaction-tests", + "documents": [ + { + "_id": 1 + } + ] + } + ] + }, + { + "description": "commitTransaction succeeds after InterruptedAtShutdown", + "runOnRequirements": [ + { + "serverless": "forbid" + } + ], + "operations": [ + { + "object": "testRunner", + "name": "failPoint", + "arguments": { + "client": "client0", + "failPoint": { + "configureFailPoint": "failCommand", + "mode": { + "times": 1 + }, + "data": { + "failCommands": [ + "commitTransaction" + ], + "errorCode": 11600, + "errorLabels": [ + "RetryableWriteError" + ], + "closeConnection": false + } + } + } + }, + { + "object": "session0", + "name": "startTransaction" + }, + { + "object": "collection0", + "name": "insertOne", + "arguments": { + "session": "session0", + "document": { + "_id": 1 + } + }, + "expectResult": { + "$$unsetOrMatches": { + "insertedId": { + "$$unsetOrMatches": 1 + } + } + } + }, + { + "object": "session0", + "name": "commitTransaction" + } + ], + "expectEvents": [ + { + "client": "client0", + "events": [ + { + "commandStartedEvent": { + "command": { + "insert": "test", + "documents": [ + { + "_id": 1 + } + ], + "ordered": true, + "readConcern": { + "$$exists": false + }, + "lsid": { + "$$sessionLsid": "session0" + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": true, + "autocommit": false, + "writeConcern": { + "$$exists": false + } + }, + "commandName": "insert", + "databaseName": "transaction-tests" + } + }, + { + "commandStartedEvent": { + "command": { + "commitTransaction": 1, + "lsid": { + "$$sessionLsid": "session0" + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": { + "$$exists": false + }, + "autocommit": false, + "writeConcern": { + "$$exists": false + } + }, + "commandName": "commitTransaction", + "databaseName": "admin" + } + }, + { + "commandStartedEvent": { + "command": { + "commitTransaction": 1, + "lsid": { + "$$sessionLsid": "session0" + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": { + "$$exists": false + }, + "autocommit": false, + "writeConcern": { + "w": "majority", + "wtimeout": 10000 + } + }, + "commandName": "commitTransaction", + "databaseName": "admin" + } + } + ] + } + ], + "outcome": [ + { + "collectionName": "test", + "databaseName": "transaction-tests", + "documents": [ + { + "_id": 1 + } + ] + } + ] + }, + { + "description": "commitTransaction succeeds after ShutdownInProgress", + "runOnRequirements": [ + { + "serverless": "forbid" + } + ], + "operations": [ + { + "object": "testRunner", + "name": "failPoint", + "arguments": { + "client": "client0", + "failPoint": { + "configureFailPoint": "failCommand", + "mode": { + "times": 1 + }, + "data": { + "failCommands": [ + "commitTransaction" + ], + "errorCode": 91, + "errorLabels": [ + "RetryableWriteError" + ], + "closeConnection": false + } + } + } + }, + { + "object": "session0", + "name": "startTransaction" + }, + { + "object": "collection0", + "name": "insertOne", + "arguments": { + "session": "session0", + "document": { + "_id": 1 + } + }, + "expectResult": { + "$$unsetOrMatches": { + "insertedId": { + "$$unsetOrMatches": 1 + } + } + } + }, + { + "object": "session0", + "name": "commitTransaction" + } + ], + "expectEvents": [ + { + "client": "client0", + "events": [ + { + "commandStartedEvent": { + "command": { + "insert": "test", + "documents": [ + { + "_id": 1 + } + ], + "ordered": true, + "readConcern": { + "$$exists": false + }, + "lsid": { + "$$sessionLsid": "session0" + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": true, + "autocommit": false, + "writeConcern": { + "$$exists": false + } + }, + "commandName": "insert", + "databaseName": "transaction-tests" + } + }, + { + "commandStartedEvent": { + "command": { + "commitTransaction": 1, + "lsid": { + "$$sessionLsid": "session0" + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": { + "$$exists": false + }, + "autocommit": false, + "writeConcern": { + "$$exists": false + } + }, + "commandName": "commitTransaction", + "databaseName": "admin" + } + }, + { + "commandStartedEvent": { + "command": { + "commitTransaction": 1, + "lsid": { + "$$sessionLsid": "session0" + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": { + "$$exists": false + }, + "autocommit": false, + "writeConcern": { + "w": "majority", + "wtimeout": 10000 + } + }, + "commandName": "commitTransaction", + "databaseName": "admin" + } + } + ] + } + ], + "outcome": [ + { + "collectionName": "test", + "databaseName": "transaction-tests", + "documents": [ + { + "_id": 1 + } + ] + } + ] + } + ] +} diff --git a/source/transactions/tests/unified/retryable-commit-errorLabels.yml b/source/transactions/tests/unified/retryable-commit-errorLabels.yml new file mode 100644 index 0000000000..a29f565160 --- /dev/null +++ b/source/transactions/tests/unified/retryable-commit-errorLabels.yml @@ -0,0 +1,1474 @@ +description: retryable-commit-errorLabels + +schemaVersion: '1.4' + +runOnRequirements: + - + minServerVersion: 4.3.1 # failCommand errorLabels option + topologies: + - replicaset + - sharded + - load-balanced + +createEntities: + - + client: + id: &client0 client0 + useMultipleMongoses: false + observeEvents: + - commandStartedEvent + - + database: + id: &database0 database0 + client: *client0 + databaseName: &database_name transaction-tests + - + collection: + id: &collection0 collection0 + database: *database0 + collectionName: &collection_name test + - + session: + id: &session0 session0 + client: *client0 + # Define a second set of entities for a retryWrites=false client + - + client: + id: &client1 client1 + useMultipleMongoses: false + uriOptions: + retryWrites: false + observeEvents: + - commandStartedEvent + - + database: + id: &database1 database1 + client: *client1 + databaseName: *database_name + - + collection: + id: &collection1 collection1 + database: *database1 + collectionName: *collection_name + - + session: + id: &session1 session1 + client: *client1 + +initialData: + - + collectionName: *collection_name + databaseName: *database_name + documents: [] + +tests: + - + description: 'commitTransaction does not retry error without RetryableWriteError label' + operations: + - + object: testRunner + name: failPoint + arguments: + client: *client1 + failPoint: + configureFailPoint: failCommand + mode: { times: 1 } + data: + failCommands: + - commitTransaction + errorCode: 11600 # InterruptedAtShutdown, normally a retryable error code + errorLabels: [] # Override server behavior: do not send RetryableWriteError label with retryable code + - + object: *session1 + name: startTransaction + - + object: *collection1 + name: insertOne + arguments: + session: *session1 + document: { _id: 1 } + expectResult: + $$unsetOrMatches: { insertedId: { $$unsetOrMatches: 1 } } + - + object: *session1 + name: commitTransaction + expectError: + errorLabelsOmit: + - RetryableWriteError + - TransientTransactionError + expectEvents: + - + client: *client1 + events: + - + commandStartedEvent: + command: + insert: *collection_name + documents: + - { _id: 1 } + ordered: true + readConcern: { $$exists: false } + lsid: { $$sessionLsid: *session1 } + txnNumber: { $numberLong: '1' } + startTransaction: true + autocommit: false + writeConcern: { $$exists: false } + commandName: insert + databaseName: *database_name + - + commandStartedEvent: + command: + commitTransaction: 1 + lsid: { $$sessionLsid: *session1 } + txnNumber: { $numberLong: '1' } + startTransaction: { $$exists: false } + autocommit: false + writeConcern: { $$exists: false } + commandName: commitTransaction + databaseName: admin + # Driver does not retry commit because there was no RetryableWriteError label on response + outcome: + - + collectionName: *collection_name + databaseName: *database_name + documents: [] + - + description: 'commitTransaction retries once with RetryableWriteError from server' + operations: + - + object: testRunner + name: failPoint + arguments: + client: *client1 + failPoint: + configureFailPoint: failCommand + mode: { times: 1 } + data: + failCommands: + - commitTransaction + errorCode: 112 # WriteConflict, not a retryable error code + # Override server behavior: send RetryableWriteError label with non-retryable error code + errorLabels: + - RetryableWriteError + - + object: *session1 + name: startTransaction + - + object: *collection1 + name: insertOne + arguments: + session: *session1 + document: { _id: 1 } + expectResult: + $$unsetOrMatches: { insertedId: { $$unsetOrMatches: 1 } } + - + object: *session1 + name: commitTransaction + expectEvents: + - + client: *client1 + events: + - + commandStartedEvent: + command: + insert: *collection_name + documents: + - { _id: 1 } + ordered: true + readConcern: { $$exists: false } + lsid: { $$sessionLsid: *session1 } + txnNumber: { $numberLong: '1' } + startTransaction: true + autocommit: false + writeConcern: { $$exists: false } + commandName: insert + databaseName: *database_name + - + commandStartedEvent: + command: + commitTransaction: 1 + lsid: { $$sessionLsid: *session1 } + txnNumber: { $numberLong: '1' } + startTransaction: { $$exists: false } + autocommit: false + writeConcern: { $$exists: false } + commandName: commitTransaction + databaseName: admin + - + commandStartedEvent: + command: + commitTransaction: 1 + lsid: { $$sessionLsid: *session1 } + txnNumber: { $numberLong: '1' } + startTransaction: { $$exists: false } + autocommit: false + writeConcern: + w: majority + wtimeout: 10000 + commandName: commitTransaction + databaseName: admin + # Driver retries commit and it succeeds + outcome: + - + collectionName: *collection_name + databaseName: *database_name + documents: + - { _id: 1 } + - + description: 'commitTransaction succeeds after NotWritablePrimary' + operations: + - + object: testRunner + name: failPoint + arguments: + client: *client0 + failPoint: + configureFailPoint: failCommand + mode: { times: 1 } + data: + failCommands: + - commitTransaction + errorCode: 10107 + errorLabels: + - RetryableWriteError + closeConnection: false + - + object: *session0 + name: startTransaction + - + object: *collection0 + name: insertOne + arguments: + session: *session0 + document: { _id: 1 } + expectResult: + $$unsetOrMatches: { insertedId: { $$unsetOrMatches: 1 } } + - + object: *session0 + name: commitTransaction + expectEvents: + - + client: *client0 + events: + - + commandStartedEvent: + command: + insert: *collection_name + documents: + - { _id: 1 } + ordered: true + readConcern: { $$exists: false } + lsid: { $$sessionLsid: *session0 } + txnNumber: { $numberLong: '1' } + startTransaction: true + autocommit: false + writeConcern: { $$exists: false } + commandName: insert + databaseName: *database_name + - + commandStartedEvent: + command: + commitTransaction: 1 + lsid: { $$sessionLsid: *session0 } + txnNumber: { $numberLong: '1' } + startTransaction: { $$exists: false } + autocommit: false + writeConcern: { $$exists: false } + commandName: commitTransaction + databaseName: admin + - + commandStartedEvent: + command: + commitTransaction: 1 + lsid: { $$sessionLsid: *session0 } + txnNumber: { $numberLong: '1' } + startTransaction: { $$exists: false } + autocommit: false + # commitTransaction applies w:majority on retries + writeConcern: + w: majority + wtimeout: 10000 + commandName: commitTransaction + databaseName: admin + outcome: + - + collectionName: *collection_name + databaseName: *database_name + documents: + - { _id: 1 } + - + description: 'commitTransaction succeeds after NotPrimaryOrSecondary' + operations: + - + object: testRunner + name: failPoint + arguments: + client: *client0 + failPoint: + configureFailPoint: failCommand + mode: { times: 1 } + data: + failCommands: + - commitTransaction + errorCode: 13436 + errorLabels: + - RetryableWriteError + closeConnection: false + - + object: *session0 + name: startTransaction + - + object: *collection0 + name: insertOne + arguments: + session: *session0 + document: { _id: 1 } + expectResult: + $$unsetOrMatches: { insertedId: { $$unsetOrMatches: 1 } } + - + object: *session0 + name: commitTransaction + expectEvents: + - + client: *client0 + events: + - + commandStartedEvent: + command: + insert: *collection_name + documents: + - { _id: 1 } + ordered: true + readConcern: { $$exists: false } + lsid: { $$sessionLsid: *session0 } + txnNumber: { $numberLong: '1' } + startTransaction: true + autocommit: false + writeConcern: { $$exists: false } + commandName: insert + databaseName: *database_name + - + commandStartedEvent: + command: + commitTransaction: 1 + lsid: { $$sessionLsid: *session0 } + txnNumber: { $numberLong: '1' } + startTransaction: { $$exists: false } + autocommit: false + writeConcern: { $$exists: false } + commandName: commitTransaction + databaseName: admin + - + commandStartedEvent: + command: + commitTransaction: 1 + lsid: { $$sessionLsid: *session0 } + txnNumber: { $numberLong: '1' } + startTransaction: { $$exists: false } + autocommit: false + # commitTransaction applies w:majority on retries + writeConcern: + w: majority + wtimeout: 10000 + commandName: commitTransaction + databaseName: admin + outcome: + - + collectionName: *collection_name + databaseName: *database_name + documents: + - { _id: 1 } + - + description: 'commitTransaction succeeds after NotPrimaryNoSecondaryOk' + operations: + - + object: testRunner + name: failPoint + arguments: + client: *client0 + failPoint: + configureFailPoint: failCommand + mode: { times: 1 } + data: + failCommands: + - commitTransaction + errorCode: 13435 + errorLabels: + - RetryableWriteError + closeConnection: false + - + object: *session0 + name: startTransaction + - + object: *collection0 + name: insertOne + arguments: + session: *session0 + document: { _id: 1 } + expectResult: + $$unsetOrMatches: { insertedId: { $$unsetOrMatches: 1 } } + - + object: *session0 + name: commitTransaction + expectEvents: + - + client: *client0 + events: + - + commandStartedEvent: + command: + insert: *collection_name + documents: + - { _id: 1 } + ordered: true + readConcern: { $$exists: false } + lsid: { $$sessionLsid: *session0 } + txnNumber: { $numberLong: '1' } + startTransaction: true + autocommit: false + writeConcern: { $$exists: false } + commandName: insert + databaseName: *database_name + - + commandStartedEvent: + command: + commitTransaction: 1 + lsid: { $$sessionLsid: *session0 } + txnNumber: { $numberLong: '1' } + startTransaction: { $$exists: false } + autocommit: false + writeConcern: { $$exists: false } + commandName: commitTransaction + databaseName: admin + - + commandStartedEvent: + command: + commitTransaction: 1 + lsid: { $$sessionLsid: *session0 } + txnNumber: { $numberLong: '1' } + startTransaction: { $$exists: false } + autocommit: false + # commitTransaction applies w:majority on retries + writeConcern: + w: majority + wtimeout: 10000 + commandName: commitTransaction + databaseName: admin + outcome: + - + collectionName: *collection_name + databaseName: *database_name + documents: + - { _id: 1 } + - + description: 'commitTransaction succeeds after InterruptedDueToReplStateChange' + operations: + - + object: testRunner + name: failPoint + arguments: + client: *client0 + failPoint: + configureFailPoint: failCommand + mode: { times: 1 } + data: + failCommands: + - commitTransaction + errorCode: 11602 + errorLabels: + - RetryableWriteError + closeConnection: false + - + object: *session0 + name: startTransaction + - + object: *collection0 + name: insertOne + arguments: + session: *session0 + document: { _id: 1 } + expectResult: + $$unsetOrMatches: { insertedId: { $$unsetOrMatches: 1 } } + - + object: *session0 + name: commitTransaction + expectEvents: + - + client: *client0 + events: + - + commandStartedEvent: + command: + insert: *collection_name + documents: + - { _id: 1 } + ordered: true + readConcern: { $$exists: false } + lsid: { $$sessionLsid: *session0 } + txnNumber: { $numberLong: '1' } + startTransaction: true + autocommit: false + writeConcern: { $$exists: false } + commandName: insert + databaseName: *database_name + - + commandStartedEvent: + command: + commitTransaction: 1 + lsid: { $$sessionLsid: *session0 } + txnNumber: { $numberLong: '1' } + startTransaction: { $$exists: false } + autocommit: false + writeConcern: { $$exists: false } + commandName: commitTransaction + databaseName: admin + - + commandStartedEvent: + command: + commitTransaction: 1 + lsid: { $$sessionLsid: *session0 } + txnNumber: { $numberLong: '1' } + startTransaction: { $$exists: false } + autocommit: false + # commitTransaction applies w:majority on retries + writeConcern: + w: majority + wtimeout: 10000 + commandName: commitTransaction + databaseName: admin + outcome: + - + collectionName: *collection_name + databaseName: *database_name + documents: + - { _id: 1 } + - + description: 'commitTransaction succeeds after PrimarySteppedDown' + operations: + - + object: testRunner + name: failPoint + arguments: + client: *client0 + failPoint: + configureFailPoint: failCommand + mode: { times: 1 } + data: + failCommands: + - commitTransaction + errorCode: 189 + errorLabels: + - RetryableWriteError + closeConnection: false + - + object: *session0 + name: startTransaction + - + object: *collection0 + name: insertOne + arguments: + session: *session0 + document: { _id: 1 } + expectResult: + $$unsetOrMatches: { insertedId: { $$unsetOrMatches: 1 } } + - + object: *session0 + name: commitTransaction + expectEvents: + - + client: *client0 + events: + - + commandStartedEvent: + command: + insert: *collection_name + documents: + - { _id: 1 } + ordered: true + readConcern: { $$exists: false } + lsid: { $$sessionLsid: *session0 } + txnNumber: { $numberLong: '1' } + startTransaction: true + autocommit: false + writeConcern: { $$exists: false } + commandName: insert + databaseName: *database_name + - + commandStartedEvent: + command: + commitTransaction: 1 + lsid: { $$sessionLsid: *session0 } + txnNumber: { $numberLong: '1' } + startTransaction: { $$exists: false } + autocommit: false + writeConcern: { $$exists: false } + commandName: commitTransaction + databaseName: admin + - + commandStartedEvent: + command: + commitTransaction: 1 + lsid: { $$sessionLsid: *session0 } + txnNumber: { $numberLong: '1' } + startTransaction: { $$exists: false } + autocommit: false + # commitTransaction applies w:majority on retries + writeConcern: + w: majority + wtimeout: 10000 + commandName: commitTransaction + databaseName: admin + outcome: + - + collectionName: *collection_name + databaseName: *database_name + documents: + - { _id: 1 } + - + description: 'commitTransaction succeeds after HostNotFound' + operations: + - + object: testRunner + name: failPoint + arguments: + client: *client0 + failPoint: + configureFailPoint: failCommand + mode: { times: 1 } + data: + failCommands: + - commitTransaction + errorCode: 7 + errorLabels: + - RetryableWriteError + closeConnection: false + - + object: *session0 + name: startTransaction + - + object: *collection0 + name: insertOne + arguments: + session: *session0 + document: { _id: 1 } + expectResult: + $$unsetOrMatches: { insertedId: { $$unsetOrMatches: 1 } } + - + object: *session0 + name: commitTransaction + expectEvents: + - + client: *client0 + events: + - + commandStartedEvent: + command: + insert: *collection_name + documents: + - { _id: 1 } + ordered: true + readConcern: { $$exists: false } + lsid: { $$sessionLsid: *session0 } + txnNumber: { $numberLong: '1' } + startTransaction: true + autocommit: false + writeConcern: { $$exists: false } + commandName: insert + databaseName: *database_name + - + commandStartedEvent: + command: + commitTransaction: 1 + lsid: { $$sessionLsid: *session0 } + txnNumber: { $numberLong: '1' } + startTransaction: { $$exists: false } + autocommit: false + writeConcern: { $$exists: false } + commandName: commitTransaction + databaseName: admin + - + commandStartedEvent: + command: + commitTransaction: 1 + lsid: { $$sessionLsid: *session0 } + txnNumber: { $numberLong: '1' } + startTransaction: { $$exists: false } + autocommit: false + # commitTransaction applies w:majority on retries + writeConcern: + w: majority + wtimeout: 10000 + commandName: commitTransaction + databaseName: admin + outcome: + - + collectionName: *collection_name + databaseName: *database_name + documents: + - { _id: 1 } + - + description: 'commitTransaction succeeds after HostUnreachable' + operations: + - + object: testRunner + name: failPoint + arguments: + client: *client0 + failPoint: + configureFailPoint: failCommand + mode: { times: 1 } + data: + failCommands: + - commitTransaction + errorCode: 6 + errorLabels: + - RetryableWriteError + closeConnection: false + - + object: *session0 + name: startTransaction + - + object: *collection0 + name: insertOne + arguments: + session: *session0 + document: { _id: 1 } + expectResult: + $$unsetOrMatches: { insertedId: { $$unsetOrMatches: 1 } } + - + object: *session0 + name: commitTransaction + expectEvents: + - + client: *client0 + events: + - + commandStartedEvent: + command: + insert: *collection_name + documents: + - { _id: 1 } + ordered: true + readConcern: { $$exists: false } + lsid: { $$sessionLsid: *session0 } + txnNumber: { $numberLong: '1' } + startTransaction: true + autocommit: false + writeConcern: { $$exists: false } + commandName: insert + databaseName: *database_name + - + commandStartedEvent: + command: + commitTransaction: 1 + lsid: { $$sessionLsid: *session0 } + txnNumber: { $numberLong: '1' } + startTransaction: { $$exists: false } + autocommit: false + writeConcern: { $$exists: false } + commandName: commitTransaction + databaseName: admin + - + commandStartedEvent: + command: + commitTransaction: 1 + lsid: { $$sessionLsid: *session0 } + txnNumber: { $numberLong: '1' } + startTransaction: { $$exists: false } + autocommit: false + # commitTransaction applies w:majority on retries + writeConcern: + w: majority + wtimeout: 10000 + commandName: commitTransaction + databaseName: admin + outcome: + - + collectionName: *collection_name + databaseName: *database_name + documents: + - { _id: 1 } + - + description: 'commitTransaction succeeds after SocketException' + operations: + - + object: testRunner + name: failPoint + arguments: + client: *client0 + failPoint: + configureFailPoint: failCommand + mode: { times: 1 } + data: + failCommands: + - commitTransaction + errorCode: 9001 + errorLabels: + - RetryableWriteError + closeConnection: false + - + object: *session0 + name: startTransaction + - + object: *collection0 + name: insertOne + arguments: + session: *session0 + document: { _id: 1 } + expectResult: + $$unsetOrMatches: { insertedId: { $$unsetOrMatches: 1 } } + - + object: *session0 + name: commitTransaction + expectEvents: + - + client: *client0 + events: + - + commandStartedEvent: + command: + insert: *collection_name + documents: + - { _id: 1 } + ordered: true + readConcern: { $$exists: false } + lsid: { $$sessionLsid: *session0 } + txnNumber: { $numberLong: '1' } + startTransaction: true + autocommit: false + writeConcern: { $$exists: false } + commandName: insert + databaseName: *database_name + - + commandStartedEvent: + command: + commitTransaction: 1 + lsid: { $$sessionLsid: *session0 } + txnNumber: { $numberLong: '1' } + startTransaction: { $$exists: false } + autocommit: false + writeConcern: { $$exists: false } + commandName: commitTransaction + databaseName: admin + - + commandStartedEvent: + command: + commitTransaction: 1 + lsid: { $$sessionLsid: *session0 } + txnNumber: { $numberLong: '1' } + startTransaction: { $$exists: false } + autocommit: false + # commitTransaction applies w:majority on retries + writeConcern: + w: majority + wtimeout: 10000 + commandName: commitTransaction + databaseName: admin + outcome: + - + collectionName: *collection_name + databaseName: *database_name + documents: + - { _id: 1 } + - + description: 'commitTransaction succeeds after NetworkTimeout' + operations: + - + object: testRunner + name: failPoint + arguments: + client: *client0 + failPoint: + configureFailPoint: failCommand + mode: { times: 1 } + data: + failCommands: + - commitTransaction + errorCode: 89 + errorLabels: + - RetryableWriteError + closeConnection: false + - + object: *session0 + name: startTransaction + - + object: *collection0 + name: insertOne + arguments: + session: *session0 + document: { _id: 1 } + expectResult: + $$unsetOrMatches: { insertedId: { $$unsetOrMatches: 1 } } + - + object: *session0 + name: commitTransaction + expectEvents: + - + client: *client0 + events: + - + commandStartedEvent: + command: + insert: *collection_name + documents: + - { _id: 1 } + ordered: true + readConcern: { $$exists: false } + lsid: { $$sessionLsid: *session0 } + txnNumber: { $numberLong: '1' } + startTransaction: true + autocommit: false + writeConcern: { $$exists: false } + commandName: insert + databaseName: *database_name + - + commandStartedEvent: + command: + commitTransaction: 1 + lsid: { $$sessionLsid: *session0 } + txnNumber: { $numberLong: '1' } + startTransaction: { $$exists: false } + autocommit: false + writeConcern: { $$exists: false } + commandName: commitTransaction + databaseName: admin + - + commandStartedEvent: + command: + commitTransaction: 1 + lsid: { $$sessionLsid: *session0 } + txnNumber: { $numberLong: '1' } + startTransaction: { $$exists: false } + autocommit: false + # commitTransaction applies w:majority on retries + writeConcern: + w: majority + wtimeout: 10000 + commandName: commitTransaction + databaseName: admin + outcome: + - + collectionName: *collection_name + databaseName: *database_name + documents: + - { _id: 1 } + - + description: 'commitTransaction succeeds after WriteConcernError InterruptedAtShutdown' + operations: + - + object: testRunner + name: failPoint + arguments: + client: *client0 + failPoint: + configureFailPoint: failCommand + mode: { times: 1 } + data: + failCommands: + - commitTransaction + errorLabels: + - RetryableWriteError + writeConcernError: + code: 11600 + errmsg: 'Replication is being shut down' + - + object: *session0 + name: startTransaction + arguments: + writeConcern: + w: majority + - + object: *collection0 + name: insertOne + arguments: + session: *session0 + document: { _id: 1 } + expectResult: + $$unsetOrMatches: { insertedId: { $$unsetOrMatches: 1 } } + - + object: *session0 + name: commitTransaction + expectEvents: + - + client: *client0 + events: + - + commandStartedEvent: + command: + insert: *collection_name + documents: + - { _id: 1 } + ordered: true + readConcern: { $$exists: false } + lsid: { $$sessionLsid: *session0 } + txnNumber: { $numberLong: '1' } + startTransaction: true + autocommit: false + writeConcern: { $$exists: false } + commandName: insert + databaseName: *database_name + - + commandStartedEvent: + command: + commitTransaction: 1 + lsid: { $$sessionLsid: *session0 } + txnNumber: { $numberLong: '1' } + startTransaction: { $$exists: false } + autocommit: false + writeConcern: + w: majority + commandName: commitTransaction + databaseName: admin + - + commandStartedEvent: + command: + commitTransaction: 1 + lsid: { $$sessionLsid: *session0 } + txnNumber: { $numberLong: '1' } + startTransaction: { $$exists: false } + autocommit: false + # commitTransaction applies w:majority on retries + writeConcern: + w: majority + wtimeout: 10000 + commandName: commitTransaction + databaseName: admin + outcome: + - + collectionName: *collection_name + databaseName: *database_name + documents: + - { _id: 1 } + - + description: 'commitTransaction succeeds after WriteConcernError InterruptedDueToReplStateChange' + operations: + - + object: testRunner + name: failPoint + arguments: + client: *client0 + failPoint: + configureFailPoint: failCommand + mode: { times: 1 } + data: + failCommands: + - commitTransaction + errorLabels: + - RetryableWriteError + writeConcernError: + code: 11602 + errmsg: 'Replication is being shut down' + - + object: *session0 + name: startTransaction + arguments: + writeConcern: + w: majority + - + object: *collection0 + name: insertOne + arguments: + session: *session0 + document: { _id: 1 } + expectResult: + $$unsetOrMatches: { insertedId: { $$unsetOrMatches: 1 } } + - + object: *session0 + name: commitTransaction + expectEvents: + - + client: *client0 + events: + - + commandStartedEvent: + command: + insert: *collection_name + documents: + - { _id: 1 } + ordered: true + readConcern: { $$exists: false } + lsid: { $$sessionLsid: *session0 } + txnNumber: { $numberLong: '1' } + startTransaction: true + autocommit: false + writeConcern: { $$exists: false } + commandName: insert + databaseName: *database_name + - + commandStartedEvent: + command: + commitTransaction: 1 + lsid: { $$sessionLsid: *session0 } + txnNumber: { $numberLong: '1' } + startTransaction: { $$exists: false } + autocommit: false + writeConcern: + w: majority + commandName: commitTransaction + databaseName: admin + - + commandStartedEvent: + command: + commitTransaction: 1 + lsid: { $$sessionLsid: *session0 } + txnNumber: { $numberLong: '1' } + startTransaction: { $$exists: false } + autocommit: false + # commitTransaction applies w:majority on retries + writeConcern: + w: majority + wtimeout: 10000 + commandName: commitTransaction + databaseName: admin + outcome: + - + collectionName: *collection_name + databaseName: *database_name + documents: + - { _id: 1 } + - + description: 'commitTransaction succeeds after WriteConcernError PrimarySteppedDown' + operations: + - + object: testRunner + name: failPoint + arguments: + client: *client0 + failPoint: + configureFailPoint: failCommand + mode: { times: 1 } + data: + failCommands: + - commitTransaction + errorLabels: + - RetryableWriteError + writeConcernError: + code: 189 + errmsg: 'Replication is being shut down' + - + object: *session0 + name: startTransaction + arguments: + writeConcern: + w: majority + - + object: *collection0 + name: insertOne + arguments: + session: *session0 + document: { _id: 1 } + expectResult: + $$unsetOrMatches: { insertedId: { $$unsetOrMatches: 1 } } + - + object: *session0 + name: commitTransaction + expectEvents: + - + client: *client0 + events: + - + commandStartedEvent: + command: + insert: *collection_name + documents: + - { _id: 1 } + ordered: true + readConcern: { $$exists: false } + lsid: { $$sessionLsid: *session0 } + txnNumber: { $numberLong: '1' } + startTransaction: true + autocommit: false + writeConcern: { $$exists: false } + commandName: insert + databaseName: *database_name + - + commandStartedEvent: + command: + commitTransaction: 1 + lsid: { $$sessionLsid: *session0 } + txnNumber: { $numberLong: '1' } + startTransaction: { $$exists: false } + autocommit: false + writeConcern: + w: majority + commandName: commitTransaction + databaseName: admin + - + commandStartedEvent: + command: + commitTransaction: 1 + lsid: { $$sessionLsid: *session0 } + txnNumber: { $numberLong: '1' } + startTransaction: { $$exists: false } + autocommit: false + # commitTransaction applies w:majority on retries + writeConcern: + w: majority + wtimeout: 10000 + commandName: commitTransaction + databaseName: admin + outcome: + - + collectionName: *collection_name + databaseName: *database_name + documents: + - { _id: 1 } + - + description: 'commitTransaction succeeds after WriteConcernError ShutdownInProgress' + operations: + - + object: testRunner + name: failPoint + arguments: + client: *client0 + failPoint: + configureFailPoint: failCommand + mode: { times: 1 } + data: + failCommands: + - commitTransaction + errorLabels: + - RetryableWriteError + writeConcernError: + code: 91 + errmsg: 'Replication is being shut down' + - + object: *session0 + name: startTransaction + arguments: + writeConcern: + w: majority + - + object: *collection0 + name: insertOne + arguments: + session: *session0 + document: { _id: 1 } + expectResult: + $$unsetOrMatches: { insertedId: { $$unsetOrMatches: 1 } } + - + object: *session0 + name: commitTransaction + expectEvents: + - + client: *client0 + events: + - + commandStartedEvent: + command: + insert: *collection_name + documents: + - { _id: 1 } + ordered: true + readConcern: { $$exists: false } + lsid: { $$sessionLsid: *session0 } + txnNumber: { $numberLong: '1' } + startTransaction: true + autocommit: false + writeConcern: { $$exists: false } + commandName: insert + databaseName: *database_name + - + commandStartedEvent: + command: + commitTransaction: 1 + lsid: { $$sessionLsid: *session0 } + txnNumber: { $numberLong: '1' } + startTransaction: { $$exists: false } + autocommit: false + writeConcern: + w: majority + commandName: commitTransaction + databaseName: admin + - + commandStartedEvent: + command: + commitTransaction: 1 + lsid: { $$sessionLsid: *session0 } + txnNumber: { $numberLong: '1' } + startTransaction: { $$exists: false } + autocommit: false + # commitTransaction applies w:majority on retries + writeConcern: + w: majority + wtimeout: 10000 + commandName: commitTransaction + databaseName: admin + outcome: + - + collectionName: *collection_name + databaseName: *database_name + documents: + - { _id: 1 } + - + description: 'commitTransaction succeeds after InterruptedAtShutdown' + # Fail points using state change errors (e.g. InterruptedAtShutdown, + # ShutdownInProgress) may remain enabled indefinitely (CLOUDP-84573). + runOnRequirements: + - serverless: forbid + operations: + - + object: testRunner + name: failPoint + arguments: + client: *client0 + failPoint: + configureFailPoint: failCommand + mode: { times: 1 } + data: + failCommands: + - commitTransaction + errorCode: 11600 + errorLabels: + - RetryableWriteError + closeConnection: false + - + object: *session0 + name: startTransaction + - + object: *collection0 + name: insertOne + arguments: + session: *session0 + document: { _id: 1 } + expectResult: + $$unsetOrMatches: { insertedId: { $$unsetOrMatches: 1 } } + - + object: *session0 + name: commitTransaction + expectEvents: + - + client: *client0 + events: + - + commandStartedEvent: + command: + insert: *collection_name + documents: + - { _id: 1 } + ordered: true + readConcern: { $$exists: false } + lsid: { $$sessionLsid: *session0 } + txnNumber: { $numberLong: '1' } + startTransaction: true + autocommit: false + writeConcern: { $$exists: false } + commandName: insert + databaseName: *database_name + - + commandStartedEvent: + command: + commitTransaction: 1 + lsid: { $$sessionLsid: *session0 } + txnNumber: { $numberLong: '1' } + startTransaction: { $$exists: false } + autocommit: false + writeConcern: { $$exists: false } + commandName: commitTransaction + databaseName: admin + - + commandStartedEvent: + command: + commitTransaction: 1 + lsid: { $$sessionLsid: *session0 } + txnNumber: { $numberLong: '1' } + startTransaction: { $$exists: false } + autocommit: false + # commitTransaction applies w:majority on retries + writeConcern: + w: majority + wtimeout: 10000 + commandName: commitTransaction + databaseName: admin + outcome: + - + collectionName: *collection_name + databaseName: *database_name + documents: + - { _id: 1 } + - + description: 'commitTransaction succeeds after ShutdownInProgress' + # Fail points using state change errors (e.g. InterruptedAtShutdown, + # ShutdownInProgress) may remain enabled indefinitely (CLOUDP-84573). + runOnRequirements: + - serverless: forbid + operations: + - + object: testRunner + name: failPoint + arguments: + client: *client0 + failPoint: + configureFailPoint: failCommand + mode: { times: 1 } + data: + failCommands: + - commitTransaction + errorCode: 91 + errorLabels: + - RetryableWriteError + closeConnection: false + - + object: *session0 + name: startTransaction + - + object: *collection0 + name: insertOne + arguments: + session: *session0 + document: { _id: 1 } + expectResult: + $$unsetOrMatches: { insertedId: { $$unsetOrMatches: 1 } } + - + object: *session0 + name: commitTransaction + expectEvents: + - + client: *client0 + events: + - + commandStartedEvent: + command: + insert: *collection_name + documents: + - { _id: 1 } + ordered: true + readConcern: { $$exists: false } + lsid: { $$sessionLsid: *session0 } + txnNumber: { $numberLong: '1' } + startTransaction: true + autocommit: false + writeConcern: { $$exists: false } + commandName: insert + databaseName: *database_name + - + commandStartedEvent: + command: + commitTransaction: 1 + lsid: { $$sessionLsid: *session0 } + txnNumber: { $numberLong: '1' } + startTransaction: { $$exists: false } + autocommit: false + writeConcern: { $$exists: false } + commandName: commitTransaction + databaseName: admin + - + commandStartedEvent: + command: + commitTransaction: 1 + lsid: { $$sessionLsid: *session0 } + txnNumber: { $numberLong: '1' } + startTransaction: { $$exists: false } + autocommit: false + # commitTransaction applies w:majority on retries + writeConcern: + w: majority + wtimeout: 10000 + commandName: commitTransaction + databaseName: admin + outcome: + - + collectionName: *collection_name + databaseName: *database_name + documents: + - { _id: 1 } diff --git a/source/transactions/tests/unified/retryable-commit-handshake.yml b/source/transactions/tests/unified/retryable-commit-handshake.yml index e9904fdf51..6a03ba6b6d 100644 --- a/source/transactions/tests/unified/retryable-commit-handshake.yml +++ b/source/transactions/tests/unified/retryable-commit-handshake.yml @@ -105,8 +105,7 @@ tests: - commandStartedEvent: command: commitTransaction: 1 - lsid: - $$sessionLsid: *session0 + lsid: { $$sessionLsid: *session0 } commandName: commitTransaction databaseName: admin diff --git a/source/transactions/tests/unified/retryable-commit.json b/source/transactions/tests/unified/retryable-commit.json new file mode 100644 index 0000000000..b794c1c55c --- /dev/null +++ b/source/transactions/tests/unified/retryable-commit.json @@ -0,0 +1,868 @@ +{ + "description": "retryable-commit", + "schemaVersion": "1.4", + "runOnRequirements": [ + { + "minServerVersion": "4.0", + "topologies": [ + "replicaset" + ] + }, + { + "minServerVersion": "4.1.8", + "topologies": [ + "sharded", + "load-balanced" + ] + } + ], + "createEntities": [ + { + "client": { + "id": "client0", + "useMultipleMongoses": false, + "observeEvents": [ + "commandStartedEvent" + ] + } + }, + { + "database": { + "id": "database0", + "client": "client0", + "databaseName": "transaction-tests" + } + }, + { + "collection": { + "id": "collection0", + "database": "database0", + "collectionName": "test" + } + }, + { + "session": { + "id": "session0", + "client": "client0" + } + }, + { + "client": { + "id": "client1", + "useMultipleMongoses": false, + "uriOptions": { + "retryWrites": false + }, + "observeEvents": [ + "commandStartedEvent" + ] + } + }, + { + "database": { + "id": "database1", + "client": "client1", + "databaseName": "transaction-tests" + } + }, + { + "collection": { + "id": "collection1", + "database": "database1", + "collectionName": "test" + } + }, + { + "session": { + "id": "session1", + "client": "client1" + } + } + ], + "initialData": [ + { + "collectionName": "test", + "databaseName": "transaction-tests", + "documents": [] + } + ], + "tests": [ + { + "description": "commitTransaction fails after Interrupted", + "operations": [ + { + "object": "testRunner", + "name": "failPoint", + "arguments": { + "client": "client0", + "failPoint": { + "configureFailPoint": "failCommand", + "mode": { + "times": 1 + }, + "data": { + "failCommands": [ + "commitTransaction" + ], + "errorCode": 11601, + "closeConnection": false + } + } + } + }, + { + "object": "session0", + "name": "startTransaction" + }, + { + "object": "collection0", + "name": "insertOne", + "arguments": { + "session": "session0", + "document": { + "_id": 1 + } + }, + "expectResult": { + "$$unsetOrMatches": { + "insertedId": { + "$$unsetOrMatches": 1 + } + } + } + }, + { + "object": "session0", + "name": "commitTransaction", + "expectError": { + "errorCodeName": "Interrupted", + "errorLabelsOmit": [ + "RetryableWriteError", + "TransientTransactionError", + "UnknownTransactionCommitResult" + ] + } + } + ], + "expectEvents": [ + { + "client": "client0", + "events": [ + { + "commandStartedEvent": { + "command": { + "insert": "test", + "documents": [ + { + "_id": 1 + } + ], + "ordered": true, + "readConcern": { + "$$exists": false + }, + "lsid": { + "$$sessionLsid": "session0" + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": true, + "autocommit": false, + "writeConcern": { + "$$exists": false + } + }, + "commandName": "insert", + "databaseName": "transaction-tests" + } + }, + { + "commandStartedEvent": { + "command": { + "commitTransaction": 1, + "lsid": { + "$$sessionLsid": "session0" + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": { + "$$exists": false + }, + "autocommit": false, + "writeConcern": { + "$$exists": false + } + }, + "commandName": "commitTransaction", + "databaseName": "admin" + } + } + ] + } + ], + "outcome": [ + { + "collectionName": "test", + "databaseName": "transaction-tests", + "documents": [] + } + ] + }, + { + "description": "commitTransaction is not retried after UnsatisfiableWriteConcern error", + "operations": [ + { + "object": "testRunner", + "name": "failPoint", + "arguments": { + "client": "client0", + "failPoint": { + "configureFailPoint": "failCommand", + "mode": { + "times": 1 + }, + "data": { + "failCommands": [ + "commitTransaction" + ], + "writeConcernError": { + "code": 100, + "errmsg": "Not enough data-bearing nodes" + } + } + } + } + }, + { + "object": "session0", + "name": "startTransaction", + "arguments": { + "writeConcern": { + "w": "majority" + } + } + }, + { + "object": "collection0", + "name": "insertOne", + "arguments": { + "session": "session0", + "document": { + "_id": 1 + } + }, + "expectResult": { + "$$unsetOrMatches": { + "insertedId": { + "$$unsetOrMatches": 1 + } + } + } + }, + { + "object": "session0", + "name": "commitTransaction", + "expectError": { + "errorLabelsOmit": [ + "RetryableWriteError", + "TransientTransactionError", + "UnknownTransactionCommitResult" + ] + } + } + ], + "expectEvents": [ + { + "client": "client0", + "events": [ + { + "commandStartedEvent": { + "command": { + "insert": "test", + "documents": [ + { + "_id": 1 + } + ], + "ordered": true, + "readConcern": { + "$$exists": false + }, + "lsid": { + "$$sessionLsid": "session0" + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": true, + "autocommit": false, + "writeConcern": { + "$$exists": false + } + }, + "commandName": "insert", + "databaseName": "transaction-tests" + } + }, + { + "commandStartedEvent": { + "command": { + "commitTransaction": 1, + "lsid": { + "$$sessionLsid": "session0" + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": { + "$$exists": false + }, + "autocommit": false, + "writeConcern": { + "w": "majority" + } + }, + "commandName": "commitTransaction", + "databaseName": "admin" + } + } + ] + } + ], + "outcome": [ + { + "collectionName": "test", + "databaseName": "transaction-tests", + "documents": [ + { + "_id": 1 + } + ] + } + ] + }, + { + "description": "commitTransaction fails after two errors", + "runOnRequirements": [ + { + "serverless": "forbid" + } + ], + "operations": [ + { + "object": "testRunner", + "name": "failPoint", + "arguments": { + "client": "client1", + "failPoint": { + "configureFailPoint": "failCommand", + "mode": { + "times": 2 + }, + "data": { + "failCommands": [ + "commitTransaction" + ], + "closeConnection": true + } + } + } + }, + { + "object": "session1", + "name": "startTransaction" + }, + { + "object": "collection1", + "name": "insertOne", + "arguments": { + "session": "session1", + "document": { + "_id": 1 + } + }, + "expectResult": { + "$$unsetOrMatches": { + "insertedId": { + "$$unsetOrMatches": 1 + } + } + } + }, + { + "object": "session1", + "name": "commitTransaction", + "expectError": { + "errorLabelsContain": [ + "RetryableWriteError", + "UnknownTransactionCommitResult" + ], + "errorLabelsOmit": [ + "TransientTransactionError" + ] + } + }, + { + "object": "session1", + "name": "commitTransaction" + } + ], + "expectEvents": [ + { + "client": "client1", + "events": [ + { + "commandStartedEvent": { + "command": { + "insert": "test", + "documents": [ + { + "_id": 1 + } + ], + "ordered": true, + "readConcern": { + "$$exists": false + }, + "lsid": { + "$$sessionLsid": "session1" + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": true, + "autocommit": false, + "writeConcern": { + "$$exists": false + } + }, + "commandName": "insert", + "databaseName": "transaction-tests" + } + }, + { + "commandStartedEvent": { + "command": { + "commitTransaction": 1, + "lsid": { + "$$sessionLsid": "session1" + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": { + "$$exists": false + }, + "autocommit": false, + "writeConcern": { + "$$exists": false + } + }, + "commandName": "commitTransaction", + "databaseName": "admin" + } + }, + { + "commandStartedEvent": { + "command": { + "commitTransaction": 1, + "lsid": { + "$$sessionLsid": "session1" + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": { + "$$exists": false + }, + "autocommit": false, + "writeConcern": { + "w": "majority", + "wtimeout": 10000 + } + }, + "commandName": "commitTransaction", + "databaseName": "admin" + } + }, + { + "commandStartedEvent": { + "command": { + "commitTransaction": 1, + "lsid": { + "$$sessionLsid": "session1" + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": { + "$$exists": false + }, + "autocommit": false, + "writeConcern": { + "w": "majority", + "wtimeout": 10000 + } + }, + "commandName": "commitTransaction", + "databaseName": "admin" + } + } + ] + } + ], + "outcome": [ + { + "collectionName": "test", + "databaseName": "transaction-tests", + "documents": [ + { + "_id": 1 + } + ] + } + ] + }, + { + "description": "commitTransaction applies majority write concern on retries", + "runOnRequirements": [ + { + "serverless": "forbid" + } + ], + "operations": [ + { + "object": "testRunner", + "name": "failPoint", + "arguments": { + "client": "client1", + "failPoint": { + "configureFailPoint": "failCommand", + "mode": { + "times": 2 + }, + "data": { + "failCommands": [ + "commitTransaction" + ], + "closeConnection": true + } + } + } + }, + { + "object": "session1", + "name": "startTransaction", + "arguments": { + "writeConcern": { + "w": 2, + "journal": true, + "wtimeoutMS": 5000 + } + } + }, + { + "object": "collection1", + "name": "insertOne", + "arguments": { + "session": "session1", + "document": { + "_id": 1 + } + }, + "expectResult": { + "$$unsetOrMatches": { + "insertedId": { + "$$unsetOrMatches": 1 + } + } + } + }, + { + "object": "session1", + "name": "commitTransaction", + "expectError": { + "errorLabelsContain": [ + "RetryableWriteError", + "UnknownTransactionCommitResult" + ], + "errorLabelsOmit": [ + "TransientTransactionError" + ] + } + }, + { + "object": "session1", + "name": "commitTransaction" + } + ], + "expectEvents": [ + { + "client": "client1", + "events": [ + { + "commandStartedEvent": { + "command": { + "insert": "test", + "documents": [ + { + "_id": 1 + } + ], + "ordered": true, + "readConcern": { + "$$exists": false + }, + "lsid": { + "$$sessionLsid": "session1" + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": true, + "autocommit": false, + "writeConcern": { + "$$exists": false + } + }, + "commandName": "insert", + "databaseName": "transaction-tests" + } + }, + { + "commandStartedEvent": { + "command": { + "commitTransaction": 1, + "lsid": { + "$$sessionLsid": "session1" + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": { + "$$exists": false + }, + "autocommit": false, + "writeConcern": { + "w": 2, + "j": true, + "wtimeout": 5000 + } + }, + "commandName": "commitTransaction", + "databaseName": "admin" + } + }, + { + "commandStartedEvent": { + "command": { + "commitTransaction": 1, + "lsid": { + "$$sessionLsid": "session1" + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": { + "$$exists": false + }, + "autocommit": false, + "writeConcern": { + "w": "majority", + "j": true, + "wtimeout": 5000 + } + }, + "commandName": "commitTransaction", + "databaseName": "admin" + } + }, + { + "commandStartedEvent": { + "command": { + "commitTransaction": 1, + "lsid": { + "$$sessionLsid": "session1" + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": { + "$$exists": false + }, + "autocommit": false, + "writeConcern": { + "w": "majority", + "j": true, + "wtimeout": 5000 + } + }, + "commandName": "commitTransaction", + "databaseName": "admin" + } + } + ] + } + ], + "outcome": [ + { + "collectionName": "test", + "databaseName": "transaction-tests", + "documents": [ + { + "_id": 1 + } + ] + } + ] + }, + { + "description": "commitTransaction succeeds after connection error", + "runOnRequirements": [ + { + "serverless": "forbid" + } + ], + "operations": [ + { + "object": "testRunner", + "name": "failPoint", + "arguments": { + "client": "client0", + "failPoint": { + "configureFailPoint": "failCommand", + "mode": { + "times": 1 + }, + "data": { + "failCommands": [ + "commitTransaction" + ], + "closeConnection": true + } + } + } + }, + { + "object": "session0", + "name": "startTransaction" + }, + { + "object": "collection0", + "name": "insertOne", + "arguments": { + "session": "session0", + "document": { + "_id": 1 + } + }, + "expectResult": { + "$$unsetOrMatches": { + "insertedId": { + "$$unsetOrMatches": 1 + } + } + } + }, + { + "object": "session0", + "name": "commitTransaction" + } + ], + "expectEvents": [ + { + "client": "client0", + "events": [ + { + "commandStartedEvent": { + "command": { + "insert": "test", + "documents": [ + { + "_id": 1 + } + ], + "ordered": true, + "readConcern": { + "$$exists": false + }, + "lsid": { + "$$sessionLsid": "session0" + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": true, + "autocommit": false, + "writeConcern": { + "$$exists": false + } + }, + "commandName": "insert", + "databaseName": "transaction-tests" + } + }, + { + "commandStartedEvent": { + "command": { + "commitTransaction": 1, + "lsid": { + "$$sessionLsid": "session0" + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": { + "$$exists": false + }, + "autocommit": false, + "writeConcern": { + "$$exists": false + } + }, + "commandName": "commitTransaction", + "databaseName": "admin" + } + }, + { + "commandStartedEvent": { + "command": { + "commitTransaction": 1, + "lsid": { + "$$sessionLsid": "session0" + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": { + "$$exists": false + }, + "autocommit": false, + "writeConcern": { + "w": "majority", + "wtimeout": 10000 + } + }, + "commandName": "commitTransaction", + "databaseName": "admin" + } + } + ] + } + ], + "outcome": [ + { + "collectionName": "test", + "databaseName": "transaction-tests", + "documents": [ + { + "_id": 1 + } + ] + } + ] + } + ] +} diff --git a/source/transactions/tests/unified/retryable-commit.yml b/source/transactions/tests/unified/retryable-commit.yml new file mode 100644 index 0000000000..916944065a --- /dev/null +++ b/source/transactions/tests/unified/retryable-commit.yml @@ -0,0 +1,521 @@ +description: retryable-commit + +schemaVersion: '1.4' + +runOnRequirements: + - + minServerVersion: '4.0' + topologies: + - replicaset + - + minServerVersion: 4.1.8 + topologies: + - sharded + - load-balanced + +createEntities: + - + client: + id: &client0 client0 + useMultipleMongoses: false + observeEvents: + - commandStartedEvent + - + database: + id: &database0 database0 + client: *client0 + databaseName: &database_name transaction-tests + - + collection: + id: &collection0 collection0 + database: *database0 + collectionName: &collection_name test + - + session: + id: &session0 session0 + client: *client0 + # Define a second set of entities for a retryWrites=false client + - + client: + id: &client1 client1 + useMultipleMongoses: false + uriOptions: + retryWrites: false + observeEvents: + - commandStartedEvent + - + database: + id: &database1 database1 + client: *client1 + databaseName: *database_name + - + collection: + id: &collection1 collection1 + database: *database1 + collectionName: *collection_name + - + session: + id: &session1 session1 + client: *client1 + +initialData: + - + collectionName: *collection_name + databaseName: *database_name + documents: [] + +tests: + - + description: 'commitTransaction fails after Interrupted' + operations: + - + object: testRunner + name: failPoint + arguments: + client: *client0 + failPoint: + configureFailPoint: failCommand + mode: { times: 1 } + data: + failCommands: + - commitTransaction + errorCode: 11601 + closeConnection: false + - + object: *session0 + name: startTransaction + - + object: *collection0 + name: insertOne + arguments: + session: *session0 + document: { _id: 1 } + expectResult: + $$unsetOrMatches: { insertedId: { $$unsetOrMatches: 1 } } + - + object: *session0 + name: commitTransaction + expectError: + errorCodeName: Interrupted + errorLabelsOmit: + - RetryableWriteError + - TransientTransactionError + - UnknownTransactionCommitResult + expectEvents: + - + client: *client0 + events: + - + commandStartedEvent: + command: + insert: *collection_name + documents: + - { _id: 1 } + ordered: true + readConcern: { $$exists: false } + lsid: { $$sessionLsid: *session0 } + txnNumber: { $numberLong: '1' } + startTransaction: true + autocommit: false + writeConcern: { $$exists: false } + commandName: insert + databaseName: *database_name + - + commandStartedEvent: + command: + commitTransaction: 1 + lsid: { $$sessionLsid: *session0 } + txnNumber: { $numberLong: '1' } + startTransaction: { $$exists: false } + autocommit: false + writeConcern: { $$exists: false } + commandName: commitTransaction + databaseName: admin + outcome: + - + collectionName: *collection_name + databaseName: *database_name + documents: [] + - + description: 'commitTransaction is not retried after UnsatisfiableWriteConcern error' + operations: + - + object: testRunner + name: failPoint + arguments: + client: *client0 + failPoint: + configureFailPoint: failCommand + mode: { times: 1 } + data: + failCommands: + - commitTransaction + writeConcernError: + code: 100 + errmsg: 'Not enough data-bearing nodes' + - + object: *session0 + name: startTransaction + arguments: + writeConcern: + w: majority + - + object: *collection0 + name: insertOne + arguments: + session: *session0 + document: { _id: 1 } + expectResult: + $$unsetOrMatches: { insertedId: { $$unsetOrMatches: 1 } } + - + object: *session0 + name: commitTransaction + expectError: + errorLabelsOmit: + - RetryableWriteError + - TransientTransactionError + - UnknownTransactionCommitResult + expectEvents: + - + client: *client0 + events: + - + commandStartedEvent: + command: + insert: *collection_name + documents: + - { _id: 1 } + ordered: true + readConcern: { $$exists: false } + lsid: { $$sessionLsid: *session0 } + txnNumber: { $numberLong: '1' } + startTransaction: true + autocommit: false + writeConcern: { $$exists: false } + commandName: insert + databaseName: *database_name + - + commandStartedEvent: + command: + commitTransaction: 1 + lsid: { $$sessionLsid: *session0 } + txnNumber: { $numberLong: '1' } + startTransaction: { $$exists: false } + autocommit: false + writeConcern: + w: majority + commandName: commitTransaction + databaseName: admin + outcome: + - + collectionName: *collection_name + databaseName: *database_name + documents: + - { _id: 1 } + - + description: 'commitTransaction fails after two errors' + # Failing commitTransaction with closeConnection:true may abort the + # transaction (CLOUDP-202309). + runOnRequirements: + - serverless: forbid + operations: + - + object: testRunner + name: failPoint + arguments: + client: *client1 + failPoint: + configureFailPoint: failCommand + mode: { times: 2 } + data: + failCommands: + - commitTransaction + closeConnection: true + - + object: *session1 + name: startTransaction + - + object: *collection1 + name: insertOne + arguments: + session: *session1 + document: { _id: 1 } + expectResult: + $$unsetOrMatches: { insertedId: { $$unsetOrMatches: 1 } } + # First call to commit fails after a single retry attempt. + - + object: *session1 + name: commitTransaction + expectError: + errorLabelsContain: + - RetryableWriteError + - UnknownTransactionCommitResult + errorLabelsOmit: + - TransientTransactionError + # Second call to commit succeeds because the failpoint was disabled. + - + object: *session1 + name: commitTransaction + expectEvents: + - + client: *client1 + events: + - + commandStartedEvent: + command: + insert: *collection_name + documents: + - { _id: 1 } + ordered: true + readConcern: { $$exists: false } + lsid: { $$sessionLsid: *session1 } + txnNumber: { $numberLong: '1' } + startTransaction: true + autocommit: false + writeConcern: { $$exists: false } + commandName: insert + databaseName: *database_name + - + commandStartedEvent: + command: + commitTransaction: 1 + lsid: { $$sessionLsid: *session1 } + txnNumber: { $numberLong: '1' } + startTransaction: { $$exists: false } + autocommit: false + writeConcern: { $$exists: false } + commandName: commitTransaction + databaseName: admin + - + commandStartedEvent: + command: + commitTransaction: 1 + lsid: { $$sessionLsid: *session1 } + txnNumber: { $numberLong: '1' } + startTransaction: { $$exists: false } + autocommit: false + # commitTransaction applies w:majority on retries + writeConcern: + w: majority + wtimeout: 10000 + commandName: commitTransaction + databaseName: admin + - + commandStartedEvent: + command: + commitTransaction: 1 + lsid: { $$sessionLsid: *session1 } + txnNumber: { $numberLong: '1' } + startTransaction: { $$exists: false } + autocommit: false + writeConcern: + w: majority + wtimeout: 10000 + commandName: commitTransaction + databaseName: admin + outcome: + - + collectionName: *collection_name + databaseName: *database_name + documents: + - { _id: 1 } + - + description: 'commitTransaction applies majority write concern on retries' + # Failing commitTransaction with closeConnection:true may abort the + # transaction (CLOUDP-202309). + runOnRequirements: + - serverless: forbid + operations: + - + object: testRunner + name: failPoint + arguments: + client: *client1 + failPoint: + configureFailPoint: failCommand + mode: { times: 2 } + data: + failCommands: + - commitTransaction + closeConnection: true + - + object: *session1 + name: startTransaction + arguments: + writeConcern: + w: 2 + journal: true + wtimeoutMS: 5000 + - + object: *collection1 + name: insertOne + arguments: + session: *session1 + document: { _id: 1 } + expectResult: + $$unsetOrMatches: { insertedId: { $$unsetOrMatches: 1 } } + # First call to commit fails after a single retry attempt. + - + object: *session1 + name: commitTransaction + expectError: + errorLabelsContain: + - RetryableWriteError + - UnknownTransactionCommitResult + errorLabelsOmit: + - TransientTransactionError + # Second call to commit succeeds because the failpoint was disabled. + - + object: *session1 + name: commitTransaction + expectEvents: + - + client: *client1 + events: + - + commandStartedEvent: + command: + insert: *collection_name + documents: + - { _id: 1 } + ordered: true + readConcern: { $$exists: false } + lsid: { $$sessionLsid: *session1 } + txnNumber: { $numberLong: '1' } + startTransaction: true + autocommit: false + writeConcern: { $$exists: false } + commandName: insert + databaseName: *database_name + - + commandStartedEvent: + command: + commitTransaction: 1 + lsid: { $$sessionLsid: *session1 } + txnNumber: { $numberLong: '1' } + startTransaction: { $$exists: false } + autocommit: false + writeConcern: + w: 2 + j: true + wtimeout: 5000 + commandName: commitTransaction + databaseName: admin + - + commandStartedEvent: + command: + commitTransaction: 1 + lsid: { $$sessionLsid: *session1 } + txnNumber: { $numberLong: '1' } + startTransaction: { $$exists: false } + autocommit: false + # commitTransaction applies w:majority on retries + writeConcern: + w: majority + j: true + wtimeout: 5000 + commandName: commitTransaction + databaseName: admin + - + commandStartedEvent: + command: + commitTransaction: 1 + lsid: { $$sessionLsid: *session1 } + txnNumber: { $numberLong: '1' } + startTransaction: { $$exists: false } + autocommit: false + writeConcern: + w: majority + j: true + wtimeout: 5000 + commandName: commitTransaction + databaseName: admin + outcome: + - + collectionName: *collection_name + databaseName: *database_name + documents: + - { _id: 1 } + - + description: 'commitTransaction succeeds after connection error' + # Failing commitTransaction with closeConnection:true may abort the + # transaction (CLOUDP-202309). + runOnRequirements: + - serverless: forbid + operations: + - + object: testRunner + name: failPoint + arguments: + client: *client0 + failPoint: + configureFailPoint: failCommand + mode: { times: 1 } + data: + failCommands: + - commitTransaction + closeConnection: true + - + object: *session0 + name: startTransaction + - + object: *collection0 + name: insertOne + arguments: + session: *session0 + document: { _id: 1 } + expectResult: + $$unsetOrMatches: { insertedId: { $$unsetOrMatches: 1 } } + - + object: *session0 + name: commitTransaction + expectEvents: + - + client: *client0 + events: + - + commandStartedEvent: + command: + insert: *collection_name + documents: + - { _id: 1 } + ordered: true + readConcern: { $$exists: false } + lsid: { $$sessionLsid: *session0 } + txnNumber: { $numberLong: '1' } + startTransaction: true + autocommit: false + writeConcern: { $$exists: false } + commandName: insert + databaseName: *database_name + - + commandStartedEvent: + command: + commitTransaction: 1 + lsid: { $$sessionLsid: *session0 } + txnNumber: { $numberLong: '1' } + startTransaction: { $$exists: false } + autocommit: false + writeConcern: { $$exists: false } + commandName: commitTransaction + databaseName: admin + - + commandStartedEvent: + command: + commitTransaction: 1 + lsid: { $$sessionLsid: *session0 } + txnNumber: { $numberLong: '1' } + startTransaction: { $$exists: false } + autocommit: false + # commitTransaction applies w:majority on retries + writeConcern: + w: majority + wtimeout: 10000 + commandName: commitTransaction + databaseName: admin + outcome: + - + collectionName: *collection_name + databaseName: *database_name + documents: + - { _id: 1 } diff --git a/source/transactions/tests/unified/retryable-writes.json b/source/transactions/tests/unified/retryable-writes.json new file mode 100644 index 0000000000..c196e68622 --- /dev/null +++ b/source/transactions/tests/unified/retryable-writes.json @@ -0,0 +1,468 @@ +{ + "description": "retryable-writes", + "schemaVersion": "1.3", + "runOnRequirements": [ + { + "minServerVersion": "4.0", + "topologies": [ + "replicaset" + ] + }, + { + "minServerVersion": "4.1.8", + "topologies": [ + "sharded", + "load-balanced" + ] + } + ], + "createEntities": [ + { + "client": { + "id": "client0", + "useMultipleMongoses": false, + "observeEvents": [ + "commandStartedEvent" + ] + } + }, + { + "database": { + "id": "database0", + "client": "client0", + "databaseName": "transaction-tests" + } + }, + { + "collection": { + "id": "collection0", + "database": "database0", + "collectionName": "test" + } + }, + { + "session": { + "id": "session0", + "client": "client0" + } + } + ], + "initialData": [ + { + "collectionName": "test", + "databaseName": "transaction-tests", + "documents": [] + } + ], + "tests": [ + { + "description": "increment txnNumber", + "operations": [ + { + "object": "session0", + "name": "startTransaction" + }, + { + "object": "collection0", + "name": "insertOne", + "arguments": { + "session": "session0", + "document": { + "_id": 1 + } + }, + "expectResult": { + "$$unsetOrMatches": { + "insertedId": { + "$$unsetOrMatches": 1 + } + } + } + }, + { + "object": "session0", + "name": "commitTransaction" + }, + { + "object": "collection0", + "name": "insertOne", + "arguments": { + "session": "session0", + "document": { + "_id": 2 + } + }, + "expectResult": { + "$$unsetOrMatches": { + "insertedId": { + "$$unsetOrMatches": 2 + } + } + } + }, + { + "object": "session0", + "name": "startTransaction" + }, + { + "object": "collection0", + "name": "insertOne", + "arguments": { + "session": "session0", + "document": { + "_id": 3 + } + }, + "expectResult": { + "$$unsetOrMatches": { + "insertedId": { + "$$unsetOrMatches": 3 + } + } + } + }, + { + "object": "session0", + "name": "abortTransaction" + }, + { + "object": "collection0", + "name": "insertMany", + "arguments": { + "documents": [ + { + "_id": 4 + }, + { + "_id": 5 + } + ], + "session": "session0" + }, + "expectResult": { + "$$unsetOrMatches": { + "insertedIds": { + "$$unsetOrMatches": { + "0": 4, + "1": 5 + } + } + } + } + } + ], + "expectEvents": [ + { + "client": "client0", + "events": [ + { + "commandStartedEvent": { + "command": { + "insert": "test", + "documents": [ + { + "_id": 1 + } + ], + "ordered": true, + "readConcern": { + "$$exists": false + }, + "lsid": { + "$$sessionLsid": "session0" + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": true, + "autocommit": false, + "writeConcern": { + "$$exists": false + } + }, + "commandName": "insert", + "databaseName": "transaction-tests" + } + }, + { + "commandStartedEvent": { + "command": { + "commitTransaction": 1, + "lsid": { + "$$sessionLsid": "session0" + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": { + "$$exists": false + }, + "autocommit": false, + "writeConcern": { + "$$exists": false + } + }, + "commandName": "commitTransaction", + "databaseName": "admin" + } + }, + { + "commandStartedEvent": { + "command": { + "insert": "test", + "documents": [ + { + "_id": 2 + } + ], + "ordered": true, + "readConcern": { + "$$exists": false + }, + "lsid": { + "$$sessionLsid": "session0" + }, + "txnNumber": { + "$numberLong": "2" + }, + "startTransaction": { + "$$exists": false + }, + "autocommit": { + "$$exists": false + }, + "writeConcern": { + "$$exists": false + } + }, + "commandName": "insert", + "databaseName": "transaction-tests" + } + }, + { + "commandStartedEvent": { + "command": { + "insert": "test", + "documents": [ + { + "_id": 3 + } + ], + "ordered": true, + "readConcern": { + "afterClusterTime": { + "$$exists": true + } + }, + "lsid": { + "$$sessionLsid": "session0" + }, + "txnNumber": { + "$numberLong": "3" + }, + "startTransaction": true, + "autocommit": false, + "writeConcern": { + "$$exists": false + } + }, + "commandName": "insert", + "databaseName": "transaction-tests" + } + }, + { + "commandStartedEvent": { + "command": { + "abortTransaction": 1, + "lsid": { + "$$sessionLsid": "session0" + }, + "txnNumber": { + "$numberLong": "3" + }, + "startTransaction": { + "$$exists": false + }, + "autocommit": false, + "writeConcern": { + "$$exists": false + } + }, + "commandName": "abortTransaction", + "databaseName": "admin" + } + }, + { + "commandStartedEvent": { + "command": { + "insert": "test", + "documents": [ + { + "_id": 4 + }, + { + "_id": 5 + } + ], + "ordered": true, + "readConcern": { + "$$exists": false + }, + "lsid": { + "$$sessionLsid": "session0" + }, + "txnNumber": { + "$numberLong": "4" + }, + "startTransaction": { + "$$exists": false + }, + "autocommit": { + "$$exists": false + }, + "writeConcern": { + "$$exists": false + } + }, + "commandName": "insert", + "databaseName": "transaction-tests" + } + } + ] + } + ], + "outcome": [ + { + "collectionName": "test", + "databaseName": "transaction-tests", + "documents": [ + { + "_id": 1 + }, + { + "_id": 2 + }, + { + "_id": 4 + }, + { + "_id": 5 + } + ] + } + ] + }, + { + "description": "writes are not retried", + "operations": [ + { + "object": "testRunner", + "name": "failPoint", + "arguments": { + "client": "client0", + "failPoint": { + "configureFailPoint": "failCommand", + "mode": { + "times": 1 + }, + "data": { + "failCommands": [ + "insert" + ], + "closeConnection": true + } + } + } + }, + { + "object": "session0", + "name": "startTransaction" + }, + { + "object": "collection0", + "name": "insertOne", + "arguments": { + "session": "session0", + "document": { + "_id": 1 + } + }, + "expectError": { + "errorLabelsContain": [ + "TransientTransactionError" + ] + } + }, + { + "object": "session0", + "name": "abortTransaction" + } + ], + "expectEvents": [ + { + "client": "client0", + "events": [ + { + "commandStartedEvent": { + "command": { + "insert": "test", + "documents": [ + { + "_id": 1 + } + ], + "ordered": true, + "readConcern": { + "$$exists": false + }, + "lsid": { + "$$sessionLsid": "session0" + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": true, + "autocommit": false, + "writeConcern": { + "$$exists": false + } + }, + "commandName": "insert", + "databaseName": "transaction-tests" + } + }, + { + "commandStartedEvent": { + "command": { + "abortTransaction": 1, + "lsid": { + "$$sessionLsid": "session0" + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": { + "$$exists": false + }, + "autocommit": false, + "writeConcern": { + "$$exists": false + } + }, + "commandName": "abortTransaction", + "databaseName": "admin" + } + } + ] + } + ], + "outcome": [ + { + "collectionName": "test", + "databaseName": "transaction-tests", + "documents": [] + } + ] + } + ] +} diff --git a/source/transactions/tests/unified/retryable-writes.yml b/source/transactions/tests/unified/retryable-writes.yml new file mode 100644 index 0000000000..aa9c037d41 --- /dev/null +++ b/source/transactions/tests/unified/retryable-writes.yml @@ -0,0 +1,259 @@ +description: retryable-writes + +schemaVersion: '1.3' + +runOnRequirements: + - + minServerVersion: '4.0' + topologies: + - replicaset + - + minServerVersion: 4.1.8 + topologies: + - sharded + - load-balanced + +createEntities: + - + client: + id: &client0 client0 + useMultipleMongoses: false + observeEvents: + - commandStartedEvent + - + database: + id: &database0 database0 + client: *client0 + databaseName: &database_name transaction-tests + - + collection: + id: &collection0 collection0 + database: *database0 + collectionName: &collection_name test + - + session: + id: &session0 session0 + client: *client0 + +initialData: + - + collectionName: *collection_name + databaseName: *database_name + documents: [] + +tests: + - + description: 'increment txnNumber' + operations: + - + object: *session0 + name: startTransaction + - + object: *collection0 + name: insertOne + arguments: + session: *session0 + document: { _id: 1 } + expectResult: + $$unsetOrMatches: { insertedId: { $$unsetOrMatches: 1 } } + - + object: *session0 + name: commitTransaction + - + object: *collection0 + name: insertOne + arguments: + session: *session0 + document: { _id: 2 } + expectResult: + $$unsetOrMatches: { insertedId: { $$unsetOrMatches: 2 } } + - + object: *session0 + name: startTransaction + - + object: *collection0 + name: insertOne + arguments: + session: *session0 + document: { _id: 3 } + expectResult: + $$unsetOrMatches: { insertedId: { $$unsetOrMatches: 3 } } + - + object: *session0 + name: abortTransaction + - + object: *collection0 + name: insertMany + arguments: + documents: + - { _id: 4 } + - { _id: 5 } + session: *session0 + expectResult: + $$unsetOrMatches: + insertedIds: + $$unsetOrMatches: + '0': 4 + '1': 5 + expectEvents: + - + client: *client0 + events: + - + commandStartedEvent: + command: + insert: *collection_name + documents: + - { _id: 1 } + ordered: true + readConcern: { $$exists: false } + lsid: { $$sessionLsid: *session0 } + txnNumber: { $numberLong: '1' } + startTransaction: true + autocommit: false + writeConcern: { $$exists: false } + commandName: insert + databaseName: *database_name + - + commandStartedEvent: + command: + commitTransaction: 1 + lsid: { $$sessionLsid: *session0 } + txnNumber: { $numberLong: '1' } + startTransaction: { $$exists: false } + autocommit: false + writeConcern: { $$exists: false } + commandName: commitTransaction + databaseName: admin + - + commandStartedEvent: + command: + insert: *collection_name + documents: + - { _id: 2 } + ordered: true + readConcern: { $$exists: false } + lsid: { $$sessionLsid: *session0 } + txnNumber: { $numberLong: '2' } + startTransaction: { $$exists: false } + autocommit: { $$exists: false } + writeConcern: { $$exists: false } + commandName: insert + databaseName: *database_name + - + commandStartedEvent: + command: + insert: *collection_name + documents: + - { _id: 3 } + ordered: true + readConcern: + afterClusterTime: { $$exists: true } + lsid: { $$sessionLsid: *session0 } + txnNumber: { $numberLong: '3' } + startTransaction: true + autocommit: false + writeConcern: { $$exists: false } + commandName: insert + databaseName: *database_name + - + commandStartedEvent: + command: + abortTransaction: 1 + lsid: { $$sessionLsid: *session0 } + txnNumber: { $numberLong: '3' } + startTransaction: { $$exists: false } + autocommit: false + writeConcern: { $$exists: false } + commandName: abortTransaction + databaseName: admin + - + commandStartedEvent: + command: + insert: *collection_name + documents: + - { _id: 4 } + - { _id: 5 } + ordered: true + readConcern: { $$exists: false } + lsid: { $$sessionLsid: *session0 } + txnNumber: { $numberLong: '4' } + startTransaction: { $$exists: false } + autocommit: { $$exists: false } + writeConcern: { $$exists: false } + commandName: insert + databaseName: *database_name + outcome: + - + collectionName: *collection_name + databaseName: *database_name + documents: + - { _id: 1 } + - { _id: 2 } + - { _id: 4 } + - { _id: 5 } + - + description: 'writes are not retried' + operations: + - + object: testRunner + name: failPoint + arguments: + client: *client0 + failPoint: + configureFailPoint: failCommand + mode: { times: 1 } + data: + failCommands: + - insert + closeConnection: true + - + object: *session0 + name: startTransaction + - + object: *collection0 + name: insertOne + arguments: + session: *session0 + document: { _id: 1 } + expectError: + errorLabelsContain: + - TransientTransactionError + - + object: *session0 + name: abortTransaction + expectEvents: + - + client: *client0 + events: + - + commandStartedEvent: + command: + insert: *collection_name + documents: + - { _id: 1 } + ordered: true + readConcern: { $$exists: false } + lsid: { $$sessionLsid: *session0 } + txnNumber: { $numberLong: '1' } + startTransaction: true + autocommit: false + writeConcern: { $$exists: false } + commandName: insert + databaseName: *database_name + - + commandStartedEvent: + command: + abortTransaction: 1 + lsid: { $$sessionLsid: *session0 } + txnNumber: { $numberLong: '1' } + startTransaction: { $$exists: false } + autocommit: false + writeConcern: { $$exists: false } + commandName: abortTransaction + databaseName: admin + outcome: + - + collectionName: *collection_name + databaseName: *database_name + documents: [] diff --git a/source/transactions/tests/unified/run-command.json b/source/transactions/tests/unified/run-command.json new file mode 100644 index 0000000000..7bd420ef74 --- /dev/null +++ b/source/transactions/tests/unified/run-command.json @@ -0,0 +1,421 @@ +{ + "description": "run-command", + "schemaVersion": "1.9", + "runOnRequirements": [ + { + "minServerVersion": "4.0", + "topologies": [ + "replicaset" + ] + }, + { + "minServerVersion": "4.1.8", + "topologies": [ + "sharded", + "load-balanced" + ] + } + ], + "createEntities": [ + { + "client": { + "id": "client0", + "useMultipleMongoses": false, + "observeEvents": [ + "commandStartedEvent" + ] + } + }, + { + "database": { + "id": "database0", + "client": "client0", + "databaseName": "transaction-tests" + } + }, + { + "collection": { + "id": "collection0", + "database": "database0", + "collectionName": "test" + } + }, + { + "session": { + "id": "session0", + "client": "client0" + } + } + ], + "initialData": [ + { + "collectionName": "test", + "databaseName": "transaction-tests", + "documents": [] + } + ], + "tests": [ + { + "description": "run command with default read preference", + "operations": [ + { + "object": "session0", + "name": "startTransaction" + }, + { + "object": "database0", + "name": "runCommand", + "arguments": { + "session": "session0", + "command": { + "insert": "test", + "documents": [ + { + "_id": 1 + } + ] + }, + "commandName": "insert" + }, + "expectResult": { + "n": 1 + } + }, + { + "object": "session0", + "name": "commitTransaction" + } + ], + "expectEvents": [ + { + "client": "client0", + "events": [ + { + "commandStartedEvent": { + "command": { + "insert": "test", + "documents": [ + { + "_id": 1 + } + ], + "readConcern": { + "$$exists": false + }, + "lsid": { + "$$sessionLsid": "session0" + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": true, + "autocommit": false, + "writeConcern": { + "$$exists": false + } + }, + "commandName": "insert", + "databaseName": "transaction-tests" + } + }, + { + "commandStartedEvent": { + "command": { + "commitTransaction": 1, + "lsid": { + "$$sessionLsid": "session0" + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": { + "$$exists": false + }, + "autocommit": false, + "writeConcern": { + "$$exists": false + } + }, + "commandName": "commitTransaction", + "databaseName": "admin" + } + } + ] + } + ] + }, + { + "description": "run command with secondary read preference in client option and primary read preference in transaction options", + "operations": [ + { + "object": "testRunner", + "name": "createEntities", + "arguments": { + "entities": [ + { + "client": { + "id": "client1", + "useMultipleMongoses": false, + "uriOptions": { + "readPreference": "secondary" + }, + "observeEvents": [ + "commandStartedEvent" + ] + } + }, + { + "database": { + "id": "database1", + "client": "client1", + "databaseName": "transaction-tests" + } + }, + { + "session": { + "id": "session1", + "client": "client1" + } + } + ] + } + }, + { + "object": "session1", + "name": "startTransaction", + "arguments": { + "readPreference": { + "mode": "primary" + } + } + }, + { + "object": "database1", + "name": "runCommand", + "arguments": { + "session": "session1", + "command": { + "insert": "test", + "documents": [ + { + "_id": 1 + } + ] + }, + "commandName": "insert" + }, + "expectResult": { + "n": 1 + } + }, + { + "object": "session1", + "name": "commitTransaction" + } + ], + "expectEvents": [ + { + "client": "client1", + "events": [ + { + "commandStartedEvent": { + "command": { + "insert": "test", + "documents": [ + { + "_id": 1 + } + ], + "readConcern": { + "$$exists": false + }, + "lsid": { + "$$sessionLsid": "session1" + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": true, + "autocommit": false, + "writeConcern": { + "$$exists": false + } + }, + "commandName": "insert", + "databaseName": "transaction-tests" + } + }, + { + "commandStartedEvent": { + "command": { + "commitTransaction": 1, + "lsid": { + "$$sessionLsid": "session1" + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": { + "$$exists": false + }, + "autocommit": false, + "writeConcern": { + "$$exists": false + } + }, + "commandName": "commitTransaction", + "databaseName": "admin" + } + } + ] + } + ] + }, + { + "description": "run command with explicit primary read preference", + "operations": [ + { + "object": "session0", + "name": "startTransaction" + }, + { + "object": "database0", + "name": "runCommand", + "arguments": { + "session": "session0", + "command": { + "insert": "test", + "documents": [ + { + "_id": 1 + } + ] + }, + "readPreference": { + "mode": "primary" + }, + "commandName": "insert" + }, + "expectResult": { + "n": 1 + } + }, + { + "object": "session0", + "name": "commitTransaction" + } + ], + "expectEvents": [ + { + "client": "client0", + "events": [ + { + "commandStartedEvent": { + "command": { + "insert": "test", + "documents": [ + { + "_id": 1 + } + ], + "readConcern": { + "$$exists": false + }, + "lsid": { + "$$sessionLsid": "session0" + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": true, + "autocommit": false, + "writeConcern": { + "$$exists": false + } + }, + "commandName": "insert", + "databaseName": "transaction-tests" + } + }, + { + "commandStartedEvent": { + "command": { + "commitTransaction": 1, + "lsid": { + "$$sessionLsid": "session0" + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": { + "$$exists": false + }, + "autocommit": false, + "writeConcern": { + "$$exists": false + } + }, + "commandName": "commitTransaction", + "databaseName": "admin" + } + } + ] + } + ] + }, + { + "description": "run command fails with explicit secondary read preference", + "operations": [ + { + "object": "session0", + "name": "startTransaction" + }, + { + "object": "database0", + "name": "runCommand", + "arguments": { + "session": "session0", + "command": { + "find": "test" + }, + "readPreference": { + "mode": "secondary" + }, + "commandName": "find" + }, + "expectError": { + "errorContains": "read preference in a transaction must be primary" + } + } + ] + }, + { + "description": "run command fails with secondary read preference from transaction options", + "operations": [ + { + "object": "session0", + "name": "startTransaction", + "arguments": { + "readPreference": { + "mode": "secondary" + } + } + }, + { + "object": "database0", + "name": "runCommand", + "arguments": { + "session": "session0", + "command": { + "find": "test" + }, + "commandName": "find" + }, + "expectError": { + "errorContains": "read preference in a transaction must be primary" + } + } + ] + } + ] +} diff --git a/source/transactions/tests/unified/run-command.yml b/source/transactions/tests/unified/run-command.yml new file mode 100644 index 0000000000..b9e1033d4c --- /dev/null +++ b/source/transactions/tests/unified/run-command.yml @@ -0,0 +1,254 @@ +description: run-command + +schemaVersion: '1.9' + +runOnRequirements: + - + minServerVersion: '4.0' + topologies: + - replicaset + - + minServerVersion: 4.1.8 + topologies: + - sharded + - load-balanced + +createEntities: + - + client: + id: &client0 client0 + useMultipleMongoses: false + observeEvents: + - commandStartedEvent + - + database: + id: &database0 database0 + client: *client0 + databaseName: &database_name transaction-tests + - + collection: + id: &collection0 collection0 + database: *database0 + collectionName: &collection_name test + - + session: + id: &session0 session0 + client: *client0 + +initialData: + - + collectionName: *collection_name + databaseName: *database_name + documents: [] + +tests: + - + description: 'run command with default read preference' + operations: + - + object: *session0 + name: startTransaction + - + object: *database0 + name: runCommand + arguments: + session: *session0 + command: + insert: *collection_name + documents: + - { _id: 1 } + commandName: insert + expectResult: + 'n': 1 + - + object: *session0 + name: commitTransaction + expectEvents: + - + client: *client0 + events: + - + commandStartedEvent: + command: + insert: *collection_name + documents: + - { _id: 1 } + readConcern: { $$exists: false } + lsid: { $$sessionLsid: *session0 } + txnNumber: { $numberLong: '1' } + startTransaction: true + autocommit: false + writeConcern: { $$exists: false } + commandName: insert + databaseName: *database_name + - + commandStartedEvent: + command: + commitTransaction: 1 + lsid: { $$sessionLsid: *session0 } + txnNumber: { $numberLong: '1' } + startTransaction: { $$exists: false } + autocommit: false + writeConcern: { $$exists: false } + commandName: commitTransaction + databaseName: admin + - + description: 'run command with secondary read preference in client option and primary read preference in transaction options' + operations: + - + object: testRunner + name: createEntities + arguments: + entities: + - client: + id: &client1 client1 + useMultipleMongoses: false + uriOptions: { readPreference: secondary } + observeEvents: + - commandStartedEvent + - database: + id: &database1 database1 + client: *client1 + databaseName: *database_name + - session: + id: &session1 session1 + client: *client1 + - + object: *session1 + name: startTransaction + arguments: + readPreference: + mode: primary + - + object: *database1 + name: runCommand + arguments: + session: *session1 + command: + insert: *collection_name + documents: + - { _id: 1 } + commandName: insert + expectResult: + 'n': 1 + - + object: *session1 + name: commitTransaction + expectEvents: + - + client: *client1 + events: + - + commandStartedEvent: + command: + insert: *collection_name + documents: + - { _id: 1 } + readConcern: { $$exists: false } + lsid: { $$sessionLsid: *session1 } + txnNumber: { $numberLong: '1' } + startTransaction: true + autocommit: false + writeConcern: { $$exists: false } + commandName: insert + databaseName: *database_name + - + commandStartedEvent: + command: + commitTransaction: 1 + lsid: { $$sessionLsid: *session1 } + txnNumber: { $numberLong: '1' } + startTransaction: { $$exists: false } + autocommit: false + writeConcern: { $$exists: false } + commandName: commitTransaction + databaseName: admin + - + description: 'run command with explicit primary read preference' + operations: + - + object: *session0 + name: startTransaction + - + object: *database0 + name: runCommand + arguments: + session: *session0 + command: + insert: *collection_name + documents: + - { _id: 1 } + readPreference: + mode: primary + commandName: insert + expectResult: + 'n': 1 + - + object: *session0 + name: commitTransaction + expectEvents: + - + client: *client0 + events: + - + commandStartedEvent: + command: + insert: *collection_name + documents: + - { _id: 1 } + readConcern: { $$exists: false } + lsid: { $$sessionLsid: *session0 } + txnNumber: { $numberLong: '1' } + startTransaction: true + autocommit: false + writeConcern: { $$exists: false } + commandName: insert + databaseName: *database_name + - + commandStartedEvent: + command: + commitTransaction: 1 + lsid: { $$sessionLsid: *session0 } + txnNumber: { $numberLong: '1' } + startTransaction: { $$exists: false } + autocommit: false + writeConcern: { $$exists: false } + commandName: commitTransaction + databaseName: admin + - + description: 'run command fails with explicit secondary read preference' + operations: + - + object: *session0 + name: startTransaction + - + object: *database0 + name: runCommand + arguments: + session: *session0 + command: + find: *collection_name + readPreference: + mode: secondary + commandName: find + expectError: + errorContains: 'read preference in a transaction must be primary' + - + description: 'run command fails with secondary read preference from transaction options' + operations: + - + object: *session0 + name: startTransaction + arguments: + readPreference: + mode: secondary + - + object: *database0 + name: runCommand + arguments: + session: *session0 + command: + find: *collection_name + commandName: find + expectError: + errorContains: 'read preference in a transaction must be primary' diff --git a/source/transactions/tests/unified/transaction-options-repl.json b/source/transactions/tests/unified/transaction-options-repl.json new file mode 100644 index 0000000000..dc2cb77582 --- /dev/null +++ b/source/transactions/tests/unified/transaction-options-repl.json @@ -0,0 +1,267 @@ +{ + "description": "transaction-options-repl", + "schemaVersion": "1.9", + "runOnRequirements": [ + { + "minServerVersion": "4.0", + "topologies": [ + "replicaset" + ] + } + ], + "createEntities": [ + { + "client": { + "id": "client0", + "useMultipleMongoses": false, + "observeEvents": [ + "commandStartedEvent" + ] + } + }, + { + "database": { + "id": "database0", + "client": "client0", + "databaseName": "transaction-tests" + } + }, + { + "collection": { + "id": "collection0", + "database": "database0", + "collectionName": "test" + } + }, + { + "session": { + "id": "session0", + "client": "client0" + } + } + ], + "initialData": [ + { + "collectionName": "test", + "databaseName": "transaction-tests", + "documents": [] + } + ], + "tests": [ + { + "description": "readConcern snapshot in startTransaction options", + "operations": [ + { + "object": "testRunner", + "name": "createEntities", + "arguments": { + "entities": [ + { + "session": { + "id": "session1", + "client": "client0", + "sessionOptions": { + "defaultTransactionOptions": { + "readConcern": { + "level": "majority" + } + } + } + } + } + ] + } + }, + { + "object": "session1", + "name": "startTransaction", + "arguments": { + "readConcern": { + "level": "snapshot" + } + } + }, + { + "object": "collection0", + "name": "insertOne", + "arguments": { + "session": "session1", + "document": { + "_id": 1 + } + }, + "expectResult": { + "$$unsetOrMatches": { + "insertedId": { + "$$unsetOrMatches": 1 + } + } + } + }, + { + "object": "session1", + "name": "commitTransaction" + }, + { + "object": "session1", + "name": "startTransaction", + "arguments": { + "readConcern": { + "level": "snapshot" + } + } + }, + { + "object": "collection0", + "name": "insertOne", + "arguments": { + "session": "session1", + "document": { + "_id": 2 + } + }, + "expectResult": { + "$$unsetOrMatches": { + "insertedId": { + "$$unsetOrMatches": 2 + } + } + } + }, + { + "object": "session1", + "name": "abortTransaction" + } + ], + "expectEvents": [ + { + "client": "client0", + "events": [ + { + "commandStartedEvent": { + "command": { + "insert": "test", + "documents": [ + { + "_id": 1 + } + ], + "ordered": true, + "lsid": { + "$$sessionLsid": "session1" + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": true, + "autocommit": false, + "readConcern": { + "level": "snapshot" + }, + "writeConcern": { + "$$exists": false + } + }, + "commandName": "insert", + "databaseName": "transaction-tests" + } + }, + { + "commandStartedEvent": { + "command": { + "commitTransaction": 1, + "lsid": { + "$$sessionLsid": "session1" + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": { + "$$exists": false + }, + "autocommit": false, + "readConcern": { + "$$exists": false + }, + "writeConcern": { + "$$exists": false + } + }, + "commandName": "commitTransaction", + "databaseName": "admin" + } + }, + { + "commandStartedEvent": { + "command": { + "insert": "test", + "documents": [ + { + "_id": 2 + } + ], + "ordered": true, + "lsid": { + "$$sessionLsid": "session1" + }, + "txnNumber": { + "$numberLong": "2" + }, + "startTransaction": true, + "autocommit": false, + "readConcern": { + "level": "snapshot", + "afterClusterTime": { + "$$exists": true + } + }, + "writeConcern": { + "$$exists": false + } + }, + "commandName": "insert", + "databaseName": "transaction-tests" + } + }, + { + "commandStartedEvent": { + "command": { + "abortTransaction": 1, + "lsid": { + "$$sessionLsid": "session1" + }, + "txnNumber": { + "$numberLong": "2" + }, + "startTransaction": { + "$$exists": false + }, + "autocommit": false, + "readConcern": { + "$$exists": false + }, + "writeConcern": { + "$$exists": false + } + }, + "commandName": "abortTransaction", + "databaseName": "admin" + } + } + ] + } + ], + "outcome": [ + { + "collectionName": "test", + "databaseName": "transaction-tests", + "documents": [ + { + "_id": 1 + } + ] + } + ] + } + ] +} diff --git a/source/transactions/tests/unified/transaction-options-repl.yml b/source/transactions/tests/unified/transaction-options-repl.yml new file mode 100644 index 0000000000..f801c13dd8 --- /dev/null +++ b/source/transactions/tests/unified/transaction-options-repl.yml @@ -0,0 +1,155 @@ +description: transaction-options-repl + +schemaVersion: '1.9' + +runOnRequirements: + - + minServerVersion: '4.0' + topologies: + - replicaset + +createEntities: + - + client: + id: &client0 client0 + useMultipleMongoses: false + observeEvents: + - commandStartedEvent + - + database: + id: &database0 database0 + client: *client0 + databaseName: &database_name transaction-tests + - + collection: + id: &collection0 collection0 + database: *database0 + collectionName: &collection_name test + - + session: + id: &session0 session0 + client: *client0 + +initialData: + - + collectionName: *collection_name + databaseName: *database_name + documents: [] + +tests: + - + description: 'readConcern snapshot in startTransaction options' + operations: + - + object: testRunner + name: createEntities + arguments: + entities: + - session: + id: &session1 session1 + client: *client0 + sessionOptions: + defaultTransactionOptions: + readConcern: { level: majority } + - + object: *session1 + name: startTransaction + arguments: + readConcern: + level: snapshot + - + object: *collection0 + name: insertOne + arguments: + session: *session1 + document: { _id: 1 } + expectResult: + $$unsetOrMatches: { insertedId: { $$unsetOrMatches: 1 } } + - + object: *session1 + name: commitTransaction + # Now test abort + - + object: *session1 + name: startTransaction + arguments: + readConcern: + level: snapshot + - + object: *collection0 + name: insertOne + arguments: + session: *session1 + document: { _id: 2 } + expectResult: + $$unsetOrMatches: { insertedId: { $$unsetOrMatches: 2 } } + - + object: *session1 + name: abortTransaction + expectEvents: + - + client: *client0 + events: + - + commandStartedEvent: + command: + insert: *collection_name + documents: + - { _id: 1 } + ordered: true + lsid: { $$sessionLsid: *session1 } + txnNumber: { $numberLong: '1' } + startTransaction: true + autocommit: false + readConcern: + level: snapshot + writeConcern: { $$exists: false } + commandName: insert + databaseName: *database_name + - + commandStartedEvent: + command: + commitTransaction: 1 + lsid: { $$sessionLsid: *session1 } + txnNumber: { $numberLong: '1' } + startTransaction: { $$exists: false } + autocommit: false + readConcern: { $$exists: false } + writeConcern: { $$exists: false } + commandName: commitTransaction + databaseName: admin + - + commandStartedEvent: + command: + insert: *collection_name + documents: + - { _id: 2 } + ordered: true + lsid: { $$sessionLsid: *session1 } + txnNumber: { $numberLong: '2' } + startTransaction: true + autocommit: false + readConcern: + level: snapshot + afterClusterTime: { $$exists: true } + writeConcern: { $$exists: false } + commandName: insert + databaseName: *database_name + - + commandStartedEvent: + command: + abortTransaction: 1 + lsid: { $$sessionLsid: *session1 } + txnNumber: { $numberLong: '2' } + startTransaction: { $$exists: false } + autocommit: false + readConcern: { $$exists: false } + writeConcern: { $$exists: false } + commandName: abortTransaction + databaseName: admin + outcome: + - + collectionName: *collection_name + databaseName: *database_name + documents: + - { _id: 1 } diff --git a/source/transactions/tests/unified/transaction-options.json b/source/transactions/tests/unified/transaction-options.json new file mode 100644 index 0000000000..78e4c8207b --- /dev/null +++ b/source/transactions/tests/unified/transaction-options.json @@ -0,0 +1,2081 @@ +{ + "description": "transaction-options", + "schemaVersion": "1.9", + "runOnRequirements": [ + { + "minServerVersion": "4.0", + "topologies": [ + "replicaset" + ] + }, + { + "minServerVersion": "4.1.8", + "topologies": [ + "sharded", + "load-balanced" + ] + } + ], + "createEntities": [ + { + "client": { + "id": "client0", + "useMultipleMongoses": false, + "observeEvents": [ + "commandStartedEvent" + ] + } + }, + { + "database": { + "id": "database0", + "client": "client0", + "databaseName": "transaction-tests" + } + }, + { + "collection": { + "id": "collection0", + "database": "database0", + "collectionName": "test" + } + }, + { + "session": { + "id": "session0", + "client": "client0" + } + } + ], + "initialData": [ + { + "collectionName": "test", + "databaseName": "transaction-tests", + "documents": [] + } + ], + "tests": [ + { + "description": "no transaction options set", + "operations": [ + { + "object": "session0", + "name": "startTransaction" + }, + { + "object": "collection0", + "name": "insertOne", + "arguments": { + "session": "session0", + "document": { + "_id": 1 + } + }, + "expectResult": { + "$$unsetOrMatches": { + "insertedId": { + "$$unsetOrMatches": 1 + } + } + } + }, + { + "object": "session0", + "name": "commitTransaction" + }, + { + "object": "session0", + "name": "startTransaction" + }, + { + "object": "collection0", + "name": "insertOne", + "arguments": { + "session": "session0", + "document": { + "_id": 2 + } + }, + "expectResult": { + "$$unsetOrMatches": { + "insertedId": { + "$$unsetOrMatches": 2 + } + } + } + }, + { + "object": "session0", + "name": "abortTransaction" + } + ], + "expectEvents": [ + { + "client": "client0", + "events": [ + { + "commandStartedEvent": { + "command": { + "insert": "test", + "documents": [ + { + "_id": 1 + } + ], + "ordered": true, + "lsid": { + "$$sessionLsid": "session0" + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": true, + "autocommit": false, + "readConcern": { + "$$exists": false + }, + "writeConcern": { + "$$exists": false + }, + "maxTimeMS": { + "$$exists": false + } + }, + "commandName": "insert", + "databaseName": "transaction-tests" + } + }, + { + "commandStartedEvent": { + "command": { + "commitTransaction": 1, + "lsid": { + "$$sessionLsid": "session0" + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": { + "$$exists": false + }, + "autocommit": false, + "readConcern": { + "$$exists": false + }, + "writeConcern": { + "$$exists": false + }, + "maxTimeMS": { + "$$exists": false + } + }, + "commandName": "commitTransaction", + "databaseName": "admin" + } + }, + { + "commandStartedEvent": { + "command": { + "insert": "test", + "documents": [ + { + "_id": 2 + } + ], + "ordered": true, + "lsid": { + "$$sessionLsid": "session0" + }, + "txnNumber": { + "$numberLong": "2" + }, + "startTransaction": true, + "autocommit": false, + "readConcern": { + "afterClusterTime": { + "$$exists": true + } + }, + "writeConcern": { + "$$exists": false + }, + "maxTimeMS": { + "$$exists": false + } + }, + "commandName": "insert", + "databaseName": "transaction-tests" + } + }, + { + "commandStartedEvent": { + "command": { + "abortTransaction": 1, + "lsid": { + "$$sessionLsid": "session0" + }, + "txnNumber": { + "$numberLong": "2" + }, + "startTransaction": { + "$$exists": false + }, + "autocommit": false, + "readConcern": { + "$$exists": false + }, + "writeConcern": { + "$$exists": false + }, + "maxTimeMS": { + "$$exists": false + } + }, + "commandName": "abortTransaction", + "databaseName": "admin" + } + } + ] + } + ], + "outcome": [ + { + "collectionName": "test", + "databaseName": "transaction-tests", + "documents": [ + { + "_id": 1 + } + ] + } + ] + }, + { + "description": "transaction options inherited from client", + "operations": [ + { + "object": "testRunner", + "name": "createEntities", + "arguments": { + "entities": [ + { + "client": { + "id": "client1", + "useMultipleMongoses": false, + "uriOptions": { + "readConcernLevel": "local", + "w": 1 + }, + "observeEvents": [ + "commandStartedEvent" + ] + } + }, + { + "database": { + "id": "database1", + "client": "client1", + "databaseName": "transaction-tests" + } + }, + { + "collection": { + "id": "collection1", + "database": "database1", + "collectionName": "test" + } + }, + { + "session": { + "id": "session1", + "client": "client1" + } + } + ] + } + }, + { + "object": "session1", + "name": "startTransaction" + }, + { + "object": "collection1", + "name": "insertOne", + "arguments": { + "session": "session1", + "document": { + "_id": 1 + } + }, + "expectResult": { + "$$unsetOrMatches": { + "insertedId": { + "$$unsetOrMatches": 1 + } + } + } + }, + { + "object": "session1", + "name": "commitTransaction" + }, + { + "object": "session1", + "name": "startTransaction" + }, + { + "object": "collection1", + "name": "insertOne", + "arguments": { + "session": "session1", + "document": { + "_id": 2 + } + }, + "expectResult": { + "$$unsetOrMatches": { + "insertedId": { + "$$unsetOrMatches": 2 + } + } + } + }, + { + "object": "session1", + "name": "abortTransaction" + } + ], + "expectEvents": [ + { + "client": "client1", + "events": [ + { + "commandStartedEvent": { + "command": { + "insert": "test", + "documents": [ + { + "_id": 1 + } + ], + "ordered": true, + "lsid": { + "$$sessionLsid": "session1" + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": true, + "autocommit": false, + "readConcern": { + "level": "local" + }, + "writeConcern": { + "$$exists": false + }, + "maxTimeMS": { + "$$exists": false + } + }, + "commandName": "insert", + "databaseName": "transaction-tests" + } + }, + { + "commandStartedEvent": { + "command": { + "commitTransaction": 1, + "lsid": { + "$$sessionLsid": "session1" + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": { + "$$exists": false + }, + "autocommit": false, + "readConcern": { + "$$exists": false + }, + "writeConcern": { + "w": 1 + }, + "maxTimeMS": { + "$$exists": false + } + }, + "commandName": "commitTransaction", + "databaseName": "admin" + } + }, + { + "commandStartedEvent": { + "command": { + "insert": "test", + "documents": [ + { + "_id": 2 + } + ], + "ordered": true, + "lsid": { + "$$sessionLsid": "session1" + }, + "txnNumber": { + "$numberLong": "2" + }, + "startTransaction": true, + "autocommit": false, + "readConcern": { + "level": "local", + "afterClusterTime": { + "$$exists": true + } + }, + "writeConcern": { + "$$exists": false + }, + "maxTimeMS": { + "$$exists": false + } + }, + "commandName": "insert", + "databaseName": "transaction-tests" + } + }, + { + "commandStartedEvent": { + "command": { + "abortTransaction": 1, + "lsid": { + "$$sessionLsid": "session1" + }, + "txnNumber": { + "$numberLong": "2" + }, + "startTransaction": { + "$$exists": false + }, + "autocommit": false, + "readConcern": { + "$$exists": false + }, + "writeConcern": { + "w": 1 + }, + "maxTimeMS": { + "$$exists": false + } + }, + "commandName": "abortTransaction", + "databaseName": "admin" + } + } + ] + } + ], + "outcome": [ + { + "collectionName": "test", + "databaseName": "transaction-tests", + "documents": [ + { + "_id": 1 + } + ] + } + ] + }, + { + "description": "transaction options inherited from defaultTransactionOptions", + "operations": [ + { + "object": "testRunner", + "name": "createEntities", + "arguments": { + "entities": [ + { + "session": { + "id": "session1", + "client": "client0", + "sessionOptions": { + "defaultTransactionOptions": { + "readConcern": { + "level": "majority" + }, + "writeConcern": { + "w": 1 + }, + "maxCommitTimeMS": 60000 + } + } + } + } + ] + } + }, + { + "object": "session1", + "name": "startTransaction" + }, + { + "object": "collection0", + "name": "insertOne", + "arguments": { + "session": "session1", + "document": { + "_id": 1 + } + }, + "expectResult": { + "$$unsetOrMatches": { + "insertedId": { + "$$unsetOrMatches": 1 + } + } + } + }, + { + "object": "session1", + "name": "commitTransaction" + }, + { + "object": "session1", + "name": "startTransaction" + }, + { + "object": "collection0", + "name": "insertOne", + "arguments": { + "session": "session1", + "document": { + "_id": 2 + } + }, + "expectResult": { + "$$unsetOrMatches": { + "insertedId": { + "$$unsetOrMatches": 2 + } + } + } + }, + { + "object": "session1", + "name": "abortTransaction" + } + ], + "expectEvents": [ + { + "client": "client0", + "events": [ + { + "commandStartedEvent": { + "command": { + "insert": "test", + "documents": [ + { + "_id": 1 + } + ], + "ordered": true, + "lsid": { + "$$sessionLsid": "session1" + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": true, + "autocommit": false, + "readConcern": { + "level": "majority" + }, + "writeConcern": { + "$$exists": false + } + }, + "commandName": "insert", + "databaseName": "transaction-tests" + } + }, + { + "commandStartedEvent": { + "command": { + "commitTransaction": 1, + "lsid": { + "$$sessionLsid": "session1" + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": { + "$$exists": false + }, + "autocommit": false, + "readConcern": { + "$$exists": false + }, + "writeConcern": { + "w": 1 + }, + "maxTimeMS": 60000 + }, + "commandName": "commitTransaction", + "databaseName": "admin" + } + }, + { + "commandStartedEvent": { + "command": { + "insert": "test", + "documents": [ + { + "_id": 2 + } + ], + "ordered": true, + "lsid": { + "$$sessionLsid": "session1" + }, + "txnNumber": { + "$numberLong": "2" + }, + "startTransaction": true, + "autocommit": false, + "readConcern": { + "level": "majority", + "afterClusterTime": { + "$$exists": true + } + }, + "writeConcern": { + "$$exists": false + } + }, + "commandName": "insert", + "databaseName": "transaction-tests" + } + }, + { + "commandStartedEvent": { + "command": { + "abortTransaction": 1, + "lsid": { + "$$sessionLsid": "session1" + }, + "txnNumber": { + "$numberLong": "2" + }, + "startTransaction": { + "$$exists": false + }, + "autocommit": false, + "readConcern": { + "$$exists": false + }, + "writeConcern": { + "w": 1 + } + }, + "commandName": "abortTransaction", + "databaseName": "admin" + } + } + ] + } + ], + "outcome": [ + { + "collectionName": "test", + "databaseName": "transaction-tests", + "documents": [ + { + "_id": 1 + } + ] + } + ] + }, + { + "description": "startTransaction options override defaults", + "operations": [ + { + "object": "testRunner", + "name": "createEntities", + "arguments": { + "entities": [ + { + "client": { + "id": "client1", + "useMultipleMongoses": false, + "uriOptions": { + "readConcernLevel": "local", + "w": 1 + }, + "observeEvents": [ + "commandStartedEvent" + ] + } + }, + { + "database": { + "id": "database1", + "client": "client1", + "databaseName": "transaction-tests" + } + }, + { + "collection": { + "id": "collection1", + "database": "database1", + "collectionName": "test" + } + }, + { + "session": { + "id": "session1", + "client": "client1", + "sessionOptions": { + "defaultTransactionOptions": { + "readConcern": { + "level": "snapshot" + }, + "writeConcern": { + "w": 1 + }, + "maxCommitTimeMS": 30000 + } + } + } + } + ] + } + }, + { + "object": "session1", + "name": "startTransaction", + "arguments": { + "readConcern": { + "level": "majority" + }, + "writeConcern": { + "w": "majority" + }, + "maxCommitTimeMS": 60000 + } + }, + { + "object": "collection1", + "name": "insertOne", + "arguments": { + "session": "session1", + "document": { + "_id": 1 + } + }, + "expectResult": { + "$$unsetOrMatches": { + "insertedId": { + "$$unsetOrMatches": 1 + } + } + } + }, + { + "object": "session1", + "name": "commitTransaction" + }, + { + "object": "session1", + "name": "startTransaction", + "arguments": { + "readConcern": { + "level": "majority" + }, + "writeConcern": { + "w": "majority" + } + } + }, + { + "object": "collection1", + "name": "insertOne", + "arguments": { + "session": "session1", + "document": { + "_id": 2 + } + }, + "expectResult": { + "$$unsetOrMatches": { + "insertedId": { + "$$unsetOrMatches": 2 + } + } + } + }, + { + "object": "session1", + "name": "abortTransaction" + } + ], + "expectEvents": [ + { + "client": "client1", + "events": [ + { + "commandStartedEvent": { + "command": { + "insert": "test", + "documents": [ + { + "_id": 1 + } + ], + "ordered": true, + "lsid": { + "$$sessionLsid": "session1" + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": true, + "autocommit": false, + "readConcern": { + "level": "majority" + }, + "writeConcern": { + "$$exists": false + }, + "maxTimeMS": { + "$$exists": false + } + }, + "commandName": "insert", + "databaseName": "transaction-tests" + } + }, + { + "commandStartedEvent": { + "command": { + "commitTransaction": 1, + "lsid": { + "$$sessionLsid": "session1" + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": { + "$$exists": false + }, + "autocommit": false, + "readConcern": { + "$$exists": false + }, + "writeConcern": { + "w": "majority" + }, + "maxTimeMS": 60000 + }, + "commandName": "commitTransaction", + "databaseName": "admin" + } + }, + { + "commandStartedEvent": { + "command": { + "insert": "test", + "documents": [ + { + "_id": 2 + } + ], + "ordered": true, + "lsid": { + "$$sessionLsid": "session1" + }, + "txnNumber": { + "$numberLong": "2" + }, + "startTransaction": true, + "autocommit": false, + "readConcern": { + "level": "majority", + "afterClusterTime": { + "$$exists": true + } + }, + "writeConcern": { + "$$exists": false + }, + "maxTimeMS": { + "$$exists": false + } + }, + "commandName": "insert", + "databaseName": "transaction-tests" + } + }, + { + "commandStartedEvent": { + "command": { + "abortTransaction": 1, + "lsid": { + "$$sessionLsid": "session1" + }, + "txnNumber": { + "$numberLong": "2" + }, + "startTransaction": { + "$$exists": false + }, + "autocommit": false, + "readConcern": { + "$$exists": false + }, + "writeConcern": { + "w": "majority" + }, + "maxTimeMS": { + "$$exists": false + } + }, + "commandName": "abortTransaction", + "databaseName": "admin" + } + } + ] + } + ], + "outcome": [ + { + "collectionName": "test", + "databaseName": "transaction-tests", + "documents": [ + { + "_id": 1 + } + ] + } + ] + }, + { + "description": "defaultTransactionOptions override client options", + "operations": [ + { + "object": "testRunner", + "name": "createEntities", + "arguments": { + "entities": [ + { + "client": { + "id": "client1", + "useMultipleMongoses": false, + "uriOptions": { + "readConcernLevel": "local", + "w": 1 + }, + "observeEvents": [ + "commandStartedEvent" + ] + } + }, + { + "database": { + "id": "database1", + "client": "client1", + "databaseName": "transaction-tests" + } + }, + { + "collection": { + "id": "collection1", + "database": "database1", + "collectionName": "test" + } + }, + { + "session": { + "id": "session1", + "client": "client1", + "sessionOptions": { + "defaultTransactionOptions": { + "readConcern": { + "level": "majority" + }, + "writeConcern": { + "w": "majority" + }, + "maxCommitTimeMS": 60000 + } + } + } + } + ] + } + }, + { + "object": "session1", + "name": "startTransaction" + }, + { + "object": "collection1", + "name": "insertOne", + "arguments": { + "session": "session1", + "document": { + "_id": 1 + } + }, + "expectResult": { + "$$unsetOrMatches": { + "insertedId": { + "$$unsetOrMatches": 1 + } + } + } + }, + { + "object": "session1", + "name": "commitTransaction" + }, + { + "object": "session1", + "name": "startTransaction" + }, + { + "object": "collection1", + "name": "insertOne", + "arguments": { + "session": "session1", + "document": { + "_id": 2 + } + }, + "expectResult": { + "$$unsetOrMatches": { + "insertedId": { + "$$unsetOrMatches": 2 + } + } + } + }, + { + "object": "session1", + "name": "abortTransaction" + } + ], + "expectEvents": [ + { + "client": "client1", + "events": [ + { + "commandStartedEvent": { + "command": { + "insert": "test", + "documents": [ + { + "_id": 1 + } + ], + "ordered": true, + "lsid": { + "$$sessionLsid": "session1" + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": true, + "autocommit": false, + "readConcern": { + "level": "majority" + }, + "writeConcern": { + "$$exists": false + }, + "maxTimeMS": { + "$$exists": false + } + }, + "commandName": "insert", + "databaseName": "transaction-tests" + } + }, + { + "commandStartedEvent": { + "command": { + "commitTransaction": 1, + "lsid": { + "$$sessionLsid": "session1" + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": { + "$$exists": false + }, + "autocommit": false, + "readConcern": { + "$$exists": false + }, + "writeConcern": { + "w": "majority" + }, + "maxTimeMS": 60000 + }, + "commandName": "commitTransaction", + "databaseName": "admin" + } + }, + { + "commandStartedEvent": { + "command": { + "insert": "test", + "documents": [ + { + "_id": 2 + } + ], + "ordered": true, + "lsid": { + "$$sessionLsid": "session1" + }, + "txnNumber": { + "$numberLong": "2" + }, + "startTransaction": true, + "autocommit": false, + "readConcern": { + "level": "majority", + "afterClusterTime": { + "$$exists": true + } + }, + "writeConcern": { + "$$exists": false + }, + "maxTimeMS": { + "$$exists": false + } + }, + "commandName": "insert", + "databaseName": "transaction-tests" + } + }, + { + "commandStartedEvent": { + "command": { + "abortTransaction": 1, + "lsid": { + "$$sessionLsid": "session1" + }, + "txnNumber": { + "$numberLong": "2" + }, + "startTransaction": { + "$$exists": false + }, + "autocommit": false, + "readConcern": { + "$$exists": false + }, + "writeConcern": { + "w": "majority" + }, + "maxTimeMS": { + "$$exists": false + } + }, + "commandName": "abortTransaction", + "databaseName": "admin" + } + } + ] + } + ], + "outcome": [ + { + "collectionName": "test", + "databaseName": "transaction-tests", + "documents": [ + { + "_id": 1 + } + ] + } + ] + }, + { + "description": "readConcern local in defaultTransactionOptions", + "operations": [ + { + "object": "testRunner", + "name": "createEntities", + "arguments": { + "entities": [ + { + "client": { + "id": "client1", + "useMultipleMongoses": false, + "uriOptions": { + "w": 1 + }, + "observeEvents": [ + "commandStartedEvent" + ] + } + }, + { + "database": { + "id": "database1", + "client": "client1", + "databaseName": "transaction-tests" + } + }, + { + "collection": { + "id": "collection1", + "database": "database1", + "collectionName": "test" + } + }, + { + "session": { + "id": "session1", + "client": "client1", + "sessionOptions": { + "defaultTransactionOptions": { + "readConcern": { + "level": "local" + } + } + } + } + } + ] + } + }, + { + "object": "session1", + "name": "startTransaction" + }, + { + "object": "collection1", + "name": "insertOne", + "arguments": { + "session": "session1", + "document": { + "_id": 1 + } + }, + "expectResult": { + "$$unsetOrMatches": { + "insertedId": { + "$$unsetOrMatches": 1 + } + } + } + }, + { + "object": "session1", + "name": "commitTransaction" + }, + { + "object": "session1", + "name": "startTransaction" + }, + { + "object": "collection1", + "name": "insertOne", + "arguments": { + "session": "session1", + "document": { + "_id": 2 + } + }, + "expectResult": { + "$$unsetOrMatches": { + "insertedId": { + "$$unsetOrMatches": 2 + } + } + } + }, + { + "object": "session1", + "name": "abortTransaction" + } + ], + "expectEvents": [ + { + "client": "client1", + "events": [ + { + "commandStartedEvent": { + "command": { + "insert": "test", + "documents": [ + { + "_id": 1 + } + ], + "ordered": true, + "lsid": { + "$$sessionLsid": "session1" + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": true, + "autocommit": false, + "readConcern": { + "level": "local" + }, + "writeConcern": { + "$$exists": false + } + }, + "commandName": "insert", + "databaseName": "transaction-tests" + } + }, + { + "commandStartedEvent": { + "command": { + "commitTransaction": 1, + "lsid": { + "$$sessionLsid": "session1" + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": { + "$$exists": false + }, + "autocommit": false, + "readConcern": { + "$$exists": false + }, + "writeConcern": { + "w": 1 + } + }, + "commandName": "commitTransaction", + "databaseName": "admin" + } + }, + { + "commandStartedEvent": { + "command": { + "insert": "test", + "documents": [ + { + "_id": 2 + } + ], + "ordered": true, + "lsid": { + "$$sessionLsid": "session1" + }, + "txnNumber": { + "$numberLong": "2" + }, + "startTransaction": true, + "autocommit": false, + "readConcern": { + "level": "local", + "afterClusterTime": { + "$$exists": true + } + }, + "writeConcern": { + "$$exists": false + } + }, + "commandName": "insert", + "databaseName": "transaction-tests" + } + }, + { + "commandStartedEvent": { + "command": { + "abortTransaction": 1, + "lsid": { + "$$sessionLsid": "session1" + }, + "txnNumber": { + "$numberLong": "2" + }, + "startTransaction": { + "$$exists": false + }, + "autocommit": false, + "readConcern": { + "$$exists": false + }, + "writeConcern": { + "w": 1 + } + }, + "commandName": "abortTransaction", + "databaseName": "admin" + } + } + ] + } + ], + "outcome": [ + { + "collectionName": "test", + "databaseName": "transaction-tests", + "documents": [ + { + "_id": 1 + } + ] + } + ] + }, + { + "description": "client writeConcern ignored for bulk", + "operations": [ + { + "object": "testRunner", + "name": "createEntities", + "arguments": { + "entities": [ + { + "client": { + "id": "client1", + "useMultipleMongoses": false, + "uriOptions": { + "w": "majority" + }, + "observeEvents": [ + "commandStartedEvent" + ] + } + }, + { + "database": { + "id": "database1", + "client": "client1", + "databaseName": "transaction-tests" + } + }, + { + "collection": { + "id": "collection1", + "database": "database1", + "collectionName": "test" + } + }, + { + "session": { + "id": "session1", + "client": "client1" + } + } + ] + } + }, + { + "object": "session1", + "name": "startTransaction", + "arguments": { + "writeConcern": { + "w": 1 + } + } + }, + { + "object": "collection1", + "name": "bulkWrite", + "arguments": { + "requests": [ + { + "insertOne": { + "document": { + "_id": 1 + } + } + } + ], + "session": "session1" + }, + "expectResult": { + "deletedCount": 0, + "insertedCount": 1, + "insertedIds": { + "$$unsetOrMatches": { + "0": 1 + } + }, + "matchedCount": 0, + "modifiedCount": 0, + "upsertedCount": 0, + "upsertedIds": {} + } + }, + { + "object": "session1", + "name": "commitTransaction" + } + ], + "expectEvents": [ + { + "client": "client1", + "events": [ + { + "commandStartedEvent": { + "command": { + "insert": "test", + "documents": [ + { + "_id": 1 + } + ], + "ordered": true, + "readConcern": { + "$$exists": false + }, + "lsid": { + "$$sessionLsid": "session1" + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": true, + "autocommit": false, + "writeConcern": { + "$$exists": false + } + }, + "commandName": "insert", + "databaseName": "transaction-tests" + } + }, + { + "commandStartedEvent": { + "command": { + "commitTransaction": 1, + "lsid": { + "$$sessionLsid": "session1" + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": { + "$$exists": false + }, + "autocommit": false, + "writeConcern": { + "w": 1 + } + }, + "commandName": "commitTransaction", + "databaseName": "admin" + } + } + ] + } + ], + "outcome": [ + { + "collectionName": "test", + "databaseName": "transaction-tests", + "documents": [ + { + "_id": 1 + } + ] + } + ] + }, + { + "description": "readPreference inherited from client", + "operations": [ + { + "object": "testRunner", + "name": "createEntities", + "arguments": { + "entities": [ + { + "client": { + "id": "client1", + "useMultipleMongoses": false, + "uriOptions": { + "readPreference": "secondary" + }, + "observeEvents": [ + "commandStartedEvent" + ] + } + }, + { + "database": { + "id": "database1", + "client": "client1", + "databaseName": "transaction-tests" + } + }, + { + "collection": { + "id": "collection1", + "database": "database1", + "collectionName": "test" + } + }, + { + "session": { + "id": "session1", + "client": "client1" + } + } + ] + } + }, + { + "object": "session1", + "name": "startTransaction" + }, + { + "object": "collection1", + "name": "insertOne", + "arguments": { + "session": "session1", + "document": { + "_id": 1 + } + }, + "expectResult": { + "$$unsetOrMatches": { + "insertedId": { + "$$unsetOrMatches": 1 + } + } + } + }, + { + "object": "collection1", + "name": "find", + "arguments": { + "session": "session1", + "filter": { + "_id": 1 + } + }, + "expectError": { + "errorContains": "read preference in a transaction must be primary" + } + }, + { + "object": "session1", + "name": "commitTransaction" + } + ], + "expectEvents": [ + { + "client": "client1", + "events": [ + { + "commandStartedEvent": { + "command": { + "insert": "test", + "documents": [ + { + "_id": 1 + } + ], + "ordered": true, + "lsid": { + "$$sessionLsid": "session1" + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": true, + "autocommit": false, + "readConcern": { + "$$exists": false + }, + "writeConcern": { + "$$exists": false + } + }, + "commandName": "insert", + "databaseName": "transaction-tests" + } + }, + { + "commandStartedEvent": { + "command": { + "commitTransaction": 1, + "lsid": { + "$$sessionLsid": "session1" + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": { + "$$exists": false + }, + "autocommit": false, + "readConcern": { + "$$exists": false + }, + "writeConcern": { + "$$exists": false + } + }, + "commandName": "commitTransaction", + "databaseName": "admin" + } + } + ] + } + ], + "outcome": [ + { + "collectionName": "test", + "databaseName": "transaction-tests", + "documents": [ + { + "_id": 1 + } + ] + } + ] + }, + { + "description": "readPreference inherited from defaultTransactionOptions", + "operations": [ + { + "object": "testRunner", + "name": "createEntities", + "arguments": { + "entities": [ + { + "client": { + "id": "client1", + "useMultipleMongoses": false, + "uriOptions": { + "readPreference": "primary" + }, + "observeEvents": [ + "commandStartedEvent" + ] + } + }, + { + "database": { + "id": "database1", + "client": "client1", + "databaseName": "transaction-tests" + } + }, + { + "collection": { + "id": "collection1", + "database": "database1", + "collectionName": "test" + } + }, + { + "session": { + "id": "session1", + "client": "client1", + "sessionOptions": { + "defaultTransactionOptions": { + "readPreference": { + "mode": "secondary" + } + } + } + } + } + ] + } + }, + { + "object": "session1", + "name": "startTransaction" + }, + { + "object": "collection1", + "name": "insertOne", + "arguments": { + "session": "session1", + "document": { + "_id": 1 + } + }, + "expectResult": { + "$$unsetOrMatches": { + "insertedId": { + "$$unsetOrMatches": 1 + } + } + } + }, + { + "object": "collection1", + "name": "find", + "arguments": { + "session": "session1", + "filter": { + "_id": 1 + } + }, + "expectError": { + "errorContains": "read preference in a transaction must be primary" + } + }, + { + "object": "session1", + "name": "commitTransaction" + } + ], + "expectEvents": [ + { + "client": "client1", + "events": [ + { + "commandStartedEvent": { + "command": { + "insert": "test", + "documents": [ + { + "_id": 1 + } + ], + "ordered": true, + "lsid": { + "$$sessionLsid": "session1" + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": true, + "autocommit": false, + "readConcern": { + "$$exists": false + }, + "writeConcern": { + "$$exists": false + } + }, + "commandName": "insert", + "databaseName": "transaction-tests" + } + }, + { + "commandStartedEvent": { + "command": { + "commitTransaction": 1, + "lsid": { + "$$sessionLsid": "session1" + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": { + "$$exists": false + }, + "autocommit": false, + "readConcern": { + "$$exists": false + }, + "writeConcern": { + "$$exists": false + } + }, + "commandName": "commitTransaction", + "databaseName": "admin" + } + } + ] + } + ], + "outcome": [ + { + "collectionName": "test", + "databaseName": "transaction-tests", + "documents": [ + { + "_id": 1 + } + ] + } + ] + }, + { + "description": "startTransaction overrides readPreference", + "operations": [ + { + "object": "testRunner", + "name": "createEntities", + "arguments": { + "entities": [ + { + "client": { + "id": "client1", + "useMultipleMongoses": false, + "uriOptions": { + "readPreference": "primary" + }, + "observeEvents": [ + "commandStartedEvent" + ] + } + }, + { + "database": { + "id": "database1", + "client": "client1", + "databaseName": "transaction-tests" + } + }, + { + "collection": { + "id": "collection1", + "database": "database1", + "collectionName": "test" + } + }, + { + "session": { + "id": "session1", + "client": "client1", + "sessionOptions": { + "defaultTransactionOptions": { + "readPreference": { + "mode": "primary" + } + } + } + } + } + ] + } + }, + { + "object": "session1", + "name": "startTransaction", + "arguments": { + "readPreference": { + "mode": "secondary" + } + } + }, + { + "object": "collection1", + "name": "insertOne", + "arguments": { + "session": "session1", + "document": { + "_id": 1 + } + }, + "expectResult": { + "$$unsetOrMatches": { + "insertedId": { + "$$unsetOrMatches": 1 + } + } + } + }, + { + "object": "collection1", + "name": "find", + "arguments": { + "session": "session1", + "filter": { + "_id": 1 + } + }, + "expectError": { + "errorContains": "read preference in a transaction must be primary" + } + }, + { + "object": "session1", + "name": "commitTransaction" + } + ], + "expectEvents": [ + { + "client": "client1", + "events": [ + { + "commandStartedEvent": { + "command": { + "insert": "test", + "documents": [ + { + "_id": 1 + } + ], + "ordered": true, + "lsid": { + "$$sessionLsid": "session1" + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": true, + "autocommit": false, + "readConcern": { + "$$exists": false + }, + "writeConcern": { + "$$exists": false + } + }, + "commandName": "insert", + "databaseName": "transaction-tests" + } + }, + { + "commandStartedEvent": { + "command": { + "commitTransaction": 1, + "lsid": { + "$$sessionLsid": "session1" + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": { + "$$exists": false + }, + "autocommit": false, + "readConcern": { + "$$exists": false + }, + "writeConcern": { + "$$exists": false + } + }, + "commandName": "commitTransaction", + "databaseName": "admin" + } + } + ] + } + ], + "outcome": [ + { + "collectionName": "test", + "databaseName": "transaction-tests", + "documents": [ + { + "_id": 1 + } + ] + } + ] + } + ] +} diff --git a/source/transactions/tests/unified/transaction-options.yml b/source/transactions/tests/unified/transaction-options.yml new file mode 100644 index 0000000000..f3ab07cfc4 --- /dev/null +++ b/source/transactions/tests/unified/transaction-options.yml @@ -0,0 +1,1116 @@ +description: transaction-options + +schemaVersion: '1.9' + +runOnRequirements: + - + minServerVersion: '4.0' + topologies: + - replicaset + - + minServerVersion: 4.1.8 + topologies: + - sharded + - load-balanced + +createEntities: + - + client: + id: &client0 client0 + useMultipleMongoses: false + observeEvents: + - commandStartedEvent + - + database: + id: &database0 database0 + client: *client0 + databaseName: &database_name transaction-tests + - + collection: + id: &collection0 collection0 + database: *database0 + collectionName: &collection_name test + - + session: + id: &session0 session0 + client: *client0 + +initialData: + - + collectionName: *collection_name + databaseName: *database_name + documents: [] + +tests: + - + description: 'no transaction options set' + operations: + - + object: *session0 + name: startTransaction + - + object: *collection0 + name: insertOne + arguments: + session: *session0 + document: { _id: 1 } + expectResult: + $$unsetOrMatches: { insertedId: { $$unsetOrMatches: 1 } } + - + object: *session0 + name: commitTransaction + # Now test abort + - + object: *session0 + name: startTransaction + - + object: *collection0 + name: insertOne + arguments: + session: *session0 + document: { _id: 2 } + expectResult: + $$unsetOrMatches: { insertedId: { $$unsetOrMatches: 2 } } + - + object: *session0 + name: abortTransaction + expectEvents: + - + client: *client0 + events: + - + commandStartedEvent: + command: + insert: *collection_name + documents: + - { _id: 1 } + ordered: true + lsid: { $$sessionLsid: *session0 } + txnNumber: { $numberLong: '1' } + startTransaction: true + autocommit: false + readConcern: { $$exists: false } + writeConcern: { $$exists: false } + maxTimeMS: { $$exists: false } + commandName: insert + databaseName: *database_name + - + commandStartedEvent: + command: + commitTransaction: 1 + lsid: { $$sessionLsid: *session0 } + txnNumber: { $numberLong: '1' } + startTransaction: { $$exists: false } + autocommit: false + readConcern: { $$exists: false } + writeConcern: { $$exists: false } + maxTimeMS: { $$exists: false } + commandName: commitTransaction + databaseName: admin + - + commandStartedEvent: + command: + insert: *collection_name + documents: + - { _id: 2 } + ordered: true + lsid: { $$sessionLsid: *session0 } + txnNumber: { $numberLong: '2' } + startTransaction: true + autocommit: false + readConcern: + afterClusterTime: { $$exists: true } + writeConcern: { $$exists: false } + maxTimeMS: { $$exists: false } + commandName: insert + databaseName: *database_name + - + commandStartedEvent: + command: + abortTransaction: 1 + lsid: { $$sessionLsid: *session0 } + txnNumber: { $numberLong: '2' } + startTransaction: { $$exists: false } + autocommit: false + readConcern: { $$exists: false } + writeConcern: { $$exists: false } + maxTimeMS: { $$exists: false } + commandName: abortTransaction + databaseName: admin + outcome: &outcome + - + collectionName: *collection_name + databaseName: *database_name + documents: + - { _id: 1 } + - + description: 'transaction options inherited from client' + operations: + - + object: testRunner + name: createEntities + arguments: + entities: + - client: + id: &client1 client1 + useMultipleMongoses: false + uriOptions: + readConcernLevel: local + w: 1 + observeEvents: + - commandStartedEvent + - database: + id: &database1 database1 + client: *client1 + databaseName: *database_name + - collection: + id: &collection1 collection1 + database: *database1 + collectionName: *collection_name + - session: + id: &session1 session1 + client: *client1 + - + object: *session1 + name: startTransaction + - + object: *collection1 + name: insertOne + arguments: + session: *session1 + document: { _id: 1 } + expectResult: + $$unsetOrMatches: { insertedId: { $$unsetOrMatches: 1 } } + - + object: *session1 + name: commitTransaction + - + object: *session1 + name: startTransaction + - + object: *collection1 + name: insertOne + arguments: + session: *session1 + document: { _id: 2 } + expectResult: + $$unsetOrMatches: { insertedId: { $$unsetOrMatches: 2 } } + - + object: *session1 + name: abortTransaction + expectEvents: + - + client: *client1 + events: + - + commandStartedEvent: + command: + insert: *collection_name + documents: + - { _id: 1 } + ordered: true + lsid: { $$sessionLsid: *session1 } + txnNumber: { $numberLong: '1' } + startTransaction: true + autocommit: false + readConcern: + level: local + writeConcern: { $$exists: false } + maxTimeMS: { $$exists: false } + commandName: insert + databaseName: *database_name + - + commandStartedEvent: + command: + commitTransaction: 1 + lsid: { $$sessionLsid: *session1 } + txnNumber: { $numberLong: '1' } + startTransaction: { $$exists: false } + autocommit: false + readConcern: { $$exists: false } + writeConcern: + w: 1 + maxTimeMS: { $$exists: false } + commandName: commitTransaction + databaseName: admin + - + commandStartedEvent: + command: + insert: *collection_name + documents: + - { _id: 2 } + ordered: true + lsid: { $$sessionLsid: *session1 } + txnNumber: { $numberLong: '2' } + startTransaction: true + autocommit: false + readConcern: + level: local + afterClusterTime: { $$exists: true } + writeConcern: { $$exists: false } + maxTimeMS: { $$exists: false } + commandName: insert + databaseName: *database_name + - + commandStartedEvent: + command: + abortTransaction: 1 + lsid: { $$sessionLsid: *session1 } + txnNumber: { $numberLong: '2' } + startTransaction: { $$exists: false } + autocommit: false + readConcern: { $$exists: false } + writeConcern: + w: 1 + maxTimeMS: { $$exists: false } + commandName: abortTransaction + databaseName: admin + outcome: *outcome + - + description: 'transaction options inherited from defaultTransactionOptions' + operations: + - + object: testRunner + name: createEntities + arguments: + entities: + - session: + id: &session1 session1 + client: *client0 + sessionOptions: + defaultTransactionOptions: + readConcern: { level: majority } + writeConcern: { w: 1 } + maxCommitTimeMS: 60000 + - + object: *session1 + name: startTransaction + - + object: *collection0 + name: insertOne + arguments: + session: *session1 + document: { _id: 1 } + expectResult: + $$unsetOrMatches: { insertedId: { $$unsetOrMatches: 1 } } + - + object: *session1 + name: commitTransaction + - + object: *session1 + name: startTransaction + - + object: *collection0 + name: insertOne + arguments: + session: *session1 + document: { _id: 2 } + expectResult: + $$unsetOrMatches: { insertedId: { $$unsetOrMatches: 2 } } + - + object: *session1 + name: abortTransaction + expectEvents: + - + client: *client0 + events: + - + commandStartedEvent: + command: + insert: *collection_name + documents: + - { _id: 1 } + ordered: true + lsid: { $$sessionLsid: *session1 } + txnNumber: { $numberLong: '1' } + startTransaction: true + autocommit: false + readConcern: + level: majority + writeConcern: { $$exists: false } + commandName: insert + databaseName: *database_name + - + commandStartedEvent: + command: + commitTransaction: 1 + lsid: { $$sessionLsid: *session1 } + txnNumber: { $numberLong: '1' } + startTransaction: { $$exists: false } + autocommit: false + readConcern: { $$exists: false } + writeConcern: + w: 1 + maxTimeMS: 60000 + commandName: commitTransaction + databaseName: admin + - + commandStartedEvent: + command: + insert: *collection_name + documents: + - { _id: 2 } + ordered: true + lsid: { $$sessionLsid: *session1 } + txnNumber: { $numberLong: '2' } + startTransaction: true + autocommit: false + readConcern: + level: majority + afterClusterTime: { $$exists: true } + writeConcern: { $$exists: false } + commandName: insert + databaseName: *database_name + - + commandStartedEvent: + command: + abortTransaction: 1 + lsid: { $$sessionLsid: *session1 } + txnNumber: { $numberLong: '2' } + startTransaction: { $$exists: false } + autocommit: false + readConcern: { $$exists: false } + writeConcern: + w: 1 + commandName: abortTransaction + databaseName: admin + outcome: *outcome + - + description: 'startTransaction options override defaults' + operations: + - + object: testRunner + name: createEntities + arguments: + entities: + - client: + id: &client1 client1 + useMultipleMongoses: false + uriOptions: + readConcernLevel: local + w: 1 + observeEvents: + - commandStartedEvent + - database: + id: &database1 database1 + client: *client1 + databaseName: *database_name + - collection: + id: &collection1 collection1 + database: *database1 + collectionName: *collection_name + - session: + id: &session1 session1 + client: *client1 + sessionOptions: + defaultTransactionOptions: + readConcern: { level: snapshot } + writeConcern: { w: 1 } + maxCommitTimeMS: 30000 + - + object: *session1 + name: startTransaction + arguments: + readConcern: + level: majority + writeConcern: + w: majority + maxCommitTimeMS: 60000 + - + object: *collection1 + name: insertOne + arguments: + session: *session1 + document: { _id: 1 } + expectResult: + $$unsetOrMatches: { insertedId: { $$unsetOrMatches: 1 } } + - + object: *session1 + name: commitTransaction + - + object: *session1 + name: startTransaction + arguments: + readConcern: + level: majority + writeConcern: + w: majority + - + object: *collection1 + name: insertOne + arguments: + session: *session1 + document: { _id: 2 } + expectResult: + $$unsetOrMatches: { insertedId: { $$unsetOrMatches: 2 } } + - + object: *session1 + name: abortTransaction + expectEvents: + - + client: *client1 + events: + - + commandStartedEvent: + command: + insert: *collection_name + documents: + - { _id: 1 } + ordered: true + lsid: { $$sessionLsid: *session1 } + txnNumber: { $numberLong: '1' } + startTransaction: true + autocommit: false + readConcern: + level: majority + writeConcern: { $$exists: false } + maxTimeMS: { $$exists: false } + commandName: insert + databaseName: *database_name + - + commandStartedEvent: + command: + commitTransaction: 1 + lsid: { $$sessionLsid: *session1 } + txnNumber: { $numberLong: '1' } + startTransaction: { $$exists: false } + autocommit: false + readConcern: { $$exists: false } + writeConcern: + w: majority + maxTimeMS: 60000 + commandName: commitTransaction + databaseName: admin + - + commandStartedEvent: + command: + insert: *collection_name + documents: + - { _id: 2 } + ordered: true + lsid: { $$sessionLsid: *session1 } + txnNumber: { $numberLong: '2' } + startTransaction: true + autocommit: false + readConcern: + level: majority + afterClusterTime: { $$exists: true } + writeConcern: { $$exists: false } + maxTimeMS: { $$exists: false } + commandName: insert + databaseName: *database_name + - + commandStartedEvent: + command: + abortTransaction: 1 + lsid: { $$sessionLsid: *session1 } + txnNumber: { $numberLong: '2' } + startTransaction: { $$exists: false } + autocommit: false + readConcern: { $$exists: false } + writeConcern: + w: majority + maxTimeMS: { $$exists: false } + commandName: abortTransaction + databaseName: admin + outcome: *outcome + - + description: 'defaultTransactionOptions override client options' + operations: + - + object: testRunner + name: createEntities + arguments: + entities: + - client: + id: &client1 client1 + useMultipleMongoses: false + uriOptions: + readConcernLevel: local + w: 1 + observeEvents: + - commandStartedEvent + - database: + id: &database1 database1 + client: *client1 + databaseName: *database_name + - collection: + id: &collection1 collection1 + database: *database1 + collectionName: *collection_name + - session: + id: &session1 session1 + client: *client1 + sessionOptions: + defaultTransactionOptions: + readConcern: { level: majority } + writeConcern: { w: majority } + maxCommitTimeMS: 60000 + - + object: *session1 + name: startTransaction + - + object: *collection1 + name: insertOne + arguments: + session: *session1 + document: { _id: 1 } + expectResult: + $$unsetOrMatches: { insertedId: { $$unsetOrMatches: 1 } } + - + object: *session1 + name: commitTransaction + - + object: *session1 + name: startTransaction + - + object: *collection1 + name: insertOne + arguments: + session: *session1 + document: { _id: 2 } + expectResult: + $$unsetOrMatches: { insertedId: { $$unsetOrMatches: 2 } } + - + object: *session1 + name: abortTransaction + expectEvents: + - + client: *client1 + events: + - + commandStartedEvent: + command: + insert: *collection_name + documents: + - { _id: 1 } + ordered: true + lsid: { $$sessionLsid: *session1 } + txnNumber: { $numberLong: '1' } + startTransaction: true + autocommit: false + readConcern: + level: majority + writeConcern: { $$exists: false } + maxTimeMS: { $$exists: false } + commandName: insert + databaseName: *database_name + - + commandStartedEvent: + command: + commitTransaction: 1 + lsid: { $$sessionLsid: *session1 } + txnNumber: { $numberLong: '1' } + startTransaction: { $$exists: false } + autocommit: false + readConcern: { $$exists: false } + writeConcern: + w: majority + maxTimeMS: 60000 + commandName: commitTransaction + databaseName: admin + - + commandStartedEvent: + command: + insert: *collection_name + documents: + - { _id: 2 } + ordered: true + lsid: { $$sessionLsid: *session1 } + txnNumber: { $numberLong: '2' } + startTransaction: true + autocommit: false + readConcern: + level: majority + afterClusterTime: { $$exists: true } + writeConcern: { $$exists: false } + maxTimeMS: { $$exists: false } + commandName: insert + databaseName: *database_name + - + commandStartedEvent: + command: + abortTransaction: 1 + lsid: { $$sessionLsid: *session1 } + txnNumber: { $numberLong: '2' } + startTransaction: { $$exists: false } + autocommit: false + readConcern: { $$exists: false } + writeConcern: + w: majority + maxTimeMS: { $$exists: false } + commandName: abortTransaction + databaseName: admin + outcome: *outcome + - + description: 'readConcern local in defaultTransactionOptions' + operations: + - + object: testRunner + name: createEntities + arguments: + entities: + - client: + id: &client1 client1 + useMultipleMongoses: false + uriOptions: + w: 1 + observeEvents: + - commandStartedEvent + - database: + id: &database1 database1 + client: *client1 + databaseName: *database_name + - collection: + id: &collection1 collection1 + database: *database1 + collectionName: *collection_name + - session: + id: &session1 session1 + client: *client1 + sessionOptions: + defaultTransactionOptions: + readConcern: { level: local } + - + object: *session1 + name: startTransaction + - + object: *collection1 + name: insertOne + arguments: + session: *session1 + document: { _id: 1 } + expectResult: + $$unsetOrMatches: { insertedId: { $$unsetOrMatches: 1 } } + - + object: *session1 + name: commitTransaction + - + object: *session1 + name: startTransaction + - + object: *collection1 + name: insertOne + arguments: + session: *session1 + document: { _id: 2 } + expectResult: + $$unsetOrMatches: { insertedId: { $$unsetOrMatches: 2 } } + - + object: *session1 + name: abortTransaction + expectEvents: + - + client: *client1 + events: + - + commandStartedEvent: + command: + insert: *collection_name + documents: + - { _id: 1 } + ordered: true + lsid: { $$sessionLsid: *session1 } + txnNumber: { $numberLong: '1' } + startTransaction: true + autocommit: false + readConcern: + level: local + writeConcern: { $$exists: false } + commandName: insert + databaseName: *database_name + - + commandStartedEvent: + command: + commitTransaction: 1 + lsid: { $$sessionLsid: *session1 } + txnNumber: { $numberLong: '1' } + startTransaction: { $$exists: false } + autocommit: false + readConcern: { $$exists: false } + writeConcern: + w: 1 + commandName: commitTransaction + databaseName: admin + - + commandStartedEvent: + command: + insert: *collection_name + documents: + - { _id: 2 } + ordered: true + lsid: { $$sessionLsid: *session1 } + txnNumber: { $numberLong: '2' } + startTransaction: true + autocommit: false + readConcern: + level: local + afterClusterTime: { $$exists: true } + writeConcern: { $$exists: false } + commandName: insert + databaseName: *database_name + - + commandStartedEvent: + command: + abortTransaction: 1 + lsid: { $$sessionLsid: *session1 } + txnNumber: { $numberLong: '2' } + startTransaction: { $$exists: false } + autocommit: false + readConcern: { $$exists: false } + writeConcern: + w: 1 + commandName: abortTransaction + databaseName: admin + outcome: *outcome + - + description: 'client writeConcern ignored for bulk' + operations: + - + object: testRunner + name: createEntities + arguments: + entities: + - client: + id: &client1 client1 + useMultipleMongoses: false + uriOptions: + w: majority + observeEvents: + - commandStartedEvent + - database: + id: &database1 database1 + client: *client1 + databaseName: *database_name + - collection: + id: &collection1 collection1 + database: *database1 + collectionName: *collection_name + - session: + id: &session1 session1 + client: *client1 + - + object: *session1 + name: startTransaction + arguments: + writeConcern: + w: 1 + - + object: *collection1 + name: bulkWrite + arguments: + requests: + - + insertOne: + document: { _id: 1 } + session: *session1 + expectResult: + deletedCount: 0 + insertedCount: 1 + insertedIds: + $$unsetOrMatches: + '0': 1 + matchedCount: 0 + modifiedCount: 0 + upsertedCount: 0 + upsertedIds: { } + - + object: *session1 + name: commitTransaction + expectEvents: + - + client: *client1 + events: + - + commandStartedEvent: + command: + insert: *collection_name + documents: + - { _id: 1 } + ordered: true + readConcern: { $$exists: false } + lsid: { $$sessionLsid: *session1 } + txnNumber: { $numberLong: '1' } + startTransaction: true + autocommit: false + # No writeConcern + writeConcern: { $$exists: false } + commandName: insert + databaseName: *database_name + - + commandStartedEvent: + command: + commitTransaction: 1 + lsid: { $$sessionLsid: *session1 } + txnNumber: { $numberLong: '1' } + startTransaction: { $$exists: false } + autocommit: false + writeConcern: + w: 1 + commandName: commitTransaction + databaseName: admin + outcome: *outcome + - + description: 'readPreference inherited from client' + operations: + - + object: testRunner + name: createEntities + arguments: + entities: + - client: + id: &client1 client1 + useMultipleMongoses: false + uriOptions: + readPreference: secondary + observeEvents: + - commandStartedEvent + - database: + id: &database1 database1 + client: *client1 + databaseName: *database_name + - collection: + id: &collection1 collection1 + database: *database1 + collectionName: *collection_name + - session: + id: &session1 session1 + client: *client1 + - + object: *session1 + name: startTransaction + - + object: *collection1 + name: insertOne + arguments: + session: *session1 + document: { _id: 1 } + expectResult: + $$unsetOrMatches: { insertedId: { $$unsetOrMatches: 1 } } + - + object: *collection1 + name: find + arguments: + session: *session1 + filter: { _id: 1 } + expectError: + errorContains: 'read preference in a transaction must be primary' + - + object: *session1 + name: commitTransaction + expectEvents: + - + client: *client1 + events: + - + commandStartedEvent: + command: + insert: *collection_name + documents: + - { _id: 1 } + ordered: true + lsid: { $$sessionLsid: *session1 } + txnNumber: { $numberLong: '1' } + startTransaction: true + autocommit: false + readConcern: { $$exists: false } + writeConcern: { $$exists: false } + commandName: insert + databaseName: *database_name + - + commandStartedEvent: + command: + commitTransaction: 1 + lsid: { $$sessionLsid: *session1 } + txnNumber: { $numberLong: '1' } + startTransaction: { $$exists: false } + autocommit: false + readConcern: { $$exists: false } + writeConcern: { $$exists: false } + commandName: commitTransaction + databaseName: admin + outcome: + - + collectionName: *collection_name + databaseName: *database_name + documents: + - { _id: 1 } + - + description: 'readPreference inherited from defaultTransactionOptions' + operations: + - + object: testRunner + name: createEntities + arguments: + entities: + - client: + id: &client1 client1 + useMultipleMongoses: false + uriOptions: + readPreference: primary + observeEvents: + - commandStartedEvent + - database: + id: &database1 database1 + client: *client1 + databaseName: *database_name + - collection: + id: &collection1 collection1 + database: *database1 + collectionName: *collection_name + - session: + id: &session1 session1 + client: *client1 + sessionOptions: + defaultTransactionOptions: + readPreference: { mode: secondary } + - + object: *session1 + name: startTransaction + - + object: *collection1 + name: insertOne + arguments: + session: *session1 + document: { _id: 1 } + expectResult: + $$unsetOrMatches: { insertedId: { $$unsetOrMatches: 1 } } + - + object: *collection1 + name: find + arguments: + session: *session1 + filter: { _id: 1 } + expectError: + errorContains: 'read preference in a transaction must be primary' + - + object: *session1 + name: commitTransaction + expectEvents: + - + client: *client1 + events: + - + commandStartedEvent: + command: + insert: *collection_name + documents: + - { _id: 1 } + ordered: true + lsid: { $$sessionLsid: *session1 } + txnNumber: { $numberLong: '1' } + startTransaction: true + autocommit: false + readConcern: { $$exists: false } + writeConcern: { $$exists: false } + commandName: insert + databaseName: *database_name + - + commandStartedEvent: + command: + commitTransaction: 1 + lsid: { $$sessionLsid: *session1 } + txnNumber: { $numberLong: '1' } + startTransaction: { $$exists: false } + autocommit: false + readConcern: { $$exists: false } + writeConcern: { $$exists: false } + commandName: commitTransaction + databaseName: admin + outcome: + - + collectionName: *collection_name + databaseName: *database_name + documents: + - { _id: 1 } + - + description: 'startTransaction overrides readPreference' + operations: + - + object: testRunner + name: createEntities + arguments: + entities: + - client: + id: &client1 client1 + useMultipleMongoses: false + uriOptions: + readPreference: primary + observeEvents: + - commandStartedEvent + - database: + id: &database1 database1 + client: *client1 + databaseName: *database_name + - collection: + id: &collection1 collection1 + database: *database1 + collectionName: *collection_name + - session: + id: &session1 session1 + client: *client1 + sessionOptions: + defaultTransactionOptions: + readPreference: { mode: primary } + - + object: *session1 + name: startTransaction + arguments: + readPreference: + mode: secondary + - + object: *collection1 + name: insertOne + arguments: + session: *session1 + document: { _id: 1 } + expectResult: + $$unsetOrMatches: { insertedId: { $$unsetOrMatches: 1 } } + - + object: *collection1 + name: find + arguments: + session: *session1 + filter: { _id: 1 } + expectError: + errorContains: 'read preference in a transaction must be primary' + - + object: *session1 + name: commitTransaction + expectEvents: + - + client: *client1 + events: + - + commandStartedEvent: + command: + insert: *collection_name + documents: + - { _id: 1 } + ordered: true + lsid: { $$sessionLsid: *session1 } + txnNumber: { $numberLong: '1' } + startTransaction: true + autocommit: false + readConcern: { $$exists: false } + writeConcern: { $$exists: false } + commandName: insert + databaseName: *database_name + - + commandStartedEvent: + command: + commitTransaction: 1 + lsid: { $$sessionLsid: *session1 } + txnNumber: { $numberLong: '1' } + startTransaction: { $$exists: false } + autocommit: false + readConcern: { $$exists: false } + writeConcern: { $$exists: false } + commandName: commitTransaction + databaseName: admin + outcome: + - + collectionName: *collection_name + databaseName: *database_name + documents: + - { _id: 1 } diff --git a/source/transactions/tests/unified/update.json b/source/transactions/tests/unified/update.json new file mode 100644 index 0000000000..8090fc9087 --- /dev/null +++ b/source/transactions/tests/unified/update.json @@ -0,0 +1,565 @@ +{ + "description": "update", + "schemaVersion": "1.9", + "runOnRequirements": [ + { + "minServerVersion": "4.0", + "topologies": [ + "replicaset" + ] + }, + { + "minServerVersion": "4.1.8", + "topologies": [ + "sharded", + "load-balanced" + ] + } + ], + "createEntities": [ + { + "client": { + "id": "client0", + "useMultipleMongoses": false, + "observeEvents": [ + "commandStartedEvent" + ] + } + }, + { + "database": { + "id": "database0", + "client": "client0", + "databaseName": "transaction-tests" + } + }, + { + "collection": { + "id": "collection0", + "database": "database0", + "collectionName": "test" + } + }, + { + "session": { + "id": "session0", + "client": "client0" + } + } + ], + "initialData": [ + { + "collectionName": "test", + "databaseName": "transaction-tests", + "documents": [ + { + "_id": 1 + }, + { + "_id": 2 + }, + { + "_id": 3 + } + ] + } + ], + "tests": [ + { + "description": "update", + "operations": [ + { + "object": "session0", + "name": "startTransaction" + }, + { + "object": "collection0", + "name": "updateOne", + "arguments": { + "session": "session0", + "filter": { + "_id": 4 + }, + "update": { + "$inc": { + "x": 1 + } + }, + "upsert": true + }, + "expectResult": { + "matchedCount": 0, + "modifiedCount": 0, + "upsertedCount": 1, + "upsertedId": 4 + } + }, + { + "object": "collection0", + "name": "replaceOne", + "arguments": { + "session": "session0", + "filter": { + "x": 1 + }, + "replacement": { + "y": 1 + } + }, + "expectResult": { + "matchedCount": 1, + "modifiedCount": 1, + "upsertedCount": 0 + } + }, + { + "object": "collection0", + "name": "updateMany", + "arguments": { + "session": "session0", + "filter": { + "_id": { + "$gte": 3 + } + }, + "update": { + "$set": { + "z": 1 + } + } + }, + "expectResult": { + "matchedCount": 2, + "modifiedCount": 2, + "upsertedCount": 0 + } + }, + { + "object": "session0", + "name": "commitTransaction" + } + ], + "expectEvents": [ + { + "client": "client0", + "events": [ + { + "commandStartedEvent": { + "command": { + "update": "test", + "updates": [ + { + "q": { + "_id": 4 + }, + "u": { + "$inc": { + "x": 1 + } + }, + "upsert": true, + "multi": { + "$$unsetOrMatches": false + } + } + ], + "ordered": true, + "readConcern": { + "$$exists": false + }, + "lsid": { + "$$sessionLsid": "session0" + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": true, + "autocommit": false, + "writeConcern": { + "$$exists": false + } + }, + "commandName": "update", + "databaseName": "transaction-tests" + } + }, + { + "commandStartedEvent": { + "command": { + "update": "test", + "updates": [ + { + "q": { + "x": 1 + }, + "u": { + "y": 1 + }, + "multi": { + "$$unsetOrMatches": false + }, + "upsert": { + "$$unsetOrMatches": false + } + } + ], + "ordered": true, + "lsid": { + "$$sessionLsid": "session0" + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": { + "$$exists": false + }, + "autocommit": false, + "writeConcern": { + "$$exists": false + } + }, + "commandName": "update", + "databaseName": "transaction-tests" + } + }, + { + "commandStartedEvent": { + "command": { + "update": "test", + "updates": [ + { + "q": { + "_id": { + "$gte": 3 + } + }, + "u": { + "$set": { + "z": 1 + } + }, + "multi": true, + "upsert": { + "$$unsetOrMatches": false + } + } + ], + "ordered": true, + "lsid": { + "$$sessionLsid": "session0" + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": { + "$$exists": false + }, + "autocommit": false, + "writeConcern": { + "$$exists": false + } + }, + "commandName": "update", + "databaseName": "transaction-tests" + } + }, + { + "commandStartedEvent": { + "command": { + "commitTransaction": 1, + "lsid": { + "$$sessionLsid": "session0" + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": { + "$$exists": false + }, + "autocommit": false, + "writeConcern": { + "$$exists": false + } + }, + "commandName": "commitTransaction", + "databaseName": "admin" + } + } + ] + } + ], + "outcome": [ + { + "collectionName": "test", + "databaseName": "transaction-tests", + "documents": [ + { + "_id": 1 + }, + { + "_id": 2 + }, + { + "_id": 3, + "z": 1 + }, + { + "_id": 4, + "y": 1, + "z": 1 + } + ] + } + ] + }, + { + "description": "collections writeConcern ignored for update", + "operations": [ + { + "object": "testRunner", + "name": "createEntities", + "arguments": { + "entities": [ + { + "collection": { + "id": "collection1", + "database": "database0", + "collectionName": "test", + "collectionOptions": { + "writeConcern": { + "w": "majority" + } + } + } + } + ] + } + }, + { + "object": "session0", + "name": "startTransaction", + "arguments": { + "writeConcern": { + "w": "majority" + } + } + }, + { + "object": "collection1", + "name": "updateOne", + "arguments": { + "session": "session0", + "filter": { + "_id": 4 + }, + "update": { + "$inc": { + "x": 1 + } + }, + "upsert": true + }, + "expectResult": { + "matchedCount": 0, + "modifiedCount": 0, + "upsertedCount": 1, + "upsertedId": 4 + } + }, + { + "object": "collection1", + "name": "replaceOne", + "arguments": { + "session": "session0", + "filter": { + "x": 1 + }, + "replacement": { + "y": 1 + } + }, + "expectResult": { + "matchedCount": 1, + "modifiedCount": 1, + "upsertedCount": 0 + } + }, + { + "object": "collection1", + "name": "updateMany", + "arguments": { + "session": "session0", + "filter": { + "_id": { + "$gte": 3 + } + }, + "update": { + "$set": { + "z": 1 + } + } + }, + "expectResult": { + "matchedCount": 2, + "modifiedCount": 2, + "upsertedCount": 0 + } + }, + { + "object": "session0", + "name": "commitTransaction" + } + ], + "expectEvents": [ + { + "client": "client0", + "events": [ + { + "commandStartedEvent": { + "command": { + "update": "test", + "updates": [ + { + "q": { + "_id": 4 + }, + "u": { + "$inc": { + "x": 1 + } + }, + "upsert": true, + "multi": { + "$$unsetOrMatches": false + } + } + ], + "ordered": true, + "readConcern": { + "$$exists": false + }, + "lsid": { + "$$sessionLsid": "session0" + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": true, + "autocommit": false, + "writeConcern": { + "$$exists": false + } + }, + "commandName": "update", + "databaseName": "transaction-tests" + } + }, + { + "commandStartedEvent": { + "command": { + "update": "test", + "updates": [ + { + "q": { + "x": 1 + }, + "u": { + "y": 1 + }, + "multi": { + "$$unsetOrMatches": false + }, + "upsert": { + "$$unsetOrMatches": false + } + } + ], + "ordered": true, + "lsid": { + "$$sessionLsid": "session0" + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": { + "$$exists": false + }, + "autocommit": false, + "writeConcern": { + "$$exists": false + } + }, + "commandName": "update", + "databaseName": "transaction-tests" + } + }, + { + "commandStartedEvent": { + "command": { + "update": "test", + "updates": [ + { + "q": { + "_id": { + "$gte": 3 + } + }, + "u": { + "$set": { + "z": 1 + } + }, + "multi": true, + "upsert": { + "$$unsetOrMatches": false + } + } + ], + "ordered": true, + "lsid": { + "$$sessionLsid": "session0" + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": { + "$$exists": false + }, + "autocommit": false, + "writeConcern": { + "$$exists": false + } + }, + "commandName": "update", + "databaseName": "transaction-tests" + } + }, + { + "commandStartedEvent": { + "command": { + "commitTransaction": 1, + "lsid": { + "$$sessionLsid": "session0" + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": { + "$$exists": false + }, + "autocommit": false, + "writeConcern": { + "w": "majority" + } + }, + "commandName": "commitTransaction", + "databaseName": "admin" + } + } + ] + } + ] + } + ] +} diff --git a/source/transactions/tests/unified/update.yml b/source/transactions/tests/unified/update.yml new file mode 100644 index 0000000000..4e49350653 --- /dev/null +++ b/source/transactions/tests/unified/update.yml @@ -0,0 +1,299 @@ +description: update + +schemaVersion: '1.9' + +runOnRequirements: + - + minServerVersion: '4.0' + topologies: + - replicaset + - + minServerVersion: 4.1.8 + topologies: + - sharded + - load-balanced + +createEntities: + - + client: + id: &client0 client0 + useMultipleMongoses: false + observeEvents: + - commandStartedEvent + - + database: + id: &database0 database0 + client: *client0 + databaseName: &database_name transaction-tests + - + collection: + id: &collection0 collection0 + database: *database0 + collectionName: &collection_name test + - + session: + id: &session0 session0 + client: *client0 + +initialData: + - + collectionName: *collection_name + databaseName: *database_name + documents: + - { _id: 1 } + - { _id: 2 } + - { _id: 3 } + +tests: + - + description: update + operations: + - + object: *session0 + name: startTransaction + - + object: *collection0 + name: updateOne + arguments: + session: *session0 + filter: { _id: 4 } + update: { $inc: { x: 1 } } + upsert: true + expectResult: + matchedCount: 0 + modifiedCount: 0 + upsertedCount: 1 + upsertedId: 4 + - + object: *collection0 + name: replaceOne + arguments: + session: *session0 + filter: { x: 1 } + replacement: { y: 1 } + expectResult: + matchedCount: 1 + modifiedCount: 1 + upsertedCount: 0 + - + object: *collection0 + name: updateMany + arguments: + session: *session0 + filter: { _id: { $gte: 3 } } + update: { $set: { z: 1 } } + expectResult: + matchedCount: 2 + modifiedCount: 2 + upsertedCount: 0 + - + object: *session0 + name: commitTransaction + expectEvents: + - + client: *client0 + events: + - + commandStartedEvent: + command: + update: *collection_name + updates: + - + q: { _id: 4 } + u: { $inc: { x: 1 } } + upsert: true + multi: { $$unsetOrMatches: false } + ordered: true + readConcern: { $$exists: false } + lsid: { $$sessionLsid: *session0 } + txnNumber: { $numberLong: '1' } + startTransaction: true + autocommit: false + writeConcern: { $$exists: false } + commandName: update + databaseName: *database_name + - + commandStartedEvent: + command: + update: *collection_name + updates: + - + q: { x: 1 } + u: { y: 1 } + multi: { $$unsetOrMatches: false } + upsert: { $$unsetOrMatches: false } + ordered: true + lsid: { $$sessionLsid: *session0 } + txnNumber: { $numberLong: '1' } + startTransaction: { $$exists: false } + autocommit: false + writeConcern: { $$exists: false } + commandName: update + databaseName: *database_name + - + commandStartedEvent: + command: + update: *collection_name + updates: + - + q: { _id: { $gte: 3 } } + u: { $set: { z: 1 } } + multi: true + upsert: { $$unsetOrMatches: false } + ordered: true + lsid: { $$sessionLsid: *session0 } + txnNumber: { $numberLong: '1' } + startTransaction: { $$exists: false } + autocommit: false + writeConcern: { $$exists: false } + commandName: update + databaseName: *database_name + - + commandStartedEvent: + command: + commitTransaction: 1 + lsid: { $$sessionLsid: *session0 } + txnNumber: { $numberLong: '1' } + startTransaction: { $$exists: false } + autocommit: false + writeConcern: { $$exists: false } + commandName: commitTransaction + databaseName: admin + outcome: + - + collectionName: *collection_name + databaseName: *database_name + documents: + - { _id: 1 } + - { _id: 2 } + - { _id: 3, z: 1 } + - { _id: 4, y: 1, z: 1 } + - + description: 'collections writeConcern ignored for update' + operations: + - + object: testRunner + name: createEntities + arguments: + entities: + - collection: + id: &collection1 collection1 + database: *database0 + collectionName: *collection_name + collectionOptions: + writeConcern: { w: majority } + - + object: *session0 + name: startTransaction + arguments: + writeConcern: + w: majority + - + object: *collection1 + name: updateOne + arguments: + session: *session0 + filter: { _id: 4 } + update: { $inc: { x: 1 } } + upsert: true + expectResult: + matchedCount: 0 + modifiedCount: 0 + upsertedCount: 1 + upsertedId: 4 + - + object: *collection1 + name: replaceOne + arguments: + session: *session0 + filter: { x: 1 } + replacement: { y: 1 } + expectResult: + matchedCount: 1 + modifiedCount: 1 + upsertedCount: 0 + - + object: *collection1 + name: updateMany + arguments: + session: *session0 + filter: { _id: { $gte: 3 } } + update: { $set: { z: 1 } } + expectResult: + matchedCount: 2 + modifiedCount: 2 + upsertedCount: 0 + - + object: *session0 + name: commitTransaction + expectEvents: + - + client: *client0 + events: + - + commandStartedEvent: + command: + update: *collection_name + updates: + - + q: { _id: 4 } + u: { $inc: { x: 1 } } + upsert: true + multi: { $$unsetOrMatches: false } + ordered: true + readConcern: { $$exists: false } + lsid: { $$sessionLsid: *session0 } + txnNumber: { $numberLong: '1' } + startTransaction: true + autocommit: false + writeConcern: { $$exists: false } + commandName: update + databaseName: *database_name + - + commandStartedEvent: + command: + update: *collection_name + updates: + - + q: { x: 1 } + u: { y: 1 } + multi: { $$unsetOrMatches: false } + upsert: { $$unsetOrMatches: false } + ordered: true + lsid: { $$sessionLsid: *session0 } + txnNumber: { $numberLong: '1' } + startTransaction: { $$exists: false } + autocommit: false + writeConcern: { $$exists: false } + commandName: update + databaseName: *database_name + - + commandStartedEvent: + command: + update: *collection_name + updates: + - + q: { _id: { $gte: 3 } } + u: { $set: { z: 1 } } + multi: true + upsert: { $$unsetOrMatches: false } + ordered: true + lsid: { $$sessionLsid: *session0 } + txnNumber: { $numberLong: '1' } + startTransaction: { $$exists: false } + autocommit: false + writeConcern: { $$exists: false } + commandName: update + databaseName: *database_name + - + commandStartedEvent: + command: + commitTransaction: 1 + lsid: { $$sessionLsid: *session0 } + txnNumber: { $numberLong: '1' } + startTransaction: { $$exists: false } + autocommit: false + writeConcern: + w: majority + commandName: commitTransaction + databaseName: admin diff --git a/source/transactions/tests/unified/write-concern.json b/source/transactions/tests/unified/write-concern.json new file mode 100644 index 0000000000..7acdd54066 --- /dev/null +++ b/source/transactions/tests/unified/write-concern.json @@ -0,0 +1,1584 @@ +{ + "description": "write-concern", + "schemaVersion": "1.9", + "runOnRequirements": [ + { + "minServerVersion": "4.0", + "topologies": [ + "replicaset" + ] + }, + { + "minServerVersion": "4.1.8", + "topologies": [ + "sharded", + "load-balanced" + ] + } + ], + "createEntities": [ + { + "client": { + "id": "client0", + "useMultipleMongoses": false, + "observeEvents": [ + "commandStartedEvent" + ] + } + }, + { + "database": { + "id": "database0", + "client": "client0", + "databaseName": "transaction-tests" + } + }, + { + "collection": { + "id": "collection0", + "database": "database0", + "collectionName": "test" + } + }, + { + "collection": { + "id": "collection_w0", + "database": "database0", + "collectionName": "test", + "collectionOptions": { + "writeConcern": { + "w": 0 + } + } + } + }, + { + "session": { + "id": "session0", + "client": "client0" + } + } + ], + "initialData": [ + { + "collectionName": "test", + "databaseName": "transaction-tests", + "documents": [ + { + "_id": 0 + } + ] + } + ], + "tests": [ + { + "description": "commit with majority", + "operations": [ + { + "object": "session0", + "name": "startTransaction", + "arguments": { + "writeConcern": { + "w": "majority" + } + } + }, + { + "object": "collection0", + "name": "insertOne", + "arguments": { + "session": "session0", + "document": { + "_id": 1 + } + }, + "expectResult": { + "$$unsetOrMatches": { + "insertedId": { + "$$unsetOrMatches": 1 + } + } + } + }, + { + "object": "session0", + "name": "commitTransaction" + } + ], + "expectEvents": [ + { + "client": "client0", + "events": [ + { + "commandStartedEvent": { + "command": { + "insert": "test", + "documents": [ + { + "_id": 1 + } + ], + "ordered": true, + "lsid": { + "$$sessionLsid": "session0" + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": true, + "autocommit": false, + "readConcern": { + "$$exists": false + }, + "writeConcern": { + "$$exists": false + } + }, + "commandName": "insert", + "databaseName": "transaction-tests" + } + }, + { + "commandStartedEvent": { + "command": { + "commitTransaction": 1, + "lsid": { + "$$sessionLsid": "session0" + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": { + "$$exists": false + }, + "autocommit": false, + "writeConcern": { + "w": "majority" + } + }, + "commandName": "commitTransaction", + "databaseName": "admin" + } + } + ] + } + ], + "outcome": [ + { + "collectionName": "test", + "databaseName": "transaction-tests", + "documents": [ + { + "_id": 0 + }, + { + "_id": 1 + } + ] + } + ] + }, + { + "description": "commit with default", + "operations": [ + { + "object": "session0", + "name": "startTransaction" + }, + { + "object": "collection0", + "name": "insertOne", + "arguments": { + "session": "session0", + "document": { + "_id": 1 + } + }, + "expectResult": { + "$$unsetOrMatches": { + "insertedId": { + "$$unsetOrMatches": 1 + } + } + } + }, + { + "object": "session0", + "name": "commitTransaction" + } + ], + "expectEvents": [ + { + "client": "client0", + "events": [ + { + "commandStartedEvent": { + "command": { + "insert": "test", + "documents": [ + { + "_id": 1 + } + ], + "ordered": true, + "lsid": { + "$$sessionLsid": "session0" + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": true, + "autocommit": false, + "readConcern": { + "$$exists": false + }, + "writeConcern": { + "$$exists": false + } + }, + "commandName": "insert", + "databaseName": "transaction-tests" + } + }, + { + "commandStartedEvent": { + "command": { + "commitTransaction": 1, + "lsid": { + "$$sessionLsid": "session0" + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": { + "$$exists": false + }, + "autocommit": false, + "writeConcern": { + "$$exists": false + } + }, + "commandName": "commitTransaction", + "databaseName": "admin" + } + } + ] + } + ], + "outcome": [ + { + "collectionName": "test", + "databaseName": "transaction-tests", + "documents": [ + { + "_id": 0 + }, + { + "_id": 1 + } + ] + } + ] + }, + { + "description": "abort with majority", + "operations": [ + { + "object": "session0", + "name": "startTransaction", + "arguments": { + "writeConcern": { + "w": "majority" + } + } + }, + { + "object": "collection0", + "name": "insertOne", + "arguments": { + "session": "session0", + "document": { + "_id": 1 + } + }, + "expectResult": { + "$$unsetOrMatches": { + "insertedId": { + "$$unsetOrMatches": 1 + } + } + } + }, + { + "object": "session0", + "name": "abortTransaction" + } + ], + "expectEvents": [ + { + "client": "client0", + "events": [ + { + "commandStartedEvent": { + "command": { + "insert": "test", + "documents": [ + { + "_id": 1 + } + ], + "ordered": true, + "lsid": { + "$$sessionLsid": "session0" + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": true, + "autocommit": false, + "readConcern": { + "$$exists": false + }, + "writeConcern": { + "$$exists": false + } + }, + "commandName": "insert", + "databaseName": "transaction-tests" + } + }, + { + "commandStartedEvent": { + "command": { + "abortTransaction": 1, + "lsid": { + "$$sessionLsid": "session0" + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": { + "$$exists": false + }, + "autocommit": false, + "writeConcern": { + "w": "majority" + } + }, + "commandName": "abortTransaction", + "databaseName": "admin" + } + } + ] + } + ], + "outcome": [ + { + "collectionName": "test", + "databaseName": "transaction-tests", + "documents": [ + { + "_id": 0 + } + ] + } + ] + }, + { + "description": "abort with default", + "operations": [ + { + "object": "session0", + "name": "startTransaction" + }, + { + "object": "collection0", + "name": "insertOne", + "arguments": { + "session": "session0", + "document": { + "_id": 1 + } + }, + "expectResult": { + "$$unsetOrMatches": { + "insertedId": { + "$$unsetOrMatches": 1 + } + } + } + }, + { + "object": "session0", + "name": "abortTransaction" + } + ], + "expectEvents": [ + { + "client": "client0", + "events": [ + { + "commandStartedEvent": { + "command": { + "insert": "test", + "documents": [ + { + "_id": 1 + } + ], + "ordered": true, + "lsid": { + "$$sessionLsid": "session0" + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": true, + "autocommit": false, + "readConcern": { + "$$exists": false + }, + "writeConcern": { + "$$exists": false + } + }, + "commandName": "insert", + "databaseName": "transaction-tests" + } + }, + { + "commandStartedEvent": { + "command": { + "abortTransaction": 1, + "lsid": { + "$$sessionLsid": "session0" + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": { + "$$exists": false + }, + "autocommit": false, + "writeConcern": { + "$$exists": false + } + }, + "commandName": "abortTransaction", + "databaseName": "admin" + } + } + ] + } + ], + "outcome": [ + { + "collectionName": "test", + "databaseName": "transaction-tests", + "documents": [ + { + "_id": 0 + } + ] + } + ] + }, + { + "description": "start with unacknowledged write concern", + "operations": [ + { + "object": "session0", + "name": "startTransaction", + "arguments": { + "writeConcern": { + "w": 0 + } + }, + "expectError": { + "isClientError": true, + "errorContains": "transactions do not support unacknowledged write concern" + } + } + ] + }, + { + "description": "start with implicit unacknowledged write concern", + "operations": [ + { + "object": "testRunner", + "name": "createEntities", + "arguments": { + "entities": [ + { + "client": { + "id": "client1", + "useMultipleMongoses": false, + "uriOptions": { + "w": 0 + } + } + }, + { + "session": { + "id": "session1", + "client": "client1" + } + } + ] + } + }, + { + "object": "session1", + "name": "startTransaction", + "expectError": { + "isClientError": true, + "errorContains": "transactions do not support unacknowledged write concern" + } + } + ] + }, + { + "description": "unacknowledged write concern coll insertOne", + "operations": [ + { + "object": "session0", + "name": "startTransaction" + }, + { + "object": "collection_w0", + "name": "insertOne", + "arguments": { + "session": "session0", + "document": { + "_id": 1 + } + }, + "expectResult": { + "$$unsetOrMatches": { + "insertedId": { + "$$unsetOrMatches": 1 + } + } + } + }, + { + "object": "session0", + "name": "commitTransaction" + } + ], + "expectEvents": [ + { + "client": "client0", + "events": [ + { + "commandStartedEvent": { + "command": { + "insert": "test", + "documents": [ + { + "_id": 1 + } + ], + "ordered": true, + "lsid": { + "$$sessionLsid": "session0" + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": true, + "autocommit": false, + "readConcern": { + "$$exists": false + }, + "writeConcern": { + "$$exists": false + } + }, + "commandName": "insert", + "databaseName": "transaction-tests" + } + }, + { + "commandStartedEvent": { + "command": { + "commitTransaction": 1, + "lsid": { + "$$sessionLsid": "session0" + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": { + "$$exists": false + }, + "autocommit": false, + "writeConcern": { + "$$exists": false + } + }, + "commandName": "commitTransaction", + "databaseName": "admin" + } + } + ] + } + ], + "outcome": [ + { + "collectionName": "test", + "databaseName": "transaction-tests", + "documents": [ + { + "_id": 0 + }, + { + "_id": 1 + } + ] + } + ] + }, + { + "description": "unacknowledged write concern coll insertMany", + "operations": [ + { + "object": "session0", + "name": "startTransaction" + }, + { + "object": "collection_w0", + "name": "insertMany", + "arguments": { + "session": "session0", + "documents": [ + { + "_id": 1 + }, + { + "_id": 2 + } + ] + }, + "expectResult": { + "$$unsetOrMatches": { + "insertedIds": { + "$$unsetOrMatches": { + "0": 1, + "1": 2 + } + } + } + } + }, + { + "object": "session0", + "name": "commitTransaction" + } + ], + "expectEvents": [ + { + "client": "client0", + "events": [ + { + "commandStartedEvent": { + "command": { + "insert": "test", + "documents": [ + { + "_id": 1 + }, + { + "_id": 2 + } + ], + "ordered": true, + "lsid": { + "$$sessionLsid": "session0" + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": true, + "autocommit": false, + "readConcern": { + "$$exists": false + }, + "writeConcern": { + "$$exists": false + } + }, + "commandName": "insert", + "databaseName": "transaction-tests" + } + }, + { + "commandStartedEvent": { + "command": { + "commitTransaction": 1, + "lsid": { + "$$sessionLsid": "session0" + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": { + "$$exists": false + }, + "autocommit": false, + "writeConcern": { + "$$exists": false + } + }, + "commandName": "commitTransaction", + "databaseName": "admin" + } + } + ] + } + ], + "outcome": [ + { + "collectionName": "test", + "databaseName": "transaction-tests", + "documents": [ + { + "_id": 0 + }, + { + "_id": 1 + }, + { + "_id": 2 + } + ] + } + ] + }, + { + "description": "unacknowledged write concern coll bulkWrite", + "operations": [ + { + "object": "session0", + "name": "startTransaction" + }, + { + "object": "collection_w0", + "name": "bulkWrite", + "arguments": { + "session": "session0", + "requests": [ + { + "insertOne": { + "document": { + "_id": 1 + } + } + } + ] + }, + "expectResult": { + "deletedCount": 0, + "insertedCount": 1, + "insertedIds": { + "$$unsetOrMatches": { + "0": 1 + } + }, + "matchedCount": 0, + "modifiedCount": 0, + "upsertedCount": 0, + "upsertedIds": {} + } + }, + { + "object": "session0", + "name": "commitTransaction" + } + ], + "expectEvents": [ + { + "client": "client0", + "events": [ + { + "commandStartedEvent": { + "command": { + "insert": "test", + "documents": [ + { + "_id": 1 + } + ], + "ordered": true, + "lsid": { + "$$sessionLsid": "session0" + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": true, + "autocommit": false, + "readConcern": { + "$$exists": false + }, + "writeConcern": { + "$$exists": false + } + }, + "commandName": "insert", + "databaseName": "transaction-tests" + } + }, + { + "commandStartedEvent": { + "command": { + "commitTransaction": 1, + "lsid": { + "$$sessionLsid": "session0" + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": { + "$$exists": false + }, + "autocommit": false, + "writeConcern": { + "$$exists": false + } + }, + "commandName": "commitTransaction", + "databaseName": "admin" + } + } + ] + } + ], + "outcome": [ + { + "collectionName": "test", + "databaseName": "transaction-tests", + "documents": [ + { + "_id": 0 + }, + { + "_id": 1 + } + ] + } + ] + }, + { + "description": "unacknowledged write concern coll deleteOne", + "operations": [ + { + "object": "session0", + "name": "startTransaction" + }, + { + "object": "collection_w0", + "name": "deleteOne", + "arguments": { + "session": "session0", + "filter": { + "_id": 0 + } + }, + "expectResult": { + "deletedCount": 1 + } + }, + { + "object": "session0", + "name": "commitTransaction" + } + ], + "expectEvents": [ + { + "client": "client0", + "events": [ + { + "commandStartedEvent": { + "command": { + "delete": "test", + "deletes": [ + { + "q": { + "_id": 0 + }, + "limit": 1 + } + ], + "ordered": true, + "lsid": { + "$$sessionLsid": "session0" + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": true, + "autocommit": false, + "readConcern": { + "$$exists": false + }, + "writeConcern": { + "$$exists": false + } + }, + "commandName": "delete", + "databaseName": "transaction-tests" + } + }, + { + "commandStartedEvent": { + "command": { + "commitTransaction": 1, + "lsid": { + "$$sessionLsid": "session0" + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": { + "$$exists": false + }, + "autocommit": false, + "writeConcern": { + "$$exists": false + } + }, + "commandName": "commitTransaction", + "databaseName": "admin" + } + } + ] + } + ], + "outcome": [ + { + "collectionName": "test", + "databaseName": "transaction-tests", + "documents": [] + } + ] + }, + { + "description": "unacknowledged write concern coll deleteMany", + "operations": [ + { + "object": "session0", + "name": "startTransaction" + }, + { + "object": "collection_w0", + "name": "deleteMany", + "arguments": { + "session": "session0", + "filter": { + "_id": 0 + } + }, + "expectResult": { + "deletedCount": 1 + } + }, + { + "object": "session0", + "name": "commitTransaction" + } + ], + "expectEvents": [ + { + "client": "client0", + "events": [ + { + "commandStartedEvent": { + "command": { + "delete": "test", + "deletes": [ + { + "q": { + "_id": 0 + }, + "limit": 0 + } + ], + "ordered": true, + "lsid": { + "$$sessionLsid": "session0" + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": true, + "autocommit": false, + "readConcern": { + "$$exists": false + }, + "writeConcern": { + "$$exists": false + } + }, + "commandName": "delete", + "databaseName": "transaction-tests" + } + }, + { + "commandStartedEvent": { + "command": { + "commitTransaction": 1, + "lsid": { + "$$sessionLsid": "session0" + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": { + "$$exists": false + }, + "autocommit": false, + "writeConcern": { + "$$exists": false + } + }, + "commandName": "commitTransaction", + "databaseName": "admin" + } + } + ] + } + ], + "outcome": [ + { + "collectionName": "test", + "databaseName": "transaction-tests", + "documents": [] + } + ] + }, + { + "description": "unacknowledged write concern coll updateOne", + "operations": [ + { + "object": "session0", + "name": "startTransaction" + }, + { + "object": "collection_w0", + "name": "updateOne", + "arguments": { + "session": "session0", + "filter": { + "_id": 0 + }, + "update": { + "$inc": { + "x": 1 + } + }, + "upsert": true + }, + "expectResult": { + "matchedCount": 1, + "modifiedCount": 1, + "upsertedCount": 0 + } + }, + { + "object": "session0", + "name": "commitTransaction" + } + ], + "expectEvents": [ + { + "client": "client0", + "events": [ + { + "commandStartedEvent": { + "command": { + "update": "test", + "updates": [ + { + "q": { + "_id": 0 + }, + "u": { + "$inc": { + "x": 1 + } + }, + "upsert": true, + "multi": { + "$$unsetOrMatches": false + } + } + ], + "ordered": true, + "lsid": { + "$$sessionLsid": "session0" + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": true, + "autocommit": false, + "readConcern": { + "$$exists": false + }, + "writeConcern": { + "$$exists": false + } + }, + "commandName": "update", + "databaseName": "transaction-tests" + } + }, + { + "commandStartedEvent": { + "command": { + "commitTransaction": 1, + "lsid": { + "$$sessionLsid": "session0" + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": { + "$$exists": false + }, + "autocommit": false, + "writeConcern": { + "$$exists": false + } + }, + "commandName": "commitTransaction", + "databaseName": "admin" + } + } + ] + } + ], + "outcome": [ + { + "collectionName": "test", + "databaseName": "transaction-tests", + "documents": [ + { + "_id": 0, + "x": 1 + } + ] + } + ] + }, + { + "description": "unacknowledged write concern coll updateMany", + "operations": [ + { + "object": "session0", + "name": "startTransaction" + }, + { + "object": "collection_w0", + "name": "updateMany", + "arguments": { + "session": "session0", + "filter": { + "_id": 0 + }, + "update": { + "$inc": { + "x": 1 + } + }, + "upsert": true + }, + "expectResult": { + "matchedCount": 1, + "modifiedCount": 1, + "upsertedCount": 0 + } + }, + { + "object": "session0", + "name": "commitTransaction" + } + ], + "expectEvents": [ + { + "client": "client0", + "events": [ + { + "commandStartedEvent": { + "command": { + "update": "test", + "updates": [ + { + "q": { + "_id": 0 + }, + "u": { + "$inc": { + "x": 1 + } + }, + "multi": true, + "upsert": true + } + ], + "ordered": true, + "lsid": { + "$$sessionLsid": "session0" + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": true, + "autocommit": false, + "readConcern": { + "$$exists": false + }, + "writeConcern": { + "$$exists": false + } + }, + "commandName": "update", + "databaseName": "transaction-tests" + } + }, + { + "commandStartedEvent": { + "command": { + "commitTransaction": 1, + "lsid": { + "$$sessionLsid": "session0" + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": { + "$$exists": false + }, + "autocommit": false, + "writeConcern": { + "$$exists": false + } + }, + "commandName": "commitTransaction", + "databaseName": "admin" + } + } + ] + } + ], + "outcome": [ + { + "collectionName": "test", + "databaseName": "transaction-tests", + "documents": [ + { + "_id": 0, + "x": 1 + } + ] + } + ] + }, + { + "description": "unacknowledged write concern coll findOneAndDelete", + "operations": [ + { + "object": "session0", + "name": "startTransaction" + }, + { + "object": "collection_w0", + "name": "findOneAndDelete", + "arguments": { + "session": "session0", + "filter": { + "_id": 0 + } + }, + "expectResult": { + "_id": 0 + } + }, + { + "object": "session0", + "name": "commitTransaction" + } + ], + "expectEvents": [ + { + "client": "client0", + "events": [ + { + "commandStartedEvent": { + "command": { + "findAndModify": "test", + "query": { + "_id": 0 + }, + "remove": true, + "lsid": { + "$$sessionLsid": "session0" + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": true, + "autocommit": false, + "readConcern": { + "$$exists": false + }, + "writeConcern": { + "$$exists": false + } + }, + "commandName": "findAndModify", + "databaseName": "transaction-tests" + } + }, + { + "commandStartedEvent": { + "command": { + "commitTransaction": 1, + "lsid": { + "$$sessionLsid": "session0" + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": { + "$$exists": false + }, + "autocommit": false, + "writeConcern": { + "$$exists": false + } + }, + "commandName": "commitTransaction", + "databaseName": "admin" + } + } + ] + } + ], + "outcome": [ + { + "collectionName": "test", + "databaseName": "transaction-tests", + "documents": [] + } + ] + }, + { + "description": "unacknowledged write concern coll findOneAndReplace", + "operations": [ + { + "object": "session0", + "name": "startTransaction" + }, + { + "object": "collection_w0", + "name": "findOneAndReplace", + "arguments": { + "session": "session0", + "filter": { + "_id": 0 + }, + "replacement": { + "x": 1 + }, + "returnDocument": "Before" + }, + "expectResult": { + "_id": 0 + } + }, + { + "object": "session0", + "name": "commitTransaction" + } + ], + "expectEvents": [ + { + "client": "client0", + "events": [ + { + "commandStartedEvent": { + "command": { + "findAndModify": "test", + "query": { + "_id": 0 + }, + "update": { + "x": 1 + }, + "new": false, + "lsid": { + "$$sessionLsid": "session0" + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": true, + "autocommit": false, + "readConcern": { + "$$exists": false + }, + "writeConcern": { + "$$exists": false + } + }, + "commandName": "findAndModify", + "databaseName": "transaction-tests" + } + }, + { + "commandStartedEvent": { + "command": { + "commitTransaction": 1, + "lsid": { + "$$sessionLsid": "session0" + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": { + "$$exists": false + }, + "autocommit": false, + "writeConcern": { + "$$exists": false + } + }, + "commandName": "commitTransaction", + "databaseName": "admin" + } + } + ] + } + ], + "outcome": [ + { + "collectionName": "test", + "databaseName": "transaction-tests", + "documents": [ + { + "_id": 0, + "x": 1 + } + ] + } + ] + }, + { + "description": "unacknowledged write concern coll findOneAndUpdate", + "operations": [ + { + "object": "session0", + "name": "startTransaction" + }, + { + "object": "collection_w0", + "name": "findOneAndUpdate", + "arguments": { + "session": "session0", + "filter": { + "_id": 0 + }, + "update": { + "$inc": { + "x": 1 + } + }, + "returnDocument": "Before" + }, + "expectResult": { + "_id": 0 + } + }, + { + "object": "session0", + "name": "commitTransaction" + } + ], + "expectEvents": [ + { + "client": "client0", + "events": [ + { + "commandStartedEvent": { + "command": { + "findAndModify": "test", + "query": { + "_id": 0 + }, + "update": { + "$inc": { + "x": 1 + } + }, + "new": false, + "lsid": { + "$$sessionLsid": "session0" + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": true, + "autocommit": false, + "readConcern": { + "$$exists": false + }, + "writeConcern": { + "$$exists": false + } + }, + "commandName": "findAndModify", + "databaseName": "transaction-tests" + } + }, + { + "commandStartedEvent": { + "command": { + "commitTransaction": 1, + "lsid": { + "$$sessionLsid": "session0" + }, + "txnNumber": { + "$numberLong": "1" + }, + "startTransaction": { + "$$exists": false + }, + "autocommit": false, + "writeConcern": { + "$$exists": false + } + }, + "commandName": "commitTransaction", + "databaseName": "admin" + } + } + ] + } + ], + "outcome": [ + { + "collectionName": "test", + "databaseName": "transaction-tests", + "documents": [ + { + "_id": 0, + "x": 1 + } + ] + } + ] + } + ] +} diff --git a/source/transactions/tests/unified/write-concern.yml b/source/transactions/tests/unified/write-concern.yml new file mode 100644 index 0000000000..ecb9fac0ea --- /dev/null +++ b/source/transactions/tests/unified/write-concern.yml @@ -0,0 +1,655 @@ +# Assumes the default for transactions is the same as for all ops, tests +# setting the writeConcern to "majority". +description: write-concern + +schemaVersion: '1.9' + +runOnRequirements: + - + minServerVersion: '4.0' + topologies: + - replicaset + - + minServerVersion: 4.1.8 + topologies: + - sharded + - load-balanced + +createEntities: + - + client: + id: &client0 client0 + useMultipleMongoses: false + observeEvents: + - commandStartedEvent + - + database: + id: &database0 database0 + client: *client0 + databaseName: &database_name transaction-tests + - + collection: + id: &collection0 collection0 + database: *database0 + collectionName: &collection_name test + - + collection: + id: &collection_w0 collection_w0 + database: *database0 + collectionName: &collection_name test + collectionOptions: + writeConcern: { w: 0 } + - + session: + id: &session0 session0 + client: *client0 + +initialData: + - + collectionName: *collection_name + databaseName: *database_name + documents: &data + - { _id: 0 } + +tests: + - + description: 'commit with majority' + operations: + - + object: *session0 + name: startTransaction + arguments: + writeConcern: + w: majority + - + object: *collection0 + name: insertOne + arguments: + session: *session0 + document: { _id: 1 } + expectResult: + $$unsetOrMatches: { insertedId: { $$unsetOrMatches: 1 } } + - &commitTransaction + object: *session0 + name: commitTransaction + expectEvents: + - + client: *client0 + events: + - &insertOneEvent + commandStartedEvent: + command: + insert: *collection_name + documents: + - { _id: 1 } + ordered: true + <<: &transactionCommandArgs + lsid: { $$sessionLsid: *session0 } + txnNumber: { $numberLong: '1' } + startTransaction: true + autocommit: false + readConcern: { $$exists: false } + writeConcern: { $$exists: false } + commandName: insert + databaseName: *database_name + - + commandStartedEvent: + command: + commitTransaction: 1 + lsid: { $$sessionLsid: *session0 } + txnNumber: { $numberLong: '1' } + startTransaction: { $$exists: false } + autocommit: false + writeConcern: + w: majority + commandName: commitTransaction + databaseName: admin + outcome: + - + collectionName: *collection_name + databaseName: *database_name + documents: + - { _id: 0 } + - { _id: 1 } + - + description: 'commit with default' + operations: + - &startTransaction + object: *session0 + name: startTransaction + - + object: *collection0 + name: insertOne + arguments: + session: *session0 + document: { _id: 1 } + expectResult: + $$unsetOrMatches: { insertedId: { $$unsetOrMatches: 1 } } + - *commitTransaction + expectEvents: + - + client: *client0 + events: + - + commandStartedEvent: + command: + insert: *collection_name + documents: + - { _id: 1 } + ordered: true + <<: *transactionCommandArgs + commandName: insert + databaseName: *database_name + - &commitWithDefaultWCEvent + commandStartedEvent: + command: + commitTransaction: 1 + lsid: { $$sessionLsid: *session0 } + txnNumber: { $numberLong: '1' } + startTransaction: { $$exists: false } + autocommit: false + writeConcern: { $$exists: false } + commandName: commitTransaction + databaseName: admin + outcome: + - + collectionName: *collection_name + databaseName: *database_name + documents: + - { _id: 0 } + - { _id: 1 } + - + description: 'abort with majority' + operations: + - + object: *session0 + name: startTransaction + arguments: + writeConcern: + w: majority + - + object: *collection0 + name: insertOne + arguments: + session: *session0 + document: { _id: 1 } + expectResult: + $$unsetOrMatches: { insertedId: { $$unsetOrMatches: 1 } } + - + object: *session0 + name: abortTransaction + expectEvents: + - + client: *client0 + events: + - + commandStartedEvent: + command: + insert: *collection_name + documents: + - { _id: 1 } + ordered: true + <<: *transactionCommandArgs + commandName: insert + databaseName: *database_name + - + commandStartedEvent: + command: + abortTransaction: 1 + lsid: { $$sessionLsid: *session0 } + txnNumber: { $numberLong: '1' } + startTransaction: { $$exists: false } + autocommit: false + writeConcern: + w: majority + commandName: abortTransaction + databaseName: admin + outcome: + - + collectionName: *collection_name + databaseName: *database_name + documents: *data + - + description: 'abort with default' + operations: + - + object: *session0 + name: startTransaction + - + object: *collection0 + name: insertOne + arguments: + session: *session0 + document: { _id: 1 } + expectResult: + $$unsetOrMatches: { insertedId: { $$unsetOrMatches: 1 } } + - + object: *session0 + name: abortTransaction + expectEvents: + - + client: *client0 + events: + - + commandStartedEvent: + command: + insert: *collection_name + documents: + - { _id: 1 } + ordered: true + <<: *transactionCommandArgs + commandName: insert + databaseName: *database_name + - + commandStartedEvent: + command: + abortTransaction: 1 + lsid: { $$sessionLsid: *session0 } + txnNumber: { $numberLong: '1' } + startTransaction: { $$exists: false } + autocommit: false + writeConcern: { $$exists: false } + commandName: abortTransaction + databaseName: admin + outcome: + - + collectionName: *collection_name + databaseName: *database_name + documents: *data + - + description: 'start with unacknowledged write concern' + operations: + - + object: *session0 + name: startTransaction + arguments: + writeConcern: + w: 0 + expectError: + isClientError: true + errorContains: 'transactions do not support unacknowledged write concern' + - + description: 'start with implicit unacknowledged write concern' + operations: + - + object: testRunner + name: createEntities + arguments: + entities: + - client: + id: &client1 client1 + useMultipleMongoses: false + uriOptions: { w: 0 } + - session: + id: &session1 session1 + client: *client1 + - + object: *session1 + name: startTransaction + expectError: + isClientError: true + errorContains: 'transactions do not support unacknowledged write concern' + - + description: 'unacknowledged write concern coll insertOne' + operations: + - *startTransaction + - + object: *collection_w0 + name: insertOne + arguments: + session: *session0 + document: { _id: 1 } + expectResult: + $$unsetOrMatches: { insertedId: { $$unsetOrMatches: 1 } } + - *commitTransaction + expectEvents: + - + client: *client0 + events: + - *insertOneEvent + - *commitWithDefaultWCEvent + outcome: + - + collectionName: *collection_name + databaseName: *database_name + documents: + - { _id: 0 } + - { _id: 1 } + - + description: 'unacknowledged write concern coll insertMany' + operations: + - *startTransaction + - + object: *collection_w0 + name: insertMany + arguments: + session: *session0 + documents: + - { _id: 1 } + - { _id: 2 } + expectResult: + $$unsetOrMatches: + insertedIds: + $$unsetOrMatches: + '0': 1 + '1': 2 + - *commitTransaction + expectEvents: + - + client: *client0 + events: + - + commandStartedEvent: + command: + insert: *collection_name + documents: + - { _id: 1 } + - { _id: 2 } + ordered: true + <<: *transactionCommandArgs + commandName: insert + databaseName: *database_name + - *commitWithDefaultWCEvent + outcome: + - + collectionName: *collection_name + databaseName: *database_name + documents: + - { _id: 0 } + - { _id: 1 } + - { _id: 2 } + - + description: 'unacknowledged write concern coll bulkWrite' + operations: + - *startTransaction + - + object: *collection_w0 + name: bulkWrite + arguments: + session: *session0 + requests: + - + insertOne: + document: { _id: 1 } + expectResult: + deletedCount: 0 + insertedCount: 1 + insertedIds: + $$unsetOrMatches: + '0': 1 + matchedCount: 0 + modifiedCount: 0 + upsertedCount: 0 + upsertedIds: { } + - *commitTransaction + expectEvents: + - + client: *client0 + events: + - *insertOneEvent + - *commitWithDefaultWCEvent + outcome: + - + collectionName: *collection_name + databaseName: *database_name + documents: + - { _id: 0 } + - { _id: 1 } + - + description: 'unacknowledged write concern coll deleteOne' + operations: + - *startTransaction + - + object: *collection_w0 + name: deleteOne + arguments: + session: *session0 + filter: { _id: 0 } + expectResult: + deletedCount: 1 + - *commitTransaction + expectEvents: + - + client: *client0 + events: + - + commandStartedEvent: + command: + delete: *collection_name + deletes: + - + q: { _id: 0 } + limit: 1 + ordered: true + <<: *transactionCommandArgs + commandName: delete + databaseName: *database_name + - *commitWithDefaultWCEvent + outcome: + - + collectionName: *collection_name + databaseName: *database_name + documents: [] + - + description: 'unacknowledged write concern coll deleteMany' + operations: + - *startTransaction + - + object: *collection_w0 + name: deleteMany + arguments: + session: *session0 + filter: { _id: 0 } + expectResult: + deletedCount: 1 + - *commitTransaction + expectEvents: + - + client: *client0 + events: + - + commandStartedEvent: + command: + delete: *collection_name + deletes: + - + q: { _id: 0 } + limit: 0 + ordered: true + <<: *transactionCommandArgs + commandName: delete + databaseName: *database_name + - *commitWithDefaultWCEvent + outcome: + - + collectionName: *collection_name + databaseName: *database_name + documents: [] + - + description: 'unacknowledged write concern coll updateOne' + operations: + - *startTransaction + - + object: *collection_w0 + name: updateOne + arguments: + session: *session0 + filter: { _id: 0 } + update: { $inc: { x: 1 } } + upsert: true + expectResult: + matchedCount: 1 + modifiedCount: 1 + upsertedCount: 0 + - *commitTransaction + expectEvents: + - + client: *client0 + events: + - + commandStartedEvent: + command: + update: *collection_name + updates: + - + q: { _id: 0 } + u: { $inc: { x: 1 } } + upsert: true + multi: { $$unsetOrMatches: false } + ordered: true + <<: *transactionCommandArgs + commandName: update + databaseName: *database_name + - *commitWithDefaultWCEvent + outcome: + - + collectionName: *collection_name + databaseName: *database_name + documents: + - { _id: 0, x: 1 } + - + description: 'unacknowledged write concern coll updateMany' + operations: + - *startTransaction + - + object: *collection_w0 + name: updateMany + arguments: + session: *session0 + filter: { _id: 0 } + update: { $inc: { x: 1 } } + upsert: true + expectResult: + matchedCount: 1 + modifiedCount: 1 + upsertedCount: 0 + - *commitTransaction + expectEvents: + - + client: *client0 + events: + - + commandStartedEvent: + command: + update: *collection_name + updates: + - + q: { _id: 0 } + u: { $inc: { x: 1 } } + multi: true + upsert: true + ordered: true + <<: *transactionCommandArgs + commandName: update + databaseName: *database_name + - *commitWithDefaultWCEvent + outcome: + - + collectionName: *collection_name + databaseName: *database_name + documents: + - { _id: 0, x: 1 } + - + description: 'unacknowledged write concern coll findOneAndDelete' + operations: + - *startTransaction + - + object: *collection_w0 + name: findOneAndDelete + arguments: + session: *session0 + filter: { _id: 0 } + expectResult: + _id: 0 + - *commitTransaction + expectEvents: + - + client: *client0 + events: + - + commandStartedEvent: + command: + findAndModify: *collection_name + query: { _id: 0 } + remove: true + <<: *transactionCommandArgs + commandName: findAndModify + databaseName: *database_name + - *commitWithDefaultWCEvent + outcome: + - + collectionName: *collection_name + databaseName: *database_name + documents: [] + - + description: 'unacknowledged write concern coll findOneAndReplace' + operations: + - *startTransaction + - + object: *collection_w0 + name: findOneAndReplace + arguments: + session: *session0 + filter: { _id: 0 } + replacement: { x: 1 } + returnDocument: Before + expectResult: + _id: 0 + - *commitTransaction + expectEvents: + - + client: *client0 + events: + - + commandStartedEvent: + command: + findAndModify: *collection_name + query: { _id: 0 } + update: { x: 1 } + new: false + <<: *transactionCommandArgs + commandName: findAndModify + databaseName: *database_name + - *commitWithDefaultWCEvent + outcome: + - + collectionName: *collection_name + databaseName: *database_name + documents: + - { _id: 0, x: 1 } + - + description: 'unacknowledged write concern coll findOneAndUpdate' + operations: + - *startTransaction + - + object: *collection_w0 + name: findOneAndUpdate + arguments: + session: *session0 + filter: { _id: 0 } + update: { $inc: { x: 1 } } + returnDocument: Before + expectResult: + _id: 0 + - *commitTransaction + expectEvents: + - + client: *client0 + events: + - + commandStartedEvent: + command: + findAndModify: *collection_name + query: { _id: 0 } + update: { $inc: { x: 1 } } + new: false + <<: *transactionCommandArgs + commandName: findAndModify + databaseName: *database_name + - *commitWithDefaultWCEvent + outcome: + - + collectionName: *collection_name + databaseName: *database_name + documents: + - { _id: 0, x: 1 } diff --git a/source/unified-test-format/unified-test-format.md b/source/unified-test-format/unified-test-format.md index e10b9a8dd3..ef7aa34bba 100644 --- a/source/unified-test-format/unified-test-format.md +++ b/source/unified-test-format/unified-test-format.md @@ -1849,8 +1849,13 @@ The `targetedFailPoint` operation instructs the test runner to configure a fail The following arguments are supported: - `failPoint`: Required document. The `configureFailPoint` command to be executed. + - `session`: Required string. See [commonOptions_session](#commonOptions_session). + The client entity associated with this session SHOULD specify true for + [useMultipleMongoses](#entity_client_useMultipleMongoses). This is advised because targeted fail points are intended + to test mongos pinning, which warrants multiple mongoses. + The mongos on which to set the fail point is determined by the `session` argument (after resolution to a session entity). Test runners MUST error if the session is not pinned to a mongos server at the time this operation is executed. @@ -1862,6 +1867,11 @@ SHOULD use the internal MongoClient corresponding to the session's pinned server runners MUST create a new MongoClient that is directly connected to the session's pinned server for this operation. The new MongoClient instance MUST be closed once the command has finished executing. +A test utilizing `targetedFailPoint` SHOULD NOT be permitted execute on a load balancer (according to +[runOnRequirements](#runOnRequirements) or [test.runOnRequirements](#test_runOnRequirements)). This is advised because +the `configureFailPoint` command does not use the session directly, which means there is no guarantee that the load +balancer will direct the command to the intended mongos. + When executing this operation, the test runner MUST keep a record of both the fail point and pinned mongos server so that the fail point can be disabled on the same mongos server after the test. @@ -1881,6 +1891,9 @@ An example of this operation follows: closeConnection: true ``` +Since mongos pinning only applies when multiple mongoses are used, tests SHOULD NOT use `targetedFailPoint` unless the +session's MongoClient is configured with `useMultipleMongoses: true`. + #### assertSessionTransactionState The `assertSessionTransactionState` operation instructs the test runner to assert that the given session has a @@ -3298,6 +3311,9 @@ other specs *and* collating spec changes developed in parallel or during the sam ## Changelog +- 2024-02-12: Clarify that `targetedFailPoint` should only be used when `useMultipleMongoses` is true and not on + load-balanced topologies. + - 2024-02-06: Migrated from reStructuredText to Markdown. - 2024-01-17: **Schema version 1.19.**\