Skip to content

Commit e3cab42

Browse files
authored
Add unified change stream test for comment (#908)
Requires support for absent saveResultAsEntity, which is optional JAVA-4369
1 parent 49491e5 commit e3cab42

File tree

2 files changed

+335
-7
lines changed

2 files changed

+335
-7
lines changed

driver-core/src/test/resources/unified-test-format/change-streams/change-streams.json

Lines changed: 320 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,21 @@
11
{
22
"description": "change-streams",
33
"schemaVersion": "1.0",
4+
"runOnRequirements": [
5+
{
6+
"topologies": [
7+
"replicaset",
8+
"sharded-replicaset"
9+
]
10+
}
11+
],
412
"createEntities": [
513
{
614
"client": {
7-
"id": "client0"
15+
"id": "client0",
16+
"observeEvents": [
17+
"commandStartedEvent"
18+
]
819
}
920
},
1021
{
@@ -34,10 +45,7 @@
3445
"description": "Test array truncation",
3546
"runOnRequirements": [
3647
{
37-
"minServerVersion": "4.7",
38-
"topologies": [
39-
"replicaset"
40-
]
48+
"minServerVersion": "4.7"
4149
}
4250
],
4351
"operations": [
@@ -111,6 +119,313 @@
111119
}
112120
}
113121
]
122+
},
123+
{
124+
"description": "Test with document comment",
125+
"runOnRequirements": [
126+
{
127+
"minServerVersion": "4.4"
128+
}
129+
],
130+
"operations": [
131+
{
132+
"name": "createChangeStream",
133+
"object": "collection0",
134+
"arguments": {
135+
"pipeline": [],
136+
"comment": {
137+
"name": "test1"
138+
}
139+
},
140+
"saveResultAsEntity": "changeStream0"
141+
}
142+
],
143+
"expectEvents": [
144+
{
145+
"client": "client0",
146+
"events": [
147+
{
148+
"commandStartedEvent": {
149+
"command": {
150+
"aggregate": "collection0",
151+
"pipeline": [
152+
{
153+
"$changeStream": {}
154+
}
155+
],
156+
"comment": {
157+
"name": "test1"
158+
}
159+
}
160+
}
161+
}
162+
]
163+
}
164+
]
165+
},
166+
{
167+
"description": "Test with document comment - pre 4.4",
168+
"runOnRequirements": [
169+
{
170+
"minServerVersion": "3.6.0",
171+
"maxServerVersion": "4.2.99"
172+
}
173+
],
174+
"operations": [
175+
{
176+
"name": "createChangeStream",
177+
"object": "collection0",
178+
"arguments": {
179+
"pipeline": [],
180+
"comment": {
181+
"name": "test1"
182+
}
183+
},
184+
"expectError": {
185+
"isClientError": false
186+
}
187+
}
188+
],
189+
"expectEvents": [
190+
{
191+
"client": "client0",
192+
"events": [
193+
{
194+
"commandStartedEvent": {
195+
"command": {
196+
"aggregate": "collection0",
197+
"pipeline": [
198+
{
199+
"$changeStream": {}
200+
}
201+
],
202+
"comment": {
203+
"name": "test1"
204+
}
205+
}
206+
}
207+
}
208+
]
209+
}
210+
]
211+
},
212+
{
213+
"description": "Test with string comment",
214+
"runOnRequirements": [
215+
{
216+
"minServerVersion": "3.6.0"
217+
}
218+
],
219+
"operations": [
220+
{
221+
"name": "createChangeStream",
222+
"object": "collection0",
223+
"arguments": {
224+
"pipeline": [],
225+
"comment": "comment"
226+
},
227+
"saveResultAsEntity": "changeStream0"
228+
}
229+
],
230+
"expectEvents": [
231+
{
232+
"client": "client0",
233+
"events": [
234+
{
235+
"commandStartedEvent": {
236+
"command": {
237+
"aggregate": "collection0",
238+
"pipeline": [
239+
{
240+
"$changeStream": {}
241+
}
242+
],
243+
"comment": "comment"
244+
}
245+
}
246+
}
247+
]
248+
}
249+
]
250+
},
251+
{
252+
"description": "Test that comment is set on getMore",
253+
"runOnRequirements": [
254+
{
255+
"minServerVersion": "4.4.0",
256+
"topologies": [
257+
"replicaset"
258+
]
259+
}
260+
],
261+
"operations": [
262+
{
263+
"name": "createChangeStream",
264+
"object": "collection0",
265+
"arguments": {
266+
"pipeline": [],
267+
"comment": {
268+
"key": "value"
269+
}
270+
},
271+
"saveResultAsEntity": "changeStream0"
272+
},
273+
{
274+
"name": "insertOne",
275+
"object": "collection0",
276+
"arguments": {
277+
"document": {
278+
"_id": 1,
279+
"a": 1
280+
}
281+
}
282+
},
283+
{
284+
"name": "iterateUntilDocumentOrError",
285+
"object": "changeStream0"
286+
}
287+
],
288+
"expectEvents": [
289+
{
290+
"client": "client0",
291+
"events": [
292+
{
293+
"commandStartedEvent": {
294+
"command": {
295+
"aggregate": "collection0",
296+
"pipeline": [
297+
{
298+
"$changeStream": {}
299+
}
300+
],
301+
"comment": {
302+
"key": "value"
303+
}
304+
}
305+
}
306+
},
307+
{
308+
"commandStartedEvent": {
309+
"command": {
310+
"insert": "collection0",
311+
"documents": [
312+
{
313+
"_id": 1,
314+
"a": 1
315+
}
316+
]
317+
}
318+
}
319+
},
320+
{
321+
"commandStartedEvent": {
322+
"command": {
323+
"getMore": {
324+
"$$type": [
325+
"int",
326+
"long"
327+
]
328+
},
329+
"collection": "collection0",
330+
"comment": {
331+
"key": "value"
332+
}
333+
},
334+
"commandName": "getMore",
335+
"databaseName": "database0"
336+
}
337+
}
338+
]
339+
}
340+
]
341+
},
342+
{
343+
"description": "Test that comment is not set on getMore - pre 4.4",
344+
"runOnRequirements": [
345+
{
346+
"minServerVersion": "3.6.0",
347+
"maxServerVersion": "4.3.99",
348+
"topologies": [
349+
"replicaset"
350+
]
351+
}
352+
],
353+
"operations": [
354+
{
355+
"name": "createChangeStream",
356+
"object": "collection0",
357+
"arguments": {
358+
"pipeline": [],
359+
"comment": "comment"
360+
},
361+
"saveResultAsEntity": "changeStream0"
362+
},
363+
{
364+
"name": "insertOne",
365+
"object": "collection0",
366+
"arguments": {
367+
"document": {
368+
"_id": 1,
369+
"a": 1
370+
}
371+
}
372+
},
373+
{
374+
"name": "iterateUntilDocumentOrError",
375+
"object": "changeStream0"
376+
}
377+
],
378+
"expectEvents": [
379+
{
380+
"client": "client0",
381+
"events": [
382+
{
383+
"commandStartedEvent": {
384+
"command": {
385+
"aggregate": "collection0",
386+
"pipeline": [
387+
{
388+
"$changeStream": {}
389+
}
390+
],
391+
"comment": "comment"
392+
}
393+
}
394+
},
395+
{
396+
"commandStartedEvent": {
397+
"command": {
398+
"insert": "collection0",
399+
"documents": [
400+
{
401+
"_id": 1,
402+
"a": 1
403+
}
404+
]
405+
}
406+
}
407+
},
408+
{
409+
"commandStartedEvent": {
410+
"command": {
411+
"getMore": {
412+
"$$type": [
413+
"int",
414+
"long"
415+
]
416+
},
417+
"collection": "collection0",
418+
"comment": {
419+
"$$exists": false
420+
}
421+
},
422+
"commandName": "getMore",
423+
"databaseName": "database0"
424+
}
425+
}
426+
]
427+
}
428+
]
114429
}
115430
]
116431
}

0 commit comments

Comments
 (0)