Search in sources :

Example 46 with InterruptAfter

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());
}
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 47 with InterruptAfter

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);
}
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 48 with InterruptAfter

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());
}
Also used : TestCluster(io.aeron.test.cluster.TestCluster) TestNode(io.aeron.test.cluster.TestNode) Matchers.containsString(org.hamcrest.Matchers.containsString) SlowTest(io.aeron.test.SlowTest) Test(org.junit.jupiter.api.Test) InterruptAfter(io.aeron.test.InterruptAfter)

Example 49 with InterruptAfter

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);
}
Also used : TestNode(io.aeron.test.cluster.TestNode) Test(org.junit.jupiter.api.Test) SlowTest(io.aeron.test.SlowTest) InterruptAfter(io.aeron.test.InterruptAfter)

Example 50 with InterruptAfter

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());
}
Also used : TestNode(io.aeron.test.cluster.TestNode) Test(org.junit.jupiter.api.Test) SlowTest(io.aeron.test.SlowTest) InterruptAfter(io.aeron.test.InterruptAfter)

Aggregations

InterruptAfter (io.aeron.test.InterruptAfter)304 Test (org.junit.jupiter.api.Test)240 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)90 MediaDriver (io.aeron.driver.MediaDriver)74 TestNode (io.aeron.test.cluster.TestNode)72 UnsafeBuffer (org.agrona.concurrent.UnsafeBuffer)68 Tests (io.aeron.test.Tests)66 CountersReader (org.agrona.concurrent.status.CountersReader)64 MethodSource (org.junit.jupiter.params.provider.MethodSource)62 SlowTest (io.aeron.test.SlowTest)60 InterruptingTestCallback (io.aeron.test.InterruptingTestCallback)58 ExtendWith (org.junit.jupiter.api.extension.ExtendWith)58 TestMediaDriver (io.aeron.test.driver.TestMediaDriver)54 TestCluster (io.aeron.test.cluster.TestCluster)52 ThreadingMode (io.aeron.driver.ThreadingMode)50 MutableInteger (org.agrona.collections.MutableInteger)50 DirectBuffer (org.agrona.DirectBuffer)48 SystemTestWatcher (io.aeron.test.SystemTestWatcher)46 MutableLong (org.agrona.collections.MutableLong)46 RegisterExtension (org.junit.jupiter.api.extension.RegisterExtension)46