Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
N
neoppod
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Levin Zimmermann
neoppod
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 (
...
@@ -38,8 +38,8 @@ import (
type
MyObject
struct
{
type
MyObject
struct
{
Persistent
Persistent
value
string
// persistent state
value
string
// persistent state
_v_
valu
e
string
// volatile in-RAM only state; not managed by persistency layer
_v_
cooki
e
string
// volatile in-RAM only state; not managed by persistency layer
}
}
func
NewMyObject
(
jar
*
Connection
)
*
MyObject
{
func
NewMyObject
(
jar
*
Connection
)
*
MyObject
{
...
@@ -602,23 +602,6 @@ func testPersistentDB(t0 *testing.T, rawcache bool) {
...
@@ -602,23 +602,6 @@ func testPersistentDB(t0 *testing.T, rawcache bool) {
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"
)
// 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
// finish tnx3 and txn2 - conn1 and conn2 go back to db pool
t
.
Abort
()
t
.
Abort
()
t2
.
Abort
()
t2
.
Abort
()
...
@@ -732,6 +715,8 @@ func testPersistentDB(t0 *testing.T, rawcache bool) {
...
@@ -732,6 +715,8 @@ func testPersistentDB(t0 *testing.T, rawcache bool) {
// Test details of how LiveCache handles live caching policy.
// Test details of how LiveCache handles live caching policy.
func
TestLiveCache
(
t0
*
testing
.
T
)
{
func
TestLiveCache
(
t0
*
testing
.
T
)
{
assert
:=
assert
.
New
(
t0
)
tdb
:=
testdb
(
t0
,
/*rawcache=*/
false
)
tdb
:=
testdb
(
t0
,
/*rawcache=*/
false
)
defer
tdb
.
Close
()
defer
tdb
.
Close
()
...
@@ -778,7 +763,37 @@ func TestLiveCache(t0 *testing.T) {
...
@@ -778,7 +763,37 @@ func TestLiveCache(t0 *testing.T) {
obj3
.
PDeactivate
()
obj3
.
PDeactivate
()
t
.
checkObj
(
obj1
,
101
,
InvalidTid
,
GHOST
,
0
)
t
.
checkObj
(
obj1
,
101
,
InvalidTid
,
GHOST
,
0
)
t
.
checkObj
(
obj2
,
102
,
at1
,
UPTODATE
,
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.
// 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