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

Function TestInstanceSearchTraceQL

modules/livestore/instance_search_test.go:93–147  ·  view source on GitHub ↗

TestInstanceSearchTraceQL is duplicate of TestInstanceSearch for now

(t *testing.T)

Source from the content-addressed store, hash-verified

91
92// TestInstanceSearchTraceQL is duplicate of TestInstanceSearch for now
93func TestInstanceSearchTraceQL(t *testing.T) {
94 queries := []string{
95 `{ .service.name = "test-service" }`,
96 `{ duration >= 1s }`,
97 `{ duration >= 1s && .service.name = "test-service" }`,
98 }
99
100 for _, query := range queries {
101 t.Run(fmt.Sprintf("Query:%s", query), func(t *testing.T) {
102 i, ls := defaultInstanceAndTmpDir(t)
103
104 _, ids := pushTracesToInstance(t, i, 10)
105
106 req := &tempopb.SearchRequest{Query: query, Limit: 20, SpansPerSpanSet: 10}
107
108 // Test live traces, these are cut roughly every 5 seconds so these should
109 // not exist yet.
110 sr, err := i.Search(t.Context(), req)
111 assert.NoError(t, err)
112 assert.Len(t, sr.Traces, 0)
113
114 // Test after appending to WAL
115 drained, cutErr := i.cutIdleTraces(t.Context(), true)
116 require.NoError(t, cutErr)
117 require.True(t, drained, "should drain live traces in one iteration")
118
119 sr, err = i.Search(t.Context(), req)
120 assert.NoError(t, err)
121 assert.Len(t, sr.Traces, len(ids))
122 checkEqual(t, ids, sr)
123
124 // Test after cutting new headBlock
125 blockID, err := i.cutBlocks(t.Context(), true)
126 require.NoError(t, err)
127 assert.NotEqual(t, blockID, uuid.Nil)
128
129 sr, err = i.Search(t.Context(), req)
130 assert.NoError(t, err)
131 assert.Len(t, sr.Traces, len(ids))
132 checkEqual(t, ids, sr)
133
134 // Test after completing a block
135 _, err = i.completeBlock(t.Context(), blockID)
136 require.NoError(t, err)
137
138 sr, err = i.Search(t.Context(), req)
139 assert.NoError(t, err)
140 assert.Len(t, sr.Traces, len(ids))
141 checkEqual(t, ids, sr)
142
143 err = services.StopAndAwaitTerminated(t.Context(), ls)
144 require.NoError(t, err)
145 })
146 }
147}
148
149func TestInstanceSearchWithStartAndEnd(t *testing.T) {
150 i, ls := defaultInstanceAndTmpDir(t)

Callers

nothing calls this directly

Calls 10

defaultInstanceAndTmpDirFunction · 0.85
pushTracesToInstanceFunction · 0.85
checkEqualFunction · 0.85
cutIdleTracesMethod · 0.80
cutBlocksMethod · 0.80
completeBlockMethod · 0.80
SearchMethod · 0.65
ContextMethod · 0.65
LenMethod · 0.65
RunMethod · 0.45

Tested by

no test coverage detected