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
d4ff5502
Commit
d4ff5502
authored
Jul 31, 2018
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
10480280
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
62 additions
and
9 deletions
+62
-9
go/zodb/btree/btree_test.go
go/zodb/btree/btree_test.go
+35
-2
go/zodb/btree/py/gen-testdata
go/zodb/btree/py/gen-testdata
+21
-4
go/zodb/btree/ztestdata_expect_test.go
go/zodb/btree/ztestdata_expect_test.go
+6
-3
No files found.
go/zodb/btree/btree_test.go
View file @
d4ff5502
...
@@ -36,12 +36,24 @@ type kv struct {
...
@@ -36,12 +36,24 @@ type kv struct {
value
interface
{}
value
interface
{}
}
}
type
bkind
int
const
(
kindBucket
bkind
=
iota
kindBTree
)
// testEntry is information about a Bucket or a BTree.
// testEntry is information about a Bucket or a BTree.
type
testEntry
struct
{
type
testEntry
struct
{
oid
zodb
.
Oid
oid
zodb
.
Oid
kind
bkind
itemv
[]
kv
itemv
[]
kv
}
}
// bmapping represents Get of Bucket or BTree.
type
bmapping
interface
{
Get
(
context
.
Context
,
KEY
)
(
interface
{},
bool
,
error
)
}
func
TestBucket
(
t
*
testing
.
T
)
{
func
TestBucket
(
t
*
testing
.
T
)
{
ctx
:=
context
.
Background
()
ctx
:=
context
.
Background
()
stor
,
err
:=
zodb
.
OpenStorage
(
ctx
,
"testdata/1.fs"
,
&
zodb
.
OpenOptions
{
ReadOnly
:
true
})
stor
,
err
:=
zodb
.
OpenStorage
(
ctx
,
"testdata/1.fs"
,
&
zodb
.
OpenOptions
{
ReadOnly
:
true
})
...
@@ -64,9 +76,27 @@ func TestBucket(t *testing.T) {
...
@@ -64,9 +76,27 @@ func TestBucket(t *testing.T) {
t
.
Fatal
(
err
)
t
.
Fatal
(
err
)
}
}
obj
,
ok
:=
xobj
.
(
*
Bucket
)
obj
,
ok
:=
xobj
.
(
bmapping
)
if
!
ok
{
if
!
ok
{
t
.
Fatalf
(
"%s: got %T; want Bucket"
,
tt
.
oid
,
xobj
)
t
.
Fatalf
(
"%s: got %T; want Bucket|BTree"
,
tt
.
oid
,
xobj
)
}
want
:=
""
switch
tt
.
kind
{
case
kindBucket
:
if
_
,
ok
=
obj
.
(
*
Bucket
);
!
ok
{
want
=
"Bucket"
}
case
kindBTree
:
if
_
,
ok
=
obj
.
(
*
BTree
);
!
ok
{
want
=
"BTree"
}
default
:
panic
(
0
)
}
if
want
!=
""
{
t
.
Fatalf
(
"%s: got %T; want %s"
,
tt
.
oid
,
obj
,
want
)
}
}
for
_
,
kv
:=
range
tt
.
itemv
{
for
_
,
kv
:=
range
tt
.
itemv
{
...
@@ -84,6 +114,9 @@ func TestBucket(t *testing.T) {
...
@@ -84,6 +114,9 @@ func TestBucket(t *testing.T) {
if
value
!=
kv
.
value
{
if
value
!=
kv
.
value
{
t
.
Errorf
(
"get %v -> %v; want %v"
,
kv
.
key
,
value
,
kv
.
value
)
t
.
Errorf
(
"get %v -> %v; want %v"
,
kv
.
key
,
value
,
kv
.
value
)
}
}
// XXX .next == nil
// XXX check keys, values directly (i.e. there is nothing else)
}
}
}
}
}
}
go/zodb/btree/py/gen-testdata
View file @
d4ff5502
...
@@ -21,7 +21,7 @@
...
@@ -21,7 +21,7 @@
"""generate test data for btree serialization tests"""
"""generate test data for btree serialization tests"""
from
ZODB.DB
import
DB
from
ZODB.DB
import
DB
from
BTrees.LOBTree
import
LOBucket
from
BTrees.LOBTree
import
LOBucket
,
LOBTree
from
ZODB.utils
import
u64
from
ZODB.utils
import
u64
import
os
,
transaction
import
os
,
transaction
...
@@ -40,6 +40,12 @@ def main():
...
@@ -40,6 +40,12 @@ def main():
root
[
'b1'
]
=
b1
=
LOBucket
([(
10
,
17
)])
# 1k -> 1v
root
[
'b1'
]
=
b1
=
LOBucket
([(
10
,
17
)])
# 1k -> 1v
root
[
'b2'
]
=
b2
=
LOBucket
([(
15
,
1
),
(
23
,
"hello"
)])
# 2k -> 2v
root
[
'b2'
]
=
b2
=
LOBucket
([(
15
,
1
),
(
23
,
"hello"
)])
# 2k -> 2v
root
[
'B0'
]
=
B0
=
LOBTree
()
# empty btree
root
[
'B1'
]
=
B1
=
LOBTree
({
5
:
4
})
# btree with 1 bucket (1kv)
root
[
'B2'
]
=
B2
=
LOBTree
({
7
:
3
,
9
:
"world"
})
# btree with 1 bucket (2kv)
root
[
'B3'
]
=
B3
=
LOBTree
(
dict
([(
_
,
_
)
for
_
in
range
(
10000
)]))
transaction
.
commit
()
transaction
.
commit
()
with
open
(
"ztestdata_expect_test.go"
,
"w"
)
as
f
:
with
open
(
"ztestdata_expect_test.go"
,
"w"
)
as
f
:
...
@@ -49,9 +55,9 @@ def main():
...
@@ -49,9 +55,9 @@ def main():
emit
(
"package btree
\
n
"
)
emit
(
"package btree
\
n
"
)
#emit("import \"lab.nexedi.com/kirr/neo/go/zodb\"\n")
#emit("import \"lab.nexedi.com/kirr/neo/go/zodb\"\n")
emit
(
"
\
n
var _bucketTestv = [...]testEntry{"
)
def
emititems
(
b
):
for
b
in
(
b0
,
b1
,
b2
):
s
=
"testEntry{oid: %s, kind: %s, itemv: []kv{"
\
s
=
"testEntry{oid: %s, itemv: []kv{"
%
u64
(
b
.
_p_oid
)
%
(
u64
(
b
.
_p_oid
),
"kind%s"
%
type
(
b
).
__name__
[
2
:]
)
for
k
,
v
in
b
.
items
():
for
k
,
v
in
b
.
items
():
if
isinstance
(
v
,
str
):
if
isinstance
(
v
,
str
):
v
=
qq
(
v
)
v
=
qq
(
v
)
...
@@ -63,8 +69,19 @@ def main():
...
@@ -63,8 +69,19 @@ def main():
s
+=
"{%s, %s}, "
%
(
k
,
v
)
s
+=
"{%s, %s}, "
%
(
k
,
v
)
s
+=
"}},"
s
+=
"}},"
emit
(
"
\
t
"
+
s
)
emit
(
"
\
t
"
+
s
)
emit
(
"
\
n
var _bucketTestv = [...]testEntry{"
)
for
b
in
(
b0
,
b1
,
b2
,
B0
,
B1
,
B2
):
emititems
(
b
)
emit
(
"}"
)
emit
(
"}"
)
# emit("\nvar _btreeTestv = [...]testEntry{")
# for B in (B0, B1, B2): # XXX + B3
# emititems(B)
# emit("}")
# XXX B3
conn
.
close
()
conn
.
close
()
db
.
close
()
db
.
close
()
...
...
go/zodb/btree/ztestdata_expect_test.go
View file @
d4ff5502
...
@@ -3,7 +3,10 @@ package btree
...
@@ -3,7 +3,10 @@ package btree
var
_bucketTestv
=
[
...
]
testEntry
{
var
_bucketTestv
=
[
...
]
testEntry
{
testEntry
{
oid
:
1
,
itemv
:
[]
kv
{}},
testEntry
{
oid
:
6
,
kind
:
kindBucket
,
itemv
:
[]
kv
{}},
testEntry
{
oid
:
2
,
itemv
:
[]
kv
{{
10
,
int64
(
17
)},
}},
testEntry
{
oid
:
3
,
kind
:
kindBucket
,
itemv
:
[]
kv
{{
10
,
int64
(
17
)},
}},
testEntry
{
oid
:
3
,
itemv
:
[]
kv
{{
15
,
int64
(
1
)},
{
23
,
"hello"
},
}},
testEntry
{
oid
:
1
,
kind
:
kindBucket
,
itemv
:
[]
kv
{{
15
,
int64
(
1
)},
{
23
,
"hello"
},
}},
testEntry
{
oid
:
2
,
kind
:
kindBTree
,
itemv
:
[]
kv
{}},
testEntry
{
oid
:
7
,
kind
:
kindBTree
,
itemv
:
[]
kv
{{
5
,
int64
(
4
)},
}},
testEntry
{
oid
:
4
,
kind
:
kindBTree
,
itemv
:
[]
kv
{{
7
,
int64
(
3
)},
{
9
,
"world"
},
}},
}
}
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