Search in sources :

Example 16 with TestCluster

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

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

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

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

Example 20 with TestCluster

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

the class ClusterToolTest method shouldSuspendAndResume.

@Test
@InterruptAfter(30)
void shouldSuspendAndResume() {
    final TestCluster cluster = aCluster().withStaticNodes(3).start();
    systemTestWatcher.cluster(cluster);
    final TestNode leader = cluster.awaitLeader();
    final CapturingPrintStream capturingPrintStream = new CapturingPrintStream();
    assertTrue(ClusterTool.suspend(leader.consensusModule().context().clusterDir(), capturingPrintStream.resetAndGetPrintStream()));
    assertThat(capturingPrintStream.flushAndGetContent(), containsString("SUSPEND applied successfully"));
    assertTrue(ClusterTool.resume(leader.consensusModule().context().clusterDir(), capturingPrintStream.resetAndGetPrintStream()));
    assertThat(capturingPrintStream.flushAndGetContent(), containsString("RESUME applied successfully"));
}
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

TestCluster (io.aeron.test.cluster.TestCluster)54 InterruptAfter (io.aeron.test.InterruptAfter)52 Test (org.junit.jupiter.api.Test)50 TestNode (io.aeron.test.cluster.TestNode)48 SlowTest (io.aeron.test.SlowTest)32 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)14 AeronCluster (io.aeron.cluster.client.AeronCluster)4 TestBackupNode (io.aeron.test.cluster.TestBackupNode)4 ValueSource (org.junit.jupiter.params.provider.ValueSource)4 Matchers.containsString (org.hamcrest.Matchers.containsString)2 Disabled (org.junit.jupiter.api.Disabled)2 EnabledForJreRange (org.junit.jupiter.api.condition.EnabledForJreRange)2