use of io.aeron.test.cluster.TestNode in project aeron by real-logic.
the class ClusterTest method shouldAbortClusterAndRestart.
@Test
@InterruptAfter(30)
public void shouldAbortClusterAndRestart() {
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.abortCluster(leader);
cluster.awaitNodeTerminations();
assertFalse(cluster.node(0).service().wasSnapshotTaken());
assertFalse(cluster.node(1).service().wasSnapshotTaken());
assertFalse(cluster.node(2).service().wasSnapshotTaken());
cluster.stopAllNodes();
cluster.restartAllNodes(false);
cluster.awaitLeader();
assertEquals(2, cluster.followers().size());
assertFalse(cluster.node(0).service().wasSnapshotLoaded());
assertFalse(cluster.node(1).service().wasSnapshotLoaded());
assertFalse(cluster.node(2).service().wasSnapshotLoaded());
}
use of io.aeron.test.cluster.TestNode in project aeron by real-logic.
the class ClusterTest method shouldAbortClusterOnTerminationTimeout.
@Test
@InterruptAfter(30)
public void shouldAbortClusterOnTerminationTimeout() {
cluster = aCluster().withStaticNodes(3).start();
systemTestWatcher.cluster(cluster);
final TestNode leader = cluster.awaitLeader();
final List<TestNode> followers = cluster.followers();
assertEquals(2, followers.size());
final TestNode followerA = followers.get(0);
final TestNode followerB = followers.get(1);
leader.isTerminationExpected(true);
followerA.isTerminationExpected(true);
cluster.stopNode(followerB);
final int messageCount = 10;
cluster.connectClient();
cluster.sendMessages(messageCount);
cluster.awaitResponseMessageCount(messageCount);
cluster.abortCluster(leader);
cluster.awaitNodeTermination(leader);
cluster.awaitNodeTermination(followerA);
cluster.stopNode(leader);
cluster.stopNode(followerA);
}
use of io.aeron.test.cluster.TestNode in project aeron by real-logic.
the class ClusterTest method shouldTakeASnapshotAfterReceivingAdminRequestOfTypeSnapshotAndNotifyViaControlledPoll.
@Test
@InterruptAfter(20)
void shouldTakeASnapshotAfterReceivingAdminRequestOfTypeSnapshotAndNotifyViaControlledPoll() {
cluster = aCluster().withStaticNodes(3).withAuthorisationServiceSupplier(() -> (protocolId, actionId, type, encodedPrincipal) -> {
assertEquals(MessageHeaderDecoder.SCHEMA_ID, protocolId);
assertEquals(AdminRequestEncoder.TEMPLATE_ID, actionId);
assertEquals(AdminRequestType.SNAPSHOT, type);
return true;
}).start();
systemTestWatcher.cluster(cluster);
final TestNode leader = cluster.awaitLeader();
final long requestCorrelationId = System.nanoTime();
final MutableBoolean responseReceived = injectAdminRequestControlledEgressListener(requestCorrelationId, AdminRequestType.SNAPSHOT, AdminResponseCode.OK, "");
final AeronCluster client = cluster.connectClient();
while (!client.sendAdminRequestToTakeASnapshot(requestCorrelationId)) {
Tests.yield();
}
while (!responseReceived.get()) {
client.controlledPollEgress();
Tests.yield();
}
cluster.awaitSnapshotCount(1);
cluster.awaitNeutralControlToggle(leader);
}
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);
}
use of io.aeron.test.cluster.TestNode in project aeron by real-logic.
the class ClusterTest method shouldTolerateMultipleLeaderFailures.
@Test
@InterruptAfter(50)
public void shouldTolerateMultipleLeaderFailures() {
cluster = aCluster().withStaticNodes(3).start();
systemTestWatcher.cluster(cluster);
final TestNode firstLeader = cluster.awaitLeader();
cluster.stopNode(firstLeader);
final TestNode secondLeader = cluster.awaitLeader();
final long commitPos = secondLeader.commitPosition();
final TestNode newFollower = cluster.startStaticNode(firstLeader.index(), false);
cluster.awaitCommitPosition(newFollower, commitPos);
awaitElectionClosed(newFollower);
cluster.stopNode(secondLeader);
cluster.awaitLeader();
final int messageCount = 10;
cluster.connectClient();
cluster.sendMessages(messageCount);
cluster.awaitResponseMessageCount(messageCount);
}
Aggregations