Search in sources :

Example 1 with NodeCfg

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();
}
Also used : FixedPartitionCfg(io.camunda.zeebe.broker.system.configuration.partitioning.FixedPartitionCfg) NodeCfg(io.camunda.zeebe.broker.system.configuration.partitioning.FixedPartitionCfg.NodeCfg) BrokerCfg(io.camunda.zeebe.broker.system.configuration.BrokerCfg) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 2 with NodeCfg

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();
}
Also used : FixedPartitionCfg(io.camunda.zeebe.broker.system.configuration.partitioning.FixedPartitionCfg) NodeCfg(io.camunda.zeebe.broker.system.configuration.partitioning.FixedPartitionCfg.NodeCfg) BrokerCfg(io.camunda.zeebe.broker.system.configuration.BrokerCfg) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 3 with NodeCfg

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);
}
Also used : FixedPartitionCfg(io.camunda.zeebe.broker.system.configuration.partitioning.FixedPartitionCfg) NodeCfg(io.camunda.zeebe.broker.system.configuration.partitioning.FixedPartitionCfg.NodeCfg) BrokerCfg(io.camunda.zeebe.broker.system.configuration.BrokerCfg) ValueSource(org.junit.jupiter.params.provider.ValueSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 4 with NodeCfg

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}]");
}
Also used : FixedPartitionCfg(io.camunda.zeebe.broker.system.configuration.partitioning.FixedPartitionCfg) NodeCfg(io.camunda.zeebe.broker.system.configuration.partitioning.FixedPartitionCfg.NodeCfg) BrokerCfg(io.camunda.zeebe.broker.system.configuration.BrokerCfg) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 5 with NodeCfg

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();
}
Also used : FixedPartitionCfg(io.camunda.zeebe.broker.system.configuration.partitioning.FixedPartitionCfg) NodeCfg(io.camunda.zeebe.broker.system.configuration.partitioning.FixedPartitionCfg.NodeCfg) BrokerCfg(io.camunda.zeebe.broker.system.configuration.BrokerCfg) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Aggregations

BrokerCfg (io.camunda.zeebe.broker.system.configuration.BrokerCfg)12 FixedPartitionCfg (io.camunda.zeebe.broker.system.configuration.partitioning.FixedPartitionCfg)12 NodeCfg (io.camunda.zeebe.broker.system.configuration.partitioning.FixedPartitionCfg.NodeCfg)12 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)12 Test (org.junit.jupiter.api.Test)9 ValueSource (org.junit.jupiter.params.provider.ValueSource)3