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
52157648
Commit
52157648
authored
Jan 23, 2019
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
099f2e00
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
31 additions
and
15 deletions
+31
-15
go/zodb/persistent_test.go
go/zodb/persistent_test.go
+31
-15
No files found.
go/zodb/persistent_test.go
View file @
52157648
...
...
@@ -214,9 +214,9 @@ func TestPersistentDB(t *testing.T) {
txn1
,
ctx1
:=
transaction
.
New
(
ctx
)
conn1
,
err
:=
db
.
Open
(
ctx1
,
&
ConnOptions
{});
X
(
err
)
// do not evict obj
1 from live cache. obj2
is ok to be evicted.
// do not evict obj
2 from live cache. obj1
is ok to be evicted.
zcache1
:=
conn1
.
Cache
()
zcache1
.
SetControl
(
&
zcacheControl
{[]
Oid
{
_obj
1
.
oid
}})
zcache1
.
SetControl
(
&
zcacheControl
{[]
Oid
{
_obj
2
.
oid
}})
// get objects and assert their type
assert
.
Equal
(
conn1
.
At
(),
at1
)
...
...
@@ -226,6 +226,8 @@ func TestPersistentDB(t *testing.T) {
assert
.
Equal
(
ClassOf
(
xobj1
),
"t.zodb.MyObject"
)
assert
.
Equal
(
ClassOf
(
xobj2
),
"t.zodb.MyObject"
)
// XXX objX -> c1objX
obj1
:=
xobj1
.
(
*
MyObject
)
obj2
:=
xobj2
.
(
*
MyObject
)
checkObj
(
obj1
,
conn1
,
101
,
InvalidTid
,
GHOST
,
0
,
nil
)
...
...
@@ -251,13 +253,13 @@ func TestPersistentDB(t *testing.T) {
checkObj
(
obj1
,
conn1
,
101
,
at1
,
UPTODATE
,
1
,
nil
)
checkObj
(
obj2
,
conn1
,
102
,
at1
,
UPTODATE
,
1
,
nil
)
// deactivate: state dropped for obj
2, obj1
stays in live cache
// deactivate: state dropped for obj
1, obj2
stays in live cache
obj1
.
PDeactivate
()
obj2
.
PDeactivate
()
checkObj
(
obj1
,
conn1
,
101
,
at1
,
UPTODATE
,
0
,
nil
)
checkObj
(
obj2
,
conn1
,
102
,
InvalidTid
,
GHOST
,
0
,
nil
)
checkObj
(
obj1
,
conn1
,
101
,
InvalidTid
,
GHOST
,
0
,
nil
)
checkObj
(
obj2
,
conn1
,
102
,
at1
,
UPTODATE
,
0
,
nil
)
// invalidate: obj
1
state dropped
// invalidate: obj
2
state dropped
obj1
.
PInvalidate
()
obj2
.
PInvalidate
()
checkObj
(
obj1
,
conn1
,
101
,
InvalidTid
,
GHOST
,
0
,
nil
)
...
...
@@ -272,7 +274,7 @@ func TestPersistentDB(t *testing.T) {
txn2
,
ctx2
:=
transaction
.
New
(
ctx
)
conn2
,
err
:=
db
.
Open
(
ctx2
,
&
ConnOptions
{});
X
(
err
)
assert
.
Equal
(
conn2
.
At
(),
at
1
)
assert
.
Equal
(
conn2
.
At
(),
at
2
)
xc2obj1
,
err
:=
conn2
.
Get
(
ctx2
,
101
);
X
(
err
)
xc2obj2
,
err
:=
conn2
.
Get
(
ctx2
,
102
);
X
(
err
)
...
...
@@ -281,21 +283,35 @@ func TestPersistentDB(t *testing.T) {
c2obj1
:=
xc2obj1
.
(
*
MyObject
)
c2obj2
:=
xc2obj2
.
(
*
MyObject
)
checkObj
(
c2obj1
,
conn
1
,
101
,
InvalidTid
,
GHOST
,
0
,
nil
)
checkObj
(
c2obj2
,
conn
1
,
102
,
InvalidTid
,
GHOST
,
0
,
nil
)
checkObj
(
c2obj1
,
conn
2
,
101
,
InvalidTid
,
GHOST
,
0
,
nil
)
checkObj
(
c2obj2
,
conn
2
,
102
,
InvalidTid
,
GHOST
,
0
,
nil
)
err
=
c2obj1
.
PActivate
(
ctx
1
);
X
(
err
)
err
=
c2obj2
.
PActivate
(
ctx
1
);
X
(
err
)
checkObj
(
c2obj1
,
conn
1
,
101
,
at1
,
UPTODATE
,
1
,
nil
)
checkObj
(
c2obj2
,
conn
1
,
102
,
at2
,
UPTODATE
,
1
,
nil
)
err
=
c2obj1
.
PActivate
(
ctx
2
);
X
(
err
)
err
=
c2obj2
.
PActivate
(
ctx
2
);
X
(
err
)
checkObj
(
c2obj1
,
conn
2
,
101
,
at1
,
UPTODATE
,
1
,
nil
)
checkObj
(
c2obj2
,
conn
2
,
102
,
at2
,
UPTODATE
,
1
,
nil
)
assert
.
Equal
(
c2obj1
.
value
,
"hello"
)
assert
.
Equal
(
c2obj2
.
value
,
"kitty"
)
// XXX c1 stays at older view
// conn1 stays at older view for now
err
=
obj1
.
PActivate
(
ctx1
);
X
(
err
)
err
=
obj2
.
PActivate
(
ctx1
);
X
(
err
)
checkObj
(
obj1
,
conn1
,
101
,
at1
,
UPTODATE
,
1
,
nil
)
checkObj
(
obj2
,
conn1
,
102
,
at1
,
UPTODATE
,
1
,
nil
)
assert
.
Equal
(
obj1
.
value
,
"hello"
)
assert
.
Equal
(
obj2
.
value
,
"world"
)
// conn1 deactivate: obj2 stays in conn1 live cache with old state
obj1
.
PDeactivate
()
obj2
.
PDeactivate
()
checkObj
(
obj1
,
conn1
,
101
,
InvalidTid
,
GHOST
,
0
,
nil
)
checkObj
(
obj2
,
conn1
,
102
,
at1
,
UPTODATE
,
0
,
nil
)
txn1
.
Abort
()
// XXX conn1.Resync -> c1obj2 invalidated
// XXX
txn1
.
Abort
()
txn2
.
Abort
()
}
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