Search in sources :

Example 21 with Slobrok

use of com.yahoo.jrt.slobrok.server.Slobrok in project vespa by vespa-engine.

the class ServerTestDriverTestCase method requireThatFactoryMethodsWork.

@Test
public void requireThatFactoryMethodsWork() throws ListenFailedException {
    ServerTestDriver driver = ServerTestDriver.newInstance(new NonWorkingRequestHandler());
    assertNotNull(driver);
    assertTrue(driver.close());
    driver = ServerTestDriver.newInstanceWithProtocol(new SimpleProtocol(), new NonWorkingRequestHandler());
    assertNotNull(driver);
    assertTrue(driver.close());
    Slobrok slobrok = new Slobrok();
    driver = ServerTestDriver.newInstanceWithExternSlobrok(slobrok.configId(), new NonWorkingRequestHandler());
    assertNotNull(driver);
    assertTrue(driver.close());
}
Also used : SimpleProtocol(com.yahoo.messagebus.test.SimpleProtocol) Slobrok(com.yahoo.jrt.slobrok.server.Slobrok) NonWorkingRequestHandler(com.yahoo.jdisc.test.NonWorkingRequestHandler) Test(org.junit.Test)

Example 22 with Slobrok

use of com.yahoo.jrt.slobrok.server.Slobrok in project vespa by vespa-engine.

the class SharedIntermediateSessionTestCase method requireThatReplyHandlerCanNotBeSet.

@Test
public void requireThatReplyHandlerCanNotBeSet() throws ListenFailedException {
    Slobrok slobrok = new Slobrok();
    try {
        newIntermediateSession(slobrok.configId(), new IntermediateSessionParams().setReplyHandler(new ReplyQueue()));
        fail();
    } catch (IllegalArgumentException e) {
        assertEquals("Reply handler must be null.", e.getMessage());
    }
}
Also used : ReplyQueue(com.yahoo.messagebus.jdisc.test.ReplyQueue) Slobrok(com.yahoo.jrt.slobrok.server.Slobrok) Test(org.junit.Test)

Example 23 with Slobrok

use of com.yahoo.jrt.slobrok.server.Slobrok in project vespa by vespa-engine.

the class PolicyTestCase method requireThatExternPolicyWithIllegalParamIsAnErrorPolicy.

@Test
public void requireThatExternPolicyWithIllegalParamIsAnErrorPolicy() throws ListenFailedException {
    Slobrok slobrok = new Slobrok();
    String spec = "tcp/localhost:" + slobrok.port();
    assertTrue(new DocumentProtocol(manager).createPolicy("Extern", null) instanceof ErrorPolicy);
    assertTrue(new DocumentProtocol(manager).createPolicy("Extern", "") instanceof ErrorPolicy);
    assertTrue(new DocumentProtocol(manager).createPolicy("Extern", spec) instanceof ErrorPolicy);
    assertTrue(new DocumentProtocol(manager).createPolicy("Extern", spec + ";") instanceof ErrorPolicy);
    assertTrue(new DocumentProtocol(manager).createPolicy("Extern", spec + ";bar") instanceof ErrorPolicy);
}
Also used : Slobrok(com.yahoo.jrt.slobrok.server.Slobrok) Test(org.junit.Test)

Example 24 with Slobrok

use of com.yahoo.jrt.slobrok.server.Slobrok in project vespa by vespa-engine.

the class PolicyTestCase method testExternSend.

@Test
public void testExternSend() throws Exception {
    // Setup local source node.
    Slobrok local = new Slobrok();
    TestServer src = new TestServer("src", null, local, new DocumentProtocol(manager));
    SourceSession ss = src.mb.createSourceSession(new Receptor(), new SourceSessionParams().setTimeout(TIMEOUT));
    // Setup remote cluster with routing config.
    Slobrok slobrok = new Slobrok();
    TestServer itr = new TestServer("itr", new RoutingTableSpec(DocumentProtocol.NAME).addRoute(new RouteSpec("default").addHop("dst")).addHop(new HopSpec("dst", "dst/session")), slobrok, new DocumentProtocol(manager));
    IntermediateSession is = itr.mb.createIntermediateSession("session", true, new Receptor(), new Receptor());
    TestServer dst = new TestServer("dst", null, slobrok, new DocumentProtocol(manager));
    DestinationSession ds = dst.mb.createDestinationSession("session", true, new Receptor());
    // Send message from local node to remote cluster and resolve route there.
    Message msg = new RemoveDocumentMessage(new DocumentId("doc:scheme:"));
    msg.getTrace().setLevel(9);
    msg.setRoute(Route.parse("[Extern:tcp/localhost:" + slobrok.port() + ";itr/session] default"));
    assertTrue(ss.send(msg).isAccepted());
    assertNotNull(msg = ((Receptor) is.getMessageHandler()).getMessage(TIMEOUT));
    is.forward(msg);
    assertNotNull(msg = ((Receptor) ds.getMessageHandler()).getMessage(TIMEOUT));
    ds.acknowledge(msg);
    Reply reply = ((Receptor) is.getReplyHandler()).getReply(TIMEOUT);
    assertNotNull(reply);
    is.forward(reply);
    assertNotNull(reply = ((Receptor) ss.getReplyHandler()).getReply(TIMEOUT));
    System.out.println(reply.getTrace().toString());
    // Perform necessary cleanup.
    src.destroy();
    itr.destroy();
    dst.destroy();
    slobrok.stop();
    local.stop();
}
Also used : TestServer(com.yahoo.messagebus.network.rpc.test.TestServer) Receptor(com.yahoo.messagebus.test.Receptor) Slobrok(com.yahoo.jrt.slobrok.server.Slobrok) Test(org.junit.Test)

Example 25 with Slobrok

use of com.yahoo.jrt.slobrok.server.Slobrok in project vespa by vespa-engine.

the class PolicyTestCase method requireThatExternPolicyMergesOneReplyAsProtocol.

@Test
public void requireThatExternPolicyMergesOneReplyAsProtocol() throws Exception {
    PolicyTestFrame frame = newPutDocumentFrame("doc:scheme:");
    Slobrok slobrok = new Slobrok();
    TestServer server = new TestServer("docproc/cluster.default/0", null, slobrok, new DocumentProtocol(manager));
    server.net.registerSession("chain.default");
    setupExternPolicy(frame, slobrok, "docproc/cluster.default/*/chain.default", 1);
    frame.assertMergeOneReply(server.net.getConnectionSpec() + "/chain.default");
    server.destroy();
    frame.destroy();
}
Also used : Slobrok(com.yahoo.jrt.slobrok.server.Slobrok) TestServer(com.yahoo.messagebus.network.rpc.test.TestServer) Test(org.junit.Test)

Aggregations

Slobrok (com.yahoo.jrt.slobrok.server.Slobrok)43 TestServer (com.yahoo.messagebus.network.rpc.test.TestServer)23 Test (org.junit.Test)20 Receptor (com.yahoo.messagebus.test.Receptor)17 RPCNetworkParams (com.yahoo.messagebus.network.rpc.RPCNetworkParams)15 Identity (com.yahoo.messagebus.network.Identity)12 SimpleProtocol (com.yahoo.messagebus.test.SimpleProtocol)11 SimpleMessage (com.yahoo.messagebus.test.SimpleMessage)6 RoutingTableSpec (com.yahoo.messagebus.routing.RoutingTableSpec)4 Before (org.junit.Before)4 ListenFailedException (com.yahoo.jrt.ListenFailedException)3 Spec (com.yahoo.jrt.Spec)3 DocumentTypeManager (com.yahoo.document.DocumentTypeManager)2 DocumentProtocol (com.yahoo.documentapi.messagebus.protocol.DocumentProtocol)2 MessageBusParams (com.yahoo.messagebus.MessageBusParams)2 SourceSessionParams (com.yahoo.messagebus.SourceSessionParams)2 SimpleReply (com.yahoo.messagebus.test.SimpleReply)2 MessageBusDocumentAccess (com.yahoo.documentapi.messagebus.MessageBusDocumentAccess)1 MessageBusParams (com.yahoo.documentapi.messagebus.MessageBusParams)1 NonWorkingRequestHandler (com.yahoo.jdisc.test.NonWorkingRequestHandler)1