@@ -186,14 +186,15 @@ class QueryBatchCursorFunctionalSpecification extends OperationFunctionalSpecifi
186
186
187
187
@SuppressWarnings (' EmptyCatchBlock' )
188
188
@Category (Slow )
189
- def ' test tailable' () {
189
+ def ' should block waiting for next batch on a tailable cursor' () {
190
+ given :
191
+ def connection = connectionSource. getConnection()
190
192
collectionHelper. create(collectionName, new CreateCollectionOptions (). capped(true ). sizeInBytes(1000 ))
191
193
collectionHelper. insertDocuments(new DocumentCodec (), new Document (' _id' , 1 ). append(' ts' , new BsonTimestamp (5 , 0 )))
192
- def firstBatch = executeQuery(new BsonDocument (' ts' , new BsonDocument (' $gte' , new BsonTimestamp (5 , 0 ))), 0 , 2 , true , true );
193
-
194
+ def firstBatch = executeQuery(new BsonDocument (' ts' , new BsonDocument (' $gte' , new BsonTimestamp (5 , 0 ))), 0 , 2 , true , awaitData);
194
195
195
196
when :
196
- cursor = new QueryBatchCursor<Document > (firstBatch, 0 , 2 , new DocumentCodec (), connectionSource)
197
+ cursor = new QueryBatchCursor<Document > (firstBatch, 0 , 2 , maxTimeMS, new DocumentCodec (), connectionSource, connection )
197
198
198
199
then :
199
200
cursor. hasNext()
@@ -203,7 +204,7 @@ class QueryBatchCursorFunctionalSpecification extends OperationFunctionalSpecifi
203
204
def latch = new CountDownLatch (1 )
204
205
Thread . start {
205
206
try {
206
- sleep(1000 )
207
+ sleep(500 )
207
208
collectionHelper. insertDocuments(new DocumentCodec (), new Document (' _id' , 2 ). append(' ts' , new BsonTimestamp (6 , 0 )))
208
209
} catch (interrupt) {
209
210
// pass
@@ -223,6 +224,13 @@ class QueryBatchCursorFunctionalSpecification extends OperationFunctionalSpecifi
223
224
if (! cleanedUp) {
224
225
throw new MongoTimeoutException (' Timed out waiting for documents to be inserted' )
225
226
}
227
+ connection?. release()
228
+
229
+ where :
230
+ awaitData | maxTimeMS
231
+ true | 0
232
+ true | 100
233
+ false | 0
226
234
}
227
235
228
236
@Category (Slow )
0 commit comments