Skip to content

Commit

Permalink
go/storage: Remove memory storage backend
Browse files Browse the repository at this point in the history
  • Loading branch information
kostko committed Aug 20, 2019
1 parent faecd3f commit d2e3c79
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 815 deletions.
19 changes: 13 additions & 6 deletions go/storage/cachingclient/cachingclient_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import (
"github.com/oasislabs/ekiden/go/common/crypto/hash"
memorySigner "github.com/oasislabs/ekiden/go/common/crypto/signature/signers/memory"
"github.com/oasislabs/ekiden/go/storage/api"
"github.com/oasislabs/ekiden/go/storage/memory"
"github.com/oasislabs/ekiden/go/storage/leveldb"
"github.com/oasislabs/ekiden/go/storage/mkvs/urkel"
"github.com/oasislabs/ekiden/go/storage/mkvs/urkel/node"
"github.com/oasislabs/ekiden/go/storage/tests"
Expand All @@ -31,11 +31,14 @@ const cacheSize = 10
func TestCachingClient(t *testing.T) {
signer, err := memorySigner.NewSigner(rand.Reader)
require.NoError(t, err, "failed to generate dummy receipt signing key")
remote := memory.New(signer, false)
dbDir, err := ioutil.TempDir("", "cachingclient.test.leveldb")
require.NoError(t, err, "TempDir")
defer os.RemoveAll(dbDir)
remote, err := leveldb.New(dbDir, signer, 0, false)
require.NoError(t, err, "leveldb.New")

client, cacheDir := requireNewClient(t, remote)
defer func() {
os.RemoveAll(cacheDir)
}()
defer os.RemoveAll(cacheDir)

wl := makeTestWriteLog([]byte("TestSingle"), cacheSize)
expectedNewRoot := tests.CalculateExpectedNewRoot(t, wl, testNs, 1)
Expand Down Expand Up @@ -75,7 +78,11 @@ func TestCachingClient(t *testing.T) {

// Test the persistence.
client.Cleanup()
remote = memory.New(signer, false)
dbDir, err = ioutil.TempDir("", "cachingclient.test.leveldb")
require.NoError(t, err, "TempDir")
defer os.RemoveAll(dbDir)
remote, err = leveldb.New(dbDir, signer, 0, false)
require.NoError(t, err, "leveldb.New")
_, err = New(remote, false)
require.NoError(t, err, "New - reopen")

Expand Down
11 changes: 8 additions & 3 deletions go/storage/crashing_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package storage

import (
"crypto/rand"
"io/ioutil"
"testing"

"github.com/stretchr/testify/require"
Expand All @@ -10,7 +11,7 @@ import (
"github.com/oasislabs/ekiden/go/common/crash"
"github.com/oasislabs/ekiden/go/common/crypto/hash"
memorySigner "github.com/oasislabs/ekiden/go/common/crypto/signature/signers/memory"
"github.com/oasislabs/ekiden/go/storage/memory"
"github.com/oasislabs/ekiden/go/storage/leveldb"
"github.com/oasislabs/ekiden/go/storage/tests"
)

Expand All @@ -20,8 +21,12 @@ func TestCrashingBackendDoNotInterfere(t *testing.T) {
signer, err := memorySigner.NewSigner(rand.Reader)
require.NoError(t, err, "NewSigner()")

memoryBackend := memory.New(signer, false)
backend := newCrashingWrapper(memoryBackend)
dbDir, err := ioutil.TempDir("", "crashing.test.leveldb")
require.NoError(t, err, "TempDir")
defer os.RemoveAll(dbDir)
realBackend, err := leveldb.New(dbDir, signer, 0, false)
require.NoError(t, err, "leveldb.New")
backend := newCrashingWrapper(realBackend)

crash.Config(map[string]float64{
"storage.write.before": 0.0,
Expand Down
5 changes: 1 addition & 4 deletions go/storage/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import (
"github.com/oasislabs/ekiden/go/storage/cachingclient"
"github.com/oasislabs/ekiden/go/storage/client"
"github.com/oasislabs/ekiden/go/storage/leveldb"
"github.com/oasislabs/ekiden/go/storage/memory"
)

const (
Expand Down Expand Up @@ -56,8 +55,6 @@ func New(
insecureSkipChecks := viper.GetBool(cfgInsecureSkipChecks)

switch strings.ToLower(backend) {
case memory.BackendName:
impl = memory.New(signer, insecureSkipChecks)
case badger.BackendName:
dbDir := filepath.Join(dataDir, badger.DBFile)
impl, err = badger.New(dbDir, signer, applyLockLRUSlots, insecureSkipChecks)
Expand Down Expand Up @@ -93,7 +90,7 @@ func New(
// command.
func RegisterFlags(cmd *cobra.Command) {
if !cmd.Flags().Parsed() {
cmd.Flags().String(cfgBackend, memory.BackendName, "Storage backend")
cmd.Flags().String(cfgBackend, leveldb.BackendName, "Storage backend")
cmd.Flags().Bool(cfgDebugMockSigningKey, false, "Generate volatile mock signing key")
cmd.Flags().Bool(cfgCrashEnabled, false, "Enable the crashing storage wrapper")
cmd.Flags().Int(cfgLRUSlots, 1000, "How many LRU slots to use for Apply call locks in the MKVS tree root cache")
Expand Down
213 changes: 0 additions & 213 deletions go/storage/memory/memory.go

This file was deleted.

31 changes: 0 additions & 31 deletions go/storage/memory/memory_test.go

This file was deleted.

Loading

0 comments on commit d2e3c79

Please sign in to comment.