Search in sources :

Example 51 with TestCluster

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

the class ClusterBackupTest method shouldBackupClusterNoSnapshotsAndNonEmptyLogWithReQuery.

@Test
@InterruptAfter(30)
public void shouldBackupClusterNoSnapshotsAndNonEmptyLogWithReQuery() {
    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();
    final TestBackupNode backupNode = cluster.startClusterBackupNode(true);
    cluster.awaitBackupState(ClusterBackup.State.BACKING_UP);
    cluster.awaitBackupLiveLogPosition(logPosition);
    assertTrue(backupNode.nextBackupQueryDeadlineMs(0));
    cluster.sendMessages(5);
    cluster.awaitResponseMessageCount(messageCount + 5);
    cluster.awaitServiceMessageCount(leader, messageCount + 5);
    final long nextLogPosition = leader.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());
}
Also used : TestCluster(io.aeron.test.cluster.TestCluster) TestNode(io.aeron.test.cluster.TestNode) TestBackupNode(io.aeron.test.cluster.TestBackupNode) SlowTest(io.aeron.test.SlowTest) Test(org.junit.jupiter.api.Test) InterruptAfter(io.aeron.test.InterruptAfter)

Example 52 with TestCluster

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

the class ClusterBackupTest method shouldBackupClusterWithSnapshot.

@Test
@InterruptAfter(30)
public void shouldBackupClusterWithSnapshot() {
    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.takeSnapshot(leader);
    cluster.awaitSnapshotCount(1);
    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());
    assertTrue(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 TestCluster

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

the class ClusterBackupTest method shouldBeAbleToGetTimeOfNextBackupQuery.

@Test
@InterruptAfter(30)
public void shouldBeAbleToGetTimeOfNextBackupQuery() {
    final TestCluster cluster = aCluster().withStaticNodes(3).start();
    systemTestWatcher.cluster(cluster);
    cluster.awaitLeader();
    final TestBackupNode backupNode = cluster.startClusterBackupNode(true);
    cluster.awaitBackupState(ClusterBackup.State.BACKING_UP);
    final long nowMs = backupNode.epochClock().time();
    assertThat(backupNode.nextBackupQueryDeadlineMs(), greaterThan(nowMs));
}
Also used : TestCluster(io.aeron.test.cluster.TestCluster) TestBackupNode(io.aeron.test.cluster.TestBackupNode) SlowTest(io.aeron.test.SlowTest) Test(org.junit.jupiter.api.Test) InterruptAfter(io.aeron.test.InterruptAfter)

Example 54 with TestCluster

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

the class ClusterBackupTest method shouldBackupClusterNoSnapshotsAndEmptyLog.

@Test
@InterruptAfter(30)
public void shouldBackupClusterNoSnapshotsAndEmptyLog() {
    final TestCluster cluster = aCluster().withStaticNodes(3).start();
    systemTestWatcher.cluster(cluster);
    cluster.awaitLeader();
    cluster.startClusterBackupNode(true);
    cluster.awaitBackupState(ClusterBackup.State.BACKING_UP);
    cluster.awaitBackupLiveLogPosition(cluster.findLeader().service().cluster().logPosition());
    cluster.stopAllNodes();
    final TestNode node = cluster.startStaticNodeFromBackup();
    cluster.awaitLeader();
    assertEquals(0, 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

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