...
1description: "change-streams-showExpandedEvents"
2schemaVersion: "1.7"
3runOnRequirements:
4 - minServerVersion: "6.0.0"
5 topologies: [ replicaset, sharded-replicaset, sharded ]
6createEntities:
7 - client:
8 id: &client0 client0
9 observeEvents: [ commandStartedEvent ]
10 ignoreCommandMonitoringEvents: [ killCursors ]
11 useMultipleMongoses: false
12 - database:
13 id: &database0 database0
14 client: *client0
15 databaseName: *database0
16 - collection:
17 id: &collection0 collection0
18 database: *database0
19 collectionName: *collection0
20 - database:
21 id: &database1 database1
22 client: *client0
23 databaseName: *database1
24 - collection:
25 id: &collection1 collection1
26 database: *database1
27 collectionName: *collection1
28 - database:
29 id: &shardedDb shardedDb
30 client: *client0
31 databaseName: *shardedDb
32 - database:
33 id: &adminDb adminDb
34 client: *client0
35 databaseName: admin
36 - collection:
37 id: &shardedCollection shardedCollection
38 database: *shardedDb
39 collectionName: *shardedCollection
40
41initialData:
42 - collectionName: *collection0
43 databaseName: *database0
44 documents: []
45
46tests:
47 - description: "when provided, showExpandedEvents is sent as a part of the aggregate command"
48 operations:
49 - name: createChangeStream
50 object: *collection0
51 arguments:
52 pipeline: []
53 showExpandedEvents: true
54 saveResultAsEntity: &changeStream0 changeStream0
55 expectEvents:
56 - client: *client0
57 ignoreExtraEvents: true
58 events:
59 - commandStartedEvent:
60 command:
61 aggregate: *collection0
62 cursor: {}
63 pipeline:
64 - $changeStream:
65 showExpandedEvents: true
66 commandName: aggregate
67 databaseName: *database0
68
69 - description: "when omitted, showExpandedEvents is not sent as a part of the aggregate command"
70 operations:
71 - name: createChangeStream
72 object: *collection0
73 arguments:
74 pipeline: []
75 saveResultAsEntity: &changeStream0 changeStream0
76 expectEvents:
77 - client: *client0
78 ignoreExtraEvents: true
79 events:
80 - commandStartedEvent:
81 command:
82 aggregate: *collection0
83 cursor: {}
84 pipeline:
85 - $changeStream:
86 showExpandedEvents:
87 $$exists: false
88 commandName: aggregate
89 databaseName: *database0
90
91 - description: "when showExpandedEvents is true, new fields on change stream events are handled appropriately"
92 operations:
93 - name: dropCollection
94 object: *database0
95 arguments:
96 collection: &existing-collection foo
97 - name: createCollection
98 object: *database0
99 arguments:
100 collection: *existing-collection
101 - name: createChangeStream
102 object: *collection0
103 arguments:
104 pipeline: []
105 showExpandedEvents: true
106 saveResultAsEntity: &changeStream0 changeStream0
107 - name: insertOne
108 object: *collection0
109 arguments:
110 document:
111 a: 1
112 - name: createIndex
113 object: *collection0
114 arguments:
115 keys:
116 x: 1
117 name: x_1
118 - name: rename
119 object: *collection0
120 arguments:
121 to: *existing-collection
122 dropTarget: true
123 - name: iterateUntilDocumentOrError
124 object: *changeStream0
125 expectResult:
126 operationType: insert
127 ns:
128 db: *database0
129 coll: *collection0
130 collectionUUID:
131 $$exists: true
132 - name: iterateUntilDocumentOrError
133 object: *changeStream0
134 expectResult:
135 operationType: createIndexes
136 ns:
137 db: *database0
138 coll: *collection0
139 operationDescription:
140 $$exists: true
141 - name: iterateUntilDocumentOrError
142 object: *changeStream0
143 expectResult:
144 operationType: rename
145 ns:
146 db: *database0
147 coll: *collection0
148 to:
149 db: *database0
150 coll: *existing-collection
151 operationDescription:
152 dropTarget:
153 $$exists: true
154 to:
155 db: *database0
156 coll: *existing-collection
157
158 - description: "when showExpandedEvents is true, createIndex events are reported"
159 operations:
160 - name: createChangeStream
161 object: *collection0
162 arguments:
163 pipeline:
164 # On sharded clusters, the create command run when loading initial
165 # data sometimes is still reported in the change stream. To avoid
166 # this, we exclude the create command when creating the change
167 # stream, but specifically don't exclude other events to still catch
168 # driver errors.
169 - $match:
170 operationType:
171 $ne: create
172 showExpandedEvents: true
173 saveResultAsEntity: &changeStream0 changeStream0
174 - name: createIndex
175 object: *collection0
176 arguments:
177 keys:
178 x: 1
179 name: x_1
180 - name: iterateUntilDocumentOrError
181 object: *changeStream0
182 expectResult:
183 operationType: createIndexes
184
185 - description: "when showExpandedEvents is true, dropIndexes events are reported"
186 operations:
187 - name: createIndex
188 object: *collection0
189 arguments:
190 keys:
191 x: 1
192 name: &index1 x_1
193 - name: createChangeStream
194 object: *collection0
195 arguments:
196 pipeline: []
197 showExpandedEvents: true
198 saveResultAsEntity: &changeStream0 changeStream0
199 - name: dropIndex
200 object: *collection0
201 arguments:
202 name: *index1
203 - name: iterateUntilDocumentOrError
204 object: *changeStream0
205 expectResult:
206 operationType: dropIndexes
207
208 - description: "when showExpandedEvents is true, create events are reported"
209 operations:
210 - name: dropCollection
211 object: *database0
212 arguments:
213 collection: &collection1 foo
214 - name: createChangeStream
215 object: *database0
216 arguments:
217 pipeline: []
218 showExpandedEvents: true
219 saveResultAsEntity: &changeStream0 changeStream0
220 - name: createCollection
221 object: *database0
222 arguments:
223 collection: *collection1
224 - name: iterateUntilDocumentOrError
225 object: *changeStream0
226 expectResult:
227 operationType: create
228
229 - description: "when showExpandedEvents is true, create events on views are reported"
230 operations:
231 - name: dropCollection
232 object: *database0
233 arguments:
234 collection: &collection1 foo
235 - name: createChangeStream
236 object: *database0
237 arguments:
238 pipeline: []
239 showExpandedEvents: true
240 saveResultAsEntity: &changeStream0 changeStream0
241 - name: createCollection
242 object: *database0
243 arguments:
244 collection: *collection1
245 viewOn: testName
246 - name: iterateUntilDocumentOrError
247 object: *changeStream0
248 expectResult:
249 operationType: create
250
251 - description: "when showExpandedEvents is true, modify events are reported"
252 operations:
253 - name: createIndex
254 object: *collection0
255 arguments:
256 keys:
257 x: 1
258 name: &index2 x_2
259 - name: createChangeStream
260 object: *collection0
261 arguments:
262 pipeline: []
263 showExpandedEvents: true
264 saveResultAsEntity: &changeStream0 changeStream0
265 - name: runCommand
266 object: *database0
267 arguments:
268 command:
269 collMod: *collection0
270 commandName: collMod
271 - name: iterateUntilDocumentOrError
272 object: *changeStream0
273 expectResult:
274 operationType: modify
275
276 - description: "when showExpandedEvents is true, shardCollection events are reported"
277 runOnRequirements:
278 - topologies: [ sharded-replicaset, sharded ]
279 operations:
280 - name: dropCollection
281 object: *shardedDb
282 arguments:
283 collection: *shardedCollection
284 - name: createCollection
285 object: *shardedDb
286 arguments:
287 collection: *shardedCollection
288 - name: createChangeStream
289 object: *shardedCollection
290 arguments:
291 pipeline: []
292 showExpandedEvents: true
293 saveResultAsEntity: &changeStream0 changeStream0
294 - name: runCommand
295 object: *adminDb
296 arguments:
297 command:
298 shardCollection: shardedDb.shardedCollection
299 key:
300 _id: 1
301 commandName: shardCollection
302 - name: iterateUntilDocumentOrError
303 object: *changeStream0
304 expectResult:
305 operationType: shardCollection
View as plain text