Skip to content

PYTHON-2482 Test Versioned API with a server started with acceptAPIVersion2 #545

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jan 14, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 15 additions & 5 deletions .evergreen/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1989,18 +1989,27 @@ axes:
test_pyopenssl: true
batchtime: 10080 # 7 days

- id: requireApiVersion
display_name: "requireApiVersion"
- id: versionedApi
display_name: "versionedApi"
values:
# Test against a cluster with requireApiVersion=1.
- id: "requireApiVersion1"
display_name: "requireApiVersion1"
tags: [ "requireApiVersion_tag" ]
tags: [ "versionedApi_tag" ]
variables:
# REQUIRE_API_VERSION is set to make drivers-evergreen-tools
# start a cluster with the requireApiVersion parameter.
REQUIRE_API_VERSION: "1"
# MONGODB_API_VERSION is the apiVersion to use in the test suite.
MONGODB_API_VERSION: "1"
# Test against a cluster with acceptAPIVersion2 but without
# requireApiVersion, and don't automatically add apiVersion to
# clients created in the test suite.
- id: "acceptAPIVersion2"
display_name: "acceptAPIVersion2"
tags: [ "versionedApi_tag" ]
variables:
ORCHESTRATION_FILE: "versioned-api-testing.json"
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I reworked this section slightly because in one case we want to test two different cases:

  • against a cluster with requireApiVersion=1 and with MONGODB_API_VERSION
  • against a cluster without requireApiVersion without MONGODB_API_VERSION but with acceptAPIVersion2.


buildvariants:
- matrix_name: "tests-all"
Expand Down Expand Up @@ -2533,8 +2542,9 @@ buildvariants:
platform: ubuntu-16.04
python-version: ["3.6", "3.9"]
auth: "auth"
requireApiVersion: "*"
display_name: "requireApiVersion ${python-version}"
versionedApi: "*"
display_name: "Versioned API ${versionedApi} ${python-version}"
batchtime: 10080 # 7 days
tasks:
# Versioned API was introduced in MongoDB 4.7
- "test-latest-standalone"
Expand Down
1 change: 1 addition & 0 deletions test/versioned-api/crud-api-version-1-strict.json
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@
},
{
"description": "aggregate on database appends declared API version",
"skipReason": "DRIVERS-1505 $listLocalSessions is not supported in API version 1",
"operations": [
{
"name": "aggregate",
Expand Down
3 changes: 2 additions & 1 deletion test/versioned-api/test-commands-deprecation-errors.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
"minServerVersion": "4.7",
"serverParameters": {
"enableTestCommands": true,
"acceptAPIVersion2": true
"acceptAPIVersion2": true,
"requireApiVersion": false
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was added in mongodb/specifications#893

}
}
],
Expand Down
156 changes: 156 additions & 0 deletions test/versioned-api/transaction-handling.json
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,162 @@
]
}
]
},
{
"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
}
}
}
}
]
}
]
}
]
}