tests the reloading from another physical page
(t *testing.T)
| 449 | |
| 450 | // tests the reloading from another physical page |
| 451 | func TestFreelist_E2E_Reload(t *testing.T) { |
| 452 | freelist := newTestFreelist() |
| 453 | freelist.Init([]common.Pgid{}) |
| 454 | freelist.Free(common.Txid(2), common.NewPage(5, common.LeafPageFlag, 0, 1)) |
| 455 | freelist.Free(common.Txid(2), common.NewPage(8, common.LeafPageFlag, 0, 0)) |
| 456 | freelist.ReleasePendingPages() |
| 457 | requirePages(t, freelist, common.Pgids{5, 6, 8}, common.Pgids{}) |
| 458 | buf := make([]byte, 4096) |
| 459 | p := common.LoadPage(buf) |
| 460 | freelist.Write(p) |
| 461 | |
| 462 | freelist.Free(common.Txid(3), common.NewPage(3, common.LeafPageFlag, 0, 1)) |
| 463 | freelist.Free(common.Txid(3), common.NewPage(10, common.LeafPageFlag, 0, 2)) |
| 464 | requirePages(t, freelist, common.Pgids{5, 6, 8}, common.Pgids{3, 4, 10, 11, 12}) |
| 465 | |
| 466 | otherBuf := make([]byte, 4096) |
| 467 | px := common.LoadPage(otherBuf) |
| 468 | freelist.Write(px) |
| 469 | |
| 470 | loadFreeList := newTestFreelist() |
| 471 | loadFreeList.Init([]common.Pgid{}) |
| 472 | loadFreeList.Read(px) |
| 473 | requirePages(t, loadFreeList, common.Pgids{3, 4, 5, 6, 8, 10, 11, 12}, common.Pgids{}) |
| 474 | // restore the original freelist again |
| 475 | loadFreeList.Reload(p) |
| 476 | requirePages(t, loadFreeList, common.Pgids{5, 6, 8}, common.Pgids{}) |
| 477 | |
| 478 | // reload another page with different free pages to test we are deduplicating the free pages with the pending ones correctly |
| 479 | freelist = newTestFreelist() |
| 480 | freelist.Init([]common.Pgid{}) |
| 481 | freelist.Free(common.Txid(5), common.NewPage(5, common.LeafPageFlag, 0, 4)) |
| 482 | freelist.Reload(p) |
| 483 | requirePages(t, freelist, common.Pgids{}, common.Pgids{5, 6, 7, 8, 9}) |
| 484 | } |
| 485 | |
| 486 | // tests the loading and reloading from physical pages |
| 487 | func TestFreelist_E2E_SerDe_HappyPath(t *testing.T) { |
nothing calls this directly
no test coverage detected