Skip to content

Commit 922412f

Browse files
test(NODE-3248): sync new unified change stream tests & enhance runner (#3233)
1 parent d0f622b commit 922412f

17 files changed

+9497
-45
lines changed

test/integration/change-streams/change_streams.spec.test.ts

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,31 @@ import { loadSpecTests } from '../../spec';
77
import { runUnifiedSuite } from '../../tools/unified-spec-runner/runner';
88
import { delay, setupDatabase } from '../shared';
99

10+
// TODO(NODE-4126): Fix change stream resumabilty in iterator mode
11+
const skippedResumabilityTests = [
12+
'change stream resumes after HostUnreachable',
13+
'change stream resumes after HostNotFound',
14+
'change stream resumes after NetworkTimeout',
15+
'change stream resumes after ShutdownInProgress',
16+
'change stream resumes after PrimarySteppedDown',
17+
'change stream resumes after ExceededTimeLimit',
18+
'change stream resumes after SocketException',
19+
'change stream resumes after NotWritablePrimary',
20+
'change stream resumes after InterruptedAtShutdown',
21+
'change stream resumes after InterruptedDueToReplStateChange',
22+
'change stream resumes after NotPrimaryNoSecondaryOk',
23+
'change stream resumes after NotPrimaryOrSecondary',
24+
'change stream resumes after StaleShardVersion',
25+
'change stream resumes after StaleEpoch',
26+
'change stream resumes after RetryChangeStream',
27+
'change stream resumes after FailedToSatisfyReadPreference',
28+
'change stream resumes if error contains ResumableChangeStreamError',
29+
'change stream resumes after a network error',
30+
'change stream resumes after CursorNotFound',
31+
'Test consecutive resume'
32+
];
1033
describe('Change Streams Spec - Unified', function () {
11-
runUnifiedSuite(loadSpecTests(path.join('change-streams', 'unified')));
34+
runUnifiedSuite(loadSpecTests(path.join('change-streams', 'unified')), skippedResumabilityTests);
1235
});
1336

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

0 commit comments

Comments
 (0)