-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Expand file tree
/
Copy pathrunCursorCommand.yml
More file actions
314 lines (304 loc) · 10.3 KB
/
runCursorCommand.yml
File metadata and controls
314 lines (304 loc) · 10.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
description: runCursorCommand
schemaVersion: '1.9'
runOnRequirements:
- minServerVersion: "4.4"
createEntities:
- client:
id: &failPointClient failPointClient
useMultipleMongoses: false
- client:
id: &commandClient commandClient
useMultipleMongoses: false
observeEvents: [commandStartedEvent, commandSucceededEvent]
- client:
id: &client client
useMultipleMongoses: false
observeEvents: [commandStartedEvent]
ignoreCommandMonitoringEvents: [killCursors]
- database: # For tests that need success event assertions
id: &commandDb commandDb
client: *commandClient
databaseName: *commandDb
- database:
id: &db db
client: *client
databaseName: *db
- collection:
id: &collection collection
database: *db
collectionName: *collection
initialData:
- collectionName: *collection
databaseName: *db
documents: &documents
- { _id: 1, x: 11 }
- { _id: 2, x: 22 }
- { _id: 3, x: 33 }
- { _id: 4, x: 44 }
- { _id: 5, x: 55 }
tests:
- description: errors if timeoutMode is set without timeoutMS
operations:
- name: runCursorCommand
object: *db
arguments:
commandName: find
command: { find: *collection }
timeoutMode: cursorLifetime
expectError:
isClientError: true
- description: error if timeoutMode is cursorLifetime and cursorType is tailableAwait
operations:
- name: runCursorCommand
object: *db
arguments:
commandName: find
command: { find: *collection }
timeoutMode: cursorLifetime
cursorType: tailableAwait
expectError:
isClientError: true
# If timeoutMode is unset, it should default to CURSOR_LIFETIME and the time remaining after the find succeeds should be applied to the getMore
- description: Non-tailable cursor lifetime remaining timeoutMS applied to getMore if timeoutMode is unset
runOnRequirements:
- serverless: forbid
operations:
# pre-populate the pool with a connection
- name: find
object: collection
arguments:
filter: { _id: 0 }
expectResult: []
# Block find/getMore for 60ms.
- name: failPoint
object: testRunner
arguments:
client: *failPointClient
failPoint:
configureFailPoint: failCommand
mode: { times: 2 }
data:
failCommands: [find, getMore]
blockConnection: true
blockTimeMS: 60
# Run a find with timeoutMS less than double our failPoint blockTimeMS and
# batchSize less than the total document count will cause a find and a
# getMore to be sent. Both will block for 60ms so together they will go
# over the timeout.
- name: runCursorCommand
object: *db
arguments:
commandName: find
timeoutMS: 100
command: { find: *collection, batchSize: 2 }
expectError:
isTimeoutError: true
expectEvents:
- client: *client
events:
# first find is from the initial find to populate the connection poo
- commandStartedEvent:
commandName: find
- commandStartedEvent:
commandName: find
command:
find: *collection
maxTimeMS: { $$type: [int, long] }
- commandStartedEvent:
commandName: getMore
command:
getMore: { $$type: [int, long] }
collection: *collection
maxTimeMS: { $$exists: false }
# If timeoutMode=ITERATION, timeoutMS applies separately to the initial find and the getMore on the cursor. Neither
# command should have a maxTimeMS field. This is a failure test. The "find" inherits timeoutMS=100 and "getMore"
# commands are blocked for 60ms, causing iteration to fail with a timeout error.
- description: Non-tailable cursor iteration timeoutMS is refreshed for getMore if timeoutMode is iteration - failure
runOnRequirements:
- serverless: forbid
operations:
- name: failPoint
object: testRunner
arguments:
client: *failPointClient
failPoint:
configureFailPoint: failCommand
mode: { times: 1 }
data:
failCommands: ["getMore"]
blockConnection: true
blockTimeMS: 60
- name: runCursorCommand
object: *db
arguments:
commandName: find
command: { find: *collection, batchSize: 2 }
timeoutMode: iteration
timeoutMS: 100
batchSize: 2
expectError:
isTimeoutError: true
expectEvents:
- client: *client
events:
- commandStartedEvent:
commandName: find
databaseName: *db
command:
find: *collection
maxTimeMS: { $$exists: false }
- commandStartedEvent:
commandName: getMore
databaseName: *db
command:
getMore: { $$type: ["int", "long"] }
collection: *collection
maxTimeMS: { $$exists: false }
# The timeoutMS option should apply separately to the initial "find" and each getMore. This is a failure test. The
# find inherits timeoutMS=100 from the collection and the getMore command blocks for 60ms, causing iteration to fail
# with a timeout error.
- description: Tailable cursor iteration timeoutMS is refreshed for getMore - failure
runOnRequirements:
- serverless: forbid
operations:
- name: failPoint
object: testRunner
arguments:
client: *failPointClient
failPoint:
configureFailPoint: failCommand
mode: { times: 1 }
data:
failCommands: ["getMore"]
blockConnection: true
blockTimeMS: 60
- name: dropCollection
object: *db
arguments:
collection: &cappedCollection cappedCollection
- name: createCollection
object: *db
arguments:
collection: *cappedCollection
capped: true
size: 4096
max: 3
saveResultAsEntity: *cappedCollection
- name: insertMany
object: *cappedCollection
arguments:
documents:
- { _id: 1, x: 11 }
- { _id: 2, x: 22 }
- name: createCommandCursor
object: *db
arguments:
commandName: find
command: { find: *cappedCollection, batchSize: 1, tailable: true }
timeoutMode: iteration
timeoutMS: 100
batchSize: 1
cursorType: tailable
saveResultAsEntity: &tailableCursor tailableCursor
# Iterate the cursor twice: the first iteration will return the document from the batch in the find and the
# second will do a getMore.
- name: iterateUntilDocumentOrError
object: *tailableCursor
- name: iterateUntilDocumentOrError
object: *tailableCursor
expectError:
isTimeoutError: true
expectEvents:
- client: *client
events:
- commandStartedEvent:
commandName: drop
- commandStartedEvent:
commandName: create
- commandStartedEvent:
commandName: insert
- commandStartedEvent:
commandName: find
databaseName: *db
command:
find: *cappedCollection
tailable: true
awaitData: { $$exists: false }
maxTimeMS: { $$exists: false }
- commandStartedEvent:
commandName: getMore
databaseName: *db
command:
getMore: { $$type: ["int", "long"] }
collection: *cappedCollection
maxTimeMS: { $$exists: false }
# The timeoutMS value should be refreshed for getMore's. This is a failure test. The find inherits timeoutMS=10 from
# the collection and the getMore blocks for 15ms, causing iteration to fail with a timeout error.
- description: Tailable cursor awaitData iteration timeoutMS is refreshed for getMore - failure
runOnRequirements:
- serverless: forbid
operations:
- name: failPoint
object: testRunner
arguments:
client: *failPointClient
failPoint:
configureFailPoint: failCommand
mode: { times: 1 }
data:
failCommands: ["getMore"]
blockConnection: true
blockTimeMS: 60
- name: dropCollection
object: *db
arguments:
collection: &cappedCollection cappedCollection
- name: createCollection
object: *db
arguments:
collection: *cappedCollection
capped: true
size: 4096
max: 3
saveResultAsEntity: *cappedCollection
- name: insertMany
object: *cappedCollection
arguments:
documents: [ { foo: bar }, { fizz: buzz } ]
- name: createCommandCursor
object: *db
arguments:
command: { find: *cappedCollection, tailable: true, awaitData: true }
cursorType: tailableAwait
batchSize: 1
saveResultAsEntity: &tailableCursor tailableCursor
# Iterate twice to force a getMore.
- name: iterateUntilDocumentOrError
object: *tailableCursor
- name: iterateUntilDocumentOrError
object: *tailableCursor
expectError:
isTimeoutError: true
expectEvents:
- client: *client
events:
- commandStartedEvent:
commandName: drop
- commandStartedEvent:
commandName: create
- commandStartedEvent:
commandName: insert
- commandStartedEvent:
commandName: find
databaseName: *db
command:
find: *cappedCollection
tailable: true
awaitData: true
maxTimeMS: { $$exists: true }
- commandStartedEvent:
commandName: getMore
databaseName: *db
command:
getMore: { $$type: ["int", "long"] }
collection: *cappedCollection