use of io.aeron.test.cluster.TestNode in project Aeron by real-logic.
the class ClusterTest method shouldReplaySnapshotTakenWhileDown.
@Test
@InterruptAfter(40)
public void shouldReplaySnapshotTakenWhileDown() {
cluster = aCluster().withStaticNodes(3).start();
systemTestWatcher.cluster(cluster);
final TestNode leader = cluster.awaitLeader();
final List<TestNode> followers = cluster.followers();
final TestNode followerA = followers.get(0);
TestNode followerB = followers.get(1);
awaitElectionClosed(followerB);
cluster.stopNode(followerB);
cluster.takeSnapshot(leader);
cluster.awaitSnapshotCount(leader, 1);
cluster.awaitSnapshotCount(followerA, 1);
final int messageCount = 10;
cluster.connectClient();
cluster.sendMessages(messageCount);
cluster.awaitResponseMessageCount(messageCount);
followerB = cluster.startStaticNode(followerB.index(), false);
cluster.awaitSnapshotCount(followerB, 1);
assertEquals(FOLLOWER, followerB.role());
cluster.awaitServiceMessageCount(followerB, messageCount);
assertEquals(0L, followerB.errors());
}
use of io.aeron.test.cluster.TestNode in project Aeron by real-logic.
the class ClusterTest method shouldShutdownClusterAndRestartWithSnapshots.
@Test
@InterruptAfter(30)
public void shouldShutdownClusterAndRestartWithSnapshots() {
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.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);
cluster.awaitLeader();
assertEquals(2, cluster.followers().size());
cluster.awaitSnapshotsLoaded();
}
use of io.aeron.test.cluster.TestNode in project Aeron by real-logic.
the class ClusterTest method shouldNotifyClientOfNewLeader.
@Test
@InterruptAfter(40)
public void shouldNotifyClientOfNewLeader() {
cluster = aCluster().withStaticNodes(3).start();
systemTestWatcher.cluster(cluster);
final TestNode leader = cluster.awaitLeader();
cluster.connectClient();
cluster.awaitActiveSessionCount(cluster.followers().get(0), 1);
cluster.stopNode(leader);
cluster.awaitNewLeadershipEvent(1);
}
use of io.aeron.test.cluster.TestNode in project Aeron by real-logic.
the class ClusterTest method shouldCatchupFromEmptyLog.
@Test
@InterruptAfter(30)
public void shouldCatchupFromEmptyLog() {
cluster = aCluster().withStaticNodes(3).start();
systemTestWatcher.cluster(cluster);
cluster.awaitLeader();
final List<TestNode> followers = cluster.followers();
TestNode follower = followers.get(1);
awaitElectionClosed(follower);
cluster.stopNode(follower);
final int messageCount = 10;
cluster.connectClient();
cluster.sendMessages(messageCount);
cluster.awaitResponseMessageCount(messageCount);
follower = cluster.startStaticNode(follower.index(), true);
cluster.awaitServiceMessageCount(follower, messageCount);
}
use of io.aeron.test.cluster.TestNode in project Aeron by real-logic.
the class ClusterTest method shouldRecoverQuicklyAfterKillingFollowersThenRestartingOne.
@Test
@InterruptAfter(40)
public void shouldRecoverQuicklyAfterKillingFollowersThenRestartingOne() {
cluster = aCluster().withStaticNodes(3).start();
systemTestWatcher.cluster(cluster);
final TestNode leader = cluster.awaitLeader();
final List<TestNode> followers = cluster.followers();
final TestNode followerOne = followers.get(0);
final TestNode followerTwo = followers.get(1);
final int messageCount = 10;
cluster.connectClient();
cluster.sendMessages(messageCount);
cluster.awaitResponseMessageCount(messageCount);
cluster.stopNode(followerOne);
cluster.stopNode(followerTwo);
while (leader.role() == LEADER) {
cluster.sendMessages(1);
Tests.sleep(500);
}
cluster.startStaticNode(followerTwo.index(), true);
cluster.awaitLeader();
}
Aggregations