File: non-tailable-cursors.yml

package info (click to toggle)
ruby-mongo 2.21.3-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 14,764 kB
  • sloc: ruby: 108,806; makefile: 5; sh: 2
file content (307 lines) | stat: -rw-r--r-- 10,121 bytes parent folder | download
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
description: "timeoutMS behaves correctly for non-tailable cursors"

schemaVersion: "1.9"

runOnRequirements:
  - minServerVersion: "4.4"

createEntities:
  - client:
      id: &failPointClient failPointClient
      useMultipleMongoses: false
  - client:
      id: &client client
      uriOptions:
        timeoutMS: 10
      useMultipleMongoses: false
      observeEvents:
        - commandStartedEvent
      ignoreCommandMonitoringEvents:
        - killCursors
  - database:
      id: &database database
      client: *client
      databaseName: &databaseName test
  - collection:
      id: &collection collection
      database: *database
      collectionName: &collectionName coll

initialData:
  - collectionName: *collectionName
    databaseName: *databaseName
    documents:
      - { _id: 0 }
      - { _id: 1 }
      - { _id: 2 }
  - collectionName: &aggregateOutputCollectionName aggregateOutputColl
    databaseName: *databaseName
    documents: []

tests:
  # If timeoutMode is explicitly set to CURSOR_LIFETIME, the timeout should apply to the initial command.
  # This should also be the case if timeoutMode is unset, but this is already tested in global-timeoutMS.yml.
  - description: "timeoutMS applied to find if timeoutMode is cursor_lifetime"
    operations:
      - name: failPoint
        object: testRunner
        arguments:
          client: *failPointClient
          failPoint:
            configureFailPoint: failCommand
            mode: { times: 1 }
            data:
              failCommands: ["find"]
              blockConnection: true
              # changed to 30ms to accommodate jruby latencies
              blockTimeMS: 30
      - name: find
        object: *collection
        arguments:
          filter: {}
          # added as a 25ms timeout to accommodate jruby latencies
          timeoutMS: 25
          timeoutMode: cursorLifetime
        expectError:
          isTimeoutError: true
    expectEvents:
      - client: *client
        events:
          - commandStartedEvent:
              commandName: find
              databaseName: *databaseName
              command:
                find: *collectionName
                maxTimeMS: { $$type: ["int", "long"] }

  # 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: "remaining timeoutMS applied to getMore if timeoutMode is unset"
    operations:
      # Block find/getMore for 15ms.
      - name: failPoint
        object: testRunner
        arguments:
          client: *failPointClient
          failPoint:
            configureFailPoint: failCommand
            mode: { times: 2 }
            data:
              failCommands: ["find", "getMore"]
              blockConnection: true
              # bumped to 50 to accommodate jruby latencies
              blockTimeMS: 50
      # Run a find with timeoutMS=39 and batchSize=1 to force two batches, which will cause a find and a getMore to be
      # sent. Both will block for 20ms so together they will go over the timeout.
      - name: find
        object: *collection
        arguments:
          filter: {}
          # bumped to 99 to accommodate jruby latencies
          timeoutMS: 99
          batchSize: 2
        expectError:
          isTimeoutError: true
    expectEvents:
      - client: *client
        events:
          - commandStartedEvent:
              commandName: find
              databaseName: *databaseName
              command:
                find: *collectionName
                maxTimeMS: { $$type: ["int", "long"] }
          - commandStartedEvent:
              commandName: getMore
              databaseName: *databaseName
              command:
                getMore: { $$type: ["int", "long"] }
                collection: *collectionName
                maxTimeMS: { $$exists: false }

  # Same test as above, but with timeoutMode explicitly set to CURSOR_LIFETIME.
  - description: "remaining timeoutMS applied to getMore if timeoutMode is cursor_lifetime"
    operations:
      - name: failPoint
        object: testRunner
        arguments:
          client: *failPointClient
          failPoint:
            configureFailPoint: failCommand
            mode: { times: 2 }
            data:
              failCommands: ["find", "getMore"]
              blockConnection: true
              blockTimeMS: 20
      - name: find
        object: *collection
        arguments:
          filter: {}
          timeoutMode: cursorLifetime
          timeoutMS: 39
          batchSize: 2
        expectError:
          isTimeoutError: true
    expectEvents:
      - client: *client
        events:
          - commandStartedEvent:
              commandName: find
              databaseName: *databaseName
              command:
                find: *collectionName
                maxTimeMS: { $$type: ["int", "long"] }
          - commandStartedEvent:
              commandName: getMore
              databaseName: *databaseName
              command:
                getMore: { $$type: ["int", "long"] }
                collection: *collectionName
                maxTimeMS: { $$exists: false }

  # If timeoutMode=ITERATION, timeoutMS should apply to the initial find command and the command shouldn't have a
  # maxTimeMS field.
  - description: "timeoutMS applied to find if timeoutMode is iteration"
    operations:
      - name: failPoint
        object: testRunner
        arguments:
          client: *failPointClient
          failPoint:
            configureFailPoint: failCommand
            mode: { times: 1 }
            data:
              failCommands: ["find"]
              blockConnection: true
              blockTimeMS: 15
      - name: find
        object: *collection
        arguments:
          filter: {}
          timeoutMode: iteration
        expectError:
          isTimeoutError: true
    expectEvents:
      - client: *client
        events:
          - commandStartedEvent:
              commandName: find
              databaseName: *databaseName
              command:
                find: *collectionName
                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 success test. The "find" is executed with timeoutMS=29 and both
  # "find" and "getMore" commands are blocked for 15ms each. Neither exceeds the timeout, so iteration succeeds.
  - description: "timeoutMS is refreshed for getMore if timeoutMode is iteration - success"
    operations:
      - name: failPoint
        object: testRunner
        arguments:
          client: *failPointClient
          failPoint:
            configureFailPoint: failCommand
            mode: { times: 2 }
            data:
              failCommands: ["find", "getMore"]
              blockConnection: true
              # blockTimeMS: 15
              # Increase timeout
              blockTimeMS: 20
      - name: find
        object: *collection
        arguments:
          filter: {}
          timeoutMode: iteration
          # timeoutMS: 29
          # Increase timeout
          timeoutMS: 39
          batchSize: 2
    expectEvents:
      - client: *client
        events:
          - commandStartedEvent:
              commandName: find
              databaseName: *databaseName
              command:
                find: *collectionName
                maxTimeMS: { $$exists: false }
          - commandStartedEvent:
              commandName: getMore
              databaseName: *databaseName
              command:
                getMore: { $$type: ["int", "long"] }
                collection: *collectionName
                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=10 and "getMore"
  # commands are blocked for 15ms, causing iteration to fail with a timeout error.
  - description: "timeoutMS is refreshed for getMore if timeoutMode is iteration - failure"
    operations:
      - name: failPoint
        object: testRunner
        arguments:
          client: *failPointClient
          failPoint:
            configureFailPoint: failCommand
            mode: { times: 1 }
            data:
              failCommands: ["getMore"]
              blockConnection: true
              blockTimeMS: 15
      - name: find
        object: *collection
        arguments:
          filter: {}
          timeoutMode: iteration
          batchSize: 2
        expectError:
          isTimeoutError: true
    expectEvents:
      - client: *client
        events:
          - commandStartedEvent:
              commandName: find
              databaseName: *databaseName
              command:
                find: *collectionName
                maxTimeMS: { $$exists: false }
          - commandStartedEvent:
              commandName: getMore
              databaseName: *databaseName
              command:
                getMore: { $$type: ["int", "long"] }
                collection: *collectionName
                maxTimeMS: { $$exists: false }

  - description: "aggregate with $out errors if timeoutMode is iteration"
    operations:
      - name: aggregate
        object: *collection
        arguments:
          pipeline:
            - $out: *aggregateOutputCollectionName
          timeoutMS: 100
          timeoutMode: iteration
        expectError:
          isClientError: true
    expectEvents:
      - client: *client
        events: []

  - description: "aggregate with $merge errors if timeoutMode is iteration"
    operations:
      - name: aggregate
        object: *collection
        arguments:
          pipeline:
            - $merge: *aggregateOutputCollectionName
          timeoutMS: 100
          timeoutMode: iteration
        expectError:
          isClientError: true
    expectEvents:
      - client: *client
        events: []