Search in sources :

Example 1 with SnapshotId

use of io.camunda.zeebe.snapshots.SnapshotId in project zeebe by camunda.

the class BrokerSnapshotTest method shouldTakeSnapshotAtCorrectIndex.

@Test
public void shouldTakeSnapshotAtCorrectIndex() {
    // given
    createSomeEvents();
    // when
    brokerAdminService.takeSnapshot();
    final SnapshotId snapshotId = waitForSnapshotAtBroker(brokerAdminService, PARTITION_ID);
    // then
    final long processedIndex = journalReader.seekToAsqn(snapshotId.getProcessedPosition());
    final long expectedSnapshotIndex = processedIndex - 1;
    assertThat(snapshotId.getIndex()).isEqualTo(expectedSnapshotIndex);
}
Also used : SnapshotId(io.camunda.zeebe.snapshots.SnapshotId) Test(org.junit.Test)

Example 2 with SnapshotId

use of io.camunda.zeebe.snapshots.SnapshotId in project zeebe by camunda-cloud.

the class ClusteredSnapshotTest method shouldKeepIndexAndTerm.

@Test
public void shouldKeepIndexAndTerm() {
    // given
    ControllableExporter.updatePosition(false);
    removeExporters();
    restartCluster();
    publishMessages();
    triggerSnapshotRoutine();
    // expect - each broker has created a snapshot
    awaitUntilAsserted((broker) -> {
        assertThat(broker).havingSnapshot().withExportedPosition(Long.MAX_VALUE);
    });
    final Map<Integer, SnapshotId> snapshotsByBroker = clusteringRule.getTopologyFromClient().getBrokers().stream().collect(Collectors.toMap(BrokerInfo::getNodeId, this::getSnapshot));
    // when
    configureExporters();
    restartCluster();
    publishMessages();
    triggerSnapshotRoutine();
    // then
    awaitUntilAsserted((broker) -> {
        final SnapshotId expectedSnapshot = snapshotsByBroker.get(broker.getConfig().getCluster().getNodeId());
        assertThat(broker).havingSnapshot().withIndex(expectedSnapshot.getIndex()).withTerm(expectedSnapshot.getTerm());
    });
}
Also used : SnapshotId(io.camunda.zeebe.snapshots.SnapshotId) Test(org.junit.Test)

Example 3 with SnapshotId

use of io.camunda.zeebe.snapshots.SnapshotId in project zeebe by camunda-cloud.

the class ClusteredSnapshotTest method shouldNotTakeNewSnapshot.

@Test
public void shouldNotTakeNewSnapshot() {
    // given
    ControllableExporter.updatePosition(false);
    removeExporters();
    restartCluster();
    publishMessages();
    final var leaderId = clusteringRule.getLeaderForPartition(1).getNodeId();
    final var leaderAdminService = clusteringRule.getBroker(leaderId).getBrokerContext().getBrokerAdminService();
    final var expectedProcessedPosition = leaderAdminService.getPartitionStatus().get(1).getProcessedPosition();
    // expect
    awaitUntilAsserted((broker) -> {
        triggerSnapshotRoutine();
        assertThat(broker).havingSnapshot().withProcessedPosition(expectedProcessedPosition).withExportedPosition(Long.MAX_VALUE);
    });
    final Map<Integer, SnapshotId> snapshotsByBroker = clusteringRule.getTopologyFromClient().getBrokers().stream().collect(Collectors.toMap(BrokerInfo::getNodeId, this::getSnapshot));
    // when
    configureExporters();
    restartCluster();
    triggerSnapshotRoutine();
    // then
    awaitUntilAsserted((broker) -> {
        final SnapshotId expectedSnapshot = snapshotsByBroker.get(broker.getConfig().getCluster().getNodeId());
        assertThat(broker).havingSnapshot().isEqualTo(expectedSnapshot);
    });
}
Also used : SnapshotId(io.camunda.zeebe.snapshots.SnapshotId) Test(org.junit.Test)

Example 4 with SnapshotId

use of io.camunda.zeebe.snapshots.SnapshotId in project zeebe by zeebe-io.

the class ClusteredSnapshotTest method shouldNotTakeNewSnapshot.

@Test
public void shouldNotTakeNewSnapshot() {
    // given
    ControllableExporter.updatePosition(false);
    removeExporters();
    restartCluster();
    publishMessages();
    final var leaderId = clusteringRule.getLeaderForPartition(1).getNodeId();
    final var leaderAdminService = clusteringRule.getBroker(leaderId).getBrokerContext().getBrokerAdminService();
    final var expectedProcessedPosition = leaderAdminService.getPartitionStatus().get(1).getProcessedPosition();
    // expect
    awaitUntilAsserted((broker) -> {
        triggerSnapshotRoutine();
        assertThat(broker).havingSnapshot().withProcessedPosition(expectedProcessedPosition).withExportedPosition(Long.MAX_VALUE);
    });
    final Map<Integer, SnapshotId> snapshotsByBroker = clusteringRule.getTopologyFromClient().getBrokers().stream().collect(Collectors.toMap(BrokerInfo::getNodeId, this::getSnapshot));
    // when
    configureExporters();
    restartCluster();
    triggerSnapshotRoutine();
    // then
    awaitUntilAsserted((broker) -> {
        final SnapshotId expectedSnapshot = snapshotsByBroker.get(broker.getConfig().getCluster().getNodeId());
        assertThat(broker).havingSnapshot().isEqualTo(expectedSnapshot);
    });
}
Also used : SnapshotId(io.camunda.zeebe.snapshots.SnapshotId) Test(org.junit.Test)

Example 5 with SnapshotId

use of io.camunda.zeebe.snapshots.SnapshotId in project zeebe by zeebe-io.

the class ClusteredSnapshotTest method shouldKeepIndexAndTerm.

@Test
public void shouldKeepIndexAndTerm() {
    // given
    ControllableExporter.updatePosition(false);
    removeExporters();
    restartCluster();
    publishMessages();
    triggerSnapshotRoutine();
    // expect - each broker has created a snapshot
    awaitUntilAsserted((broker) -> {
        assertThat(broker).havingSnapshot().withExportedPosition(Long.MAX_VALUE);
    });
    final Map<Integer, SnapshotId> snapshotsByBroker = clusteringRule.getTopologyFromClient().getBrokers().stream().collect(Collectors.toMap(BrokerInfo::getNodeId, this::getSnapshot));
    // when
    configureExporters();
    restartCluster();
    publishMessages();
    triggerSnapshotRoutine();
    // then
    awaitUntilAsserted((broker) -> {
        final SnapshotId expectedSnapshot = snapshotsByBroker.get(broker.getConfig().getCluster().getNodeId());
        assertThat(broker).havingSnapshot().withIndex(expectedSnapshot.getIndex()).withTerm(expectedSnapshot.getTerm());
    });
}
Also used : SnapshotId(io.camunda.zeebe.snapshots.SnapshotId) Test(org.junit.Test)

Aggregations

SnapshotId (io.camunda.zeebe.snapshots.SnapshotId)9 Test (org.junit.Test)9