Search in sources :

Example 1 with ZeebeNode

use of io.zeebe.containers.ZeebeNode in project zeebe by zeebe-io.

the class AdvertisedAddressTest method shouldCommunicateOverProxy.

@Test
void shouldCommunicateOverProxy() {
    // given
    cluster.start();
    // gossip
    try (final var client = cluster.newClientBuilder().build()) {
        final Topology topology = client.newTopologyRequest().send().join(5, TimeUnit.SECONDS);
        final var messageSend = client.newPublishMessageCommand().messageName("test").correlationKey("test").send().join(5, TimeUnit.SECONDS);
        // then - gateway can talk to the broker
        final var proxiedPorts = cluster.getBrokers().values().stream().map(ZeebeNode::getInternalHost).map(host -> toxiproxy.getProxy(host, ZeebePort.COMMAND.getPort())).map(ContainerProxy::getOriginalProxyPort).collect(Collectors.toList());
        TopologyAssert.assertThat(topology).isComplete(3, 1).hasBrokerSatisfying(b -> assertThat(b.getAddress()).as("broker 0 advertises the correct proxied address").isEqualTo(TOXIPROXY_NETWORK_ALIAS + ":" + proxiedPorts.get(0))).hasBrokerSatisfying(b -> assertThat(b.getAddress()).as("broker 1 advertises the correct proxied address").isEqualTo(TOXIPROXY_NETWORK_ALIAS + ":" + proxiedPorts.get(1))).hasBrokerSatisfying(b -> assertThat(b.getAddress()).as("broker 2 advertises the correct proxied address").isEqualTo(TOXIPROXY_NETWORK_ALIAS + ":" + proxiedPorts.get(2)));
        assertThat(messageSend.getMessageKey()).isPositive();
    }
}
Also used : BeforeEach(org.junit.jupiter.api.BeforeEach) Topology(io.camunda.zeebe.client.api.response.Topology) DockerImageName(org.testcontainers.utility.DockerImageName) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) Testcontainers(org.testcontainers.junit.jupiter.Testcontainers) Collectors(java.util.stream.Collectors) Network(org.testcontainers.containers.Network) ArrayList(java.util.ArrayList) TimeUnit(java.util.concurrent.TimeUnit) Test(org.junit.jupiter.api.Test) ZeebeBrokerNode(io.zeebe.containers.ZeebeBrokerNode) List(java.util.List) AfterEach(org.junit.jupiter.api.AfterEach) ContainerProxy(org.testcontainers.containers.ToxiproxyContainer.ContainerProxy) ZeebeTestContainerDefaults(io.camunda.zeebe.test.util.testcontainers.ZeebeTestContainerDefaults) ToxiproxyContainer(org.testcontainers.containers.ToxiproxyContainer) ZeebeGatewayNode(io.zeebe.containers.ZeebeGatewayNode) ZeebeNode(io.zeebe.containers.ZeebeNode) TopologyAssert(io.camunda.zeebe.test.util.asserts.TopologyAssert) ZeebePort(io.zeebe.containers.ZeebePort) ZeebeCluster(io.zeebe.containers.cluster.ZeebeCluster) CloseHelper(org.agrona.CloseHelper) Container(org.testcontainers.junit.jupiter.Container) Topology(io.camunda.zeebe.client.api.response.Topology) Test(org.junit.jupiter.api.Test)

Example 2 with ZeebeNode

use of io.zeebe.containers.ZeebeNode in project zeebe by camunda-cloud.

the class AdvertisedAddressTest method shouldCommunicateOverProxy.

@Test
void shouldCommunicateOverProxy() {
    // given
    cluster.start();
    // gossip
    try (final var client = cluster.newClientBuilder().build()) {
        final Topology topology = client.newTopologyRequest().send().join(5, TimeUnit.SECONDS);
        final var messageSend = client.newPublishMessageCommand().messageName("test").correlationKey("test").send().join(5, TimeUnit.SECONDS);
        // then - gateway can talk to the broker
        final var proxiedPorts = cluster.getBrokers().values().stream().map(ZeebeNode::getInternalHost).map(host -> toxiproxy.getProxy(host, ZeebePort.COMMAND.getPort())).map(ContainerProxy::getOriginalProxyPort).collect(Collectors.toList());
        TopologyAssert.assertThat(topology).isComplete(3, 1).hasBrokerSatisfying(b -> assertThat(b.getAddress()).as("broker 0 advertises the correct proxied address").isEqualTo(TOXIPROXY_NETWORK_ALIAS + ":" + proxiedPorts.get(0))).hasBrokerSatisfying(b -> assertThat(b.getAddress()).as("broker 1 advertises the correct proxied address").isEqualTo(TOXIPROXY_NETWORK_ALIAS + ":" + proxiedPorts.get(1))).hasBrokerSatisfying(b -> assertThat(b.getAddress()).as("broker 2 advertises the correct proxied address").isEqualTo(TOXIPROXY_NETWORK_ALIAS + ":" + proxiedPorts.get(2)));
        assertThat(messageSend.getMessageKey()).isPositive();
    }
}
Also used : BeforeEach(org.junit.jupiter.api.BeforeEach) Topology(io.camunda.zeebe.client.api.response.Topology) DockerImageName(org.testcontainers.utility.DockerImageName) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) Testcontainers(org.testcontainers.junit.jupiter.Testcontainers) Collectors(java.util.stream.Collectors) Network(org.testcontainers.containers.Network) ArrayList(java.util.ArrayList) TimeUnit(java.util.concurrent.TimeUnit) Test(org.junit.jupiter.api.Test) ZeebeBrokerNode(io.zeebe.containers.ZeebeBrokerNode) List(java.util.List) AfterEach(org.junit.jupiter.api.AfterEach) ContainerProxy(org.testcontainers.containers.ToxiproxyContainer.ContainerProxy) ZeebeTestContainerDefaults(io.camunda.zeebe.test.util.testcontainers.ZeebeTestContainerDefaults) ToxiproxyContainer(org.testcontainers.containers.ToxiproxyContainer) ZeebeGatewayNode(io.zeebe.containers.ZeebeGatewayNode) ZeebeNode(io.zeebe.containers.ZeebeNode) TopologyAssert(io.camunda.zeebe.test.util.asserts.TopologyAssert) ZeebePort(io.zeebe.containers.ZeebePort) ZeebeCluster(io.zeebe.containers.cluster.ZeebeCluster) CloseHelper(org.agrona.CloseHelper) Container(org.testcontainers.junit.jupiter.Container) Topology(io.camunda.zeebe.client.api.response.Topology) Test(org.junit.jupiter.api.Test)

Example 3 with ZeebeNode

use of io.zeebe.containers.ZeebeNode in project zeebe by camunda.

the class AdvertisedAddressTest method shouldCommunicateOverProxy.

@Test
void shouldCommunicateOverProxy() {
    // given
    cluster.start();
    // gossip
    try (final var client = cluster.newClientBuilder().build()) {
        final Topology topology = client.newTopologyRequest().send().join(5, TimeUnit.SECONDS);
        final var messageSend = client.newPublishMessageCommand().messageName("test").correlationKey("test").send().join(5, TimeUnit.SECONDS);
        // then - gateway can talk to the broker
        final var proxiedPorts = cluster.getBrokers().values().stream().map(ZeebeNode::getInternalHost).map(host -> toxiproxy.getProxy(host, ZeebePort.COMMAND.getPort())).map(ContainerProxy::getOriginalProxyPort).collect(Collectors.toList());
        TopologyAssert.assertThat(topology).isComplete(3, 1).hasBrokerSatisfying(b -> assertThat(b.getAddress()).as("broker 0 advertises the correct proxied address").isEqualTo(TOXIPROXY_NETWORK_ALIAS + ":" + proxiedPorts.get(0))).hasBrokerSatisfying(b -> assertThat(b.getAddress()).as("broker 1 advertises the correct proxied address").isEqualTo(TOXIPROXY_NETWORK_ALIAS + ":" + proxiedPorts.get(1))).hasBrokerSatisfying(b -> assertThat(b.getAddress()).as("broker 2 advertises the correct proxied address").isEqualTo(TOXIPROXY_NETWORK_ALIAS + ":" + proxiedPorts.get(2)));
        assertThat(messageSend.getMessageKey()).isPositive();
    }
}
Also used : BeforeEach(org.junit.jupiter.api.BeforeEach) Topology(io.camunda.zeebe.client.api.response.Topology) DockerImageName(org.testcontainers.utility.DockerImageName) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) Testcontainers(org.testcontainers.junit.jupiter.Testcontainers) Collectors(java.util.stream.Collectors) Network(org.testcontainers.containers.Network) ArrayList(java.util.ArrayList) TimeUnit(java.util.concurrent.TimeUnit) Test(org.junit.jupiter.api.Test) ZeebeBrokerNode(io.zeebe.containers.ZeebeBrokerNode) List(java.util.List) AfterEach(org.junit.jupiter.api.AfterEach) ContainerProxy(org.testcontainers.containers.ToxiproxyContainer.ContainerProxy) ZeebeTestContainerDefaults(io.camunda.zeebe.test.util.testcontainers.ZeebeTestContainerDefaults) ToxiproxyContainer(org.testcontainers.containers.ToxiproxyContainer) ZeebeGatewayNode(io.zeebe.containers.ZeebeGatewayNode) ZeebeNode(io.zeebe.containers.ZeebeNode) TopologyAssert(io.camunda.zeebe.test.util.asserts.TopologyAssert) ZeebePort(io.zeebe.containers.ZeebePort) ZeebeCluster(io.zeebe.containers.cluster.ZeebeCluster) CloseHelper(org.agrona.CloseHelper) Container(org.testcontainers.junit.jupiter.Container) Topology(io.camunda.zeebe.client.api.response.Topology) Test(org.junit.jupiter.api.Test)

Aggregations

Topology (io.camunda.zeebe.client.api.response.Topology)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 ZeebeCluster (io.zeebe.containers.cluster.ZeebeCluster)3 ArrayList (java.util.ArrayList)3 List (java.util.List)3 TimeUnit (java.util.concurrent.TimeUnit)3 Collectors (java.util.stream.Collectors)3 CloseHelper (org.agrona.CloseHelper)3 Assertions.assertThat (org.assertj.core.api.Assertions.assertThat)3 AfterEach (org.junit.jupiter.api.AfterEach)3 BeforeEach (org.junit.jupiter.api.BeforeEach)3 Test (org.junit.jupiter.api.Test)3 Network (org.testcontainers.containers.Network)3 ToxiproxyContainer (org.testcontainers.containers.ToxiproxyContainer)3 ContainerProxy (org.testcontainers.containers.ToxiproxyContainer.ContainerProxy)3