Skip to content

Commit 3914f0a

Browse files
committed
Reduced fragility of one of the QueryBatchCursor tests
1 parent 540674a commit 3914f0a

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

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

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import com.mongodb.OperationFunctionalSpecification
77
import com.mongodb.ServerCursor
88
import com.mongodb.binding.ConnectionSource
99
import com.mongodb.client.model.CreateCollectionOptions
10+
import com.mongodb.connection.Connection
1011
import com.mongodb.connection.QueryResult
1112
import org.bson.BsonDocument
1213
import org.bson.BsonTimestamp
@@ -241,18 +242,15 @@ class QueryBatchCursorSpecification extends OperationFunctionalSpecification {
241242

242243
// 2.2 does not properly detect cursor not found, so ignoring
243244
@IgnoreIf({ isSharded() && !serverVersionAtLeast([2, 4, 0]) })
244-
@Category(Slow)
245245
def 'should kill cursor if limit is reached on initial query'() throws InterruptedException {
246246
given:
247247
def firstBatch = executeQuery(5)
248248
def connection = connectionSource.getConnection()
249249

250250
cursor = new QueryBatchCursor<Document>(firstBatch, 5, 0, new DocumentCodec(), connectionSource, connection)
251251

252-
Thread.sleep(1000) //Note: waiting for some time for killCursor operation to be performed on a server.
253-
254252
when:
255-
makeAdditionalGetMoreCall(firstBatch.cursor)
253+
makeAdditionalGetMoreCall(firstBatch.cursor, connection)
256254

257255
then:
258256
thrown(MongoCursorNotFoundException)
@@ -429,9 +427,13 @@ class QueryBatchCursorSpecification extends OperationFunctionalSpecification {
429427
private void makeAdditionalGetMoreCall(ServerCursor serverCursor) {
430428
def connection = connectionSource.getConnection()
431429
try {
432-
connection.getMore(getNamespace(), serverCursor.getId(), 1, new DocumentCodec())
430+
makeAdditionalGetMoreCall(serverCursor, connection)
433431
} finally {
434432
connection.release()
435433
}
436434
}
435+
436+
private void makeAdditionalGetMoreCall(ServerCursor serverCursor, Connection connection) {
437+
connection.getMore(getNamespace(), serverCursor.getId(), 1, new DocumentCodec())
438+
}
437439
}

0 commit comments

Comments
 (0)