Search in sources :

Example 26 with TestCluster

use of io.aeron.test.cluster.TestCluster in project aeron by real-logic.

the class AppointedLeaderTest method shouldEchoMessagesViaService.

@Test
@InterruptAfter(20)
public void shouldEchoMessagesViaService() {
    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();
    final int messageCount = 10;
    cluster.sendMessages(messageCount);
    cluster.awaitResponseMessageCount(messageCount);
    cluster.awaitServicesMessageCount(messageCount);
}
Also used : TestCluster(io.aeron.test.cluster.TestCluster) TestNode(io.aeron.test.cluster.TestNode) Test(org.junit.jupiter.api.Test) InterruptAfter(io.aeron.test.InterruptAfter)

Example 27 with TestCluster

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);
}
Also used : TestCluster(io.aeron.test.cluster.TestCluster) Test(org.junit.jupiter.api.Test) InterruptAfter(io.aeron.test.InterruptAfter)

Example 28 with TestCluster

use of io.aeron.test.cluster.TestCluster in project aeron by real-logic.

the class StalledLeaderLogReplicationClusterTest method shouldHandleMultipleElections.

@Test
@InterruptAfter(60)
void shouldHandleMultipleElections() {
    final TestCluster cluster = aCluster().withStaticNodes(3).start();
    systemTestWatcher.cluster(cluster);
    final TestNode leader0 = cluster.awaitLeader();
    final int numMessages = 3;
    cluster.connectClient();
    cluster.sendMessages(numMessages);
    cluster.awaitResponseMessageCount(numMessages);
    cluster.awaitServicesMessageCount(numMessages);
    cluster.stopNode(leader0);
    final TestNode leader1 = cluster.awaitLeader(leader0.index());
    cluster.awaitNewLeadershipEvent(1);
    awaitAvailableWindow(cluster.client().ingressPublication());
    assertTrue(cluster.client().sendKeepAlive());
    cluster.startStaticNode(leader0.index(), false);
    awaitElectionClosed(cluster.node(leader0.index()));
    cluster.sendMessages(numMessages);
    cluster.awaitResponseMessageCount(numMessages * 2);
    cluster.awaitServicesMessageCount(numMessages * 2);
    cluster.stopNode(leader1);
    cluster.awaitLeader(leader1.index());
    cluster.awaitNewLeadershipEvent(2);
    awaitAvailableWindow(cluster.client().ingressPublication());
    assertTrue(cluster.client().sendKeepAlive());
    cluster.startStaticNode(leader1.index(), false);
    awaitElectionClosed(cluster.node(leader1.index()));
    cluster.sendMessages(numMessages);
    cluster.awaitResponseMessageCount(numMessages * 3);
    cluster.awaitServicesMessageCount(numMessages * 3);
}
Also used : TestCluster(io.aeron.test.cluster.TestCluster) TestNode(io.aeron.test.cluster.TestNode) SlowTest(io.aeron.test.SlowTest) Test(org.junit.jupiter.api.Test) InterruptAfter(io.aeron.test.InterruptAfter)

Example 29 with TestCluster

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);
}
Also used : TestCluster(io.aeron.test.cluster.TestCluster) TestNode(io.aeron.test.cluster.TestNode) Test(org.junit.jupiter.api.Test) Disabled(org.junit.jupiter.api.Disabled)

Example 30 with TestCluster

use of io.aeron.test.cluster.TestCluster in project Aeron by real-logic.

the class SingleNodeTest method shouldReplayLog.

@Test
@InterruptAfter(20)
public void shouldReplayLog() {
    final TestCluster cluster = aCluster().withStaticNodes(1).start();
    systemTestWatcher.cluster(cluster);
    final TestNode leader = cluster.awaitLeader();
    final int messageCount = 10;
    cluster.connectClient();
    cluster.sendMessages(messageCount);
    cluster.awaitResponseMessageCount(messageCount);
    cluster.awaitServiceMessageCount(leader, messageCount);
    cluster.stopNode(leader);
    cluster.startStaticNode(0, false);
    final TestNode newLeader = cluster.awaitLeader();
    cluster.awaitServiceMessageCount(newLeader, messageCount);
}
Also used : TestCluster(io.aeron.test.cluster.TestCluster) TestNode(io.aeron.test.cluster.TestNode) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) InterruptAfter(io.aeron.test.InterruptAfter)

Aggregations

TestCluster (io.aeron.test.cluster.TestCluster)54 InterruptAfter (io.aeron.test.InterruptAfter)52 Test (org.junit.jupiter.api.Test)50 TestNode (io.aeron.test.cluster.TestNode)48 SlowTest (io.aeron.test.SlowTest)32 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)14 AeronCluster (io.aeron.cluster.client.AeronCluster)4 TestBackupNode (io.aeron.test.cluster.TestBackupNode)4 ValueSource (org.junit.jupiter.params.provider.ValueSource)4 Matchers.containsString (org.hamcrest.Matchers.containsString)2 Disabled (org.junit.jupiter.api.Disabled)2 EnabledForJreRange (org.junit.jupiter.api.condition.EnabledForJreRange)2