use of com.yahoo.prelude.fastsearch.test.fs4mock.MockBackend in project vespa by vespa-engine.
the class FastSearcherTestCase method testSinglePhaseCachedSupersets.
@Ignore
public void testSinglePhaseCachedSupersets() {
Logger.getLogger(FastSearcher.class.getName()).setLevel(Level.ALL);
MockFSChannel.resetDocstamp();
FastSearcher fastSearcher = new FastSearcher(new MockBackend(), new FS4ResourcePool(1), new MockDispatcher(Collections.emptyList()), new SummaryParameters(null), new ClusterParams("testhittype"), new CacheParams(100, 1e64), documentdbInfoConfig);
CacheControl c = fastSearcher.getCacheControl();
Result result = doSearch(fastSearcher, new Query("?query=ignored"), 0, 2);
Query q = new Query("?query=ignored");
((WordItem) q.getModel().getQueryTree().getRoot()).setUniqueID(1);
QueryPacket queryPacket = QueryPacket.create(q);
CacheKey k = new CacheKey(queryPacket);
PacketWrapper p = c.lookup(k, q);
assertEquals(1, p.getResultPackets().size());
result = doSearch(fastSearcher, new Query("?query=ignored"), 1, 1);
p = c.lookup(k, q);
// ensure we don't get redundant QueryResultPacket instances
// in the cache
assertEquals(1, p.getResultPackets().size());
assertEquals(1, result.getConcreteHitCount());
for (int i = 0; i < result.getHitCount(); i++) {
assertTrue(result.hits().get(i).isCached());
}
result = doSearch(fastSearcher, new Query("?query=ignored"), 0, 1);
p = c.lookup(k, q);
assertEquals(1, p.getResultPackets().size());
assertEquals(1, result.getConcreteHitCount());
for (int i = 0; i < result.getHitCount(); i++) {
assertTrue(result.hits().get(i).isCached());
}
}
use of com.yahoo.prelude.fastsearch.test.fs4mock.MockBackend in project vespa by vespa-engine.
the class FastSearcherTestCase method createFastSearcher.
private FastSearcher createFastSearcher() {
mockBackend = new MockBackend();
ConfigGetter<DocumentdbInfoConfig> getter = new ConfigGetter<>(DocumentdbInfoConfig.class);
DocumentdbInfoConfig config = getter.getConfig("file:src/test/java/com/yahoo/prelude/fastsearch/test/documentdb-info.cfg");
MockFSChannel.resetDocstamp();
Logger.getLogger(FastSearcher.class.getName()).setLevel(Level.ALL);
return new FastSearcher(mockBackend, new FS4ResourcePool(1), new MockDispatcher(Collections.emptyList()), new SummaryParameters(null), new ClusterParams("testhittype"), new CacheParams(100, 1e64), config);
}
use of com.yahoo.prelude.fastsearch.test.fs4mock.MockBackend in project vespa by vespa-engine.
the class FastSearcherTestCase method testQueryWithRestrict.
@Test
public void testQueryWithRestrict() {
mockBackend = new MockBackend();
DocumentdbInfoConfig documentdbConfigWithOneDb = new DocumentdbInfoConfig(new DocumentdbInfoConfig.Builder().documentdb(new DocumentdbInfoConfig.Documentdb.Builder().name("testDb")));
FastSearcher fastSearcher = new FastSearcher(mockBackend, new FS4ResourcePool(1), new MockDispatcher(Collections.emptyList()), new SummaryParameters(null), new ClusterParams("testhittype"), new CacheParams(100, 1e64), documentdbConfigWithOneDb);
Query query = new Query("?query=foo&model.restrict=testDb");
query.prepare();
Result result = doSearch(fastSearcher, query, 0, 10);
Packet receivedPacket = mockBackend.getChannel().getLastQueryPacket();
byte[] encoded = QueryTestCase.packetToBytes(receivedPacket);
byte[] correct = new byte[] { 0, 0, 0, 100, 0, 0, 0, -38, 0, 0, 0, 0, 0, 16, 0, 6, 0, 10, // time left
QueryTestCase.ignored, // time left
QueryTestCase.ignored, // time left
QueryTestCase.ignored, // time left
QueryTestCase.ignored, 0, 0, 0x40, 0x03, 7, 100, 101, 102, 97, 117, 108, 116, 0, 0, 0, 1, 0, 0, 0, 5, 109, 97, 116, 99, 104, 0, 0, 0, 1, 0, 0, 0, 24, 100, 111, 99, 117, 109, 101, 110, 116, 100, 98, 46, 115, 101, 97, 114, 99, 104, 100, 111, 99, 116, 121, 112, 101, 0, 0, 0, 6, 116, 101, 115, 116, 68, 98, 0, 0, 0, 1, 0, 0, 0, 7, 68, 1, 0, 3, 102, 111, 111 };
QueryTestCase.assertEqualArrays(correct, encoded);
}
use of com.yahoo.prelude.fastsearch.test.fs4mock.MockBackend in project vespa by vespa-engine.
the class FastSearcherTestCase method testSinglePassGroupingIsNotForcedWithSingleNodeGroups.
@Test
public void testSinglePassGroupingIsNotForcedWithSingleNodeGroups() {
MockDispatcher dispatcher = new MockDispatcher(ImmutableList.of(new SearchCluster.Node("host0", 123, 0), new SearchCluster.Node("host1", 123, 0)));
FastSearcher fastSearcher = new FastSearcher(new MockBackend(), new FS4ResourcePool(1), dispatcher, new SummaryParameters(null), new ClusterParams("testhittype"), new CacheParams(100, 1e64), documentdbInfoConfig);
Query q = new Query("?query=foo");
GroupingRequest request1 = GroupingRequest.newInstance(q);
request1.setRootOperation(new AllOperation());
GroupingRequest request2 = GroupingRequest.newInstance(q);
AllOperation all = new AllOperation();
all.addChild(new EachOperation());
all.addChild(new EachOperation());
request2.setRootOperation(all);
assertForceSinglePassIs(false, q);
fastSearcher.search(q, new Execution(Execution.Context.createContextStub()));
assertForceSinglePassIs(false, q);
}
use of com.yahoo.prelude.fastsearch.test.fs4mock.MockBackend in project vespa by vespa-engine.
the class FastSearcherTestCase method testMultiPhaseCachedSupersets.
@Test
public void testMultiPhaseCachedSupersets() {
Logger.getLogger(FastSearcher.class.getName()).setLevel(Level.ALL);
MockFSChannel.resetDocstamp();
FastSearcher fastSearcher = new FastSearcher(new MockBackend(), new FS4ResourcePool(1), new MockDispatcher(Collections.emptyList()), new SummaryParameters(null), new ClusterParams("testhittype"), new CacheParams(100, 1e64), documentdbInfoConfig);
Result result = doSearch(fastSearcher, new Query("?query=ignored"), 0, 2);
result = doSearch(fastSearcher, new Query("?query=ignored"), 1, 1);
assertEquals(1, result.getConcreteHitCount());
for (int i = 0; i < result.getHitCount(); i++) {
assertTrue(result.hits().get(i).isCached());
if (!result.hits().get(i).isMeta()) {
assertTrue(result.hits().get(i).getFilled().isEmpty());
}
}
result = doSearch(fastSearcher, new Query("?query=ignored"), 0, 1);
assertEquals(1, result.getConcreteHitCount());
for (int i = 0; i < result.getHitCount(); i++) {
assertTrue(result.hits().get(i).isCached());
if (!result.hits().get(i).isMeta()) {
assertTrue(result.hits().get(i).getFilled().isEmpty());
}
}
}
Aggregations