Search in sources :

Example 1 with Trace

use of com.yahoo.processing.execution.Execution.Trace in project vespa by vespa-engine.

the class FastSearcherTestCase method getTraceString.

private String getTraceString(String summary) {
    FastSearcher fastSearcher = createFastSearcher();
    Query query = new Query("?query=ignored");
    query.getPresentation().setSummary(summary);
    query.setTraceLevel(2);
    Result result = doSearch(fastSearcher, query, 0, 10);
    doFill(fastSearcher, result);
    Trace trace = query.getContext(false).getTrace();
    final AtomicReference<String> fillTraceString = new AtomicReference<>();
    trace.traceNode().accept(new TraceVisitor() {

        @Override
        public void visit(TraceNode traceNode) {
            if (traceNode.payload() instanceof String && traceNode.payload().toString().contains("fill to dispatch"))
                fillTraceString.set((String) traceNode.payload());
        }
    });
    return fillTraceString.get();
}
Also used : Trace(com.yahoo.processing.execution.Execution.Trace) Query(com.yahoo.search.Query) TraceVisitor(com.yahoo.yolean.trace.TraceVisitor) AtomicReference(java.util.concurrent.atomic.AtomicReference) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) TraceNode(com.yahoo.yolean.trace.TraceNode) Result(com.yahoo.search.Result)

Example 2 with Trace

use of com.yahoo.processing.execution.Execution.Trace in project vespa by vespa-engine.

the class JSONDebugSearcherTestCase method test.

@Test
public final void test() {
    Execution e = new Execution(searchChain, Execution.Context.createContextStub());
    e.search(new Query(NODUMPJSON));
    Trace t = e.trace();
    LookForJson visitor = new LookForJson();
    t.accept(visitor);
    assertEquals(false, visitor.gotJson);
    e = new Execution(searchChain, Execution.Context.createContextStub());
    e.search(new Query(DUMPJSON));
    t = e.trace();
    t.accept(visitor);
    assertEquals(true, visitor.gotJson);
}
Also used : Trace(com.yahoo.processing.execution.Execution.Trace) Execution(com.yahoo.search.searchchain.Execution) Query(com.yahoo.search.Query) Test(org.junit.Test)

Aggregations

Trace (com.yahoo.processing.execution.Execution.Trace)2 Query (com.yahoo.search.Query)2 Result (com.yahoo.search.Result)1 Execution (com.yahoo.search.searchchain.Execution)1 TraceNode (com.yahoo.yolean.trace.TraceNode)1 TraceVisitor (com.yahoo.yolean.trace.TraceVisitor)1 AtomicReference (java.util.concurrent.atomic.AtomicReference)1 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)1 Test (org.junit.Test)1