Skip to content
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
58 changes: 58 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,64 @@ jobs:
with:
report_paths: "**/build/test-results/test/TEST-*.xml"

integration_test_cloud:
name: Integration test with Temporal Cloud
if: >-
github.event_name == 'push' ||
(
github.event_name == 'pull_request' &&
github.event.pull_request.head.repo.full_name == github.repository &&
github.event.pull_request.user.login != 'dependabot[bot]'
)
continue-on-error: true
runs-on: ubuntu-latest-16-cores
timeout-minutes: 60
concurrency:
group: temporal-cloud-integration-tests
cancel-in-progress: false
env:
USER: unittest
USE_EXTERNAL_SERVICE: true
# API-key authentication uses the regional data-plane endpoint; the namespace endpoint requires mTLS.
TEMPORAL_SERVICE_ADDRESS: ca-central-1.aws.api.temporal.io:7233
TEMPORAL_NAMESPACE: sdk-ci.a2dd6
steps:
- name: Checkout repo
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
with:
fetch-depth: 0
submodules: recursive
ref: ${{ github.event.pull_request.head.sha }}

- name: Set up Java
uses: actions/setup-java@be666c2fcd27ec809703dec50e508c2fdc7f6654 # v5
with:
java-version: |
11
23
distribution: "temurin"

- name: Set up Gradle
uses: gradle/actions/setup-gradle@ac396bf1a80af16236baf54bd7330ae21dc6ece5 # v6

- name: Run integration tests (Java 11)
env:
TEMPORAL_CLIENT_CLOUD_API_KEY: ${{ secrets.TEMPORAL_CLIENT_CLOUD_API_KEY }}
run: ./gradlew --no-daemon --max-workers=1 --continue test -x spotlessCheck -x spotlessApply -x spotlessJava -PtestJavaVersion=11

- name: Run virtual thread integration tests (Java 21)
if: success() || failure()
env:
TEMPORAL_CLIENT_CLOUD_API_KEY: ${{ secrets.TEMPORAL_CLIENT_CLOUD_API_KEY }}
run: ./gradlew --no-daemon --max-workers=1 :temporal-sdk:virtualThreadTests -x spotlessCheck -x spotlessApply -x spotlessJava -PtestJavaVersion=21

- name: Publish Test Report
uses: mikepenz/action-junit-report@bccf2e31636835cf0874589931c4116687171386 # v6
if: success() || failure()
with:
report_paths: "**/build/test-results/*/TEST-*.xml"
annotate_only: true

code_format:
name: Code format
runs-on: ubuntu-latest
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import io.temporal.common.interceptors.ActivityClientInterceptor;
import io.temporal.common.interceptors.Header;
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 @@ -36,6 +37,7 @@ class ActivityClientImpl implements ActivityClient {
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 @@ -19,6 +19,7 @@ public class ActivityNextRetryDelayTest {
@Rule
public SDKTestWorkflowRule testWorkflowRule =
SDKTestWorkflowRule.newBuilder()
.setTestTimeoutSeconds(30)
.setWorkflowTypes(TestWorkflowImpl.class)
.setActivityImplementations(new NextRetryDelayActivityImpl())
.build();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
import static org.junit.Assert.*;

import io.grpc.*;
import io.temporal.api.nexus.v1.Endpoint;
import io.temporal.client.ActivityClient;
import io.temporal.client.ActivityClientOptions;
import io.temporal.client.StartActivityOptions;
import io.temporal.client.WorkflowClient;
import io.temporal.client.WorkflowOptions;
import io.temporal.serviceclient.WorkflowServiceStubsOptions;
Expand All @@ -16,6 +20,7 @@
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.concurrent.atomic.AtomicInteger;
import org.junit.After;
import org.junit.Before;
import org.junit.Rule;
Expand All @@ -30,6 +35,7 @@ public class AuthorizationTokenTest {
private static final String AUTH_TOKEN = "Bearer <token>";

private TestWorkflowEnvironment testEnvironment;
private final AtomicInteger authTokenSupplyCount = new AtomicInteger();

@Rule
public TestWatcher watchman =
Expand All @@ -45,6 +51,7 @@ protected void failed(Throwable e, Description description) {
@Before
public void setUp() {
loggedRequests.clear();
authTokenSupplyCount.set(0);
WorkflowServiceStubsOptions stubOptions =
WorkflowServiceStubsOptions.newBuilder()
.addGrpcClientInterceptor(
Expand Down Expand Up @@ -78,7 +85,12 @@ public void start(Listener<RespT> responseListener, Metadata headers) {
}
}
})
.addGrpcMetadataProvider(new AuthorizationGrpcMetadataProvider(() -> AUTH_TOKEN))
.addGrpcMetadataProvider(
new AuthorizationGrpcMetadataProvider(
() -> {
authTokenSupplyCount.incrementAndGet();
return AUTH_TOKEN;
}))
.build();

TestEnvironmentOptions options =
Expand Down Expand Up @@ -120,6 +132,44 @@ public void allRequestsShouldHaveAnAuthToken() {
}
}

@Test
public void operatorServiceRequestsShouldHaveAnAuthToken() {
Endpoint endpoint = testEnvironment.createNexusEndpoint("authorization-token-test", TASK_QUEUE);
try {
assertTrue(authTokenSupplyCount.get() > 0);
} finally {
testEnvironment.deleteNexusEndpoint(endpoint);
}
}

@Test
public void activityClientRequestsShouldHaveNamespaceHeader() {
ActivityClient client =
ActivityClient.newInstance(
testEnvironment.getWorkflowServiceStubs(),
ActivityClientOptions.newBuilder()
.setNamespace(testEnvironment.getNamespace())
.build());
try {
client.start(
"TestActivity",
StartActivityOptions.newBuilder()
.setId("test-activity")
.setTaskQueue(TASK_QUEUE)
.setScheduleToCloseTimeout(Duration.ofMinutes(1))
.build());
} catch (StatusRuntimeException e) {
assertEquals(Status.Code.UNIMPLEMENTED, e.getStatus().getCode());
}

GrpcRequest request =
loggedRequests.stream()
.filter(r -> "StartActivityExecution".equals(r.methodName))
.findFirst()
.orElseThrow(() -> new AssertionError("StartActivityExecution request was not sent"));
assertEquals(testEnvironment.getNamespace(), request.namespace);
}

public static class EmptyWorkflowImpl implements TestWorkflows.TestWorkflow1 {

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ public class ScheduleTest {
@Rule
public SDKTestWorkflowRule testWorkflowRule =
SDKTestWorkflowRule.newBuilder()
.setTestTimeoutSeconds(30)
.setWorkflowTypes(ScheduleTest.QuickWorkflowImpl.class)
.build();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ public void verifyTypedSearchAttributes(

@Test
public void updateExternalSchedule() {
String namespace = testWorkflowRule.getWorkflowClient().getOptions().getNamespace();
// Create schedule using raw GRPC api to simulate one created from a different SDK
io.temporal.api.common.v1.SearchAttributes searchAttributes =
io.temporal.api.common.v1.SearchAttributes.newBuilder()
Expand Down Expand Up @@ -159,7 +160,7 @@ public void updateExternalSchedule() {
.build();
CreateScheduleRequest request =
CreateScheduleRequest.newBuilder()
.setNamespace(SDKTestWorkflowRule.NAMESPACE)
.setNamespace(namespace)
.setIdentity(testWorkflowRule.getWorkflowClient().getOptions().getIdentity())
.setRequestId(UUID.randomUUID().toString())
.setScheduleId(scheduleId)
Expand Down Expand Up @@ -224,7 +225,7 @@ public void updateExternalSchedule() {
.blockingStub()
.deleteSchedule(
DeleteScheduleRequest.newBuilder()
.setNamespace(SDKTestWorkflowRule.NAMESPACE)
.setNamespace(namespace)
.setIdentity(testWorkflowRule.getWorkflowClient().getOptions().getIdentity())
.setScheduleId(scheduleId)
.build());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ public class WorkflowIdSignedPayloadsTest {
@Rule
public SDKTestWorkflowRule testWorkflowRule =
SDKTestWorkflowRule.newBuilder()
.setTestTimeoutSeconds(30)
.setWorkflowTypes(
SimpleWorkflowWithAnActivity.class,
TestWorkflowWithCronScheduleImpl.class,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ public void queryIsOutdated() throws Throwable {

ReplayWorkflowRunTaskHandler handler =
new ReplayWorkflowRunTaskHandler(
"UnitTest",
testWorkflowRule.getWorkflowClient().getOptions().getNamespace(),
createReplayWorkflow(workflowExecutionHistory),
wft,
SingleWorkerOptions.newBuilder().build(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ private Map<String, String> getActivityTagsWithWorkerType(
String workerType, String workflowType) {
Map<String, String> tags = new HashMap<>();
tags.put("task_queue", testWorkflowRule.getTaskQueue());
tags.put("namespace", "UnitTest");
tags.put("namespace", testWorkflowRule.getWorkflowClient().getOptions().getNamespace());
tags.put("activity_type", "Execute");
tags.put("exception", "ApplicationFailure");
tags.put("worker_type", workerType);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ private Map<String, String> getWorkflowTags(String workflowType) {
"task_queue",
testWorkflowRule.getTaskQueue(),
"namespace",
"UnitTest",
testWorkflowRule.getWorkflowClient().getOptions().getNamespace(),
"workflow_type",
workflowType);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ private Map<String, String> getWorkerTags(String workerType) {
"task_queue",
testWorkflowRule.getTaskQueue(),
"namespace",
"UnitTest");
testWorkflowRule.getWorkflowClient().getOptions().getNamespace());
}

private static class MaybeFailWFTResponseInterceptor implements ClientInterceptor {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ private Map<String, String> getWorkerTags(String workerType) {
"task_queue",
testWorkflowRule.getTaskQueue(),
"namespace",
"UnitTest");
testWorkflowRule.getWorkflowClient().getOptions().getNamespace());
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,6 @@ private Map<String, String> getWorkerTags(String workerType) {
"task_queue",
testWorkflowRule.getTaskQueue(),
"namespace",
"UnitTest");
testWorkflowRule.getWorkflowClient().getOptions().getNamespace());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import io.temporal.serviceclient.MetricsTag;
import io.temporal.testing.TestEnvironmentOptions;
import io.temporal.testing.TestWorkflowEnvironment;
import io.temporal.testing.internal.ExternalServiceTestConfigurator;
import io.temporal.testing.internal.SDKTestWorkflowRule;
import io.temporal.workflow.Async;
import io.temporal.workflow.CompletablePromise;
Expand Down Expand Up @@ -52,8 +53,9 @@
public class StickyWorkerTest {

private static final boolean useExternalService =
Boolean.parseBoolean(System.getenv("USE_EXTERNAL_SERVICE"));
private static final String serviceAddress = System.getenv("TEMPORAL_SERVICE_ADDRESS");
ExternalServiceTestConfigurator.isUseExternalService();
private static final String serviceAddress =
ExternalServiceTestConfigurator.getTemporalServiceAddress();

@Rule public TestName testName = new TestName();

Expand Down Expand Up @@ -519,6 +521,8 @@ public TestEnvironmentWrapper(WorkerFactoryOptions options) {
.setMetricsScope(metricsScope)
.setWorkflowClientOptions(clientOptions)
.setWorkerFactoryOptions(options)
.setWorkflowServiceStubsOptions(
ExternalServiceTestConfigurator.getWorkflowServiceStubsOptions())
.setUseExternalService(useExternalService)
.setTarget(serviceAddress)
.build();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
import io.temporal.client.WorkflowOptions;
import io.temporal.client.WorkflowStub;
import io.temporal.serviceclient.WorkflowServiceStubs;
import io.temporal.serviceclient.WorkflowServiceStubsOptions;
import io.temporal.testing.TestEnvironmentOptions;
import io.temporal.testing.TestWorkflowEnvironment;
import io.temporal.testing.internal.ExternalServiceTestConfigurator;
Expand Down Expand Up @@ -152,9 +151,7 @@ public TestEnvironmentWrapper(WorkerFactoryOptions options) {
if (ExternalServiceTestConfigurator.isUseExternalService()) {
service =
WorkflowServiceStubs.newServiceStubs(
WorkflowServiceStubsOptions.newBuilder()
.setTarget(ExternalServiceTestConfigurator.getTemporalServiceAddress())
.build());
ExternalServiceTestConfigurator.getWorkflowServiceStubsOptions());
WorkflowClient client = WorkflowClient.newInstance(service, clientOptions);
factory = WorkerFactory.newInstance(client, options);
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
import io.temporal.internal.worker.SlotReservationData;
import io.temporal.internal.worker.TrackingSlotSupplier;
import io.temporal.serviceclient.WorkflowServiceStubs;
import io.temporal.serviceclient.WorkflowServiceStubsOptions;
import io.temporal.testing.internal.ExternalServiceTestConfigurator;
import io.temporal.testing.internal.SDKTestWorkflowRule;
import io.temporal.worker.Worker;
Expand Down Expand Up @@ -192,12 +191,13 @@ public void testEndToEndWorkerWithResourceStarvationRecovery() throws Exception
// Create connections to real Temporal server
WorkflowServiceStubs service =
WorkflowServiceStubs.newServiceStubs(
WorkflowServiceStubsOptions.newBuilder()
.setTarget(ExternalServiceTestConfigurator.getTemporalServiceAddress())
.build());
ExternalServiceTestConfigurator.getWorkflowServiceStubsOptions());
WorkflowClient client =
WorkflowClient.newInstance(
service, WorkflowClientOptions.newBuilder().setNamespace("default").build());
service,
WorkflowClientOptions.newBuilder()
.setNamespace(ExternalServiceTestConfigurator.getNamespace())
.build());
WorkerFactory workerFactory = WorkerFactory.newInstance(client);

// Create our own resource controller that we can control
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import io.temporal.client.WorkflowClient;
import io.temporal.client.WorkflowClientOptions;
import io.temporal.serviceclient.WorkflowServiceStubs;
import io.temporal.serviceclient.WorkflowServiceStubsOptions;
import io.temporal.testing.internal.ExternalServiceTestConfigurator;
import io.temporal.worker.WorkerFactory;
import java.util.concurrent.TimeUnit;
import org.junit.After;
Expand All @@ -22,8 +22,7 @@
public class WorkerFactoryTests {

private static final boolean useExternalService =
Boolean.parseBoolean(System.getenv("USE_EXTERNAL_SERVICE"));
private static final String serviceAddress = System.getenv("TEMPORAL_SERVICE_ADDRESS");
ExternalServiceTestConfigurator.isUseExternalService();

@BeforeClass
public static void beforeClass() {
Expand All @@ -37,8 +36,13 @@ public static void beforeClass() {
public void setUp() {
service =
WorkflowServiceStubs.newServiceStubs(
WorkflowServiceStubsOptions.newBuilder().setTarget(serviceAddress).build());
WorkflowClient client = WorkflowClient.newInstance(service);
ExternalServiceTestConfigurator.getWorkflowServiceStubsOptions());
WorkflowClient client =
WorkflowClient.newInstance(
service,
WorkflowClientOptions.newBuilder()
.setNamespace(ExternalServiceTestConfigurator.getNamespace())
.build());
factory = WorkerFactory.newInstance(client);
}

Expand Down Expand Up @@ -138,7 +142,7 @@ public void factoryCanBeShutdownMoreThanOnce() {
public void startFailsOnNonexistentNamespace() {
WorkflowServiceStubs serviceLocal =
WorkflowServiceStubs.newServiceStubs(
WorkflowServiceStubsOptions.newBuilder().setTarget(serviceAddress).build());
ExternalServiceTestConfigurator.getWorkflowServiceStubsOptions());
WorkflowClient clientLocal =
WorkflowClient.newInstance(
serviceLocal, WorkflowClientOptions.newBuilder().setNamespace("i_dont_exist").build());
Expand Down
Loading
Loading