From 487a4f080ed11478e4fea467242e9a80e3b09839 Mon Sep 17 00:00:00 2001 From: Matt McShane Date: Fri, 14 Jan 2022 15:20:49 -0500 Subject: [PATCH] Split out temporal-test-server module Moves the io.temporal.internal package under a new temporal-test-server module and marked the existing temporal-testing module as dependent on the same. Adjustments to top-level build.gradle and various README files to refer to things in the correct locations. --- settings.gradle | 3 +- .../Dockerfile | 0 temporal-test-server/LICENSE.txt | 18 ++++++ temporal-test-server/README.md | 46 +++++++++++++++ temporal-test-server/build.gradle | 58 +++++++++++++++++++ .../docker/RegisterTestNamespace.java | 0 .../sync/DeterministicRunnerWrapper.java | 0 .../sync/DummySyncWorkflowContext.java | 0 .../internal/testservice/ActivityId.java | 0 .../internal/testservice/CronUtils.java | 0 .../testservice/DecisionTaskToken.java | 0 .../internal/testservice/ExecutionId.java | 0 .../internal/testservice/QueryId.java | 0 .../internal/testservice/RequestContext.java | 0 .../testservice/SelfAdvancingTimer.java | 0 .../testservice/SelfAdvancingTimerImpl.java | 0 .../internal/testservice/StateMachine.java | 0 .../internal/testservice/StateMachines.java | 0 .../internal/testservice/StateUtils.java | 0 .../internal/testservice/TaskQueue.java | 0 .../testservice/TestServiceRetryState.java | 0 .../testservice/TestServiceServer.java | 0 .../testservice/TestWorkflowMutableState.java | 0 .../TestWorkflowMutableStateImpl.java | 0 .../testservice/TestWorkflowService.java | 0 .../testservice/TestWorkflowStore.java | 0 .../testservice/TestWorkflowStoreImpl.java | 0 .../internal/testservice/WorkflowId.java | 0 .../temporal-test-server}/jni-config.json | 0 .../native-image.properties | 32 ++++++++++ .../predefined-classes-config.json | 0 .../temporal-test-server}/proxy-config.json | 0 .../temporal-test-server}/reflect-config.json | 0 .../resource-config.json | 0 .../serialization-config.json | 0 temporal-testing/README.md | 30 +--------- temporal-testing/build.gradle | 54 +---------------- 37 files changed, 159 insertions(+), 82 deletions(-) rename {temporal-testing => temporal-test-server}/Dockerfile (100%) create mode 100644 temporal-test-server/LICENSE.txt create mode 100644 temporal-test-server/README.md create mode 100644 temporal-test-server/build.gradle rename {temporal-testing => temporal-test-server}/src/main/java/io/temporal/internal/docker/RegisterTestNamespace.java (100%) rename {temporal-testing => temporal-test-server}/src/main/java/io/temporal/internal/sync/DeterministicRunnerWrapper.java (100%) rename {temporal-testing => temporal-test-server}/src/main/java/io/temporal/internal/sync/DummySyncWorkflowContext.java (100%) rename {temporal-testing => temporal-test-server}/src/main/java/io/temporal/internal/testservice/ActivityId.java (100%) rename {temporal-testing => temporal-test-server}/src/main/java/io/temporal/internal/testservice/CronUtils.java (100%) rename {temporal-testing => temporal-test-server}/src/main/java/io/temporal/internal/testservice/DecisionTaskToken.java (100%) rename {temporal-testing => temporal-test-server}/src/main/java/io/temporal/internal/testservice/ExecutionId.java (100%) rename {temporal-testing => temporal-test-server}/src/main/java/io/temporal/internal/testservice/QueryId.java (100%) rename {temporal-testing => temporal-test-server}/src/main/java/io/temporal/internal/testservice/RequestContext.java (100%) rename {temporal-testing => temporal-test-server}/src/main/java/io/temporal/internal/testservice/SelfAdvancingTimer.java (100%) rename {temporal-testing => temporal-test-server}/src/main/java/io/temporal/internal/testservice/SelfAdvancingTimerImpl.java (100%) rename {temporal-testing => temporal-test-server}/src/main/java/io/temporal/internal/testservice/StateMachine.java (100%) rename {temporal-testing => temporal-test-server}/src/main/java/io/temporal/internal/testservice/StateMachines.java (100%) rename {temporal-testing => temporal-test-server}/src/main/java/io/temporal/internal/testservice/StateUtils.java (100%) rename {temporal-testing => temporal-test-server}/src/main/java/io/temporal/internal/testservice/TaskQueue.java (100%) rename {temporal-testing => temporal-test-server}/src/main/java/io/temporal/internal/testservice/TestServiceRetryState.java (100%) rename {temporal-testing => temporal-test-server}/src/main/java/io/temporal/internal/testservice/TestServiceServer.java (100%) rename {temporal-testing => temporal-test-server}/src/main/java/io/temporal/internal/testservice/TestWorkflowMutableState.java (100%) rename {temporal-testing => temporal-test-server}/src/main/java/io/temporal/internal/testservice/TestWorkflowMutableStateImpl.java (100%) rename {temporal-testing => temporal-test-server}/src/main/java/io/temporal/internal/testservice/TestWorkflowService.java (100%) rename {temporal-testing => temporal-test-server}/src/main/java/io/temporal/internal/testservice/TestWorkflowStore.java (100%) rename {temporal-testing => temporal-test-server}/src/main/java/io/temporal/internal/testservice/TestWorkflowStoreImpl.java (100%) rename {temporal-testing => temporal-test-server}/src/main/java/io/temporal/internal/testservice/WorkflowId.java (100%) rename {temporal-testing/src/main/resources/META-INF/native-image/io.temporal/temporal-testing => temporal-test-server/src/main/resources/META-INF/native-image/io.temporal/temporal-test-server}/jni-config.json (100%) create mode 100644 temporal-test-server/src/main/resources/META-INF/native-image/io.temporal/temporal-test-server/native-image.properties rename {temporal-testing/src/main/resources/META-INF/native-image/io.temporal/temporal-testing => temporal-test-server/src/main/resources/META-INF/native-image/io.temporal/temporal-test-server}/predefined-classes-config.json (100%) rename {temporal-testing/src/main/resources/META-INF/native-image/io.temporal/temporal-testing => temporal-test-server/src/main/resources/META-INF/native-image/io.temporal/temporal-test-server}/proxy-config.json (100%) rename {temporal-testing/src/main/resources/META-INF/native-image/io.temporal/temporal-testing => temporal-test-server/src/main/resources/META-INF/native-image/io.temporal/temporal-test-server}/reflect-config.json (100%) rename {temporal-testing/src/main/resources/META-INF/native-image/io.temporal/temporal-testing => temporal-test-server/src/main/resources/META-INF/native-image/io.temporal/temporal-test-server}/resource-config.json (100%) rename {temporal-testing/src/main/resources/META-INF/native-image/io.temporal/temporal-testing => temporal-test-server/src/main/resources/META-INF/native-image/io.temporal/temporal-test-server}/serialization-config.json (100%) diff --git a/settings.gradle b/settings.gradle index cb2789a872..26dc285e6e 100644 --- a/settings.gradle +++ b/settings.gradle @@ -2,5 +2,6 @@ rootProject.name='temporal-java-sdk' include 'temporal-serviceclient' include 'temporal-sdk' include 'temporal-testing' +include 'temporal-test-server' include 'temporal-opentracing' -include 'temporal-kotlin' \ No newline at end of file +include 'temporal-kotlin' diff --git a/temporal-testing/Dockerfile b/temporal-test-server/Dockerfile similarity index 100% rename from temporal-testing/Dockerfile rename to temporal-test-server/Dockerfile diff --git a/temporal-test-server/LICENSE.txt b/temporal-test-server/LICENSE.txt new file mode 100644 index 0000000000..7bbf24f9f4 --- /dev/null +++ b/temporal-test-server/LICENSE.txt @@ -0,0 +1,18 @@ +Temporal Java SDK + +Copyright (c) 2020 Temporal Technologies, Inc. All Rights Reserved + +Copyright (c) 2017 Uber Technologies, Inc. All Rights Reserved + +AWS Simple Workflow Flow Library +Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved + +Licensed under the Apache License, Version 2.0 (the "License"); you may not use this +file except in compliance with the License. You may obtain a copy of the License at + +http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software distributed under +the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR +CONDITIONS OF ANY KIND, either express or implied. See the License for the +specific language governing permissions and limitations under the License. diff --git a/temporal-test-server/README.md b/temporal-test-server/README.md new file mode 100644 index 0000000000..51c4420303 --- /dev/null +++ b/temporal-test-server/README.md @@ -0,0 +1,46 @@ +# Temporal Test Workflow Server + +This module includes an in-memory Temporal testing service implementation. It is +not intended to be used directly but rather by programming against the +`TestWorkflowEnvironment` interface in the `temporal-testing` module. + +In addition to being consumed as a library by JVM-based languages, this module +can be built into a standalone executable and run as an independent process. + +## Usage + +Do not depend on this module directly, see the instructions in +[temporal-testing](../temporal-testing/README.md). + +## In-memory Temporal testing service + +This service allows to run a test-only in-memory implementation of Temporal server API. + +## To build a test server using GraalVM native-image + +From the root of the java-sdk repo: +``` +./gradlew :temporal-test-server:build +``` +This will give you a native executable `build/graal/temporal-test-server`. The +executable requires a single argument: the port number on which it should +listen. + +## To build a test server docker image + +From the root of the java-sdk repo: +``` +./gradlew :temporal-test-server:docker +``` + +This will result in a local image being built: +`temporalio/temporal-test-server`. + +## GraalVM native-image configuration + +The GraalVM native-image compiler uses the native-image.properties file and the +referenced JSON files during compilation. The JSON files are generated by +running the test server java code in a JVM configured with the [GraalVM tracing +agent](https://www.graalvm.org/reference-manual/native-image/Agent/) configured, +e.g. with the flag +`-agentlib:native-image-agent=config-output-dir=temporal-test-server/src/main/resources/META-INF/native-image/io.temporal/temporal-test-server`. diff --git a/temporal-test-server/build.gradle b/temporal-test-server/build.gradle new file mode 100644 index 0000000000..1273339810 --- /dev/null +++ b/temporal-test-server/build.gradle @@ -0,0 +1,58 @@ +plugins { + id 'application' + id 'com.palantir.graal' version '0.10.0' + id 'com.palantir.docker' version '0.32.0' +} + +description = '''Temporal test workflow server''' + +dependencies { + api project(':temporal-sdk') + implementation("io.grpc:grpc-core:$grpcVersion") + implementation "com.google.guava:guava:$guavaVersion" + implementation group: 'com.cronutils', name: 'cron-utils', version: '9.1.6' +} + +application { + mainClassName = 'io.temporal.internal.testservice.TestServiceServer' +} + +jar { + manifest { + attributes("Main-Class": application.mainClassName) + } +} + +graal { + outputName "temporal-test-server" + mainClass application.mainClassName + javaVersion '17' + graalVersion '21.3.0' + + // Ignore type resolution errors at build-time + option "--allow-incomplete-classpath" + + // Don't fallback to running a JVM + option "--no-fallback" + + // Signal handling so that ^C actually stops the process + option "--install-exit-handlers" + + // If we're on linux, static link everything but libc. Otherwise link + // everything dynamically (note the '-' rather than '+' in fromt of + // StaticExecutable) + option isLinux() + ? "-H:+StaticExecutableWithDynamicLibC" + : "-H:-StaticExecutable" +} + +docker { + name "temporalio/temporal-test-server:${version}" + files tasks.nativeImage.outputs +} + +def isLinux() { + return System.properties['os.name'].toLowerCase().contains('linux') +} + +tasks.build.dependsOn('nativeImage') diff --git a/temporal-testing/src/main/java/io/temporal/internal/docker/RegisterTestNamespace.java b/temporal-test-server/src/main/java/io/temporal/internal/docker/RegisterTestNamespace.java similarity index 100% rename from temporal-testing/src/main/java/io/temporal/internal/docker/RegisterTestNamespace.java rename to temporal-test-server/src/main/java/io/temporal/internal/docker/RegisterTestNamespace.java diff --git a/temporal-testing/src/main/java/io/temporal/internal/sync/DeterministicRunnerWrapper.java b/temporal-test-server/src/main/java/io/temporal/internal/sync/DeterministicRunnerWrapper.java similarity index 100% rename from temporal-testing/src/main/java/io/temporal/internal/sync/DeterministicRunnerWrapper.java rename to temporal-test-server/src/main/java/io/temporal/internal/sync/DeterministicRunnerWrapper.java diff --git a/temporal-testing/src/main/java/io/temporal/internal/sync/DummySyncWorkflowContext.java b/temporal-test-server/src/main/java/io/temporal/internal/sync/DummySyncWorkflowContext.java similarity index 100% rename from temporal-testing/src/main/java/io/temporal/internal/sync/DummySyncWorkflowContext.java rename to temporal-test-server/src/main/java/io/temporal/internal/sync/DummySyncWorkflowContext.java diff --git a/temporal-testing/src/main/java/io/temporal/internal/testservice/ActivityId.java b/temporal-test-server/src/main/java/io/temporal/internal/testservice/ActivityId.java similarity index 100% rename from temporal-testing/src/main/java/io/temporal/internal/testservice/ActivityId.java rename to temporal-test-server/src/main/java/io/temporal/internal/testservice/ActivityId.java diff --git a/temporal-testing/src/main/java/io/temporal/internal/testservice/CronUtils.java b/temporal-test-server/src/main/java/io/temporal/internal/testservice/CronUtils.java similarity index 100% rename from temporal-testing/src/main/java/io/temporal/internal/testservice/CronUtils.java rename to temporal-test-server/src/main/java/io/temporal/internal/testservice/CronUtils.java diff --git a/temporal-testing/src/main/java/io/temporal/internal/testservice/DecisionTaskToken.java b/temporal-test-server/src/main/java/io/temporal/internal/testservice/DecisionTaskToken.java similarity index 100% rename from temporal-testing/src/main/java/io/temporal/internal/testservice/DecisionTaskToken.java rename to temporal-test-server/src/main/java/io/temporal/internal/testservice/DecisionTaskToken.java diff --git a/temporal-testing/src/main/java/io/temporal/internal/testservice/ExecutionId.java b/temporal-test-server/src/main/java/io/temporal/internal/testservice/ExecutionId.java similarity index 100% rename from temporal-testing/src/main/java/io/temporal/internal/testservice/ExecutionId.java rename to temporal-test-server/src/main/java/io/temporal/internal/testservice/ExecutionId.java diff --git a/temporal-testing/src/main/java/io/temporal/internal/testservice/QueryId.java b/temporal-test-server/src/main/java/io/temporal/internal/testservice/QueryId.java similarity index 100% rename from temporal-testing/src/main/java/io/temporal/internal/testservice/QueryId.java rename to temporal-test-server/src/main/java/io/temporal/internal/testservice/QueryId.java diff --git a/temporal-testing/src/main/java/io/temporal/internal/testservice/RequestContext.java b/temporal-test-server/src/main/java/io/temporal/internal/testservice/RequestContext.java similarity index 100% rename from temporal-testing/src/main/java/io/temporal/internal/testservice/RequestContext.java rename to temporal-test-server/src/main/java/io/temporal/internal/testservice/RequestContext.java diff --git a/temporal-testing/src/main/java/io/temporal/internal/testservice/SelfAdvancingTimer.java b/temporal-test-server/src/main/java/io/temporal/internal/testservice/SelfAdvancingTimer.java similarity index 100% rename from temporal-testing/src/main/java/io/temporal/internal/testservice/SelfAdvancingTimer.java rename to temporal-test-server/src/main/java/io/temporal/internal/testservice/SelfAdvancingTimer.java diff --git a/temporal-testing/src/main/java/io/temporal/internal/testservice/SelfAdvancingTimerImpl.java b/temporal-test-server/src/main/java/io/temporal/internal/testservice/SelfAdvancingTimerImpl.java similarity index 100% rename from temporal-testing/src/main/java/io/temporal/internal/testservice/SelfAdvancingTimerImpl.java rename to temporal-test-server/src/main/java/io/temporal/internal/testservice/SelfAdvancingTimerImpl.java diff --git a/temporal-testing/src/main/java/io/temporal/internal/testservice/StateMachine.java b/temporal-test-server/src/main/java/io/temporal/internal/testservice/StateMachine.java similarity index 100% rename from temporal-testing/src/main/java/io/temporal/internal/testservice/StateMachine.java rename to temporal-test-server/src/main/java/io/temporal/internal/testservice/StateMachine.java diff --git a/temporal-testing/src/main/java/io/temporal/internal/testservice/StateMachines.java b/temporal-test-server/src/main/java/io/temporal/internal/testservice/StateMachines.java similarity index 100% rename from temporal-testing/src/main/java/io/temporal/internal/testservice/StateMachines.java rename to temporal-test-server/src/main/java/io/temporal/internal/testservice/StateMachines.java diff --git a/temporal-testing/src/main/java/io/temporal/internal/testservice/StateUtils.java b/temporal-test-server/src/main/java/io/temporal/internal/testservice/StateUtils.java similarity index 100% rename from temporal-testing/src/main/java/io/temporal/internal/testservice/StateUtils.java rename to temporal-test-server/src/main/java/io/temporal/internal/testservice/StateUtils.java diff --git a/temporal-testing/src/main/java/io/temporal/internal/testservice/TaskQueue.java b/temporal-test-server/src/main/java/io/temporal/internal/testservice/TaskQueue.java similarity index 100% rename from temporal-testing/src/main/java/io/temporal/internal/testservice/TaskQueue.java rename to temporal-test-server/src/main/java/io/temporal/internal/testservice/TaskQueue.java diff --git a/temporal-testing/src/main/java/io/temporal/internal/testservice/TestServiceRetryState.java b/temporal-test-server/src/main/java/io/temporal/internal/testservice/TestServiceRetryState.java similarity index 100% rename from temporal-testing/src/main/java/io/temporal/internal/testservice/TestServiceRetryState.java rename to temporal-test-server/src/main/java/io/temporal/internal/testservice/TestServiceRetryState.java diff --git a/temporal-testing/src/main/java/io/temporal/internal/testservice/TestServiceServer.java b/temporal-test-server/src/main/java/io/temporal/internal/testservice/TestServiceServer.java similarity index 100% rename from temporal-testing/src/main/java/io/temporal/internal/testservice/TestServiceServer.java rename to temporal-test-server/src/main/java/io/temporal/internal/testservice/TestServiceServer.java diff --git a/temporal-testing/src/main/java/io/temporal/internal/testservice/TestWorkflowMutableState.java b/temporal-test-server/src/main/java/io/temporal/internal/testservice/TestWorkflowMutableState.java similarity index 100% rename from temporal-testing/src/main/java/io/temporal/internal/testservice/TestWorkflowMutableState.java rename to temporal-test-server/src/main/java/io/temporal/internal/testservice/TestWorkflowMutableState.java diff --git a/temporal-testing/src/main/java/io/temporal/internal/testservice/TestWorkflowMutableStateImpl.java b/temporal-test-server/src/main/java/io/temporal/internal/testservice/TestWorkflowMutableStateImpl.java similarity index 100% rename from temporal-testing/src/main/java/io/temporal/internal/testservice/TestWorkflowMutableStateImpl.java rename to temporal-test-server/src/main/java/io/temporal/internal/testservice/TestWorkflowMutableStateImpl.java diff --git a/temporal-testing/src/main/java/io/temporal/internal/testservice/TestWorkflowService.java b/temporal-test-server/src/main/java/io/temporal/internal/testservice/TestWorkflowService.java similarity index 100% rename from temporal-testing/src/main/java/io/temporal/internal/testservice/TestWorkflowService.java rename to temporal-test-server/src/main/java/io/temporal/internal/testservice/TestWorkflowService.java diff --git a/temporal-testing/src/main/java/io/temporal/internal/testservice/TestWorkflowStore.java b/temporal-test-server/src/main/java/io/temporal/internal/testservice/TestWorkflowStore.java similarity index 100% rename from temporal-testing/src/main/java/io/temporal/internal/testservice/TestWorkflowStore.java rename to temporal-test-server/src/main/java/io/temporal/internal/testservice/TestWorkflowStore.java diff --git a/temporal-testing/src/main/java/io/temporal/internal/testservice/TestWorkflowStoreImpl.java b/temporal-test-server/src/main/java/io/temporal/internal/testservice/TestWorkflowStoreImpl.java similarity index 100% rename from temporal-testing/src/main/java/io/temporal/internal/testservice/TestWorkflowStoreImpl.java rename to temporal-test-server/src/main/java/io/temporal/internal/testservice/TestWorkflowStoreImpl.java diff --git a/temporal-testing/src/main/java/io/temporal/internal/testservice/WorkflowId.java b/temporal-test-server/src/main/java/io/temporal/internal/testservice/WorkflowId.java similarity index 100% rename from temporal-testing/src/main/java/io/temporal/internal/testservice/WorkflowId.java rename to temporal-test-server/src/main/java/io/temporal/internal/testservice/WorkflowId.java diff --git a/temporal-testing/src/main/resources/META-INF/native-image/io.temporal/temporal-testing/jni-config.json b/temporal-test-server/src/main/resources/META-INF/native-image/io.temporal/temporal-test-server/jni-config.json similarity index 100% rename from temporal-testing/src/main/resources/META-INF/native-image/io.temporal/temporal-testing/jni-config.json rename to temporal-test-server/src/main/resources/META-INF/native-image/io.temporal/temporal-test-server/jni-config.json diff --git a/temporal-test-server/src/main/resources/META-INF/native-image/io.temporal/temporal-test-server/native-image.properties b/temporal-test-server/src/main/resources/META-INF/native-image/io.temporal/temporal-test-server/native-image.properties new file mode 100644 index 0000000000..be10603397 --- /dev/null +++ b/temporal-test-server/src/main/resources/META-INF/native-image/io.temporal/temporal-test-server/native-image.properties @@ -0,0 +1,32 @@ +# +# Copyright (C) 2020 Temporal Technologies, Inc. All Rights Reserved. +# +# Copyright 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved. +# +# Modifications copyright (C) 2017 Uber Technologies, Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"). You may not +# use this file except in compliance with the License. A copy of the License is +# located at +# +# http://aws.amazon.com/apache2.0 +# +# or in the "license" file accompanying this file. This file is distributed on +# an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either +# express or implied. See the License for the specific language governing +# permissions and limitations under the License. +# + +Args = --initialize-at-build-time=org.slf4j.impl.StaticLoggerBinder \ + --initialize-at-build-time=org.slf4j.LoggerFactory \ + --initialize-at-run-time=io.grpc.netty.shaded.io.netty.channel.epoll \ + --initialize-at-run-time=io.grpc.netty.shaded.io.netty.channel.unix \ + --initialize-at-run-time=io.grpc.netty.shaded.io.netty.util.internal.logging.Log4JLogger \ + --initialize-at-run-time=io.grpc.netty.shaded.io.netty.internal.tcnative \ + --initialize-at-run-time=io.grpc.netty.shaded.io.netty.handler.ssl \ + -H:DynamicProxyConfigurationResources=${.}/proxy-config.json \ + -H:JNIConfigurationResources=${.}/jni-config.json \ + -H:ReflectionConfigurationResources=${.}/reflect-config.json \ + -H:ResourceConfigurationResources=${.}/resource-config.json \ + -H:SerializationConfigurationResources=${.}/serialization-config.json + diff --git a/temporal-testing/src/main/resources/META-INF/native-image/io.temporal/temporal-testing/predefined-classes-config.json b/temporal-test-server/src/main/resources/META-INF/native-image/io.temporal/temporal-test-server/predefined-classes-config.json similarity index 100% rename from temporal-testing/src/main/resources/META-INF/native-image/io.temporal/temporal-testing/predefined-classes-config.json rename to temporal-test-server/src/main/resources/META-INF/native-image/io.temporal/temporal-test-server/predefined-classes-config.json diff --git a/temporal-testing/src/main/resources/META-INF/native-image/io.temporal/temporal-testing/proxy-config.json b/temporal-test-server/src/main/resources/META-INF/native-image/io.temporal/temporal-test-server/proxy-config.json similarity index 100% rename from temporal-testing/src/main/resources/META-INF/native-image/io.temporal/temporal-testing/proxy-config.json rename to temporal-test-server/src/main/resources/META-INF/native-image/io.temporal/temporal-test-server/proxy-config.json diff --git a/temporal-testing/src/main/resources/META-INF/native-image/io.temporal/temporal-testing/reflect-config.json b/temporal-test-server/src/main/resources/META-INF/native-image/io.temporal/temporal-test-server/reflect-config.json similarity index 100% rename from temporal-testing/src/main/resources/META-INF/native-image/io.temporal/temporal-testing/reflect-config.json rename to temporal-test-server/src/main/resources/META-INF/native-image/io.temporal/temporal-test-server/reflect-config.json diff --git a/temporal-testing/src/main/resources/META-INF/native-image/io.temporal/temporal-testing/resource-config.json b/temporal-test-server/src/main/resources/META-INF/native-image/io.temporal/temporal-test-server/resource-config.json similarity index 100% rename from temporal-testing/src/main/resources/META-INF/native-image/io.temporal/temporal-testing/resource-config.json rename to temporal-test-server/src/main/resources/META-INF/native-image/io.temporal/temporal-test-server/resource-config.json diff --git a/temporal-testing/src/main/resources/META-INF/native-image/io.temporal/temporal-testing/serialization-config.json b/temporal-test-server/src/main/resources/META-INF/native-image/io.temporal/temporal-test-server/serialization-config.json similarity index 100% rename from temporal-testing/src/main/resources/META-INF/native-image/io.temporal/temporal-testing/serialization-config.json rename to temporal-test-server/src/main/resources/META-INF/native-image/io.temporal/temporal-test-server/serialization-config.json diff --git a/temporal-testing/README.md b/temporal-testing/README.md index a76f4e20d5..db86d43cd7 100644 --- a/temporal-testing/README.md +++ b/temporal-testing/README.md @@ -1,7 +1,7 @@ # Temporal Workflow Java SDK Testing module -This module includes an in-memory Temporal testing service implementation, -supporting classes for unit tests and extensions for testing framework +This module includes Temporal testing utilities for unit tests and extensions +for testing frameworks. ## Usage @@ -29,11 +29,6 @@ testImplementation("io.temporal:temporal-testing:N.N.N") { } ``` -## In-memory Temporal testing service - -This service allows to run a test-only in-memory implementation of Temporal server API. -The entry point is `io.temporal.testing.TestWorkflowEnvironment` - ## JUnit4 and Junit5 extensions For JUnit4 see `io.temporal.testing.TestWorkflowRule` for testing of workflows @@ -45,24 +40,3 @@ and `io.temporal.testing.TestActivityExtension` for isolated testing of activiti See `io.temporal.testing.TestActivityEnvironment` that provides an easy way for isolated testing of activity implementations without needing to provide workflows calling the activities, triggering the workflows and bootstrapping a Temporal server or In-memory testing service. - -## To build a test service using GraalVM native-image - -From the root of the java-sdk repo: -``` -./gradlew :temporal-testing:copyDependencies -``` -``` -native-image -jar "./temporal-testing/build/libs/temporal-testing-1.6.0-SNAPSHOT.jar" test-server --class-path "./temporal-testing/build/dependencies/*" \ ---allow-incomplete-classpath --no-fallback -``` -Additional `native-image` flags to consider: -1. `--static` to build a fully static binary. _[Not supported](https://developer.apple.com/library/archive/qa/qa1118/_index.html) for MacOS._ - -### Notes on installing GraalVM -1. Install [prerequisites](https://www.graalvm.org/reference-manual/native-image/#prerequisites) -2. Install [sdkman](https://sdkman.io/install) -3. `sdk install java 21.2.0.r11-grl` GraalVM on JDK 11 -4. `sdk use java 21.2.0.r11-grl` -5. `gu install native-image`, where `gu` is GraalVM Updater. -6. After these steps, if sdkman is configured properly, you can switch to GraalVM JDK any time in the shell by using `sdk use java 21.2.0.r11-grl` which will make `native-image` tool also available diff --git a/temporal-testing/build.gradle b/temporal-testing/build.gradle index 119145edf9..8b4c9fce22 100644 --- a/temporal-testing/build.gradle +++ b/temporal-testing/build.gradle @@ -1,7 +1,5 @@ plugins { id 'application' - id 'com.palantir.graal' version '0.10.0' - id 'com.palantir.docker' version '0.32.0' } description = '''Temporal Workflow Java SDK testing''' @@ -17,11 +15,7 @@ java { dependencies { api project(':temporal-sdk') - - implementation("io.grpc:grpc-core:$grpcVersion") - implementation "com.google.guava:guava:$guavaVersion" - implementation group: 'com.cronutils', name: 'cron-utils', version: '9.1.6' - implementation "com.jayway.jsonpath:json-path:$jsonPathVersion" + api project(':temporal-test-server') junit4Api 'junit:junit:4.13.2' @@ -32,52 +26,6 @@ dependencies { testRuntimeOnly group: 'ch.qos.logback', name: 'logback-classic', version: "${logbackVersion}" } -application { - mainClassName = 'io.temporal.internal.testservice.TestServiceServer' -} - -task copyDependencies(type: Copy) { - from configurations.runtimeClasspath - into 'build/dependencies' -} - -jar { - manifest { - attributes("Main-Class": application.mainClassName) - } -} - -task testServiceServer(type: CreateStartScripts) { - mainClassName = 'io.temporal.internal.testservice.TestServiceServer' - applicationName = 'test-service-server' - outputDir = new File(project.buildDir, 'dist') - classpath = startScripts.classpath - dependsOn 'sourcesJar' -} - -graal { - outputName "temporal-test-server" - mainClass application.mainClassName - javaVersion '17' - graalVersion '21.3.0' - option "--class-path=${buildDir}/dependencies/*" - option "--allow-incomplete-classpath" - option "--no-fallback" - option "--install-exit-handlers" - option "-H:+StaticExecutableWithDynamicLibC" -} - -docker { - name "temporalio/temporal-test-server:${version}" - files tasks.nativeImage.outputs -} - -// Run: ./gradlew installDist :temporal-testing:testServiceServer -applicationDistribution.into('bin') { - from(testServiceServer) - fileMode = 0755 -} - test { useJUnitPlatform() }