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