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
Port transactions spec tests to unified format #1310
Conversation
@jyemin: Looking at the failures related to transactions in the most recent patch build:
|
It does not have that logic because no tests had been failing. Since I'm only seeing the failures on 4.2 sharded clusters, I am currently planning to skip the two distinct tests in that variant The other failures are coming from write concern errors on collection drop. @ShaneHarvey suggested that we add a retry of drop until it succeeds. I've done that and now 3.6 and 4.0 sharded clusters are looking good. |
I'll add that Python's UTR also does not run killAllSessions or distinct since we haven't seen test failures that need those workarounds yet. |
|
@@ -89,7 +93,16 @@ public static void drop(final MongoNamespace namespace) { | |||
} | |||
|
|||
public static void drop(final MongoNamespace namespace, final WriteConcern writeConcern) { | |||
new DropCollectionOperation(namespace, writeConcern).execute(getBinding()); | |||
boolean success = false; |
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.
On sharded clusters < 4.2, drop
sometimes fails on the first try with a write concern error. Trying again works around it. Same for create
below, except with a different exception. :(
I'm curious whether other drivers will run into this. I imagine they will and if so a DRIVERS ticket is probably in order. What do you think @jmikola ?
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 don't recall encountering a PHPLIB build failure for drop
or create
in this context. If you want to open a DRIVERS ticket, I'd suggest including the server errors in the description and immediately opening a specs PR with the desired clarification while this is still fresh on your mind.
public class UnifiedTransactionsTest extends UnifiedReactiveStreamsTest { | ||
public UnifiedTransactionsTest(@SuppressWarnings("unused") final String fileDescription, | ||
@SuppressWarnings("unused") final String testDescription, | ||
final String schemaVersion, final BsonArray runOnRequirements, final BsonArray entitiesArray, | ||
final BsonArray initialData, final BsonDocument definition) { | ||
super(schemaVersion, runOnRequirements, entitiesArray, initialData, definition); | ||
assumeFalse(fileDescription.equals("count")); | ||
if (serverVersionLessThan(4, 4) && isSharded()) { |
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.
There's a way to work around this but since it only affects 4.2, which is EOL, just skip them.
@@ -217,6 +218,9 @@ public void setUp() { | |||
this::createMongoClient, | |||
this::createGridFSBucket, | |||
this::createClientEncryption); | |||
|
|||
killAllSessions(); |
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.
This is part of the unified test spec but until now wasn't needed.
@@ -838,6 +856,7 @@ private OperationResult executeAssertSessionTransactionState(final BsonDocument | |||
//noinspection SwitchStatementWithTooFewBranches | |||
switch (state) { | |||
case "starting": | |||
case "in_progress": |
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.
This is the same as is done in the legacy test runner. There doesn't appear to be any difference in observable state between the two.
@@ -449,7 +467,7 @@ private OperationResult executeOperation(final UnifiedTestContext context, final | |||
case "abortTransaction": | |||
return crudHelper.executeAbortTransaction(operation); | |||
case "withTransaction": | |||
return crudHelper.executeWithTransaction(operation, (op, idx) -> assertOperation(context, op, idx)); | |||
return crudHelper.executeWithTransaction(operation, (op, idx) -> assertOperationAndThrow(context, op, idx)); |
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.
This is necessary because, unlike a normal operation where we just assert the result (exceptional or not) and then move on to the next one, when an operation is executed in the body of a withTransaction callback, any exception thrown by that operation has to propagate out of the callback, so that it can trigger an abortTransaction instead of a commitTransaction.
...nc/src/test/functional/com/mongodb/client/unified/WithTransactionHelperTransactionsTest.java
Outdated
Show resolved
Hide resolved
driver-core/src/test/functional/com/mongodb/client/test/CollectionHelper.java
Show resolved
Hide resolved
driver-sync/src/test/functional/com/mongodb/client/unified/UnifiedTest.java
Outdated
Show resolved
Hide resolved
driver-sync/src/test/functional/com/mongodb/client/unified/UnifiedTest.java
Show resolved
Hide resolved
driver-sync/src/test/functional/com/mongodb/client/unified/UnifiedTransactionsTest.java
Show resolved
Hide resolved
driver-core/src/test/functional/com/mongodb/client/test/CollectionHelper.java
Outdated
Show resolved
Hide resolved
driver-sync/src/test/functional/com/mongodb/client/unified/UnifiedTransactionsTest.java
Show resolved
Hide resolved
Turns out that other PR is not necessary. Just moving killAllSessions to right before initial data creation did the trick. |
JAVA-4171