Search in sources :

Example 36 with Receptor

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));
}
Also used : SimpleMessage(com.yahoo.messagebus.test.SimpleMessage) Receptor(com.yahoo.messagebus.test.Receptor)

Example 37 with Receptor

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));
}
Also used : SimpleMessage(com.yahoo.messagebus.test.SimpleMessage) Receptor(com.yahoo.messagebus.test.Receptor)

Example 38 with Receptor

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"));
}
Also used : SimpleMessage(com.yahoo.messagebus.test.SimpleMessage) Receptor(com.yahoo.messagebus.test.Receptor)

Example 39 with Receptor

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));
}
Also used : SimpleProtocol(com.yahoo.messagebus.test.SimpleProtocol) Receptor(com.yahoo.messagebus.test.Receptor) RPCNetworkParams(com.yahoo.messagebus.network.rpc.RPCNetworkParams) Slobrok(com.yahoo.jrt.slobrok.server.Slobrok) Identity(com.yahoo.messagebus.network.Identity) TestServer(com.yahoo.messagebus.network.rpc.test.TestServer) Before(org.junit.Before)

Example 40 with Receptor

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();
}
Also used : SimpleProtocol(com.yahoo.messagebus.test.SimpleProtocol) Receptor(com.yahoo.messagebus.test.Receptor) RetryTransientErrorsPolicy(com.yahoo.messagebus.routing.RetryTransientErrorsPolicy) RPCNetworkParams(com.yahoo.messagebus.network.rpc.RPCNetworkParams) SimpleMessage(com.yahoo.messagebus.test.SimpleMessage) Slobrok(com.yahoo.jrt.slobrok.server.Slobrok) TestServer(com.yahoo.messagebus.network.rpc.test.TestServer) Test(org.junit.Test)

Aggregations

Receptor (com.yahoo.messagebus.test.Receptor)69 SimpleMessage (com.yahoo.messagebus.test.SimpleMessage)46 Test (org.junit.Test)35 SimpleProtocol (com.yahoo.messagebus.test.SimpleProtocol)30 TestServer (com.yahoo.messagebus.network.rpc.test.TestServer)18 Slobrok (com.yahoo.jrt.slobrok.server.Slobrok)17 CustomPolicyFactory (com.yahoo.messagebus.routing.test.CustomPolicyFactory)12 RPCNetworkParams (com.yahoo.messagebus.network.rpc.RPCNetworkParams)10 Error (com.yahoo.messagebus.Error)9 Identity (com.yahoo.messagebus.network.Identity)9 SimpleReply (com.yahoo.messagebus.test.SimpleReply)6 DocumentProtocol (com.yahoo.documentapi.messagebus.protocol.DocumentProtocol)3 ArrayList (java.util.ArrayList)3 Before (org.junit.Before)3 DocumentTypeManager (com.yahoo.document.DocumentTypeManager)2 Route (com.yahoo.messagebus.routing.Route)2 Version (com.yahoo.component.Version)1 VersionSpecification (com.yahoo.component.VersionSpecification)1 DocumentMessage (com.yahoo.documentapi.messagebus.protocol.DocumentMessage)1 DocumentReply (com.yahoo.documentapi.messagebus.protocol.DocumentReply)1