use of io.camunda.zeebe.broker.system.configuration.partitioning.FixedPartitionCfg.NodeCfg in project zeebe by camunda.
the class SystemContextTest method shouldNotThrowExceptionIfFixedPartitioningSchemeHasWrongPrioritiesWhenPriorityDisabled.
@Test
void shouldNotThrowExceptionIfFixedPartitioningSchemeHasWrongPrioritiesWhenPriorityDisabled() {
// given
final BrokerCfg brokerCfg = new BrokerCfg();
final var config = brokerCfg.getExperimental().getPartitioning();
final var fixedPartition = new FixedPartitionCfg();
final var nodes = List.of(new NodeCfg(), new NodeCfg());
brokerCfg.getCluster().getRaft().setEnablePriorityElection(false);
brokerCfg.getCluster().setClusterSize(2);
config.setScheme(Scheme.FIXED);
config.setFixed(List.of(fixedPartition));
fixedPartition.setNodes(nodes);
nodes.get(0).setNodeId(0);
nodes.get(0).setPriority(1);
nodes.get(1).setNodeId(1);
nodes.get(1).setPriority(1);
// when - then
assertThatCode(() -> initSystemContext(brokerCfg)).doesNotThrowAnyException();
}
use of io.camunda.zeebe.broker.system.configuration.partitioning.FixedPartitionCfg.NodeCfg in project zeebe by zeebe-io.
the class SystemContextTest method shouldNotThrowExceptionIfFixedPartitioningSchemeHasWrongPrioritiesWhenPriorityDisabled.
@Test
void shouldNotThrowExceptionIfFixedPartitioningSchemeHasWrongPrioritiesWhenPriorityDisabled() {
// given
final BrokerCfg brokerCfg = new BrokerCfg();
final var config = brokerCfg.getExperimental().getPartitioning();
final var fixedPartition = new FixedPartitionCfg();
final var nodes = List.of(new NodeCfg(), new NodeCfg());
brokerCfg.getCluster().getRaft().setEnablePriorityElection(false);
brokerCfg.getCluster().setClusterSize(2);
config.setScheme(Scheme.FIXED);
config.setFixed(List.of(fixedPartition));
fixedPartition.setNodes(nodes);
nodes.get(0).setNodeId(0);
nodes.get(0).setPriority(1);
nodes.get(1).setNodeId(1);
nodes.get(1).setPriority(1);
// when - then
assertThatCode(() -> initSystemContext(brokerCfg)).doesNotThrowAnyException();
}
use of io.camunda.zeebe.broker.system.configuration.partitioning.FixedPartitionCfg.NodeCfg in project zeebe by camunda-cloud.
the class SystemContextTest method shouldThrowExceptionIfFixedPartitioningSchemeUsesInvalidNodeId.
@ParameterizedTest
@ValueSource(ints = { -1, 2 })
void shouldThrowExceptionIfFixedPartitioningSchemeUsesInvalidNodeId(final int invalidId) {
// given
final BrokerCfg brokerCfg = new BrokerCfg();
final var config = brokerCfg.getExperimental().getPartitioning();
final var fixedPartition = new FixedPartitionCfg();
final var node = new NodeCfg();
config.setScheme(Scheme.FIXED);
config.setFixed(List.of(fixedPartition));
fixedPartition.getNodes().add(node);
node.setNodeId(invalidId);
// when - then
assertThatCode(() -> initSystemContext(brokerCfg)).isInstanceOf(IllegalArgumentException.class).hasMessageContaining("Expected fixed partition scheme for partition 1 to define nodes with a " + "nodeId between 0 and 0, but it was %d", invalidId);
}
use of io.camunda.zeebe.broker.system.configuration.partitioning.FixedPartitionCfg.NodeCfg in project zeebe by camunda-cloud.
the class SystemContextTest method shouldThrowExceptionIfFixedPartitioningSchemeHasSamePriorities.
@Test
void shouldThrowExceptionIfFixedPartitioningSchemeHasSamePriorities() {
// given
final BrokerCfg brokerCfg = new BrokerCfg();
final var config = brokerCfg.getExperimental().getPartitioning();
final var fixedPartition = new FixedPartitionCfg();
final var nodes = List.of(new NodeCfg(), new NodeCfg());
brokerCfg.getCluster().getRaft().setEnablePriorityElection(true);
brokerCfg.getCluster().setClusterSize(2);
config.setScheme(Scheme.FIXED);
config.setFixed(List.of(fixedPartition));
fixedPartition.setNodes(nodes);
nodes.get(0).setNodeId(0);
nodes.get(0).setPriority(1);
nodes.get(1).setNodeId(1);
nodes.get(1).setPriority(1);
// when - then
assertThatCode(() -> initSystemContext(brokerCfg)).isInstanceOf(IllegalArgumentException.class).hasMessageContaining("Expected each node for a partition 1 to have a different priority, but at least two of" + " them have the same priorities: [NodeCfg{nodeId=0, priority=1}," + " NodeCfg{nodeId=1, priority=1}]");
}
use of io.camunda.zeebe.broker.system.configuration.partitioning.FixedPartitionCfg.NodeCfg in project zeebe by camunda-cloud.
the class SystemContextTest method shouldNotThrowExceptionIfFixedPartitioningSchemeHasWrongPrioritiesWhenPriorityDisabled.
@Test
void shouldNotThrowExceptionIfFixedPartitioningSchemeHasWrongPrioritiesWhenPriorityDisabled() {
// given
final BrokerCfg brokerCfg = new BrokerCfg();
final var config = brokerCfg.getExperimental().getPartitioning();
final var fixedPartition = new FixedPartitionCfg();
final var nodes = List.of(new NodeCfg(), new NodeCfg());
brokerCfg.getCluster().getRaft().setEnablePriorityElection(false);
brokerCfg.getCluster().setClusterSize(2);
config.setScheme(Scheme.FIXED);
config.setFixed(List.of(fixedPartition));
fixedPartition.setNodes(nodes);
nodes.get(0).setNodeId(0);
nodes.get(0).setPriority(1);
nodes.get(1).setNodeId(1);
nodes.get(1).setPriority(1);
// when - then
assertThatCode(() -> initSystemContext(brokerCfg)).doesNotThrowAnyException();
}
Aggregations