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
bb52c1f9
Commit
bb52c1f9
authored
Jun 01, 2020
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
1df073df
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
16 deletions
+17
-16
wcfs/δbtail_test.go
wcfs/δbtail_test.go
+17
-16
No files found.
wcfs/δbtail_test.go
View file @
bb52c1f9
...
...
@@ -224,9 +224,8 @@ func XGetKV(db *zodb.DB, at zodb.Tid, kvOid map[Key]Value) map[Key]string {
//
// it is known that @at1 and @at2 the tree has kv1 and kv2 values correspondingly.
// it is known that for at1->at2 ZODB-level change is δZ.
func
xverifyΔBTail
(
t
*
testing
.
T
,
db
*
zodb
.
DB
,
treeRoot
zodb
.
Oid
,
at1
,
at2
zodb
.
Tid
,
kv1
,
kv2
map
[
Key
]
string
,
δZ
*
zodb
.
EventCommit
)
{
func
xverifyΔBTail
(
t
*
testing
.
T
,
subj
string
,
db
*
zodb
.
DB
,
treeRoot
zodb
.
Oid
,
at1
,
at2
zodb
.
Tid
,
kv1
,
kv2
map
[
Key
]
string
,
δZ
*
zodb
.
EventCommit
)
{
d12
:=
kvdiff
(
kv1
,
kv2
)
fmt
.
Println
(
"d12:"
,
d12
)
// verify transition at1->at2 for all initial states of tracked {keys} from kv1 + ∞
keyv1
:=
[]
Key
{
10000
}
// inf, simulating ZBigFile.Size() query
...
...
@@ -242,16 +241,21 @@ func xverifyΔBTail(t *testing.T, db *zodb.DB, treeRoot zodb.Oid, at1, at2 zodb.
keys
.
Add
(
keyv1
[
idx
])
}
xverifyΔBTail1
(
t
,
db
,
treeRoot
,
at1
,
at2
,
kv1
,
kv2
,
d12
,
δZ
,
keys
)
xverifyΔBTail1
(
t
,
subj
,
db
,
treeRoot
,
at1
,
at2
,
kv1
,
kv2
,
d12
,
δZ
,
keys
)
}
}
// xverifyΔBTail1 verifies how ΔBTail handles ZODB update at1->at2 from initial
// tracked state defined by initialTrackedKeys.
func
xverifyΔBTail1
(
t
*
testing
.
T
,
db
*
zodb
.
DB
,
treeRoot
zodb
.
Oid
,
at1
,
at2
zodb
.
Tid
,
kv1
,
kv2
,
d12
map
[
Key
]
string
,
δZ
*
zodb
.
EventCommit
,
initialTrackedKeys
SetKey
)
{
func
xverifyΔBTail1
(
t
*
testing
.
T
,
subj
string
,
db
*
zodb
.
DB
,
treeRoot
zodb
.
Oid
,
at1
,
at2
zodb
.
Tid
,
kv1
,
kv2
,
d12
map
[
Key
]
string
,
δZ
*
zodb
.
EventCommit
,
initialTrackedKeys
SetKey
)
{
X
:=
exc
.
Raiseif
assert
:=
require
.
New
(
t
)
fmt
.
Println
(
"verify1"
,
initialTrackedKeys
)
tracked
:=
initialTrackedKeys
.
Elements
()
sort
.
Slice
(
tracked
,
func
(
i
,
j
int
)
bool
{
return
tracked
[
i
]
<
tracked
[
j
]
})
//fmt.Println("verify1", tracked)
txn
,
ctx
:=
transaction
.
New
(
context
.
Background
())
defer
txn
.
Abort
()
...
...
@@ -292,8 +296,8 @@ func xverifyΔBTail1(t *testing.T, db *zodb.DB, treeRoot zodb.Oid, at1,at2 zodb.
δToid
:=
δB
.
ByRoot
[
treeRoot
]
// {} k -> oid
δT
:=
XGetKV
(
db
,
at2
,
δToid
)
// {} k -> ZBlk(oid).data
fmt
.
Println
(
"d12:"
,
d12
)
fmt
.
Println
(
"δT: "
,
δT
)
//
fmt.Println("d12:", d12)
//
fmt.Println("δT: ", δT)
var
badv
[]
string
badf
:=
func
(
format
string
,
argv
...
interface
{})
{
...
...
@@ -330,14 +334,11 @@ func xverifyΔBTail1(t *testing.T, db *zodb.DB, treeRoot zodb.Oid, at1,at2 zodb.
}
if
badv
!=
nil
{
emsg
:=
"δT is wrong:
\n\n
"
tracked
:=
initialTrackedKeys
.
Elements
()
sort
.
Slice
(
tracked
,
func
(
i
,
j
int
)
bool
{
return
tracked
[
i
]
<
tracked
[
j
]
})
emsg
+=
fmt
.
Sprintf
(
"d12: %v
\n
δT: %v
\n
tracked: %v
\n\n
"
,
d12
,
δT
,
tracked
)
emsg
:=
fmt
.
Sprintf
(
"%s ; tracked=%v : δT is wrong:
\n\n
"
,
subj
,
tracked
)
emsg
+=
fmt
.
Sprintf
(
"d12: %v
\n
δT: %v
\n\n
"
,
d12
,
δT
)
emsg
+=
strings
.
Join
(
badv
,
"
\n
"
)
t
.
Fatal
(
emsg
)
emsg
+=
"
\n
"
t
.
Error
(
emsg
)
}
}
...
...
@@ -437,8 +438,8 @@ func TestΔBTail(t *testing.T) {
at2
:=
δZ
.
Tid
kv2
:=
XGetTree
(
db
,
at2
,
tg
.
treeRoot
)
fmt
.
Printf
(
"
\n
%s -> %s
\n
"
,
tree1
,
tree2
)
// XXX -> subtest? excctx?
xverifyΔBTail
(
t
,
db
,
tg
.
treeRoot
,
at1
,
at2
,
kv1
,
kv2
,
δZ
)
subj
:=
fmt
.
Sprintf
(
"%s -> %s"
,
tree1
,
tree2
)
xverifyΔBTail
(
t
,
subj
,
db
,
tg
.
treeRoot
,
at1
,
at2
,
kv1
,
kv2
,
δZ
)
at1
=
at2
kv1
=
kv2
...
...
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