Skip to content

Commit 6ff1f5c

Browse files
authored
Convert change streams spec tests to unified format (#949)
GODRIVER-1986 GODRIVER-2362 GODRIVER-2296
1 parent 7fbb175 commit 6ff1f5c

31 files changed

+10104
-8304
lines changed
Lines changed: 246 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,246 @@
1+
{
2+
"description": "change-streams-errors",
3+
"schemaVersion": "1.7",
4+
"runOnRequirements": [
5+
{
6+
"serverless": "forbid"
7+
}
8+
],
9+
"createEntities": [
10+
{
11+
"client": {
12+
"id": "client0",
13+
"observeEvents": [
14+
"commandStartedEvent"
15+
],
16+
"ignoreCommandMonitoringEvents": [
17+
"killCursors"
18+
],
19+
"useMultipleMongoses": false
20+
}
21+
},
22+
{
23+
"client": {
24+
"id": "globalClient",
25+
"useMultipleMongoses": false
26+
}
27+
},
28+
{
29+
"database": {
30+
"id": "database0",
31+
"client": "client0",
32+
"databaseName": "database0"
33+
}
34+
},
35+
{
36+
"collection": {
37+
"id": "collection0",
38+
"database": "database0",
39+
"collectionName": "collection0"
40+
}
41+
},
42+
{
43+
"database": {
44+
"id": "globalDatabase0",
45+
"client": "globalClient",
46+
"databaseName": "database0"
47+
}
48+
},
49+
{
50+
"collection": {
51+
"id": "globalCollection0",
52+
"database": "globalDatabase0",
53+
"collectionName": "collection0"
54+
}
55+
}
56+
],
57+
"initialData": [
58+
{
59+
"collectionName": "collection0",
60+
"databaseName": "database0",
61+
"documents": []
62+
}
63+
],
64+
"tests": [
65+
{
66+
"description": "The watch helper must not throw a custom exception when executed against a single server topology, but instead depend on a server error",
67+
"runOnRequirements": [
68+
{
69+
"minServerVersion": "3.6.0",
70+
"topologies": [
71+
"single"
72+
]
73+
}
74+
],
75+
"operations": [
76+
{
77+
"name": "createChangeStream",
78+
"object": "collection0",
79+
"arguments": {
80+
"pipeline": []
81+
},
82+
"expectError": {
83+
"errorCode": 40573
84+
}
85+
}
86+
]
87+
},
88+
{
89+
"description": "Change Stream should error when an invalid aggregation stage is passed in",
90+
"runOnRequirements": [
91+
{
92+
"minServerVersion": "3.6.0",
93+
"topologies": [
94+
"replicaset"
95+
]
96+
}
97+
],
98+
"operations": [
99+
{
100+
"name": "createChangeStream",
101+
"object": "collection0",
102+
"arguments": {
103+
"pipeline": [
104+
{
105+
"$unsupported": "foo"
106+
}
107+
]
108+
},
109+
"expectError": {
110+
"errorCode": 40324
111+
}
112+
}
113+
],
114+
"expectEvents": [
115+
{
116+
"client": "client0",
117+
"ignoreExtraEvents": true,
118+
"events": [
119+
{
120+
"commandStartedEvent": {
121+
"command": {
122+
"aggregate": "collection0",
123+
"cursor": {},
124+
"pipeline": [
125+
{
126+
"$changeStream": {}
127+
},
128+
{
129+
"$unsupported": "foo"
130+
}
131+
]
132+
},
133+
"commandName": "aggregate",
134+
"databaseName": "database0"
135+
}
136+
}
137+
]
138+
}
139+
]
140+
},
141+
{
142+
"description": "Change Stream should error when _id is projected out",
143+
"runOnRequirements": [
144+
{
145+
"minServerVersion": "4.1.11",
146+
"topologies": [
147+
"replicaset",
148+
"sharded-replicaset",
149+
"load-balanced"
150+
]
151+
}
152+
],
153+
"operations": [
154+
{
155+
"name": "createChangeStream",
156+
"object": "collection0",
157+
"arguments": {
158+
"pipeline": [
159+
{
160+
"$project": {
161+
"_id": 0
162+
}
163+
}
164+
]
165+
},
166+
"saveResultAsEntity": "changeStream0"
167+
},
168+
{
169+
"name": "insertOne",
170+
"object": "globalCollection0",
171+
"arguments": {
172+
"document": {
173+
"z": 3
174+
}
175+
}
176+
},
177+
{
178+
"name": "iterateUntilDocumentOrError",
179+
"object": "changeStream0",
180+
"expectError": {
181+
"errorCode": 280
182+
}
183+
}
184+
]
185+
},
186+
{
187+
"description": "change stream errors on ElectionInProgress",
188+
"runOnRequirements": [
189+
{
190+
"minServerVersion": "4.2",
191+
"topologies": [
192+
"replicaset",
193+
"sharded-replicaset",
194+
"load-balanced"
195+
]
196+
}
197+
],
198+
"operations": [
199+
{
200+
"name": "failPoint",
201+
"object": "testRunner",
202+
"arguments": {
203+
"client": "globalClient",
204+
"failPoint": {
205+
"configureFailPoint": "failCommand",
206+
"mode": {
207+
"times": 1
208+
},
209+
"data": {
210+
"failCommands": [
211+
"getMore"
212+
],
213+
"errorCode": 216,
214+
"closeConnection": false
215+
}
216+
}
217+
}
218+
},
219+
{
220+
"name": "createChangeStream",
221+
"object": "collection0",
222+
"arguments": {
223+
"pipeline": []
224+
},
225+
"saveResultAsEntity": "changeStream0"
226+
},
227+
{
228+
"name": "insertOne",
229+
"object": "globalCollection0",
230+
"arguments": {
231+
"document": {
232+
"z": 3
233+
}
234+
}
235+
},
236+
{
237+
"name": "iterateUntilDocumentOrError",
238+
"object": "changeStream0",
239+
"expectError": {
240+
"errorCode": 216
241+
}
242+
}
243+
]
244+
}
245+
]
246+
}
Lines changed: 120 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
1+
description: "change-streams-errors"
2+
3+
schemaVersion: "1.7"
4+
5+
runOnRequirements:
6+
- serverless: forbid
7+
8+
createEntities:
9+
- client:
10+
id: &client0 client0
11+
observeEvents: [ commandStartedEvent ]
12+
ignoreCommandMonitoringEvents: [ killCursors ]
13+
useMultipleMongoses: false
14+
- client:
15+
id: &globalClient globalClient
16+
useMultipleMongoses: false
17+
- database:
18+
id: &database0 database0
19+
client: *client0
20+
databaseName: *database0
21+
- collection:
22+
id: &collection0 collection0
23+
database: *database0
24+
collectionName: *collection0
25+
- database:
26+
id: &globalDatabase0 globalDatabase0
27+
client: *globalClient
28+
databaseName: *database0
29+
- collection:
30+
id: &globalCollection0 globalCollection0
31+
database: *globalDatabase0
32+
collectionName: *collection0
33+
34+
initialData:
35+
- collectionName: *collection0
36+
databaseName: *database0
37+
documents: []
38+
39+
tests:
40+
- description: "The watch helper must not throw a custom exception when executed against a single server topology, but instead depend on a server error"
41+
runOnRequirements:
42+
- minServerVersion: "3.6.0"
43+
topologies: [ single ]
44+
operations:
45+
- name: createChangeStream
46+
object: *collection0
47+
arguments: { pipeline: [] }
48+
expectError: { errorCode: 40573 }
49+
50+
- description: Change Stream should error when an invalid aggregation stage is passed in
51+
runOnRequirements:
52+
- minServerVersion: "3.6.0"
53+
topologies: [ replicaset ]
54+
operations:
55+
- name: createChangeStream
56+
object: *collection0
57+
arguments:
58+
pipeline: [ { $unsupported: foo } ]
59+
expectError: { errorCode: 40324 }
60+
expectEvents:
61+
- client: *client0
62+
ignoreExtraEvents: true
63+
events:
64+
- commandStartedEvent:
65+
command:
66+
aggregate: *collection0
67+
cursor: {}
68+
pipeline:
69+
- $changeStream: {}
70+
- $unsupported: foo
71+
commandName: aggregate
72+
databaseName: *database0
73+
74+
- description: Change Stream should error when _id is projected out
75+
runOnRequirements:
76+
- minServerVersion: "4.1.11"
77+
topologies: [ replicaset, sharded-replicaset, load-balanced ]
78+
operations:
79+
- name: createChangeStream
80+
object: *collection0
81+
arguments:
82+
pipeline:
83+
- $project: { _id: 0 }
84+
saveResultAsEntity: &changeStream0 changeStream0
85+
- name: insertOne
86+
object: *globalCollection0
87+
arguments:
88+
document: { z: 3 }
89+
- name: iterateUntilDocumentOrError
90+
object: *changeStream0
91+
expectError: { errorCode: 280 }
92+
93+
- description: change stream errors on ElectionInProgress
94+
runOnRequirements:
95+
- minServerVersion: "4.2"
96+
topologies: [ replicaset, sharded-replicaset, load-balanced ]
97+
operations:
98+
- name: failPoint
99+
object: testRunner
100+
arguments:
101+
client: *globalClient
102+
failPoint:
103+
configureFailPoint: failCommand
104+
mode: { times: 1 }
105+
data:
106+
failCommands: [ getMore ]
107+
errorCode: 216
108+
closeConnection: false
109+
- name: createChangeStream
110+
object: *collection0
111+
arguments:
112+
pipeline: []
113+
saveResultAsEntity: &changeStream0 changeStream0
114+
- name: insertOne
115+
object: *globalCollection0
116+
arguments:
117+
document: { z: 3 }
118+
- name: iterateUntilDocumentOrError
119+
object: *changeStream0
120+
expectError: { errorCode: 216 }

0 commit comments

Comments
 (0)