use of io.zeebe.client.event.TaskEvent in project zeebe by zeebe-io.
the class CreateTopicClusteredTest method shouldCreateTaskAfterTopicCreation.
@Test
public void shouldCreateTaskAfterTopicCreation() {
// given
clusteringRule.createTopic("foo", PARTITION_COUNT);
// then
final TaskEvent taskEvent = client.tasks().create("foo", "bar").execute();
assertThat(taskEvent).isNotNull();
assertThat(taskEvent.getState()).isEqualTo("CREATED");
}
use of io.zeebe.client.event.TaskEvent in project zeebe by zeebe-io.
the class CreateTopicClusteredTest method shouldCompleteTaskAfterNewLeaderWasChosen.
@Test
public void shouldCompleteTaskAfterNewLeaderWasChosen() throws Exception {
// given
final int partitionsCount = 1;
clusteringRule.createTopic("foo", partitionsCount);
final TaskEvent taskEvent = client.tasks().create("foo", "bar").execute();
final int partitionId = taskEvent.getMetadata().getPartitionId();
final TopologyBroker leaderForPartition = clusteringRule.getLeaderForPartition(partitionId);
final SocketAddress currentLeaderAddress = leaderForPartition.getSocketAddress();
// when
clusteringRule.stopBroker(currentLeaderAddress);
// then
final TopologyBroker newLeader = clusteringRule.getLeaderForPartition(partitionId);
assertThat(newLeader.getSocketAddress()).isNotEqualTo(leaderForPartition.getSocketAddress());
final CompletableFuture<TaskEvent> taskCompleted = new CompletableFuture<>();
client.tasks().newTaskSubscription("foo").handler((taskClient, lockedEvent) -> {
final TaskEvent completedTask = taskClient.complete(lockedEvent).execute();
taskCompleted.complete(completedTask);
}).taskType("bar").lockOwner("owner").lockTime(5000).open();
waitUntil(() -> taskCompleted.isDone());
assertThat(taskCompleted).isCompleted();
final TaskEvent completedTask = taskCompleted.get();
assertThat(completedTask.getState()).isEqualTo("COMPLETED");
}
use of io.zeebe.client.event.TaskEvent in project zeebe by zeebe-io.
the class BrokerRecoveryTest method shouldContinueWorkflowInstanceWithLockedTaskAfterRestart.
@Test
public void shouldContinueWorkflowInstanceWithLockedTaskAfterRestart() {
// given
clientRule.workflows().deploy(clientRule.getDefaultTopic()).addWorkflowModel(WORKFLOW, "workflow.bpmn").execute();
clientRule.workflows().create(clientRule.getDefaultTopic()).bpmnProcessId("process").execute();
final RecordingTaskHandler recordingTaskHandler = new RecordingTaskHandler();
clientRule.tasks().newTaskSubscription(clientRule.getDefaultTopic()).taskType("foo").lockOwner("test").lockTime(Duration.ofSeconds(5)).handler(recordingTaskHandler).open();
waitUntil(() -> !recordingTaskHandler.getHandledTasks().isEmpty());
// when
restartBroker();
final TaskEvent task = recordingTaskHandler.getHandledTasks().get(0);
clientRule.tasks().complete(task).execute();
// then
waitUntil(() -> eventRecorder.hasTaskEvent(taskEvent("COMPLETED")));
waitUntil(() -> eventRecorder.hasWorkflowInstanceEvent(wfInstanceEvent("WORKFLOW_INSTANCE_COMPLETED")));
}
use of io.zeebe.client.event.TaskEvent in project zeebe by zeebe-io.
the class BrokerRecoveryTest method shouldResolveIncidentAfterRestart.
@Test
public void shouldResolveIncidentAfterRestart() {
// given
clientRule.workflows().deploy(clientRule.getDefaultTopic()).addWorkflowModel(WORKFLOW_INCIDENT, "incident.bpmn").execute();
clientRule.workflows().create(clientRule.getDefaultTopic()).bpmnProcessId("process").execute();
waitUntil(() -> eventRecorder.hasIncidentEvent(incidentEvent("CREATED")));
final WorkflowInstanceEvent activityInstance = eventRecorder.getSingleWorkflowInstanceEvent(TopicEventRecorder.wfInstanceEvent("ACTIVITY_READY"));
// when
restartBroker();
clientRule.workflows().updatePayload(activityInstance).payload("{\"foo\":\"bar\"}").execute();
// then
waitUntil(() -> eventRecorder.hasIncidentEvent(incidentEvent("RESOLVED")));
waitUntil(() -> eventRecorder.hasTaskEvent(taskEvent("CREATED")));
assertThat(eventRecorder.getIncidentEvents(i -> true)).extracting("state").containsExactly("CREATE", "CREATED", "RESOLVE", "RESOLVED");
}
use of io.zeebe.client.event.TaskEvent in project zeebe by zeebe-io.
the class BrokerRecoveryTest method shouldResolveFailedIncidentAfterRestart.
@Test
public void shouldResolveFailedIncidentAfterRestart() {
// given
clientRule.workflows().deploy(clientRule.getDefaultTopic()).addWorkflowModel(WORKFLOW_INCIDENT, "incident.bpmn").execute();
clientRule.workflows().create(clientRule.getDefaultTopic()).bpmnProcessId("process").execute();
waitUntil(() -> eventRecorder.hasIncidentEvent(incidentEvent("CREATED")));
final WorkflowInstanceEvent activityInstance = eventRecorder.getSingleWorkflowInstanceEvent(TopicEventRecorder.wfInstanceEvent("ACTIVITY_READY"));
clientRule.workflows().updatePayload(activityInstance).payload("{\"x\":\"y\"}").execute();
waitUntil(() -> eventRecorder.hasIncidentEvent(incidentEvent("RESOLVE_FAILED")));
// when
restartBroker();
clientRule.workflows().updatePayload(activityInstance).payload("{\"foo\":\"bar\"}").execute();
// then
waitUntil(() -> eventRecorder.hasIncidentEvent(incidentEvent("RESOLVED")));
waitUntil(() -> eventRecorder.hasTaskEvent(taskEvent("CREATED")));
assertThat(eventRecorder.getIncidentEvents(i -> true)).extracting("state").containsExactly("CREATE", "CREATED", "RESOLVE", "RESOLVE_FAILED", "RESOLVE", "RESOLVED");
}
Aggregations