use of io.aeron.test.cluster.TestCluster in project Aeron by real-logic.
the class ServiceIpcIngressTest method shouldEchoIpcMessages.
@Test
@InterruptAfter(20)
public void shouldEchoIpcMessages() {
final TestCluster cluster = aCluster().withStaticNodes(3).start();
systemTestWatcher.cluster(cluster);
cluster.awaitLeader();
cluster.connectClient();
final int messageCount = 10;
for (int i = 0; i < messageCount; i++) {
cluster.msgBuffer().putStringWithoutLengthAscii(0, ClusterTests.ECHO_IPC_INGRESS_MSG);
cluster.pollUntilMessageSent(ClusterTests.ECHO_IPC_INGRESS_MSG.length());
}
cluster.awaitResponseMessageCount(messageCount);
cluster.awaitServicesMessageCount(messageCount);
}
use of io.aeron.test.cluster.TestCluster in project Aeron by real-logic.
the class SingleNodeTest method shouldSendMessagesToCluster.
@ParameterizedTest
@ValueSource(booleans = { false, true })
@InterruptAfter(20)
public void shouldSendMessagesToCluster(final boolean preTouch) {
System.setProperty(PRE_TOUCH_MAPPED_MEMORY_PROP_NAME, Boolean.toString(preTouch));
try {
final TestCluster cluster = aCluster().withStaticNodes(1).start();
systemTestWatcher.cluster(cluster);
final TestNode leader = cluster.awaitLeader();
assertEquals(0, leader.index());
assertEquals(Cluster.Role.LEADER, leader.role());
cluster.connectClient();
cluster.sendMessages(10);
cluster.awaitResponseMessageCount(10);
cluster.awaitServiceMessageCount(leader, 10);
} finally {
System.clearProperty(PRE_TOUCH_MAPPED_MEMORY_PROP_NAME);
}
}
use of io.aeron.test.cluster.TestCluster in project aeron by real-logic.
the class ClusterBackupTest method shouldBackupClusterWithSnapshotThenSend.
@Test
@InterruptAfter(30)
public void shouldBackupClusterWithSnapshotThenSend() {
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.startClusterBackupNode(true);
cluster.sendMessages(postSnapshotMessageCount);
cluster.awaitResponseMessageCount(totalMessageCount);
cluster.awaitServiceMessageCount(leader, totalMessageCount);
final long logPosition = leader.service().cluster().logPosition();
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 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 shouldBackupClusterAfterCleanShutdown.
@Test
@InterruptAfter(30)
public void shouldBackupClusterAfterCleanShutdown() {
final TestCluster cluster = aCluster().withStaticNodes(3).start();
systemTestWatcher.cluster(cluster);
final TestNode leader = cluster.awaitLeader();
final int messageCount = 10;
cluster.connectClient();
cluster.sendMessages(messageCount);
cluster.awaitResponseMessageCount(messageCount);
cluster.awaitServicesMessageCount(messageCount);
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);
final TestNode newLeader = cluster.awaitLeader();
final long logPosition = newLeader.service().cluster().logPosition();
cluster.startClusterBackupNode(true);
cluster.awaitBackupState(ClusterBackup.State.BACKING_UP);
cluster.awaitBackupLiveLogPosition(logPosition);
}
Aggregations