MCPcopy
hub / github.com/grafana/tempo / TestInstanceSearch

Function TestInstanceSearch

modules/livestore/instance_search_test.go:51–90  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

49)
50
51func TestInstanceSearch(t *testing.T) {
52 i, ls := defaultInstanceAndTmpDir(t)
53
54 tagKey := foo
55 tagValue := bar
56 ids, _, _, _ := writeTracesForSearch(t, i, "", tagKey, tagValue, false, false)
57
58 req := &tempopb.SearchRequest{
59 Query: fmt.Sprintf(`{ span.%s = "%s" }`, tagKey, tagValue),
60 }
61 req.Limit = uint32(len(ids)) + 1
62
63 // Test after appending to WAL. writeTracesforSearch() makes sure all traces are in the wal
64 sr, err := i.Search(t.Context(), req)
65 assert.NoError(t, err)
66 assert.Len(t, sr.Traces, len(ids))
67 checkEqual(t, ids, sr)
68
69 // Test after cutting new headblock
70 blockID, err := i.cutBlocks(t.Context(), true)
71 require.NoError(t, err)
72 assert.NotEqual(t, blockID, uuid.Nil)
73
74 sr, err = i.Search(t.Context(), req)
75 assert.NoError(t, err)
76 assert.Len(t, sr.Traces, len(ids))
77 checkEqual(t, ids, sr)
78
79 // Test after completing a block
80 _, err = i.completeBlock(t.Context(), blockID)
81 require.NoError(t, err)
82
83 sr, err = i.Search(t.Context(), req)
84 assert.NoError(t, err)
85 assert.Len(t, sr.Traces, len(ids))
86 checkEqual(t, ids, sr)
87
88 err = services.StopAndAwaitTerminated(t.Context(), ls)
89 require.NoError(t, err)
90}
91
92// TestInstanceSearchTraceQL is duplicate of TestInstanceSearch for now
93func TestInstanceSearchTraceQL(t *testing.T) {

Callers

nothing calls this directly

Calls 8

defaultInstanceAndTmpDirFunction · 0.85
writeTracesForSearchFunction · 0.85
checkEqualFunction · 0.85
cutBlocksMethod · 0.80
completeBlockMethod · 0.80
SearchMethod · 0.65
ContextMethod · 0.65
LenMethod · 0.65

Tested by

no test coverage detected