MCPcopy
hub / github.com/etcd-io/bbolt / TestFreelist_E2E_MultiSpanOverflows

Function TestFreelist_E2E_MultiSpanOverflows

internal/freelist/freelist_test.go:394–417  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

392}
393
394func TestFreelist_E2E_MultiSpanOverflows(t *testing.T) {
395 f := newTestFreelist()
396 f.Init([]common.Pgid{})
397 f.Free(common.Txid(10), common.NewPage(20, common.LeafPageFlag, 0, 1))
398 f.Free(common.Txid(10), common.NewPage(25, common.LeafPageFlag, 0, 2))
399 f.Free(common.Txid(10), common.NewPage(35, common.LeafPageFlag, 0, 3))
400 f.Free(common.Txid(10), common.NewPage(39, common.LeafPageFlag, 0, 2))
401 f.Free(common.Txid(10), common.NewPage(45, common.LeafPageFlag, 0, 4))
402 requirePages(t, f, common.Pgids{}, common.Pgids{20, 21, 25, 26, 27, 35, 36, 37, 38, 39, 40, 41, 45, 46, 47, 48, 49})
403 f.ReleasePendingPages()
404 requirePages(t, f, common.Pgids{20, 21, 25, 26, 27, 35, 36, 37, 38, 39, 40, 41, 45, 46, 47, 48, 49}, common.Pgids{})
405
406 // that sequence, regardless of implementation, should always yield the same blocks of pages
407 allocSequence := []int{7, 5, 3, 2}
408 expectedSpanStarts := []common.Pgid{35, 45, 25, 20}
409 for i, pageNums := range allocSequence {
410 allocated := f.Allocate(common.Txid(11), pageNums)
411 require.Equal(t, expectedSpanStarts[i], allocated)
412 // ensure all pages in that span are not considered free anymore
413 for i := 0; i < pageNums; i++ {
414 require.False(t, f.Freed(allocated+common.Pgid(i)))
415 }
416 }
417}
418
419func TestFreelist_E2E_Rollbacks(t *testing.T) {
420 freelist := newTestFreelist()

Callers

nothing calls this directly

Calls 10

TxidTypeAlias · 0.92
NewPageFunction · 0.92
PgidTypeAlias · 0.92
newTestFreelistFunction · 0.85
requirePagesFunction · 0.85
InitMethod · 0.65
FreeMethod · 0.65
ReleasePendingPagesMethod · 0.65
AllocateMethod · 0.65
FreedMethod · 0.65

Tested by

no test coverage detected