-
Notifications
You must be signed in to change notification settings - Fork 150
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
WorkflowClient#execute doesn't pair correctly with workflowStub.getResult() #856
Comments
I am seeing a similar issue with The use case looks like this: class EventConsumer {
private WorkflowClient workflowClient;
public EventConsumer(WorkflowClient client) {
this.workflowClient = client;
}
public void accept(Stream<SomeEvent> eventStream) {
eventStream.forEach(event -> {
final var workflowOptions = WorkflowOptions.newBuilder()
.setTaskQueue("someQueue)
.setWorkflowId(event.getId())
.setWorkflowIdReusePolicy(WORKFLOW_ID_REUSE_POLICY_ALLOW_DUPLICATE_FAILED_ONLY)
.build();
final var workflow = workflowClient.newWorkflowStub(MyWorkflow.class, workflowOptions);
WorkflowClient.execute(workflow::processEvent, event)
.whenComplete((v, throwable) -> log.info("completed"));
});
}
} The test case uses junit5 extension: class EventConsumerTest {
@RegisterExtension
public static final TestWorkflowExtension testWorkflowExtension = TestWorkflowExtension.newBuilder()
.setWorkflowClientOptions(WorkflowClientOptions.newBuilder()
.setNamespace("namespace")
.build())
.setWorkflowTypes(MyWorkflow.class)
.setDoNotStart(true)
.build();
@Test
void startWorkflow(TestWorkflowEnvironment testEnv, Worker worker) {
MyActivity activity = mock(MyActivity.class, withSettings().withoutAnnotations());
worker.registerActivitiesImplementations(activity);
testEnv.start();
EventConsumer consumer = new EventConsumer(testEnv.getWorkflowClient());
// assertJ assertion
assertThatCode(() -> consumer.accept(Stream.of(event))).doesNotThrowAnyException();
// mockito verification
then(activity).should(timeout(5000)).doSomething();
} The test times out after 5s as specified on the mockito verification and the (anonymized) log trace looks like this:
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Actual behavior
Spikhalskiy@40c0d62#diff-7cfba47d2337ff3ee746b09a4d916e5e839f9b8bff45a26e588727667437c160R94
This unit test for a trivial workflow, that finishes immediately, hangs.
Uncommenting on either sleep or waiting for a completable future makes it pass.
Replacing execute with start (that returns
WorkflowExecution
) also makes this test pass.Expected behavior
The test passes.
The text was updated successfully, but these errors were encountered: