2020-02-13 16:19:46 +00:00
|
|
|
package kv
|
2019-09-26 16:29:10 +00:00
|
|
|
|
|
|
|
import (
|
2020-08-18 12:41:25 +00:00
|
|
|
"io/ioutil"
|
2019-09-26 16:29:10 +00:00
|
|
|
"testing"
|
2020-01-22 05:39:21 +00:00
|
|
|
|
2020-08-18 12:41:25 +00:00
|
|
|
"github.com/prysmaticlabs/prysm/shared/testutil/require"
|
|
|
|
"github.com/sirupsen/logrus"
|
2019-09-26 16:29:10 +00:00
|
|
|
)
|
|
|
|
|
2020-08-18 12:41:25 +00:00
|
|
|
func TestMain(m *testing.M) {
|
2020-12-04 16:10:07 +00:00
|
|
|
logrus.SetLevel(logrus.DebugLevel)
|
|
|
|
logrus.SetOutput(ioutil.Discard)
|
2020-08-18 12:41:25 +00:00
|
|
|
|
2020-12-04 16:10:07 +00:00
|
|
|
m.Run()
|
2020-08-18 12:41:25 +00:00
|
|
|
}
|
|
|
|
|
2020-10-12 08:11:05 +00:00
|
|
|
func setupDB(t testing.TB) *Store {
|
2020-04-22 15:53:09 +00:00
|
|
|
cfg := &Config{}
|
2020-11-10 22:45:17 +00:00
|
|
|
db, err := NewKVStore(t.TempDir(), cfg)
|
2020-08-18 12:41:25 +00:00
|
|
|
require.NoError(t, err, "Failed to instantiate DB")
|
2020-05-04 01:14:34 +00:00
|
|
|
t.Cleanup(func() {
|
2020-08-18 12:41:25 +00:00
|
|
|
require.NoError(t, db.Close(), "Failed to close database")
|
2020-05-04 01:14:34 +00:00
|
|
|
})
|
2020-01-22 05:39:21 +00:00
|
|
|
return db
|
|
|
|
}
|
2019-09-26 16:29:10 +00:00
|
|
|
|
2020-03-09 05:35:39 +00:00
|
|
|
func setupDBDiffCacheSize(t testing.TB, cacheSize int) *Store {
|
2020-04-22 15:53:09 +00:00
|
|
|
cfg := &Config{SpanCacheSize: cacheSize}
|
2020-11-10 22:45:17 +00:00
|
|
|
db, err := NewKVStore(t.TempDir(), cfg)
|
2020-08-18 12:41:25 +00:00
|
|
|
require.NoError(t, err, "Failed to instantiate DB")
|
2020-05-04 01:14:34 +00:00
|
|
|
t.Cleanup(func() {
|
2020-08-18 12:41:25 +00:00
|
|
|
require.NoError(t, db.Close(), "Failed to close database")
|
2020-05-04 01:14:34 +00:00
|
|
|
})
|
|
|
|
return db
|
2019-09-26 16:29:10 +00:00
|
|
|
}
|