Search in sources :

Example 41 with TestNode

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

the class DynamicMembershipTest method shouldDynamicallyJoinClusterOfThreeNoSnapshotsThenSend.

@Test
@InterruptAfter(30)
public void shouldDynamicallyJoinClusterOfThreeNoSnapshotsThenSend(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 int messageCount = 10;
    cluster.connectClient();
    cluster.sendMessages(messageCount);
    cluster.awaitResponseMessageCount(messageCount);
    cluster.awaitServiceMessageCount(leader, messageCount);
    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 42 with TestNode

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

the class DynamicMembershipTest method shouldDynamicallyJoinClusterOfThreeWithEmptySnapshot.

@Test
@InterruptAfter(30)
public void shouldDynamicallyJoinClusterOfThreeWithEmptySnapshot(final TestInfo testInfo) {
    cluster = aCluster().withStaticNodes(3).withDynamicNodes(1).start();
    systemTestWatcher.cluster(cluster);
    final TestNode leader = cluster.awaitLeader();
    cluster.takeSnapshot(leader);
    cluster.awaitSnapshotCount(1);
    final TestNode dynamicMember = cluster.startDynamicNode(3, true);
    awaitElectionClosed(dynamicMember);
    assertEquals(FOLLOWER, dynamicMember.role());
    cluster.awaitSnapshotLoadedForService(dynamicMember);
}
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 43 with TestNode

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

the class DynamicMembershipTest method shouldRemoveFollower.

@Test
@InterruptAfter(30)
public void shouldRemoveFollower(final TestInfo testInfo) {
    cluster = aCluster().withStaticNodes(3).start();
    systemTestWatcher.cluster(cluster);
    final TestNode leader = cluster.awaitLeader();
    final TestNode follower = cluster.followers().get(0);
    follower.isTerminationExpected(true);
    leader.removeMember(follower.index(), false);
    cluster.awaitNodeTermination(follower);
    cluster.stopNode(follower);
    final ClusterMembership clusterMembership = awaitMembershipSize(leader, 2);
    assertEquals(leader.index(), clusterMembership.leaderMemberId);
}
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 44 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 45 with TestNode

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

the class MultiNodeTest method shouldElectAppointedLeaderWithThreeNodesWithNoReplayNoSnapshot.

@Test
@InterruptAfter(20)
public void shouldElectAppointedLeaderWithThreeNodesWithNoReplayNoSnapshot() {
    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());
    assertEquals(Cluster.Role.FOLLOWER, cluster.node(0).role());
    assertEquals(Cluster.Role.FOLLOWER, cluster.node(2).role());
}
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)83 Test (org.junit.jupiter.api.Test)81 InterruptAfter (io.aeron.test.InterruptAfter)36 SlowTest (io.aeron.test.SlowTest)28 TestCluster (io.aeron.test.cluster.TestCluster)25 AeronCluster (io.aeron.cluster.client.AeronCluster)6 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)6 MutableBoolean (org.agrona.collections.MutableBoolean)4 AeronArchive (io.aeron.archive.client.AeronArchive)3 MutableInteger (org.agrona.collections.MutableInteger)2 Aeron (io.aeron.Aeron)1 Publication (io.aeron.Publication)1 ControlledEgressListener (io.aeron.cluster.client.ControlledEgressListener)1 EgressListener (io.aeron.cluster.client.EgressListener)1 io.aeron.cluster.codecs (io.aeron.cluster.codecs)1 FOLLOWER (io.aeron.cluster.service.Cluster.Role.FOLLOWER)1 LEADER (io.aeron.cluster.service.Cluster.Role.LEADER)1 EventLogExtension (io.aeron.log.EventLogExtension)1 ControlledFragmentHandler (io.aeron.logbuffer.ControlledFragmentHandler)1 FrameDescriptor.computeMaxMessageLength (io.aeron.logbuffer.FrameDescriptor.computeMaxMessageLength)1