Search in sources :

Example 51 with TestNode

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

the class ClusterBackupTest method shouldBackupClusterAfterCleanShutdown.

@Test
@InterruptAfter(30)
public void shouldBackupClusterAfterCleanShutdown() {
    final TestCluster cluster = aCluster().withStaticNodes(3).start();
    systemTestWatcher.cluster(cluster);
    final TestNode leader = cluster.awaitLeader();
    final int messageCount = 10;
    cluster.connectClient();
    cluster.sendMessages(messageCount);
    cluster.awaitResponseMessageCount(messageCount);
    cluster.awaitServicesMessageCount(messageCount);
    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);
    final TestNode newLeader = cluster.awaitLeader();
    final long logPosition = newLeader.service().cluster().logPosition();
    cluster.startClusterBackupNode(true);
    cluster.awaitBackupState(ClusterBackup.State.BACKING_UP);
    cluster.awaitBackupLiveLogPosition(logPosition);
}
Also used : TestCluster(io.aeron.test.cluster.TestCluster) TestNode(io.aeron.test.cluster.TestNode) SlowTest(io.aeron.test.SlowTest) Test(org.junit.jupiter.api.Test) InterruptAfter(io.aeron.test.InterruptAfter)

Example 52 with TestNode

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

the class ClusterBackupTest method shouldBackupClusterNoSnapshotsAndThenSendMessages.

@Test
@InterruptAfter(30)
public void shouldBackupClusterNoSnapshotsAndThenSendMessages() {
    final TestCluster cluster = aCluster().withStaticNodes(3).start();
    systemTestWatcher.cluster(cluster);
    final TestNode leader = cluster.awaitLeader();
    cluster.startClusterBackupNode(true);
    cluster.awaitBackupState(ClusterBackup.State.BACKING_UP);
    final int messageCount = 10;
    cluster.connectClient();
    cluster.sendMessages(messageCount);
    cluster.awaitResponseMessageCount(messageCount);
    cluster.awaitServicesMessageCount(messageCount);
    final long logPosition = leader.service().cluster().logPosition();
    cluster.awaitBackupLiveLogPosition(logPosition);
    cluster.stopAllNodes();
    final TestNode node = cluster.startStaticNodeFromBackup();
    cluster.awaitLeader();
    assertEquals(messageCount, node.service().messageCount());
    assertFalse(node.service().wasSnapshotLoaded());
}
Also used : TestCluster(io.aeron.test.cluster.TestCluster) TestNode(io.aeron.test.cluster.TestNode) SlowTest(io.aeron.test.SlowTest) Test(org.junit.jupiter.api.Test) InterruptAfter(io.aeron.test.InterruptAfter)

Example 53 with TestNode

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

the class ClusterBackupTest method shouldBackupClusterNoSnapshotsAndNonEmptyLogWithFailure.

@Test
@InterruptAfter(60)
public void shouldBackupClusterNoSnapshotsAndNonEmptyLogWithFailure() {
    final TestCluster cluster = aCluster().withStaticNodes(3).start();
    systemTestWatcher.cluster(cluster);
    final TestNode leaderOne = cluster.awaitLeader();
    final int messageCount = 10;
    final AeronCluster aeronCluster = cluster.connectClient();
    cluster.sendMessages(messageCount);
    cluster.awaitResponseMessageCount(messageCount);
    cluster.awaitServicesMessageCount(messageCount);
    final long logPosition = leaderOne.service().cluster().logPosition();
    cluster.startClusterBackupNode(true);
    aeronCluster.sendKeepAlive();
    cluster.awaitBackupState(ClusterBackup.State.BACKING_UP);
    aeronCluster.sendKeepAlive();
    cluster.awaitBackupLiveLogPosition(logPosition);
    cluster.stopNode(leaderOne);
    final TestNode leaderTwo = cluster.awaitLeader();
    cluster.awaitNewLeadershipEvent(1);
    cluster.sendMessages(5);
    cluster.awaitResponseMessageCount(messageCount + 5);
    final long nextLogPosition = leaderTwo.service().cluster().logPosition();
    cluster.awaitBackupState(ClusterBackup.State.BACKING_UP);
    cluster.awaitBackupLiveLogPosition(nextLogPosition);
    cluster.stopAllNodes();
    final TestNode node = cluster.startStaticNodeFromBackup();
    cluster.awaitLeader();
    assertEquals(messageCount + 5, node.service().messageCount());
    assertFalse(node.service().wasSnapshotLoaded());
}
Also used : TestCluster(io.aeron.test.cluster.TestCluster) AeronCluster(io.aeron.cluster.client.AeronCluster) TestNode(io.aeron.test.cluster.TestNode) SlowTest(io.aeron.test.SlowTest) Test(org.junit.jupiter.api.Test) InterruptAfter(io.aeron.test.InterruptAfter)

Example 54 with TestNode

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

the class ClusterBackupTest method shouldBackupClusterNoSnapshotsAndNonEmptyLogAfterFailure.

@Test
@InterruptAfter(40)
public void shouldBackupClusterNoSnapshotsAndNonEmptyLogAfterFailure() {
    final TestCluster cluster = aCluster().withStaticNodes(3).start();
    systemTestWatcher.cluster(cluster);
    final TestNode leaderOne = cluster.awaitLeader();
    final int messageCount = 10;
    cluster.connectClient();
    cluster.sendMessages(messageCount);
    cluster.awaitResponseMessageCount(messageCount);
    cluster.awaitServicesMessageCount(messageCount);
    cluster.stopNode(leaderOne);
    final TestNode leaderTwo = cluster.awaitLeader();
    final long logPosition = leaderTwo.service().cluster().logPosition();
    cluster.startClusterBackupNode(true);
    cluster.awaitBackupState(ClusterBackup.State.BACKING_UP);
    cluster.awaitBackupLiveLogPosition(logPosition);
    cluster.stopAllNodes();
    final TestNode node = cluster.startStaticNodeFromBackup();
    cluster.awaitLeader();
    assertEquals(messageCount, node.service().messageCount());
    assertFalse(node.service().wasSnapshotLoaded());
}
Also used : TestCluster(io.aeron.test.cluster.TestCluster) TestNode(io.aeron.test.cluster.TestNode) SlowTest(io.aeron.test.SlowTest) Test(org.junit.jupiter.api.Test) InterruptAfter(io.aeron.test.InterruptAfter)

Example 55 with TestNode

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

the class ClusterBackupTest method shouldBackupClusterNoSnapshotsAndNonEmptyLog.

@Test
@InterruptAfter(30)
public void shouldBackupClusterNoSnapshotsAndNonEmptyLog() {
    final TestCluster cluster = aCluster().withStaticNodes(3).start();
    systemTestWatcher.cluster(cluster);
    final TestNode leader = cluster.awaitLeader();
    final int messageCount = 10;
    cluster.connectClient();
    cluster.sendMessages(messageCount);
    cluster.awaitResponseMessageCount(messageCount);
    cluster.awaitServicesMessageCount(messageCount);
    final long logPosition = leader.service().cluster().logPosition();
    cluster.startClusterBackupNode(true);
    cluster.awaitBackupState(ClusterBackup.State.BACKING_UP);
    cluster.awaitBackupLiveLogPosition(logPosition);
    cluster.stopAllNodes();
    final TestNode node = cluster.startStaticNodeFromBackup();
    cluster.awaitLeader();
    assertEquals(messageCount, node.service().messageCount());
    assertFalse(node.service().wasSnapshotLoaded());
}
Also used : TestCluster(io.aeron.test.cluster.TestCluster) TestNode(io.aeron.test.cluster.TestNode) SlowTest(io.aeron.test.SlowTest) Test(org.junit.jupiter.api.Test) 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