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
9feea1a4
Commit
9feea1a4
authored
Jul 09, 2021
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
3c40e38d
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
68 additions
and
36 deletions
+68
-36
wcfs/internal/xbtree/xbtreetest/treeenv.go
wcfs/internal/xbtree/xbtreetest/treeenv.go
+40
-30
wcfs/internal/zdata/δftail_test.go
wcfs/internal/zdata/δftail_test.go
+28
-6
No files found.
wcfs/internal/xbtree/xbtreetest/treeenv.go
View file @
9feea1a4
...
@@ -50,14 +50,19 @@ type T struct {
...
@@ -50,14 +50,19 @@ type T struct {
// Commit represent test commit changing a tree.
// Commit represent test commit changing a tree.
type
Commit
struct
{
type
Commit
struct
{
Tree
string
// the tree in topology-encoding
Tree
string
// the tree in topology-encoding
Prev
*
Commit
// previous commit
Prev
*
Commit
// previous commit
At
zodb
.
Tid
// commit revision
At
zodb
.
Tid
// commit revision
ΔZ
*
zodb
.
EventCommit
// raw ZODB changes; δZ.tid == at
ΔZ
*
zodb
.
EventCommit
// raw ZODB changes; δZ.tid == at
Xkv
RBucketSet
// full tree state as of @at
Xkv
RBucketSet
// full tree state as of @at
Δxkv
map
[
Key
]
Δstring
// full tree-diff against parent
Δxkv
map
[
Key
]
Δstring
// full tree-diff against parent
ZBlkDataTab
map
[
zodb
.
Oid
]
string
// full snapshot of all ZBlk data @at
ZBlkTab
map
[
zodb
.
Oid
]
ZBlkInfo
// full snapshot of all ZBlk name/data @at
// δzblkData map[zodb.Oid]Δstring // full diff for zblkData against parent XXX ?
}
// ZBlkInfo describes one ZBlk object.
type
ZBlkInfo
struct
{
Name
string
// this ZBlk comes under root['treegen/values'][Name]
Data
string
}
}
// NewT creates new T.
// NewT creates new T.
...
@@ -93,13 +98,13 @@ func NewT(t *testing.T) *T {
...
@@ -93,13 +98,13 @@ func NewT(t *testing.T) *T {
head
:=
tt
.
treeSrv
.
head
head
:=
tt
.
treeSrv
.
head
t1
:=
&
Commit
{
t1
:=
&
Commit
{
Tree
:
"T/B:"
,
// treegen.py creates the tree as initially empty
Tree
:
"T/B:"
,
// treegen.py creates the tree as initially empty
Prev
:
nil
,
Prev
:
nil
,
At
:
head
,
At
:
head
,
Xkv
:
xGetTree
(
tt
.
DB
,
head
,
tt
.
Root
()),
Xkv
:
xGetTree
(
tt
.
DB
,
head
,
tt
.
Root
()),
ZBlk
DataTab
:
xGetBlkData
Tab
(
tt
.
DB
,
head
),
ZBlk
Tab
:
xGetBlk
Tab
(
tt
.
DB
,
head
),
ΔZ
:
nil
,
ΔZ
:
nil
,
Δxkv
:
nil
,
Δxkv
:
nil
,
}
}
tt
.
commitv
=
[]
*
Commit
{
t1
}
tt
.
commitv
=
[]
*
Commit
{
t1
}
...
@@ -178,11 +183,11 @@ func (t *T) CommitTree(tree string) *Commit {
...
@@ -178,11 +183,11 @@ func (t *T) CommitTree(tree string) *Commit {
}
}
ttree
:=
&
Commit
{
ttree
:=
&
Commit
{
Tree
:
tree
,
Tree
:
tree
,
At
:
δZ
.
Tid
,
At
:
δZ
.
Tid
,
ΔZ
:
δZ
,
ΔZ
:
δZ
,
Xkv
:
xkv
,
Xkv
:
xkv
,
ZBlk
DataTab
:
xGetBlkData
Tab
(
t
.
DB
,
δZ
.
Tid
),
ZBlk
Tab
:
xGetBlk
Tab
(
t
.
DB
,
δZ
.
Tid
),
}
}
tprev
:=
t
.
Head
()
tprev
:=
t
.
Head
()
...
@@ -194,14 +199,14 @@ func (t *T) CommitTree(tree string) *Commit {
...
@@ -194,14 +199,14 @@ func (t *T) CommitTree(tree string) *Commit {
return
ttree
return
ttree
}
}
// xGetBlk
Data
Tab loads all ZBlk from db@at.
// xGetBlkTab loads all ZBlk from db@at.
//
//
// it returns {} oid -> blkdata.
// it returns {} oid -> blkdata.
func
xGetBlk
DataTab
(
db
*
zodb
.
DB
,
at
zodb
.
Tid
)
map
[
zodb
.
Oid
]
string
{
func
xGetBlk
Tab
(
db
*
zodb
.
DB
,
at
zodb
.
Tid
)
map
[
zodb
.
Oid
]
ZBlkInfo
{
defer
exc
.
Contextf
(
"%s: @%s: get blk
data
tab"
,
db
.
Storage
()
.
URL
(),
at
)
defer
exc
.
Contextf
(
"%s: @%s: get blktab"
,
db
.
Storage
()
.
URL
(),
at
)
X
:=
exc
.
Raiseif
X
:=
exc
.
Raiseif
blk
DataTab
:=
map
[
zodb
.
Oid
]
string
{}
blk
Tab
:=
map
[
zodb
.
Oid
]
ZBlkInfo
{}
txn
,
ctx
:=
transaction
.
New
(
context
.
Background
())
txn
,
ctx
:=
transaction
.
New
(
context
.
Background
())
defer
txn
.
Abort
()
defer
txn
.
Abort
()
...
@@ -228,18 +233,23 @@ func xGetBlkDataTab(db *zodb.DB, at zodb.Tid) map[zodb.Oid]string {
...
@@ -228,18 +233,23 @@ func xGetBlkDataTab(db *zodb.DB, at zodb.Tid) map[zodb.Oid]string {
err
=
zblkdir
.
PActivate
(
ctx
);
X
(
err
)
err
=
zblkdir
.
PActivate
(
ctx
);
X
(
err
)
defer
zblkdir
.
PDeactivate
()
defer
zblkdir
.
PDeactivate
()
for
k
,
xzblk
:=
range
zblkdir
.
Data
{
for
xname
,
xzblk
:=
range
zblkdir
.
Data
{
name
,
ok
:=
xname
.
(
string
)
if
!
ok
{
exc
.
Raisef
(
"root['treegen/values']: key [%q]: expected str, got %T"
,
xname
,
xname
)
}
zblk
,
ok
:=
xzblk
.
(
zodb
.
IPersistent
)
zblk
,
ok
:=
xzblk
.
(
zodb
.
IPersistent
)
if
!
ok
{
if
!
ok
{
exc
.
Raisef
(
"root['treegen/values'][%q]: expected IPersistent, got %s"
,
k
,
xzodb
.
TypeOf
(
xzblk
))
exc
.
Raisef
(
"root['treegen/values'][%q]: expected IPersistent, got %s"
,
name
,
xzodb
.
TypeOf
(
xzblk
))
}
}
oid
:=
zblk
.
POid
()
oid
:=
zblk
.
POid
()
data
:=
xzgetBlkData
(
ctx
,
zconn
,
oid
)
data
:=
xzgetBlkData
(
ctx
,
zconn
,
oid
)
blk
DataTab
[
oid
]
=
data
blk
Tab
[
oid
]
=
ZBlkInfo
{
name
,
data
}
}
}
return
blk
Data
Tab
return
blkTab
}
}
// XGetBlkData loads blk data for ZBlk<oid> @t.at
// XGetBlkData loads blk data for ZBlk<oid> @t.at
...
@@ -249,11 +259,11 @@ func (t *Commit) XGetBlkData(oid zodb.Oid) string {
...
@@ -249,11 +259,11 @@ func (t *Commit) XGetBlkData(oid zodb.Oid) string {
if
oid
==
VDEL
{
if
oid
==
VDEL
{
return
DEL
return
DEL
}
}
data
,
ok
:=
t
.
ZBlkData
Tab
[
oid
]
zblki
,
ok
:=
t
.
ZBlk
Tab
[
oid
]
if
!
ok
{
if
!
ok
{
exc
.
Raisef
(
"getBlkData ZBlk<%s> @%s: no such ZBlk"
,
oid
,
t
.
At
)
exc
.
Raisef
(
"getBlkData ZBlk<%s> @%s: no such ZBlk"
,
oid
,
t
.
At
)
}
}
return
d
ata
return
zblki
.
D
ata
}
}
...
...
wcfs/internal/zdata/δftail_test.go
View file @
9feea1a4
...
@@ -82,6 +82,7 @@ func testΔFtail(t_ *testing.T, testq chan ΔFTestEntry) {
...
@@ -82,6 +82,7 @@ func testΔFtail(t_ *testing.T, testq chan ΔFTestEntry) {
err
=
zroot
.
PActivate
(
ctx
);
X
(
err
)
err
=
zroot
.
PActivate
(
ctx
);
X
(
err
)
defer
zroot
.
PDeactivate
()
defer
zroot
.
PDeactivate
()
zfile
:=
zroot
.
Data
[
"treegen/file"
]
.
(
*
ZBigFile
)
zfile
:=
zroot
.
Data
[
"treegen/file"
]
.
(
*
ZBigFile
)
zfileOid
:=
zfile
.
POid
()
err
=
zfile
.
PActivate
(
ctx
);
X
(
err
)
err
=
zfile
.
PActivate
(
ctx
);
X
(
err
)
defer
zfile
.
PDeactivate
()
defer
zfile
.
PDeactivate
()
if
treeOid
:=
zfile
.
blktab
.
POid
();
treeOid
!=
t
.
Root
()
{
if
treeOid
:=
zfile
.
blktab
.
POid
();
treeOid
!=
t
.
Root
()
{
...
@@ -103,9 +104,8 @@ func testΔFtail(t_ *testing.T, testq chan ΔFTestEntry) {
...
@@ -103,9 +104,8 @@ func testΔFtail(t_ *testing.T, testq chan ΔFTestEntry) {
Zinblk
:=
map
[
string
]
setI64
{}
// ZBlk<name> -> which #blk refer to it
Zinblk
:=
map
[
string
]
setI64
{}
// ZBlk<name> -> which #blk refer to it
// initialize dataTab from root['treegen/values']
// initialize dataTab from root['treegen/values']
for
/*oid*/
_
,
zblk
:=
range
t
.
Head
()
.
ZBlkDataTab
{
for
/*oid*/
_
,
zblki
:=
range
t
.
Head
()
.
ZBlkTab
{
// treegen initializes values[x] = ZBlk(x)
dataTab
[
zblki
.
Name
]
=
zblki
.
Data
dataTab
[
zblk
]
=
zblk
}
}
...
@@ -186,7 +186,7 @@ func testΔFtail(t_ *testing.T, testq chan ΔFTestEntry) {
...
@@ -186,7 +186,7 @@ func testΔFtail(t_ *testing.T, testq chan ΔFTestEntry) {
}
}
δfilesOK
:=
setOid
{}
δfilesOK
:=
setOid
{}
if
δfok
!=
nil
{
if
δfok
!=
nil
{
δfilesOK
.
Add
(
zfile
.
POid
()
)
δfilesOK
.
Add
(
zfile
Oid
)
}
}
if
!
δfiles
.
Equal
(
δfilesOK
)
{
if
!
δfiles
.
Equal
(
δfilesOK
)
{
t
.
Errorf
(
"wrong δF.ByFile:
\n
have keys: %s
\n
want keys: %s"
,
δfiles
,
δfilesOK
)
t
.
Errorf
(
"wrong δF.ByFile:
\n
have keys: %s
\n
want keys: %s"
,
δfiles
,
δfilesOK
)
...
@@ -198,9 +198,31 @@ func testΔFtail(t_ *testing.T, testq chan ΔFTestEntry) {
...
@@ -198,9 +198,31 @@ func testΔFtail(t_ *testing.T, testq chan ΔFTestEntry) {
}
}
// verify δf
// verify δf
δf
:=
δF
.
ByFile
[
zfile
.
POid
()
]
δf
:=
δF
.
ByFile
[
zfile
Oid
]
if
!
reflect
.
DeepEqual
(
δf
,
δfok
)
{
if
!
reflect
.
DeepEqual
(
δf
,
δfok
)
{
t
.
Errorf
(
"wrong δf:
\n
have: %v
\n
want: %v"
,
δf
,
δfok
)
t
.
Errorf
(
"δf:
\n
have: %v
\n
want: %v"
,
δf
,
δfok
)
}
// verify δftail.trackSetZBlk
trackZinblk
:=
map
[
string
]
setI64
{}
for
oid
,
zt
:=
range
δftail
.
trackSetZBlk
{
zblki
:=
commit
.
ZBlkTab
[
oid
]
for
foid
,
blocks
:=
range
zt
.
infile
{
if
foid
!=
zfileOid
{
t
.
Errorf
(
".trackSetZBlk: zblk %s points to unexpected file %s"
,
zblki
.
Name
,
foid
)
continue
}
inblk
,
ok
:=
trackZinblk
[
zblki
.
Name
]
if
!
ok
{
inblk
=
setI64
{}
trackZinblk
[
zblki
.
Name
]
=
inblk
}
inblk
.
Update
(
blocks
)
}
}
if
!
reflect
.
DeepEqual
(
trackZinblk
,
Zinblk
)
{
t
.
Errorf
(
".trackSetZBlk:
\n
~have: %v
\n
want: %v"
,
trackZinblk
,
Zinblk
)
}
}
// XXX ForgePast configure threshold
// XXX ForgePast configure threshold
...
...
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