Search in sources :

Example 21 with TestCluster

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

Example 22 with TestCluster

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);
}
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)

Example 23 with TestCluster

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);
}
Also used : TestCluster(io.aeron.test.cluster.TestCluster) AeronCluster(io.aeron.cluster.client.AeronCluster) InterruptAfter(io.aeron.test.InterruptAfter) ValueSource(org.junit.jupiter.params.provider.ValueSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 24 with TestCluster

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);
}
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)

Example 25 with TestCluster

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());
}
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)

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