Skip to content

Commit 629195b

Browse files
committed
Reduce race condition possibility in change stream resume test
1 parent 8c67732 commit 629195b

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

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

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -478,9 +478,13 @@ class ChangeStreamOperationSpecification extends OperationFunctionalSpecificatio
478478
when:
479479
helper.killCursor(helper.getNamespace(), cursor.getWrapped().getServerCursor())
480480
expected = insertDocuments(helper, [3, 4])
481+
def results = nextAndClean(cursor, async)
482+
if (results.size() < expected.size()) {
483+
results.addAll(nextAndClean(cursor, async))
484+
}
481485

482486
then:
483-
nextAndClean(cursor, async) == expected
487+
results == expected
484488

485489
then:
486490
tryNextAndClean(cursor, async) == null
@@ -489,8 +493,13 @@ class ChangeStreamOperationSpecification extends OperationFunctionalSpecificatio
489493
expected = insertDocuments(helper, [5, 6])
490494
helper.killCursor(helper.getNamespace(), cursor.getWrapped().getServerCursor())
491495

496+
results = nextAndClean(cursor, async)
497+
if (results.size() < expected.size()) {
498+
results.addAll(nextAndClean(cursor, async))
499+
}
500+
492501
then:
493-
nextAndClean(cursor, async) == expected
502+
results == expected
494503

495504
cleanup:
496505
cursor?.close()

0 commit comments

Comments
 (0)