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
513ef608
Commit
513ef608
authored
Oct 04, 2021
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
d4da2a21
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
48 additions
and
3 deletions
+48
-3
go/zodb/btree/btree_test.go
go/zodb/btree/btree_test.go
+48
-2
go/zodb/btree/testdata/gen-testdata
go/zodb/btree/testdata/gen-testdata
+0
-1
No files found.
go/zodb/btree/btree_test.go
View file @
513ef608
...
@@ -23,6 +23,7 @@ package btree
...
@@ -23,6 +23,7 @@ package btree
import
(
import
(
"context"
"context"
"reflect"
"testing"
"testing"
"lab.nexedi.com/kirr/go123/exc"
"lab.nexedi.com/kirr/go123/exc"
...
@@ -98,6 +99,12 @@ func (b *bucketWrap) MaxKey(ctx context.Context) (k int64, ok bool, err error) {
...
@@ -98,6 +99,12 @@ func (b *bucketWrap) MaxKey(ctx context.Context) (k int64, ok bool, err error) {
return
return
}
}
// tVisit is information about one visit call.
type
tVisit
struct
{
node
zodb
.
Oid
keycov
LKeyRange
}
func
TestBTree
(
t
*
testing
.
T
)
{
func
TestBTree
(
t
*
testing
.
T
)
{
X
:=
exc
.
Raiseif
X
:=
exc
.
Raiseif
ctx
:=
context
.
Background
()
ctx
:=
context
.
Background
()
...
@@ -105,6 +112,10 @@ func TestBTree(t *testing.T) {
...
@@ -105,6 +112,10 @@ func TestBTree(t *testing.T) {
if
err
!=
nil
{
if
err
!=
nil
{
t
.
Fatal
(
err
)
t
.
Fatal
(
err
)
}
}
defer
func
()
{
err
:=
stor
.
Close
();
X
(
err
)
}()
db
:=
zodb
.
NewDB
(
stor
,
&
zodb
.
DBOptions
{})
db
:=
zodb
.
NewDB
(
stor
,
&
zodb
.
DBOptions
{})
defer
func
()
{
defer
func
()
{
err
:=
db
.
Close
();
X
(
err
)
err
:=
db
.
Close
();
X
(
err
)
...
@@ -118,8 +129,6 @@ func TestBTree(t *testing.T) {
...
@@ -118,8 +129,6 @@ func TestBTree(t *testing.T) {
t
.
Fatal
(
err
)
t
.
Fatal
(
err
)
}
}
// XXX close db/stor
// go through small test Buckets/BTrees and verify that Get(key) is as expected.
// go through small test Buckets/BTrees and verify that Get(key) is as expected.
for
_
,
tt
:=
range
smallTestv
{
for
_
,
tt
:=
range
smallTestv
{
xobj
,
err
:=
conn
.
Get
(
ctx
,
tt
.
oid
)
xobj
,
err
:=
conn
.
Get
(
ctx
,
tt
.
oid
)
...
@@ -262,4 +271,41 @@ func TestBTree(t *testing.T) {
...
@@ -262,4 +271,41 @@ func TestBTree(t *testing.T) {
// XXX verify FirstBucket / Next ?
// XXX verify FirstBucket / Next ?
verifyFirstBucket
(
B3
)
verifyFirstBucket
(
B3
)
// verify nodes/keycov visited through VGet/V{Min,Max}Key
xBv
,
err
:=
conn
.
Get
(
ctx
,
Bv_oid
);
X
(
err
)
Bv
,
ok
:=
xBv
.
(
*
LOBTree
)
if
!
ok
{
t
.
Fatalf
(
"Bv: %v; got %T; want LOBTree"
,
Bv_oid
,
xBv
)
}
for
k
,
visitOK
:=
range
Bvdict
{
visit
:=
[]
tVisit
{}
_
,
_
,
err
:=
Bv
.
VGet
(
ctx
,
k
,
func
(
node
LONode
,
keycov
LKeyRange
)
{
visit
=
append
(
visit
,
tVisit
{
node
.
POid
(),
keycov
})
});
X
(
err
)
if
!
reflect
.
DeepEqual
(
visit
,
visitOK
)
{
t
.
Errorf
(
"VGet(%d): visit:
\n
have: %v
\n
want: %v"
,
k
,
visit
,
visitOK
)
}
}
/* XXX reenable
visitMinOK := Bvdict[kmin]
visitMaxOK := Bvdict[kmax]
visitMin := []tVisit{}
visitMax := []tVisit{}
_, _, err = Bv.VMinKey(ctx, func(node LONode, keycov LKeyRange) {
visitMin = append(visitMin, tVisit{node.POid(), keycov})
}); X(err)
_, _, err = Bv.VMaxKey(ctx, func(node LONode, keycov LKeyRange) {
visitMax = append(visitMax, tVisit{node.POid(), keycov})
}); X(err)
if !reflect.DeepEqual(visitMin, visitMinOK) {
t.Errorf("VMinKey(): visit:\nhave: %v\nwant: %v", visitMin, visitMinOK)
}
if !reflect.DeepEqual(visitMax, visitMaxOK) {
t.Errorf("VMaxKey(): visit:\nhave: %v\nwant: %v", visitMax, visitMaxOK)
}
*/
}
}
go/zodb/btree/testdata/gen-testdata
View file @
513ef608
...
@@ -59,7 +59,6 @@ def main2():
...
@@ -59,7 +59,6 @@ def main2():
print
>>
f
,
v
print
>>
f
,
v
emit
(
"// Code generated by %s; DO NOT EDIT."
%
__file__
)
emit
(
"// Code generated by %s; DO NOT EDIT."
%
__file__
)
emit
(
"package btree
\
n
"
)
emit
(
"package btree
\
n
"
)
#emit("import \"lab.nexedi.com/kirr/neo/go/zodb\"\n")
def
emititems
(
b
):
def
emititems
(
b
):
s
=
"testEntry{oid: %s, kind: %s, itemv: []kv{"
\
s
=
"testEntry{oid: %s, kind: %s, itemv: []kv{"
\
...
...
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