Search in sources :

Example 6 with WorkflowStub

use of com.uber.cadence.client.WorkflowStub in project cadence-client by uber-java.

the class WorkerStressTests method longHistoryWorkflowsCompleteSuccessfully.

// Todo: Write a unit test specifically to test DecisionTaskWithHistoryIteratorImpl
@Ignore("Takes a long time to run")
@Test
public void longHistoryWorkflowsCompleteSuccessfully() {
    // Arrange
    String taskListName = "veryLongWorkflow";
    TestEnvironmentWrapper wrapper = new TestEnvironmentWrapper(WorkerFactoryOptions.newBuilder().setMaxWorkflowThreadCount(200).build());
    WorkerFactory factory = wrapper.getWorkerFactory();
    Worker worker = factory.newWorker(taskListName);
    worker.registerWorkflowImplementationTypes(ActivitiesWorkflowImpl.class);
    worker.registerActivitiesImplementations(new ActivitiesImpl());
    factory.start();
    WorkflowOptions workflowOptions = new WorkflowOptions.Builder().setTaskList(taskListName).setExecutionStartToCloseTimeout(Duration.ofSeconds(250)).setTaskStartToCloseTimeout(Duration.ofSeconds(30)).build();
    WorkflowStub workflow = wrapper.getWorkflowClient().newUntypedWorkflowStub("ActivitiesWorkflow::execute", workflowOptions);
    // Act
    // This will yeild around 10000 events which is above the page limit returned by the server.
    WorkflowParams w = new WorkflowParams();
    w.CadenceSleep = Duration.ofSeconds(0);
    w.ChainSequence = 50;
    w.ConcurrentCount = 50;
    w.PayloadSizeBytes = 10000;
    w.TaskListName = taskListName;
    workflow.start(w);
    assertNotNull("I'm done.", workflow.getResult(String.class));
    wrapper.close();
}
Also used : WorkflowStub(com.uber.cadence.client.WorkflowStub) WorkflowOptions(com.uber.cadence.client.WorkflowOptions) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 7 with WorkflowStub

use of com.uber.cadence.client.WorkflowStub in project cadence-client by uber-java.

the class WorkerStressTests method selfEvictionDoesNotCauseDeadlock.

@Test
public void selfEvictionDoesNotCauseDeadlock() throws InterruptedException {
    // Arrange
    String taskListName = "veryLongWorkflow" + UUID.randomUUID();
    TestEnvironmentWrapper wrapper = new TestEnvironmentWrapper(WorkerFactoryOptions.newBuilder().setDisableStickyExecution(false).setMaxWorkflowThreadCount(2).build());
    WorkerFactory factory = wrapper.getWorkerFactory();
    Worker worker = factory.newWorker(taskListName);
    worker.registerWorkflowImplementationTypes(ActivitiesWorkflowImpl.class);
    worker.registerActivitiesImplementations(new ActivitiesImpl());
    factory.start();
    WorkflowOptions workflowOptions = new WorkflowOptions.Builder().setTaskList(taskListName).setExecutionStartToCloseTimeout(Duration.ofSeconds(250)).setTaskStartToCloseTimeout(Duration.ofSeconds(30)).build();
    WorkflowStub workflow = wrapper.getWorkflowClient().newUntypedWorkflowStub("ActivitiesWorkflow::execute", workflowOptions);
    // Act
    WorkflowParams w = new WorkflowParams();
    w.CadenceSleep = Duration.ofSeconds(0);
    w.ChainSequence = 1;
    w.ConcurrentCount = 15;
    w.PayloadSizeBytes = 100;
    w.TaskListName = taskListName;
    // This will attempt to self evict given that there are only two threads available
    workflow.start(w);
    // Wait enough time to trigger self eviction
    Thread.sleep(Duration.ofSeconds(1).toMillis());
    // Start a second workflow and kick the previous one out
    WorkflowStub workflow2 = wrapper.getWorkflowClient().newUntypedWorkflowStub("ActivitiesWorkflow::execute", workflowOptions);
    w.ConcurrentCount = 1;
    workflow2.start(w);
    assertNotNull("I'm done.", workflow2.getResult(String.class));
    wrapper.close();
}
Also used : WorkflowStub(com.uber.cadence.client.WorkflowStub) WorkflowOptions(com.uber.cadence.client.WorkflowOptions) Test(org.junit.Test)

Aggregations

WorkflowStub (com.uber.cadence.client.WorkflowStub)7 Test (org.junit.Test)7 DeterministicRunnerTest (com.uber.cadence.internal.sync.DeterministicRunnerTest)5 WorkflowOptions (com.uber.cadence.client.WorkflowOptions)3 CancellationException (java.util.concurrent.CancellationException)3 AtomicReference (java.util.concurrent.atomic.AtomicReference)2 WorkflowExecution (com.uber.cadence.WorkflowExecution)1 DuplicateWorkflowException (com.uber.cadence.client.DuplicateWorkflowException)1 WorkflowClient (com.uber.cadence.client.WorkflowClient)1 WorkflowClientInterceptorBase (com.uber.cadence.client.WorkflowClientInterceptorBase)1 WorkflowClientOptions (com.uber.cadence.client.WorkflowClientOptions)1 WorkflowException (com.uber.cadence.client.WorkflowException)1 Builder (com.uber.cadence.testing.TestEnvironmentOptions.Builder)1 Ignore (org.junit.Ignore)1