Search in sources :

Example 11 with RoutingTableSpec

use of com.yahoo.messagebus.routing.RoutingTableSpec in project vespa by vespa-engine.

the class ErrorTestCase method requireThatErrorIsPropagated.

@Test
public void requireThatErrorIsPropagated() throws Exception {
    RoutingTableSpec table = new RoutingTableSpec(SimpleProtocol.NAME);
    table.addHop("itr", "test/itr/session", Arrays.asList("test/itr/session"));
    table.addHop("dst", "test/dst/session", Arrays.asList("test/dst/session"));
    table.addRoute("test", Arrays.asList("itr", "dst"));
    Slobrok slobrok = new Slobrok();
    TestServer src = new TestServer("test/src", table, slobrok, null);
    TestServer itr = new TestServer("test/itr", table, slobrok, null);
    TestServer dst = new TestServer("test/dst", table, slobrok, null);
    Receptor ss_rr = new Receptor();
    SourceSession ss = src.mb.createSourceSession(ss_rr);
    Receptor is_mr = new Receptor();
    Receptor is_rr = new Receptor();
    IntermediateSession is = itr.mb.createIntermediateSession("session", true, is_mr, is_rr);
    Receptor ds_mr = new Receptor();
    DestinationSession ds = dst.mb.createDestinationSession("session", true, ds_mr);
    src.waitSlobrok("test/itr/session", 1);
    src.waitSlobrok("test/dst/session", 1);
    itr.waitSlobrok("test/dst/session", 1);
    for (int i = 0; i < 5; i++) {
        assertTrue(ss.send(new SimpleMessage("msg"), "test").isAccepted());
        Message msg = is_mr.getMessage(60);
        assertNotNull(msg);
        is.forward(msg);
        assertNotNull(msg = ds_mr.getMessage(60));
        Reply reply = new EmptyReply();
        msg.swapState(reply);
        reply.addError(new Error(ErrorCode.APP_FATAL_ERROR, "fatality"));
        ds.reply(reply);
        assertNotNull(reply = is_rr.getReply(60));
        assertEquals(reply.getNumErrors(), 1);
        assertEquals(reply.getError(0).getService(), "test/dst/session");
        reply.addError(new Error(ErrorCode.APP_FATAL_ERROR, "fatality"));
        is.forward(reply);
        assertNotNull(reply = ss_rr.getReply(60));
        assertEquals(reply.getNumErrors(), 2);
        assertEquals(reply.getError(0).getService(), "test/dst/session");
        assertEquals(reply.getError(1).getService(), "test/itr/session");
    }
    ss.destroy();
    is.destroy();
    ds.destroy();
    dst.destroy();
    itr.destroy();
    src.destroy();
    slobrok.stop();
}
Also used : SimpleMessage(com.yahoo.messagebus.test.SimpleMessage) SimpleMessage(com.yahoo.messagebus.test.SimpleMessage) TestServer(com.yahoo.messagebus.network.rpc.test.TestServer) RoutingTableSpec(com.yahoo.messagebus.routing.RoutingTableSpec) Receptor(com.yahoo.messagebus.test.Receptor) Slobrok(com.yahoo.jrt.slobrok.server.Slobrok) Test(org.junit.Test)

Aggregations

RoutingTableSpec (com.yahoo.messagebus.routing.RoutingTableSpec)11 RouteSpec (com.yahoo.messagebus.routing.RouteSpec)6 Slobrok (com.yahoo.jrt.slobrok.server.Slobrok)4 TestServer (com.yahoo.messagebus.network.rpc.test.TestServer)4 Test (org.junit.Test)4 RoutingTable (com.yahoo.messagebus.routing.RoutingTable)3 Route (com.yahoo.messagebus.routing.Route)2 VespaModel (com.yahoo.vespa.model.VespaModel)2 DocumentProtocol (com.yahoo.vespa.model.routing.DocumentProtocol)2 Routing (com.yahoo.vespa.model.routing.Routing)2 DocumentrouteselectorpolicyConfig (com.yahoo.documentapi.messagebus.protocol.DocumentrouteselectorpolicyConfig)1 MessagebusConfig (com.yahoo.messagebus.MessagebusConfig)1 HopSpec (com.yahoo.messagebus.routing.HopSpec)1 RoutingSpec (com.yahoo.messagebus.routing.RoutingSpec)1 Receptor (com.yahoo.messagebus.test.Receptor)1 SimpleMessage (com.yahoo.messagebus.test.SimpleMessage)1 HostResource (com.yahoo.vespa.model.HostResource)1 ContainerCluster (com.yahoo.vespa.model.container.ContainerCluster)1 ContentCluster (com.yahoo.vespa.model.content.cluster.ContentCluster)1