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
02891b74
Commit
02891b74
authored
Jul 08, 2021
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
fdda65cd
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
40 additions
and
12 deletions
+40
-12
wcfs/internal/zdata/δftail_test.go
wcfs/internal/zdata/δftail_test.go
+40
-12
No files found.
wcfs/internal/zdata/δftail_test.go
View file @
02891b74
...
@@ -28,6 +28,7 @@ package zdata
...
@@ -28,6 +28,7 @@ package zdata
import
(
import
(
"context"
"context"
"fmt"
"fmt"
"reflect"
"sort"
"sort"
"strings"
"strings"
"testing"
"testing"
...
@@ -98,7 +99,7 @@ func TestΔFtail(t_ *testing.T) {
...
@@ -98,7 +99,7 @@ func TestΔFtail(t_ *testing.T) {
}
}
// data built via applying changes from testv
// data built via applying changes from testv
vδf
:=
[]
ΔFile
{}
// (rev↑, {}blk) XXX +.Size?
vδf
:=
[]
*
ΔFile
{}
// (rev↑, {}blk) XXX +.Size?
blkTab
:=
map
[
int64
]
string
{}
// #blk -> ZBlk<oid>
blkTab
:=
map
[
int64
]
string
{}
// #blk -> ZBlk<oid>
dataTab
:=
map
[
string
]
string
{}
// ZBlk<oid> -> data
dataTab
:=
map
[
string
]
string
{}
// ZBlk<oid> -> data
Zinblk
:=
map
[
string
]
setI64
{}
// ZBlk<oid> -> which #blk refer to it
Zinblk
:=
map
[
string
]
setI64
{}
// ZBlk<oid> -> which #blk refer to it
...
@@ -111,7 +112,7 @@ func TestΔFtail(t_ *testing.T) {
...
@@ -111,7 +112,7 @@ func TestΔFtail(t_ *testing.T) {
for
i
,
test
:=
range
testv
{
for
i
,
test
:=
range
testv
{
δ
f
:=
setI64
{}
δ
blk
:=
setI64
{}
// rebuild blkTab/Zinblk
// rebuild blkTab/Zinblk
for
blk
,
zblk
:=
range
test
.
δblkTab
{
for
blk
,
zblk
:=
range
test
.
δblkTab
{
...
@@ -132,9 +133,9 @@ func TestΔFtail(t_ *testing.T) {
...
@@ -132,9 +133,9 @@ func TestΔFtail(t_ *testing.T) {
inblk
.
Add
(
blk
)
inblk
.
Add
(
blk
)
}
}
// update δ
f
due to change in blkTab
// update δ
blk
due to change in blkTab
if
zblk
!=
zprev
{
if
zblk
!=
zprev
{
δ
f
.
Add
(
blk
)
δ
blk
.
Add
(
blk
)
}
}
}
}
...
@@ -147,29 +148,56 @@ func TestΔFtail(t_ *testing.T) {
...
@@ -147,29 +148,56 @@ func TestΔFtail(t_ *testing.T) {
data
=
fmt
.
Sprintf
(
"%s%d"
,
data
[
:
1
],
i
)
// e.g. a4
data
=
fmt
.
Sprintf
(
"%s%d"
,
data
[
:
1
],
i
)
// e.g. a4
dataTab
[
zblk
]
=
data
dataTab
[
zblk
]
=
data
// update δ
f
due to change in ZBlk data
// update δ
blk
due to change in ZBlk data
for
blk
:=
range
Zinblk
[
zblk
]
{
for
blk
:=
range
Zinblk
[
zblk
]
{
δ
f
.
Add
(
blk
)
δ
blk
.
Add
(
blk
)
}
}
}
}
vδf
=
append
(
vδf
,
ΔFile
{
if
len
(
δblk
)
==
0
{
Rev
:
zodb
.
InvalidTid
,
// XXX will be set after treegen commit
t
.
Fatal
(
"BUG: prepared δblk = ø"
)
Blocks
:
δf
,
}
δfok
:=
&
ΔFile
{
Rev
:
zodb
.
InvalidTid
,
// will be set after treegen commit
Blocks
:
δblk
,
Size
:
false
/*XXX*/
,
Size
:
false
/*XXX*/
,
}
)
}
// commit updated blkTab + dataTab
// commit updated blkTab + dataTab
tdTxt
:=
fmt
.
Sprintf
(
"t%s D%s"
,
xbtreetest
.
KVTxt
(
blkTab
),
dataTabTxt
(
dataTab
))
tdTxt
:=
fmt
.
Sprintf
(
"t%s D%s"
,
xbtreetest
.
KVTxt
(
blkTab
),
dataTabTxt
(
dataTab
))
commit
:=
t
.
CommitTree
(
tdTxt
)
commit
:=
t
.
CommitTree
(
tdTxt
)
δfok
.
Rev
=
commit
.
At
vδf
=
append
(
vδf
,
δfok
)
fmt
.
Printf
(
"@%s δT: %v δD: %s
\n
"
,
commit
.
At
,
test
.
δblkTab
,
test
.
δdataTab
)
fmt
.
Printf
(
"@%s δT: %v δD: %s
\n
"
,
commit
.
At
,
test
.
δblkTab
,
test
.
δdataTab
)
fmt
.
Printf
(
"@%s %s
\n
"
,
commit
.
At
,
commit
.
Tree
)
fmt
.
Printf
(
"@%s %s
\n
"
,
commit
.
At
,
commit
.
Tree
)
// update δftail
// update δftail
δF
,
err
:=
δftail
.
Update
(
commit
.
ΔZ
);
X
(
err
)
δF
,
err
:=
δftail
.
Update
(
commit
.
ΔZ
);
X
(
err
)
// XXX assert
// assert δF points to the file
_
=
δF
if
δF
.
Rev
!=
δfok
.
Rev
{
t
.
Errorf
(
"wrong δF.Rev: have %s ; want %s"
,
δF
.
Rev
,
δfok
.
Rev
)
}
δfiles
:=
setOid
{}
for
δfile
:=
range
δF
.
ByFile
{
δfiles
.
Add
(
δfile
)
}
δfilesOK
:=
setOid
{};
δfilesOK
.
Add
(
zfile
.
POid
())
if
!
δfiles
.
Equal
(
δfilesOK
)
{
t
.
Errorf
(
"wrong δF.ByFile:
\n
have keys: %s
\n
want keys: %s"
,
δfiles
,
δfilesOK
)
continue
}
// verify δf
δf
:=
δF
.
ByFile
[
zfile
.
POid
()]
if
!
reflect
.
DeepEqual
(
δf
,
δfok
)
{
t
.
Errorf
(
"wrong δf:
\n
have: %v
\n
want: %v"
,
δf
,
δfok
)
}
// XXX verify SliceByFileRev + LastBlkRev
}
}
}
}
...
...
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