Search in sources :

Example 51 with InterruptAfter

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

the class DynamicMembershipTest method shouldRemoveLeaderAfterDynamicNodeJoinedThenRestartCluster.

@Test
@InterruptAfter(30)
public void shouldRemoveLeaderAfterDynamicNodeJoinedThenRestartCluster(final TestInfo testInfo) {
    cluster = aCluster().withStaticNodes(3).withDynamicNodes(1).start();
    systemTestWatcher.cluster(cluster);
    final TestNode initialLeader = cluster.awaitLeader();
    final TestNode dynamicMember = cluster.startDynamicNode(3, true);
    awaitElectionClosed(dynamicMember);
    awaitMembershipSize(initialLeader, 4);
    final int initialLeaderIndex = initialLeader.index();
    initialLeader.isTerminationExpected(true);
    initialLeader.removeMember(initialLeaderIndex, false);
    cluster.awaitNodeTermination(initialLeader);
    cluster.stopNode(initialLeader);
    final TestNode newLeader = cluster.awaitLeader(initialLeaderIndex);
    final ClusterMembership clusterMembership = awaitMembershipSize(newLeader, 3);
    assertEquals(newLeader.index(), clusterMembership.leaderMemberId);
    assertNotEquals(initialLeaderIndex, clusterMembership.leaderMemberId);
    cluster.stopAllNodes();
    for (int i = 0; i < 3; i++) {
        if (initialLeaderIndex != i) {
            cluster.startStaticNode(i, false);
        }
    }
    cluster.awaitLeader();
    assertEquals(1, cluster.followers().size());
    awaitElectionClosed(cluster.followers().get(0));
}
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 52 with InterruptAfter

use of io.aeron.test.InterruptAfter 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 53 with InterruptAfter

use of io.aeron.test.InterruptAfter 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 54 with InterruptAfter

use of io.aeron.test.InterruptAfter 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 55 with InterruptAfter

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

Aggregations

InterruptAfter (io.aeron.test.InterruptAfter)304 Test (org.junit.jupiter.api.Test)240 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)90 MediaDriver (io.aeron.driver.MediaDriver)74 TestNode (io.aeron.test.cluster.TestNode)72 UnsafeBuffer (org.agrona.concurrent.UnsafeBuffer)68 Tests (io.aeron.test.Tests)66 CountersReader (org.agrona.concurrent.status.CountersReader)64 MethodSource (org.junit.jupiter.params.provider.MethodSource)62 SlowTest (io.aeron.test.SlowTest)60 InterruptingTestCallback (io.aeron.test.InterruptingTestCallback)58 ExtendWith (org.junit.jupiter.api.extension.ExtendWith)58 TestMediaDriver (io.aeron.test.driver.TestMediaDriver)54 TestCluster (io.aeron.test.cluster.TestCluster)52 ThreadingMode (io.aeron.driver.ThreadingMode)50 MutableInteger (org.agrona.collections.MutableInteger)50 DirectBuffer (org.agrona.DirectBuffer)48 SystemTestWatcher (io.aeron.test.SystemTestWatcher)46 MutableLong (org.agrona.collections.MutableLong)46 RegisterExtension (org.junit.jupiter.api.extension.RegisterExtension)46