Search in sources :

Example 6 with WorkflowInstanceEvent

use of io.zeebe.client.event.WorkflowInstanceEvent in project zeebe by zeebe-io.

the class UpdatePayloadTest method shouldFailUpdatePayloadIfWorkflowInstanceIsCompleted.

@Test
public void shouldFailUpdatePayloadIfWorkflowInstanceIsCompleted() {
    // given
    clientRule.workflows().create(clientRule.getDefaultTopic()).bpmnProcessId("process").execute();
    clientRule.tasks().newTaskSubscription(clientRule.getDefaultTopic()).taskType("task-1").lockOwner("owner").lockTime(Duration.ofMinutes(5)).handler((c, t) -> c.complete(t).payload("{\"result\": \"done\"}").execute()).open();
    waitUntil(() -> eventRecorder.hasWorkflowInstanceEvent(wfInstanceEvent("ACTIVITY_COMPLETED")));
    final WorkflowInstanceEvent activityInstance = eventRecorder.getSingleWorkflowInstanceEvent(wfInstanceEvent("ACTIVITY_ACTIVATED"));
    // then
    thrown.expect(ClientCommandRejectedException.class);
    thrown.expectMessage("Command for event with key " + activityInstance.getMetadata().getKey() + " was rejected by broker (UPDATE_PAYLOAD_REJECTED)");
    // when
    clientRule.workflows().updatePayload(activityInstance).payload(PAYLOAD).execute();
}
Also used : TestUtil.waitUntil(io.zeebe.test.util.TestUtil.waitUntil) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) Bpmn(io.zeebe.model.bpmn.Bpmn) WorkflowInstanceEvent(io.zeebe.client.event.WorkflowInstanceEvent) TopicEventRecorder(io.zeebe.broker.it.util.TopicEventRecorder) RuleChain(org.junit.rules.RuleChain) ClientRule(io.zeebe.broker.it.ClientRule) TopicEventRecorder.wfInstanceEvent(io.zeebe.broker.it.util.TopicEventRecorder.wfInstanceEvent) Duration(java.time.Duration) EmbeddedBrokerRule(io.zeebe.broker.it.EmbeddedBrokerRule) org.junit(org.junit) ClientCommandRejectedException(io.zeebe.client.cmd.ClientCommandRejectedException) WorkflowDefinition(io.zeebe.model.bpmn.instance.WorkflowDefinition) ExpectedException(org.junit.rules.ExpectedException) WorkflowInstanceEvent(io.zeebe.client.event.WorkflowInstanceEvent)

Example 7 with WorkflowInstanceEvent

use of io.zeebe.client.event.WorkflowInstanceEvent 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");
}
Also used : TaskEvent(io.zeebe.client.event.TaskEvent) RecordingTaskHandler(io.zeebe.broker.it.util.RecordingTaskHandler) TestFileUtil(io.zeebe.test.util.TestFileUtil) TopologyResponse(io.zeebe.client.clustering.impl.TopologyResponse) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) Bpmn(io.zeebe.model.bpmn.Bpmn) WorkflowInstanceEvent(io.zeebe.client.event.WorkflowInstanceEvent) TopicEventRecorder(io.zeebe.broker.it.util.TopicEventRecorder) ZeebeClient(io.zeebe.client.ZeebeClient) SocketAddress(io.zeebe.transport.SocketAddress) Duration(java.time.Duration) ClusterServiceNames(io.zeebe.broker.clustering.ClusterServiceNames) EmbeddedBrokerRule(io.zeebe.broker.it.EmbeddedBrokerRule) ClientCommandRejectedException(io.zeebe.client.cmd.ClientCommandRejectedException) WorkflowDefinition(io.zeebe.model.bpmn.instance.WorkflowDefinition) ServiceName(io.zeebe.servicecontainer.ServiceName) ExpectedException(org.junit.rules.ExpectedException) Raft(io.zeebe.raft.Raft) TestUtil.waitUntil(io.zeebe.test.util.TestUtil.waitUntil) TopologyBroker(io.zeebe.client.clustering.impl.TopologyBroker) Test(org.junit.Test) RaftState(io.zeebe.raft.state.RaftState) TestUtil.doRepeatedly(io.zeebe.test.util.TestUtil.doRepeatedly) File(java.io.File) StandardCharsets(java.nio.charset.StandardCharsets) BrokerPartitionState(io.zeebe.client.clustering.impl.BrokerPartitionState) RuleChain(org.junit.rules.RuleChain) List(java.util.List) ClientRule(io.zeebe.broker.it.ClientRule) Rule(org.junit.Rule) Pattern(java.util.regex.Pattern) Files(org.assertj.core.util.Files) DeploymentEvent(io.zeebe.client.event.DeploymentEvent) Collections(java.util.Collections) TemporaryFolder(org.junit.rules.TemporaryFolder) InputStream(java.io.InputStream) TestUtil(io.zeebe.test.util.TestUtil) WorkflowInstanceEvent(io.zeebe.client.event.WorkflowInstanceEvent) Test(org.junit.Test)

Example 8 with WorkflowInstanceEvent

use of io.zeebe.client.event.WorkflowInstanceEvent in project zeebe by zeebe-io.

the class BrokerRecoveryTest method shouldDeployNewWorkflowVersionAfterRestart.

@Test
public void shouldDeployNewWorkflowVersionAfterRestart() {
    // given
    clientRule.workflows().deploy(clientRule.getDefaultTopic()).addWorkflowModel(WORKFLOW, "workflow.bpmn").execute();
    // when
    restartBroker();
    final DeploymentEvent deploymentResult = clientRule.workflows().deploy(clientRule.getDefaultTopic()).addWorkflowModel(WORKFLOW, "workflow.bpmn").execute();
    // then
    assertThat(deploymentResult.getDeployedWorkflows().get(0).getVersion()).isEqualTo(2);
    final WorkflowInstanceEvent workflowInstanceV1 = clientRule.workflows().create(clientRule.getDefaultTopic()).bpmnProcessId("process").version(1).execute();
    final WorkflowInstanceEvent workflowInstanceV2 = clientRule.workflows().create(clientRule.getDefaultTopic()).bpmnProcessId("process").latestVersion().execute();
    // then
    assertThat(workflowInstanceV1.getVersion()).isEqualTo(1);
    assertThat(workflowInstanceV2.getVersion()).isEqualTo(2);
}
Also used : WorkflowInstanceEvent(io.zeebe.client.event.WorkflowInstanceEvent) DeploymentEvent(io.zeebe.client.event.DeploymentEvent) Test(org.junit.Test)

Example 9 with WorkflowInstanceEvent

use of io.zeebe.client.event.WorkflowInstanceEvent 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");
}
Also used : TaskEvent(io.zeebe.client.event.TaskEvent) RecordingTaskHandler(io.zeebe.broker.it.util.RecordingTaskHandler) TestFileUtil(io.zeebe.test.util.TestFileUtil) TopologyResponse(io.zeebe.client.clustering.impl.TopologyResponse) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) Bpmn(io.zeebe.model.bpmn.Bpmn) WorkflowInstanceEvent(io.zeebe.client.event.WorkflowInstanceEvent) TopicEventRecorder(io.zeebe.broker.it.util.TopicEventRecorder) ZeebeClient(io.zeebe.client.ZeebeClient) SocketAddress(io.zeebe.transport.SocketAddress) Duration(java.time.Duration) ClusterServiceNames(io.zeebe.broker.clustering.ClusterServiceNames) EmbeddedBrokerRule(io.zeebe.broker.it.EmbeddedBrokerRule) ClientCommandRejectedException(io.zeebe.client.cmd.ClientCommandRejectedException) WorkflowDefinition(io.zeebe.model.bpmn.instance.WorkflowDefinition) ServiceName(io.zeebe.servicecontainer.ServiceName) ExpectedException(org.junit.rules.ExpectedException) Raft(io.zeebe.raft.Raft) TestUtil.waitUntil(io.zeebe.test.util.TestUtil.waitUntil) TopologyBroker(io.zeebe.client.clustering.impl.TopologyBroker) Test(org.junit.Test) RaftState(io.zeebe.raft.state.RaftState) TestUtil.doRepeatedly(io.zeebe.test.util.TestUtil.doRepeatedly) File(java.io.File) StandardCharsets(java.nio.charset.StandardCharsets) BrokerPartitionState(io.zeebe.client.clustering.impl.BrokerPartitionState) RuleChain(org.junit.rules.RuleChain) List(java.util.List) ClientRule(io.zeebe.broker.it.ClientRule) Rule(org.junit.Rule) Pattern(java.util.regex.Pattern) Files(org.assertj.core.util.Files) DeploymentEvent(io.zeebe.client.event.DeploymentEvent) Collections(java.util.Collections) TemporaryFolder(org.junit.rules.TemporaryFolder) InputStream(java.io.InputStream) TestUtil(io.zeebe.test.util.TestUtil) WorkflowInstanceEvent(io.zeebe.client.event.WorkflowInstanceEvent) Test(org.junit.Test)

Example 10 with WorkflowInstanceEvent

use of io.zeebe.client.event.WorkflowInstanceEvent in project zeebe by zeebe-io.

the class DeploymentClusteredTest method shouldDeployWorkflowAndCreateInstances.

@Test
public void shouldDeployWorkflowAndCreateInstances() {
    // given
    final int workCount = 10 * PARTITION_COUNT;
    clusteringRule.createTopic("test", PARTITION_COUNT);
    // when
    client.workflows().deploy("test").addWorkflowModel(WORKFLOW, "workflow.bpmn").execute();
    // then
    for (int p = 0; p < workCount; p++) {
        final WorkflowInstanceEvent workflowInstanceEvent = client.workflows().create("test").bpmnProcessId("process").execute();
        assertThat(workflowInstanceEvent.getState()).isEqualTo("WORKFLOW_INSTANCE_CREATED");
    }
}
Also used : WorkflowInstanceEvent(io.zeebe.client.event.WorkflowInstanceEvent) Test(org.junit.Test)

Aggregations

WorkflowInstanceEvent (io.zeebe.client.event.WorkflowInstanceEvent)31 Test (org.junit.Test)14 ClientRule (io.zeebe.broker.it.ClientRule)7 EmbeddedBrokerRule (io.zeebe.broker.it.EmbeddedBrokerRule)7 TopicEventRecorder (io.zeebe.broker.it.util.TopicEventRecorder)7 Bpmn (io.zeebe.model.bpmn.Bpmn)7 WorkflowDefinition (io.zeebe.model.bpmn.instance.WorkflowDefinition)7 TestUtil.waitUntil (io.zeebe.test.util.TestUtil.waitUntil)7 Duration (java.time.Duration)7 Assertions.assertThat (org.assertj.core.api.Assertions.assertThat)7 RuleChain (org.junit.rules.RuleChain)7 RecordingTaskHandler (io.zeebe.broker.it.util.RecordingTaskHandler)6 WorkflowsClient (io.zeebe.client.WorkflowsClient)6 TaskEvent (io.zeebe.client.event.TaskEvent)6 ExpectedException (org.junit.rules.ExpectedException)6 TopicEventRecorder.wfInstanceEvent (io.zeebe.broker.it.util.TopicEventRecorder.wfInstanceEvent)5 org.junit (org.junit)5 ClientCommandRejectedException (io.zeebe.client.cmd.ClientCommandRejectedException)4 DeploymentEvent (io.zeebe.client.event.DeploymentEvent)4 TasksClient (io.zeebe.client.TasksClient)3