use of io.aeron.test.cluster.TestNode in project Aeron by real-logic.
the class ClusterTest method shouldRecoverWhenFollowerArrivesPartWayThroughTerm.
@Test
@InterruptAfter(40)
public void shouldRecoverWhenFollowerArrivesPartWayThroughTerm() {
cluster = aCluster().withStaticNodes(3).start();
systemTestWatcher.cluster(cluster);
cluster.awaitLeader();
final TestNode followerOne = cluster.followers().get(0);
final int messageCount = 10;
cluster.connectClient();
cluster.sendMessages(messageCount);
cluster.awaitResponseMessageCount(messageCount);
cluster.stopNode(followerOne);
cluster.sendMessages(messageCount);
cluster.awaitResponseMessageCount(messageCount * 2);
cluster.startStaticNode(followerOne.index(), false);
// Needs a little time to replay the transactions...
Tests.await(() -> cluster.node(followerOne.index()).service().messageCount() >= messageCount * 2);
assertEquals(messageCount * 2, cluster.node(followerOne.index()).service().messageCount());
}
use of io.aeron.test.cluster.TestNode in project Aeron by real-logic.
the class ClusterTest method shouldAbortClusterAndRestart.
@Test
@InterruptAfter(30)
public void shouldAbortClusterAndRestart() {
cluster = aCluster().withStaticNodes(3).start();
systemTestWatcher.cluster(cluster);
final TestNode leader = cluster.awaitLeader();
cluster.node(0).isTerminationExpected(true);
cluster.node(1).isTerminationExpected(true);
cluster.node(2).isTerminationExpected(true);
cluster.abortCluster(leader);
cluster.awaitNodeTerminations();
assertFalse(cluster.node(0).service().wasSnapshotTaken());
assertFalse(cluster.node(1).service().wasSnapshotTaken());
assertFalse(cluster.node(2).service().wasSnapshotTaken());
cluster.stopAllNodes();
cluster.restartAllNodes(false);
cluster.awaitLeader();
assertEquals(2, cluster.followers().size());
assertFalse(cluster.node(0).service().wasSnapshotLoaded());
assertFalse(cluster.node(1).service().wasSnapshotLoaded());
assertFalse(cluster.node(2).service().wasSnapshotLoaded());
}
use of io.aeron.test.cluster.TestNode in project Aeron by real-logic.
the class ClusterTest method shouldStopLeaderAndRestartAsFollowerWithSendingAfterThenStopLeader.
@Test
@InterruptAfter(60)
public void shouldStopLeaderAndRestartAsFollowerWithSendingAfterThenStopLeader() {
cluster = aCluster().withStaticNodes(3).start();
systemTestWatcher.cluster(cluster);
final TestNode originalLeader = cluster.awaitLeader();
cluster.stopNode(originalLeader);
cluster.awaitLeader(originalLeader.index());
final TestNode follower = cluster.startStaticNode(originalLeader.index(), false);
awaitElectionClosed(follower);
assertEquals(FOLLOWER, follower.role());
final int messageCount = 10;
cluster.connectClient();
cluster.sendMessages(messageCount);
cluster.awaitResponseMessageCount(messageCount);
final TestNode leader = cluster.awaitLeader();
cluster.stopNode(leader);
cluster.awaitLeader(leader.index());
}
use of io.aeron.test.cluster.TestNode in project Aeron by real-logic.
the class ClusterTest method shouldCatchUpAfterFollowerMissesMessage.
private void shouldCatchUpAfterFollowerMissesMessage(final String message) {
cluster = aCluster().withStaticNodes(3).start();
systemTestWatcher.cluster(cluster);
cluster.awaitLeader();
TestNode follower = cluster.followers().get(0);
cluster.stopNode(follower);
cluster.connectClient();
cluster.msgBuffer().putStringWithoutLengthAscii(0, message);
cluster.pollUntilMessageSent(message.length());
cluster.awaitResponseMessageCount(1);
follower = cluster.startStaticNode(follower.index(), false);
awaitElectionClosed(follower);
assertEquals(FOLLOWER, follower.role());
}
use of io.aeron.test.cluster.TestNode in project Aeron by real-logic.
the class ClusterTest method shouldAcceptMessagesAfterTwoNodeCleanRestart.
@Test
@InterruptAfter(30)
public void shouldAcceptMessagesAfterTwoNodeCleanRestart() {
cluster = aCluster().withStaticNodes(3).start();
systemTestWatcher.cluster(cluster);
cluster.awaitLeader();
final List<TestNode> followers = cluster.followers();
TestNode followerA = followers.get(0), followerB = followers.get(1);
awaitElectionClosed(followerA);
awaitElectionClosed(followerB);
cluster.stopNode(followerA);
cluster.stopNode(followerB);
followerA = cluster.startStaticNode(followerA.index(), true);
followerB = cluster.startStaticNode(followerB.index(), true);
awaitElectionClosed(followerA);
awaitElectionClosed(followerB);
assertEquals(FOLLOWER, followerA.role());
assertEquals(FOLLOWER, followerB.role());
final int messageCount = 10;
cluster.connectClient();
cluster.sendMessages(messageCount);
cluster.awaitResponseMessageCount(messageCount);
cluster.awaitServiceMessageCount(followerA, messageCount);
cluster.awaitServiceMessageCount(followerB, messageCount);
}
Aggregations