Search in sources :

Example 6 with BrokerInfo

use of io.camunda.zeebe.client.api.response.BrokerInfo in project zeebe by camunda.

the class AvailabilityTest method shouldActivateJobsRoundRobinWhenOnePartitionDown.

@Test
public void shouldActivateJobsRoundRobinWhenOnePartitionDown() {
    // given
    final int numInstances = 2 * partitionCount;
    final BrokerInfo leaderForPartition = clusteringRule.getLeaderForPartition(partitionCount);
    clusteringRule.stopBroker(leaderForPartition.getNodeId());
    for (int i = 0; i < numInstances; i++) {
        clientRule.createProcessInstance(processDefinitionKey);
    }
    // when
    Awaitility.await().until(() -> RecordingExporter.jobRecords(JobIntent.CREATED).limit(numInstances).count() == numInstances);
    final Set<Long> activatedJobsKey = new HashSet<>();
    final List<ActivatedJob> jobs = clientRule.getClient().newActivateJobsCommand().jobType(JOBTYPE).maxJobsToActivate(2 * numInstances).timeout(Duration.ofMinutes(5)).send().join().getJobs();
    jobs.forEach(job -> activatedJobsKey.add(job.getKey()));
    // then
    assertThat(activatedJobsKey).hasSize(numInstances);
}
Also used : ActivatedJob(io.camunda.zeebe.client.api.response.ActivatedJob) BrokerInfo(io.camunda.zeebe.client.api.response.BrokerInfo) HashSet(java.util.HashSet) Test(org.junit.Test)

Example 7 with BrokerInfo

use of io.camunda.zeebe.client.api.response.BrokerInfo in project zeebe by camunda.

the class AvailabilityTest method shouldCreateProcessWhenPartitionRecovers.

@Test
public void shouldCreateProcessWhenPartitionRecovers() {
    // given
    final int failingPartition = partitionCount;
    final BrokerInfo leaderForPartition = clusteringRule.getLeaderForPartition(failingPartition);
    clusteringRule.stopBroker(leaderForPartition.getNodeId());
    for (int i = 0; i < partitionCount; i++) {
        clientRule.createProcessInstance(processDefinitionKey);
    }
    // when
    clusteringRule.restartBroker(leaderForPartition.getNodeId());
    for (int i = 0; i < partitionCount; i++) {
        clientRule.createProcessInstance(processDefinitionKey);
    }
    // then
    assertThat(RecordingExporter.processInstanceCreationRecords().withIntent(ProcessInstanceCreationIntent.CREATED).filter(r -> r.getPartitionId() == failingPartition)).hasSizeGreaterThanOrEqualTo(1);
}
Also used : BrokerInfo(io.camunda.zeebe.client.api.response.BrokerInfo) Test(org.junit.Test)

Example 8 with BrokerInfo

use of io.camunda.zeebe.client.api.response.BrokerInfo in project zeebe by camunda.

the class AvailabilityTest method shouldCreateProcessWhenOnePartitionDown.

@Test
public void shouldCreateProcessWhenOnePartitionDown() {
    final BrokerInfo leaderForPartition = clusteringRule.getLeaderForPartition(partitionCount);
    // when
    clusteringRule.stopBroker(leaderForPartition.getNodeId());
    for (int i = 0; i < 2 * partitionCount; i++) {
        clientRule.createProcessInstance(processDefinitionKey);
    }
    // then
    final List<Integer> partitionIds = RecordingExporter.processInstanceCreationRecords().withIntent(ProcessInstanceCreationIntent.CREATED).map(Record::getPartitionId).limit(2 * partitionCount).collect(Collectors.toList());
    assertThat(partitionIds).hasSize(2 * partitionCount);
    assertThat(partitionIds).containsExactlyInAnyOrder(1, 1, 1, 2, 2, 2);
}
Also used : Record(io.camunda.zeebe.protocol.record.Record) BrokerInfo(io.camunda.zeebe.client.api.response.BrokerInfo) Test(org.junit.Test)

Example 9 with BrokerInfo

use of io.camunda.zeebe.client.api.response.BrokerInfo in project zeebe by camunda.

the class TopologyClusterTest method shouldExposeClusterSettings.

@Test
public void shouldExposeClusterSettings() {
    // when
    final Topology topology = CLIENT_RULE.getClient().newTopologyRequest().send().join();
    // then
    assertThat(topology.getClusterSize()).isEqualTo(CLUSTERING_RULE.getClusterSize());
    assertThat(topology.getPartitionsCount()).isEqualTo(CLUSTERING_RULE.getPartitionCount());
    assertThat(topology.getReplicationFactor()).isEqualTo(CLUSTERING_RULE.getReplicationFactor());
    // NOTE: this fails in Intellij because we don't have access to the package version but it works
    // when run from the CLI
    assertThat(topology.getGatewayVersion()).isEqualTo(Gateway.class.getPackage().getImplementationVersion());
    for (final BrokerInfo broker : topology.getBrokers()) {
        assertThat(broker.getVersion()).isEqualTo(Broker.class.getPackage().getImplementationVersion());
    }
}
Also used : Topology(io.camunda.zeebe.client.api.response.Topology) BrokerInfo(io.camunda.zeebe.client.api.response.BrokerInfo) Test(org.junit.Test)

Example 10 with BrokerInfo

use of io.camunda.zeebe.client.api.response.BrokerInfo in project zeebe by camunda.

the class GossipClusteringTest method shouldRemoveLeaderFromCluster.

@Test
public void shouldRemoveLeaderFromCluster() {
    // given
    final BrokerInfo leaderForPartition = clusteringRule.getLeaderForPartition(1);
    final InetSocketAddress[] otherBrokers = clusteringRule.getOtherBrokers(leaderForPartition.getNodeId());
    // when
    clusteringRule.stopBrokerAndAwaitNewLeader(leaderForPartition.getNodeId());
    // then
    final List<InetSocketAddress> topologyBrokers = clusteringRule.getBrokersInCluster();
    assertThat(topologyBrokers).containsExactlyInAnyOrder(otherBrokers);
}
Also used : InetSocketAddress(java.net.InetSocketAddress) BrokerInfo(io.camunda.zeebe.client.api.response.BrokerInfo) Test(org.junit.Test)

Aggregations

BrokerInfo (io.camunda.zeebe.client.api.response.BrokerInfo)52 Test (org.junit.Test)39 Topology (io.camunda.zeebe.client.api.response.Topology)29 PartitionInfo (io.camunda.zeebe.client.api.response.PartitionInfo)16 ZeebeClient (io.camunda.zeebe.client.ZeebeClient)9 ActivatedJob (io.camunda.zeebe.client.api.response.ActivatedJob)6 InetSocketAddress (java.net.InetSocketAddress)6 HashSet (java.util.HashSet)6 HashMap (java.util.HashMap)5 Test (org.junit.jupiter.api.Test)5 AtomixCluster (io.atomix.cluster.AtomixCluster)3 AtomixClusterBuilder (io.atomix.cluster.AtomixClusterBuilder)3 ClusterConfig (io.atomix.cluster.ClusterConfig)3 MemberId (io.atomix.cluster.MemberId)3 BootstrapDiscoveryProvider (io.atomix.cluster.discovery.BootstrapDiscoveryProvider)3 NettyMessagingService (io.atomix.cluster.messaging.impl.NettyMessagingService)3 NettyUnicastService (io.atomix.cluster.messaging.impl.NettyUnicastService)3 SwimMembershipProtocol (io.atomix.cluster.protocol.SwimMembershipProtocol)3 RaftPartition (io.atomix.raft.partition.RaftPartition)3 Address (io.atomix.utils.net.Address)3