use of com.yahoo.messagebus.test.Receptor in project vespa by vespa-engine.
the class ResenderTestCase method testDisableRetry.
public void testDisableRetry() {
retryPolicy.setEnabled(false);
assertTrue(srcSession.send(createMessage("msg"), Route.parse("dst/session")).isAccepted());
Message msg = ((Receptor) dstSession.getMessageHandler()).getMessage(60);
assertNotNull(msg);
replyFromDestination(msg, ErrorCode.APP_TRANSIENT_ERROR, 0);
Reply reply = ((Receptor) srcSession.getReplyHandler()).getReply(60);
assertNotNull(reply);
assertTrue(reply.hasErrors());
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 testTransientError.
public void testTransientError() {
assertTrue(srcSession.send(createMessage("msg"), Route.parse("dst/session")).isAccepted());
Message msg = ((Receptor) dstSession.getMessageHandler()).getMessage(60);
assertNotNull(msg);
replyFromDestination(msg, ErrorCode.APP_TRANSIENT_ERROR, 0);
assertNotNull(msg = ((Receptor) dstSession.getMessageHandler()).getMessage(60));
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 testRetryDelay.
public void testRetryDelay() {
retryPolicy.setBaseDelay(0.01);
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) {
replyFromDestination(msg, ErrorCode.APP_TRANSIENT_ERROR, -1);
assertNotNull(msg = ((Receptor) dstSession.getMessageHandler()).getMessage(60));
}
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));
String trace = reply.getTrace().toString();
assertTrue(trace.contains("retry 1 in 0.01"));
assertTrue(trace.contains("retry 2 in 0.02"));
assertTrue(trace.contains("retry 3 in 0.03"));
assertTrue(trace.contains("retry 4 in 0.04"));
assertTrue(trace.contains("retry 5 in 0.05"));
}
use of com.yahoo.messagebus.test.Receptor 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.Receptor 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();
}
Aggregations