use of com.yahoo.messagebus.test.Receptor in project vespa by vespa-engine.
the class RoutingContextTestCase method testSingleDirective.
// //////////////////////////////////////////////////////////////////////////////
//
// Tests
//
// //////////////////////////////////////////////////////////////////////////////
public void testSingleDirective() {
SimpleProtocol protocol = new SimpleProtocol();
protocol.addPolicyFactory("Custom", new CustomPolicyFactory(false, Arrays.asList("foo", "bar", "baz/cox"), Arrays.asList("foo", "bar")));
srcServer.mb.putProtocol(protocol);
srcServer.setupRouting(new RoutingTableSpec(SimpleProtocol.NAME).addRoute(new RouteSpec("myroute").addHop("myhop")).addHop(new HopSpec("myhop", "[Custom]").addRecipient("foo").addRecipient("bar").addRecipient("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.Receptor in project vespa by vespa-engine.
the class RoutingContextTestCase method setUp.
@Override
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(new RetryTransientErrorsPolicy().setBaseDelay(0)).addProtocol(new SimpleProtocol()), new RPCNetworkParams().setSlobrokConfigId(TestServer.getSlobrokConfig(slobrok)));
srcSession = srcServer.mb.createSourceSession(new SourceSessionParams().setTimeout(600.0).setReplyHandler(new Receptor()));
assertTrue(srcServer.waitSlobrok("dst/session", 1));
}
use of com.yahoo.messagebus.test.Receptor in project vespa by vespa-engine.
the class RoutingContextTestCase method testRecipientsRemain.
public void testRecipientsRemain() {
SimpleProtocol protocol = new SimpleProtocol();
protocol.addPolicyFactory("First", new CustomPolicyFactory(true, Arrays.asList("foo/bar"), Arrays.asList("foo/[Second]")));
protocol.addPolicyFactory("Second", new CustomPolicyFactory(false, Arrays.asList("foo/bar"), Arrays.asList("foo/bar")));
srcServer.mb.putProtocol(protocol);
srcServer.setupRouting(new RoutingTableSpec(SimpleProtocol.NAME).addRoute(new RouteSpec("myroute").addHop("myhop")).addHop(new HopSpec("myhop", "[First]/[Second]").addRecipient("foo/bar")));
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.Receptor in project vespa by vespa-engine.
the class RoutingTestCase method requireThatPolicyCanConsumeErrors.
@Test
public void requireThatPolicyCanConsumeErrors() {
SimpleProtocol protocol = new SimpleProtocol();
protocol.addPolicyFactory("Custom", new CustomPolicyFactory(true, ErrorCode.NO_ADDRESS_FOR_SERVICE));
srcServer.mb.putProtocol(protocol);
retryPolicy.setEnabled(false);
assertTrue(srcSession.send(createMessage("msg"), Route.parse("[Custom:dst/session,dst/unknown]")).isAccepted());
Message msg = ((Receptor) dstSession.getMessageHandler()).getMessage(60);
assertNotNull(msg);
dstSession.acknowledge(msg);
Reply reply = ((Receptor) srcSession.getReplyHandler()).getReply(60);
assertNotNull(reply);
System.out.println(reply.getTrace());
assertEquals(1, reply.getNumErrors());
assertEquals(ErrorCode.NO_ADDRESS_FOR_SERVICE, reply.getError(0).getCode());
assertTrace(Arrays.asList("Selecting [dst/session, dst/unknown].", "[NO_ADDRESS_FOR_SERVICE @ localhost]", "Sending reply", "Merged [dst/session, dst/unknown]."), reply.getTrace());
}
use of com.yahoo.messagebus.test.Receptor in project vespa by vespa-engine.
the class RoutingTestCase method requireThatRetryCallsSelect.
@Test
public void requireThatRetryCallsSelect() {
SimpleProtocol protocol = new SimpleProtocol();
protocol.addPolicyFactory("Custom", new CustomPolicyFactory());
srcServer.mb.putProtocol(protocol);
assertTrue(srcSession.send(createMessage("msg"), Route.parse("[Custom:dst/session]")).isAccepted());
Message msg = ((Receptor) dstSession.getMessageHandler()).getMessage(60);
assertNotNull(msg);
Reply reply = new EmptyReply();
reply.swapState(msg);
reply.addError(new Error(ErrorCode.APP_TRANSIENT_ERROR, "err"));
dstSession.reply(reply);
assertNotNull(msg = ((Receptor) dstSession.getMessageHandler()).getMessage(60));
dstSession.acknowledge(msg);
assertNotNull(reply = ((Receptor) srcSession.getReplyHandler()).getReply(60));
System.out.println(reply.getTrace());
assertFalse(reply.hasErrors());
assertTrace(Arrays.asList("Selecting [dst/session].", "[APP_TRANSIENT_ERROR @ localhost]", "-[APP_TRANSIENT_ERROR @ localhost]", "Merged [dst/session].", "Selecting [dst/session].", "Sending reply", "Merged [dst/session]."), reply.getTrace());
}
Aggregations