Search in sources :

Example 1 with ClientOutput

use of io.zeebe.transport.ClientOutput in project zeebe by zeebe-io.

the class CreateTopicTest method shouldRejectPartitionCreationAndNotBreak.

@Test
public void shouldRejectPartitionCreationAndNotBreak() {
    // given
    final ClientTransport transport = apiRule.getTransport();
    final RemoteAddress remoteAddress = transport.registerRemoteAndAwaitChannel(BROKER_MGMT_ADDRESS);
    final ClientOutput output = transport.getOutput();
    final CreatePartitionRequest partitionMessage = new CreatePartitionRequest();
    final DirectBuffer topicName = BufferUtil.wrapString("foo");
    final int partition1 = 142;
    final int partition2 = 143;
    partitionMessage.topicName(topicName);
    partitionMessage.partitionId(partition1);
    // => should create partition
    doRepeatedly(() -> output.sendRequest(remoteAddress, partitionMessage)).until(r -> r != null);
    // => should be rejected/ignored
    doRepeatedly(() -> output.sendRequest(remoteAddress, partitionMessage)).until(r -> r != null);
    // when creating another partition
    partitionMessage.partitionId(partition2);
    doRepeatedly(() -> output.sendRequest(remoteAddress, partitionMessage)).until(r -> r != null);
    // then this should be successful (i.e. the rejected request should not have jammed the broker)
    waitUntil(() -> arePublished(partition1, partition2));
}
Also used : DirectBuffer(org.agrona.DirectBuffer) RemoteAddress(io.zeebe.transport.RemoteAddress) CreatePartitionRequest(io.zeebe.broker.clustering.management.message.CreatePartitionRequest) ClientTransport(io.zeebe.transport.ClientTransport) ClientOutput(io.zeebe.transport.ClientOutput) Test(org.junit.Test)

Aggregations

CreatePartitionRequest (io.zeebe.broker.clustering.management.message.CreatePartitionRequest)1 ClientOutput (io.zeebe.transport.ClientOutput)1 ClientTransport (io.zeebe.transport.ClientTransport)1 RemoteAddress (io.zeebe.transport.RemoteAddress)1 DirectBuffer (org.agrona.DirectBuffer)1 Test (org.junit.Test)1