Search in sources :

Example 66 with TestNode

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

the class DynamicMembershipTest method shouldDynamicallyJoinClusterOfThreeNoSnapshotsWithCatchup.

@Test
@InterruptAfter(30)
public void shouldDynamicallyJoinClusterOfThreeNoSnapshotsWithCatchup(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.awaitServiceMessageCount(leader, messageCount);
    final TestNode dynamicMember = cluster.startDynamicNode(3, true);
    cluster.awaitServiceMessageCount(dynamicMember, messageCount);
}
Also used : TestNode(io.aeron.test.cluster.TestNode) Test(org.junit.jupiter.api.Test) SlowTest(io.aeron.test.SlowTest) InterruptAfter(io.aeron.test.InterruptAfter)

Example 67 with TestNode

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

the class DynamicMembershipTest method shouldDynamicallyJoinClusterOfThreeWithSnapshotThenSend.

@Test
@InterruptAfter(30)
public void shouldDynamicallyJoinClusterOfThreeWithSnapshotThenSend(final TestInfo testInfo) {
    cluster = aCluster().withStaticNodes(3).withDynamicNodes(1).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.takeSnapshot(leader);
    cluster.awaitSnapshotCount(1);
    assertTrue(cluster.client().sendKeepAlive());
    final TestNode dynamicMember = cluster.startDynamicNode(3, true);
    assertTrue(cluster.client().sendKeepAlive());
    awaitElectionClosed(dynamicMember);
    assertEquals(FOLLOWER, dynamicMember.role());
    cluster.awaitSnapshotLoadedForService(dynamicMember);
    assertEquals(preSnapshotMessageCount, dynamicMember.service().messageCount());
    cluster.sendMessages(postSnapshotMessageCount);
    cluster.awaitResponseMessageCount(totalMessageCount);
    cluster.awaitServiceMessageCount(dynamicMember, totalMessageCount);
}
Also used : TestNode(io.aeron.test.cluster.TestNode) Test(org.junit.jupiter.api.Test) SlowTest(io.aeron.test.SlowTest) InterruptAfter(io.aeron.test.InterruptAfter)

Example 68 with TestNode

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

the class DynamicMembershipTest method shouldDynamicallyJoinClusterOfThreeNoSnapshots.

@Test
@InterruptAfter(30)
public void shouldDynamicallyJoinClusterOfThreeNoSnapshots(final TestInfo testInfo) {
    cluster = aCluster().withStaticNodes(3).withDynamicNodes(1).start();
    systemTestWatcher.cluster(cluster);
    final TestNode leader = cluster.awaitLeader();
    final TestNode dynamicMember = cluster.startDynamicNode(3, true);
    awaitElectionClosed(dynamicMember);
    assertEquals(FOLLOWER, dynamicMember.role());
    final ClusterMembership clusterMembership = awaitMembershipSize(leader, 4);
    assertEquals(leader.index(), clusterMembership.leaderMemberId);
    assertEquals("", clusterMembership.passiveMembersStr);
}
Also used : TestNode(io.aeron.test.cluster.TestNode) Test(org.junit.jupiter.api.Test) SlowTest(io.aeron.test.SlowTest) InterruptAfter(io.aeron.test.InterruptAfter)

Example 69 with TestNode

use of io.aeron.test.cluster.TestNode 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 70 with TestNode

use of io.aeron.test.cluster.TestNode 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)

Aggregations

TestNode (io.aeron.test.cluster.TestNode)166 Test (org.junit.jupiter.api.Test)162 InterruptAfter (io.aeron.test.InterruptAfter)72 SlowTest (io.aeron.test.SlowTest)56 TestCluster (io.aeron.test.cluster.TestCluster)50 AeronCluster (io.aeron.cluster.client.AeronCluster)12 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)12 MutableBoolean (org.agrona.collections.MutableBoolean)8 AeronArchive (io.aeron.archive.client.AeronArchive)6 MutableInteger (org.agrona.collections.MutableInteger)4 Aeron (io.aeron.Aeron)2 Publication (io.aeron.Publication)2 ControlledEgressListener (io.aeron.cluster.client.ControlledEgressListener)2 EgressListener (io.aeron.cluster.client.EgressListener)2 io.aeron.cluster.codecs (io.aeron.cluster.codecs)2 FOLLOWER (io.aeron.cluster.service.Cluster.Role.FOLLOWER)2 LEADER (io.aeron.cluster.service.Cluster.Role.LEADER)2 EventLogExtension (io.aeron.log.EventLogExtension)2 ControlledFragmentHandler (io.aeron.logbuffer.ControlledFragmentHandler)2 FrameDescriptor.computeMaxMessageLength (io.aeron.logbuffer.FrameDescriptor.computeMaxMessageLength)2