Skip to content

Commit

Permalink
Make Java async accepted test more forgiving
Browse files Browse the repository at this point in the history
  • Loading branch information
Quinn-With-Two-Ns committed Sep 5, 2024
1 parent 71c6d40 commit dd90883
Showing 1 changed file with 17 additions and 10 deletions.
27 changes: 17 additions & 10 deletions features/update/async_accepted/feature.java
Original file line number Diff line number Diff line change
Expand Up @@ -88,19 +88,26 @@ public Run execute(Runner runner) throws Exception {
Assertions.assertEquals(UPDATE_RESULT, handle.getResultAsync().get());
// issue an async update that should throw
updateId = UUID.randomUUID().toString();
UpdateHandle<Integer> errorHandle =
untypedStub.startUpdate(
UpdateOptions.newBuilder(Integer.class)
.setUpdateName("update")
.setUpdateId(updateId)
.setFirstExecutionRunId(run.execution.getRunId())
.setWaitForStage(WorkflowUpdateStage.ACCEPTED)
.build(),
false);
try {
// If the worker accepts the update, but fails it in the same workflow task
// the update will be marked as failed and the exception may be thrown
// from startUpdate. This is not consistent with the behavior of the
// other SDKs.
UpdateHandle<Integer> errorHandle =
untypedStub.startUpdate(
UpdateOptions.newBuilder(Integer.class)
.setUpdateName("update")
.setUpdateId(updateId)
.setFirstExecutionRunId(run.execution.getRunId())
.setWaitForStage(WorkflowUpdateStage.ACCEPTED)
.build(),
false);
errorHandle.getResultAsync().get();
Assertions.fail("unreachable");
} catch (ExecutionException e) {
} catch (Throwable e) {
if (e instanceof ExecutionException) {
e = e.getCause();
}
Assertions.assertTrue(e.getCause() instanceof WorkflowUpdateException);
WorkflowUpdateException wue = (WorkflowUpdateException) e.getCause();
Assertions.assertTrue(wue.getCause() instanceof ApplicationFailure);
Expand Down

0 comments on commit dd90883

Please # to comment.