JAVA-6055 Implement prose backpressure retryable writes tests#1929
Conversation
There was a problem hiding this comment.
Pull request overview
Adds/updates prose tests to cover the retryable writes “backpressure retryable writes” scenarios from the spec updates, including refactoring test infrastructure to configure fail points in reaction to command events.
Changes:
- Introduce
ConfigureFailPointCommandListenerto enable a failpoint once upon matching aCommandEvent, and automatically disable it via try-with-resources. - Refactor existing retryable reads/writes prose tests to use the new helper and updated spec link references.
- Add new “error propagation after encountering multiple errors” retryable writes prose test cases (with Case 1 temporarily disabled behind TODO-BACKPRESSURE).
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| driver-sync/src/test/functional/com/mongodb/internal/event/ConfigureFailPointCommandListener.java | New test utility to configure/cleanup failpoints triggered by command events. |
| driver-sync/src/test/functional/com/mongodb/client/RetryableWritesProseTest.java | Refactor existing prose tests; add new multi-error propagation cases. |
| driver-sync/src/test/functional/com/mongodb/client/RetryableReadsProseTest.java | Update prose-test references and align helper usage/signatures. |
| driver-reactive-streams/src/test/functional/com/mongodb/reactivestreams/client/RetryableWritesProseTest.java | Mirror sync prose test updates via sync-adapter delegation; add new cases. |
| driver-reactive-streams/src/test/functional/com/mongodb/reactivestreams/client/RetryableReadsProseTest.java | Update prose-test references and align helper usage/signatures. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
driver-sync/src/test/functional/com/mongodb/client/RetryableWritesProseTest.java
Show resolved
Hide resolved
...-streams/src/test/functional/com/mongodb/reactivestreams/client/RetryableReadsProseTest.java
Outdated
Show resolved
Hide resolved
53e526f to
44c8119
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 5 out of 5 changed files in this pull request and generated no new comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
44c8119 to
973ee55
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
...r-sync/src/test/functional/com/mongodb/internal/event/ConfigureFailPointCommandListener.java
Outdated
Show resolved
Hide resolved
driver-sync/src/test/functional/com/mongodb/client/RetryableWritesProseTest.java
Outdated
Show resolved
Hide resolved
973ee55 to
758b89e
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
driver-sync/src/test/functional/com/mongodb/client/RetryableWritesProseTest.java
Outdated
Show resolved
Hide resolved
driver-sync/src/test/functional/com/mongodb/client/RetryableWritesProseTest.java
Outdated
Show resolved
Hide resolved
758b89e to
d270460
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
...-streams/src/test/functional/com/mongodb/reactivestreams/client/RetryableReadsProseTest.java
Show resolved
Hide resolved
driver-sync/src/test/functional/com/mongodb/client/RetryableWritesProseTest.java
Outdated
Show resolved
Hide resolved
driver-sync/src/test/functional/com/mongodb/client/RetryableWritesProseTest.java
Outdated
Show resolved
Hide resolved
The relevant spec changes: - https://github.com/mongodb/specifications/blame/ba14b6bdc1dc695aa9cc20ccf9378592da1b2329/source/retryable-writes/tests/README.md#L265-L418 - See also https://jira.mongodb.org/browse/DRIVERS-3432 for the required fixes for "Test 3 Case 3" JAVA-6055
d270460 to
72d70e4
Compare
nhachicha
left a comment
There was a problem hiding this comment.
Good idea extracting ConfigureFailPointCommandListener as a reusable utility 👍
some minor comments from me & Claude review
...r-sync/src/test/functional/com/mongodb/internal/event/ConfigureFailPointCommandListener.java
Show resolved
Hide resolved
...r-sync/src/test/functional/com/mongodb/internal/event/ConfigureFailPointCommandListener.java
Show resolved
Hide resolved
driver-sync/src/test/functional/com/mongodb/client/RetryableWritesProseTest.java
Show resolved
Hide resolved
driver-sync/src/test/functional/com/mongodb/client/RetryableWritesProseTest.java
Outdated
Show resolved
Hide resolved
driver-sync/src/test/functional/com/mongodb/client/RetryableWritesProseTest.java
Outdated
Show resolved
Hide resolved
| import static com.mongodb.assertions.Assertions.assertTrue; | ||
| import static com.mongodb.assertions.Assertions.fail; | ||
|
|
||
| public final class ConfigureFailPointCommandListener implements CommandListener, AutoCloseable { |
There was a problem hiding this comment.
Worth annotating with @ThreadSafe ?
There was a problem hiding this comment.
Done in f9fd19e.
None of our other named (non-anonymous) implementations of CommandListener are annotated with @ThreadSafe, even though some of them are thread-safe, and some don't have to be thread-safe due to the way they are used in tests. I marked all of them with @ThreadSafe/@NotThreadSafe.
driver-sync/src/test/functional/com/mongodb/client/RetryableWritesProseTest.java
Show resolved
Hide resolved
driver-sync/src/test/functional/com/mongodb/client/RetryableWritesProseTest.java
Show resolved
Hide resolved
driver-sync/src/test/functional/com/mongodb/client/RetryableWritesProseTest.java
Outdated
Show resolved
Hide resolved
…ailPointCommandListener`
…`/`@NotThreadSafe`.
…unteringMultipleErrorsCase3` This made its `configureFailPointEventMatcher` the same as the one in cases 1 and 2, which lead to a nice simplification.
stIncMale
left a comment
There was a problem hiding this comment.
I am ready for another review round. @nhachicha, thank you for marking AI-generated concerns with [claude-review].
The new wording provides guarantees that allow assertions in event matchers.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 9 out of 9 changed files in this pull request and generated 1 comment.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
driver-sync/src/test/functional/com/mongodb/client/RetryableWritesProseTest.java
Show resolved
Hide resolved
driver-sync/src/test/functional/com/mongodb/client/RetryableWritesProseTest.java
Show resolved
Hide resolved
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 9 out of 9 changed files in this pull request and generated 5 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
driver-sync/src/test/functional/com/mongodb/client/RetryableWritesProseTest.java
Show resolved
Hide resolved
driver-sync/src/test/functional/com/mongodb/client/RetryableWritesProseTest.java
Show resolved
Hide resolved
driver-sync/src/test/functional/com/mongodb/client/RetryableWritesProseTest.java
Show resolved
Hide resolved
...streams/src/test/functional/com/mongodb/reactivestreams/client/RetryableWritesProseTest.java
Show resolved
Hide resolved
...streams/src/test/functional/com/mongodb/reactivestreams/client/RetryableWritesProseTest.java
Show resolved
Hide resolved
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 9 out of 9 changed files in this pull request and generated no new comments.
Comments suppressed due to low confidence (1)
driver-core/src/test/functional/com/mongodb/internal/connection/TestCommandListener.java:71
@ThreadSafeon thisTestCommandListenerappears incorrect:ignoreNextSucceededOrFailedEventis read/written outside oflock(e.g., set incommandStartedand read/reset incommandSucceeded/commandFailedbefore locking), which is a data race under concurrent command event delivery. Either remove the@ThreadSafeannotation, or make the state used for filtering (ignoreNextSucceededOrFailedEvent) properly concurrency-safe (and consider whether a single global flag is valid when multiple operations/threads can interleave).
@ThreadSafe
public class TestCommandListener implements CommandListener {
private final List<String> eventTypes;
private final List<String> ignoredCommandMonitoringEvents;
private final List<CommandEvent> events = new ArrayList<>();
@Nullable
private final TestListener listener;
private final Lock lock = new ReentrantLock();
private final Condition commandCompletedCondition = lock.newCondition();
private final Condition commandAnyEventCondition = lock.newCondition();
private final boolean observeSensitiveCommands;
private boolean ignoreNextSucceededOrFailedEvent;
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
I agree with AI in #1929 (review) - the code looks suspicious. But that does not change the fact that the |
The relevant spec changes:
I recommend reviewing the first two commits one by one to simplify reviewing: the first commit does the refactoring, including the necessary refactoring (the introduction of
ConfigureFailPointCommandListener), the second commit adds the new tests.I used the
TODO-BACKPRESSURE Valentincomments as described in #1918.JAVA-6055