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

Function TestIteratorContextCancelled

tempodb/encoding/vparquet4/wal_block_test.go:300–329  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

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

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