Search in sources :

Example 1 with BaseServer

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

the class TestClientRouterTest method onlyDropEpochChangeMessages.

@Test
public void onlyDropEpochChangeMessages() {
    TestServerRouter tsr = new TestServerRouter();
    BaseServer bs = new BaseServer();
    tsr.addServer(bs);
    TestClientRouter tcr = new TestClientRouter(tsr);
    BaseClient bc = new BaseClient();
    tcr.addClient(bc);
    tcr.rules.add(new TestRule().matches(x -> x.getMsgType().equals(CorfuMsgType.SET_EPOCH)).drop());
    assertThat(bc.pingSync()).isTrue();
    final long NEW_EPOCH = 9L;
    assertThatThrownBy(() -> bc.setRemoteEpoch(NEW_EPOCH).get()).hasCauseInstanceOf(TimeoutException.class);
}
Also used : TestServerRouter(org.corfudb.infrastructure.TestServerRouter) BaseServer(org.corfudb.infrastructure.BaseServer) Test(org.junit.Test) AbstractCorfuTest(org.corfudb.AbstractCorfuTest)

Example 2 with BaseServer

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

the class TestClientRouterTest method testRuleDropsMessages.

@Test
public void testRuleDropsMessages() {
    TestServerRouter tsr = new TestServerRouter();
    BaseServer bs = new BaseServer();
    tsr.addServer(bs);
    TestClientRouter tcr = new TestClientRouter(tsr);
    BaseClient bc = new BaseClient();
    tcr.addClient(bc);
    assertThat(bc.pingSync()).isTrue();
    tcr.rules.add(new TestRule().always().drop());
    assertThat(bc.pingSync()).isFalse();
}
Also used : TestServerRouter(org.corfudb.infrastructure.TestServerRouter) BaseServer(org.corfudb.infrastructure.BaseServer) Test(org.junit.Test) AbstractCorfuTest(org.corfudb.AbstractCorfuTest)

Example 3 with BaseServer

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

the class NettyCommTest method runWithBaseServer.

void runWithBaseServer(NettyServerDataConstructor nsdc, NettyClientRouterConstructor ncrc, NettyCommFunction actionFn) throws Exception {
    NettyServerRouter nsr = new NettyServerRouter(new ImmutableMap.Builder<String, Object>().build());
    nsr.addServer(new BaseServer());
    int port = findRandomOpenPort();
    NettyServerData d = nsdc.createNettyServerData(port);
    NettyClientRouter ncr = null;
    try {
        d.bootstrapServer();
        ncr = ncrc.createNettyClientRouter(port);
        ncr.addClient(new BaseClient());
        ncr.start();
        actionFn.runTest(ncr, d);
    } catch (Exception ex) {
        log.error("Exception ", ex);
        throw ex;
    } finally {
        try {
            if (ncr != null) {
                ncr.stop();
            }
        } catch (Exception ex) {
            log.warn("Error shutting down client...", ex);
        }
        d.shutdownServer();
    }
}
Also used : BaseServer(org.corfudb.infrastructure.BaseServer) NettyServerRouter(org.corfudb.infrastructure.NettyServerRouter) IOException(java.io.IOException)

Aggregations

BaseServer (org.corfudb.infrastructure.BaseServer)3 AbstractCorfuTest (org.corfudb.AbstractCorfuTest)2 TestServerRouter (org.corfudb.infrastructure.TestServerRouter)2 Test (org.junit.Test)2 IOException (java.io.IOException)1 NettyServerRouter (org.corfudb.infrastructure.NettyServerRouter)1