use of io.aeron.test.InterruptAfter 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());
}
use of io.aeron.test.InterruptAfter 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);
}
use of io.aeron.test.InterruptAfter in project Aeron by real-logic.
the class ClusterToolTest method shouldNotSnapshotWhenSuspendedOnly.
@Test
@InterruptAfter(30)
void shouldNotSnapshotWhenSuspendedOnly() {
final TestCluster cluster = aCluster().withStaticNodes(3).start();
systemTestWatcher.cluster(cluster);
final TestNode leader = cluster.awaitLeader();
final long initialSnapshotCount = leader.consensusModule().context().snapshotCounter().get();
final CapturingPrintStream capturingPrintStream = new CapturingPrintStream();
assertTrue(ClusterTool.suspend(leader.consensusModule().context().clusterDir(), capturingPrintStream.resetAndGetPrintStream()));
assertThat(capturingPrintStream.flushAndGetContent(), containsString("SUSPEND applied successfully"));
assertFalse(ClusterTool.snapshot(leader.consensusModule().context().clusterDir(), capturingPrintStream.resetAndGetPrintStream()));
final String expectedMessage = "Unable to SNAPSHOT as the state of the consensus module is SUSPENDED, but needs to be ACTIVE";
assertThat(capturingPrintStream.flushAndGetContent(), containsString(expectedMessage));
assertEquals(initialSnapshotCount, leader.consensusModule().context().snapshotCounter().get());
}
use of io.aeron.test.InterruptAfter in project Aeron by real-logic.
the class DynamicMembershipTest method shouldJoinDynamicNodeToSingleStaticLeader.
@Test
@InterruptAfter(30)
public void shouldJoinDynamicNodeToSingleStaticLeader(final TestInfo testInfo) {
cluster = aCluster().withStaticNodes(1).withDynamicNodes(1).start();
systemTestWatcher.cluster(cluster);
final TestNode initialLeader = cluster.awaitLeader();
final TestNode dynamicMember = cluster.startDynamicNode(1, true);
awaitElectionClosed(dynamicMember);
awaitMembershipSize(initialLeader, 2);
}
use of io.aeron.test.InterruptAfter in project Aeron by real-logic.
the class DynamicMembershipTest method shouldDynamicallyJoinClusterOfThreeWithSnapshot.
@Test
@InterruptAfter(30)
public void shouldDynamicallyJoinClusterOfThreeWithSnapshot(final TestInfo testInfo) {
cluster = aCluster().withStaticNodes(3).withDynamicNodes(1).start();
systemTestWatcher.cluster(cluster);
final TestNode leader = cluster.awaitLeader();
final int messageCount = 10;
cluster.connectClient();
cluster.sendMessages(messageCount);
cluster.awaitResponseMessageCount(messageCount);
cluster.takeSnapshot(leader);
cluster.awaitSnapshotCount(1);
final TestNode dynamicMember = cluster.startDynamicNode(3, true);
awaitElectionClosed(dynamicMember);
assertEquals(FOLLOWER, dynamicMember.role());
cluster.awaitSnapshotLoadedForService(dynamicMember);
assertEquals(messageCount, dynamicMember.service().messageCount());
}
Aggregations