Skip to content

Commit 9465cda

Browse files
authored
DRIVERS-776: Split tests to work around SERVER-57403 (#1013)
1 parent a274fbf commit 9465cda

File tree

2 files changed

+139
-0
lines changed

2 files changed

+139
-0
lines changed

source/crud/tests/unified/aggregate-let.json

Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,109 @@
4444
"minServerVersion": "5.0"
4545
}
4646
],
47+
"operations": [
48+
{
49+
"name": "aggregate",
50+
"object": "collection0",
51+
"arguments": {
52+
"pipeline": [
53+
{
54+
"$match": {
55+
"$expr": {
56+
"$eq": [
57+
"$_id",
58+
"$$id"
59+
]
60+
}
61+
}
62+
},
63+
{
64+
"$project": {
65+
"_id": 0,
66+
"x": "$$x",
67+
"y": "$$y",
68+
"rand": "$$rand"
69+
}
70+
}
71+
],
72+
"let": {
73+
"id": 1,
74+
"x": "foo",
75+
"y": {
76+
"$literal": "bar"
77+
},
78+
"rand": {
79+
"$rand": {}
80+
}
81+
}
82+
},
83+
"expectResult": [
84+
{
85+
"x": "foo",
86+
"y": "bar",
87+
"rand": {
88+
"$$type": "double"
89+
}
90+
}
91+
]
92+
}
93+
],
94+
"expectEvents": [
95+
{
96+
"client": "client0",
97+
"events": [
98+
{
99+
"commandStartedEvent": {
100+
"command": {
101+
"aggregate": "coll0",
102+
"pipeline": [
103+
{
104+
"$match": {
105+
"$expr": {
106+
"$eq": [
107+
"$_id",
108+
"$$id"
109+
]
110+
}
111+
}
112+
},
113+
{
114+
"$project": {
115+
"_id": 0,
116+
"x": "$$x",
117+
"y": "$$y",
118+
"rand": "$$rand"
119+
}
120+
}
121+
],
122+
"let": {
123+
"id": 1,
124+
"x": "foo",
125+
"y": {
126+
"$literal": "bar"
127+
},
128+
"rand": {
129+
"$rand": {}
130+
}
131+
}
132+
}
133+
}
134+
}
135+
]
136+
}
137+
]
138+
},
139+
{
140+
"description": "Aggregate with let option and dollar-prefixed $literal value",
141+
"runOnRequirements": [
142+
{
143+
"minServerVersion": "5.0",
144+
"topologies": [
145+
"single",
146+
"replicaset"
147+
]
148+
}
149+
],
47150
"operations": [
48151
{
49152
"name": "aggregate",

source/crud/tests/unified/aggregate-let.yml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,45 @@ initialData: &initialData
2222
- { _id: 1 }
2323

2424
tests:
25+
# TODO: Once SERVER-57403 is resolved, this test can be removed in favor of
26+
# the "dollar-prefixed $literal value" test below.
2527
- description: "Aggregate with let option"
2628
runOnRequirements:
2729
- minServerVersion: "5.0"
30+
operations:
31+
- name: aggregate
32+
object: *collection0
33+
arguments:
34+
pipeline: &pipeline0
35+
# $match takes a query expression, so $expr is necessary to utilize
36+
# an aggregate expression context and access "let" variables.
37+
- $match: { $expr: { $eq: ["$_id", "$$id"] } }
38+
- $project: { _id: 0, x: "$$x", y: "$$y", rand: "$$rand" }
39+
# Values in "let" must be constant or closed expressions that do not
40+
# depend on document values. This test demonstrates a basic constant
41+
# value, a value wrapped with $literal (to avoid expression parsing),
42+
# and a closed expression (e.g. $rand).
43+
let: &let0
44+
id: 1
45+
x: foo
46+
y: { $literal: "bar" }
47+
rand: { $rand: {} }
48+
expectResult:
49+
- { x: "foo", y: "bar", rand: { $$type: "double" } }
50+
expectEvents:
51+
- client: *client0
52+
events:
53+
- commandStartedEvent:
54+
command:
55+
aggregate: *collection0Name
56+
pipeline: *pipeline0
57+
let: *let0
58+
59+
- description: "Aggregate with let option and dollar-prefixed $literal value"
60+
runOnRequirements:
61+
- minServerVersion: "5.0"
62+
# TODO: Remove topology restrictions once SERVER-57403 is resolved
63+
topologies: ["single", "replicaset"]
2864
operations:
2965
- name: aggregate
3066
object: *collection0

0 commit comments

Comments
 (0)