Skip to content
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

DRIVERS-776: Splits tests to work around SERVER-57403 #1013

Merged
merged 1 commit into from
Jun 7, 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
103 changes: 103 additions & 0 deletions source/crud/tests/unified/aggregate-let.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,109 @@
"minServerVersion": "5.0"
}
],
"operations": [
{
"name": "aggregate",
"object": "collection0",
"arguments": {
"pipeline": [
{
"$match": {
"$expr": {
"$eq": [
"$_id",
"$$id"
]
}
}
},
{
"$project": {
"_id": 0,
"x": "$$x",
"y": "$$y",
"rand": "$$rand"
}
}
],
"let": {
"id": 1,
"x": "foo",
"y": {
"$literal": "bar"
},
"rand": {
"$rand": {}
}
}
},
"expectResult": [
{
"x": "foo",
"y": "bar",
"rand": {
"$$type": "double"
}
}
]
}
],
"expectEvents": [
{
"client": "client0",
"events": [
{
"commandStartedEvent": {
"command": {
"aggregate": "coll0",
"pipeline": [
{
"$match": {
"$expr": {
"$eq": [
"$_id",
"$$id"
]
}
}
},
{
"$project": {
"_id": 0,
"x": "$$x",
"y": "$$y",
"rand": "$$rand"
}
}
],
"let": {
"id": 1,
"x": "foo",
"y": {
"$literal": "bar"
},
"rand": {
"$rand": {}
}
}
}
}
}
]
}
]
},
{
"description": "Aggregate with let option and dollar-prefixed $literal value",
"runOnRequirements": [
{
"minServerVersion": "5.0",
"topologies": [
"single",
"replicaset"
]
}
],
"operations": [
{
"name": "aggregate",
Expand Down
36 changes: 36 additions & 0 deletions source/crud/tests/unified/aggregate-let.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,45 @@ initialData: &initialData
- { _id: 1 }

tests:
# TODO: Once SERVER-57403 is resolved, this test can be removed in favor of
# the "dollar-prefixed $literal value" test below.
- description: "Aggregate with let option"
runOnRequirements:
- minServerVersion: "5.0"
operations:
- name: aggregate
object: *collection0
arguments:
pipeline: &pipeline0
# $match takes a query expression, so $expr is necessary to utilize
# an aggregate expression context and access "let" variables.
- $match: { $expr: { $eq: ["$_id", "$$id"] } }
- $project: { _id: 0, x: "$$x", y: "$$y", rand: "$$rand" }
# Values in "let" must be constant or closed expressions that do not
# depend on document values. This test demonstrates a basic constant
# value, a value wrapped with $literal (to avoid expression parsing),
# and a closed expression (e.g. $rand).
let: &let0
id: 1
x: foo
y: { $literal: "bar" }
rand: { $rand: {} }
expectResult:
- { x: "foo", y: "bar", rand: { $$type: "double" } }
expectEvents:
- client: *client0
events:
- commandStartedEvent:
command:
aggregate: *collection0Name
pipeline: *pipeline0
let: *let0

- description: "Aggregate with let option and dollar-prefixed $literal value"
runOnRequirements:
- minServerVersion: "5.0"
# TODO: Remove topology restrictions once SERVER-57403 is resolved
topologies: ["single", "replicaset"]
operations:
- name: aggregate
object: *collection0
Expand Down