1
0
mirror of https://github.com/etcd-io/bbolt.git synced 2025-04-28 22:09:37 +00:00

test: check free page counts on close/reopen for freelist overflow

Confirm that the number of freed pages exceeds the overflow count, then check
that reopening gives the same number of free pages.
This commit is contained in:
Anthony Romano 2017-08-08 19:47:15 -07:00
parent 2ab139b399
commit f50ad8e90c

@ -423,6 +423,22 @@ func TestBucket_Delete_FreelistOverflow(t *testing.T) {
}); err != nil {
t.Fatal(err)
}
// Check more than an overflow's worth of pages are freed.
stats := db.Stats()
freePages := stats.FreePageN + stats.PendingPageN
if freePages <= 0xFFFF {
t.Fatalf("expected more than 0xFFFF free pages, got %v", freePages)
}
// Free page count should be preserved on reopen.
if err := db.DB.Close(); err != nil {
t.Fatal(err)
}
db.MustReopen()
if reopenFreePages := db.Stats().FreePageN; freePages != reopenFreePages {
t.Fatalf("expected %d free pages, got %+v", freePages, db.Stats())
}
}
// Ensure that accessing and updating nested buckets is ok across transactions.