use of io.zeebe.client.event.TaskEvent in project zeebe by zeebe-io.
the class BrokerRecoveryTest method shouldCreateTopicAfterRestart.
@Test
public void shouldCreateTopicAfterRestart() {
// given
final ZeebeClient client = clientRule.getClient();
restartBroker();
// when
client.topics().create("foo", 2).execute();
// then
final TaskEvent taskEvent = client.tasks().create("foo", "bar").execute();
assertThat(taskEvent.getState()).isEqualTo("CREATED");
}
use of io.zeebe.client.event.TaskEvent in project zeebe by zeebe-io.
the class CreateTopicTest method shouldCreateTaskOnNewTopic.
@Test
public void shouldCreateTaskOnNewTopic() {
// given
clientRule.topics().create("newTopic", 2).execute();
// when
final TaskEvent taskEvent = clientRule.tasks().create("newTopic", "foo").execute();
// then
assertThat(taskEvent.getState()).isEqualTo("CREATED");
}
use of io.zeebe.client.event.TaskEvent in project zeebe by zeebe-io.
the class TaskEventClusteredTest method shouldCreateTaskWhenFollowerUnavailable.
@Test
public void shouldCreateTaskWhenFollowerUnavailable() {
// given
final ZeebeClient client = clientRule.getClient();
final String topicName = "foo";
clusteringRule.createTopic(topicName, 1);
final Topics topics = client.topics().getTopics().execute();
final Topic topic = topics.getTopics().stream().filter(t -> topicName.equals(t.getName())).findFirst().get();
final TopologyBroker leader = clusteringRule.getLeaderForPartition(topic.getPartitions().get(0).getId());
// choosing a new leader in a raft group where the previously leading broker is no longer available
clusteringRule.stopBroker(leader.getSocketAddress());
// when
final TaskEvent taskEvent = client.tasks().create(topicName, "bar").execute();
// then
assertThat(taskEvent.getState()).isEqualTo("CREATED");
}
use of io.zeebe.client.event.TaskEvent in project zeebe by zeebe-io.
the class IncidentTest method shouldCreateAndResolveTaskIncident.
@Test
public void shouldCreateAndResolveTaskIncident() {
// given a workflow instance with an open task
clientRule.workflows().deploy(clientRule.getDefaultTopic()).addWorkflowModel(WORKFLOW, "workflow.bpmn").execute();
clientRule.workflows().create(clientRule.getDefaultTopic()).bpmnProcessId("process").payload(PAYLOAD).execute();
// when the task fails until it has no more retries left
final ControllableTaskHandler taskHandler = new ControllableTaskHandler();
taskHandler.failTask = true;
clientRule.tasks().newTaskSubscription(clientRule.getDefaultTopic()).taskType("test").lockOwner("owner").lockTime(Duration.ofMinutes(5)).handler(taskHandler).open();
// then an incident is created
waitUntil(() -> eventRecorder.hasIncidentEvent(incidentEvent("CREATED")));
// when the task retries are increased
taskHandler.failTask = false;
final TaskEvent task = taskHandler.task;
clientRule.tasks().updateRetries(task).retries(3).execute();
// then the incident is deleted
waitUntil(() -> eventRecorder.hasIncidentEvent(incidentEvent("DELETED")));
}
use of io.zeebe.client.event.TaskEvent in project zeebe by zeebe-io.
the class MultipleClientTest method shouldOpenTaskSubscriptionsForDifferentTypes.
@Test
public void shouldOpenTaskSubscriptionsForDifferentTypes() {
// given
final RecordingTaskHandler handler1 = new RecordingTaskHandler();
final RecordingTaskHandler handler2 = new RecordingTaskHandler();
client1.tasks().newTaskSubscription(client1.getDefaultTopic()).handler(handler1).taskType("foo").lockTime(Duration.ofMinutes(5)).lockOwner("client1").open();
client2.tasks().newTaskSubscription(client2.getDefaultTopic()).handler(handler2).taskType("bar").lockTime(Duration.ofMinutes(5)).lockOwner("client2").open();
// when
final TaskEvent task1 = client1.tasks().create(client1.getDefaultTopic(), "foo").execute();
final TaskEvent task2 = client1.tasks().create(client1.getDefaultTopic(), "bar").execute();
// then
waitUntil(() -> handler1.getHandledTasks().size() + handler2.getHandledTasks().size() >= 2);
assertThat(handler1.getHandledTasks()).hasSize(1);
assertThat(handler1.getHandledTasks().get(0).getMetadata().getKey()).isEqualTo(task1.getMetadata().getKey());
assertThat(handler2.getHandledTasks()).hasSize(1);
assertThat(handler2.getHandledTasks().get(0).getMetadata().getKey()).isEqualTo(task2.getMetadata().getKey());
}
Aggregations