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
789cbc2b
Commit
789cbc2b
authored
Jan 23, 2019
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
0fdfd342
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
35 additions
and
6 deletions
+35
-6
go/zodb/db.go
go/zodb/db.go
+1
-1
go/zodb/persistent_test.go
go/zodb/persistent_test.go
+34
-5
No files found.
go/zodb/db.go
View file @
789cbc2b
...
@@ -207,7 +207,7 @@ func (db *DB) get(at Tid) *Connection {
...
@@ -207,7 +207,7 @@ func (db *DB) get(at Tid) *Connection {
}
}
if
conn
.
at
!=
at
{
if
conn
.
at
!=
at
{
panic
(
"DB.get: TODO: invalidations"
)
panic
(
"DB.get: TODO: invalidations"
)
// XXX
}
}
return
conn
return
conn
...
...
go/zodb/persistent_test.go
View file @
789cbc2b
...
@@ -197,7 +197,6 @@ func TestPersistentDB(t *testing.T) {
...
@@ -197,7 +197,6 @@ func TestPersistentDB(t *testing.T) {
work
,
err
:=
ioutil
.
TempDir
(
""
,
"t-persistent"
);
X
(
err
)
work
,
err
:=
ioutil
.
TempDir
(
""
,
"t-persistent"
);
X
(
err
)
defer
func
()
{
defer
func
()
{
//return
err
:=
os
.
RemoveAll
(
work
);
X
(
err
)
err
:=
os
.
RemoveAll
(
work
);
X
(
err
)
}()
}()
...
@@ -216,6 +215,8 @@ func TestPersistentDB(t *testing.T) {
...
@@ -216,6 +215,8 @@ func TestPersistentDB(t *testing.T) {
txn1
,
ctx1
:=
transaction
.
New
(
ctx
)
txn1
,
ctx1
:=
transaction
.
New
(
ctx
)
conn1
,
err
:=
db
.
Open
(
ctx1
,
&
ConnOptions
{});
X
(
err
)
conn1
,
err
:=
db
.
Open
(
ctx1
,
&
ConnOptions
{});
X
(
err
)
assert
.
Equal
(
conn1
.
At
(),
at1
)
assert
.
Equal
(
db
.
connv
,
[]
*
Connection
(
nil
))
assert
.
Equal
(
conn1
.
db
,
db
)
assert
.
Equal
(
conn1
.
db
,
db
)
assert
.
Equal
(
conn1
.
txn
,
txn1
)
assert
.
Equal
(
conn1
.
txn
,
txn1
)
...
@@ -224,7 +225,6 @@ func TestPersistentDB(t *testing.T) {
...
@@ -224,7 +225,6 @@ func TestPersistentDB(t *testing.T) {
zcache1
.
SetControl
(
&
zcacheControl
{[]
Oid
{
_obj2
.
oid
}})
zcache1
.
SetControl
(
&
zcacheControl
{[]
Oid
{
_obj2
.
oid
}})
// get objects and assert their type
// get objects and assert their type
assert
.
Equal
(
conn1
.
At
(),
at1
)
xobj1
,
err
:=
conn1
.
Get
(
ctx1
,
101
);
X
(
err
)
xobj1
,
err
:=
conn1
.
Get
(
ctx1
,
101
);
X
(
err
)
xobj2
,
err
:=
conn1
.
Get
(
ctx1
,
102
);
X
(
err
)
xobj2
,
err
:=
conn1
.
Get
(
ctx1
,
102
);
X
(
err
)
...
@@ -278,10 +278,11 @@ func TestPersistentDB(t *testing.T) {
...
@@ -278,10 +278,11 @@ func TestPersistentDB(t *testing.T) {
// new db connection should see the change
// new db connection should see the change
txn2
,
ctx2
:=
transaction
.
New
(
ctx
)
txn2
,
ctx2
:=
transaction
.
New
(
ctx
)
conn2
,
err
:=
db
.
Open
(
ctx2
,
&
ConnOptions
{});
X
(
err
)
conn2
,
err
:=
db
.
Open
(
ctx2
,
&
ConnOptions
{});
X
(
err
)
assert
.
Equal
(
conn2
.
At
(),
at2
)
assert
.
Equal
(
db
.
connv
,
[]
*
Connection
(
nil
))
assert
.
Equal
(
conn2
.
db
,
db
)
assert
.
Equal
(
conn2
.
db
,
db
)
assert
.
Equal
(
conn2
.
txn
,
txn2
)
assert
.
Equal
(
conn2
.
txn
,
txn2
)
assert
.
Equal
(
conn2
.
At
(),
at2
)
xc2obj1
,
err
:=
conn2
.
Get
(
ctx2
,
101
);
X
(
err
)
xc2obj1
,
err
:=
conn2
.
Get
(
ctx2
,
101
);
X
(
err
)
xc2obj2
,
err
:=
conn2
.
Get
(
ctx2
,
102
);
X
(
err
)
xc2obj2
,
err
:=
conn2
.
Get
(
ctx2
,
102
);
X
(
err
)
...
@@ -319,12 +320,40 @@ func TestPersistentDB(t *testing.T) {
...
@@ -319,12 +320,40 @@ func TestPersistentDB(t *testing.T) {
assert
.
Equal
(
conn1
.
txn
,
txn1
)
assert
.
Equal
(
conn1
.
txn
,
txn1
)
txn1
.
Abort
()
txn1
.
Abort
()
assert
.
Equal
(
conn1
.
txn
,
nil
)
assert
.
Equal
(
conn1
.
txn
,
nil
)
assert
.
Equal
(
db
.
connv
,
[]
*
Connection
{
conn1
})
// open new connection - it should be conn1 but at updated database view
txn3
,
ctx3
:=
transaction
.
New
(
ctx
)
assert
.
NotEqual
(
txn3
,
txn1
)
conn3
,
err
:=
db
.
Open
(
ctx3
,
&
ConnOptions
{});
X
(
err
)
assert
.
Equal
(
conn3
,
conn1
)
// XXX is
assert
.
Equal
(
conn1
.
At
(),
at2
)
assert
.
Equal
(
conn1
.
db
,
db
)
assert
.
Equal
(
conn1
.
txn
,
txn3
)
assert
.
Equal
(
db
.
connv
,
[]
*
Connection
{})
// XXX ctx1 = ctx3 (not to use 3 below) ?
// obj2 should be invalidated
assert
.
Equal
(
conn1
.
Cache
()
.
Get
(
101
),
obj1
)
// XXX is
assert
.
Equal
(
conn1
.
Cache
()
.
Get
(
101
),
obj2
)
// XXX is
checkObj
(
obj1
,
conn1
,
101
,
InvalidTid
,
GHOST
,
0
,
nil
)
checkObj
(
obj2
,
conn1
,
102
,
InvalidTid
,
GHOST
,
0
,
nil
)
// obj2 data should be new
// XXX conn1.Resync -> c1obj2 invalidated
xobj1
,
err
=
conn1
.
Get
(
ctx1
,
101
);
X
(
err
)
xobj2
,
err
=
conn1
.
Get
(
ctx1
,
102
);
X
(
err
)
assert
.
Exactly
(
obj1
,
xobj1
)
assert
.
Exactly
(
obj2
,
xobj2
)
checkObj
(
obj1
,
conn1
,
101
,
at1
,
UPTODATE
,
1
,
nil
)
checkObj
(
obj2
,
conn1
,
102
,
at2
,
UPTODATE
,
1
,
nil
)
assert
.
Equal
(
obj1
.
value
,
"hello"
)
assert
.
Equal
(
obj2
.
value
,
"kitty"
)
// XXX also Resync
// XXX
// XXX
txn3
.
Abort
()
txn2
.
Abort
()
txn2
.
Abort
()
// XXX cache dropping entries after GC
}
}
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