-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Implemented new prose test for Transactions #1824
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
…ons are ignored when inside a transaction. JAVA-5684
|
||
@DisplayName("Options Inside Transaction Prose Tests. 1. Write concern not inherited from collection object inside transaction") | ||
@Test | ||
void testWriteConcernInheritance() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Having to use map / flatMap to pass the session into each Mono is painful. But appears to be the correct way to ensure that the session use is correctly ordered.
import static com.mongodb.ClusterFixture.isSharded; | ||
import static org.junit.Assert.assertTrue; | ||
import static org.junit.Assume.assumeTrue; | ||
import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I took the opportunity to modernize the test to junit5
session.startTransaction(); | ||
addresses.add(collection.find(session, Document.parse("{}"))); | ||
try (MongoCursor<Document> cursor = collection.find(session, Document.parse("{}")).cursor()) { | ||
addresses.add(cursor.getServerAddress()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The test wasn't to spec as it didn't actually check the server addresses, as it does in the prose test spec.
session = client.startSession(); | ||
public void testNewTransactionUnpinsSession() { | ||
collection.insertOne(Document.parse("{}")); | ||
try (ClientSession session = client.startSession()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Prefer try with resources (this code was from java 6 days).
return isSharded(); | ||
@DisplayName("Options Inside Transaction Prose Tests. 1. Write concern not inherited from collection object inside transaction") | ||
@Test | ||
void testWriteConcernInheritance() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The new prose test.
…on cold publishers Only run the validation when subscribe has been called. JAVA-5985
} | ||
|
||
@Override | ||
public Publisher<Void> commitTransaction() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Writing the reactive streams prose test identified a bug. Validation was done when the publisher was created and not when the publisher was being used.
This complicated the usage of transactions, a fact that was hidden by the lack of prose tests! This fix is in the remit of JAVA-5895
Ensuring collection write concern options are ignored when inside a transaction.
JAVA-5684