Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
W
wendelin.core
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Labels
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
Kirill Smelkov
wendelin.core
Commits
9eef8bdd
Commit
9eef8bdd
authored
3 years ago
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
6b2c1d79
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
28 additions
and
19 deletions
+28
-19
wcfs/internal/zdata/δftail_test.go
wcfs/internal/zdata/δftail_test.go
+28
-19
No files found.
wcfs/internal/zdata/δftail_test.go
View file @
9eef8bdd
...
...
@@ -177,7 +177,7 @@ func testΔFtail(t_ *testing.T, testq chan ΔFTestEntry) {
t
:=
xbtreetest
.
NewT
(
t_
)
X
:=
exc
.
Raiseif
δ
f
tail
:=
NewΔFtail
(
t
.
Head
()
.
At
,
t
.
DB
)
δ
F
tail
:=
NewΔFtail
(
t
.
Head
()
.
At
,
t
.
DB
)
// load zfile via root['treegen/file']
txn
,
ctx
:=
transaction
.
New
(
context
.
Background
())
...
...
@@ -198,7 +198,7 @@ func testΔFtail(t_ *testing.T, testq chan ΔFTestEntry) {
// track zfile[-∞,∞) from the beginning
// this should make ΔFtail to see all zfile changes
size
,
path
,
err
:=
zfile
.
Size
(
ctx
);
X
(
err
)
δ
f
tail
.
Track
(
zfile
,
/*blk*/
-
1
,
path
,
/*zblk*/
nil
)
δ
F
tail
.
Track
(
zfile
,
/*blk*/
-
1
,
path
,
/*zblk*/
nil
)
if
size
!=
0
{
t
.
Fatalf
(
"BUG: zfile is not initially empty: size=%d"
,
size
)
}
...
...
@@ -216,8 +216,18 @@ func testΔFtail(t_ *testing.T, testq chan ΔFTestEntry) {
}
xat
:=
map
[
zodb
.
Tid
]
string
{}
// tid > "at<i>"
xat
[
δftail
.
Head
()]
=
"at0"
t
.
Logf
(
"# @at0 (%s)"
,
δftail
.
Head
())
xat
[
δFtail
.
Head
()]
=
"at0"
t
.
Logf
(
"# @at0 (%s)"
,
δFtail
.
Head
())
// vector of epochs and func to create a new one
epochv
:=
[]
zodb
.
Tid
{
0
}
onNewEpoch
:=
func
(
epoch
zodb
.
Tid
)
{
epochv
=
append
(
epochv
,
epoch
)
for
blk
:=
range
blkTab
{
_
,
path
,
zblk
,
_
,
err
:=
zfile
.
LoadBlk
(
ctx
,
blk
);
X
(
err
)
δFtail
.
Track
(
zfile
,
blk
,
path
,
zblk
)
}
}
// δfstr/vδfstr converts δf/vδf to string taking xat into account
δfstr
:=
func
(
δf
*
ΔFile
)
string
{
...
...
@@ -241,7 +251,6 @@ func testΔFtail(t_ *testing.T, testq chan ΔFTestEntry) {
i
:=
0
delfilePrev
:=
false
epochv
:=
[]
zodb
.
Tid
{
0
}
for
test
:=
range
testq
{
i
++
δblk
:=
setI64
{}
...
...
@@ -316,14 +325,11 @@ func testΔFtail(t_ *testing.T, testq chan ΔFTestEntry) {
req
=
tTxt
+
" "
+
dTxt
}
commit
:=
t
.
CommitTree
(
req
)
if
newEpoch
{
epochv
=
append
(
epochv
,
commit
.
At
)
}
// update blkRevAt
var
blkRevPrev
map
[
int64
]
zodb
.
Tid
if
i
!=
0
{
blkRevPrev
=
blkRevAt
[
δ
f
tail
.
Head
()]
blkRevPrev
=
blkRevAt
[
δ
F
tail
.
Head
()]
}
blkRev
:=
map
[
int64
]
zodb
.
Tid
{}
for
blk
,
rev
:=
range
blkRevPrev
{
...
...
@@ -361,8 +367,11 @@ func testΔFtail(t_ *testing.T, testq chan ΔFTestEntry) {
//fmt.Printf("Zinblk: %v\n", Zinblk)
// update δftail
δF
,
err
:=
δftail
.
Update
(
commit
.
ΔZ
);
X
(
err
)
// update δFtail
δF
,
err
:=
δFtail
.
Update
(
commit
.
ΔZ
);
X
(
err
)
if
newEpoch
{
onNewEpoch
(
commit
.
At
)
}
// assert δF points to the file if δfok != ø
if
δF
.
Rev
!=
commit
.
At
{
...
...
@@ -387,9 +396,9 @@ func testΔFtail(t_ *testing.T, testq chan ΔFTestEntry) {
t
.
Errorf
(
"δf:
\n
have: %v
\n
want: %v"
,
δf
,
δfok
)
}
// verify δ
f
tail.trackSetZBlk
// verify δ
F
tail.trackSetZBlk
trackZinblk
:=
map
[
string
]
setI64
{}
for
oid
,
zt
:=
range
δ
f
tail
.
trackSetZBlk
{
for
oid
,
zt
:=
range
δ
F
tail
.
trackSetZBlk
{
zblki
:=
commit
.
ZBlkTab
[
oid
]
for
root
,
blocks
:=
range
zt
.
inroot
{
if
root
!=
blktabOid
{
...
...
@@ -414,10 +423,10 @@ func testΔFtail(t_ *testing.T, testq chan ΔFTestEntry) {
if
len
(
vδf
)
>=
ncut
{
revcut
:=
vδf
[
0
]
.
Rev
t
.
Logf
(
"# forget ≤ @%s"
,
xat
[
revcut
])
δ
f
tail
.
ForgetPast
(
revcut
)
δ
F
tail
.
ForgetPast
(
revcut
)
vδf
=
vδf
[
1
:
]
//t.Logf("# vδf: %s", vδfstr(vδf))
//t.Logf("# vδt: %s", vδfstr(δ
ftail.SliceByFileRev(zfile, δftail.Tail(), δf
tail.Head())))
//t.Logf("# vδt: %s", vδfstr(δ
Ftail.SliceByFileRev(zfile, δFtail.Tail(), δF
tail.Head())))
}
// SliceByFileRev
...
...
@@ -432,7 +441,7 @@ func testΔFtail(t_ *testing.T, testq chan ΔFTestEntry) {
hi
:=
vδf
[
k
]
.
Rev
vδf_ok
:=
vδf
[
j
:
k
+
1
]
// [j,k]
vδf_
:=
δ
f
tail
.
SliceByFileRev
(
zfile
,
lo
,
hi
)
vδf_
:=
δ
F
tail
.
SliceByFileRev
(
zfile
,
lo
,
hi
)
if
!
reflect
.
DeepEqual
(
vδf_
,
vδf_ok
)
{
t
.
Errorf
(
"slice (@%s,@%s]:
\n
have: %v
\n
want: %v"
,
xat
[
lo
],
xat
[
hi
],
vδfstr
(
vδf_
),
vδfstr
(
vδf_ok
))
}
...
...
@@ -457,7 +466,7 @@ func testΔFtail(t_ *testing.T, testq chan ΔFTestEntry) {
at
:=
vδf
[
j
]
.
Rev
blkRev
:=
blkRevAt
[
at
]
for
_
,
blk
:=
range
blkv
{
rev
,
exact
:=
δ
f
tail
.
LastBlkRev
(
ctx
,
zfile
,
blk
,
at
)
rev
,
exact
:=
δ
F
tail
.
LastBlkRev
(
ctx
,
zfile
,
blk
,
at
)
revOK
,
ok
:=
blkRev
[
blk
]
if
!
ok
{
k
:=
len
(
epochv
)
-
1
...
...
@@ -469,8 +478,8 @@ func testΔFtail(t_ *testing.T, testq chan ΔFTestEntry) {
revOK
=
epochv
[
k
]
}
exactOK
:=
true
if
revOK
<=
δ
f
tail
.
Tail
()
{
revOK
,
exactOK
=
δ
f
tail
.
Tail
(),
false
if
revOK
<=
δ
F
tail
.
Tail
()
{
revOK
,
exactOK
=
δ
F
tail
.
Tail
(),
false
}
if
!
(
rev
==
revOK
&&
exact
==
exactOK
)
{
t
.
Errorf
(
"blkrev #%d @%s:
\n
have: @%s, %v
\n
want: @%s, %v"
,
blk
,
xat
[
at
],
xat
[
rev
],
exact
,
xat
[
revOK
],
exactOK
)
...
...
This diff is collapsed.
Click to expand it.
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