Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
N
neo
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Labels
Merge Requests
2
Merge Requests
2
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Jobs
Commits
Open sidebar
Kirill Smelkov
neo
Commits
39ff832b
Commit
39ff832b
authored
Mar 11, 2019
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
234f0bbc
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
35 additions
and
20 deletions
+35
-20
go/zodb/persistent_test.go
go/zodb/persistent_test.go
+35
-20
No files found.
go/zodb/persistent_test.go
View file @
39ff832b
...
...
@@ -38,8 +38,8 @@ import (
type
MyObject
struct
{
Persistent
value
string
// persistent state
_v_
valu
e
string
// volatile in-RAM only state; not managed by persistency layer
value
string
// persistent state
_v_
cooki
e
string
// volatile in-RAM only state; not managed by persistency layer
}
func
NewMyObject
(
jar
*
Connection
)
*
MyObject
{
...
...
@@ -602,23 +602,6 @@ func testPersistentDB(t0 *testing.T, rawcache bool) {
t
.
checkObj
(
obj1
,
101
,
InvalidTid
,
GHOST
,
0
)
t
.
checkObj
(
obj2
,
102
,
at2
,
UPTODATE
,
0
,
"kitty"
)
// live cache keeps pinned object live even if we drop
// all regular pointers to it and do GC.
// XXX also PCachePinObject without PCacheKeepState
obj1
=
nil
obj2
=
nil
for
i
:=
0
;
i
<
10
;
i
++
{
runtime
.
GC
()
// need only 2 runs since cache uses finalizers
}
xobj1
:=
t
.
conn
.
Cache
()
.
Get
(
101
)
xobj2
:=
t
.
conn
.
Cache
()
.
Get
(
102
)
assert
.
Equal
(
xobj1
,
nil
)
assert
.
NotEqual
(
xobj2
,
nil
)
obj2
=
xobj2
.
(
*
MyObject
)
t
.
checkObj
(
obj2
,
102
,
at2
,
UPTODATE
,
0
,
"kitty"
)
// finish tnx3 and txn2 - conn1 and conn2 go back to db pool
t
.
Abort
()
t2
.
Abort
()
...
...
@@ -732,6 +715,8 @@ func testPersistentDB(t0 *testing.T, rawcache bool) {
// Test details of how LiveCache handles live caching policy.
func
TestLiveCache
(
t0
*
testing
.
T
)
{
assert
:=
assert
.
New
(
t0
)
tdb
:=
testdb
(
t0
,
/*rawcache=*/
false
)
defer
tdb
.
Close
()
...
...
@@ -778,7 +763,37 @@ func TestLiveCache(t0 *testing.T) {
obj3
.
PDeactivate
()
t
.
checkObj
(
obj1
,
101
,
InvalidTid
,
GHOST
,
0
)
t
.
checkObj
(
obj2
,
102
,
at1
,
UPTODATE
,
0
,
"труд"
)
t
.
checkObj
(
obj3
,
103
,
at1
,
UPTODATE
,
0
,
"май"
)
t
.
checkObj
(
obj3
,
103
,
InvalidTid
,
GHOST
,
0
)
// live cache should keep pinned object live even if we drop all
// regular pointers to it and do GC.
obj1
.
_v_cookie
=
"peace"
obj2
.
_v_cookie
=
"labour"
obj3
.
_v_cookie
=
"may"
obj1
=
nil
obj2
=
nil
obj3
=
nil
for
i
:=
0
;
i
<
10
;
i
++
{
runtime
.
GC
()
// need only 2 runs since cache uses finalizers
}
xobj1
:=
zcache
.
Get
(
101
)
xobj2
:=
zcache
.
Get
(
102
)
xobj3
:=
zcache
.
Get
(
103
)
assert
.
Equal
(
xobj1
,
nil
)
assert
.
NotEqual
(
xobj2
,
nil
)
assert
.
NotEqual
(
xobj3
,
nil
)
obj2
=
xobj2
.
(
*
MyObject
)
obj3
=
xobj2
.
(
*
MyObject
)
t
.
checkObj
(
obj2
,
102
,
at1
,
UPTODATE
,
0
,
"труд"
)
t
.
checkObj
(
obj3
,
103
,
InvalidTid
,
GHOST
,
0
)
assert
.
Equal
(
obj2
.
_v_cookie
,
"zzz"
)
// XXX labour
assert
.
Equal
(
obj3
.
_v_cookie
,
"may"
)
obj1
=
t
.
Get
(
101
)
t
.
checkObj
(
obj1
,
101
,
InvalidTid
,
GHOST
,
0
)
assert
.
Equal
(
obj1
.
_v_cookie
,
""
)
}
// TODO Map & List tests.
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment