forked from osmosis-labs/tm-db
-
Notifications
You must be signed in to change notification settings - Fork 0
/
rocksdb_test.go
50 lines (40 loc) · 972 Bytes
/
rocksdb_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
//go:build rocksdb
package db
import (
"fmt"
"os"
"testing"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
func TestRocksDBBackend(t *testing.T) {
name := fmt.Sprintf("test_%x", randStr(12))
dir := os.TempDir()
db, err := NewDB(name, RocksDBBackend, dir)
require.NoError(t, err)
defer cleanupDBDir(dir, name)
_, ok := db.(*RocksDB)
assert.True(t, ok)
}
func TestRocksDBStats(t *testing.T) {
name := fmt.Sprintf("test_%x", randStr(12))
dir := os.TempDir()
db, err := NewDB(name, RocksDBBackend, dir)
require.NoError(t, err)
defer cleanupDBDir(dir, name)
assert.NotEmpty(t, db.Stats())
}
func BenchmarkRocksDBRandomReadsWrites(b *testing.B) {
name := fmt.Sprintf("test_%x", randStr(12))
dir := os.TempDir()
db, err := NewDB(name, RocksDBBackend, dir)
if err != nil {
b.Fatal(err)
}
defer func() {
db.Close()
cleanupDBDir("", name)
}()
benchmarkRandomReadsWrites(b, db)
}
// TODO: Add tests for rocksdb