Skip to content

Commit e4a66e2

Browse files
committed
update cloud runner to return error when invocation fail
1 parent df05d2f commit e4a66e2

2 files changed

Lines changed: 17 additions & 1 deletion

File tree

sdk-testing/src/main/java/software/amazon/lambda/durable/testing/HistoryEventProcessor.java

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,21 @@ public <O> TestResult<O> processEvents(List<Event> events, TypeToken<O> outputTy
5353
}
5454

5555
switch (eventType) {
56-
case EXECUTION_STARTED, INVOCATION_COMPLETED -> {
56+
case EXECUTION_STARTED -> {
5757
// Execution started - no action needed, just track the event
5858
}
59+
case INVOCATION_COMPLETED -> {
60+
var details = event.invocationCompletedDetails();
61+
if (details != null
62+
&& details.error() != null
63+
&& details.error().payload() != null) {
64+
// This will get overridden by the execution events but
65+
// the test cases will still be able to see the error
66+
// if the execution succeeds.
67+
status = ExecutionStatus.FAILED;
68+
error = details.error().payload();
69+
}
70+
}
5971
case EXECUTION_SUCCEEDED -> {
6072
status = ExecutionStatus.SUCCEEDED;
6173
var details = event.executionSucceededDetails();

sdk-testing/src/main/java/software/amazon/lambda/durable/testing/TestResult.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,10 @@ public class TestResult<O> {
5151

5252
/** Returns the execution status (SUCCEEDED, FAILED, or PENDING). */
5353
public ExecutionStatus getStatus() {
54+
if (status == ExecutionStatus.SUCCEEDED && error != null) {
55+
throw new IllegalStateException(
56+
"Execution succeeded while invocation failed with: " + error.errorMessage());
57+
}
5458
return status;
5559
}
5660

0 commit comments

Comments
 (0)