Search in sources :

Example 1 with MockBackend

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());
    }
}
Also used : Query(com.yahoo.search.Query) Result(com.yahoo.search.Result) MockBackend(com.yahoo.prelude.fastsearch.test.fs4mock.MockBackend) WordItem(com.yahoo.prelude.query.WordItem) Ignore(org.junit.Ignore)

Example 2 with MockBackend

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);
}
Also used : DocumentdbInfoConfig(com.yahoo.prelude.fastsearch.DocumentdbInfoConfig) MockBackend(com.yahoo.prelude.fastsearch.test.fs4mock.MockBackend) ConfigGetter(com.yahoo.config.subscription.ConfigGetter)

Example 3 with MockBackend

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);
}
Also used : Query(com.yahoo.search.Query) Result(com.yahoo.search.Result) DocumentdbInfoConfig(com.yahoo.prelude.fastsearch.DocumentdbInfoConfig) MockBackend(com.yahoo.prelude.fastsearch.test.fs4mock.MockBackend) Test(org.junit.Test)

Example 4 with MockBackend

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);
}
Also used : Query(com.yahoo.search.Query) TraceNode(com.yahoo.yolean.trace.TraceNode) EachOperation(com.yahoo.search.grouping.request.EachOperation) Execution(com.yahoo.search.searchchain.Execution) MockBackend(com.yahoo.prelude.fastsearch.test.fs4mock.MockBackend) GroupingRequest(com.yahoo.search.grouping.GroupingRequest) AllOperation(com.yahoo.search.grouping.request.AllOperation) Test(org.junit.Test)

Example 5 with MockBackend

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());
        }
    }
}
Also used : Query(com.yahoo.search.Query) MockBackend(com.yahoo.prelude.fastsearch.test.fs4mock.MockBackend) Result(com.yahoo.search.Result) Test(org.junit.Test)

Aggregations

MockBackend (com.yahoo.prelude.fastsearch.test.fs4mock.MockBackend)9 Query (com.yahoo.search.Query)8 Test (org.junit.Test)7 Result (com.yahoo.search.Result)6 DocumentdbInfoConfig (com.yahoo.prelude.fastsearch.DocumentdbInfoConfig)3 GroupingRequest (com.yahoo.search.grouping.GroupingRequest)2 AllOperation (com.yahoo.search.grouping.request.AllOperation)2 EachOperation (com.yahoo.search.grouping.request.EachOperation)2 ErrorMessage (com.yahoo.search.result.ErrorMessage)2 Execution (com.yahoo.search.searchchain.Execution)2 TraceNode (com.yahoo.yolean.trace.TraceNode)2 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)2 ConfigGetter (com.yahoo.config.subscription.ConfigGetter)1 WordItem (com.yahoo.prelude.query.WordItem)1 Ignore (org.junit.Ignore)1