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();
}
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();
}
Aggregations