Search in sources :

Example 1 with Topology

use of io.camunda.zeebe.client.api.response.Topology in project zeebe-process-test by camunda.

the class EngineClientTest method shouldUseGatewayAddressToBuildClient.

@Test
void shouldUseGatewayAddressToBuildClient() {
    // given
    final ZeebeClient client = ZeebeClient.newClientBuilder().usePlaintext().gatewayAddress(zeebeEngine.getGatewayAddress()).build();
    // when
    final Topology topology = zeebeClient.newTopologyRequest().send().join();
    client.close();
    // then
    assertThat(topology).isNotNull();
}
Also used : ZeebeClient(io.camunda.zeebe.client.ZeebeClient) Topology(io.camunda.zeebe.client.api.response.Topology) Test(org.junit.jupiter.api.Test)

Example 2 with Topology

use of io.camunda.zeebe.client.api.response.Topology in project zeebe-test-container by camunda-community-hub.

the class ZeebeClusterTest method shouldStartClusterWithMixedGateways.

@Test
void shouldStartClusterWithMixedGateways() {
    // given
    cluster = ZeebeCluster.builder().withEmbeddedGateway(true).withReplicationFactor(1).withPartitionsCount(1).withBrokersCount(1).withGatewaysCount(1).build();
    // when
    cluster.start();
    // then
    for (final ZeebeGatewayNode<?> gateway : cluster.getGateways().values()) {
        try (final ZeebeClient client = ZeebeClient.newClientBuilder().usePlaintext().gatewayAddress(gateway.getExternalGatewayAddress()).build()) {
            final Topology topology = client.newTopologyRequest().send().join();
            assertThat(topology.getPartitionsCount()).as("there is exactly one partition as configured").isEqualTo(1);
            assertThat(topology.getReplicationFactor()).as("there is a replication factor of 1 as configured").isEqualTo(1);
            TopologyAssert.assertThat(topology).as("the topology is complete for a one broker, one partition cluster").isComplete(1, 1, 1).hasBrokersCount(1);
        }
    }
}
Also used : ZeebeClient(io.camunda.zeebe.client.ZeebeClient) Topology(io.camunda.zeebe.client.api.response.Topology) Test(org.junit.jupiter.api.Test)

Example 3 with Topology

use of io.camunda.zeebe.client.api.response.Topology in project zeebe-test-container by camunda-community-hub.

the class ZeebeClusterTest method shouldStartClusterWithEmbeddedGateways.

@Test
void shouldStartClusterWithEmbeddedGateways() {
    // given
    cluster = ZeebeCluster.builder().withEmbeddedGateway(true).withReplicationFactor(2).withPartitionsCount(2).withBrokersCount(2).build();
    // when
    cluster.start();
    // then
    for (final ZeebeGatewayNode<?> gateway : cluster.getGateways().values()) {
        try (final ZeebeClient client = ZeebeClient.newClientBuilder().usePlaintext().gatewayAddress(gateway.getExternalGatewayAddress()).build()) {
            final Topology topology = client.newTopologyRequest().send().join();
            assertThat(topology.getReplicationFactor()).as("there is replication factor of 2 as configured").isEqualTo(2);
            assertThat(topology.getPartitionsCount()).as("there are exactly two partitions as configured").isEqualTo(2);
            TopologyAssert.assertThat(topology).as("the topology is complete with 2 partitions and 2 brokers").hasBrokersCount(2).isComplete(2, 2, 2);
        }
    }
}
Also used : ZeebeClient(io.camunda.zeebe.client.ZeebeClient) Topology(io.camunda.zeebe.client.api.response.Topology) Test(org.junit.jupiter.api.Test)

Example 4 with Topology

use of io.camunda.zeebe.client.api.response.Topology in project zeebe-test-container by camunda-community-hub.

the class ClusterWithGatewayExampleTest method shouldStartCluster.

@Test
@Timeout(value = 15, unit = TimeUnit.MINUTES)
void shouldStartCluster() {
    // given
    Startables.deepStart(brokers).join();
    gatewayContainer.start();
    // when
    final Topology topology;
    try (final ZeebeClient client = newZeebeClient(gatewayContainer)) {
        topology = client.newTopologyRequest().send().join(5, TimeUnit.SECONDS);
    }
    // then
    final List<BrokerInfo> brokers = topology.getBrokers();
    Assertions.assertThat(brokers).as("the topology contains all the brokers, advertising the right address").hasSize(3).extracting(BrokerInfo::getAddress).containsExactlyInAnyOrder(brokerZeroContainer.getInternalCommandAddress(), brokerOneContainer.getInternalCommandAddress(), brokerTwoContainer.getInternalCommandAddress());
}
Also used : ZeebeClient(io.camunda.zeebe.client.ZeebeClient) Topology(io.camunda.zeebe.client.api.response.Topology) BrokerInfo(io.camunda.zeebe.client.api.response.BrokerInfo) Test(org.junit.jupiter.api.Test) Timeout(org.junit.jupiter.api.Timeout)

Example 5 with Topology

use of io.camunda.zeebe.client.api.response.Topology in project zeebe-test-container by camunda-community-hub.

the class ZeebeClusterSingleNodeExampleTest method shouldConnectToZeebe.

@Test
@Timeout(value = 5, unit = TimeUnit.MINUTES)
void shouldConnectToZeebe() {
    // given
    final Topology topology;
    // when
    try (final ZeebeClient client = cluster.newClientBuilder().build()) {
        topology = client.newTopologyRequest().send().join(5, TimeUnit.SECONDS);
    }
    // then
    final List<BrokerInfo> brokers = topology.getBrokers();
    Assertions.assertThat(brokers).as("the topology contains all the brokers, advertising the expected address").hasSize(1).extracting(BrokerInfo::getAddress).containsExactlyInAnyOrder(cluster.getBrokers().get(0).getInternalCommandAddress());
}
Also used : ZeebeClient(io.camunda.zeebe.client.ZeebeClient) Topology(io.camunda.zeebe.client.api.response.Topology) BrokerInfo(io.camunda.zeebe.client.api.response.BrokerInfo) Test(org.junit.jupiter.api.Test) Timeout(org.junit.jupiter.api.Timeout)

Aggregations

Topology (io.camunda.zeebe.client.api.response.Topology)62 Test (org.junit.jupiter.api.Test)27 BrokerInfo (io.camunda.zeebe.client.api.response.BrokerInfo)26 Test (org.junit.Test)26 ZeebeClient (io.camunda.zeebe.client.ZeebeClient)16 PartitionInfo (io.camunda.zeebe.client.api.response.PartitionInfo)11 ZeebeClientBuilder (io.camunda.zeebe.client.ZeebeClientBuilder)6 Timeout (org.junit.jupiter.api.Timeout)6 ClientTest (io.camunda.zeebe.client.util.ClientTest)5 TopologyResponse (io.camunda.zeebe.gateway.protocol.GatewayOuterClass.TopologyResponse)4 UncheckedExecutionException (com.google.common.util.concurrent.UncheckedExecutionException)3 RetriableClientFutureImpl (io.camunda.zeebe.client.impl.RetriableClientFutureImpl)3 TopologyImpl (io.camunda.zeebe.client.impl.response.TopologyImpl)3 TopologyRequest (io.camunda.zeebe.gateway.protocol.GatewayOuterClass.TopologyRequest)3 TopologyAssert (io.camunda.zeebe.test.util.asserts.TopologyAssert)3 ZeebeTestContainerDefaults (io.camunda.zeebe.test.util.testcontainers.ZeebeTestContainerDefaults)3 ZeebeBrokerNode (io.zeebe.containers.ZeebeBrokerNode)3 ZeebeGatewayNode (io.zeebe.containers.ZeebeGatewayNode)3 ZeebeNode (io.zeebe.containers.ZeebeNode)3 ZeebePort (io.zeebe.containers.ZeebePort)3