Search in sources :

Example 1 with Ping

use of com.yahoo.prelude.Ping in project vespa by vespa-engine.

the class FastSearcherTestCase method testPing.

@Test
public void testPing() throws IOException, InterruptedException {
    Logger.getLogger(FastSearcher.class.getName()).setLevel(Level.ALL);
    BackendTestCase.MockServer server = new BackendTestCase.MockServer();
    FS4ResourcePool listeners = new FS4ResourcePool(new Fs4Config(new Fs4Config.Builder()));
    Backend backend = listeners.getBackend(server.host.getHostString(), server.host.getPort());
    FastSearcher fastSearcher = new FastSearcher(backend, new FS4ResourcePool(1), new MockDispatcher(Collections.emptyList()), new SummaryParameters(null), new ClusterParams("testhittype"), new CacheParams(0, 0.0d), documentdbInfoConfig);
    server.dispatch.packetData = BackendTestCase.PONG;
    server.dispatch.setNoChannel();
    Chain<Searcher> chain = new Chain<>(fastSearcher);
    Execution e = new Execution(chain, Execution.Context.createContextStub());
    Pong pong = e.ping(new Ping());
    assertTrue(pong.getPongPacket().isPresent());
    assertEquals(127, pong.getPongPacket().get().getDocstamp());
    backend.shutdown();
    server.dispatch.socket.close();
    server.dispatch.connection.close();
    server.worker.join();
    pong.setPingInfo("blbl");
    assertEquals("Result of pinging using blbl", pong.toString());
}
Also used : Chain(com.yahoo.component.chain.Chain) Searcher(com.yahoo.search.Searcher) Fs4Config(com.yahoo.container.search.Fs4Config) MockBackend(com.yahoo.prelude.fastsearch.test.fs4mock.MockBackend) Execution(com.yahoo.search.searchchain.Execution) Ping(com.yahoo.prelude.Ping) Pong(com.yahoo.prelude.Pong) Test(org.junit.Test)

Example 2 with Ping

use of com.yahoo.prelude.Ping in project vespa by vespa-engine.

the class VdsStreamingSearcherTestCase method testTrivialitiesToIncreaseCoverage.

@Test
public void testTrivialitiesToIncreaseCoverage() {
    VdsStreamingSearcher searcher = new VdsStreamingSearcher();
    assertNull(searcher.getSearchClusterConfigId());
    String searchClusterConfigId = "searchClusterConfigId";
    searcher.setSearchClusterConfigId(searchClusterConfigId);
    assertEquals(searchClusterConfigId, searcher.getSearchClusterConfigId());
    assertNull(searcher.getStorageClusterRouteSpec());
    String storageClusterRouteSpec = "storageClusterRouteSpec";
    searcher.setStorageClusterRouteSpec(storageClusterRouteSpec);
    assertEquals(storageClusterRouteSpec, searcher.getStorageClusterRouteSpec());
    Pong pong = searcher.ping(new Ping(), new Execution(new Execution.Context(null, null, null, null, null)));
    assertEquals(0, pong.getErrorSize());
}
Also used : Execution(com.yahoo.search.searchchain.Execution) Ping(com.yahoo.prelude.Ping) Pong(com.yahoo.prelude.Pong) Test(org.junit.Test)

Example 3 with Ping

use of com.yahoo.prelude.Ping in project vespa by vespa-engine.

the class PingTestCase method checkSearchAndPing.

private void checkSearchAndPing(boolean firstSearch, boolean pongCheck, boolean secondSearch, int port) {
    String resultThing;
    String comment;
    TestHTTPClientSearcher searcher = new TestHTTPClientSearcher("test", "localhost", port);
    try {
        Query query = new Query("/?query=test");
        query.setWindow(0, 10);
        // high timeout to allow for overloaded test machine
        query.setTimeout(TIMEOUT_MS);
        Ping ping = new Ping(TIMEOUT_MS);
        long start = System.currentTimeMillis();
        Execution exe = new Execution(searcher, Execution.Context.createContextStub());
        exe.search(query);
        resultThing = firstSearch ? "ok" : null;
        comment = firstSearch ? "First search should have succeeded." : "First search should fail.";
        assertEquals(comment, resultThing, query.properties().get("gotResponse"));
        Pong pong = searcher.ping(ping, searcher.getConnection());
        if (pongCheck) {
            assertEquals("Ping should not have failed.", 0, pong.getErrorSize());
        } else {
            assertEquals("Ping should have failed.", 1, pong.getErrorSize());
        }
        exe = new Execution(searcher, Execution.Context.createContextStub());
        exe.search(query);
        resultThing = secondSearch ? "ok" : null;
        comment = secondSearch ? "Second search should have succeeded." : "Second search should fail.";
        assertEquals(resultThing, query.properties().get("gotResponse"));
        long duration = System.currentTimeMillis() - start;
        // target for duration based on the timeout values + some slack
        assertTrue("This test probably hanged.", duration < TIMEOUT_MS + 4000);
        searcher.shutdownConnectionManagers();
    } finally {
        searcher.deconstruct();
    }
}
Also used : Execution(com.yahoo.search.searchchain.Execution) Query(com.yahoo.search.Query) Ping(com.yahoo.prelude.Ping) Pong(com.yahoo.prelude.Pong)

Example 4 with Ping

use of com.yahoo.prelude.Ping in project vespa by vespa-engine.

the class TimingSearcherTestCase method testMeasurementPingPath.

public void testMeasurementPingPath() {
    Parameters p = new Parameters("timingtest", TimeTracker.Activity.PING);
    TimingSearcher ts = new TimingSearcher(new ComponentId("lblblbl"), p, Statistics.nullImplementation);
    MockValue v = new MockValue();
    ts.setMeasurements(v);
    Execution exec = new Execution(ts, Execution.Context.createContextStub());
    Result r = exec.search(new Query("/?query=a"));
    Hit f = new Hit("blblbl");
    f.setFillable();
    r.hits().add(f);
    exec.fill(r, "whatever");
    exec.fill(r, "lalala");
    exec.ping(new Ping());
    exec.ping(new Ping());
    exec.ping(new Ping());
    assertEquals(3, v.putCount);
}
Also used : Hit(com.yahoo.search.result.Hit) Parameters(com.yahoo.search.statistics.TimingSearcher.Parameters) Execution(com.yahoo.search.searchchain.Execution) Query(com.yahoo.search.Query) Ping(com.yahoo.prelude.Ping) ComponentId(com.yahoo.component.ComponentId) Result(com.yahoo.search.Result)

Example 5 with Ping

use of com.yahoo.prelude.Ping in project vespa by vespa-engine.

the class TimingSearcherTestCase method testMeasurementSearchPath.

public void testMeasurementSearchPath() {
    Parameters p = new Parameters("timingtest", TimeTracker.Activity.SEARCH);
    TimingSearcher ts = new TimingSearcher(new ComponentId("lblblbl"), p, Statistics.nullImplementation);
    MockValue v = new MockValue();
    ts.setMeasurements(v);
    Execution exec = new Execution(ts, Execution.Context.createContextStub());
    Result r = exec.search(new Query("/?query=a"));
    Hit f = new Hit("blblbl");
    f.setFillable();
    r.hits().add(f);
    exec.fill(r, "whatever");
    exec.fill(r, "lalala");
    exec.ping(new Ping());
    exec.ping(new Ping());
    exec.ping(new Ping());
    assertEquals(1, v.putCount);
}
Also used : Hit(com.yahoo.search.result.Hit) Parameters(com.yahoo.search.statistics.TimingSearcher.Parameters) Execution(com.yahoo.search.searchchain.Execution) Query(com.yahoo.search.Query) Ping(com.yahoo.prelude.Ping) ComponentId(com.yahoo.component.ComponentId) Result(com.yahoo.search.Result)

Aggregations

Ping (com.yahoo.prelude.Ping)6 Execution (com.yahoo.search.searchchain.Execution)6 Query (com.yahoo.search.Query)4 ComponentId (com.yahoo.component.ComponentId)3 Pong (com.yahoo.prelude.Pong)3 Result (com.yahoo.search.Result)3 Hit (com.yahoo.search.result.Hit)3 Parameters (com.yahoo.search.statistics.TimingSearcher.Parameters)3 Test (org.junit.Test)2 Chain (com.yahoo.component.chain.Chain)1 Fs4Config (com.yahoo.container.search.Fs4Config)1 MockBackend (com.yahoo.prelude.fastsearch.test.fs4mock.MockBackend)1 Searcher (com.yahoo.search.Searcher)1