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
97ecc0ab
Commit
97ecc0ab
authored
Sep 13, 2021
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
35ce1704
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
53 additions
and
30 deletions
+53
-30
wcfs/internal/zdata/δftail_test.go
wcfs/internal/zdata/δftail_test.go
+53
-30
No files found.
wcfs/internal/zdata/δftail_test.go
View file @
97ecc0ab
...
...
@@ -70,6 +70,8 @@ const ø = "ø"
// it is based on xbtreetest.T .
type
T
struct
{
*
xbtreetest
.
T
foid
zodb
.
Oid
// oid of zfile
}
...
...
@@ -434,28 +436,8 @@ func testΔFtail(t_ *testing.T, testq chan ΔFTestEntry) {
// update δFtail
δF
,
err
:=
δFtail
.
Update
(
commit
.
ΔZ
);
X
(
err
)
// assert δF points to the file if δfok != ø
if
δF
.
Rev
!=
commit
.
At
{
t
.
Errorf
(
"wrong δF.Rev: have %s ; want %s"
,
δF
.
Rev
,
commit
.
At
)
}
δfiles
:=
setOid
{}
for
δfile
:=
range
δF
.
ByFile
{
δfiles
.
Add
(
δfile
)
}
δfilesOK
:=
setOid
{}
if
δfok
!=
nil
{
δfilesOK
.
Add
(
foid
)
}
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
[
foid
]
if
!
reflect
.
DeepEqual
(
δf
,
δfok
)
{
t
.
Errorf
(
"δf:
\n
have: %v
\n
want: %v"
,
δf
,
δfok
)
}
// assert δF matches δfok
t
.
assertΔF
(
δF
,
commit
.
At
,
δfok
)
// track whole zfile again if new epoch was started
if
newEpoch
{
...
...
@@ -598,22 +580,19 @@ func TestΔFtailSliceUntrackedUniform(t_ *testing.T) {
// commit t1. all 0, 1 and 2 are in the same bucket.
t1
:=
t
.
CommitTree
(
"T/B0:a,1:b,2:c"
)
δF
,
err
:=
δFtail
.
Update
(
t1
.
ΔZ
);
X
(
err
)
// XXX assert δF == ø
_
=
δF
t
.
assertΔF
(
δF
,
t1
.
At
,
nil
)
// δf empty
t2
:=
t
.
CommitTree
(
"t0:d,1:e,2:c Da:a,b:b,c:c2,d:d,e:e"
)
// 0:-a+d 1:-b+e δc₂
δF
,
err
=
δFtail
.
Update
(
t2
.
ΔZ
);
X
(
err
)
// XXX assert δF
t
.
assertΔF
(
δF
,
t2
.
At
,
nil
)
t3
:=
t
.
CommitTree
(
"t0:d,1:e,2:c Da:a,b:b,c:c3,d:d3,e:e3"
)
// δc₃ δd₃ δe₃
δF
,
err
=
δFtail
.
Update
(
t3
.
ΔZ
);
X
(
err
)
// XXX assert δF
t
.
assertΔF
(
δF
,
t3
.
At
,
nil
)
t4
:=
t
.
CommitTree
(
"t0:d,1:e,2:c Da:a,b:b,c:c4,d:d3,e:e4"
)
// δc₄ δe₄
δF
,
err
=
δFtail
.
Update
(
t4
.
ΔZ
);
X
(
err
)
// XXX assert δF
t
.
assertΔF
(
δF
,
t4
.
At
,
nil
)
// load zfile via root['treegen/file']
txn
,
ctx
:=
transaction
.
New
(
context
.
Background
())
...
...
@@ -693,11 +672,27 @@ func dataTabTxt(dataTab map[string]string) string {
// newT creates new T.
func
newT
(
t
*
testing
.
T
)
*
T
{
return
&
T
{
xbtreetest
.
NewT
(
t
)}
t
.
Helper
()
tt
:=
&
T
{
xbtreetest
.
NewT
(
t
),
zodb
.
InvalidOid
}
// find out zfile's oid
txn
,
ctx
:=
transaction
.
New
(
context
.
Background
())
defer
func
()
{
txn
.
Abort
()
}()
zconn
,
err
:=
tt
.
DB
.
Open
(
ctx
,
&
zodb
.
ConnOptions
{
At
:
tt
.
Head
()
.
At
})
if
err
!=
nil
{
tt
.
Fatal
(
err
)
}
zfile
,
_
:=
tt
.
XLoadZFile
(
ctx
,
zconn
)
tt
.
foid
=
zfile
.
POid
()
return
tt
}
// XLoadZFile loads zfile from root["treegen/file"]@head.
func
(
t
*
T
)
XLoadZFile
(
ctx
context
.
Context
,
zconn
*
zodb
.
Connection
)
(
zfile
*
ZBigFile
,
blksize
int64
)
{
t
.
Helper
()
X
:=
exc
.
Raiseif
xzroot
,
err
:=
zconn
.
Get
(
ctx
,
0
);
X
(
err
)
zroot
:=
xzroot
.
(
*
zodb
.
Map
)
...
...
@@ -714,6 +709,34 @@ func (t *T) XLoadZFile(ctx context.Context, zconn *zodb.Connection) (zfile *ZBig
return
zfile
,
blksize
}
// assertΔF asserts that δF has rev and δf as expected.
func
(
t
*
T
)
assertΔF
(
δF
ΔF
,
rev
zodb
.
Tid
,
δfok
*
ΔFile
)
{
t
.
Helper
()
// assert δF points to zfile if δfok != ø
if
δF
.
Rev
!=
rev
{
t
.
Errorf
(
"wrong δF.Rev: have %s ; want %s"
,
δF
.
Rev
,
rev
)
}
δfiles
:=
setOid
{}
for
δfile
:=
range
δF
.
ByFile
{
δfiles
.
Add
(
δfile
)
}
δfilesOK
:=
setOid
{}
if
δfok
!=
nil
{
δfilesOK
.
Add
(
t
.
foid
)
}
if
!
δfiles
.
Equal
(
δfilesOK
)
{
t
.
Errorf
(
"wrong δF.ByFile:
\n
have keys: %s
\n
want keys: %s"
,
δfiles
,
δfilesOK
)
return
}
// verify δf
δf
:=
δF
.
ByFile
[
t
.
foid
]
if
!
reflect
.
DeepEqual
(
δf
,
δfok
)
{
t
.
Errorf
(
"δf:
\n
have: %v
\n
want: %v"
,
δf
,
δfok
)
}
}
// δfstr/vδfstr convert δf/vδf to string taking symbolic at into account.
func
(
t
*
T
)
δfstr
(
δf
*
ΔFile
)
string
{
s
:=
fmt
.
Sprintf
(
"@%s·%s"
,
t
.
AtSymb
(
δf
.
Rev
),
δf
.
Blocks
)
...
...
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