Skip to content

Commit ad54aff

Browse files
committed
Update awaitData test for batch cursors to not send maxTimeMS when awaitData is false
1 parent b67650f commit ad54aff

File tree

2 files changed

+18
-7
lines changed

2 files changed

+18
-7
lines changed

driver-core/src/test/functional/com/mongodb/operation/AsyncQueryBatchCursorFunctionalSpecification.groovy

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,7 @@ class AsyncQueryBatchCursorFunctionalSpecification extends OperationFunctionalSp
227227
def 'should block waiting for next batch on a tailable cursor'() {
228228
collectionHelper.create(collectionName, new CreateCollectionOptions().capped(true).sizeInBytes(1000))
229229
collectionHelper.insertDocuments(new DocumentCodec(), new Document('_id', 1).append('ts', new BsonTimestamp(5, 0)))
230-
def firstBatch = executeQuery(new BsonDocument('ts', new BsonDocument('$gte', new BsonTimestamp(5, 0))), 0, 2, true, false);
230+
def firstBatch = executeQuery(new BsonDocument('ts', new BsonDocument('$gte', new BsonTimestamp(5, 0))), 0, 2, true, awaitData);
231231

232232

233233
when:
@@ -259,7 +259,10 @@ class AsyncQueryBatchCursorFunctionalSpecification extends OperationFunctionalSp
259259
}
260260

261261
where:
262-
maxTimeMS << [0, 100]
262+
awaitData | maxTimeMS
263+
true | 0
264+
true | 100
265+
false | 0
263266
}
264267

265268
def 'should respect limit'() {

driver-core/src/test/functional/com/mongodb/operation/QueryBatchCursorFunctionalSpecification.groovy

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -186,14 +186,15 @@ class QueryBatchCursorFunctionalSpecification extends OperationFunctionalSpecifi
186186

187187
@SuppressWarnings('EmptyCatchBlock')
188188
@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()
190192
collectionHelper.create(collectionName, new CreateCollectionOptions().capped(true).sizeInBytes(1000))
191193
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);
194195

195196
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)
197198

198199
then:
199200
cursor.hasNext()
@@ -203,7 +204,7 @@ class QueryBatchCursorFunctionalSpecification extends OperationFunctionalSpecifi
203204
def latch = new CountDownLatch(1)
204205
Thread.start {
205206
try {
206-
sleep(1000)
207+
sleep(500)
207208
collectionHelper.insertDocuments(new DocumentCodec(), new Document('_id', 2).append('ts', new BsonTimestamp(6, 0)))
208209
} catch (interrupt) {
209210
//pass
@@ -223,6 +224,13 @@ class QueryBatchCursorFunctionalSpecification extends OperationFunctionalSpecifi
223224
if (!cleanedUp) {
224225
throw new MongoTimeoutException('Timed out waiting for documents to be inserted')
225226
}
227+
connection?.release()
228+
229+
where:
230+
awaitData | maxTimeMS
231+
true | 0
232+
true | 100
233+
false | 0
226234
}
227235

228236
@Category(Slow)

0 commit comments

Comments
 (0)