Search in sources :

Example 11 with TraceNode

use of com.yahoo.yolean.trace.TraceNode in project vespa by vespa-engine.

the class JsonRendererTestCase method testTracingOfNestedNodesWithDataAndSubnodes.

@Test
public final void testTracingOfNestedNodesWithDataAndSubnodes() throws IOException, InterruptedException, ExecutionException {
    String expected = "{\n" + "    \"root\": {\n" + "        \"fields\": {\n" + "            \"totalCount\": 0\n" + "        },\n" + "        \"id\": \"toplevel\",\n" + "        \"relevance\": 1.0\n" + "    },\n" + "    \"trace\": {\n" + "        \"children\": [\n" + "            {\n" + "                \"message\": \"No query profile is used\"\n" + "            },\n" + "            {\n" + "                \"children\": [\n" + "                    {\n" + "                        \"message\": \"string payload\",\n" + "                        \"children\": [\n" + "                            {\n" + "                                \"children\": [\n" + "                                    {\n" + "                                        \"message\": \"in OO languages, nesting is for birds\"\n" + "                                    }\n" + "                                ]\n" + "                            }\n" + "                        ]\n" + "                    }\n" + "                ]\n" + "            }\n" + "        ]\n" + "    }\n" + "}\n";
    Query q = new Query("/?query=a&tracelevel=1");
    Execution execution = new Execution(Execution.Context.createContextStub());
    Result r = new Result(q);
    execution.search(q);
    final TraceNode child = new TraceNode("string payload", 0L);
    final TraceNode childOfChild = new TraceNode(null, 0L);
    child.add(childOfChild);
    childOfChild.add(new TraceNode("in OO languages, nesting is for birds", 0L));
    execution.trace().traceNode().add(child);
    String summary = render(execution, r);
    assertEqualJson(expected, summary);
}
Also used : Execution(com.yahoo.search.searchchain.Execution) Query(com.yahoo.search.Query) JSONString(com.yahoo.prelude.hitfield.JSONString) TraceNode(com.yahoo.yolean.trace.TraceNode) Result(com.yahoo.search.Result) Test(org.junit.Test)

Example 12 with TraceNode

use of com.yahoo.yolean.trace.TraceNode in project vespa by vespa-engine.

the class SlimeTraceSerializerTest method test_string.

@Test
public void test_string() throws IOException {
    TraceNode root = new TraceNode("bar", 5);
    assertThat(toJson(root), is("{\"timestamp\":5,\"payload\":\"bar\"}"));
    assertSerialize(root);
}
Also used : TraceNode(com.yahoo.yolean.trace.TraceNode) Test(org.junit.Test)

Example 13 with TraceNode

use of com.yahoo.yolean.trace.TraceNode in project vespa by vespa-engine.

the class SlimeTraceSerializerTest method test_serializer.

@Test
public void test_serializer() throws IOException {
    TraceNode root = new TraceNode(null, 1);
    root.add(new TraceNode("foo", 4));
    root.add(new TraceNode("bar", 5).add(new TraceNode("baz", 2).add(new TraceNode("quux", 10))));
    assertThat(toJson(root), is("{\"timestamp\":1,\"children\":[{\"timestamp\":5,\"payload\":\"bar\",\"children\":[{\"timestamp\":2,\"payload\":\"baz\",\"children\":[{\"timestamp\":10,\"payload\":\"quux\"}]}]},{\"timestamp\":4,\"payload\":\"foo\"}]}"));
    assertSerialize(root);
}
Also used : TraceNode(com.yahoo.yolean.trace.TraceNode) Test(org.junit.Test)

Example 14 with TraceNode

use of com.yahoo.yolean.trace.TraceNode in project vespa by vespa-engine.

the class SlimeTraceSerializerTest method test_bool.

@Test
public void test_bool() throws IOException {
    TraceNode root = new TraceNode(true, 5);
    assertThat(toJson(root), is("{\"timestamp\":5,\"payload\":true}"));
    assertSerialize(root);
}
Also used : TraceNode(com.yahoo.yolean.trace.TraceNode) Test(org.junit.Test)

Example 15 with TraceNode

use of com.yahoo.yolean.trace.TraceNode in project vespa by vespa-engine.

the class SlimeTraceSerializerTest method test_bytearray.

@Test
public void test_bytearray() throws IOException {
    TraceNode root = new TraceNode(new byte[] { 3, 5 }, 5);
    assertThat(toJson(root), is("{\"timestamp\":5,\"payload\":\"0x0305\"}"));
    assertSerialize(root);
}
Also used : TraceNode(com.yahoo.yolean.trace.TraceNode) Test(org.junit.Test)

Aggregations

TraceNode (com.yahoo.yolean.trace.TraceNode)19 Test (org.junit.Test)11 Query (com.yahoo.search.Query)4 Result (com.yahoo.search.Result)4 JSONString (com.yahoo.prelude.hitfield.JSONString)3 Execution (com.yahoo.search.searchchain.Execution)3 XMLWriter (com.yahoo.text.XMLWriter)3 Trace (com.yahoo.processing.execution.Execution.Trace)1 DefaultRenderer (com.yahoo.search.rendering.DefaultRenderer)1 ArrayTraverser (com.yahoo.slime.ArrayTraverser)1 Cursor (com.yahoo.slime.Cursor)1 Inspector (com.yahoo.slime.Inspector)1 Slime (com.yahoo.slime.Slime)1 TraceVisitor (com.yahoo.yolean.trace.TraceVisitor)1 IOException (java.io.IOException)1 HashMap (java.util.HashMap)1 AtomicReference (java.util.concurrent.atomic.AtomicReference)1 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)1