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);
}
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();
}
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();
}
}
Aggregations