Skip to content
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import io.temporal.common.interceptors.Header;
import io.temporal.internal.client.ActivityClientInternal;
import io.temporal.internal.client.ActivityHandleImpl;
import io.temporal.internal.client.NamespaceInjectWorkflowServiceStubs;
import io.temporal.internal.client.RootActivityClientInvoker;
import io.temporal.internal.client.external.GenericWorkflowClientImpl;
import io.temporal.internal.client.external.ManualActivityCompletionClientFactory;
Expand Down Expand Up @@ -37,6 +38,7 @@ class ActivityClientImpl implements ActivityClient, ActivityClientInternal {
private final Scope metricsScope;

ActivityClientImpl(WorkflowServiceStubs stubs, ActivityClientOptions options) {
stubs = new NamespaceInjectWorkflowServiceStubs(stubs, options.getNamespace());
this.stubs = stubs;
this.options = options;
this.metricsScope =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
import static org.junit.Assert.*;

import io.grpc.*;
import io.temporal.client.ActivityClient;
import io.temporal.client.StartActivityOptions;
import io.temporal.client.WorkflowClient;
import io.temporal.client.WorkflowOptions;
import io.temporal.serviceclient.WorkflowServiceStubsOptions;
Expand All @@ -18,6 +20,7 @@
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.stream.Collectors;
import org.junit.After;
import org.junit.Before;
import org.junit.Rule;
Expand Down Expand Up @@ -125,6 +128,37 @@ public void allRequestsShouldHaveAnAuthToken() {
}
}

@Test
public void activityClientRequestsShouldHaveANamespace() {
testEnvironment.start();
ActivityClient client = testEnvironment.getActivityClient();
StartActivityOptions options =
StartActivityOptions.newBuilder()
.setId("activity-id")
.setTaskQueue(TASK_QUEUE)
.setStartToCloseTimeout(Duration.ofMinutes(1))
.build();

// The test server does not implement StartActivityExecution; only the outgoing headers matter.
assertThrows(StatusRuntimeException.class, () -> client.start("SomeActivity", options));

List<GrpcRequest> startRequests =
loggedRequests.stream()
.filter(request -> request.methodName.equals("StartActivityExecution"))
.collect(Collectors.toList());
assertFalse("StartActivityExecution should have been called", startRequests.isEmpty());
for (GrpcRequest grpcRequest : startRequests) {
assertEquals(
"StartActivityExecution should have an auth token",
AUTH_TOKEN,
grpcRequest.authTokenValue);
assertEquals(
"StartActivityExecution should have a namespace",
testEnvironment.getNamespace(),
grpcRequest.namespace);
}
}

public static class EmptyWorkflowImpl implements TestWorkflows.TestWorkflow1 {

@Override
Expand Down
Loading