Search in sources :

Example 11 with TestNode

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

the class ClusterTest method shouldReplaySnapshotTakenWhileDown.

@Test
@InterruptAfter(40)
public void shouldReplaySnapshotTakenWhileDown() {
    cluster = aCluster().withStaticNodes(3).start();
    systemTestWatcher.cluster(cluster);
    final TestNode leader = cluster.awaitLeader();
    final List<TestNode> followers = cluster.followers();
    final TestNode followerA = followers.get(0);
    TestNode followerB = followers.get(1);
    awaitElectionClosed(followerB);
    cluster.stopNode(followerB);
    cluster.takeSnapshot(leader);
    cluster.awaitSnapshotCount(leader, 1);
    cluster.awaitSnapshotCount(followerA, 1);
    final int messageCount = 10;
    cluster.connectClient();
    cluster.sendMessages(messageCount);
    cluster.awaitResponseMessageCount(messageCount);
    followerB = cluster.startStaticNode(followerB.index(), false);
    cluster.awaitSnapshotCount(followerB, 1);
    assertEquals(FOLLOWER, followerB.role());
    cluster.awaitServiceMessageCount(followerB, messageCount);
    assertEquals(0L, followerB.errors());
}
Also used : TestNode(io.aeron.test.cluster.TestNode) Test(org.junit.jupiter.api.Test)

Example 12 with TestNode

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

the class ClusterTest method shouldShutdownClusterAndRestartWithSnapshots.

@Test
@InterruptAfter(30)
public void shouldShutdownClusterAndRestartWithSnapshots() {
    cluster = aCluster().withStaticNodes(3).start();
    systemTestWatcher.cluster(cluster);
    final TestNode leader = cluster.awaitLeader();
    cluster.node(0).isTerminationExpected(true);
    cluster.node(1).isTerminationExpected(true);
    cluster.node(2).isTerminationExpected(true);
    cluster.shutdownCluster(leader);
    cluster.awaitNodeTerminations();
    assertTrue(cluster.node(0).service().wasSnapshotTaken());
    assertTrue(cluster.node(1).service().wasSnapshotTaken());
    assertTrue(cluster.node(2).service().wasSnapshotTaken());
    cluster.stopAllNodes();
    cluster.restartAllNodes(false);
    cluster.awaitLeader();
    assertEquals(2, cluster.followers().size());
    cluster.awaitSnapshotsLoaded();
}
Also used : TestNode(io.aeron.test.cluster.TestNode) Test(org.junit.jupiter.api.Test)

Example 13 with TestNode

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

the class ClusterTest method shouldNotifyClientOfNewLeader.

@Test
@InterruptAfter(40)
public void shouldNotifyClientOfNewLeader() {
    cluster = aCluster().withStaticNodes(3).start();
    systemTestWatcher.cluster(cluster);
    final TestNode leader = cluster.awaitLeader();
    cluster.connectClient();
    cluster.awaitActiveSessionCount(cluster.followers().get(0), 1);
    cluster.stopNode(leader);
    cluster.awaitNewLeadershipEvent(1);
}
Also used : TestNode(io.aeron.test.cluster.TestNode) Test(org.junit.jupiter.api.Test)

Example 14 with TestNode

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

the class ClusterTest method shouldCatchupFromEmptyLog.

@Test
@InterruptAfter(30)
public void shouldCatchupFromEmptyLog() {
    cluster = aCluster().withStaticNodes(3).start();
    systemTestWatcher.cluster(cluster);
    cluster.awaitLeader();
    final List<TestNode> followers = cluster.followers();
    TestNode follower = followers.get(1);
    awaitElectionClosed(follower);
    cluster.stopNode(follower);
    final int messageCount = 10;
    cluster.connectClient();
    cluster.sendMessages(messageCount);
    cluster.awaitResponseMessageCount(messageCount);
    follower = cluster.startStaticNode(follower.index(), true);
    cluster.awaitServiceMessageCount(follower, messageCount);
}
Also used : TestNode(io.aeron.test.cluster.TestNode) Test(org.junit.jupiter.api.Test)

Example 15 with TestNode

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

the class ClusterTest method shouldRecoverQuicklyAfterKillingFollowersThenRestartingOne.

@Test
@InterruptAfter(40)
public void shouldRecoverQuicklyAfterKillingFollowersThenRestartingOne() {
    cluster = aCluster().withStaticNodes(3).start();
    systemTestWatcher.cluster(cluster);
    final TestNode leader = cluster.awaitLeader();
    final List<TestNode> followers = cluster.followers();
    final TestNode followerOne = followers.get(0);
    final TestNode followerTwo = followers.get(1);
    final int messageCount = 10;
    cluster.connectClient();
    cluster.sendMessages(messageCount);
    cluster.awaitResponseMessageCount(messageCount);
    cluster.stopNode(followerOne);
    cluster.stopNode(followerTwo);
    while (leader.role() == LEADER) {
        cluster.sendMessages(1);
        Tests.sleep(500);
    }
    cluster.startStaticNode(followerTwo.index(), true);
    cluster.awaitLeader();
}
Also used : TestNode(io.aeron.test.cluster.TestNode) Test(org.junit.jupiter.api.Test)

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