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

Function TestWalBlockMetaSnapshot

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

Source from the content-addressed store, hash-verified

404}
405
406func TestWalBlockMetaSnapshot(t *testing.T) {
407 meta := backend.NewBlockMeta("fake", uuid.New(), VersionString)
408 w, err := createWALBlock(meta, t.TempDir(), model.CurrentEncoding, 0)
409 require.NoError(t, err)
410
411 // Snapshot before any append: counts are zero, returned pointer is distinct.
412 snap0 := w.MetaSnapshot()
413 require.NotSame(t, w.BlockMeta(), snap0, "MetaSnapshot must return a fresh allocation, not the live meta pointer")
414 require.Equal(t, int64(0), snap0.TotalObjects)
415
416 // Append a trace and confirm the snapshot reflects the mutation.
417 id := test.ValidTraceID(nil)
418 tr := test.MakeTrace(10, id)
419 trace.SortTrace(tr)
420 require.NoError(t, w.AppendTrace(id, tr, 100, 200, false))
421
422 snap1 := w.MetaSnapshot()
423 require.NotSame(t, snap0, snap1, "successive MetaSnapshot calls must return distinct pointers")
424 require.Equal(t, int64(1), snap1.TotalObjects)
425 require.Equal(t, w.BlockMeta().StartTime, snap1.StartTime)
426 require.Equal(t, w.BlockMeta().EndTime, snap1.EndTime)
427
428 // Mutating the snapshot must not affect the live meta.
429 snap1.TotalObjects = 9999
430 require.Equal(t, int64(1), w.BlockMeta().TotalObjects)
431}
432
433func TestWalBlockTombstone(t *testing.T) {
434 meta := backend.NewBlockMeta("fake", uuid.New(), VersionString)

Callers

nothing calls this directly

Calls 9

NewBlockMetaFunction · 0.92
ValidTraceIDFunction · 0.92
MakeTraceFunction · 0.92
SortTraceFunction · 0.92
createWALBlockFunction · 0.70
MetaSnapshotMethod · 0.65
BlockMetaMethod · 0.65
AppendTraceMethod · 0.65
EqualMethod · 0.45

Tested by

no test coverage detected