aboutsummaryrefslogtreecommitdiff
path: root/db_test.go
diff options
context:
space:
mode:
authorBen Johnson <benbjohnson@yahoo.com>2016-01-11 14:47:01 -0700
committerBen Johnson <benbjohnson@yahoo.com>2016-01-11 14:47:01 -0700
commit694a82a9595845d376dd19ff5c24cab78801204b (patch)
tree19c30005f6e3c46c78eb582e9f28f8af81d24d10 /db_test.go
parentMerge pull request #479 from azazeal/master (diff)
parentdo not grow dbsize agressively (diff)
downloaddedo-694a82a9595845d376dd19ff5c24cab78801204b.tar.gz
dedo-694a82a9595845d376dd19ff5c24cab78801204b.tar.xz
Merge branch 'grow' of https://github.com/xiang90/bolt into xiang90-grow
Diffstat (limited to 'db_test.go')
-rw-r--r--db_test.go10
1 files changed, 8 insertions, 2 deletions
diff --git a/db_test.go b/db_test.go
index c1346b8..7077ef2 100644
--- a/db_test.go
+++ b/db_test.go
@@ -229,6 +229,8 @@ func TestOpen_Size(t *testing.T) {
path := db.Path()
defer db.MustClose()
+ pagesize := db.Info().PageSize
+
// Insert until we get above the minimum 4MB size.
if err := db.Update(func(tx *bolt.Tx) error {
b, _ := tx.CreateBucketIfNotExists([]byte("data"))
@@ -273,7 +275,8 @@ func TestOpen_Size(t *testing.T) {
}
// Compare the original size with the new size.
- if sz != newSz {
+ // db size might increase by a few page sizes due to the new small update.
+ if sz < newSz-5*int64(pagesize) {
t.Fatalf("unexpected file growth: %d => %d", sz, newSz)
}
}
@@ -290,6 +293,8 @@ func TestOpen_Size_Large(t *testing.T) {
path := db.Path()
defer db.MustClose()
+ pagesize := db.Info().PageSize
+
// Insert until we get above the minimum 4MB size.
var index uint64
for i := 0; i < 10000; i++ {
@@ -338,7 +343,8 @@ func TestOpen_Size_Large(t *testing.T) {
}
// Compare the original size with the new size.
- if sz != newSz {
+ // db size might increase by a few page sizes due to the new small update.
+ if sz < newSz-5*int64(pagesize) {
t.Fatalf("unexpected file growth: %d => %d", sz, newSz)
}
}