Debian Codegraph @

testdata/transactions/legacy/read-pref.yml

raw symbols SCIP
1 # This test doesn't check contents of command-started events.
2 runOn:
3 -
4 minServerVersion: "4.0"
5 topology: ["replicaset"]
6 -
7 minServerVersion: "4.1.8"
8 topology: ["sharded"]
9
10 database_name: &database_name "transaction-tests"
11 collection_name: &collection_name "test"
12
13 data: []
14
15 tests:
16 - description: default readPreference
17
18 operations:
19 - name: startTransaction
20 object: session0
21 - name: insertMany
22 object: collection
23 arguments:
24 documents: &insertedDocs
25 - _id: 1
26 - _id: 2
27 - _id: 3
28 - _id: 4
29 session: session0
30 result:
31 insertedIds: {0: 1, 1: 2, 2: 3, 3: 4}
32 - name: aggregate
33 object: collection
34 collectionOptions:
35 # The driver overrides the collection's read pref with the
36 # transaction's so count runs with Primary and succeeds.
37 readPreference:
38 mode: Secondary
39 arguments:
40 session: session0
41 pipeline:
42 - $match:
43 _id: 1
44 - $count: count
45 result:
46 - count: 1
47 - name: find
48 object: collection
49 collectionOptions:
50 readPreference:
51 mode: Secondary
52 arguments:
53 session: session0
54 batchSize: 3
55 result: *insertedDocs
56 - name: aggregate
57 object: collection
58 collectionOptions:
59 readPreference:
60 mode: Secondary
61 arguments:
62 pipeline:
63 - $project:
64 _id: 1
65 batchSize: 3
66 session: session0
67 result: *insertedDocs
68 - name: commitTransaction
69 object: session0
70
71 outcome:
72 collection:
73 data: *insertedDocs
74
75 - description: primary readPreference
76
77 operations:
78 - name: startTransaction
79 object: session0
80 arguments:
81 options:
82 readPreference:
83 mode: Primary
84 - name: insertMany
85 object: collection
86 arguments:
87 documents: &insertedDocs
88 - _id: 1
89 - _id: 2
90 - _id: 3
91 - _id: 4
92 session: session0
93 result:
94 insertedIds: {0: 1, 1: 2, 2: 3, 3: 4}
95 - name: aggregate
96 object: collection
97 collectionOptions:
98 readPreference:
99 mode: Secondary
100 arguments:
101 session: session0
102 pipeline:
103 - $match:
104 _id: 1
105 - $count: count
106 result:
107 - count: 1
108 - name: find
109 object: collection
110 collectionOptions:
111 readPreference:
112 mode: Secondary
113 arguments:
114 session: session0
115 batchSize: 3
116 result: *insertedDocs
117 - name: aggregate
118 object: collection
119 collectionOptions:
120 readPreference:
121 mode: Secondary
122 arguments:
123 pipeline:
124 - $project:
125 _id: 1
126 batchSize: 3
127 session: session0
128 result: *insertedDocs
129 - name: commitTransaction
130 object: session0
131
132 outcome:
133 collection:
134 data: *insertedDocs
135
136 - description: secondary readPreference
137
138 operations:
139 - name: startTransaction
140 object: session0
141 arguments:
142 options:
143 readPreference:
144 mode: Secondary
145 - name: insertMany
146 object: collection
147 arguments:
148 documents: &insertedDocs
149 - _id: 1
150 - _id: 2
151 - _id: 3
152 - _id: 4
153 session: session0
154 result:
155 insertedIds: {0: 1, 1: 2, 2: 3, 3: 4}
156 - name: aggregate
157 object: collection
158 collectionOptions:
159 readPreference:
160 mode: Primary
161 arguments:
162 session: session0
163 pipeline:
164 - $match:
165 _id: 1
166 - $count: count
167 result:
168 errorContains: read preference in a transaction must be primary
169 - name: find
170 object: collection
171 collectionOptions:
172 readPreference:
173 mode: Primary
174 arguments:
175 session: session0
176 batchSize: 3
177 result:
178 errorContains: read preference in a transaction must be primary
179 - name: aggregate
180 object: collection
181 collectionOptions:
182 readPreference:
183 mode: Primary
184 arguments:
185 pipeline:
186 - $project:
187 _id: 1
188 batchSize: 3
189 session: session0
190 result:
191 errorContains: read preference in a transaction must be primary
192 - name: abortTransaction
193 object: session0
194
195 outcome:
196 collection:
197 data: []
198
199 - description: primaryPreferred readPreference
200
201 operations:
202 - name: startTransaction
203 object: session0
204 arguments:
205 options:
206 readPreference:
207 mode: PrimaryPreferred
208 - name: insertMany
209 object: collection
210 arguments:
211 documents: &insertedDocs
212 - _id: 1
213 - _id: 2
214 - _id: 3
215 - _id: 4
216 session: session0
217 result:
218 insertedIds: {0: 1, 1: 2, 2: 3, 3: 4}
219 - name: aggregate
220 object: collection
221 collectionOptions:
222 readPreference:
223 mode: Primary
224 arguments:
225 session: session0
226 pipeline:
227 - $match:
228 _id: 1
229 - $count: count
230 result:
231 errorContains: read preference in a transaction must be primary
232 - name: find
233 object: collection
234 collectionOptions:
235 readPreference:
236 mode: Primary
237 arguments:
238 session: session0
239 batchSize: 3
240 result:
241 errorContains: read preference in a transaction must be primary
242 - name: aggregate
243 object: collection
244 collectionOptions:
245 readPreference:
246 mode: Primary
247 arguments:
248 pipeline:
249 - $project:
250 _id: 1
251 batchSize: 3
252 session: session0
253 result:
254 errorContains: read preference in a transaction must be primary
255 - name: abortTransaction
256 object: session0
257
258 outcome:
259 collection:
260 data: []
261
262 - description: nearest readPreference
263
264 operations:
265 - name: startTransaction
266 object: session0
267 arguments:
268 options:
269 readPreference:
270 mode: Nearest
271 - name: insertMany
272 object: collection
273 arguments:
274 documents: &insertedDocs
275 - _id: 1
276 - _id: 2
277 - _id: 3
278 - _id: 4
279 session: session0
280 result:
281 insertedIds: {0: 1, 1: 2, 2: 3, 3: 4}
282 - name: aggregate
283 object: collection
284 collectionOptions:
285 readPreference:
286 mode: Primary
287 arguments:
288 session: session0
289 pipeline:
290 - $match:
291 _id: 1
292 - $count: count
293 result:
294 errorContains: read preference in a transaction must be primary
295 - name: find
296 object: collection
297 collectionOptions:
298 readPreference:
299 mode: Primary
300 arguments:
301 session: session0
302 batchSize: 3
303 result:
304 errorContains: read preference in a transaction must be primary
305 - name: aggregate
306 object: collection
307 collectionOptions:
308 readPreference:
309 mode: Primary
310 arguments:
311 pipeline:
312 - $project:
313 _id: 1
314 batchSize: 3
315 session: session0
316 result:
317 errorContains: read preference in a transaction must be primary
318 - name: abortTransaction
319 object: session0
320
321 outcome:
322 collection:
323 data: []
324
325 - description: secondary write only
326
327 operations:
328 - name: startTransaction
329 object: session0
330 arguments:
331 options:
332 readPreference:
333 mode: Secondary
334 - name: insertOne
335 object: collection
336 arguments:
337 session: session0
338 document:
339 _id: 1
340 result:
341 insertedId: 1
342 - name: commitTransaction
343 object: session0
344
345 outcome:
346 collection:
347 data:
348 - _id: 1