From ca9711838783163de9a15b3aca0c65e244448cd7 Mon Sep 17 00:00:00 2001 From: "slav.babanin" Date: Wed, 26 Jun 2024 23:32:23 -0700 Subject: [PATCH] Enable ignored tests. JAVA-5379 --- .../operation/MixedBulkWriteOperation.java | 2 +- .../internal/async/function/RetryStateTest.java | 17 ++++++----------- 2 files changed, 7 insertions(+), 12 deletions(-) diff --git a/driver-core/src/main/com/mongodb/internal/operation/MixedBulkWriteOperation.java b/driver-core/src/main/com/mongodb/internal/operation/MixedBulkWriteOperation.java index 9836c28fa0..c506bbda2f 100644 --- a/driver-core/src/main/com/mongodb/internal/operation/MixedBulkWriteOperation.java +++ b/driver-core/src/main/com/mongodb/internal/operation/MixedBulkWriteOperation.java @@ -475,7 +475,7 @@ private BulkWriteTracker(final boolean retry, @Nullable final BulkWriteBatch bat attempt = 0; attempts = retry ? RetryState.RETRIES + 1 : 1; this.batch = batch; - this.retryUntilTimeoutThrowsException = timeoutContext.hasTimeoutMS();; + this.retryUntilTimeoutThrowsException = timeoutContext.hasTimeoutMS(); } boolean lastAttempt() { diff --git a/driver-core/src/test/unit/com/mongodb/internal/async/function/RetryStateTest.java b/driver-core/src/test/unit/com/mongodb/internal/async/function/RetryStateTest.java index 8a843ea627..970d87d33e 100644 --- a/driver-core/src/test/unit/com/mongodb/internal/async/function/RetryStateTest.java +++ b/driver-core/src/test/unit/com/mongodb/internal/async/function/RetryStateTest.java @@ -21,7 +21,6 @@ import com.mongodb.internal.TimeoutSettings; import com.mongodb.internal.async.function.LoopState.AttachmentKey; import com.mongodb.internal.operation.retry.AttachmentKeys; -import org.junit.Ignore; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; @@ -331,14 +330,12 @@ void advanceOrThrowPredicateThrowsAfterFirstAttempt(final TimeoutContext timeout })); } - @Ignore // TODO (CSOT) update this @Test void advanceOrThrowPredicateThrowsTimeoutAfterFirstAttempt() { RetryState retryState = new RetryState(TIMEOUT_CONTEXT_EXPIRED_GLOBAL_TIMEOUT); RuntimeException predicateException = new RuntimeException() { }; - RuntimeException attemptException = new RuntimeException() { - }; + RuntimeException attemptException = new MongoOperationTimeoutException(EXPECTED_TIMEOUT_MESSAGE); MongoOperationTimeoutException mongoOperationTimeoutException = assertThrows(MongoOperationTimeoutException.class, () -> retryState.advanceOrThrow(attemptException, (e1, e2) -> e2, (rs, e) -> { assertTrue(rs.isFirstAttempt()); @@ -347,7 +344,7 @@ void advanceOrThrowPredicateThrowsTimeoutAfterFirstAttempt() { })); assertEquals(EXPECTED_TIMEOUT_MESSAGE, mongoOperationTimeoutException.getMessage()); - assertEquals(attemptException, mongoOperationTimeoutException.getCause()); + assertNull(mongoOperationTimeoutException.getCause()); } @ParameterizedTest @@ -417,14 +414,13 @@ void advanceOrThrowTransformAfterFirstAttempt(final TimeoutContext timeoutContex })); } - @Ignore // TODO (CSOT) update this @Test void advanceOrThrowTransformThrowsTimeoutExceptionAfterFirstAttempt() { RetryState retryState = new RetryState(TIMEOUT_CONTEXT_EXPIRED_GLOBAL_TIMEOUT); - RuntimeException attemptException = new RuntimeException() { - }; - RuntimeException transformerResult = new RuntimeException() { - }; + + RuntimeException attemptException = new MongoOperationTimeoutException(EXPECTED_TIMEOUT_MESSAGE); + RuntimeException transformerResult = new RuntimeException(); + MongoOperationTimeoutException mongoOperationTimeoutException = assertThrows(MongoOperationTimeoutException.class, () -> retryState.advanceOrThrow(attemptException, (e1, e2) -> { @@ -439,7 +435,6 @@ void advanceOrThrowTransformThrowsTimeoutExceptionAfterFirstAttempt() { assertEquals(EXPECTED_TIMEOUT_MESSAGE, mongoOperationTimeoutException.getMessage()); assertEquals(transformerResult, mongoOperationTimeoutException.getCause()); - } @ParameterizedTest