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.
pull/12/head
Anthony Romano 2017-08-08 19:47:15 -07:00
parent 2ab139b399
commit f50ad8e90c
1 changed files with 16 additions and 0 deletions

View File

@ -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.