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 RacingCatchupClusterTest method shouldCatchupIfLogPositionMovesForwardBeforeFollowersCommitPositionWhenCatchingUpNodeIsOnlyFollower.
@Test
@InterruptAfter(40)
@Disabled
public void shouldCatchupIfLogPositionMovesForwardBeforeFollowersCommitPositionWhenCatchingUpNodeIsOnlyFollower() {
final TestCluster cluster = aCluster().withStaticNodes(3).start();
systemTestWatcher.cluster(cluster);
final int messageCount = 10;
int totalMessages = 0;
final TestNode oldLeader = cluster.awaitLeader();
cluster.connectClient();
cluster.sendMessages(messageCount);
totalMessages += messageCount;
cluster.awaitResponseMessageCount(totalMessages);
cluster.awaitServicesMessageCount(totalMessages);
cluster.stopNode(oldLeader);
final TestNode newLeader = cluster.awaitLeader();
final List<TestNode> followers = cluster.followers();
cluster.connectClient();
for (final TestNode follower : followers) {
cluster.stopNode(follower);
}
Tests.sleep(1);
cluster.sendMessages(messageCount);
totalMessages += messageCount;
cluster.startStaticNode(followers.get(0).index(), false);
tag();
cluster.sendMessages(messageCount);
totalMessages += messageCount;
tag();
cluster.awaitResponseMessageCount(totalMessages);
}
use of io.aeron.test.cluster.TestCluster in project Aeron by real-logic.
the class ClusterBackupTest method shouldBackupClusterNoSnapshotsAndEmptyLog.
@Test
@InterruptAfter(30)
public void shouldBackupClusterNoSnapshotsAndEmptyLog() {
final TestCluster cluster = aCluster().withStaticNodes(3).start();
systemTestWatcher.cluster(cluster);
cluster.awaitLeader();
cluster.startClusterBackupNode(true);
cluster.awaitBackupState(ClusterBackup.State.BACKING_UP);
cluster.awaitBackupLiveLogPosition(cluster.findLeader().service().cluster().logPosition());
cluster.stopAllNodes();
final TestNode node = cluster.startStaticNodeFromBackup();
cluster.awaitLeader();
assertEquals(0, node.service().messageCount());
assertFalse(node.service().wasSnapshotLoaded());
}
use of io.aeron.test.cluster.TestCluster in project Aeron by real-logic.
the class ClusterBackupTest method shouldBackupClusterWithSnapshotAndNonEmptyLog.
@Test
@InterruptAfter(30)
public void shouldBackupClusterWithSnapshotAndNonEmptyLog() {
final TestCluster cluster = aCluster().withStaticNodes(3).start();
systemTestWatcher.cluster(cluster);
final TestNode leader = cluster.awaitLeader();
final int preSnapshotMessageCount = 10;
final int postSnapshotMessageCount = 7;
final int totalMessageCount = preSnapshotMessageCount + postSnapshotMessageCount;
cluster.connectClient();
cluster.sendMessages(preSnapshotMessageCount);
cluster.awaitResponseMessageCount(preSnapshotMessageCount);
cluster.awaitServicesMessageCount(preSnapshotMessageCount);
cluster.takeSnapshot(leader);
cluster.awaitSnapshotCount(1);
cluster.sendMessages(postSnapshotMessageCount);
cluster.awaitResponseMessageCount(totalMessageCount);
cluster.awaitServiceMessageCount(leader, totalMessageCount);
final long logPosition = leader.service().cluster().logPosition();
cluster.startClusterBackupNode(true);
cluster.awaitBackupState(ClusterBackup.State.BACKING_UP);
cluster.awaitBackupLiveLogPosition(logPosition);
cluster.stopAllNodes();
final TestNode node = cluster.startStaticNodeFromBackup();
cluster.awaitLeader();
cluster.awaitServiceMessageCount(node, totalMessageCount);
assertEquals(totalMessageCount, node.service().messageCount());
assertTrue(node.service().wasSnapshotLoaded());
}
use of io.aeron.test.cluster.TestCluster in project Aeron by real-logic.
the class ClusterBackupTest method shouldBackupClusterNoSnapshotsAndNonEmptyLogAfterFailure.
@Test
@InterruptAfter(40)
public void shouldBackupClusterNoSnapshotsAndNonEmptyLogAfterFailure() {
final TestCluster cluster = aCluster().withStaticNodes(3).start();
systemTestWatcher.cluster(cluster);
final TestNode leaderOne = cluster.awaitLeader();
final int messageCount = 10;
cluster.connectClient();
cluster.sendMessages(messageCount);
cluster.awaitResponseMessageCount(messageCount);
cluster.awaitServicesMessageCount(messageCount);
cluster.stopNode(leaderOne);
final TestNode leaderTwo = cluster.awaitLeader();
final long logPosition = leaderTwo.service().cluster().logPosition();
cluster.startClusterBackupNode(true);
cluster.awaitBackupState(ClusterBackup.State.BACKING_UP);
cluster.awaitBackupLiveLogPosition(logPosition);
cluster.stopAllNodes();
final TestNode node = cluster.startStaticNodeFromBackup();
cluster.awaitLeader();
assertEquals(messageCount, node.service().messageCount());
assertFalse(node.service().wasSnapshotLoaded());
}
Aggregations