Search in sources :

Example 11 with TestLayoutBuilder

use of org.corfudb.infrastructure.TestLayoutBuilder in project CorfuDB by CorfuDB.

the class SMRMultiLogunitTest method setRuntime.

@Before
public void setRuntime() {
    addServer(SERVERS.PORT_0);
    addServer(SERVERS.PORT_1);
    addServer(SERVERS.PORT_2);
    Layout layout = new TestLayoutBuilder().setEpoch(1L).addLayoutServer(SERVERS.PORT_0).addLayoutServer(SERVERS.PORT_1).addLayoutServer(SERVERS.PORT_2).addSequencer(SERVERS.PORT_0).buildSegment().buildStripe().addLogUnit(SERVERS.PORT_0).addLogUnit(SERVERS.PORT_1).addLogUnit(SERVERS.PORT_2).addToSegment().addToLayout().build();
    bootstrapAllServers(layout);
    runtime = getRuntime().connect();
}
Also used : TestLayoutBuilder(org.corfudb.infrastructure.TestLayoutBuilder) Layout(org.corfudb.runtime.view.Layout) Before(org.junit.Before)

Example 12 with TestLayoutBuilder

use of org.corfudb.infrastructure.TestLayoutBuilder in project CorfuDB by CorfuDB.

the class LayoutViewTest method canSetLayout.

@Test
public void canSetLayout() throws Exception {
    CorfuRuntime r = getDefaultRuntime().connect();
    Layout l = new TestLayoutBuilder().setEpoch(1).addLayoutServer(SERVERS.PORT_0).addSequencer(SERVERS.PORT_0).buildSegment().buildStripe().addLogUnit(SERVERS.PORT_0).addToSegment().addToLayout().build();
    l.setRuntime(r);
    l.moveServersToEpoch();
    r.getLayoutView().updateLayout(l, 1L);
    r.invalidateLayout();
    assertThat(r.getLayoutView().getLayout().epoch).isEqualTo(1L);
}
Also used : TestLayoutBuilder(org.corfudb.infrastructure.TestLayoutBuilder) CorfuRuntime(org.corfudb.runtime.CorfuRuntime) Test(org.junit.Test)

Example 13 with TestLayoutBuilder

use of org.corfudb.infrastructure.TestLayoutBuilder in project CorfuDB by CorfuDB.

the class ManagementViewTest method testSequencerFailover.

/**
     * Scenario with 3 nodes: SERVERS.PORT_0, SERVERS.PORT_1 and SERVERS.PORT_2.
     * We fail SERVERS.PORT_1 and then wait for one of the other two servers to
     * handle this failure, propose a new layout and we assert on the epoch change.
     * The failure is handled by ConserveFailureHandlerPolicy.
     * No nodes are removed from the layout, but are marked unresponsive.
     * A sequencer failover takes place where the next working sequencer is reset
     * and made the primary.
     *
     * @throws Exception
     */
@Test
public void testSequencerFailover() throws Exception {
    getManagementTestLayout();
    final long beforeFailure = 5L;
    final long afterFailure = 10L;
    IStreamView sv = getCorfuRuntime().getStreamsView().get(CorfuRuntime.getStreamID("streamA"));
    byte[] testPayload = "hello world".getBytes();
    sv.append(testPayload);
    sv.append(testPayload);
    sv.append(testPayload);
    sv.append(testPayload);
    sv.append(testPayload);
    assertThat(getSequencer(SERVERS.PORT_1).getGlobalLogTail().get()).isEqualTo(beforeFailure);
    assertThat(getSequencer(SERVERS.PORT_0).getGlobalLogTail().get()).isEqualTo(0L);
    induceSequencerFailureAndWait();
    // verify that a failover sequencer was started with the correct starting-tail
    //
    assertThat(getSequencer(SERVERS.PORT_0).getGlobalLogTail().get()).isEqualTo(beforeFailure);
    sv.append(testPayload);
    sv.append(testPayload);
    sv.append(testPayload);
    sv.append(testPayload);
    sv.append(testPayload);
    // verify the failover layout
    //
    Layout expectedLayout = new TestLayoutBuilder().setEpoch(2L).addLayoutServer(SERVERS.PORT_0).addLayoutServer(SERVERS.PORT_1).addLayoutServer(SERVERS.PORT_2).addSequencer(SERVERS.PORT_0).addSequencer(SERVERS.PORT_1).addSequencer(SERVERS.PORT_2).buildSegment().buildStripe().addLogUnit(SERVERS.PORT_0).addLogUnit(SERVERS.PORT_2).addToSegment().addToLayout().addUnresponsiveServer(SERVERS.PORT_1).build();
    assertThat(getCorfuRuntime().getLayoutView().getLayout()).isEqualTo(expectedLayout);
    // verify that the new sequencer is advancing the tail properly
    assertThat(getSequencer(SERVERS.PORT_0).getGlobalLogTail().get()).isEqualTo(afterFailure);
    // sanity check that no other sequencer is active
    assertThat(getSequencer(SERVERS.PORT_2).getGlobalLogTail().get()).isEqualTo(0L);
}
Also used : TestLayoutBuilder(org.corfudb.infrastructure.TestLayoutBuilder) IStreamView(org.corfudb.runtime.view.stream.IStreamView) Test(org.junit.Test)

Example 14 with TestLayoutBuilder

use of org.corfudb.infrastructure.TestLayoutBuilder in project CorfuDB by CorfuDB.

the class QuorumReplicationProtocolAdditionalTests method before.

@Before
public void before() {
    addServer(SERVERS.PORT_0);
    addServer(SERVERS.PORT_1);
    addServer(SERVERS.PORT_2);
    layout = new TestLayoutBuilder().setEpoch(1L).addLayoutServer(SERVERS.PORT_0).addLayoutServer(SERVERS.PORT_1).addLayoutServer(SERVERS.PORT_2).addSequencer(SERVERS.PORT_0).buildSegment().setReplicationMode(Layout.ReplicationMode.QUORUM_REPLICATION).buildStripe().addLogUnit(SERVERS.PORT_0).addLogUnit(SERVERS.PORT_1).addLogUnit(SERVERS.PORT_2).addToSegment().addToLayout().build();
    bootstrapAllServers(layout);
    getManagementServer(SERVERS.PORT_0).shutdown();
    getManagementServer(SERVERS.PORT_1).shutdown();
    getManagementServer(SERVERS.PORT_2).shutdown();
    layout.getSegment(0L).setReplicationMode(Layout.ReplicationMode.QUORUM_REPLICATION);
    corfuRuntime = new CorfuRuntime();
    corfuRuntime.setCacheDisabled(true);
    layout.getLayoutServers().forEach(corfuRuntime::addLayoutServer);
    layout.getAllServers().forEach(serverEndpoint -> {
        corfuRuntime.getRouter(serverEndpoint).setTimeoutConnect(PARAMETERS.TIMEOUT_VERY_SHORT.toMillis());
        corfuRuntime.getRouter(serverEndpoint).setTimeoutResponse(PARAMETERS.TIMEOUT_VERY_SHORT.toMillis());
        corfuRuntime.getRouter(serverEndpoint).setTimeoutRetry(PARAMETERS.TIMEOUT_VERY_SHORT.toMillis());
    });
    corfuRuntime.connect();
}
Also used : TestLayoutBuilder(org.corfudb.infrastructure.TestLayoutBuilder) CorfuRuntime(org.corfudb.runtime.CorfuRuntime) Before(org.junit.Before)

Aggregations

TestLayoutBuilder (org.corfudb.infrastructure.TestLayoutBuilder)14 CorfuRuntime (org.corfudb.runtime.CorfuRuntime)12 Test (org.junit.Test)11 TestRule (org.corfudb.runtime.clients.TestRule)5 UUID (java.util.UUID)4 TokenResponse (org.corfudb.protocols.wireprotocol.TokenResponse)4 IStreamView (org.corfudb.runtime.view.stream.IStreamView)4 PurgeFailurePolicy (org.corfudb.infrastructure.PurgeFailurePolicy)3 ServerContext (org.corfudb.infrastructure.ServerContext)3 ServerContextBuilder (org.corfudb.infrastructure.ServerContextBuilder)3 TestServerRouter (org.corfudb.infrastructure.TestServerRouter)3 TypeToken (com.google.common.reflect.TypeToken)2 Collections (java.util.Collections)2 Map (java.util.Map)2 Semaphore (java.util.concurrent.Semaphore)2 TimeUnit (java.util.concurrent.TimeUnit)2 Getter (lombok.Getter)2 Assertions.assertThat (org.assertj.core.api.Assertions.assertThat)2 CorfuMsgType (org.corfudb.protocols.wireprotocol.CorfuMsgType)2 ManagementClient (org.corfudb.runtime.clients.ManagementClient)2