Skip to content

Commit 9d327e1

Browse files
CDRIVER-3973 + CDRIVER-4366 : Update and use change-streams tests (#1015)
CDRIVER-3973 + CDRIVER-4366 : Update and use change-streams tests (#1015) This changeset addresses both CDRIVER-3973 and CDRIVER-4366. It pulls the updated tests for 4366 while also finishing support for the test cases required to complete 3973.
1 parent 08b28a5 commit 9d327e1

File tree

4 files changed

+231
-68
lines changed

4 files changed

+231
-68
lines changed

src/libmongoc/tests/json/change_streams/unified/change-streams.json

Lines changed: 65 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,7 @@
55
{
66
"minServerVersion": "3.6",
77
"topologies": [
8-
"replicaset",
9-
"sharded-replicaset"
8+
"replicaset"
109
],
1110
"serverless": "forbid"
1211
}
@@ -314,10 +313,7 @@
314313
"description": "Test that comment is set on getMore",
315314
"runOnRequirements": [
316315
{
317-
"minServerVersion": "4.4.0",
318-
"topologies": [
319-
"replicaset"
320-
]
316+
"minServerVersion": "4.4.0"
321317
}
322318
],
323319
"operations": [
@@ -405,10 +401,7 @@
405401
"description": "Test that comment is not set on getMore - pre 4.4",
406402
"runOnRequirements": [
407403
{
408-
"maxServerVersion": "4.3.99",
409-
"topologies": [
410-
"replicaset"
411-
]
404+
"maxServerVersion": "4.3.99"
412405
}
413406
],
414407
"operations": [
@@ -621,6 +614,15 @@
621614
},
622615
{
623616
"description": "Test new structure in ns document MUST NOT err",
617+
"runOnRequirements": [
618+
{
619+
"minServerVersion": "3.6",
620+
"maxServerVersion": "5.2.99"
621+
},
622+
{
623+
"minServerVersion": "6.0"
624+
}
625+
],
624626
"operations": [
625627
{
626628
"name": "createChangeStream",
@@ -797,10 +799,7 @@
797799
"description": "$changeStream must be the first stage in a change stream pipeline sent to the server",
798800
"runOnRequirements": [
799801
{
800-
"minServerVersion": "3.6.0",
801-
"topologies": [
802-
"replicaset"
803-
]
802+
"minServerVersion": "3.6.0"
804803
}
805804
],
806805
"operations": [
@@ -873,10 +872,7 @@
873872
"description": "The server returns change stream responses in the specified server response format",
874873
"runOnRequirements": [
875874
{
876-
"minServerVersion": "3.6.0",
877-
"topologies": [
878-
"replicaset"
879-
]
875+
"minServerVersion": "3.6.0"
880876
}
881877
],
882878
"operations": [
@@ -926,10 +922,7 @@
926922
"description": "Executing a watch helper on a Collection results in notifications for changes to the specified collection",
927923
"runOnRequirements": [
928924
{
929-
"minServerVersion": "3.6.0",
930-
"topologies": [
931-
"replicaset"
932-
]
925+
"minServerVersion": "3.6.0"
933926
}
934927
],
935928
"operations": [
@@ -1014,10 +1007,7 @@
10141007
"description": "Change Stream should allow valid aggregate pipeline stages",
10151008
"runOnRequirements": [
10161009
{
1017-
"minServerVersion": "3.6.0",
1018-
"topologies": [
1019-
"replicaset"
1020-
]
1010+
"minServerVersion": "3.6.0"
10211011
}
10221012
],
10231013
"operations": [
@@ -1104,10 +1094,7 @@
11041094
"description": "Executing a watch helper on a Database results in notifications for changes to all collections in the specified database.",
11051095
"runOnRequirements": [
11061096
{
1107-
"minServerVersion": "3.8.0",
1108-
"topologies": [
1109-
"replicaset"
1110-
]
1097+
"minServerVersion": "3.8.0"
11111098
}
11121099
],
11131100
"operations": [
@@ -1209,10 +1196,7 @@
12091196
"description": "Executing a watch helper on a MongoClient results in notifications for changes to all collections in all databases in the cluster.",
12101197
"runOnRequirements": [
12111198
{
1212-
"minServerVersion": "3.8.0",
1213-
"topologies": [
1214-
"replicaset"
1215-
]
1199+
"minServerVersion": "3.8.0"
12161200
}
12171201
],
12181202
"operations": [
@@ -1333,10 +1317,7 @@
13331317
"description": "Test insert, update, replace, and delete event types",
13341318
"runOnRequirements": [
13351319
{
1336-
"minServerVersion": "3.6.0",
1337-
"topologies": [
1338-
"replicaset"
1339-
]
1320+
"minServerVersion": "3.6.0"
13401321
}
13411322
],
13421323
"operations": [
@@ -1488,10 +1469,7 @@
14881469
"description": "Test rename and invalidate event types",
14891470
"runOnRequirements": [
14901471
{
1491-
"minServerVersion": "4.0.1",
1492-
"topologies": [
1493-
"replicaset"
1494-
]
1472+
"minServerVersion": "4.0.1"
14951473
}
14961474
],
14971475
"operations": [
@@ -1568,10 +1546,7 @@
15681546
"description": "Test drop and invalidate event types",
15691547
"runOnRequirements": [
15701548
{
1571-
"minServerVersion": "4.0.1",
1572-
"topologies": [
1573-
"replicaset"
1574-
]
1549+
"minServerVersion": "4.0.1"
15751550
}
15761551
],
15771552
"operations": [
@@ -1637,10 +1612,7 @@
16371612
"description": "Test consecutive resume",
16381613
"runOnRequirements": [
16391614
{
1640-
"minServerVersion": "4.1.7",
1641-
"topologies": [
1642-
"replicaset"
1643-
]
1615+
"minServerVersion": "4.1.7"
16441616
}
16451617
],
16461618
"operations": [
@@ -1776,6 +1748,48 @@
17761748
]
17771749
}
17781750
]
1751+
},
1752+
{
1753+
"description": "Test wallTime field is set in a change event",
1754+
"runOnRequirements": [
1755+
{
1756+
"minServerVersion": "6.0.0"
1757+
}
1758+
],
1759+
"operations": [
1760+
{
1761+
"name": "createChangeStream",
1762+
"object": "collection0",
1763+
"arguments": {
1764+
"pipeline": []
1765+
},
1766+
"saveResultAsEntity": "changeStream0"
1767+
},
1768+
{
1769+
"name": "insertOne",
1770+
"object": "collection0",
1771+
"arguments": {
1772+
"document": {
1773+
"_id": 1,
1774+
"a": 1
1775+
}
1776+
}
1777+
},
1778+
{
1779+
"name": "iterateUntilDocumentOrError",
1780+
"object": "changeStream0",
1781+
"expectResult": {
1782+
"operationType": "insert",
1783+
"ns": {
1784+
"db": "database0",
1785+
"coll": "collection0"
1786+
},
1787+
"wallTime": {
1788+
"$$exists": true
1789+
}
1790+
}
1791+
}
1792+
]
17791793
}
17801794
]
1781-
}
1795+
}
Lines changed: 151 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,151 @@
1+
{
2+
"description": "expectedEventsForClient-ignoreExtraEvents",
3+
"schemaVersion": "1.7",
4+
"createEntities": [
5+
{
6+
"client": {
7+
"id": "client0",
8+
"useMultipleMongoses": true,
9+
"observeEvents": [
10+
"commandStartedEvent"
11+
]
12+
}
13+
},
14+
{
15+
"database": {
16+
"id": "database0",
17+
"client": "client0",
18+
"databaseName": "database0Name"
19+
}
20+
},
21+
{
22+
"collection": {
23+
"id": "collection0",
24+
"database": "database0",
25+
"collectionName": "coll0"
26+
}
27+
}
28+
],
29+
"initialData": [
30+
{
31+
"collectionName": "coll0",
32+
"databaseName": "database0Name",
33+
"documents": []
34+
}
35+
],
36+
"tests": [
37+
{
38+
"description": "ignoreExtraEvents can be set to false",
39+
"operations": [
40+
{
41+
"name": "insertOne",
42+
"object": "collection0",
43+
"arguments": {
44+
"document": {
45+
"_id": 1
46+
}
47+
}
48+
}
49+
],
50+
"expectEvents": [
51+
{
52+
"client": "client0",
53+
"ignoreExtraEvents": false,
54+
"events": [
55+
{
56+
"commandStartedEvent": {
57+
"command": {
58+
"insert": "coll0",
59+
"documents": [
60+
{
61+
"_id": 1
62+
}
63+
]
64+
},
65+
"commandName": "insert"
66+
}
67+
}
68+
]
69+
}
70+
]
71+
},
72+
{
73+
"description": "ignoreExtraEvents can be set to true",
74+
"operations": [
75+
{
76+
"name": "insertOne",
77+
"object": "collection0",
78+
"arguments": {
79+
"document": {
80+
"_id": 2
81+
}
82+
}
83+
},
84+
{
85+
"name": "insertOne",
86+
"object": "collection0",
87+
"arguments": {
88+
"document": {
89+
"_id": 3
90+
}
91+
}
92+
}
93+
],
94+
"expectEvents": [
95+
{
96+
"client": "client0",
97+
"ignoreExtraEvents": true,
98+
"events": [
99+
{
100+
"commandStartedEvent": {
101+
"command": {
102+
"insert": "coll0",
103+
"documents": [
104+
{
105+
"_id": 2
106+
}
107+
]
108+
},
109+
"commandName": "insert"
110+
}
111+
}
112+
]
113+
}
114+
]
115+
},
116+
{
117+
"description": "ignoreExtraEvents defaults to false if unset",
118+
"operations": [
119+
{
120+
"name": "insertOne",
121+
"object": "collection0",
122+
"arguments": {
123+
"document": {
124+
"_id": 4
125+
}
126+
}
127+
}
128+
],
129+
"expectEvents": [
130+
{
131+
"client": "client0",
132+
"events": [
133+
{
134+
"commandStartedEvent": {
135+
"command": {
136+
"insert": "coll0",
137+
"documents": [
138+
{
139+
"_id": 4
140+
}
141+
]
142+
},
143+
"commandName": "insert"
144+
}
145+
}
146+
]
147+
}
148+
]
149+
}
150+
]
151+
}

0 commit comments

Comments
 (0)