use of io.camunda.zeebe.gateway.impl.broker.request.BrokerCreateProcessInstanceRequest in project zeebe by camunda.
the class BrokerClientTest method shouldReturnErrorOnReadResponseFailure.
@Test
public void shouldReturnErrorOnReadResponseFailure() {
// given
registerCreateWfCommand();
final BrokerCreateProcessInstanceRequest request = new BrokerCreateProcessInstanceRequest() {
@Override
protected ProcessInstanceCreationRecord toResponseDto(final DirectBuffer buffer) {
throw new RuntimeException("Catch Me");
}
};
// then
assertThatThrownBy(() -> client.sendRequestWithRetry(request).join()).hasCauseInstanceOf(ClientResponseException.class).hasMessageContaining("Catch Me");
}
use of io.camunda.zeebe.gateway.impl.broker.request.BrokerCreateProcessInstanceRequest in project zeebe by camunda.
the class BrokerClientTest method shouldReturnErrorOnRequestFailure.
@Test
public void shouldReturnErrorOnRequestFailure() {
// given
broker.onExecuteCommandRequest(ValueType.PROCESS_INSTANCE_CREATION, ProcessInstanceCreationIntent.CREATE).respondWithError().errorCode(ErrorCode.INTERNAL_ERROR).errorData("test").register();
assertThatThrownBy(() -> client.sendRequestWithRetry(new BrokerCreateProcessInstanceRequest()).join()).hasCauseInstanceOf(BrokerErrorException.class).hasCause(new BrokerErrorException(new BrokerError(ErrorCode.INTERNAL_ERROR, "test")));
// then
final List<ExecuteCommandRequest> receivedCommandRequests = broker.getReceivedCommandRequests();
assertThat(receivedCommandRequests).hasSize(1);
receivedCommandRequests.forEach(request -> {
assertThat(request.valueType()).isEqualTo(ValueType.PROCESS_INSTANCE_CREATION);
assertThat(request.intent()).isEqualTo(ProcessInstanceCreationIntent.CREATE);
});
}
use of io.camunda.zeebe.gateway.impl.broker.request.BrokerCreateProcessInstanceRequest in project zeebe by camunda.
the class BrokerClientTest method shouldTimeoutIfPartitionLeaderMismatchResponse.
@Test
public void shouldTimeoutIfPartitionLeaderMismatchResponse() {
// given
broker.onExecuteCommandRequest(ValueType.PROCESS_INSTANCE_CREATION, ProcessInstanceCreationIntent.CREATE).respondWithError().errorCode(ErrorCode.PARTITION_LEADER_MISMATCH).errorData("").register();
// when
final var future = client.sendRequestWithRetry(new BrokerCreateProcessInstanceRequest());
// then
// when the partition is repeatedly not found, the client loops
// over refreshing the topology and making a request that fails and so on. The timeout
// kicks in at any point in that loop, so we cannot assert the exact error message any more
// specifically. It is also possible that Atomix times out before hand if we calculated a very
// small time out for the request, e.g. < 50ms, so we also cannot assert the value of the
// timeout
assertThatThrownBy(future::join).hasCauseInstanceOf(TimeoutException.class);
}
use of io.camunda.zeebe.gateway.impl.broker.request.BrokerCreateProcessInstanceRequest in project zeebe by camunda.
the class ClusteringRule method createProcessInstanceOnPartition.
public long createProcessInstanceOnPartition(final int partitionId, final String bpmnProcessId) {
final BrokerCreateProcessInstanceRequest request = new BrokerCreateProcessInstanceRequest().setBpmnProcessId(bpmnProcessId);
request.setPartitionId(partitionId);
final BrokerResponse<ProcessInstanceCreationRecord> response = gateway.getBrokerClient().sendRequestWithRetry(request).join();
if (response.isResponse()) {
return response.getResponse().getProcessInstanceKey();
} else {
throw new RuntimeException("Failed to create process instance for bpmn process id " + bpmnProcessId + " on partition with id " + partitionId + ": " + response);
}
}
use of io.camunda.zeebe.gateway.impl.broker.request.BrokerCreateProcessInstanceRequest in project zeebe by zeebe-io.
the class BrokerClientTest method shouldNotTimeoutIfPartitionLeaderMismatchResponseWhenRetryDisabled.
@Test
public void shouldNotTimeoutIfPartitionLeaderMismatchResponseWhenRetryDisabled() {
// given
broker.onExecuteCommandRequest(ValueType.PROCESS_INSTANCE_CREATION, ProcessInstanceCreationIntent.CREATE).respondWithError().errorCode(ErrorCode.PARTITION_LEADER_MISMATCH).errorData("").register();
// when
final var future = client.sendRequest(new BrokerCreateProcessInstanceRequest());
// then
assertThatThrownBy(future::join).hasCause(new BrokerErrorException(new BrokerError(ErrorCode.PARTITION_LEADER_MISMATCH, "")));
}
Aggregations