use of io.aeron.test.InterruptAfter 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.InterruptAfter 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.InterruptAfter in project Aeron by real-logic.
the class DynamicMembershipTest method shouldDynamicallyJoinClusterOfThreeWithEmptySnapshot.
@Test
@InterruptAfter(30)
public void shouldDynamicallyJoinClusterOfThreeWithEmptySnapshot(final TestInfo testInfo) {
cluster = aCluster().withStaticNodes(3).withDynamicNodes(1).start();
systemTestWatcher.cluster(cluster);
final TestNode leader = cluster.awaitLeader();
cluster.takeSnapshot(leader);
cluster.awaitSnapshotCount(1);
final TestNode dynamicMember = cluster.startDynamicNode(3, true);
awaitElectionClosed(dynamicMember);
assertEquals(FOLLOWER, dynamicMember.role());
cluster.awaitSnapshotLoadedForService(dynamicMember);
}
use of io.aeron.test.InterruptAfter in project Aeron by real-logic.
the class DynamicMembershipTest method shouldRemoveFollower.
@Test
@InterruptAfter(30)
public void shouldRemoveFollower(final TestInfo testInfo) {
cluster = aCluster().withStaticNodes(3).start();
systemTestWatcher.cluster(cluster);
final TestNode leader = cluster.awaitLeader();
final TestNode follower = cluster.followers().get(0);
follower.isTerminationExpected(true);
leader.removeMember(follower.index(), false);
cluster.awaitNodeTermination(follower);
cluster.stopNode(follower);
final ClusterMembership clusterMembership = awaitMembershipSize(leader, 2);
assertEquals(leader.index(), clusterMembership.leaderMemberId);
}
use of io.aeron.test.InterruptAfter in project Aeron by real-logic.
the class DynamicMembershipTest method shouldDynamicallyJoinClusterOfThreeNoSnapshots.
@Test
@InterruptAfter(30)
public void shouldDynamicallyJoinClusterOfThreeNoSnapshots(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 ClusterMembership clusterMembership = awaitMembershipSize(leader, 4);
assertEquals(leader.index(), clusterMembership.leaderMemberId);
assertEquals("", clusterMembership.passiveMembersStr);
}
Aggregations