use of io.zeebe.transport.impl.RequestResponseHeaderDescriptor in project zeebe by zeebe-io.
the class CreateTopicStreamProcessorTest method shouldCreateTopicsWithInterleavingRequests.
@Test
public void shouldCreateTopicsWithInterleavingRequests() {
// given
partitionManager.addMember(SOCKET_ADDRESS1);
final long request1 = 42;
final long request2 = 52;
rule.newEvent().event(createTopic("foo", 2)).metadata(m -> m.requestId(request1)).write();
rule.newEvent().event(createTopic("bar", 2)).metadata(m -> m.requestId(request2)).write();
rule.runStreamProcessor(this::buildStreamProcessor);
waitUntil(() -> partitionManager.getPartitionRequests().size() == 4);
partitionManager.getPartitionRequests().forEach(r -> partitionManager.declarePartitionLeader(SOCKET_ADDRESS1, r.getPartitionId()));
// when
streamProcessor.runAsync(checkPartitionsCmd);
// then
waitUntil(() -> rule.getOutput().getSentResponses().size() >= 2);
final RequestResponseHeaderDescriptor responseHeader = new RequestResponseHeaderDescriptor();
final List<Long> respondedRequests = rule.getOutput().getSentResponses().stream().map(b -> responseHeader.wrap(b, TransportHeaderDescriptor.headerLength()).requestId()).collect(Collectors.toList());
assertThat(respondedRequests).containsExactlyInAnyOrder(request1, request2);
}
Aggregations