Skip to content

Commit 5d8f317

Browse files
committed
Test improvements to reduce race conditions.
A couple more improvements to reduce races. JAVA-3535
1 parent 14d72f0 commit 5d8f317

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

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

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

481485
then:
482-
nextAndClean(cursor, async) == expected
486+
results == expected
483487

484488
then:
485489
tryNextAndClean(cursor, async) == null
@@ -488,7 +492,7 @@ class ChangeStreamOperationSpecification extends OperationFunctionalSpecificatio
488492
expected = insertDocuments(helper, [5, 6])
489493
helper.killCursor(helper.getNamespace(), cursor.getWrapped().getServerCursor())
490494

491-
def results = nextAndClean(cursor, async)
495+
results = nextAndClean(cursor, async)
492496
if (results.size() < expected.size()) {
493497
results.addAll(nextAndClean(cursor, async))
494498
}

driver-reactive-streams/src/test/functional/com/mongodb/reactivestreams/client/TestSubscriber.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ public Subscription getSubscription() {
166166
* @throws AssertionError if the sequence of items observed does not exactly match {@code items}
167167
*/
168168
public void assertReceivedOnNext(final List<T> items) {
169-
if (tryMultipleTimes(2, () -> getOnNextEvents().size() != items.size())) {
169+
if (tryMultipleTimes(items.size(), () -> getOnNextEvents().size() != items.size())) {
170170
throw new AssertionError("Number of items does not match. Provided: " + items.size() + " Actual: " + getOnNextEvents().size());
171171
}
172172

0 commit comments

Comments
 (0)