use of io.aeron.test.cluster.TestNode in project Aeron by real-logic.
the class ClusterToolTest method shouldNotSnapshotWhenSuspendedOnly.
@Test
@InterruptAfter(30)
void shouldNotSnapshotWhenSuspendedOnly() {
final TestCluster cluster = aCluster().withStaticNodes(3).start();
systemTestWatcher.cluster(cluster);
final TestNode leader = cluster.awaitLeader();
final long initialSnapshotCount = leader.consensusModule().context().snapshotCounter().get();
final CapturingPrintStream capturingPrintStream = new CapturingPrintStream();
assertTrue(ClusterTool.suspend(leader.consensusModule().context().clusterDir(), capturingPrintStream.resetAndGetPrintStream()));
assertThat(capturingPrintStream.flushAndGetContent(), containsString("SUSPEND applied successfully"));
assertFalse(ClusterTool.snapshot(leader.consensusModule().context().clusterDir(), capturingPrintStream.resetAndGetPrintStream()));
final String expectedMessage = "Unable to SNAPSHOT as the state of the consensus module is SUSPENDED, but needs to be ACTIVE";
assertThat(capturingPrintStream.flushAndGetContent(), containsString(expectedMessage));
assertEquals(initialSnapshotCount, leader.consensusModule().context().snapshotCounter().get());
}
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);
}
use of io.aeron.test.cluster.TestNode in project Aeron by real-logic.
the class DynamicMembershipTest method shouldDynamicallyJoinClusterOfThreeWithSnapshot.
@Test
@InterruptAfter(30)
public void shouldDynamicallyJoinClusterOfThreeWithSnapshot(final TestInfo testInfo) {
cluster = aCluster().withStaticNodes(3).withDynamicNodes(1).start();
systemTestWatcher.cluster(cluster);
final TestNode leader = cluster.awaitLeader();
final int messageCount = 10;
cluster.connectClient();
cluster.sendMessages(messageCount);
cluster.awaitResponseMessageCount(messageCount);
cluster.takeSnapshot(leader);
cluster.awaitSnapshotCount(1);
final TestNode dynamicMember = cluster.startDynamicNode(3, true);
awaitElectionClosed(dynamicMember);
assertEquals(FOLLOWER, dynamicMember.role());
cluster.awaitSnapshotLoadedForService(dynamicMember);
assertEquals(messageCount, dynamicMember.service().messageCount());
}
use of io.aeron.test.cluster.TestNode in project Aeron by real-logic.
the class ClusterTest method shouldRecoverWhenFollowersIsMultipleTermsBehindFromEmptyLogAndPartialLogWithoutCommittedLogEntry.
@Test
@InterruptAfter(40)
public void shouldRecoverWhenFollowersIsMultipleTermsBehindFromEmptyLogAndPartialLogWithoutCommittedLogEntry() {
cluster = aCluster().withStaticNodes(5).start(4);
systemTestWatcher.cluster(cluster);
final int messageCount = 10;
final int numTerms = 3;
int totalMessages = 0;
int partialNode = Aeron.NULL_VALUE;
for (int i = 0; i < numTerms; i++) {
final TestNode oldLeader = cluster.awaitLeader();
cluster.connectClient();
cluster.sendMessages(messageCount);
totalMessages += messageCount;
cluster.awaitResponseMessageCount(totalMessages);
if (Aeron.NULL_VALUE == partialNode) {
partialNode = (oldLeader.index() + 1) % 4;
cluster.stopNode(cluster.node(partialNode));
}
cluster.stopNode(oldLeader);
cluster.startStaticNode(oldLeader.index(), false);
cluster.awaitLeader();
}
final TestNode lateJoiningNode = cluster.startStaticNode(4, true);
cluster.awaitServiceMessageCount(lateJoiningNode, totalMessages);
final TestNode node = cluster.startStaticNode(partialNode, false);
cluster.awaitServiceMessageCount(node, totalMessages);
cluster.awaitLeader();
cluster.connectClient();
cluster.sendMessages(messageCount);
totalMessages += messageCount;
cluster.awaitResponseMessageCount(totalMessages);
cluster.awaitServiceMessageCount(node, totalMessages);
cluster.assertRecordingLogsEqual();
}
use of io.aeron.test.cluster.TestNode in project Aeron by real-logic.
the class ClusterTest method shouldTolerateMultipleLeaderFailures.
@Test
@InterruptAfter(50)
public void shouldTolerateMultipleLeaderFailures() {
cluster = aCluster().withStaticNodes(3).start();
systemTestWatcher.cluster(cluster);
final TestNode firstLeader = cluster.awaitLeader();
cluster.stopNode(firstLeader);
final TestNode secondLeader = cluster.awaitLeader();
final long commitPos = secondLeader.commitPosition();
final TestNode newFollower = cluster.startStaticNode(firstLeader.index(), false);
cluster.awaitCommitPosition(newFollower, commitPos);
awaitElectionClosed(newFollower);
cluster.stopNode(secondLeader);
cluster.awaitLeader();
final int messageCount = 10;
cluster.connectClient();
cluster.sendMessages(messageCount);
cluster.awaitResponseMessageCount(messageCount);
}
Aggregations