Commit 051cf040 authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent 1d807b7c
...@@ -192,6 +192,8 @@ func TestPersistentBasic(t *testing.T) { ...@@ -192,6 +192,8 @@ func TestPersistentBasic(t *testing.T) {
}() }()
} }
// ---- TestPersistentDB ----
// zcacheControl is simple live cache control that prevents specified objects // zcacheControl is simple live cache control that prevents specified objects
// to be evicted from live cache. // to be evicted from live cache.
type zcacheControl struct { type zcacheControl struct {
...@@ -207,8 +209,6 @@ func (cc *zcacheControl) WantEvict(obj IPersistent) bool { ...@@ -207,8 +209,6 @@ func (cc *zcacheControl) WantEvict(obj IPersistent) bool {
return true return true
} }
// ---- TestPersistentDB ----
// tPersistentDB represents one testing environment inside TestPersistentDB. // tPersistentDB represents one testing environment inside TestPersistentDB.
type tPersistentDB struct { type tPersistentDB struct {
*testing.T *testing.T
...@@ -340,6 +340,7 @@ func TestPersistentDB(t0 *testing.T) { ...@@ -340,6 +340,7 @@ func TestPersistentDB(t0 *testing.T) {
stor, err := OpenStorage(ctx, zurl, &OpenOptions{ReadOnly: true}); X(err) stor, err := OpenStorage(ctx, zurl, &OpenOptions{ReadOnly: true}); X(err)
db := NewDB(stor) db := NewDB(stor)
// testopen opens new db transaction/connection and wraps it with tPersistentDB.
testopen := func(opt *ConnOptions) *tPersistentDB { testopen := func(opt *ConnOptions) *tPersistentDB {
t0.Helper() t0.Helper()
...@@ -369,8 +370,6 @@ func TestPersistentDB(t0 *testing.T) { ...@@ -369,8 +370,6 @@ func TestPersistentDB(t0 *testing.T) {
// do not evict obj2 from live cache. obj1 is ok to be evicted. // do not evict obj2 from live cache. obj1 is ok to be evicted.
zcache1 := t.conn.Cache() zcache1 := t.conn.Cache()
zcache1.SetControl(&zcacheControl{[]Oid{_obj2.oid}}) zcache1.SetControl(&zcacheControl{[]Oid{_obj2.oid}})
// FIXME test that live cache keeps objects live even if we drop all
// regular pointers to it and do GC.
// get objects // get objects
obj1 := t.Get(101) obj1 := t.Get(101)
...@@ -476,7 +475,8 @@ func TestPersistentDB(t0 *testing.T) { ...@@ -476,7 +475,8 @@ func TestPersistentDB(t0 *testing.T) {
t.checkObj(obj1, 101, InvalidTid, GHOST, 0) t.checkObj(obj1, 101, InvalidTid, GHOST, 0)
t.checkObj(obj2, 102, at2, UPTODATE, 0, "kitty") t.checkObj(obj2, 102, at2, UPTODATE, 0, "kitty")
// TODO live cache must not drop pinned entries after GC // FIXME test that live cache keeps pinned object live even if we drop
// all regular pointers to it and do GC.
/* /*
obj1 = nil obj1 = nil
obj2 = nil obj2 = nil
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment