use of com.yahoo.messagebus.test.SimpleProtocol in project vespa by vespa-engine.
the class SharedSourceSessionTestCase method newSourceSession.
private static SharedSourceSession newSourceSession(String slobrokId, SourceSessionParams params) {
RPCNetworkParams netParams = new RPCNetworkParams().setSlobrokConfigId(slobrokId);
MessageBusParams mbusParams = new MessageBusParams().addProtocol(new SimpleProtocol());
SharedMessageBus mbus = SharedMessageBus.newInstance(mbusParams, netParams);
SharedSourceSession session = mbus.newSourceSession(params);
mbus.release();
return session;
}
use of com.yahoo.messagebus.test.SimpleProtocol in project vespa by vespa-engine.
the class ChokeTestCase method setUp.
@Before
public void setUp() throws ListenFailedException, UnknownHostException {
slobrok = new Slobrok();
dstServer = new TestServer(new MessageBusParams().addProtocol(new SimpleProtocol()), new RPCNetworkParams().setIdentity(new Identity("dst")).setSlobrokConfigId(TestServer.getSlobrokConfig(slobrok)));
dstSession = dstServer.mb.createDestinationSession(new DestinationSessionParams().setName("session").setMessageHandler(new Receptor()));
srcServer = new TestServer(new MessageBusParams().setRetryPolicy(null).addProtocol(new SimpleProtocol()), new RPCNetworkParams().setSlobrokConfigId(TestServer.getSlobrokConfig(slobrok)));
srcSession = srcServer.mb.createSourceSession(new SourceSessionParams().setTimeout(600.0).setThrottlePolicy(null).setReplyHandler(new Receptor()));
assertTrue(srcServer.waitSlobrok("dst/session", 1));
}
use of com.yahoo.messagebus.test.SimpleProtocol in project vespa by vespa-engine.
the class MessageBusTestCase method requireThatBucketSequencingWithResenderEnabledCausesError.
@Test
public void requireThatBucketSequencingWithResenderEnabledCausesError() throws ListenFailedException {
Slobrok slobrok = new Slobrok();
TestServer server = new TestServer(new MessageBusParams().addProtocol(new SimpleProtocol()).setRetryPolicy(new RetryTransientErrorsPolicy()), new RPCNetworkParams().setSlobrokConfigId(slobrok.configId()));
Receptor receptor = new Receptor();
SourceSession session = server.mb.createSourceSession(new SourceSessionParams().setTimeout(600.0).setReplyHandler(receptor));
assertTrue(session.send(new SimpleMessage("foo") {
@Override
public boolean hasBucketSequence() {
return true;
}
}.setRoute(Route.parse("bar"))).isAccepted());
Reply reply = receptor.getReply(60);
assertNotNull(reply);
assertEquals(1, reply.getNumErrors());
assertEquals(ErrorCode.SEQUENCE_ERROR, reply.getError(0).getCode());
session.destroy();
server.destroy();
slobrok.stop();
}
use of com.yahoo.messagebus.test.SimpleProtocol in project vespa by vespa-engine.
the class RoutingContextTestCase method testMoreDirectives.
public void testMoreDirectives() {
SimpleProtocol protocol = new SimpleProtocol();
protocol.addPolicyFactory("Custom", new CustomPolicyFactory(false, Arrays.asList("foo", "foo/bar", "foo/bar0/baz", "foo/bar1/baz", "foo/bar/baz/cox"), Arrays.asList("foo/bar0/baz", "foo/bar1/baz")));
srcServer.mb.putProtocol(protocol);
srcServer.setupRouting(new RoutingTableSpec(SimpleProtocol.NAME).addRoute(new RouteSpec("myroute").addHop("myhop")).addHop(new HopSpec("myhop", "foo/[Custom]/baz").addRecipient("foo").addRecipient("foo/bar").addRecipient("foo/bar0/baz").addRecipient("foo/bar1/baz").addRecipient("foo/bar/baz/cox")));
for (int i = 0; i < 2; ++i) {
assertTrue(srcSession.send(createMessage("msg"), "myroute").isAccepted());
Reply reply = ((Receptor) srcSession.getReplyHandler()).getReply(TIMEOUT_SECS);
assertNotNull(reply);
System.out.println(reply.getTrace());
assertFalse(reply.hasErrors());
}
}
use of com.yahoo.messagebus.test.SimpleProtocol in project vespa by vespa-engine.
the class RoutingContextTestCase method testConstRoute.
public void testConstRoute() {
SimpleProtocol protocol = new SimpleProtocol();
protocol.addPolicyFactory("DocumentRouteSelector", new CustomPolicyFactory(true, Arrays.asList("dst"), Arrays.asList("dst")));
srcServer.mb.putProtocol(protocol);
srcServer.setupRouting(new RoutingTableSpec(SimpleProtocol.NAME).addRoute(new RouteSpec("default").addHop("indexing")).addHop(new HopSpec("indexing", "[DocumentRouteSelector]").addRecipient("dst")).addHop(new HopSpec("dst", "dst/session")));
for (int i = 0; i < 2; ++i) {
assertTrue(srcSession.send(createMessage("msg"), Route.parse("route:default")).isAccepted());
Message msg = ((Receptor) dstSession.getMessageHandler()).getMessage(TIMEOUT_SECS);
assertNotNull(msg);
dstSession.acknowledge(msg);
Reply reply = ((Receptor) srcSession.getReplyHandler()).getReply(TIMEOUT_SECS);
assertNotNull(reply);
System.out.println(reply.getTrace());
assertFalse(reply.hasErrors());
}
}
Aggregations