Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
bd9d6a4
Update service client dependencies
Mar 16, 2021
acc66e4
Update temporal-sdk dependencies
Mar 16, 2021
7a4069c
Missed micrometer-core update
Mar 17, 2021
af82446
Merge remote-tracking branch 'upstream/master'
Mar 17, 2021
0108f7f
Last batch of factored out tests
Mar 17, 2021
62ba735
Moved classes/methods into places where they're used.
Mar 18, 2021
91f8ea0
These tests fail at the moment. Pushing to PR to get hints
Mar 18, 2021
4d3c90c
Fixed ContinueAsNewTest
Mar 27, 2021
b6c24bb
Merge remote-tracking branch 'upstream/master' into refactor-workflow…
Mar 29, 2021
43115ed
Fixed testHeartbeatTimeoutDetails()
Mar 29, 2021
5d8b25f
Fixed a few more tests that needed replay.
Mar 29, 2021
714251c
Fixed SyncTest
Mar 29, 2021
cc916ca
Fixed a silly bug.
Mar 30, 2021
29e1d88
Previously run only when testEnvironment != null, and it was null whe…
Mar 30, 2021
17859b0
Merge branch 'master' into refactor-workflowtest
vkoby Mar 30, 2021
4b0395f
Fixed CustomDatetimeField search attribute string
Mar 30, 2021
01a996d
Added .getWorkflowExecutionHistory() and .blockingStub to WorkflowRules
Mar 30, 2021
632bab2
Removed unnesassary ActivityImplementations setting.
Mar 30, 2021
41e71e4
Factored out execution history logic into the workflow rule.
Mar 31, 2021
b900865
Removed unnecessary activityImpl field
Mar 31, 2021
faa1af3
Fixed bug.
Mar 31, 2021
92ea7b3
Removed WorkflowTest!
Mar 31, 2021
c7d37dc
Merge remote-tracking branch 'upstream/master' into refactor-workflow…
Mar 31, 2021
336afef
A few minor things
Apr 1, 2021
e41270b
Merge branch 'master' into refactor-workflowtest
vkoby Apr 1, 2021
0cdc5c5
Merge branch 'master' into refactor-workflowtest
vkoby Apr 1, 2021
5d20211
Replaced with single class imports
Apr 1, 2021
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 @@ -23,7 +23,6 @@
import com.google.common.io.CharSink;
import com.google.common.io.Files;
import io.temporal.workflow.Functions;
import io.temporal.workflow.WorkflowTest;
import java.io.File;
import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException;
Expand All @@ -35,7 +34,8 @@

public class CommandsGeneratePlantUMLStateDiagrams {

private static final Logger log = LoggerFactory.getLogger(WorkflowTest.class);
private static final Logger log =
LoggerFactory.getLogger(CommandsGeneratePlantUMLStateDiagrams.class);

@Test
public void plantUML() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@
import io.temporal.workflow.Functions;
import io.temporal.workflow.Promise;
import io.temporal.workflow.Workflow;
import io.temporal.workflow.WorkflowTest;
import java.time.Duration;
import java.util.ArrayList;
import java.util.List;
Expand Down Expand Up @@ -127,7 +126,7 @@ public void testYield() throws Throwable {
* Async retry cannot be tested here as it relies on timer that is implemented outside of
* Dispatcher.
*
* @see WorkflowTest#testAsyncRetry()
* @see io.temporal.workflow.activityTests.AsyncRetryTest#testAsyncRetry()
*/
@Test
@Ignore // timer removed from dispatcher
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,10 @@
import io.temporal.client.WorkflowClient;
import io.temporal.client.WorkflowClientOptions;
import io.temporal.client.WorkflowStub;
import io.temporal.workflow.shared.*;
import io.temporal.workflow.shared.SDKTestWorkflowRule;
import io.temporal.workflow.shared.TestActivities;
import io.temporal.workflow.shared.TestOptions;
import io.temporal.workflow.shared.TestWorkflows;
import org.junit.Rule;
import org.junit.Test;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@

import io.temporal.client.WorkflowOptions;
import io.temporal.workflow.shared.SDKTestWorkflowRule;
import io.temporal.workflow.shared.TestMultiargsWorkflowsFuncParent;
import io.temporal.workflow.shared.TestOptions;
import org.junit.Assert;
import org.junit.Rule;
Expand All @@ -32,8 +33,7 @@ public class GetAttemptFromWorkflowInfoTest {
public SDKTestWorkflowRule testWorkflowRule =
SDKTestWorkflowRule.newBuilder()
.setWorkflowTypes(
WorkflowTest.TestMultiargsWorkflowsFuncParent.class,
TestAttemptReturningWorkflowFunc.class)
TestMultiargsWorkflowsFuncParent.class, TestAttemptReturningWorkflowFunc.class)
.build();

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,7 @@

package io.temporal.workflow;

import io.temporal.activity.Activity;
import io.temporal.activity.ActivityExecutionContext;
import io.temporal.activity.ActivityInterface;
import io.temporal.activity.ActivityMethod;
import io.temporal.activity.ActivityOptions;
import io.temporal.activity.ManualActivityCompletionClient;
import io.temporal.activity.*;
import io.temporal.common.RetryOptions;
import io.temporal.worker.WorkerOptions;
import io.temporal.workflow.shared.SDKTestWorkflowRule;
Expand Down Expand Up @@ -54,13 +49,33 @@ public class LocalAsyncCompletionWorkflowTest {
.setTestTimeoutSeconds(15)
.build();

/**
* This test runs 10 async activities in parallel. The expectation is that
* MAX_CONCURRENT_ACTIVITIES limit is being respected and only 1 activity should be running at the
* same time.
*/
@Test
public void verifyLocalActivityCompletionRespectsConcurrencySettings() {
String taskQueue = testWorkflowRule.getTaskQueue();
TestWorkflow workflow = testWorkflowRule.newWorkflowStub(TestWorkflow.class);
String result = workflow.execute(taskQueue);
Assert.assertEquals("success", result);
}

@WorkflowInterface
public interface TestWorkflow {

@WorkflowMethod
String execute(String taskQueue);
}

@ActivityInterface
public interface TestActivity {

@ActivityMethod
int execute(int value);
}

public static class TestWorkflowImpl implements TestWorkflow {

@Override
Expand Down Expand Up @@ -91,13 +106,6 @@ public String execute(String taskQueue) {
}
}

@ActivityInterface
public interface TestActivity {

@ActivityMethod
int execute(int value);
}

public static class AsyncActivityWithManualCompletion implements TestActivity {
private final AtomicInteger concurrentActivitiesCount = new AtomicInteger(0);

Expand Down Expand Up @@ -129,17 +137,4 @@ private void asyncActivityFn(int value, ManualActivityCompletionClient completio
}
}
}

/**
* This test runs 10 async activities in parallel. The expectation is that
* MAX_CONCURRENT_ACTIVITIES limit is being respected and only 1 activity should be running at the
* same time.
*/
@Test
public void verifyLocalActivityCompletionRespectsConcurrencySettings() {
String taskQueue = testWorkflowRule.getTaskQueue();
TestWorkflow workflow = testWorkflowRule.newWorkflowStub(TestWorkflow.class);
String result = workflow.execute(taskQueue);
Assert.assertEquals("success", result);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import io.temporal.client.WorkflowClient;
import io.temporal.client.WorkflowStub;
import io.temporal.workflow.shared.SDKTestWorkflowRule;
import io.temporal.workflow.shared.TestWorkflows;
import java.lang.management.ManagementFactory;
import java.time.Duration;
import org.junit.Assert;
Expand All @@ -37,8 +38,8 @@ public class NoQueryThreadLeakTest {
@Test
public void testNoQueryThreadLeak() throws InterruptedException {
int threadCount = ManagementFactory.getThreadMXBean().getThreadCount();
WorkflowTest.QueryableWorkflow client =
testWorkflowRule.newWorkflowStubTimeoutOptions(WorkflowTest.QueryableWorkflow.class);
TestWorkflows.QueryableWorkflow client =
testWorkflowRule.newWorkflowStubTimeoutOptions(TestWorkflows.QueryableWorkflow.class);
WorkflowClient.start(client::execute);
testWorkflowRule.sleep(Duration.ofSeconds(1));
// Calls query multiple times to check at the end of the method that if it doesn't leak threads
Expand All @@ -57,7 +58,7 @@ public void testNoQueryThreadLeak() throws InterruptedException {
Assert.assertTrue("query leaks threads: " + threadsCreated, threadsCreated < queryCount);
}

public static class TestNoQueryWorkflowImpl implements WorkflowTest.QueryableWorkflow {
public static class TestNoQueryWorkflowImpl implements TestWorkflows.QueryableWorkflow {

CompletablePromise<Void> promise = Workflow.newPromise();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@
import io.temporal.client.WorkflowOptions;
import io.temporal.failure.TimeoutFailure;
import io.temporal.worker.WorkerFactoryOptions;
import io.temporal.workflow.shared.DeterminismFailingWorkflowImpl;
import io.temporal.workflow.shared.SDKTestWorkflowRule;
import io.temporal.workflow.shared.TestWorkflows;
import java.lang.management.ManagementFactory;
import java.lang.management.ThreadInfo;
import java.time.Duration;
Expand All @@ -36,7 +38,7 @@ public class NonDeterministicWorkflowPolicyBlockWorkflowTest {
@Rule
public SDKTestWorkflowRule testWorkflowRule =
SDKTestWorkflowRule.newBuilder()
.setWorkflowTypes(WorkflowTest.DeterminismFailingWorkflowImpl.class)
.setWorkflowTypes(DeterminismFailingWorkflowImpl.class)
.setWorkerFactoryOptions(
WorkerFactoryOptions.newBuilder()
.setWorkflowHostLocalTaskQueueScheduleToStartTimeout(Duration.ZERO)
Expand All @@ -51,10 +53,10 @@ public void testNonDeterministicWorkflowPolicyBlockWorkflow() {
.setWorkflowTaskTimeout(Duration.ofSeconds(1))
.setTaskQueue(testWorkflowRule.getTaskQueue())
.build();
WorkflowTest.DeterminismFailingWorkflow workflowStub =
TestWorkflows.DeterminismFailingWorkflow workflowStub =
testWorkflowRule
.getWorkflowClient()
.newWorkflowStub(WorkflowTest.DeterminismFailingWorkflow.class, options);
.newWorkflowStub(TestWorkflows.DeterminismFailingWorkflow.class, options);
try {
workflowStub.execute(testWorkflowRule.getTaskQueue());
Assert.fail("unreachable");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,10 @@
import io.temporal.internal.replay.InternalWorkflowTaskException;
import io.temporal.worker.WorkerFactoryOptions;
import io.temporal.worker.WorkflowImplementationOptions;
import io.temporal.workflow.shared.DeterminismFailingWorkflowImpl;
import io.temporal.workflow.shared.SDKTestWorkflowRule;
import io.temporal.workflow.shared.TestActivities;
import io.temporal.workflow.shared.TestWorkflows;
import java.time.Duration;
import org.junit.Assert;
import org.junit.Rule;
Expand All @@ -42,7 +44,7 @@ public class NonDeterministicWorkflowPolicyFailWorkflowTest {
WorkflowImplementationOptions.newBuilder()
.setFailWorkflowExceptionTypes(Throwable.class)
.build(),
WorkflowTest.DeterminismFailingWorkflowImpl.class)
DeterminismFailingWorkflowImpl.class)
.setWorkerFactoryOptions(
WorkerFactoryOptions.newBuilder()
.setWorkflowHostLocalTaskQueueScheduleToStartTimeout(Duration.ZERO)
Expand All @@ -57,10 +59,10 @@ public void testNonDeterministicWorkflowPolicyFailWorkflow() {
.setWorkflowTaskTimeout(Duration.ofSeconds(1))
.setTaskQueue(testWorkflowRule.getTaskQueue())
.build();
WorkflowTest.DeterminismFailingWorkflow workflowStub =
TestWorkflows.DeterminismFailingWorkflow workflowStub =
testWorkflowRule
.getWorkflowClient()
.newWorkflowStub(WorkflowTest.DeterminismFailingWorkflow.class, options);
.newWorkflowStub(TestWorkflows.DeterminismFailingWorkflow.class, options);
try {
workflowStub.execute(testWorkflowRule.getTaskQueue());
Assert.fail("unreachable");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import io.temporal.api.enums.v1.WorkflowIdReusePolicy;
import io.temporal.client.WorkflowOptions;
import io.temporal.workflow.shared.SDKTestWorkflowRule;
import io.temporal.workflow.shared.TestChild;
import io.temporal.workflow.shared.TestWorkflows;
import java.time.Duration;
import org.junit.Assert;
Expand All @@ -33,7 +34,7 @@ public class ParentContinueAsNewTest {
@Rule
public SDKTestWorkflowRule testWorkflowRule =
SDKTestWorkflowRule.newBuilder()
.setWorkflowTypes(TestParentWorkflowContinueAsNew.class, WorkflowTest.TestChild.class)
.setWorkflowTypes(TestParentWorkflowContinueAsNew.class, TestChild.class)
.build();

/** Reproduction of a bug when a child of continued as new workflow has the same UUID ID. */
Expand All @@ -55,9 +56,9 @@ public void testParentContinueAsNew() {

public static class TestParentWorkflowContinueAsNew implements TestWorkflows.TestWorkflow1 {

private final WorkflowTest.ITestChild child1 =
private final TestWorkflows.ITestChild child1 =
Workflow.newChildWorkflowStub(
WorkflowTest.ITestChild.class,
TestWorkflows.ITestChild.class,
ChildWorkflowOptions.newBuilder()
.setWorkflowIdReusePolicy(
WorkflowIdReusePolicy.WORKFLOW_ID_REUSE_POLICY_REJECT_DUPLICATE)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import io.temporal.failure.ApplicationFailure;
import io.temporal.workflow.shared.SDKTestWorkflowRule;
import io.temporal.workflow.shared.TestOptions;
import io.temporal.workflow.shared.TestWorkflows;
import java.time.Duration;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
Expand Down Expand Up @@ -51,11 +52,11 @@ public void testWorkflowFailureNonRetryableFlag() {
.setMaximumAttempts(100)
.setBackoffCoefficient(1.0)
.build();
WorkflowTest.TestWorkflowRetry workflowStub =
TestWorkflows.TestWorkflowRetry workflowStub =
testWorkflowRule
.getWorkflowClient()
.newWorkflowStub(
WorkflowTest.TestWorkflowRetry.class,
TestWorkflows.TestWorkflowRetry.class,
TestOptions.newWorkflowOptionsWithTimeouts(testWorkflowRule.getTaskQueue())
.toBuilder()
.setRetryOptions(workflowRetryOptions)
Expand All @@ -76,7 +77,7 @@ public void testWorkflowFailureNonRetryableFlag() {
}
}

public static class TestWorkflowNonRetryableFlag implements WorkflowTest.TestWorkflowRetry {
public static class TestWorkflowNonRetryableFlag implements TestWorkflows.TestWorkflowRetry {

@Override
public String execute(String testName) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import io.temporal.failure.ApplicationFailure;
import io.temporal.workflow.shared.SDKTestWorkflowRule;
import io.temporal.workflow.shared.TestOptions;
import io.temporal.workflow.shared.TestWorkflows;
import java.time.Duration;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
Expand Down Expand Up @@ -54,11 +55,11 @@ public void testWorkflowRetryDoNotRetryException() {
.setMaximumAttempts(100)
.setBackoffCoefficient(1.0)
.build();
WorkflowTest.TestWorkflowRetry workflowStub =
TestWorkflows.TestWorkflowRetry workflowStub =
testWorkflowRule
.getWorkflowClient()
.newWorkflowStub(
WorkflowTest.TestWorkflowRetry.class,
TestWorkflows.TestWorkflowRetry.class,
TestOptions.newWorkflowOptionsWithTimeouts(testWorkflowRule.getTaskQueue())
.toBuilder()
.setRetryOptions(workflowRetryOptions)
Expand All @@ -76,7 +77,7 @@ public void testWorkflowRetryDoNotRetryException() {
}

public static class TestWorkflowRetryDoNotRetryException
implements WorkflowTest.TestWorkflowRetry {
implements TestWorkflows.TestWorkflowRetry {

@Override
public String execute(String testName) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import io.temporal.failure.ApplicationFailure;
import io.temporal.workflow.shared.SDKTestWorkflowRule;
import io.temporal.workflow.shared.TestOptions;
import io.temporal.workflow.shared.TestWorkflows;
import java.time.Duration;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
Expand Down Expand Up @@ -53,11 +54,11 @@ public void testWorkflowRetry() {
.setMaximumAttempts(3)
.setBackoffCoefficient(1.0)
.build();
WorkflowTest.TestWorkflowRetry workflowStub =
TestWorkflows.TestWorkflowRetry workflowStub =
testWorkflowRule
.getWorkflowClient()
.newWorkflowStub(
WorkflowTest.TestWorkflowRetry.class,
TestWorkflows.TestWorkflowRetry.class,
TestOptions.newWorkflowOptionsWithTimeouts(testWorkflowRule.getTaskQueue())
.toBuilder()
.setRetryOptions(workflowRetryOptions)
Expand All @@ -78,7 +79,7 @@ public void testWorkflowRetry() {
}
}

public static class TestWorkflowRetryImpl implements WorkflowTest.TestWorkflowRetry {
public static class TestWorkflowRetryImpl implements TestWorkflows.TestWorkflowRetry {

@Override
public String execute(String testName) {
Expand Down
Loading