diff --git a/driver-core/src/main/com/mongodb/internal/TimeoutContext.java b/driver-core/src/main/com/mongodb/internal/TimeoutContext.java index 6a67ee52859..937e8c83b20 100644 --- a/driver-core/src/main/com/mongodb/internal/TimeoutContext.java +++ b/driver-core/src/main/com/mongodb/internal/TimeoutContext.java @@ -65,7 +65,7 @@ public static T throwMongoTimeoutException(final String message) { } public static MongoOperationTimeoutException createMongoTimeoutException(final Throwable cause) { - return createMongoTimeoutException("Operation timed out: " + cause.getMessage(), cause); + return createMongoTimeoutException("Operation exceeded the timeout limit: " + cause.getMessage(), cause); } public static MongoOperationTimeoutException createMongoTimeoutException(final String message, final Throwable cause) { @@ -173,7 +173,7 @@ public long timeoutOrAlternative(final long alternativeTimeoutMS) { return timeout.call(MILLISECONDS, () -> 0L, (ms) -> ms, - () -> throwMongoTimeoutException("The operation timeout has expired.")); + () -> throwMongoTimeoutException("The operation exceeded the timeout limit.")); } } @@ -252,7 +252,7 @@ public int getConnectTimeoutMs() { return Math.toIntExact(Timeout.nullAsInfinite(timeout).call(MILLISECONDS, () -> connectTimeoutMS, (ms) -> connectTimeoutMS == 0 ? ms : Math.min(ms, connectTimeoutMS), - () -> throwMongoTimeoutException("The operation timeout has expired."))); + () -> throwMongoTimeoutException("The operation exceeded the timeout limit."))); } public void resetTimeout() { diff --git a/driver-core/src/main/com/mongodb/internal/async/function/RetryState.java b/driver-core/src/main/com/mongodb/internal/async/function/RetryState.java index e337db0e570..1a6c28a963d 100644 --- a/driver-core/src/main/com/mongodb/internal/async/function/RetryState.java +++ b/driver-core/src/main/com/mongodb/internal/async/function/RetryState.java @@ -209,7 +209,7 @@ private void doAdvanceOrThrow(final Throwable attemptException, */ if (hasTimeoutMs() && !loopState.isLastIteration()) { previouslyChosenException = createMongoTimeoutException( - "Retry attempt timed out.", + "Retry attempt exceeded the timeout limit.", previouslyChosenException); } throw previouslyChosenException; diff --git a/driver-core/src/main/com/mongodb/internal/connection/SocketStream.java b/driver-core/src/main/com/mongodb/internal/connection/SocketStream.java index 8f11c610a06..e0a0dd6aa15 100644 --- a/driver-core/src/main/com/mongodb/internal/connection/SocketStream.java +++ b/driver-core/src/main/com/mongodb/internal/connection/SocketStream.java @@ -164,7 +164,7 @@ public void write(final List buffers, final OperationContext operationC for (final ByteBuf cur : buffers) { outputStream.write(cur.array(), 0, cur.limit()); if (operationContext.getTimeoutContext().hasExpired()) { - throwMongoTimeoutException("Timeout occurred during socket write."); + throwMongoTimeoutException("Socket write exceeded the timeout limit."); } } } diff --git a/driver-core/src/main/com/mongodb/internal/connection/netty/NettyStream.java b/driver-core/src/main/com/mongodb/internal/connection/netty/NettyStream.java index 04989451596..b28054e7d3d 100644 --- a/driver-core/src/main/com/mongodb/internal/connection/netty/NettyStream.java +++ b/driver-core/src/main/com/mongodb/internal/connection/netty/NettyStream.java @@ -253,10 +253,7 @@ public void writeAsync(final List buffers, final OperationContext opera } long writeTimeoutMS = operationContext.getTimeoutContext().getWriteTimeoutMS(); - Optional writeTimeoutHandler = writeTimeoutMS != NO_SCHEDULE_TIME - ? Optional.of(new WriteTimeoutHandler(writeTimeoutMS, MILLISECONDS)) : Optional.empty(); - writeTimeoutHandler.map(w -> channel.pipeline().addBefore("ChannelInboundHandlerAdapter", "WriteTimeoutHandler", w)); - + final Optional writeTimeoutHandler = addWriteTimeoutHandler(writeTimeoutMS); channel.writeAndFlush(composite).addListener((ChannelFutureListener) future -> { writeTimeoutHandler.map(w -> channel.pipeline().remove(w)); if (!future.isSuccess()) { @@ -267,6 +264,15 @@ public void writeAsync(final List buffers, final OperationContext opera }); } + private Optional addWriteTimeoutHandler(final long writeTimeoutMS) { + if (writeTimeoutMS != NO_SCHEDULE_TIME) { + WriteTimeoutHandler writeTimeoutHandler = new WriteTimeoutHandler(writeTimeoutMS, MILLISECONDS); + channel.pipeline().addBefore("ChannelInboundHandlerAdapter", "WriteTimeoutHandler", writeTimeoutHandler); + return Optional.of(writeTimeoutHandler); + } + return Optional.empty(); + } + @Override public void readAsync(final int numBytes, final OperationContext operationContext, final AsyncCompletionHandler handler) { readAsync(numBytes, handler, operationContext.getTimeoutContext().getReadTimeoutMS()); diff --git a/driver-core/src/test/functional/com/mongodb/internal/connection/TestCommandListener.java b/driver-core/src/test/functional/com/mongodb/internal/connection/TestCommandListener.java index b114514f326..704dea56f44 100644 --- a/driver-core/src/test/functional/com/mongodb/internal/connection/TestCommandListener.java +++ b/driver-core/src/test/functional/com/mongodb/internal/connection/TestCommandListener.java @@ -184,6 +184,12 @@ public List getCommandFailedEvents() { return getEvents(CommandFailedEvent.class, Integer.MAX_VALUE); } + public List getCommandFailedEvents(final String commandName) { + return getEvents(CommandFailedEvent.class, + commandEvent -> commandEvent.getCommandName().equals(commandName), + Integer.MAX_VALUE); + } + public List getCommandStartedEvents() { return getEvents(CommandStartedEvent.class, Integer.MAX_VALUE); } diff --git a/driver-core/src/test/resources/unified-test-format/client-side-operation-timeout/non-tailable-cursors.json b/driver-core/src/test/resources/unified-test-format/client-side-operation-timeout/non-tailable-cursors.json index 291c6e72aa1..dd22ac3996f 100644 --- a/driver-core/src/test/resources/unified-test-format/client-side-operation-timeout/non-tailable-cursors.json +++ b/driver-core/src/test/resources/unified-test-format/client-side-operation-timeout/non-tailable-cursors.json @@ -1,5 +1,6 @@ { "description": "timeoutMS behaves correctly for non-tailable cursors", + "comment": "Manually reduced blockTimeMS for tests to pass in serverless", "schemaVersion": "1.9", "runOnRequirements": [ { @@ -143,7 +144,7 @@ "getMore" ], "blockConnection": true, - "blockTimeMS": 125 + "blockTimeMS": 101 } } } @@ -221,7 +222,7 @@ "getMore" ], "blockConnection": true, - "blockTimeMS": 150 + "blockTimeMS": 101 } } } @@ -355,7 +356,7 @@ "getMore" ], "blockConnection": true, - "blockTimeMS": 125 + "blockTimeMS": 101 } } } 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 ecc8dda3592..f14cb3e18a1 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 @@ -51,7 +51,7 @@ final class RetryStateTest { private static final TimeoutContext TIMEOUT_CONTEXT_INFINITE_GLOBAL_TIMEOUT = new TimeoutContext(new TimeoutSettings(0L, 0L, 0L, 0L, 0L)); - private static final String EXPECTED_TIMEOUT_MESSAGE = "Retry attempt timed out."; + private static final String EXPECTED_TIMEOUT_MESSAGE = "Retry attempt exceeded the timeout limit."; static Stream infiniteTimeout() { return Stream.of( @@ -302,7 +302,7 @@ void advanceThrowTimeoutExceptionWhenTransformerSwallowOriginalTimeoutException( (rs, e) -> false)); Assertions.assertNotEquals(actualTimeoutException, expectedTimeoutException); - Assertions.assertEquals("Retry attempt timed out.", actualTimeoutException.getMessage()); + Assertions.assertEquals(EXPECTED_TIMEOUT_MESSAGE, actualTimeoutException.getMessage()); Assertions.assertEquals(previousAttemptException, actualTimeoutException.getCause(), "Retry timeout exception should have a cause if transformer returned non-timeout exception."); } diff --git a/driver-reactive-streams/src/main/com/mongodb/reactivestreams/client/internal/ClientSessionPublisherImpl.java b/driver-reactive-streams/src/main/com/mongodb/reactivestreams/client/internal/ClientSessionPublisherImpl.java index fceee433ef6..62314c7e141 100644 --- a/driver-reactive-streams/src/main/com/mongodb/reactivestreams/client/internal/ClientSessionPublisherImpl.java +++ b/driver-reactive-streams/src/main/com/mongodb/reactivestreams/client/internal/ClientSessionPublisherImpl.java @@ -166,7 +166,6 @@ public Publisher commitTransaction() { .execute( new CommitTransactionOperation(writeConcern, alreadyCommitted) .recoveryToken(getRecoveryToken()), readConcern, this) - .doOnSuccess(ignored -> setTimeoutContext(null)) .doOnTerminate(() -> { commitInProgress = false; transactionState = TransactionState.COMMITTED; diff --git a/driver-reactive-streams/src/main/com/mongodb/reactivestreams/client/internal/gridfs/GridFSUploadPublisherImpl.java b/driver-reactive-streams/src/main/com/mongodb/reactivestreams/client/internal/gridfs/GridFSUploadPublisherImpl.java index c44a55ee2e4..a45d369c676 100644 --- a/driver-reactive-streams/src/main/com/mongodb/reactivestreams/client/internal/gridfs/GridFSUploadPublisherImpl.java +++ b/driver-reactive-streams/src/main/com/mongodb/reactivestreams/client/internal/gridfs/GridFSUploadPublisherImpl.java @@ -279,7 +279,7 @@ private static Mono createMonoTimer(final @Nulla private static Mono createTimeoutMonoError() { return Mono.error(TimeoutContext.createMongoTimeoutException( - "GridFS timed out waiting for data from provided source Publisher")); + "GridFS waiting for data from the source Publisher exceeded the timeout limit.")); } private Mono createSaveFileDataMono(final AtomicBoolean terminated, diff --git a/driver-reactive-streams/src/test/functional/com/mongodb/reactivestreams/client/ClientSideOperationTimeoutProseTest.java b/driver-reactive-streams/src/test/functional/com/mongodb/reactivestreams/client/ClientSideOperationTimeoutProseTest.java index 8dc6716080e..e4d8971872f 100644 --- a/driver-reactive-streams/src/test/functional/com/mongodb/reactivestreams/client/ClientSideOperationTimeoutProseTest.java +++ b/driver-reactive-streams/src/test/functional/com/mongodb/reactivestreams/client/ClientSideOperationTimeoutProseTest.java @@ -41,9 +41,7 @@ import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.DisplayName; -import org.junit.jupiter.api.Tag; import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.TestInfo; import reactor.core.publisher.Flux; import reactor.core.publisher.Hooks; import reactor.test.StepVerifier; @@ -107,7 +105,6 @@ protected boolean isAsync() { return true; } - @Tag("setsFailPoint") @DisplayName("6. GridFS Upload - uploads via openUploadStream can be timed out") @Test @Override @@ -117,7 +114,7 @@ public void testGridFSUploadViaOpenUploadStreamTimeout() { //given collectionHelper.runAdminCommand("{" - + " configureFailPoint: \"failCommand\"," + + " configureFailPoint: \"" + FAIL_COMMAND_NAME + "\"," + " mode: { times: 1 }," + " data: {" + " failCommands: [\"insert\"]," @@ -164,7 +161,6 @@ public void testGridFSUploadViaOpenUploadStreamTimeout() { } } - @Tag("setsFailPoint") @DisplayName("6. GridFS Upload - Aborting an upload stream can be timed out") @Test @Override @@ -177,7 +173,7 @@ public void testAbortingGridFsUploadStreamTimeout() throws ExecutionException, I Hooks.onErrorDropped(droppedErrorFuture::complete); collectionHelper.runAdminCommand("{" - + " configureFailPoint: \"failCommand\"," + + " configureFailPoint: \"" + FAIL_COMMAND_NAME + "\"," + " mode: { times: 1 }," + " data: {" + " failCommands: [\"delete\"]," @@ -227,7 +223,6 @@ public void testAbortingGridFsUploadStreamTimeout() throws ExecutionException, I /** * Not a prose spec test. However, it is additional test case for better coverage. */ - @Tag("setsFailPoint") @DisplayName("TimeoutMS applies to full resume attempt in a next call") @Test public void testTimeoutMSAppliesToFullResumeAttemptInNextCall() { @@ -283,7 +278,6 @@ public void testTimeoutMSAppliesToFullResumeAttemptInNextCall() { /** * Not a prose spec test. However, it is additional test case for better coverage. */ - @Tag("setsFailPoint") @DisplayName("TimeoutMS applied to initial aggregate") @Test public void testTimeoutMSAppliedToInitialAggregate() { @@ -332,7 +326,6 @@ public void testTimeoutMSAppliedToInitialAggregate() { /** * Not a prose spec test. However, it is additional test case for better coverage. */ - @Tag("setsFailPoint") @DisplayName("TimeoutMS is refreshed for getMore if maxAwaitTimeMS is not set") @Test public void testTimeoutMsRefreshedForGetMoreWhenMaxAwaitTimeMsNotSet() { @@ -402,7 +395,6 @@ public void testTimeoutMsRefreshedForGetMoreWhenMaxAwaitTimeMsNotSet() { /** * Not a prose spec test. However, it is additional test case for better coverage. */ - @Tag("setsFailPoint") @DisplayName("TimeoutMS is refreshed for getMore if maxAwaitTimeMS is set") @Test public void testTimeoutMsRefreshedForGetMoreWhenMaxAwaitTimeMsSet() { @@ -420,7 +412,8 @@ public void testTimeoutMsRefreshedForGetMoreWhenMaxAwaitTimeMsSet() { .timeout(rtt + 300, TimeUnit.MILLISECONDS))) { MongoCollection collection = client.getDatabase(namespace.getDatabaseName()) - .getCollection(namespace.getCollectionName()).withReadPreference(ReadPreference.primary()); + .getCollection(namespace.getCollectionName()) + .withReadPreference(ReadPreference.primary()); collectionHelper.runAdminCommand("{" + " configureFailPoint: \"failCommand\"," @@ -449,6 +442,7 @@ public void testTimeoutMsRefreshedForGetMoreWhenMaxAwaitTimeMsSet() { .expectNextCount(2) .thenAwait(Duration.ofMillis(600)) .thenRequest(2) + .expectNextCount(2) .thenCancel() .verify(); @@ -463,7 +457,6 @@ public void testTimeoutMsRefreshedForGetMoreWhenMaxAwaitTimeMsSet() { /** * Not a prose spec test. However, it is additional test case for better coverage. */ - @Tag("setsFailPoint") @DisplayName("TimeoutMS is honored for next operation when several getMore executed internally") @Test public void testTimeoutMsISHonoredForNnextOperationWhenSeveralGetMoreExecutedInternally() { @@ -528,8 +521,8 @@ public void setUp() { @Override @AfterEach - public void tearDown(final TestInfo info) { - super.tearDown(info); + public void tearDown() { + super.tearDown(); SyncMongoClient.disableSleep(); } diff --git a/driver-reactive-streams/src/test/functional/com/mongodb/reactivestreams/client/unified/ClientSideOperationTimeoutTest.java b/driver-reactive-streams/src/test/functional/com/mongodb/reactivestreams/client/unified/ClientSideOperationTimeoutTest.java index 50edc0edcfd..4c9a1dbb7c6 100644 --- a/driver-reactive-streams/src/test/functional/com/mongodb/reactivestreams/client/unified/ClientSideOperationTimeoutTest.java +++ b/driver-reactive-streams/src/test/functional/com/mongodb/reactivestreams/client/unified/ClientSideOperationTimeoutTest.java @@ -33,13 +33,14 @@ import java.io.IOException; import java.net.URISyntaxException; import java.util.Collection; +import java.util.List; import java.util.concurrent.atomic.AtomicReference; -import static com.mongodb.client.ClientSideOperationTimeoutTest.checkSkipCSOTTest; -import static com.mongodb.client.ClientSideOperationTimeoutTest.racyTestAssertion; +import static com.mongodb.client.ClientSideOperationTimeoutTest.skipOperationTimeoutTests; import static com.mongodb.reactivestreams.client.syncadapter.SyncMongoClient.disableSleep; import static com.mongodb.reactivestreams.client.syncadapter.SyncMongoClient.enableSleepAfterCursorError; import static java.lang.String.format; +import static java.util.Arrays.asList; import static org.junit.Assume.assumeFalse; // See https://github.com/mongodb/specifications/tree/master/source/client-side-operation-timeout/tests @@ -53,7 +54,7 @@ public ClientSideOperationTimeoutTest(final String fileDescription, final String final BsonArray initialData, final BsonDocument definition) { super(schemaVersion, runOnRequirements, entities, initialData, definition); this.testDescription = testDescription; - // Time sensitive - cannot just create a cursor with publishers + skipOperationTimeoutTests(fileDescription, testDescription); assumeFalse("No iterateOnce support. There is alternative prose test for it.", testDescription.equals("timeoutMS is refreshed for getMore if maxAwaitTimeMS is not set")); @@ -74,18 +75,20 @@ The Reactive Streams specification prevents us from allowing a subsequent next c assumeFalse(testDescription.endsWith("createChangeStream on client")); assumeFalse(testDescription.endsWith("createChangeStream on database")); assumeFalse(testDescription.endsWith("createChangeStream on collection")); - assumeFalse("TODO (CSOT) - JAVA-5104", fileDescription.equals("timeoutMS behaves correctly during command execution") - && testDescription.equals("command is not sent if RTT is greater than timeoutMS")); // No withTransaction support assumeFalse(fileDescription.contains("withTransaction") || testDescription.contains("withTransaction")); - checkSkipCSOTTest(fileDescription, testDescription); - if (testDescription.equals("timeoutMS is refreshed for close")) { enableSleepAfterCursorError(256); } + /* + * The test is occasionally racy. The "killCursors" command may appear as an additional event. This is unexpected in unified tests, + * but anticipated in reactive streams because an operation timeout error triggers the closure of the stream/publisher. + */ + ignoreExtraCommandEvents(testDescription.contains("timeoutMS is refreshed for getMore - failure")); + Hooks.onOperatorDebug(); Hooks.onErrorDropped(atomicReferenceThrowable::set); } @@ -128,6 +131,14 @@ public void cleanUp() { Hooks.resetOnErrorDropped(); } + public static boolean racyTestAssertion(final String testDescription, final AssertionError e) { + return RACY_GET_MORE_TESTS.contains(testDescription) && e.getMessage().startsWith("Number of events must be the same"); + } + + private static final List RACY_GET_MORE_TESTS = asList( + "remaining timeoutMS applied to getMore if timeoutMode is cursor_lifetime", + "remaining timeoutMS applied to getMore if timeoutMode is unset"); + private void assertNoDroppedError(final String message) { Throwable droppedError = atomicReferenceThrowable.get(); if (droppedError != null) { diff --git a/driver-reactive-streams/src/test/unit/com/mongodb/reactivestreams/client/internal/gridfs/GridFSUploadPublisherImplTest.java b/driver-reactive-streams/src/test/unit/com/mongodb/reactivestreams/client/internal/gridfs/GridFSUploadPublisherImplTest.java index aa628cc6dc8..38d19647fd7 100644 --- a/driver-reactive-streams/src/test/unit/com/mongodb/reactivestreams/client/internal/gridfs/GridFSUploadPublisherImplTest.java +++ b/driver-reactive-streams/src/test/unit/com/mongodb/reactivestreams/client/internal/gridfs/GridFSUploadPublisherImplTest.java @@ -93,7 +93,7 @@ void shouldTimeoutWhenSourcePublisherCompletionExceedsOverallOperationTimeout() Throwable throwable = onErrorEvents.get(0); assertEquals(MongoOperationTimeoutException.class, throwable.getClass()); - assertEquals("GridFS timed out waiting for data from provided source Publisher", throwable.getMessage()); + assertEquals("GridFS waiting for data from the source Publisher exceeded the timeout limit.", throwable.getMessage()); //assert no chunk has been inserted as we have not sent any data from source publisher. for (CommandEvent event : commandListener.getEvents()) { diff --git a/driver-sync/src/main/com/mongodb/client/gridfs/GridFSBucketImpl.java b/driver-sync/src/main/com/mongodb/client/gridfs/GridFSBucketImpl.java index b20521a43c2..20ac8fc6d44 100644 --- a/driver-sync/src/main/com/mongodb/client/gridfs/GridFSBucketImpl.java +++ b/driver-sync/src/main/com/mongodb/client/gridfs/GridFSBucketImpl.java @@ -62,7 +62,7 @@ final class GridFSBucketImpl implements GridFSBucket { private static final int DEFAULT_CHUNKSIZE_BYTES = 255 * 1024; - private static final String TIMEOUT_MESSAGE = "GridFS operation timed out"; + private static final String TIMEOUT_MESSAGE = "GridFS operation exceeded the timeout limit."; private final String bucketName; private final int chunkSizeBytes; private final MongoCollection filesCollection; diff --git a/driver-sync/src/main/com/mongodb/client/gridfs/GridFSDownloadStreamImpl.java b/driver-sync/src/main/com/mongodb/client/gridfs/GridFSDownloadStreamImpl.java index d6b9fcc4f40..709ae68138b 100644 --- a/driver-sync/src/main/com/mongodb/client/gridfs/GridFSDownloadStreamImpl.java +++ b/driver-sync/src/main/com/mongodb/client/gridfs/GridFSDownloadStreamImpl.java @@ -40,7 +40,7 @@ import static java.lang.String.format; class GridFSDownloadStreamImpl extends GridFSDownloadStream { - private static final String TIMEOUT_MESSAGE = "The GridFS download stream has timed out"; + private static final String TIMEOUT_MESSAGE = "The GridFS download stream exceeded the timeout limit."; private final ClientSession clientSession; private final GridFSFile fileInfo; private final MongoCollection chunksCollection; diff --git a/driver-sync/src/main/com/mongodb/client/gridfs/GridFSUploadStreamImpl.java b/driver-sync/src/main/com/mongodb/client/gridfs/GridFSUploadStreamImpl.java index 9f8e512c648..240cecf78b3 100644 --- a/driver-sync/src/main/com/mongodb/client/gridfs/GridFSUploadStreamImpl.java +++ b/driver-sync/src/main/com/mongodb/client/gridfs/GridFSUploadStreamImpl.java @@ -38,7 +38,7 @@ import static com.mongodb.internal.Locks.withInterruptibleLock; final class GridFSUploadStreamImpl extends GridFSUploadStream { - public static final String TIMEOUT_MESSAGE = "The GridFS upload stream has timed out"; + public static final String TIMEOUT_MESSAGE = "The GridFS upload stream exceeded the timeout limit."; private final ClientSession clientSession; private final MongoCollection filesCollection; private final MongoCollection chunksCollection; diff --git a/driver-sync/src/main/com/mongodb/client/internal/KeyManagementService.java b/driver-sync/src/main/com/mongodb/client/internal/KeyManagementService.java index 16f6df10f21..fee5ddac729 100644 --- a/driver-sync/src/main/com/mongodb/client/internal/KeyManagementService.java +++ b/driver-sync/src/main/com/mongodb/client/internal/KeyManagementService.java @@ -139,7 +139,7 @@ private void setSocketSoTimeoutToOperationTimeout() throws SocketException { throw new AssertionError("operationTimeout cannot be infinite"); }, (ms) -> socket.setSoTimeout(Math.toIntExact(ms)), - () -> TimeoutContext.throwMongoTimeoutException("Timeout has expired while reading from KMS server")); + () -> TimeoutContext.throwMongoTimeoutException("Reading from KMS server exceeded the timeout limit.")); } @Override diff --git a/driver-sync/src/test/functional/com/mongodb/client/AbstractClientSideOperationsTimeoutProseTest.java b/driver-sync/src/test/functional/com/mongodb/client/AbstractClientSideOperationsTimeoutProseTest.java index 119ad7f4470..b8f1569bcad 100644 --- a/driver-sync/src/test/functional/com/mongodb/client/AbstractClientSideOperationsTimeoutProseTest.java +++ b/driver-sync/src/test/functional/com/mongodb/client/AbstractClientSideOperationsTimeoutProseTest.java @@ -59,9 +59,7 @@ import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Named; -import org.junit.jupiter.api.Tag; import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.TestInfo; import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.Arguments; import org.junit.jupiter.params.provider.MethodSource; @@ -87,6 +85,7 @@ import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertInstanceOf; import static org.junit.jupiter.api.Assertions.assertNotNull; import static org.junit.jupiter.api.Assertions.assertNull; import static org.junit.jupiter.api.Assertions.assertThrows; @@ -101,6 +100,7 @@ @SuppressWarnings("checkstyle:VisibilityModifier") public abstract class AbstractClientSideOperationsTimeoutProseTest { + protected static final String FAIL_COMMAND_NAME = "failCommand"; protected static final String GRID_FS_BUCKET_NAME = "db.fs"; private static final AtomicInteger COUNTER = new AtomicInteger(); @@ -124,7 +124,6 @@ protected int postSessionCloseSleep() { return 0; } - @Tag("setsFailPoint") @SuppressWarnings("try") @FlakyTest(maxAttempts = 3) @DisplayName("4. Background Connection Pooling - timeoutMS used for handshake commands") @@ -134,7 +133,7 @@ public void testBackgroundConnectionPoolingTimeoutMSUsedForHandshakeCommands() { assumeFalse(isServerlessTest()); collectionHelper.runAdminCommand("{" - + " configureFailPoint: \"failCommand\"," + + " configureFailPoint: \"" + FAIL_COMMAND_NAME + "\"," + " mode: {" + " times: 1" + " }," @@ -162,7 +161,6 @@ public void testBackgroundConnectionPoolingTimeoutMSUsedForHandshakeCommands() { } } - @Tag("setsFailPoint") @SuppressWarnings("try") @FlakyTest(maxAttempts = 3) @DisplayName("4. Background Connection Pooling - timeoutMS is refreshed for each handshake command") @@ -172,7 +170,7 @@ public void testBackgroundConnectionPoolingTimeoutMSIsRefreshedForEachHandshakeC assumeFalse(isServerlessTest()); collectionHelper.runAdminCommand("{" - + " configureFailPoint: \"failCommand\"," + + " configureFailPoint: \"" + FAIL_COMMAND_NAME + "\"," + " mode: \"alwaysOn\"," + " data: {" + " failCommands: [\"hello\", \"isMaster\", \"saslContinue\"]," @@ -198,7 +196,6 @@ public void testBackgroundConnectionPoolingTimeoutMSIsRefreshedForEachHandshakeC } } - @Tag("setsFailPoint") @FlakyTest(maxAttempts = 3) @DisplayName("5. Blocking Iteration Methods - Tailable cursors") public void testBlockingIterationMethodsTailableCursor() { @@ -236,7 +233,6 @@ public void testBlockingIterationMethodsTailableCursor() { } } - @Tag("setsFailPoint") @FlakyTest(maxAttempts = 3) @DisplayName("5. Blocking Iteration Methods - Change Streams") public void testBlockingIterationMethodsChangeStream() { @@ -284,8 +280,6 @@ public void testBlockingIterationMethodsChangeStream() { } } - - @Tag("setsFailPoint") @DisplayName("6. GridFS Upload - uploads via openUploadStream can be timed out") @Test public void testGridFSUploadViaOpenUploadStreamTimeout() { @@ -317,7 +311,6 @@ public void testGridFSUploadViaOpenUploadStreamTimeout() { } } - @Tag("setsFailPoint") @DisplayName("6. GridFS Upload - Aborting an upload stream can be timed out") @Test public void testAbortingGridFsUploadStreamTimeout() throws Throwable { @@ -349,7 +342,6 @@ public void testAbortingGridFsUploadStreamTimeout() throws Throwable { } } - @Tag("setsFailPoint") @DisplayName("6. GridFS Download") @Test public void testGridFsDownloadStreamTimeout() { @@ -426,7 +418,6 @@ public void test8ServerSelection(final String connectionString) { } } - @Tag("setsFailPoint") @DisplayName("8. Server Selection 2 / 2") @ParameterizedTest(name = "[{index}] {0}") @MethodSource("test8ServerSelectionHandshakeArguments") @@ -467,13 +458,14 @@ public void test8ServerSelectionHandshake(final String ignoredTestName, final in } } - @Tag("setsFailPoint") @SuppressWarnings("try") - @DisplayName("9. End Session 1 / 2") + @DisplayName("9. End Session. The timeout specified via the MongoClient timeoutMS option") @Test public void test9EndSessionClientTimeout() { assumeTrue(serverVersionAtLeast(4, 4)); assumeFalse(isStandalone()); + assumeFalse(isServerlessTest()); + collectionHelper.runAdminCommand("{" + " configureFailPoint: \"failCommand\"," + " mode: { times: 1 }," @@ -499,16 +491,19 @@ public void test9EndSessionClientTimeout() { assertTrue(elapsed <= 150, "Took too long to time out, elapsedMS: " + elapsed); } } - assertDoesNotThrow(() -> commandListener.getCommandFailedEvent("abortTransaction")); + CommandFailedEvent abortTransactionEvent = assertDoesNotThrow(() -> + commandListener.getCommandFailedEvent("abortTransaction")); + assertInstanceOf(MongoOperationTimeoutException.class, abortTransactionEvent.getThrowable()); } - @Tag("setsFailPoint") @SuppressWarnings("try") - @DisplayName("9. End Session 2 / 2") + @DisplayName("9. End Session. The timeout specified via the ClientSession defaultTimeoutMS option") @Test public void test9EndSessionSessionTimeout() { assumeTrue(serverVersionAtLeast(4, 4)); assumeFalse(isStandalone()); + assumeFalse(isServerlessTest()); + collectionHelper.runAdminCommand("{" + " configureFailPoint: \"failCommand\"," + " mode: { times: 1 }," @@ -534,11 +529,11 @@ public void test9EndSessionSessionTimeout() { assertTrue(elapsed <= 150, "Took too long to time out, elapsedMS: " + elapsed); } } - - assertDoesNotThrow(() -> commandListener.getCommandFailedEvent("abortTransaction")); + CommandFailedEvent abortTransactionEvent = assertDoesNotThrow(() -> + commandListener.getCommandFailedEvent("abortTransaction")); + assertInstanceOf(MongoOperationTimeoutException.class, abortTransactionEvent.getThrowable()); } - @Tag("setsFailPoint") @DisplayName("9. End Session - Custom Test: Each operation has its own timeout with commit") @Test public void test9EndSessionCustomTesEachOperationHasItsOwnTimeoutWithCommit() { @@ -570,7 +565,6 @@ public void test9EndSessionCustomTesEachOperationHasItsOwnTimeoutWithCommit() { assertDoesNotThrow(() -> commandListener.getCommandSucceededEvent("commitTransaction")); } - @Tag("setsFailPoint") @DisplayName("9. End Session - Custom Test: Each operation has its own timeout with abort") @Test public void test9EndSessionCustomTesEachOperationHasItsOwnTimeoutWithAbort() { @@ -602,7 +596,6 @@ public void test9EndSessionCustomTesEachOperationHasItsOwnTimeoutWithAbort() { assertDoesNotThrow(() -> commandListener.getCommandSucceededEvent("abortTransaction")); } - @Tag("setsFailPoint") @DisplayName("10. Convenient Transactions") @Test public void test10ConvenientTransactions() { @@ -637,7 +630,6 @@ public void test10ConvenientTransactions() { } } - @Tag("setsFailPoint") @DisplayName("10. Convenient Transactions - Custom Test: with transaction uses a single timeout") @Test public void test10CustomTestWithTransactionUsesASingleTimeout() { @@ -671,7 +663,6 @@ public void test10CustomTestWithTransactionUsesASingleTimeout() { } } - @Tag("setsFailPoint") @DisplayName("10. Convenient Transactions - Custom Test: with transaction uses a single timeout - lock") @Test public void test10CustomTestWithTransactionUsesASingleTimeoutWithLock() { @@ -710,7 +701,6 @@ public void test10CustomTestWithTransactionUsesASingleTimeoutWithLock() { /** * Not a prose spec test. However, it is additional test case for better coverage. */ - @Tag("setsFailPoint") @Test @DisplayName("Should ignore wTimeoutMS of WriteConcern to initial and subsequent commitTransaction operations") public void shouldIgnoreWtimeoutMsOfWriteConcernToInitialAndSubsequentCommitTransactionOperations() { @@ -743,7 +733,7 @@ public void shouldIgnoreWtimeoutMsOfWriteConcernToInitialAndSubsequentCommitTran if (command.containsKey("writeConcern")) { BsonDocument writeConcern = command.getDocument("writeConcern"); assertFalse(writeConcern.isEmpty()); - assertFalse(writeConcern.containsKey("wTimeoutMS")); + assertFalse(writeConcern.containsKey("wtimeout")); }}); } @@ -751,7 +741,6 @@ public void shouldIgnoreWtimeoutMsOfWriteConcernToInitialAndSubsequentCommitTran /** * Not a prose spec test. However, it is additional test case for better coverage. */ - @Tag("setsFailPoint") @DisplayName("KillCursors is not executed after getMore network error when timeout is not enabled") @Test public void testKillCursorsIsNotExecutedAfterGetMoreNetworkErrorWhenTimeoutIsNotEnabled() { @@ -799,7 +788,6 @@ public void testKillCursorsIsNotExecutedAfterGetMoreNetworkErrorWhenTimeoutIsNot /** * Not a prose spec test. However, it is additional test case for better coverage. */ - @Tag("setsFailPoint") @DisplayName("KillCursors is not executed after getMore network error") @Test public void testKillCursorsIsNotExecutedAfterGetMoreNetworkError() { @@ -843,6 +831,49 @@ public void testKillCursorsIsNotExecutedAfterGetMoreNetworkError() { } + /** + * Not a prose spec test. However, it is additional test case for better coverage. + */ + @Test + @DisplayName("Should throw timeout exception for subsequent commit transaction") + public void shouldThrowTimeoutExceptionForSubsequentCommitTransaction() { + assumeTrue(serverVersionAtLeast(4, 4)); + assumeFalse(isStandalone()); + + try (MongoClient mongoClient = createMongoClient(getMongoClientSettingsBuilder())) { + MongoCollection collection = mongoClient.getDatabase(namespace.getDatabaseName()) + .getCollection(namespace.getCollectionName()); + + try (ClientSession session = mongoClient.startSession(ClientSessionOptions.builder() + .defaultTimeout(200, TimeUnit.MILLISECONDS) + .build())) { + session.startTransaction(TransactionOptions.builder().build()); + collection.insertOne(session, new Document("x", 1)); + sleep(200); + + assertDoesNotThrow(session::commitTransaction); + + collectionHelper.runAdminCommand("{" + + " configureFailPoint: \"failCommand\"," + + " mode: { times: 1 }," + + " data: {" + + " failCommands: [\"commitTransaction\"]," + + " blockConnection: true," + + " blockTimeMS: " + 500 + + " }" + + "}"); + + //repeat commit. + assertThrows(MongoOperationTimeoutException.class, session::commitTransaction); + } + } + List commandStartedEvents = commandListener.getCommandStartedEvents("commitTransaction"); + assertEquals(2, commandStartedEvents.size()); + + List failedEvents = commandListener.getCommandFailedEvents("commitTransaction"); + assertEquals(1, failedEvents.size()); + } + private static Stream test8ServerSelectionArguments() { return Stream.of( Arguments.of(Named.of("serverSelectionTimeoutMS honored if timeoutMS is not set", @@ -891,11 +922,9 @@ public void setUp() { } @AfterEach - public void tearDown(final TestInfo info) { + public void tearDown() { + ClusterFixture.disableFailPoint(FAIL_COMMAND_NAME); if (collectionHelper != null) { - if (info.getTags().contains("setsFailPoint") && serverVersionAtLeast(4, 4)) { - collectionHelper.runAdminCommand("{configureFailPoint: \"failCommand\", mode: \"off\"}"); - } collectionHelper.drop(); filesCollectionHelper.drop(); chunksCollectionHelper.drop(); diff --git a/driver-sync/src/test/functional/com/mongodb/client/ClientSideOperationTimeoutTest.java b/driver-sync/src/test/functional/com/mongodb/client/ClientSideOperationTimeoutTest.java index 734377f41d1..c1a995fef9e 100644 --- a/driver-sync/src/test/functional/com/mongodb/client/ClientSideOperationTimeoutTest.java +++ b/driver-sync/src/test/functional/com/mongodb/client/ClientSideOperationTimeoutTest.java @@ -28,24 +28,18 @@ import java.io.IOException; import java.net.URISyntaxException; import java.util.Collection; -import java.util.List; -import static java.util.Arrays.asList; import static org.junit.Assume.assumeFalse; // See https://github.com/mongodb/specifications/tree/master/source/client-side-operation-timeout/tests @RunWith(Parameterized.class) public class ClientSideOperationTimeoutTest extends UnifiedSyncTest { - private final String testDescription; + public ClientSideOperationTimeoutTest(final String fileDescription, final String testDescription, final String schemaVersion, @Nullable final BsonArray runOnRequirements, final BsonArray entities, final BsonArray initialData, final BsonDocument definition) { super(schemaVersion, runOnRequirements, entities, initialData, definition); - this.testDescription = testDescription; - checkSkipCSOTTest(fileDescription, testDescription); - - assumeFalse("TODO (CSOT) - JAVA-5104", fileDescription.equals("timeoutMS behaves correctly for non-tailable cursors") - && testDescription.equals("timeoutMS applied to find if timeoutMode is iteration")); + skipOperationTimeoutTests(fileDescription, testDescription); } @Parameterized.Parameters(name = "{0}: {1}") @@ -56,22 +50,11 @@ public static Collection data() throws URISyntaxException, IOException @Test @Override public void shouldPassAllOutcomes() { - try { - super.shouldPassAllOutcomes(); - } catch (AssertionError e) { - if (racyTestAssertion(testDescription, e)) { - // Ignore failure - racy test often no time to do the getMore - return; - } - throw e; - } + super.shouldPassAllOutcomes(); } - public static boolean racyTestAssertion(final String testDescription, final AssertionError e) { - return RACY_GET_MORE_TESTS.contains(testDescription) && e.getMessage().startsWith("Number of events must be the same"); - } + public static void skipOperationTimeoutTests(final String fileDescription, final String testDescription) { - public static void checkSkipCSOTTest(final String fileDescription, final String testDescription) { if (ClusterFixture.isServerlessTest()) { // It is not possible to create capped collections on serverless instances. @@ -81,33 +64,16 @@ public static void checkSkipCSOTTest(final String fileDescription, final String /* Drivers MUST NOT execute a killCursors command because the pinned connection is no longer under a load balancer. */ assumeFalse(testDescription.equals("timeoutMS is refreshed for close")); } - assumeFalse("No maxTimeMS parameter for createIndex() method", testDescription.contains("maxTimeMS is ignored if timeoutMS is set - createIndex on collection")); - assumeFalse("TODO (CSOT) CRUD Failure", - testDescription.contains("socketTimeoutMS is ignored if timeoutMS is set - deleteMany on collection")); - assumeFalse("No run cursor command", fileDescription.startsWith("runCursorCommand")); assumeFalse("No special handling of runCommand", testDescription.contains("runCommand on database")); - assumeFalse("No count command helper", testDescription.endsWith("count on collection")); - assumeFalse("No operation based overrides", fileDescription.equals("timeoutMS can be overridden for an operation")); assumeFalse("No operation session based overrides", - fileDescription.equals("timeoutMS can be overridden for individual session operations")); - assumeFalse("No operation session based overrides", - fileDescription.equals("operations ignore deprected timeout options if timeoutMS is set") - && (testDescription.equals("abortTransaction ignores socketTimeoutMS if timeoutMS is set") - || testDescription.equals("commitTransaction ignores socketTimeoutMS if timeoutMS is set") - || testDescription.equals("commitTransaction ignores maxCommitTimeMS if timeoutMS is set") - )); + testDescription.equals("timeoutMS can be overridden for commitTransaction") + || testDescription.equals("timeoutMS applied to abortTransaction")); assumeFalse("No operation based overrides", fileDescription.equals("timeoutMS behaves correctly when closing cursors") && testDescription.equals("timeoutMS can be overridden for close")); - - assumeFalse("TODO (CSOT) - JAVA-5259 No client.withTimeout", testDescription.endsWith("on client")); } - - private static final List RACY_GET_MORE_TESTS = asList( - "remaining timeoutMS applied to getMore if timeoutMode is cursor_lifetime", - "remaining timeoutMS applied to getMore if timeoutMode is unset"); } diff --git a/driver-sync/src/test/functional/com/mongodb/client/csot/AbstractClientSideOperationsEncryptionTimeoutProseTest.java b/driver-sync/src/test/functional/com/mongodb/client/csot/AbstractClientSideOperationsEncryptionTimeoutProseTest.java index 636fd302824..6d3d134e2fc 100644 --- a/driver-sync/src/test/functional/com/mongodb/client/csot/AbstractClientSideOperationsEncryptionTimeoutProseTest.java +++ b/driver-sync/src/test/functional/com/mongodb/client/csot/AbstractClientSideOperationsEncryptionTimeoutProseTest.java @@ -46,9 +46,7 @@ import org.bson.codecs.BsonDocumentCodec; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Tag; import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.TestInfo; import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.ValueSource; @@ -76,6 +74,7 @@ */ public abstract class AbstractClientSideOperationsEncryptionTimeoutProseTest { + protected static final String FAIL_COMMAND_NAME = "failCommand"; private static final Map> KMS_PROVIDERS = new HashMap<>(); private final MongoNamespace keyVaultNamespace = new MongoNamespace("keyvault", "datakeys"); @@ -92,7 +91,6 @@ public abstract class AbstractClientSideOperationsEncryptionTimeoutProseTest { protected abstract MongoClient createMongoClient(MongoClientSettings.Builder builder); @Test - @Tag("setsFailPoint") void shouldThrowOperationTimeoutExceptionWhenCreateDataKey() { assumeTrue(serverVersionAtLeast(4, 4)); long rtt = ClusterFixture.getPrimaryRTT(); @@ -105,7 +103,7 @@ void shouldThrowOperationTimeoutExceptionWhenCreateDataKey() { try (ClientEncryption clientEncryption = createClientEncryption(getClientEncryptionSettingsBuilder(rtt + 100))) { keyVaultCollectionHelper.runAdminCommand("{" - + " configureFailPoint: \"failCommand\"," + + " configureFailPoint: \"" + FAIL_COMMAND_NAME + "\"," + " mode: { times: 1 }," + " data: {" + " failCommands: [\"insert\"]," @@ -126,7 +124,6 @@ void shouldThrowOperationTimeoutExceptionWhenCreateDataKey() { } @Test - @Tag("setsFailPoint") void shouldThrowOperationTimeoutExceptionWhenEncryptData() { assumeTrue(serverVersionAtLeast(4, 4)); long rtt = ClusterFixture.getPrimaryRTT(); @@ -136,7 +133,7 @@ void shouldThrowOperationTimeoutExceptionWhenEncryptData() { clientEncryption.createDataKey("local"); keyVaultCollectionHelper.runAdminCommand("{" - + " configureFailPoint: \"failCommand\"," + + " configureFailPoint: \"" + FAIL_COMMAND_NAME + "\"," + " mode: { times: 1 }," + " data: {" + " failCommands: [\"find\"]," @@ -161,13 +158,12 @@ void shouldThrowOperationTimeoutExceptionWhenEncryptData() { } @Test - @Tag("setsFailPoint") void shouldThrowOperationTimeoutExceptionWhenDecryptData() { assumeTrue(serverVersionAtLeast(4, 4)); long rtt = ClusterFixture.getPrimaryRTT(); BsonBinary encrypted; - try (ClientEncryption clientEncryption = createClientEncryption(getClientEncryptionSettingsBuilder(rtt + 100))) { + try (ClientEncryption clientEncryption = createClientEncryption(getClientEncryptionSettingsBuilder(rtt + 400))) { clientEncryption.createDataKey("local"); BsonBinary dataKey = clientEncryption.createDataKey("local"); EncryptOptions encryptOptions = new EncryptOptions("AEAD_AES_256_CBC_HMAC_SHA_512-Deterministic"); @@ -175,14 +171,14 @@ void shouldThrowOperationTimeoutExceptionWhenDecryptData() { encrypted = clientEncryption.encrypt(new BsonString("hello"), encryptOptions); } - try (ClientEncryption clientEncryption = createClientEncryption(getClientEncryptionSettingsBuilder(rtt + 100))) { + try (ClientEncryption clientEncryption = createClientEncryption(getClientEncryptionSettingsBuilder(rtt + 400))) { keyVaultCollectionHelper.runAdminCommand("{" - + " configureFailPoint: \"failCommand\"," + + " configureFailPoint: \"" + FAIL_COMMAND_NAME + "\"," + " mode: { times: 1 }," + " data: {" + " failCommands: [\"find\"]," + " blockConnection: true," - + " blockTimeMS: " + (rtt + 100) + + " blockTimeMS: " + (rtt + 500) + " }" + "}"); commandListener.reset(); @@ -199,14 +195,13 @@ void shouldThrowOperationTimeoutExceptionWhenDecryptData() { * Not a prose spec test. However, it is additional test case for better coverage. */ @Test - @Tag("setsFailPoint") void shouldDecreaseOperationTimeoutForSubsequentOperations() { assumeTrue(serverVersionAtLeast(4, 4)); long rtt = ClusterFixture.getPrimaryRTT(); long initialTimeoutMS = rtt + 2500; keyVaultCollectionHelper.runAdminCommand("{" - + " configureFailPoint: \"failCommand\"," + + " configureFailPoint: \"" + FAIL_COMMAND_NAME + "\"," + " mode: \"alwaysOn\"," + " data: {" + " failCommands: [\"insert\", \"find\", \"listCollections\"]," @@ -274,7 +269,6 @@ void shouldDecreaseOperationTimeoutForSubsequentOperations() { */ @ParameterizedTest @ValueSource(strings = {"insert", "create"}) - @Tag("setsFailPoint") void shouldThrowTimeoutExceptionWhenCreateEncryptedCollection(final String commandToTimeout) { assumeTrue(serverVersionAtLeast(7, 0)); //given @@ -298,7 +292,7 @@ void shouldThrowTimeoutExceptionWhenCreateEncryptedCollection(final String comma + "}")); keyVaultCollectionHelper.runAdminCommand("{" - + " configureFailPoint: \"failCommand\"," + + " configureFailPoint: \"" + FAIL_COMMAND_NAME + "\"," + " mode: { times: 1 }," + " data: {" + " failCommands: [\"" + commandToTimeout + "\"]," @@ -384,11 +378,9 @@ public void setUp() { } @AfterEach - public void tearDown(final TestInfo info) { + public void tearDown() { + ClusterFixture.disableFailPoint(FAIL_COMMAND_NAME); if (keyVaultCollectionHelper != null) { - if (info.getTags().contains("setsFailPoint") && serverVersionAtLeast(4, 4)) { - keyVaultCollectionHelper.runAdminCommand("{configureFailPoint: \"failCommand\", mode: \"off\"}"); - } keyVaultCollectionHelper.drop(); } } diff --git a/driver-sync/src/test/functional/com/mongodb/client/unified/UnifiedTest.java b/driver-sync/src/test/functional/com/mongodb/client/unified/UnifiedTest.java index 5e7c3270826..72d858ddc10 100644 --- a/driver-sync/src/test/functional/com/mongodb/client/unified/UnifiedTest.java +++ b/driver-sync/src/test/functional/com/mongodb/client/unified/UnifiedTest.java @@ -21,9 +21,6 @@ import com.mongodb.MongoNamespace; import com.mongodb.ReadPreference; import com.mongodb.UnixServerAddress; -import com.mongodb.event.TestServerMonitorListener; -import com.mongodb.internal.logging.LogMessage; -import com.mongodb.logging.TestLoggingInterceptor; import com.mongodb.WriteConcern; import com.mongodb.client.ClientSession; import com.mongodb.client.MongoClient; @@ -37,10 +34,13 @@ import com.mongodb.connection.ServerDescription; import com.mongodb.event.CommandEvent; import com.mongodb.event.CommandStartedEvent; +import com.mongodb.event.TestServerMonitorListener; import com.mongodb.internal.connection.TestCommandListener; import com.mongodb.internal.connection.TestConnectionPoolListener; +import com.mongodb.internal.logging.LogMessage; import com.mongodb.lang.NonNull; import com.mongodb.lang.Nullable; +import com.mongodb.logging.TestLoggingInterceptor; import org.bson.BsonArray; import org.bson.BsonBoolean; import org.bson.BsonDocument; @@ -152,10 +152,6 @@ public UnifiedTest(@Nullable final String fileDescription, final String schemaVe crudHelper = new UnifiedCrudHelper(entities, definition.getString("description").getValue()); } - protected void ignoreExtraEvents() { - ignoreExtraEvents = true; - } - public Entities getEntities() { return entities; } @@ -980,4 +976,12 @@ private BsonDocument addInitialDataAndGetClusterTime() { } return getCurrentClusterTime(); } + + protected void ignoreExtraCommandEvents(final boolean ignoreExtraEvents) { + this.ignoreExtraEvents = ignoreExtraEvents; + } + + protected void ignoreExtraEvents() { + this.ignoreExtraEvents = true; + } }