Skip to content

RUST-768 Pass versioned API parameters to getMore and transaction-continuing commands. #397

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 5 commits into from
Jul 20, 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
4 changes: 0 additions & 4 deletions src/cmap/conn/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,6 @@ impl Command {
}

pub(crate) fn set_server_api(&mut self, server_api: &ServerApi) {
if matches!(self.name.as_str(), "getMore") {
return;
}

self.body
.insert("apiVersion", format!("{}", server_api.version));

Expand Down
2 changes: 1 addition & 1 deletion src/test/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ mod spec;
mod util;

pub(crate) use self::{
spec::{run_single_test, run_spec_test, RunOn, Serverless, Topology},
spec::{run_single_test, run_spec_test, run_spec_test_with_path, RunOn, Serverless, Topology},
util::{
assert_matches,
CmapEvent,
Expand Down
4 changes: 2 additions & 2 deletions src/test/spec/json/versioned-api/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,5 @@ To run this test, proceed as follows:
- If the environment variable is set, all clients created in tests MUST declare
the ``ServerApiVersion`` specified.

No other topologies must be tested until ``mongo-orchestration`` can handle
servers with ``requireApiVersion`` enabled.
Only standalone servers must be tested. The tests should run for each server
version >= 5.0, including ``latest``.
19 changes: 10 additions & 9 deletions src/test/spec/json/versioned-api/crud-api-version-1-strict.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"description": "CRUD Api Version 1 (strict)",
"schemaVersion": "1.1",
"schemaVersion": "1.4",
"runOnRequirements": [
{
"minServerVersion": "4.9"
Expand Down Expand Up @@ -141,6 +141,11 @@
},
{
"description": "aggregate on database appends declared API version",
"runOnRequirements": [
{
"serverless": "forbid"
}
],
"operations": [
{
"name": "aggregate",
Expand Down Expand Up @@ -651,7 +656,7 @@
]
},
{
"description": "find command with declared API version appends to the command, but getMore does not",
"description": "find and getMore append API version",
"operations": [
{
"name": "find",
Expand Down Expand Up @@ -712,14 +717,10 @@
"long"
]
},
"apiVersion": {
"$$exists": false
},
"apiStrict": {
"$$exists": false
},
"apiVersion": "1",
"apiStrict": true,
"apiDeprecationErrors": {
"$$exists": false
"$$unsetOrMatches": false
}
}
}
Expand Down
12 changes: 7 additions & 5 deletions src/test/spec/json/versioned-api/crud-api-version-1-strict.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
description: "CRUD Api Version 1 (strict)"

schemaVersion: "1.1"
schemaVersion: "1.4"

runOnRequirements:
- minServerVersion: "4.9"
Expand Down Expand Up @@ -62,6 +62,10 @@ tests:
<<: *expectedApiVersion

- description: "aggregate on database appends declared API version"
runOnRequirements:
# serverless does not support either of the current database-level aggregation stages ($listLocalSessions and
# $currentOp)
- serverless: "forbid"
operations:
- name: aggregate
object: *adminDatabase
Expand Down Expand Up @@ -240,7 +244,7 @@ tests:
- $group: { _id: 1, n: { $sum: $count }}
<<: *expectedApiVersion

- description: "find command with declared API version appends to the command, but getMore does not"
- description: "find and getMore append API version"
operations:
- name: find
object: *collection
Expand All @@ -264,9 +268,7 @@ tests:
- commandStartedEvent:
command:
getMore: { $$type: [ int, long ] }
apiVersion: { $$exists: false }
apiStrict: { $$exists: false }
apiDeprecationErrors: { $$exists: false }
<<: *expectedApiVersion

- description: "findOneAndDelete appends declared API version"
operations:
Expand Down
19 changes: 10 additions & 9 deletions src/test/spec/json/versioned-api/crud-api-version-1.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"description": "CRUD Api Version 1",
"schemaVersion": "1.1",
"schemaVersion": "1.4",
"runOnRequirements": [
{
"minServerVersion": "4.9"
Expand Down Expand Up @@ -141,6 +141,11 @@
},
{
"description": "aggregate on database appends declared API version",
"runOnRequirements": [
{
"serverless": "forbid"
}
],
"operations": [
{
"name": "aggregate",
Expand Down Expand Up @@ -643,7 +648,7 @@
]
},
{
"description": "find command with declared API version appends to the command, but getMore does not",
"description": "find and getMore append API version",
"operations": [
{
"name": "find",
Expand Down Expand Up @@ -704,15 +709,11 @@
"long"
]
},
"apiVersion": {
"$$exists": false
},
"apiVersion": "1",
"apiStrict": {
"$$exists": false
"$$unsetOrMatches": false
},
"apiDeprecationErrors": {
"$$exists": false
}
"apiDeprecationErrors": true
}
}
}
Expand Down
12 changes: 7 additions & 5 deletions src/test/spec/json/versioned-api/crud-api-version-1.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
description: "CRUD Api Version 1"

schemaVersion: "1.1"
schemaVersion: "1.4"

runOnRequirements:
- minServerVersion: "4.9"
Expand Down Expand Up @@ -64,6 +64,10 @@ tests:
<<: *expectedApiVersion

- description: "aggregate on database appends declared API version"
runOnRequirements:
# serverless does not support either of the current database-level aggregation stages ($listLocalSessions and
# $currentOp)
- serverless: forbid
operations:
- name: aggregate
object: *adminDatabase
Expand Down Expand Up @@ -234,7 +238,7 @@ tests:
- $group: { _id: 1, n: { $sum: $count }}
<<: *expectedApiVersion

- description: "find command with declared API version appends to the command, but getMore does not"
- description: "find and getMore append API version"
operations:
- name: find
object: *collection
Expand All @@ -258,9 +262,7 @@ tests:
- commandStartedEvent:
command:
getMore: { $$type: [ int, long ] }
apiVersion: { $$exists: false }
apiStrict: { $$exists: false }
apiDeprecationErrors: { $$exists: false }
<<: *expectedApiVersion

- description: "findOneAndDelete appends declared API version"
operations:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"description": "RunCommand helper: No API version declared",
"schemaVersion": "1.1",
"schemaVersion": "1.4",
"runOnRequirements": [
{
"minServerVersion": "4.9",
Expand Down Expand Up @@ -29,6 +29,11 @@
"tests": [
{
"description": "runCommand does not inspect or change the command document",
"runOnRequirements": [
{
"serverless": "forbid"
}
],
"operations": [
{
"name": "runCommand",
Expand Down Expand Up @@ -72,6 +77,11 @@
},
{
"description": "runCommand does not prevent sending invalid API version declarations",
"runOnRequirements": [
{
"serverless": "forbid"
}
],
"operations": [
{
"name": "runCommand",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
description: "RunCommand helper: No API version declared"

schemaVersion: "1.1"
schemaVersion: "1.4"

runOnRequirements:
- minServerVersion: "4.9"
Expand All @@ -19,6 +19,10 @@ createEntities:

tests:
- description: "runCommand does not inspect or change the command document"
runOnRequirements:
# serverless does not currently reject invalid API versions on
# certain commands (CLOUDP-87926)
- serverless: "forbid"
operations:
- name: runCommand
object: *database
Expand All @@ -43,6 +47,10 @@ tests:
databaseName: *databaseName

- description: "runCommand does not prevent sending invalid API version declarations"
runOnRequirements:
# serverless does not currently reject invalid API versions on
# certain commands (CLOUDP-87926)
- serverless: "forbid"
operations:
- name: runCommand
object: *database
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
{
"description": "Test commands: strict mode",
"schemaVersion": "1.1",
"schemaVersion": "1.4",
"runOnRequirements": [
{
"minServerVersion": "4.9",
"serverParameters": {
"enableTestCommands": true
}
},
"serverless": "forbid"
}
],
"createEntities": [
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
description: "Test commands: strict mode"

schemaVersion: "1.1"
schemaVersion: "1.4"

runOnRequirements:
- minServerVersion: "4.9"
serverParameters:
enableTestCommands: true
# serverless gives a different error for unrecognized testVersion2 command
serverless: "forbid"

createEntities:
- client:
Expand Down
Loading