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

Function TestGenericCombinerDoesntRace

modules/frontend/combiner/common_test.go:165–216  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

163}
164
165func TestGenericCombinerDoesntRace(t *testing.T) {
166 combiner := newTestCombiner()
167 end := make(chan struct{})
168 wg := sync.WaitGroup{}
169
170 concurrent := func(f func()) {
171 wg.Add(1)
172 go func() {
173 defer wg.Done()
174 for {
175 select {
176 case <-end:
177 return
178 default:
179 f()
180 }
181 }
182 }()
183 }
184 concurrent(func() {
185 _ = combiner.AddResponse(newTestResponse(t))
186 })
187
188 concurrent(func() {
189 // this test is going to add a failed response which cuts off certain code paths. just wait a bit to test the other paths
190 time.Sleep(10 * time.Millisecond)
191 _ = combiner.AddResponse(newFailedTestResponse())
192 })
193
194 concurrent(func() {
195 combiner.ShouldQuit()
196 })
197
198 concurrent(func() {
199 combiner.StatusCode()
200 })
201
202 concurrent(func() {
203 _, _ = combiner.HTTPFinal()
204 })
205
206 concurrent(func() {
207 _, _ = combiner.GRPCFinal()
208 })
209
210 concurrent(func() {
211 _, _ = combiner.GRPCDiff()
212 })
213
214 close(end)
215 wg.Wait()
216}
217
218type testPipelineResponse struct {
219 r *http.Response

Callers

nothing calls this directly

Calls 14

newTestCombinerFunction · 0.85
fFunction · 0.85
newTestResponseFunction · 0.85
newFailedTestResponseFunction · 0.85
AddMethod · 0.65
DoneMethod · 0.65
AddResponseMethod · 0.65
SleepMethod · 0.65
ShouldQuitMethod · 0.65
StatusCodeMethod · 0.65
HTTPFinalMethod · 0.65
GRPCFinalMethod · 0.65

Tested by

no test coverage detected