use of io.zeebe.test.broker.protocol.clientapi.ControlMessageResponse in project zeebe by zeebe-io.
the class CreateTopicTest method arePublished.
protected boolean arePublished(int... partitions) {
final ControlMessageResponse response = apiRule.createControlMessageRequest().messageType(ControlMessageType.REQUEST_TOPOLOGY).sendAndAwait();
final Set<Integer> expectedPartitions = Arrays.stream(partitions).boxed().collect(Collectors.toSet());
final Map<String, Object> topology = response.getData();
final List<Map<String, Object>> brokers = (List<Map<String, Object>>) topology.get("brokers");
for (Map<String, Object> broker : brokers) {
final List<Map<String, Object>> brokerPartitionStates = (List<Map<String, Object>>) broker.get("partitions");
for (Map<String, Object> brokerPartitionState : brokerPartitionStates) {
final String state = brokerPartitionState.get("state").toString();
if (state.equals(LEADER_STATE)) {
expectedPartitions.remove(brokerPartitionState.get("partitionId"));
}
}
}
return expectedPartitions.isEmpty();
}
use of io.zeebe.test.broker.protocol.clientapi.ControlMessageResponse in project zeebe by zeebe-io.
the class RequestPartitionsTest method shouldReturnCreatedPartitionsAfterRestart.
/**
* testing snapshotting
*/
@Test
public void shouldReturnCreatedPartitionsAfterRestart() {
// given
final String topicName = "foo";
final int numPartitions = 2;
apiRule.createTopic(topicName, 2);
brokerRule.restartBroker();
// when
// have to do this multiple times as the stream processor for answering the request may not be available yet
final ControlMessageResponse response = doRepeatedly(() -> apiRule.createControlMessageRequest().messageType(ControlMessageType.REQUEST_PARTITIONS).partitionId(Protocol.SYSTEM_PARTITION).sendAndAwait()).until(r -> r != null);
// then
assertResponse(response, numPartitions, topicName);
}
use of io.zeebe.test.broker.protocol.clientapi.ControlMessageResponse in project zeebe by zeebe-io.
the class RequestPartitionsTest method shouldReturnCreatedPartitions.
@Test
public void shouldReturnCreatedPartitions() {
// given
final String topicName = "foo";
final int numPartitions = 2;
apiRule.createTopic(topicName, 2);
// when
final ControlMessageResponse response = apiRule.createControlMessageRequest().messageType(ControlMessageType.REQUEST_PARTITIONS).partitionId(Protocol.SYSTEM_PARTITION).sendAndAwait();
// then
assertResponse(response, numPartitions, topicName);
}
use of io.zeebe.test.broker.protocol.clientapi.ControlMessageResponse in project zeebe by zeebe-io.
the class RequestPartitionsTest method shouldRespondWithNoPartition.
@Test
public void shouldRespondWithNoPartition() {
// when
final ControlMessageResponse response = doRepeatedly(() -> apiRule.createControlMessageRequest().messageType(ControlMessageType.REQUEST_PARTITIONS).partitionId(Protocol.SYSTEM_PARTITION).sendAndAwait()).until(r -> r != null);
// then
assertResponse(response, 0);
}
use of io.zeebe.test.broker.protocol.clientapi.ControlMessageResponse in project zeebe by zeebe-io.
the class TaskSubscriptionTest method shouldIgnoreCreditsRequestIfSubscriptionDoesNotExist.
@Test
public void shouldIgnoreCreditsRequestIfSubscriptionDoesNotExist() {
// given
final int nonExistingSubscriberKey = 444;
final ControlMessageRequestBuilder request = apiRule.createControlMessageRequest().messageType(ControlMessageType.INCREASE_TASK_SUBSCRIPTION_CREDITS).partitionId(apiRule.getDefaultPartitionId()).data().put("subscriberKey", nonExistingSubscriberKey).put("credits", 2).put("partitionId", apiRule.getDefaultPartitionId()).done();
// when
final ControlMessageResponse response = request.sendAndAwait();
// then
assertThat(response.getData()).containsEntry("subscriberKey", nonExistingSubscriberKey);
}
Aggregations