-
Notifications
You must be signed in to change notification settings - Fork 200
Closed
Description
The following test case should pass
public class LocalActivityAfterCancelTest {
private final TestActivitiesImpl activitiesImpl = new TestActivitiesImpl();
@Rule
public SDKTestWorkflowRule testWorkflowRule =
SDKTestWorkflowRule.newBuilder()
.setUseExternalService(true)
.setWorkflowTypes(TestLocalActivityRetry.class, BlockingWorkflow.class)
.setActivityImplementations(activitiesImpl)
.build();
@Test
public void localActivityAfterChildWorkflowCanceled() {
TestWorkflow1 workflowStub =
testWorkflowRule.newWorkflowStubTimeoutOptions(TestWorkflow1.class);
WorkflowClient.execute(workflowStub::execute, "input");
WorkflowStub.fromTyped(workflowStub).cancel();
WorkflowFailedException exception =
Assert.assertThrows(WorkflowFailedException.class, () -> workflowStub.execute("input"));
Assert.assertEquals(
EventType.EVENT_TYPE_WORKFLOW_EXECUTION_CANCELED, exception.getWorkflowCloseEventType());
}
@Test
public void testLocalActivityAfterChildWorkflowCanceledReplay() {
assertThrows(
RuntimeException.class,
() ->
WorkflowReplayer.replayWorkflowExecutionFromResource(
"testLocalActivityAfterCancelTest.json",
LocalActivityAfterCancelTest.TestLocalActivityRetry.class));
}
@WorkflowInterface
public static class BlockingWorkflow implements TestWorkflows.TestWorkflowReturnString {
@Override
public String execute() {
Workflow.await(() -> false);
return "";
}
}
public static class TestLocalActivityRetry implements TestWorkflow1 {
@Override
public String execute(String taskQueue) {
try {
ChildWorkflowOptions childOptions =
ChildWorkflowOptions.newBuilder()
.setWorkflowId(Workflow.getInfo().getWorkflowId() + "-child1")
.setCancellationType(ChildWorkflowCancellationType.WAIT_CANCELLATION_REQUESTED)
.setParentClosePolicy(ParentClosePolicy.PARENT_CLOSE_POLICY_REQUEST_CANCEL)
.validateAndBuildWithDefaults();
TestWorkflows.TestWorkflowReturnString child =
Workflow.newChildWorkflowStub(
TestWorkflows.TestWorkflowReturnString.class, childOptions);
child.execute();
} catch (TemporalFailure e) {
if (CancellationScope.current().isCancelRequested()) {
Workflow.newDetachedCancellationScope(
() -> {
VariousTestActivities act =
Workflow.newLocalActivityStub(
VariousTestActivities.class,
LocalActivityOptions.newBuilder()
.setStartToCloseTimeout(Duration.ofSeconds(5))
.validateAndBuildWithDefaults());
act.activity1(10);
})
.run();
throw e;
}
}
return "ignored";
}
}
}
It fails with an error like
LocalActivity: invalid REQUEST_PREPARED->NON_REPLAY_WORKFLOW_TASK_STARTED, transition history is [CREATED->CHECK_EXECUTION_STATE, EXECUTING->SCHEDULE]
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels