Skip to content

Commit

Permalink
test tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
erikgrinaker committed Jun 12, 2020
1 parent 69829b1 commit d554b88
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions mutable_tree_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -279,19 +279,21 @@ func TestDeleteVersion_issue261(t *testing.T) {
keepRecent = 0
}

// Create a new tree from the given database, with a fresh RecentDB for in-memory versions.
tree, err := NewMutableTreeWithOpts(mainDB, db.NewMemDB(), 0, &Options{
KeepEvery: keepEvery,
KeepRecent: keepRecent,
})
require.NoError(t, err)

// Load the latest persisted version.
version, err := tree.LoadVersion(0)
require.NoError(t, err)
t.Logf("Loaded version %v\n", version)

// Create new versions
// Create new versions.
for v := 0; v < versions; v++ {
for i := 0; i < 4096; i++ {
for i := 0; i < 16; i++ {
key := []byte(fmt.Sprintf("%v", r.Intn(65536)))
value := []byte(fmt.Sprintf("%v", r.Intn(1<<20)))
tree.Set(key, value)
Expand All @@ -316,7 +318,7 @@ func TestDeleteVersion_issue261(t *testing.T) {
require.NoError(t, err)
defer os.RemoveAll(tempdir)

levelDB, err := db.NewGoLevelDB("pruning", "")
levelDB, err := db.NewGoLevelDB("leveldb", tempdir)
require.NoError(t, err)

// First, create 12 versions and persist every 5 versions to disk, deleting the previous
Expand All @@ -325,6 +327,7 @@ func TestDeleteVersion_issue261(t *testing.T) {

// Now, create another 12 versions and persist every 5 versions to disk, deleting the previous
// persisted one. This will load version 10 (the last persisted one) and generate new versions
// from that. In the original issue, this panics after version 10 has been deleted.
// from that. In the original issue, this panics after version 10 has been deleted, when version
// 16 is about to be created.
makeVersions(t, levelDB, 12, 5)
}

0 comments on commit d554b88

Please sign in to comment.