1{
2 "description": "aggregate-write-readPreference",
3 "schemaVersion": "1.4",
4 "runOnRequirements": [
5 {
6 "minServerVersion": "3.6",
7 "topologies": [
8 "replicaset",
9 "sharded",
10 "load-balanced"
11 ]
12 }
13 ],
14 "_yamlAnchors": {
15 "readConcern": {
16 "level": "local"
17 },
18 "writeConcern": {
19 "w": 1
20 }
21 },
22 "createEntities": [
23 {
24 "client": {
25 "id": "client0",
26 "observeEvents": [
27 "commandStartedEvent"
28 ],
29 "uriOptions": {
30 "readConcernLevel": "local",
31 "w": 1
32 }
33 }
34 },
35 {
36 "database": {
37 "id": "database0",
38 "client": "client0",
39 "databaseName": "db0"
40 }
41 },
42 {
43 "collection": {
44 "id": "collection0",
45 "database": "database0",
46 "collectionName": "coll0",
47 "collectionOptions": {
48 "readPreference": {
49 "mode": "secondaryPreferred",
50 "maxStalenessSeconds": 600
51 }
52 }
53 }
54 },
55 {
56 "collection": {
57 "id": "collection1",
58 "database": "database0",
59 "collectionName": "coll1"
60 }
61 }
62 ],
63 "initialData": [
64 {
65 "collectionName": "coll0",
66 "databaseName": "db0",
67 "documents": [
68 {
69 "_id": 1,
70 "x": 11
71 },
72 {
73 "_id": 2,
74 "x": 22
75 },
76 {
77 "_id": 3,
78 "x": 33
79 }
80 ]
81 },
82 {
83 "collectionName": "coll1",
84 "databaseName": "db0",
85 "documents": []
86 }
87 ],
88 "tests": [
89 {
90 "description": "Aggregate with $out includes read preference for 5.0+ server",
91 "runOnRequirements": [
92 {
93 "minServerVersion": "5.0",
94 "serverless": "forbid"
95 }
96 ],
97 "operations": [
98 {
99 "object": "collection0",
100 "name": "aggregate",
101 "arguments": {
102 "pipeline": [
103 {
104 "$match": {
105 "_id": {
106 "$gt": 1
107 }
108 }
109 },
110 {
111 "$sort": {
112 "x": 1
113 }
114 },
115 {
116 "$out": "coll1"
117 }
118 ]
119 }
120 }
121 ],
122 "expectEvents": [
123 {
124 "client": "client0",
125 "events": [
126 {
127 "commandStartedEvent": {
128 "command": {
129 "aggregate": "coll0",
130 "pipeline": [
131 {
132 "$match": {
133 "_id": {
134 "$gt": 1
135 }
136 }
137 },
138 {
139 "$sort": {
140 "x": 1
141 }
142 },
143 {
144 "$out": "coll1"
145 }
146 ],
147 "$readPreference": {
148 "mode": "secondaryPreferred",
149 "maxStalenessSeconds": 600
150 },
151 "readConcern": {
152 "level": "local"
153 },
154 "writeConcern": {
155 "w": 1
156 }
157 }
158 }
159 }
160 ]
161 }
162 ],
163 "outcome": [
164 {
165 "collectionName": "coll1",
166 "databaseName": "db0",
167 "documents": [
168 {
169 "_id": 2,
170 "x": 22
171 },
172 {
173 "_id": 3,
174 "x": 33
175 }
176 ]
177 }
178 ]
179 },
180 {
181 "description": "Aggregate with $out omits read preference for pre-5.0 server",
182 "runOnRequirements": [
183 {
184 "minServerVersion": "4.2",
185 "maxServerVersion": "4.4.99",
186 "serverless": "forbid"
187 }
188 ],
189 "operations": [
190 {
191 "object": "collection0",
192 "name": "aggregate",
193 "arguments": {
194 "pipeline": [
195 {
196 "$match": {
197 "_id": {
198 "$gt": 1
199 }
200 }
201 },
202 {
203 "$sort": {
204 "x": 1
205 }
206 },
207 {
208 "$out": "coll1"
209 }
210 ]
211 }
212 }
213 ],
214 "expectEvents": [
215 {
216 "client": "client0",
217 "events": [
218 {
219 "commandStartedEvent": {
220 "command": {
221 "aggregate": "coll0",
222 "pipeline": [
223 {
224 "$match": {
225 "_id": {
226 "$gt": 1
227 }
228 }
229 },
230 {
231 "$sort": {
232 "x": 1
233 }
234 },
235 {
236 "$out": "coll1"
237 }
238 ],
239 "$readPreference": {
240 "$$exists": false
241 },
242 "readConcern": {
243 "level": "local"
244 },
245 "writeConcern": {
246 "w": 1
247 }
248 }
249 }
250 }
251 ]
252 }
253 ],
254 "outcome": [
255 {
256 "collectionName": "coll1",
257 "databaseName": "db0",
258 "documents": [
259 {
260 "_id": 2,
261 "x": 22
262 },
263 {
264 "_id": 3,
265 "x": 33
266 }
267 ]
268 }
269 ]
270 },
271 {
272 "description": "Aggregate with $merge includes read preference for 5.0+ server",
273 "runOnRequirements": [
274 {
275 "minServerVersion": "5.0"
276 }
277 ],
278 "operations": [
279 {
280 "object": "collection0",
281 "name": "aggregate",
282 "arguments": {
283 "pipeline": [
284 {
285 "$match": {
286 "_id": {
287 "$gt": 1
288 }
289 }
290 },
291 {
292 "$sort": {
293 "x": 1
294 }
295 },
296 {
297 "$merge": {
298 "into": "coll1"
299 }
300 }
301 ]
302 }
303 }
304 ],
305 "expectEvents": [
306 {
307 "client": "client0",
308 "events": [
309 {
310 "commandStartedEvent": {
311 "command": {
312 "aggregate": "coll0",
313 "pipeline": [
314 {
315 "$match": {
316 "_id": {
317 "$gt": 1
318 }
319 }
320 },
321 {
322 "$sort": {
323 "x": 1
324 }
325 },
326 {
327 "$merge": {
328 "into": "coll1"
329 }
330 }
331 ],
332 "$readPreference": {
333 "mode": "secondaryPreferred",
334 "maxStalenessSeconds": 600
335 },
336 "readConcern": {
337 "level": "local"
338 },
339 "writeConcern": {
340 "w": 1
341 }
342 }
343 }
344 }
345 ]
346 }
347 ],
348 "outcome": [
349 {
350 "collectionName": "coll1",
351 "databaseName": "db0",
352 "documents": [
353 {
354 "_id": 2,
355 "x": 22
356 },
357 {
358 "_id": 3,
359 "x": 33
360 }
361 ]
362 }
363 ]
364 },
365 {
366 "description": "Aggregate with $merge omits read preference for pre-5.0 server",
367 "runOnRequirements": [
368 {
369 "minServerVersion": "4.2",
370 "maxServerVersion": "4.4.99"
371 }
372 ],
373 "operations": [
374 {
375 "object": "collection0",
376 "name": "aggregate",
377 "arguments": {
378 "pipeline": [
379 {
380 "$match": {
381 "_id": {
382 "$gt": 1
383 }
384 }
385 },
386 {
387 "$sort": {
388 "x": 1
389 }
390 },
391 {
392 "$merge": {
393 "into": "coll1"
394 }
395 }
396 ]
397 }
398 }
399 ],
400 "expectEvents": [
401 {
402 "client": "client0",
403 "events": [
404 {
405 "commandStartedEvent": {
406 "command": {
407 "aggregate": "coll0",
408 "pipeline": [
409 {
410 "$match": {
411 "_id": {
412 "$gt": 1
413 }
414 }
415 },
416 {
417 "$sort": {
418 "x": 1
419 }
420 },
421 {
422 "$merge": {
423 "into": "coll1"
424 }
425 }
426 ],
427 "$readPreference": {
428 "$$exists": false
429 },
430 "readConcern": {
431 "level": "local"
432 },
433 "writeConcern": {
434 "w": 1
435 }
436 }
437 }
438 }
439 ]
440 }
441 ],
442 "outcome": [
443 {
444 "collectionName": "coll1",
445 "databaseName": "db0",
446 "documents": [
447 {
448 "_id": 2,
449 "x": 22
450 },
451 {
452 "_id": 3,
453 "x": 33
454 }
455 ]
456 }
457 ]
458 }
459 ]
460}
View as plain text