From 784dc5135438bd0cca6cc209c2f44a820406250c Mon Sep 17 00:00:00 2001 From: Maxim Katcharov Date: Thu, 5 Dec 2024 16:57:16 -0700 Subject: [PATCH] Add docs --- .../com/mongodb/client/unified/UnifiedTest.java | 2 +- .../client/unified/UnifiedTestModifications.java | 14 ++++++++++++-- 2 files changed, 13 insertions(+), 3 deletions(-) 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 95cde6a1a3..3610d77a91 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 @@ -382,7 +382,7 @@ public void shouldPassAllOutcomes( if (isLastAttempt) { throw e; } - + ignoreRemaining.remove(testName); abort("Ignoring failure and retrying attempt " + attemptNumber); } diff --git a/driver-sync/src/test/functional/com/mongodb/client/unified/UnifiedTestModifications.java b/driver-sync/src/test/functional/com/mongodb/client/unified/UnifiedTestModifications.java index c472f62c21..4ad7dc69b5 100644 --- a/driver-sync/src/test/functional/com/mongodb/client/unified/UnifiedTestModifications.java +++ b/driver-sync/src/test/functional/com/mongodb/client/unified/UnifiedTestModifications.java @@ -509,6 +509,12 @@ public TestApplicator when(final Supplier precondition) { return this; } + /** + * The modification, if it is a RETRY, will only be applied when the + * failure message contains the provided message fragment. If an + * {@code AssertionFailedError} occurs, and has a cause, the cause's + * message will be checked. Otherwise, the throwable will be checked. + */ public TestApplicator whenFailureContains(final String messageFragment) { this.matchesThrowable = (final Throwable e) -> { // inspect the cause for failed assertions with a cause @@ -546,11 +552,15 @@ public enum Modifier { */ SKIP, /** - * Retry the test on failure. + * Ignore results and retry the test on failure. Will not repeat the + * test if the test succeeds. Multiple copies of the test are used to + * facilitate retries. */ RETRY, /** - * Retry the test multiple times, without ignoring failures. + * The test will be retried multiple times, without the results being + * ignored. This is a helper that can be used, in patches, to check + * if certain tests are (still) flaky. */ FORCE_FLAKY, }