DPA test with deleted memstore, localstore Put with background db access.

This commit is contained in:
Daniel A. Nagy 2015-02-09 17:05:33 +01:00
parent 5ed5a5cbc2
commit bea138d111
3 changed files with 16 additions and 2 deletions

View file

@ -286,7 +286,6 @@ func (s *dbStore) Put(chunk *Chunk) {
batch.Put(ikey, idata) batch.Put(ikey, idata)
s.db.Write(batch) s.db.Write(batch)
} }
// try to find index; if found, update access cnt and return true // try to find index; if found, update access cnt and return true

View file

@ -44,4 +44,19 @@ func TestDPA(t *testing.T) {
if !bytes.Equal(slice, resultSlice) { if !bytes.Equal(slice, resultSlice) {
t.Errorf("Comparison error.") t.Errorf("Comparison error.")
} }
localStore.memStore = newMemStore(dbStore)
resultReader = dpa.Retrieve(key)
for i, _ := range resultSlice {
resultSlice[i] = 0
}
n, err = resultReader.ReadAt(resultSlice, 0)
if err != nil {
t.Errorf("Retrieve error after removing memStore: %v", err)
}
if n != len(slice) {
t.Errorf("Slice size error after removing memStore got %d, expected %d.", n, len(slice))
}
if !bytes.Equal(slice, resultSlice) {
t.Errorf("Comparison error after removing memStore.")
}
} }

View file

@ -10,7 +10,7 @@ type localStore struct {
// its integrity is checked ? // its integrity is checked ?
func (self *localStore) Put(chunk *Chunk) { func (self *localStore) Put(chunk *Chunk) {
self.memStore.Put(chunk) self.memStore.Put(chunk)
self.dbStore.Put(chunk) go self.dbStore.Put(chunk)
} }
// Get(chunk *Chunk) looks up a chunk in the local stores // Get(chunk *Chunk) looks up a chunk in the local stores