From d0e2ab692e12a1e79a8e24e8c0e74af2f78463fc Mon Sep 17 00:00:00 2001 From: DmitryLukyanov Date: Wed, 24 Mar 2021 00:47:40 +0300 Subject: [PATCH] CSHARP-3450: Versioned API database aggregation test only works on 4.9+ servers. --- .../tests/crud-api-version-1-strict.json | 8 +- .../tests/crud-api-version-1-strict.yml | 5 +- .../tests/crud-api-version-1.json | 41 +-- .../tests/crud-api-version-1.yml | 19 +- ...ommand-helper-no-api-version-declared.json | 2 +- ...command-helper-no-api-version-declared.yml | 2 +- .../test-commands-deprecation-errors.json | 2 +- .../test-commands-deprecation-errors.yml | 2 +- .../tests/test-commands-strict-mode.json | 2 +- .../tests/test-commands-strict-mode.yml | 2 +- .../tests/transaction-handling.json | 289 +++++++++++++++++- .../tests/transaction-handling.yml | 91 +++++- 12 files changed, 388 insertions(+), 77 deletions(-) diff --git a/tests/MongoDB.Driver.Tests/Specifications/versioned-api/tests/crud-api-version-1-strict.json b/tests/MongoDB.Driver.Tests/Specifications/versioned-api/tests/crud-api-version-1-strict.json index 2f811283488..2705b505a89 100644 --- a/tests/MongoDB.Driver.Tests/Specifications/versioned-api/tests/crud-api-version-1-strict.json +++ b/tests/MongoDB.Driver.Tests/Specifications/versioned-api/tests/crud-api-version-1-strict.json @@ -3,7 +3,7 @@ "schemaVersion": "1.1", "runOnRequirements": [ { - "minServerVersion": "4.7" + "minServerVersion": "4.9" } ], "createEntities": [ @@ -608,12 +608,6 @@ }, { "description": "estimatedDocumentCount appends declared API version", - "skipReason": "DRIVERS-1561 collStats is not in API version 1", - "runOnRequirements": [ - { - "minServerVersion": "4.9.0" - } - ], "operations": [ { "name": "estimatedDocumentCount", diff --git a/tests/MongoDB.Driver.Tests/Specifications/versioned-api/tests/crud-api-version-1-strict.yml b/tests/MongoDB.Driver.Tests/Specifications/versioned-api/tests/crud-api-version-1-strict.yml index 6c3aa79a09b..83b72f756a0 100644 --- a/tests/MongoDB.Driver.Tests/Specifications/versioned-api/tests/crud-api-version-1-strict.yml +++ b/tests/MongoDB.Driver.Tests/Specifications/versioned-api/tests/crud-api-version-1-strict.yml @@ -3,7 +3,7 @@ description: "CRUD Api Version 1 (strict)" schemaVersion: "1.1" runOnRequirements: - - minServerVersion: "4.7" + - minServerVersion: "4.9" createEntities: - client: @@ -225,9 +225,6 @@ tests: <<: *expectedApiVersion - description: "estimatedDocumentCount appends declared API version" - skipReason: "DRIVERS-1561 collStats is not in API version 1" - runOnRequirements: - - minServerVersion: "4.9.0" # $collStats is not used in estimatedDocumentCount on < 4.9 operations: - name: estimatedDocumentCount object: *collection diff --git a/tests/MongoDB.Driver.Tests/Specifications/versioned-api/tests/crud-api-version-1.json b/tests/MongoDB.Driver.Tests/Specifications/versioned-api/tests/crud-api-version-1.json index 4605a41ae71..91718583762 100644 --- a/tests/MongoDB.Driver.Tests/Specifications/versioned-api/tests/crud-api-version-1.json +++ b/tests/MongoDB.Driver.Tests/Specifications/versioned-api/tests/crud-api-version-1.json @@ -3,7 +3,7 @@ "schemaVersion": "1.1", "runOnRequirements": [ { - "minServerVersion": "4.7" + "minServerVersion": "4.9" } ], "createEntities": [ @@ -598,47 +598,8 @@ } ] }, - { - "description": "estimatedDocumentCount appends declared API version on less than 4.9.0", - "runOnRequirements": [ - { - "maxServerVersion": "4.8.99" - } - ], - "operations": [ - { - "name": "estimatedDocumentCount", - "object": "collection", - "arguments": {} - } - ], - "expectEvents": [ - { - "client": "client", - "events": [ - { - "commandStartedEvent": { - "command": { - "count": "test", - "apiVersion": "1", - "apiStrict": { - "$$unsetOrMatches": false - }, - "apiDeprecationErrors": true - } - } - } - ] - } - ] - }, { "description": "estimatedDocumentCount appends declared API version on 4.9.0 or greater", - "runOnRequirements": [ - { - "minServerVersion": "4.9.0" - } - ], "operations": [ { "name": "estimatedDocumentCount", diff --git a/tests/MongoDB.Driver.Tests/Specifications/versioned-api/tests/crud-api-version-1.yml b/tests/MongoDB.Driver.Tests/Specifications/versioned-api/tests/crud-api-version-1.yml index 31ab93dd935..3c72e079def 100644 --- a/tests/MongoDB.Driver.Tests/Specifications/versioned-api/tests/crud-api-version-1.yml +++ b/tests/MongoDB.Driver.Tests/Specifications/versioned-api/tests/crud-api-version-1.yml @@ -3,7 +3,7 @@ description: "CRUD Api Version 1" schemaVersion: "1.1" runOnRequirements: - - minServerVersion: "4.7" + - minServerVersion: "4.9" createEntities: - client: @@ -218,24 +218,7 @@ tests: key: x <<: *expectedApiVersion - - description: "estimatedDocumentCount appends declared API version on less than 4.9.0" - runOnRequirements: - - maxServerVersion: "4.8.99" - operations: - - name: estimatedDocumentCount - object: *collection - arguments: {} - expectEvents: - - client: *client - events: - - commandStartedEvent: - command: - count: *collectionName - <<: *expectedApiVersion - - description: "estimatedDocumentCount appends declared API version on 4.9.0 or greater" - runOnRequirements: - - minServerVersion: "4.9.0" operations: - name: estimatedDocumentCount object: *collection diff --git a/tests/MongoDB.Driver.Tests/Specifications/versioned-api/tests/runcommand-helper-no-api-version-declared.json b/tests/MongoDB.Driver.Tests/Specifications/versioned-api/tests/runcommand-helper-no-api-version-declared.json index 65c24ef4604..e901887e4c2 100644 --- a/tests/MongoDB.Driver.Tests/Specifications/versioned-api/tests/runcommand-helper-no-api-version-declared.json +++ b/tests/MongoDB.Driver.Tests/Specifications/versioned-api/tests/runcommand-helper-no-api-version-declared.json @@ -3,7 +3,7 @@ "schemaVersion": "1.1", "runOnRequirements": [ { - "minServerVersion": "4.7", + "minServerVersion": "4.9", "serverParameters": { "requireApiVersion": false } diff --git a/tests/MongoDB.Driver.Tests/Specifications/versioned-api/tests/runcommand-helper-no-api-version-declared.yml b/tests/MongoDB.Driver.Tests/Specifications/versioned-api/tests/runcommand-helper-no-api-version-declared.yml index dc31897e2e0..c735a32a3c4 100644 --- a/tests/MongoDB.Driver.Tests/Specifications/versioned-api/tests/runcommand-helper-no-api-version-declared.yml +++ b/tests/MongoDB.Driver.Tests/Specifications/versioned-api/tests/runcommand-helper-no-api-version-declared.yml @@ -3,7 +3,7 @@ description: "RunCommand helper: No API version declared" schemaVersion: "1.1" runOnRequirements: - - minServerVersion: "4.7" + - minServerVersion: "4.9" serverParameters: requireApiVersion: false diff --git a/tests/MongoDB.Driver.Tests/Specifications/versioned-api/tests/test-commands-deprecation-errors.json b/tests/MongoDB.Driver.Tests/Specifications/versioned-api/tests/test-commands-deprecation-errors.json index bdbc3f92ce0..6dc59a045cc 100644 --- a/tests/MongoDB.Driver.Tests/Specifications/versioned-api/tests/test-commands-deprecation-errors.json +++ b/tests/MongoDB.Driver.Tests/Specifications/versioned-api/tests/test-commands-deprecation-errors.json @@ -3,7 +3,7 @@ "schemaVersion": "1.1", "runOnRequirements": [ { - "minServerVersion": "4.7", + "minServerVersion": "4.9", "serverParameters": { "enableTestCommands": true, "acceptAPIVersion2": true, diff --git a/tests/MongoDB.Driver.Tests/Specifications/versioned-api/tests/test-commands-deprecation-errors.yml b/tests/MongoDB.Driver.Tests/Specifications/versioned-api/tests/test-commands-deprecation-errors.yml index 74a4c1044b0..c6b0a0027f9 100644 --- a/tests/MongoDB.Driver.Tests/Specifications/versioned-api/tests/test-commands-deprecation-errors.yml +++ b/tests/MongoDB.Driver.Tests/Specifications/versioned-api/tests/test-commands-deprecation-errors.yml @@ -3,7 +3,7 @@ description: "Test commands: deprecation errors" schemaVersion: "1.1" runOnRequirements: - - minServerVersion: "4.7" + - minServerVersion: "4.9" serverParameters: enableTestCommands: true acceptAPIVersion2: true diff --git a/tests/MongoDB.Driver.Tests/Specifications/versioned-api/tests/test-commands-strict-mode.json b/tests/MongoDB.Driver.Tests/Specifications/versioned-api/tests/test-commands-strict-mode.json index ebace443198..1705ba7bfff 100644 --- a/tests/MongoDB.Driver.Tests/Specifications/versioned-api/tests/test-commands-strict-mode.json +++ b/tests/MongoDB.Driver.Tests/Specifications/versioned-api/tests/test-commands-strict-mode.json @@ -3,7 +3,7 @@ "schemaVersion": "1.1", "runOnRequirements": [ { - "minServerVersion": "4.7", + "minServerVersion": "4.9", "serverParameters": { "enableTestCommands": true } diff --git a/tests/MongoDB.Driver.Tests/Specifications/versioned-api/tests/test-commands-strict-mode.yml b/tests/MongoDB.Driver.Tests/Specifications/versioned-api/tests/test-commands-strict-mode.yml index a34c7bf6a46..d7c2c15641b 100644 --- a/tests/MongoDB.Driver.Tests/Specifications/versioned-api/tests/test-commands-strict-mode.yml +++ b/tests/MongoDB.Driver.Tests/Specifications/versioned-api/tests/test-commands-strict-mode.yml @@ -3,7 +3,7 @@ description: "Test commands: strict mode" schemaVersion: "1.1" runOnRequirements: - - minServerVersion: "4.7" + - minServerVersion: "4.9" serverParameters: enableTestCommands: true diff --git a/tests/MongoDB.Driver.Tests/Specifications/versioned-api/tests/transaction-handling.json b/tests/MongoDB.Driver.Tests/Specifications/versioned-api/tests/transaction-handling.json index 313135c4bfc..a740405d3a8 100644 --- a/tests/MongoDB.Driver.Tests/Specifications/versioned-api/tests/transaction-handling.json +++ b/tests/MongoDB.Driver.Tests/Specifications/versioned-api/tests/transaction-handling.json @@ -3,7 +3,7 @@ "schemaVersion": "1.1", "runOnRequirements": [ { - "minServerVersion": "4.7", + "minServerVersion": "4.9", "topologies": [ "replicaset", "sharded-replicaset" @@ -227,6 +227,293 @@ ] } ] + }, + { + "description": "Committing a transaction twice does not append server API options", + "runOnRequirements": [ + { + "topologies": [ + "replicaset", + "sharded-replicaset" + ] + } + ], + "operations": [ + { + "name": "startTransaction", + "object": "session" + }, + { + "name": "insertOne", + "object": "collection", + "arguments": { + "session": "session", + "document": { + "_id": 6, + "x": 66 + } + }, + "expectResult": { + "$$unsetOrMatches": { + "insertedId": { + "$$unsetOrMatches": 6 + } + } + } + }, + { + "name": "insertOne", + "object": "collection", + "arguments": { + "session": "session", + "document": { + "_id": 7, + "x": 77 + } + }, + "expectResult": { + "$$unsetOrMatches": { + "insertedId": { + "$$unsetOrMatches": 7 + } + } + } + }, + { + "name": "commitTransaction", + "object": "session" + }, + { + "name": "commitTransaction", + "object": "session" + } + ], + "expectEvents": [ + { + "client": "client", + "events": [ + { + "commandStartedEvent": { + "command": { + "insert": "test", + "documents": [ + { + "_id": 6, + "x": 66 + } + ], + "lsid": { + "$$sessionLsid": "session" + }, + "startTransaction": true, + "apiVersion": "1", + "apiStrict": { + "$$unsetOrMatches": false + }, + "apiDeprecationErrors": { + "$$unsetOrMatches": false + } + } + } + }, + { + "commandStartedEvent": { + "command": { + "insert": "test", + "documents": [ + { + "_id": 7, + "x": 77 + } + ], + "lsid": { + "$$sessionLsid": "session" + }, + "apiVersion": { + "$$exists": false + }, + "apiStrict": { + "$$exists": false + }, + "apiDeprecationErrors": { + "$$exists": false + } + } + } + }, + { + "commandStartedEvent": { + "command": { + "commitTransaction": 1, + "lsid": { + "$$sessionLsid": "session" + }, + "apiVersion": { + "$$exists": false + }, + "apiStrict": { + "$$exists": false + }, + "apiDeprecationErrors": { + "$$exists": false + } + } + } + }, + { + "commandStartedEvent": { + "command": { + "commitTransaction": 1, + "lsid": { + "$$sessionLsid": "session" + }, + "apiVersion": { + "$$exists": false + }, + "apiStrict": { + "$$exists": false + }, + "apiDeprecationErrors": { + "$$exists": false + } + } + } + } + ] + } + ] + }, + { + "description": "abortTransaction does not include an API version", + "runOnRequirements": [ + { + "topologies": [ + "replicaset", + "sharded-replicaset" + ] + } + ], + "operations": [ + { + "name": "startTransaction", + "object": "session" + }, + { + "name": "insertOne", + "object": "collection", + "arguments": { + "session": "session", + "document": { + "_id": 6, + "x": 66 + } + }, + "expectResult": { + "$$unsetOrMatches": { + "insertedId": { + "$$unsetOrMatches": 6 + } + } + } + }, + { + "name": "insertOne", + "object": "collection", + "arguments": { + "session": "session", + "document": { + "_id": 7, + "x": 77 + } + }, + "expectResult": { + "$$unsetOrMatches": { + "insertedId": { + "$$unsetOrMatches": 7 + } + } + } + }, + { + "name": "abortTransaction", + "object": "session" + } + ], + "expectEvents": [ + { + "client": "client", + "events": [ + { + "commandStartedEvent": { + "command": { + "insert": "test", + "documents": [ + { + "_id": 6, + "x": 66 + } + ], + "lsid": { + "$$sessionLsid": "session" + }, + "startTransaction": true, + "apiVersion": "1", + "apiStrict": { + "$$unsetOrMatches": false + }, + "apiDeprecationErrors": { + "$$unsetOrMatches": false + } + } + } + }, + { + "commandStartedEvent": { + "command": { + "insert": "test", + "documents": [ + { + "_id": 7, + "x": 77 + } + ], + "lsid": { + "$$sessionLsid": "session" + }, + "apiVersion": { + "$$exists": false + }, + "apiStrict": { + "$$exists": false + }, + "apiDeprecationErrors": { + "$$exists": false + } + } + } + }, + { + "commandStartedEvent": { + "command": { + "abortTransaction": 1, + "lsid": { + "$$sessionLsid": "session" + }, + "apiVersion": { + "$$exists": false + }, + "apiStrict": { + "$$exists": false + }, + "apiDeprecationErrors": { + "$$exists": false + } + } + } + } + ] + } + ] } ] } diff --git a/tests/MongoDB.Driver.Tests/Specifications/versioned-api/tests/transaction-handling.yml b/tests/MongoDB.Driver.Tests/Specifications/versioned-api/tests/transaction-handling.yml index 276c22e7f6a..bd4fe850565 100644 --- a/tests/MongoDB.Driver.Tests/Specifications/versioned-api/tests/transaction-handling.yml +++ b/tests/MongoDB.Driver.Tests/Specifications/versioned-api/tests/transaction-handling.yml @@ -3,7 +3,7 @@ description: "Transaction handling" schemaVersion: "1.1" runOnRequirements: - - minServerVersion: "4.7" + - minServerVersion: "4.9" topologies: [ replicaset, sharded-replicaset ] createEntities: @@ -89,3 +89,92 @@ tests: commitTransaction: 1 lsid: { $$sessionLsid: *session } <<: *noApiVersion + - description: "Committing a transaction twice does not append server API options" + runOnRequirements: + - topologies: [ replicaset, sharded-replicaset ] + operations: + - name: startTransaction + object: *session + - name: insertOne + object: *collection + arguments: + session: *session + document: { _id: 6, x: 66 } + expectResult: { $$unsetOrMatches: { insertedId: { $$unsetOrMatches: 6 } } } + - name: insertOne + object: *collection + arguments: + session: *session + document: { _id: 7, x: 77 } + expectResult: { $$unsetOrMatches: { insertedId: { $$unsetOrMatches: 7 } } } + - name: commitTransaction + object: *session + - name: commitTransaction + object: *session + expectEvents: + - client: *client + events: + - commandStartedEvent: + command: + insert: *collectionName + documents: [ { _id: 6, x: 66 } ] + lsid: { $$sessionLsid: *session } + startTransaction: true + <<: *expectedApiVersion + - commandStartedEvent: + command: + insert: *collectionName + documents: [ { _id: 7, x: 77 } ] + lsid: { $$sessionLsid: *session } + <<: *noApiVersion + - commandStartedEvent: + command: + commitTransaction: 1 + lsid: { $$sessionLsid: *session } + <<: *noApiVersion + - commandStartedEvent: + command: + commitTransaction: 1 + lsid: { $$sessionLsid: *session } + <<: *noApiVersion + - description: "abortTransaction does not include an API version" + runOnRequirements: + - topologies: [ replicaset, sharded-replicaset ] + operations: + - name: startTransaction + object: *session + - name: insertOne + object: *collection + arguments: + session: *session + document: { _id: 6, x: 66 } + expectResult: { $$unsetOrMatches: { insertedId: { $$unsetOrMatches: 6 } } } + - name: insertOne + object: *collection + arguments: + session: *session + document: { _id: 7, x: 77 } + expectResult: { $$unsetOrMatches: { insertedId: { $$unsetOrMatches: 7 } } } + - name: abortTransaction + object: *session + expectEvents: + - client: *client + events: + - commandStartedEvent: + command: + insert: *collectionName + documents: [ { _id: 6, x: 66 } ] + lsid: { $$sessionLsid: *session } + startTransaction: true + <<: *expectedApiVersion + - commandStartedEvent: + command: + insert: *collectionName + documents: [ { _id: 7, x: 77 } ] + lsid: { $$sessionLsid: *session } + <<: *noApiVersion + - commandStartedEvent: + command: + abortTransaction: 1 + lsid: { $$sessionLsid: *session } + <<: *noApiVersion