Skip to content
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

Flaky test investigations #2173

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 4 additions & 7 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
```
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -98,6 +100,7 @@ private WorkerFactory setupWorkerFactory(
workerFactory.newWorker(
testWorkflowRule.getTaskQueue(),
WorkerOptions.newBuilder()
.setIdentity(workerIdentity)
.setWorkerTuner(
new CompositeTuner(
workflowTaskSlotSupplier,
Expand Down Expand Up @@ -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()
Expand All @@ -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(
Expand Down Expand Up @@ -289,7 +294,7 @@ public void execute() {}

private static class StartCallInterceptor implements ClientInterceptor {

private Boolean wasLastStartEager;
private boolean wasLastStartEager;

@Override
public <ReqT, RespT> ClientCall<ReqT, RespT> interceptCall(
Expand All @@ -300,12 +305,13 @@ public <ReqT, RespT> ClientCall<ReqT, RespT> 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<ReqT, RespT>
Expand All @@ -318,9 +324,23 @@ private final class EagerStartSniffingCall<ReqT, RespT>
@Override
public void sendMessage(ReqT message) {
StartWorkflowExecutionRequest request = (StartWorkflowExecutionRequest) message;
wasLastStartEager = request.getRequestEagerExecution();
super.sendMessage(message);
}

@Override
public void start(Listener<RespT> responseListener, Metadata headers) {
responseListener =
new ForwardingClientCallListener.SimpleForwardingClientCallListener<RespT>(
responseListener) {
@Override
public void onMessage(RespT message) {
StartWorkflowExecutionResponse response = (StartWorkflowExecutionResponse) message;
wasLastStartEager = response.hasEagerWorkflowTask();
super.onMessage(message);
}
};
super.start(responseListener, headers);
}
}
}
}
Loading