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