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();
}
Aggregations