diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 3d8a35bb3..86b61f594 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -45,7 +45,8 @@ commit messages. Read it, follow it, learn it, love it. ## Test and Build -Testing and building `sdk-java` requires running temporal docker locally, execute: +Testing and `sdk-java` by default will use the built-in test server. To run the tests against a real server, you can +either run the server via docker compose or via the CLI. ```bash curl -O https://raw.githubusercontent.com/temporalio/temporal/master/docker/docker-compose.yml @@ -57,11 +58,7 @@ docker-compose up Then run all the tests with: ```bash +export USE_DOCKER_SERVER=true +export TEMPORAL_SERVER_ADDRESS=localhost:7233 # or whatever address the server is running on ./gradlew test ``` - -Build with: - -```bash -./gradlew build -``` diff --git a/temporal-sdk/src/test/java/io/temporal/workflow/EagerWorkflowTaskDispatchTest.java b/temporal-sdk/src/test/java/io/temporal/workflow/EagerWorkflowTaskDispatchTest.java index 5ad08635a..eb9d6d23e 100644 --- a/temporal-sdk/src/test/java/io/temporal/workflow/EagerWorkflowTaskDispatchTest.java +++ b/temporal-sdk/src/test/java/io/temporal/workflow/EagerWorkflowTaskDispatchTest.java @@ -26,6 +26,7 @@ import io.temporal.api.enums.v1.EventType; import io.temporal.api.history.v1.HistoryEvent; import io.temporal.api.workflowservice.v1.StartWorkflowExecutionRequest; +import io.temporal.api.workflowservice.v1.StartWorkflowExecutionResponse; import io.temporal.api.workflowservice.v1.WorkflowServiceGrpc; import io.temporal.client.WorkflowClient; import io.temporal.client.WorkflowOptions; @@ -40,6 +41,7 @@ import io.temporal.workflow.shared.TestWorkflows; import java.util.ArrayList; import java.util.Collections; +import java.util.UUID; import java.util.concurrent.TimeUnit; import org.junit.After; import org.junit.Rule; @@ -98,6 +100,7 @@ private WorkerFactory setupWorkerFactory( workerFactory.newWorker( testWorkflowRule.getTaskQueue(), WorkerOptions.newBuilder() + .setIdentity(workerIdentity) .setWorkerTuner( new CompositeTuner( workflowTaskSlotSupplier, @@ -126,9 +129,10 @@ public void workflowIsEagerlyDispatchedOnTheWorkerRegisteredWithTheCorrespondent WorkflowOptions.newBuilder() .setTaskQueue(testWorkflowRule.getTaskQueue()) .setDisableEagerExecution(false) + .setWorkflowId(UUID.randomUUID() + "-w1") .build()); workflowStub1.execute(); - assertTrue(START_CALL_INTERCEPTOR.wasLastStartEager); + assertTrue(START_CALL_INTERCEPTOR.wasLastStartEager()); TestWorkflows.NoArgsWorkflow workflowStub2 = workerFactory2 .getWorkflowClient() @@ -137,9 +141,10 @@ public void workflowIsEagerlyDispatchedOnTheWorkerRegisteredWithTheCorrespondent WorkflowOptions.newBuilder() .setTaskQueue(testWorkflowRule.getTaskQueue()) .setDisableEagerExecution(false) + .setWorkflowId(UUID.randomUUID() + "-w2") .build()); workflowStub2.execute(); - assertTrue(START_CALL_INTERCEPTOR.wasLastStartEager); + assertTrue(START_CALL_INTERCEPTOR.wasLastStartEager()); HistoryEvent workflowTaskStartedEvent1 = testWorkflowRule.getHistoryEvent( @@ -289,7 +294,7 @@ public void execute() {} private static class StartCallInterceptor implements ClientInterceptor { - private Boolean wasLastStartEager; + private boolean wasLastStartEager; @Override public ClientCall interceptCall( @@ -300,12 +305,13 @@ public ClientCall interceptCall( return next.newCall(method, callOptions); } - public Boolean wasLastStartEager() { + public boolean wasLastStartEager() { + System.out.println("wasLastStartEager: " + wasLastStartEager); return wasLastStartEager; } public void clear() { - wasLastStartEager = null; + wasLastStartEager = false; } private final class EagerStartSniffingCall @@ -318,9 +324,23 @@ private final class EagerStartSniffingCall @Override public void sendMessage(ReqT message) { StartWorkflowExecutionRequest request = (StartWorkflowExecutionRequest) message; - wasLastStartEager = request.getRequestEagerExecution(); super.sendMessage(message); } + + @Override + public void start(Listener responseListener, Metadata headers) { + responseListener = + new ForwardingClientCallListener.SimpleForwardingClientCallListener( + responseListener) { + @Override + public void onMessage(RespT message) { + StartWorkflowExecutionResponse response = (StartWorkflowExecutionResponse) message; + wasLastStartEager = response.hasEagerWorkflowTask(); + super.onMessage(message); + } + }; + super.start(responseListener, headers); + } } } }