83df0ee1b0
1. Added KeyValueStore.Iterate for implementing the different List, ListV2 etc. implementations. This allows for more efficient use of memory depending on the situation. 2. Implemented an inmemory teststore for running tests. This should allow to replace MockKeyValueStore in most places. 3. Rewrote tests 4. Pulled out logger from bolt implementation so it can be used for all other storage implementations. 5. Fixed multiple things in bolt and redis implementations.
56 lines
1.0 KiB
Go
56 lines
1.0 KiB
Go
// Copyright (C) 2018 Storj Labs, Inc.
|
|
// See LICENSE for copying information.
|
|
|
|
package boltdb
|
|
|
|
import (
|
|
"io/ioutil"
|
|
"os"
|
|
"path/filepath"
|
|
"testing"
|
|
|
|
"storj.io/storj/storage/testsuite"
|
|
)
|
|
|
|
func TestSuite(t *testing.T) {
|
|
tempdir, err := ioutil.TempDir("", "bolt")
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
defer os.RemoveAll(tempdir)
|
|
|
|
dbname := filepath.Join(tempdir, "bolt.db")
|
|
store, err := New(dbname, "bucket")
|
|
if err != nil {
|
|
t.Fatalf("failed to create db: %v", err)
|
|
}
|
|
defer func() {
|
|
if err := store.Close(); err != nil {
|
|
t.Fatalf("failed to close db: %v", err)
|
|
}
|
|
}()
|
|
|
|
testsuite.RunTests(t, store)
|
|
}
|
|
|
|
func BenchmarkSuite(b *testing.B) {
|
|
tempdir, err := ioutil.TempDir("", "bolt")
|
|
if err != nil {
|
|
b.Fatal(err)
|
|
}
|
|
defer os.RemoveAll(tempdir)
|
|
|
|
dbname := filepath.Join(tempdir, "bolt.db")
|
|
store, err := New(dbname, "bucket")
|
|
if err != nil {
|
|
b.Fatalf("failed to create db: %v", err)
|
|
}
|
|
defer func() {
|
|
if err := store.Close(); err != nil {
|
|
b.Fatalf("failed to close db: %v", err)
|
|
}
|
|
}()
|
|
|
|
testsuite.RunBenchmarks(b, store)
|
|
}
|