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
6a279e2f
Commit
6a279e2f
authored
Mar 03, 2017
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
9104c87b
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
82 additions
and
82 deletions
+82
-82
t/neo/storage/fs1/filestorage_test.go
t/neo/storage/fs1/filestorage_test.go
+82
-82
No files found.
t/neo/storage/fs1/filestorage_test.go
View file @
6a279e2f
...
...
@@ -120,60 +120,31 @@ func TestLoad(t *testing.T) {
}
}
func
TestIterate
(
t
*
testing
.
T
)
{
fs
:=
xfsopen
(
t
,
"testdata/1.fs"
)
// TODO open ro
defer
exc
.
XRun
(
fs
.
Close
)
// check iterating XXX move to separate test ?
// tids we will use for tid{Min,Max}
tidv
:=
[]
zodb
.
Tid
{}
for
_
,
dbe
:=
range
_1fs_dbEntryv
{
tidv
=
append
(
tidv
,
dbe
.
Header
.
Tid
)
}
// XXX Fatal -> Error
for
i
,
tidMin
:=
range
tidv
{
minv
:=
[]
zodb
.
Tid
{
tidMin
-
1
,
tidMin
,
tidMin
+
1
}
for
j
,
tidMax
:=
range
tidv
{
maxv
:=
[]
zodb
.
Tid
{
tidMax
-
1
,
tidMax
,
tidMax
+
1
}
for
ii
,
tmin
:=
range
minv
{
for
jj
,
tmax
:=
range
maxv
{
// XXX -> ntxn ?
// expected number of iteration steps
nsteps
:=
j
-
i
+
1
nsteps
-=
ii
/
2
// one less point for tidMin+1
nsteps
-=
(
2
-
jj
)
/
2
// one less point for tidMax-1
if
nsteps
<
0
{
nsteps
=
0
// j < i and j == i and ii/jj
}
//fmt.Printf("%d%+d .. %d%+d\t -> %d steps\n", i, ii-1, j, jj-1, nsteps)
iter
:=
fs
.
Iterate
(
tmin
,
tmax
)
func
testIterate
(
t
*
testing
.
T
,
fs
*
FileStorage
,
tidMin
,
tidMax
zodb
.
Tid
,
expectv
[]
dbEntry
)
{
iter
:=
fs
.
Iterate
(
tidMin
,
tidMax
)
for
k
:=
0
;
;
k
++
{
subj
:=
fmt
.
Sprintf
(
"iterating %v..%v: step %v/%v"
,
tmin
,
tmax
,
k
+
1
,
nsteps
)
subj
:=
fmt
.
Sprintf
(
"iterating %v..%v: step %v/%v"
,
tidMin
,
tidMax
,
k
+
1
,
len
(
expectv
)
)
txni
,
dataIter
,
err
:=
iter
.
NextTxn
()
if
err
!=
nil
{
if
err
==
io
.
EOF
{
if
k
!=
nsteps
{
t
.
Fatal
f
(
"%v: steps underrun"
,
subj
)
if
k
!=
len
(
expectv
)
{
t
.
Error
f
(
"%v: steps underrun"
,
subj
)
}
break
}
t
.
Fatal
f
(
"%v: %v"
,
subj
,
err
)
t
.
Error
f
(
"%v: %v"
,
subj
,
err
)
}
if
k
>=
nsteps
{
t
.
Fatal
f
(
"%v: steps overrun"
,
subj
)
if
k
>=
len
(
expectv
)
{
t
.
Error
f
(
"%v: steps overrun"
,
subj
)
}
dbe
:=
_1fs_dbEntryv
[
i
+
ii
/
2
+
k
]
dbe
:=
expectv
[
k
]
// TODO also check .Pos, .LenPrev, .Len in iter.txnIter.*
if
!
reflect
.
DeepEqual
(
*
txni
,
dbe
.
Header
.
TxnInfo
)
{
t
.
Fatal
f
(
"%v: unexpected txn entry:
\n
have: %q
\n
want: %q"
,
subj
,
*
txni
,
dbe
.
Header
.
TxnInfo
)
t
.
Error
f
(
"%v: unexpected txn entry:
\n
have: %q
\n
want: %q"
,
subj
,
*
txni
,
dbe
.
Header
.
TxnInfo
)
}
ndata
:=
len
(
dbe
.
Entryv
)
...
...
@@ -183,36 +154,65 @@ func TestIterate(t *testing.T) {
if
err
!=
nil
{
if
err
==
io
.
EOF
{
if
kdata
!=
ndata
{
t
.
Fatal
f
(
"%v: data steps underrun"
,
dsubj
)
t
.
Error
f
(
"%v: data steps underrun"
,
dsubj
)
}
break
}
t
.
Fatal
f
(
"%v: %v"
,
dsubj
,
err
)
t
.
Error
f
(
"%v: %v"
,
dsubj
,
err
)
}
if
kdata
>
ndata
{
t
.
Fatal
f
(
"%v: dsteps overrun"
,
dsubj
)
t
.
Error
f
(
"%v: dsteps overrun"
,
dsubj
)
}
txe
:=
dbe
.
Entryv
[
kdata
]
// XXX -> func
if
datai
.
Oid
!=
txe
.
Header
.
Oid
{
t
.
Fatal
f
(
"%v: oid mismatch ..."
,
dsubj
)
// XXX
t
.
Error
f
(
"%v: oid mismatch ..."
,
dsubj
)
// XXX
}
if
datai
.
Tid
!=
txe
.
Header
.
Tid
{
t
.
Fatal
f
(
"%v: tid mismatch ..."
,
dsubj
)
// XXX
t
.
Error
f
(
"%v: tid mismatch ..."
,
dsubj
)
// XXX
}
if
!
bytes
.
Equal
(
datai
.
Data
,
txe
.
Data
())
{
t
.
Fatal
f
(
"%v: data mismatch ..."
,
dsubj
)
// XXX
t
.
Error
f
(
"%v: data mismatch ..."
,
dsubj
)
// XXX
}
// TODO .DataTid
}
}
}
}
}
func
TestIterate
(
t
*
testing
.
T
)
{
fs
:=
xfsopen
(
t
,
"testdata/1.fs"
)
// TODO open ro
defer
exc
.
XRun
(
fs
.
Close
)
// all []tids in test database
tidv
:=
[]
zodb
.
Tid
{}
for
_
,
dbe
:=
range
_1fs_dbEntryv
{
tidv
=
append
(
tidv
,
dbe
.
Header
.
Tid
)
}
// check all i,j pairs in tidv
// for every tid also check ±1 to test edge cases
for
i
,
tidMin
:=
range
tidv
{
for
j
,
tidMax
:=
range
tidv
{
minv
:=
[]
zodb
.
Tid
{
tidMin
-
1
,
tidMin
,
tidMin
+
1
}
maxv
:=
[]
zodb
.
Tid
{
tidMax
-
1
,
tidMax
,
tidMax
+
1
}
for
ii
,
tmin
:=
range
minv
{
for
jj
,
tmax
:=
range
maxv
{
// expected number of txn iteration steps
nsteps
:=
j
-
i
+
1
nsteps
-=
ii
/
2
// one less point for tidMin+1
nsteps
-=
(
2
-
jj
)
/
2
// one less point for tidMax-1
if
nsteps
<
0
{
nsteps
=
0
// j < i and j == i and ii/jj
}
//fmt.Printf("%d%+d .. %d%+d\t -> %d steps\n", i, ii-1, j, jj-1, nsteps)
testIterate
(
t
,
fs
,
tmin
,
tmax
,
_1fs_dbEntryv
[
i
+
ii
/
2
:
][
:
nsteps
])
}}
}}
}
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