use of io.aeron.test.cluster.TestNode in project aeron by real-logic.
the class ClusterTest method shouldCatchUpTwoFreshNodesAfterRestart.
@Test
@InterruptAfter(30)
public void shouldCatchUpTwoFreshNodesAfterRestart() {
cluster = aCluster().withStaticNodes(3).start();
systemTestWatcher.cluster(cluster);
final TestNode leader = cluster.awaitLeader();
final List<TestNode> followers = cluster.followers();
final int messageCount = 50_000;
cluster.connectClient();
cluster.msgBuffer().putStringWithoutLengthAscii(0, NO_OP_MSG);
for (int i = 0; i < messageCount; i++) {
cluster.pollUntilMessageSent(NO_OP_MSG.length());
}
cluster.awaitResponseMessageCount(messageCount);
cluster.terminationsExpected(true);
cluster.abortCluster(leader);
cluster.awaitNodeTerminations();
cluster.stopAllNodes();
final TestNode oldLeader = cluster.startStaticNode(leader.index(), false);
final TestNode oldFollower1 = cluster.startStaticNode(followers.get(0).index(), true);
final TestNode oldFollower2 = cluster.startStaticNode(followers.get(1).index(), true);
cluster.awaitLeader();
cluster.awaitServicesMessageCount(messageCount);
assertEquals(0L, oldLeader.errors());
assertEquals(0L, oldFollower1.errors());
assertEquals(0L, oldFollower2.errors());
}
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 DynamicMembershipTest method shouldDynamicallyJoinClusterOfThreeNoSnapshotsThenSend.
@Test
@InterruptAfter(30)
public void shouldDynamicallyJoinClusterOfThreeNoSnapshotsThenSend(final TestInfo testInfo) {
cluster = aCluster().withStaticNodes(3).withDynamicNodes(1).start();
systemTestWatcher.cluster(cluster);
final TestNode leader = cluster.awaitLeader();
final TestNode dynamicMember = cluster.startDynamicNode(3, true);
awaitElectionClosed(dynamicMember);
assertEquals(FOLLOWER, dynamicMember.role());
final int messageCount = 10;
cluster.connectClient();
cluster.sendMessages(messageCount);
cluster.awaitResponseMessageCount(messageCount);
cluster.awaitServiceMessageCount(leader, messageCount);
cluster.awaitServiceMessageCount(dynamicMember, messageCount);
}
use of io.aeron.test.cluster.TestNode in project aeron by real-logic.
the class DynamicMembershipTest method shouldRemoveLeaderAfterDynamicNodeJoinedThenRestartCluster.
@Test
@InterruptAfter(30)
public void shouldRemoveLeaderAfterDynamicNodeJoinedThenRestartCluster(final TestInfo testInfo) {
cluster = aCluster().withStaticNodes(3).withDynamicNodes(1).start();
systemTestWatcher.cluster(cluster);
final TestNode initialLeader = cluster.awaitLeader();
final TestNode dynamicMember = cluster.startDynamicNode(3, true);
awaitElectionClosed(dynamicMember);
awaitMembershipSize(initialLeader, 4);
final int initialLeaderIndex = initialLeader.index();
initialLeader.isTerminationExpected(true);
initialLeader.removeMember(initialLeaderIndex, false);
cluster.awaitNodeTermination(initialLeader);
cluster.stopNode(initialLeader);
final TestNode newLeader = cluster.awaitLeader(initialLeaderIndex);
final ClusterMembership clusterMembership = awaitMembershipSize(newLeader, 3);
assertEquals(newLeader.index(), clusterMembership.leaderMemberId);
assertNotEquals(initialLeaderIndex, clusterMembership.leaderMemberId);
cluster.stopAllNodes();
for (int i = 0; i < 3; i++) {
if (initialLeaderIndex != i) {
cluster.startStaticNode(i, false);
}
}
cluster.awaitLeader();
assertEquals(1, cluster.followers().size());
awaitElectionClosed(cluster.followers().get(0));
}
use of io.aeron.test.cluster.TestNode in project aeron by real-logic.
the class DynamicMembershipTest method shouldJoinDynamicNodeToSingleStaticLeader.
@Test
@InterruptAfter(30)
public void shouldJoinDynamicNodeToSingleStaticLeader(final TestInfo testInfo) {
cluster = aCluster().withStaticNodes(1).withDynamicNodes(1).start();
systemTestWatcher.cluster(cluster);
final TestNode initialLeader = cluster.awaitLeader();
final TestNode dynamicMember = cluster.startDynamicNode(1, true);
awaitElectionClosed(dynamicMember);
awaitMembershipSize(initialLeader, 2);
}
Aggregations