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

Function TestIteratorContextCancelled

tempodb/encoding/vparquet3/wal_block_test.go:297–326  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

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