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);
}
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);
}
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);
}
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());
}
}
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);
}
Aggregations