use of io.aeron.test.cluster.TestCluster in project aeron by real-logic.
the class FailedFirstElectionClusterTest method shouldRecoverWhenFollowerIsMultipleTermsBehindFromEmptyLog.
@Test
@EnabledForJreRange(min = JRE.JAVA_11)
@InterruptAfter(60)
public void shouldRecoverWhenFollowerIsMultipleTermsBehindFromEmptyLog() {
final int numNodes = 3;
final int messageCount = 10;
final int numTerms = 3;
final TestCluster cluster = aCluster().withStaticNodes(numNodes).start(2);
systemTestWatcher.cluster(cluster);
systemTestWatcher.ignoreErrorsMatching((s) -> s.contains("Forced failure"));
int totalMessages = 0;
for (int i = 0; i < numTerms; i++) {
final TestNode oldLeader = cluster.awaitLeader();
cluster.connectClient();
cluster.sendMessages(messageCount);
totalMessages += messageCount;
cluster.awaitResponseMessageCount(totalMessages);
cluster.stopNode(oldLeader);
cluster.startStaticNode(oldLeader.index(), false);
cluster.awaitLeader();
}
cluster.startStaticNode(2, true);
cluster.connectClient();
cluster.sendMessages(messageCount);
totalMessages += messageCount;
cluster.awaitResponseMessageCount(totalMessages);
cluster.awaitServicesMessageCount(totalMessages);
cluster.assertRecordingLogsEqual();
}
use of io.aeron.test.cluster.TestCluster in project aeron by real-logic.
the class MultiNodeTest method shouldCatchUpWithAppointedLeaderWithThreeNodesWithNoSnapshot.
@Test
@InterruptAfter(20)
public void shouldCatchUpWithAppointedLeaderWithThreeNodesWithNoSnapshot() {
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 preCatchupMessageCount = 5;
final int postCatchupMessageCount = 10;
final int totalMessageCount = preCatchupMessageCount + postCatchupMessageCount;
cluster.connectClient();
cluster.sendMessages(preCatchupMessageCount);
cluster.awaitResponseMessageCount(preCatchupMessageCount);
cluster.awaitServicesMessageCount(preCatchupMessageCount);
cluster.stopNode(cluster.node(0));
cluster.sendMessages(postCatchupMessageCount);
cluster.awaitResponseMessageCount(totalMessageCount);
cluster.awaitServicesMessageCount(totalMessageCount);
cluster.stopAllNodes();
cluster.restartAllNodes(false);
cluster.awaitLeader();
cluster.awaitServicesMessageCount(totalMessageCount);
}
use of io.aeron.test.cluster.TestCluster in project aeron by real-logic.
the class MultiNodeTest method shouldConnectClientUsingResolvedResponsePort.
@ParameterizedTest
@ValueSource(strings = { "9020", "0" })
@InterruptAfter(20)
void shouldConnectClientUsingResolvedResponsePort(final String responsePort) {
final AeronCluster.Context clientCtx = new AeronCluster.Context().ingressChannel("aeron:udp?term-length=64k").egressChannel("aeron:udp?term-length=64k|endpoint=localhost:" + responsePort);
final TestCluster cluster = aCluster().withStaticNodes(3).start();
systemTestWatcher.cluster(cluster);
final int numMessages = 10;
cluster.connectClient(clientCtx);
cluster.sendMessages(numMessages);
cluster.awaitResponseMessageCount(numMessages);
}
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