use of com.yahoo.messagebus.test.Receptor in project vespa by vespa-engine.
the class ResenderTestCase method testFatalError.
public void testFatalError() {
assertTrue(srcSession.send(createMessage("msg"), Route.parse("dst/session")).isAccepted());
Message msg = ((Receptor) dstSession.getMessageHandler()).getMessage(60);
assertNotNull(msg);
replyFromDestination(msg, ErrorCode.APP_FATAL_ERROR, 0);
Reply reply = ((Receptor) srcSession.getReplyHandler()).getReply(60);
assertNotNull(reply);
assertTrue(reply.hasFatalErrors());
assertNull(((Receptor) dstSession.getMessageHandler()).getMessage(0));
}
use of com.yahoo.messagebus.test.Receptor in project vespa by vespa-engine.
the class ResenderTestCase 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()));
retryPolicy = new RetryTransientErrorsPolicy();
retryPolicy.setBaseDelay(0);
srcServer = new TestServer(new MessageBusParams().setRetryPolicy(retryPolicy).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 ResenderTestCase method testRetryTag.
// //////////////////////////////////////////////////////////////////////////////
//
// Tests
//
// //////////////////////////////////////////////////////////////////////////////
public void testRetryTag() {
assertTrue(srcSession.send(createMessage("msg"), Route.parse("dst/session")).isAccepted());
Message msg = ((Receptor) dstSession.getMessageHandler()).getMessage(60);
assertNotNull(msg);
for (int i = 0; i < 5; ++i) {
assertEquals(i, msg.getRetry());
assertEquals(true, msg.getRetryEnabled());
replyFromDestination(msg, ErrorCode.APP_TRANSIENT_ERROR, 0);
assertNotNull(msg = ((Receptor) dstSession.getMessageHandler()).getMessage(60));
}
dstSession.acknowledge(msg);
Reply reply = ((Receptor) srcSession.getReplyHandler()).getReply(60);
assertNotNull(reply);
assertFalse(reply.hasErrors());
assertNull(((Receptor) dstSession.getMessageHandler()).getMessage(0));
System.out.println(reply.getTrace());
}
use of com.yahoo.messagebus.test.Receptor in project vespa by vespa-engine.
the class ResenderTestCase method testRetryEnabledTag.
public void testRetryEnabledTag() {
Message msg = createMessage("msg");
msg.setRetryEnabled(false);
assertTrue(srcSession.send(msg, Route.parse("dst/session")).isAccepted());
assertNotNull(msg = ((Receptor) dstSession.getMessageHandler()).getMessage(60));
assertEquals(false, msg.getRetryEnabled());
replyFromDestination(msg, ErrorCode.APP_TRANSIENT_ERROR, 0);
Reply reply = ((Receptor) srcSession.getReplyHandler()).getReply(60);
assertNotNull(reply);
assertTrue(reply.hasErrors());
assertNull(((Receptor) dstSession.getMessageHandler()).getMessage(0));
System.out.println(reply.getTrace());
}
use of com.yahoo.messagebus.test.Receptor in project vespa by vespa-engine.
the class ChokeTestCase method testMaxCount.
@Test
public void testMaxCount() {
int max = 10;
dstServer.mb.setMaxPendingCount(max);
List<Message> lst = new ArrayList<>();
for (int i = 0; i < max * 2; ++i) {
if (i < max) {
assertEquals(i, dstServer.mb.getPendingCount());
} else {
assertEquals(max, dstServer.mb.getPendingCount());
}
assertTrue(srcSession.send(createMessage("msg"), Route.parse("dst/session")).isAccepted());
if (i < max) {
Message msg = ((Receptor) dstSession.getMessageHandler()).getMessage(60);
assertNotNull(msg);
lst.add(msg);
} else {
Reply reply = ((Receptor) srcSession.getReplyHandler()).getReply(60);
assertNotNull(reply);
assertEquals(1, reply.getNumErrors());
assertEquals(ErrorCode.SESSION_BUSY, reply.getError(0).getCode());
}
}
for (int i = 0; i < 5; ++i) {
Message msg = lst.remove(0);
dstSession.acknowledge(msg);
Reply reply = ((Receptor) srcSession.getReplyHandler()).getReply(60);
assertNotNull(reply);
assertFalse(reply.hasErrors());
assertNotNull(msg = reply.getMessage());
assertTrue(srcSession.send(msg, Route.parse("dst/session")).isAccepted());
assertNotNull(msg = ((Receptor) dstSession.getMessageHandler()).getMessage(60));
lst.add(msg);
}
while (!lst.isEmpty()) {
assertEquals(lst.size(), dstServer.mb.getPendingCount());
Message msg = lst.remove(0);
dstSession.acknowledge(msg);
Reply reply = ((Receptor) srcSession.getReplyHandler()).getReply(60);
assertNotNull(reply);
assertFalse(reply.hasErrors());
}
assertEquals(0, dstServer.mb.getPendingCount());
}
Aggregations