Skip to content

Commit 216df07

Browse files
committed
JAVA-2827: Re-enable maxAwaitTime test for AggregateOperation
The server only supports maxTimeMS on getMore for tailable cursors, so added a $changeStream stage to the pipeline. Note that this is not a particularly good test, since it doesn't check to see whether maxTimeMS has been added to the getMore command. It just assumes it has been and is just checking that no exception is thrown.
1 parent a59a124 commit 216df07

File tree

1 file changed

+9
-17
lines changed

1 file changed

+9
-17
lines changed

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

Lines changed: 9 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@ import org.bson.BsonTimestamp
4949
import org.bson.Document
5050
import org.bson.codecs.BsonDocumentCodec
5151
import org.bson.codecs.DocumentCodec
52-
import spock.lang.Ignore
5352
import spock.lang.IgnoreIf
5453

5554
import static com.mongodb.ClusterFixture.collectCursorResults
@@ -63,10 +62,10 @@ import static com.mongodb.ClusterFixture.isSharded
6362
import static com.mongodb.ClusterFixture.isStandalone
6463
import static com.mongodb.ClusterFixture.serverVersionAtLeast
6564
import static com.mongodb.ExplainVerbosity.QUERY_PLANNER
66-
import static com.mongodb.internal.connection.ServerHelper.waitForLastRelease
6765
import static com.mongodb.connection.ServerType.STANDALONE
68-
import static com.mongodb.operation.QueryOperationHelper.getKeyPattern
66+
import static com.mongodb.internal.connection.ServerHelper.waitForLastRelease
6967
import static com.mongodb.operation.OperationReadConcernHelper.appendReadConcernToCommand
68+
import static com.mongodb.operation.QueryOperationHelper.getKeyPattern
7069
import static java.util.concurrent.TimeUnit.MILLISECONDS
7170
import static java.util.concurrent.TimeUnit.SECONDS
7271

@@ -444,31 +443,24 @@ class AggregateOperationSpecification extends OperationFunctionalSpecification {
444443
async << [true, false]
445444
}
446445

447-
// @IgnoreIf({ isSharded() || !serverVersionAtLeast(3, 2) })
448-
@Ignore
446+
@IgnoreIf({ !isStandalone() || !serverVersionAtLeast(3, 6) })
449447
def 'should be able to respect maxAwaitTime with pipeline'() {
450448
given:
451-
enableMaxTimeFailPoint()
452-
AggregateOperation operation = new AggregateOperation<Document>(getNamespace(), [], new DocumentCodec())
449+
AggregateOperation operation = new AggregateOperation<Document>(getNamespace(), [
450+
new BsonDocument('$changeStream', new BsonDocument())
451+
], new DocumentCodec())
453452
.batchSize(2)
454453
.maxAwaitTime(10, MILLISECONDS)
455454

456455
when:
457456
def cursor = execute(operation, async)
458-
next(cursor, async)
457+
tryNext(cursor, async)
459458

460459
then:
461-
notThrown(MongoExecutionTimeoutException)
462-
463-
when:
464-
next(cursor, async)
465-
466-
then:
467-
thrown(MongoExecutionTimeoutException)
460+
noExceptionThrown()
468461

469462
cleanup:
470-
cursor.close()
471-
disableMaxTimeFailPoint()
463+
cursor?.close()
472464

473465
where:
474466
async << [true, false]

0 commit comments

Comments
 (0)