Skip to content

DRIVERS-1603 Unified test format updates for serverless testing #944

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

Closed
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
8 changes: 7 additions & 1 deletion source/crud/tests/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,12 @@ Each YAML file has the following keys:
and "sharded". If this field is omitted, the default is all topologies (i.e.
``["single", "replicaset", "sharded"]``).

- ``serverless``: (optional) Whether or not the test should be run on
serverless instances imitating sharded clusters. Valid values are "require",
"forbid", and "allow". If "require", the test MUST only be run on serverless
instances. If "forbid", the test MUST NOT be run on Serverless instances. If
Copy link
Member

Choose a reason for hiding this comment

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

"Serverless" is still capitalized here.

omitted or "allow", this option has no effect.

- ``collection_name`` (optional): The collection to use for testing.

- ``database_name`` (optional): The database to use for testing.
Expand Down Expand Up @@ -338,4 +344,4 @@ Test that a writeConcernError "errInfo" is propagated to the user in whatever wa
},
"mode": { "times": 1 }
}
Then, perform an insert on the same database. Assert that an error occurs and that the "errInfo" is accessible and matches the one set in the failpoint.
Then, perform an insert on the same database. Assert that an error occurs and that the "errInfo" is accessible and matches the one set in the failpoint.
189 changes: 189 additions & 0 deletions source/crud/tests/unified/aggregate.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,189 @@
{
"description": "aggregate",
"schemaVersion": "1.0",
"createEntities": [
{
"client": {
"id": "client0",
"useMultipleMongoses": true,
"observeEvents": [
"commandStartedEvent"
]
}
},
{
"database": {
"id": "database0",
"client": "client0",
"databaseName": "aggregate-tests"
}
},
{
"collection": {
"id": "collection0",
"database": "database0",
"collectionName": "coll0"
}
}
],
"initialData": [
{
"collectionName": "coll0",
"databaseName": "aggregate-tests",
"documents": [
{
"_id": 1,
"x": 11
},
{
"_id": 2,
"x": 22
},
{
"_id": 3,
"x": 33
},
{
"_id": 4,
"x": 44
},
{
"_id": 5,
"x": 55
},
{
"_id": 6,
"x": 66
},
{
"_id": 7,
"x": 77
},
{
"_id": 8,
"x": 88
}
]
}
],
"tests": [
{
"description": "aggregate with multiple batches works",
"operations": [
{
"name": "aggregate",
"arguments": {
"pipeline": [
{
"$match": {
"_id": {
"$gt": 1
}
}
}
],
"batchSize": 2
},
"object": "collection0",
"expectResult": [
{
"_id": 2,
"x": 22
},
{
"_id": 3,
"x": 33
},
{
"_id": 4,
"x": 44
},
{
"_id": 5,
"x": 55
},
{
"_id": 6,
"x": 66
},
{
"_id": 7,
"x": 77
},
{
"_id": 8,
"x": 88
}
]
}
],
"expectEvents": [
{
"client": "client0",
"events": [
{
"commandStartedEvent": {
"command": {
"aggregate": "coll0",
"pipeline": [
{
"$match": {
"_id": {
"$gt": 1
}
}
}
],
"cursor": {
"batchSize": 2
}
},
"commandName": "aggregate",
"databaseName": "aggregate-tests"
}
},
{
"commandStartedEvent": {
"command": {
"getMore": {
"$$exists": true
},
"collection": "coll0",
"batchSize": 2
},
"commandName": "getMore",
"databaseName": "aggregate-tests"
}
},
{
"commandStartedEvent": {
"command": {
"getMore": {
"$$exists": true
},
"collection": "coll0",
"batchSize": 2
},
"commandName": "getMore",
"databaseName": "aggregate-tests"
}
},
{
"commandStartedEvent": {
"command": {
"getMore": {
"$$exists": true
},
"collection": "coll0",
"batchSize": 2
},
"commandName": "getMore",
"databaseName": "aggregate-tests"
}
}
]
}
]
}
]
}
79 changes: 79 additions & 0 deletions source/crud/tests/unified/aggregate.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
description: "aggregate"
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This and find.yml ensure that cursors work even with multiple batches (test required by scope).


schemaVersion: "1.0"

createEntities:
- client:
id: &client0 client0
useMultipleMongoses: true # ensure cursors pin to a single server
Copy link
Contributor

Choose a reason for hiding this comment

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

Oh good thinking!

observeEvents: [ commandStartedEvent ]
- database:
id: &database0 database0
client: *client0
databaseName: &database0Name aggregate-tests
- collection:
id: &collection0 collection0
database: *database0
collectionName: &collection0Name coll0

initialData:
- collectionName: *collection0Name
databaseName: *database0Name
documents:
- { _id: 1, x: 11 }
- { _id: 2, x: 22 }
- { _id: 3, x: 33 }
- { _id: 4, x: 44 }
- { _id: 5, x: 55 }
- { _id: 6, x: 66 }
- { _id: 7, x: 77 }
- { _id: 8, x: 88 }

tests:
- description: "aggregate with multiple batches works"
operations:
- name: aggregate
arguments:
pipeline: [ { $match: { _id: { $gt: 1 } }} ]
batchSize: 2
object: *collection0
expectResult:
- { _id: 2, x: 22 }
- { _id: 3, x: 33 }
- { _id: 4, x: 44 }
- { _id: 5, x: 55 }
- { _id: 6, x: 66 }
- { _id: 7, x: 77 }
- { _id: 8, x: 88 }
expectEvents:
- client: *client0
events:
- commandStartedEvent:
command:
aggregate: *collection0Name
pipeline: [ { $match: { _id: { $gt: 1 } }} ]
cursor: { batchSize: 2 }
commandName: aggregate
databaseName: *database0Name
- commandStartedEvent:
command:
getMore: { $$exists: true }
collection: *collection0Name
batchSize: 2
commandName: getMore
databaseName: *database0Name
- commandStartedEvent:
command:
getMore: { $$exists: true }
collection: *collection0Name
batchSize: 2
commandName: getMore
databaseName: *database0Name
- commandStartedEvent:
command:
getMore: { $$exists: true }
collection: *collection0Name
batchSize: 2
commandName: getMore
databaseName: *database0Name

17 changes: 11 additions & 6 deletions source/crud/tests/unified/estimatedDocumentCount.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"description": "estimatedDocumentCount",
"schemaVersion": "1.0",
"schemaVersion": "1.3",
"createEntities": [
{
"client": {
Expand Down Expand Up @@ -61,7 +61,8 @@
"description": "estimatedDocumentCount uses $collStats on 4.9.0 or greater",
"runOnRequirements": [
{
"minServerVersion": "4.9.0"
"minServerVersion": "4.9.0",
"serverless": "forbid"
}
],
"operations": [
Expand Down Expand Up @@ -107,7 +108,8 @@
"description": "estimatedDocumentCount with maxTimeMS on 4.9.0 or greater",
"runOnRequirements": [
{
"minServerVersion": "4.9.0"
"minServerVersion": "4.9.0",
"serverless": "forbid"
}
],
"operations": [
Expand Down Expand Up @@ -157,7 +159,8 @@
"description": "estimatedDocumentCount on non-existent collection on 4.9.0 or greater",
"runOnRequirements": [
{
"minServerVersion": "4.9.0"
"minServerVersion": "4.9.0",
"serverless": "forbid"
}
],
"operations": [
Expand Down Expand Up @@ -203,7 +206,8 @@
"description": "estimatedDocumentCount errors correctly on 4.9.0 or greater--command error",
"runOnRequirements": [
{
"minServerVersion": "4.9.0"
"minServerVersion": "4.9.0",
"serverless": "forbid"
}
],
"operations": [
Expand Down Expand Up @@ -270,7 +274,8 @@
"description": "estimatedDocumentCount errors correctly on 4.9.0 or greater--socket error",
"runOnRequirements": [
{
"minServerVersion": "4.9.0"
"minServerVersion": "4.9.0",
"serverless": "forbid"
}
],
"operations": [
Expand Down
7 changes: 6 additions & 1 deletion source/crud/tests/unified/estimatedDocumentCount.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
description: "estimatedDocumentCount"

schemaVersion: "1.0"
schemaVersion: "1.3"

createEntities:
- client:
Expand Down Expand Up @@ -34,6 +34,7 @@ tests:
- description: "estimatedDocumentCount uses $collStats on 4.9.0 or greater"
runOnRequirements:
- minServerVersion: "4.9.0"
serverless: forbid
Copy link
Contributor

Choose a reason for hiding this comment

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

Why is this forbidden? I think the new aggregation pipeline for estimatedDocumentCount would work against serverless.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

As discussed a little bit in slack, the proxy doesn't yet support count via $collStats yet (https://jira.mongodb.org/browse/CLOUDP-86318)

Copy link
Member

Choose a reason for hiding this comment

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

Is that intended to be addressed before public release?

Either way, I think this warrants a comment (as you did for db.aggregate) and maybe a reference to the issue number so we can come back to this later.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

operations:
- name: estimatedDocumentCount
object: *collection0
Expand All @@ -53,6 +54,7 @@ tests:
- description: "estimatedDocumentCount with maxTimeMS on 4.9.0 or greater"
runOnRequirements:
- minServerVersion: "4.9.0"
serverless: forbid
operations:
- name: estimatedDocumentCount
object: *collection0
Expand All @@ -75,6 +77,7 @@ tests:
- description: "estimatedDocumentCount on non-existent collection on 4.9.0 or greater"
runOnRequirements:
- minServerVersion: "4.9.0"
serverless: forbid
operations:
- name: estimatedDocumentCount
object: *collection1
Expand All @@ -94,6 +97,7 @@ tests:
- description: "estimatedDocumentCount errors correctly on 4.9.0 or greater--command error"
runOnRequirements:
- minServerVersion: "4.9.0"
serverless: forbid
operations:
- name: failPoint
object: testRunner
Expand Down Expand Up @@ -124,6 +128,7 @@ tests:
- description: "estimatedDocumentCount errors correctly on 4.9.0 or greater--socket error"
runOnRequirements:
- minServerVersion: "4.9.0"
serverless: forbid
operations:
- name: failPoint
object: testRunner
Expand Down
Loading