use of io.aeron.test.cluster.TestCluster in project Aeron by real-logic.
the class ClusterBackupTest method shouldBackupClusterAfterCleanShutdown.
@Test
@InterruptAfter(30)
public void shouldBackupClusterAfterCleanShutdown() {
final TestCluster cluster = aCluster().withStaticNodes(3).start();
systemTestWatcher.cluster(cluster);
final TestNode leader = cluster.awaitLeader();
final int messageCount = 10;
cluster.connectClient();
cluster.sendMessages(messageCount);
cluster.awaitResponseMessageCount(messageCount);
cluster.awaitServicesMessageCount(messageCount);
cluster.node(0).isTerminationExpected(true);
cluster.node(1).isTerminationExpected(true);
cluster.node(2).isTerminationExpected(true);
cluster.shutdownCluster(leader);
cluster.awaitNodeTerminations();
assertTrue(cluster.node(0).service().wasSnapshotTaken());
assertTrue(cluster.node(1).service().wasSnapshotTaken());
assertTrue(cluster.node(2).service().wasSnapshotTaken());
cluster.stopAllNodes();
cluster.restartAllNodes(false);
final TestNode newLeader = cluster.awaitLeader();
final long logPosition = newLeader.service().cluster().logPosition();
cluster.startClusterBackupNode(true);
cluster.awaitBackupState(ClusterBackup.State.BACKING_UP);
cluster.awaitBackupLiveLogPosition(logPosition);
}
use of io.aeron.test.cluster.TestCluster in project Aeron by real-logic.
the class ClusterToolTest method shouldNotSnapshotWhenSuspendedOnly.
@Test
@InterruptAfter(30)
void shouldNotSnapshotWhenSuspendedOnly() {
final TestCluster cluster = aCluster().withStaticNodes(3).start();
systemTestWatcher.cluster(cluster);
final TestNode leader = cluster.awaitLeader();
final long initialSnapshotCount = leader.consensusModule().context().snapshotCounter().get();
final CapturingPrintStream capturingPrintStream = new CapturingPrintStream();
assertTrue(ClusterTool.suspend(leader.consensusModule().context().clusterDir(), capturingPrintStream.resetAndGetPrintStream()));
assertThat(capturingPrintStream.flushAndGetContent(), containsString("SUSPEND applied successfully"));
assertFalse(ClusterTool.snapshot(leader.consensusModule().context().clusterDir(), capturingPrintStream.resetAndGetPrintStream()));
final String expectedMessage = "Unable to SNAPSHOT as the state of the consensus module is SUSPENDED, but needs to be ACTIVE";
assertThat(capturingPrintStream.flushAndGetContent(), containsString(expectedMessage));
assertEquals(initialSnapshotCount, leader.consensusModule().context().snapshotCounter().get());
}
use of io.aeron.test.cluster.TestCluster in project Aeron by real-logic.
the class MultiNodeTest method shouldElectAppointedLeaderWithThreeNodesWithNoReplayNoSnapshot.
@Test
@InterruptAfter(20)
public void shouldElectAppointedLeaderWithThreeNodesWithNoReplayNoSnapshot() {
final int appointedLeaderIndex = 1;
final TestCluster cluster = aCluster().withStaticNodes(3).withAppointedLeader(appointedLeaderIndex).start();
systemTestWatcher.cluster(cluster);
final TestNode leader = cluster.awaitLeader();
assertEquals(appointedLeaderIndex, leader.index());
assertEquals(Cluster.Role.LEADER, leader.role());
assertEquals(Cluster.Role.FOLLOWER, cluster.node(0).role());
assertEquals(Cluster.Role.FOLLOWER, cluster.node(2).role());
}
use of io.aeron.test.cluster.TestCluster in project Aeron by real-logic.
the class MultiNodeTest method shouldReplayWithAppointedLeaderWithThreeNodesWithNoSnapshot.
@Test
@InterruptAfter(20)
public void shouldReplayWithAppointedLeaderWithThreeNodesWithNoSnapshot() {
final int appointedLeaderIndex = 1;
final TestCluster cluster = aCluster().withStaticNodes(3).withAppointedLeader(appointedLeaderIndex).start();
systemTestWatcher.cluster(cluster);
final TestNode leader = cluster.awaitLeader();
assertEquals(appointedLeaderIndex, leader.index());
assertEquals(Cluster.Role.LEADER, leader.role());
final int messageCount = 10;
cluster.connectClient();
cluster.sendMessages(messageCount);
cluster.awaitResponseMessageCount(messageCount);
cluster.awaitServicesMessageCount(messageCount);
cluster.stopAllNodes();
cluster.restartAllNodes(false);
cluster.awaitLeader();
cluster.awaitServicesMessageCount(messageCount);
}
use of io.aeron.test.cluster.TestCluster in project Aeron by real-logic.
the class AppointedLeaderTest method shouldConnectAndSendKeepAlive.
@Test
@InterruptAfter(20)
public void shouldConnectAndSendKeepAlive() {
final TestCluster cluster = aCluster().withStaticNodes(3).withAppointedLeader(LEADER_ID).start();
systemTestWatcher.cluster(cluster);
final TestNode leader = cluster.awaitLeader();
assertEquals(LEADER_ID, leader.index());
assertEquals(Cluster.Role.LEADER, leader.role());
cluster.connectClient();
assertTrue(cluster.client().sendKeepAlive());
}
Aggregations