-
Notifications
You must be signed in to change notification settings - Fork 40
Backport to branch(3) : Fix error handling for mutations in Cassandra #2841
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -20,8 +20,8 @@ | |
| import com.scalar.db.api.Put; | ||
| import com.scalar.db.api.PutIfExists; | ||
| import com.scalar.db.api.PutIfNotExists; | ||
| import com.scalar.db.exception.storage.ExecutionException; | ||
| import com.scalar.db.exception.storage.NoMutationException; | ||
| import com.scalar.db.exception.storage.RetriableExecutionException; | ||
| import com.scalar.db.io.Key; | ||
| import java.util.Arrays; | ||
| import java.util.List; | ||
|
|
@@ -178,7 +178,7 @@ public void handle_CorrectHandlerAndAtLeastOneConditionalPutGiven_ShouldSetConsi | |
| } | ||
|
|
||
| @Test | ||
| public void handle_WTEThrownInLoggingInBatchExecution_ShouldThrowRetriableExecutionException() { | ||
| public void handle_WTEThrownInLoggingInBatchExecution_ShouldThrowExecutionException() { | ||
| // Arrange | ||
| configureBehavior(); | ||
| mutations = prepareConditionalPuts(); | ||
|
|
@@ -188,7 +188,7 @@ public void handle_WTEThrownInLoggingInBatchExecution_ShouldThrowRetriableExecut | |
|
|
||
| // Act Assert | ||
| assertThatThrownBy(() -> batch.handle(mutations)) | ||
| .isInstanceOf(RetriableExecutionException.class) | ||
| .isInstanceOf(ExecutionException.class) | ||
| .hasCause(e); | ||
| } | ||
|
|
||
|
|
@@ -206,7 +206,7 @@ public void handle_WTEThrownInMutationInBatchExecution_ShouldExecuteProperly() { | |
| } | ||
|
|
||
| @Test | ||
| public void handle_WTEThrownInCasInBatchExecution_ShouldThrowRetriableExecutionException() { | ||
| public void handle_WTEThrownInCasInBatchExecution_ShouldThrowExecutionException() { | ||
| // Arrange | ||
| configureBehavior(); | ||
| mutations = prepareConditionalPuts(); | ||
|
|
@@ -216,13 +216,12 @@ public void handle_WTEThrownInCasInBatchExecution_ShouldThrowRetriableExecutionE | |
|
|
||
| // Act Assert | ||
| assertThatThrownBy(() -> batch.handle(mutations)) | ||
| .isInstanceOf(RetriableExecutionException.class) | ||
| .isInstanceOf(ExecutionException.class) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
| .hasCause(e); | ||
| } | ||
|
|
||
| @Test | ||
| public void | ||
| handle_WTEThrownInSimpleWriteInBatchExecution_ShouldThrowRetriableExecutionException() { | ||
| public void handle_WTEThrownInSimpleWriteInBatchExecution_ShouldThrowExecutionException() { | ||
| // Arrange | ||
| configureBehavior(); | ||
| mutations = prepareConditionalPuts(); | ||
|
|
@@ -232,12 +231,12 @@ public void handle_WTEThrownInCasInBatchExecution_ShouldThrowRetriableExecutionE | |
|
|
||
| // Act Assert | ||
| assertThatThrownBy(() -> batch.handle(mutations)) | ||
| .isInstanceOf(RetriableExecutionException.class) | ||
| .isInstanceOf(ExecutionException.class) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
| .hasCause(e); | ||
| } | ||
|
|
||
| @Test | ||
| public void handle_DriverExceptionThrownInExecution_ShouldThrowRetriableExecutionException() { | ||
| public void handle_DriverExceptionThrownInExecution_ShouldThrowExecutionException() { | ||
| // Arrange | ||
| configureBehavior(); | ||
| mutations = prepareConditionalPuts(); | ||
|
|
@@ -246,7 +245,7 @@ public void handle_DriverExceptionThrownInExecution_ShouldThrowRetriableExecutio | |
|
|
||
| // Act Assert | ||
| assertThatThrownBy(() -> batch.handle(mutations)) | ||
| .isInstanceOf(RetriableExecutionException.class) | ||
| .isInstanceOf(ExecutionException.class) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
| .hasCause(e); | ||
| } | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -28,7 +28,6 @@ | |||||
| import com.scalar.db.api.PutIfNotExists; | ||||||
| import com.scalar.db.exception.storage.ExecutionException; | ||||||
| import com.scalar.db.exception.storage.NoMutationException; | ||||||
| import com.scalar.db.exception.storage.RetriableExecutionException; | ||||||
| import com.scalar.db.io.Key; | ||||||
| import org.junit.jupiter.api.BeforeEach; | ||||||
| import org.junit.jupiter.api.Test; | ||||||
|
|
@@ -330,7 +329,7 @@ public void setConsistency_PutOperationWithIfNotExistsGiven_ShouldPrepareWithQuo | |||||
| } | ||||||
|
|
||||||
| @Test | ||||||
| public void handle_WTEWithCasThrown_ShouldThrowProperExecutionException() { | ||||||
| public void handle_WTEWithCasThrown_ShouldThrowExecutionException() { | ||||||
| // Arrange | ||||||
| put = preparePutWithClusteringKey(); | ||||||
| put.withCondition(new PutIfNotExists()); | ||||||
|
|
@@ -342,13 +341,12 @@ public void handle_WTEWithCasThrown_ShouldThrowProperExecutionException() { | |||||
|
|
||||||
| // Act Assert | ||||||
| assertThatThrownBy(() -> spy.handle(put)) | ||||||
| .isInstanceOf(RetriableExecutionException.class) | ||||||
| .isInstanceOf(ExecutionException.class) | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||||||
| .hasCause(toThrow); | ||||||
| } | ||||||
|
|
||||||
| @Test | ||||||
| public void | ||||||
| handle_PutWithConditionGivenAndWTEWithSimpleThrown_ShouldThrowProperExecutionException() { | ||||||
| public void handle_PutWithConditionGivenAndWTEWithSimpleThrown_ShouldThrowExecutionException() { | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This test name is misleading. The underlying code throws a
Suggested change
|
||||||
| // Arrange | ||||||
| put = preparePutWithClusteringKey(); | ||||||
| put.withCondition(new PutIfNotExists()); | ||||||
|
|
@@ -366,7 +364,7 @@ public void handle_WTEWithCasThrown_ShouldThrowProperExecutionException() { | |||||
|
|
||||||
| @Test | ||||||
| public void | ||||||
| handle_PutWithoutConditionGivenAndWTEWithSimpleThrown_ShouldThrowProperExecutionException() { | ||||||
| handle_PutWithoutConditionGivenAndWTEWithSimpleThrown_ShouldThrowExecutionException() { | ||||||
| // Arrange | ||||||
| put = preparePutWithClusteringKey(); | ||||||
| spy = prepareSpiedInsertStatementHandler(); | ||||||
|
|
@@ -377,12 +375,12 @@ public void handle_WTEWithCasThrown_ShouldThrowProperExecutionException() { | |||||
|
|
||||||
| // Act Assert | ||||||
| assertThatThrownBy(() -> spy.handle(put)) | ||||||
| .isInstanceOf(RetriableExecutionException.class) | ||||||
| .isInstanceOf(ExecutionException.class) | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||||||
| .hasCause(toThrow); | ||||||
| } | ||||||
|
|
||||||
| @Test | ||||||
| public void handle_DriverExceptionThrown_ShouldThrowProperExecutionException() { | ||||||
| public void handle_DriverExceptionThrown_ShouldThrowExecutionException() { | ||||||
| // Arrange | ||||||
| put = preparePutWithClusteringKey(); | ||||||
| spy = prepareSpiedInsertStatementHandler(); | ||||||
|
|
||||||
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 assertion can be more specific.
isInstanceOf(ExecutionException.class)is also true for its subclasses. To ensure the test accurately verifies the exception, assert the exact type.