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

Function TestIteratorContextCancelled

tempodb/encoding/vparquet5/wal_block_test.go:299–328  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

297}
298
299func TestIteratorContextCancelled(t *testing.T) {
300 t.Run("already cancelled", func(t *testing.T) {
301 testWalBlock(t, func(w *walBlock, _ []common.ID, _ []*tempopb.Trace) {
302 ctx, cancel := context.WithCancel(context.Background())
303 cancel()
304
305 _, err := w.Iterator(ctx)
306 require.Error(t, err)
307 require.ErrorIs(t, err, context.Canceled)
308 })
309 })
310
311 t.Run("cancelled after creation", func(t *testing.T) {
312 testWalBlock(t, func(w *walBlock, _ []common.ID, _ []*tempopb.Trace) {
313 ctx, cancel := context.WithCancel(context.Background())
314
315 iter, err := w.Iterator(ctx)
316 require.NoError(t, err)
317 defer iter.Close()
318
319 // Cancel the context after iterator creation. Subsequent Next calls
320 // go through walReaderAt.ReadAt which checks ctx.Err().
321 cancel()
322
323 _, _, err = iter.Next(ctx)
324 require.Error(t, err)
325 require.ErrorIs(t, err, context.Canceled)
326 })
327 })
328}
329
330// TestWalBlockFindTraceByIDRace detects a data race in FindTraceByID
331func TestWalBlockRaceConditionCheck(t *testing.T) {

Callers

nothing calls this directly

Calls 6

testWalBlockFunction · 0.70
IteratorMethod · 0.65
ErrorMethod · 0.65
CloseMethod · 0.65
NextMethod · 0.65
RunMethod · 0.45

Tested by

no test coverage detected