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
1a10f6bc
Commit
1a10f6bc
authored
Jul 11, 2021
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
210e9b07
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
104 additions
and
103 deletions
+104
-103
wcfs/internal/zdata/δftail_test.go
wcfs/internal/zdata/δftail_test.go
+104
-103
No files found.
wcfs/internal/zdata/δftail_test.go
View file @
1a10f6bc
...
...
@@ -36,7 +36,7 @@ package zdata
//
// a) transition a ZBigFile in ZODB through particular .blktab and ZBlk
// states and feed ΔFtail through created database transactions.
// b) transition a ZBigFile in ZODB through
random
.blktab and ZBlk
// b) transition a ZBigFile in ZODB through
random
.blktab and ZBlk
// states and feed ΔFtail through created database transactions.
//
// TestΔFtail and TestΔFtailRandom implement approaches "a" and "b" correspondingly.
...
...
@@ -67,6 +67,109 @@ type ΔFTestEntry struct {
δdataTab
setStr
// changes to ZBlk objects
}
// TestΔFtail runs ΔFtail tests on set of concrete prepared testcases.
func
TestΔFtail
(
t
*
testing
.
T
)
{
// δT is shorthand to create δblkTab.
type
δT
=
map
[
int64
]
string
// δD is shorthand to create δdataTab.
δD
:=
func
(
zblkv
...
string
)
setStr
{
δ
:=
setStr
{}
for
_
,
zblk
:=
range
zblkv
{
δ
.
Add
(
zblk
)
}
return
δ
}
const
a
,
b
,
c
,
d
,
e
,
f
,
g
,
h
,
i
,
j
=
"a"
,
"b"
,
"c"
,
"d"
,
"e"
,
"f"
,
"g"
,
"h"
,
"i"
,
"j"
testv
:=
[]
ΔFTestEntry
{
{
δT
{
1
:
a
,
2
:
b
,
3
:
ø
},
δD
(
a
)},
{
δT
{},
δD
(
c
)},
{
δT
{
2
:
c
},
δD
(
a
,
b
)},
// clear the tree
{
δT
{
1
:
ø
,
2
:
ø
},
δD
()},
// i is first associated with file, but later unlinked from it
// then i is changed -> the file should no be in δF
{
δT
{
5
:
i
},
δD
()},
{
δT
{
5
:
e
},
δD
()},
{
δT
{},
δD
(
i
)},
// XXX more
// ---- found by TestΔFtailRandom ----
{
δT
{
1
:
a
,
6
:
i
,
7
:
d
,
8
:
e
},
δD
(
a
,
c
,
e
,
f
,
g
,
h
,
i
,
j
)},
// was including <= lo entries in SliceByFileRev
{
δT
{
0
:
b
,
2
:
j
,
3
:
i
,
5
:
f
,
6
:
b
,
7
:
i
,
8
:
d
},
δD
(
a
,
b
,
c
,
d
,
e
,
g
,
i
,
j
)},
{
δT
{
0
:
e
,
2
:
h
,
4
:
d
,
9
:
b
},
δD
(
a
,
h
,
i
)},
{
δT
{
0
:
j
,
1
:
i
,
3
:
g
,
5
:
a
,
6
:
e
,
7
:
j
,
8
:
f
,
9
:
d
},
δD
()},
{
δT
{
0
:
b
,
1
:
f
,
2
:
h
,
4
:
b
,
8
:
b
},
δD
(
b
,
d
,
i
)},
{
δT
{
1
:
a
,
3
:
d
,
6
:
j
},
δD
(
b
,
c
,
d
,
f
,
g
,
h
,
i
,
j
)},
{
δT
{
0
:
i
,
1
:
f
,
4
:
e
,
5
:
e
,
7
:
d
,
8
:
h
},
δD
(
d
,
j
)},
{
δT
{},
δD
(
a
,
b
,
c
,
e
,
f
,
g
,
h
,
i
,
j
)},
}
testq
:=
make
(
chan
ΔFTestEntry
)
go
func
()
{
defer
close
(
testq
)
for
_
,
test
:=
range
testv
{
testq
<-
test
}
}()
testΔFtail
(
t
,
testq
)
}
// TestΔFtailRandom runs ΔFtail tests on randomly-generated file changes.
func
TestΔFtailRandom
(
t
*
testing
.
T
)
{
n
:=
xbtreetest
.
N
(
1E3
,
1E4
,
1E5
)
nblk
:=
xbtreetest
.
N
(
1E1
,
2E1
,
1E2
)
// keeps failures detail small on -short
// random-number generator
rng
,
seed
:=
xbtreetest
.
NewRand
()
t
.
Logf
(
"# n=%d seed=%d"
,
n
,
seed
)
vv
:=
"abcdefghij"
randv
:=
func
()
string
{
i
:=
rng
.
Intn
(
len
(
vv
))
return
vv
[
i
:
i
+
1
]
}
testq
:=
make
(
chan
ΔFTestEntry
)
go
func
()
{
defer
close
(
testq
)
for
i
:=
0
;
i
<
n
;
i
++
{
nδblkTab
:=
rng
.
Intn
(
nblk
)
nδdataTab
:=
rng
.
Intn
(
len
(
vv
))
δblkTab
:=
map
[
int64
]
string
{}
δdataTab
:=
setStr
{}
blkv
:=
rng
.
Perm
(
nblk
)
for
j
:=
0
;
j
<
nδblkTab
;
j
++
{
blk
:=
blkv
[
j
]
zblk
:=
randv
()
δblkTab
[
int64
(
blk
)]
=
zblk
}
vv_
:=
rng
.
Perm
(
len
(
vv
))
for
j
:=
0
;
j
<
nδdataTab
;
j
++
{
k
:=
vv_
[
j
]
v
:=
vv
[
k
:
k
+
1
]
δdataTab
.
Add
(
v
)
}
testq
<-
ΔFTestEntry
{
δblkTab
,
δdataTab
}
}
}()
testΔFtail
(
t
,
testq
)
}
// testΔFtail verifies ΔFtail on sequence on testcases coming from testq.
func
testΔFtail
(
t_
*
testing
.
T
,
testq
chan
ΔFTestEntry
)
{
t
:=
xbtreetest
.
NewT
(
t_
)
X
:=
exc
.
Raiseif
...
...
@@ -276,108 +379,6 @@ func testΔFtail(t_ *testing.T, testq chan ΔFTestEntry) {
}
}
// TestΔFtail runs ΔFtail tests on set of concrete prepared testcases.
func
TestΔFtail
(
t
*
testing
.
T
)
{
// δT is shorthand to create δblkTab.
type
δT
=
map
[
int64
]
string
// δD is shorthand to create δdataTab.
δD
:=
func
(
zblkv
...
string
)
setStr
{
δ
:=
setStr
{}
for
_
,
zblk
:=
range
zblkv
{
δ
.
Add
(
zblk
)
}
return
δ
}
const
a
,
b
,
c
,
d
,
e
,
f
,
g
,
h
,
i
,
j
=
"a"
,
"b"
,
"c"
,
"d"
,
"e"
,
"f"
,
"g"
,
"h"
,
"i"
,
"j"
testv
:=
[]
ΔFTestEntry
{
{
δT
{
1
:
a
,
2
:
b
,
3
:
ø
},
δD
(
a
)},
{
δT
{},
δD
(
c
)},
{
δT
{
2
:
c
},
δD
(
a
,
b
)},
// clear the tree
{
δT
{
1
:
ø
,
2
:
ø
},
δD
()},
// i is first associated with file, but later unlinked from it
// then i is changed -> the file should no be in δF
{
δT
{
5
:
i
},
δD
()},
{
δT
{
5
:
e
},
δD
()},
{
δT
{},
δD
(
i
)},
// XXX more
// ---- found by TestΔFtailRandom ----
{
δT
{
1
:
a
,
6
:
i
,
7
:
d
,
8
:
e
},
δD
(
a
,
c
,
e
,
f
,
g
,
h
,
i
,
j
)},
// was including <= lo entries in SliceByFileRev
{
δT
{
0
:
b
,
2
:
j
,
3
:
i
,
5
:
f
,
6
:
b
,
7
:
i
,
8
:
d
},
δD
(
a
,
b
,
c
,
d
,
e
,
g
,
i
,
j
)},
{
δT
{
0
:
e
,
2
:
h
,
4
:
d
,
9
:
b
},
δD
(
a
,
h
,
i
)},
{
δT
{
0
:
j
,
1
:
i
,
3
:
g
,
5
:
a
,
6
:
e
,
7
:
j
,
8
:
f
,
9
:
d
},
δD
()},
{
δT
{
0
:
b
,
1
:
f
,
2
:
h
,
4
:
b
,
8
:
b
},
δD
(
b
,
d
,
i
)},
{
δT
{
1
:
a
,
3
:
d
,
6
:
j
},
δD
(
b
,
c
,
d
,
f
,
g
,
h
,
i
,
j
)},
{
δT
{
0
:
i
,
1
:
f
,
4
:
e
,
5
:
e
,
7
:
d
,
8
:
h
},
δD
(
d
,
j
)},
{
δT
{},
δD
(
a
,
b
,
c
,
e
,
f
,
g
,
h
,
i
,
j
)},
}
testq
:=
make
(
chan
ΔFTestEntry
)
go
func
()
{
defer
close
(
testq
)
for
_
,
test
:=
range
testv
{
testq
<-
test
}
}()
testΔFtail
(
t
,
testq
)
}
// TestΔFtailRandom runs ΔFtail tests on randomly-generated file changes.
func
TestΔFtailRandom
(
t
*
testing
.
T
)
{
n
:=
xbtreetest
.
N
(
1E3
,
1E4
,
1E5
)
nblk
:=
xbtreetest
.
N
(
1E1
,
2E1
,
1E2
)
// keeps failures detail small on -short
// random-number generator
rng
,
seed
:=
xbtreetest
.
NewRand
()
t
.
Logf
(
"# n=%d seed=%d"
,
n
,
seed
)
vv
:=
"abcdefghij"
randv
:=
func
()
string
{
i
:=
rng
.
Intn
(
len
(
vv
))
return
vv
[
i
:
i
+
1
]
}
testq
:=
make
(
chan
ΔFTestEntry
)
go
func
()
{
defer
close
(
testq
)
for
i
:=
0
;
i
<
n
;
i
++
{
nδblkTab
:=
rng
.
Intn
(
nblk
)
nδdataTab
:=
rng
.
Intn
(
len
(
vv
))
δblkTab
:=
map
[
int64
]
string
{}
δdataTab
:=
setStr
{}
blkv
:=
rng
.
Perm
(
nblk
)
for
j
:=
0
;
j
<
nδblkTab
;
j
++
{
blk
:=
blkv
[
j
]
zblk
:=
randv
()
δblkTab
[
int64
(
blk
)]
=
zblk
}
vv_
:=
rng
.
Perm
(
len
(
vv
))
for
j
:=
0
;
j
<
nδdataTab
;
j
++
{
k
:=
vv_
[
j
]
v
:=
vv
[
k
:
k
+
1
]
δdataTab
.
Add
(
v
)
}
testq
<-
ΔFTestEntry
{
δblkTab
,
δdataTab
}
}
}()
testΔFtail
(
t
,
testq
)
}
// dataTabTxt returns string representation of {} dataTab.
func
dataTabTxt
(
dataTab
map
[
string
]
string
)
string
{
...
...
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