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
e728f5db
Commit
e728f5db
authored
Oct 25, 2020
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
d89e5f74
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
0 additions
and
132 deletions
+0
-132
wcfs/δbtail_test.go
wcfs/δbtail_test.go
+0
-132
No files found.
wcfs/δbtail_test.go
View file @
e728f5db
...
...
@@ -49,16 +49,13 @@ import (
"fmt"
"io"
"io/ioutil"
"math/rand"
"os"
"os/exec"
"reflect"
"regexp"
"sort"
"strconv"
"strings"
"testing"
"time"
"lab.nexedi.com/kirr/go123/exc"
"lab.nexedi.com/kirr/go123/xerr"
...
...
@@ -1082,98 +1079,6 @@ func TestΔBTail(t *testing.T) {
}
// TestΔBTreeAllStructs verifies ΔBtail on tree topologies generated by AllStructs.
func
TestΔBTreeAllStructs
(
t
*
testing
.
T
)
{
X
:=
exc
.
Raiseif
// considerations:
// - depth↑ better for testing (more tricky topologies)
// - nsplit↑ not so better for testing (leave s=1, max s=2)
// - |kmin - kmax| affects N(variants) significantly
// -> keep key range small (dumb increase does not help testing)
// - N(keys) affects N(variants) significantly
// -> keep Nkeys reasonably small/medium (dumb increase does not help testing)
//
// - spawning python subprocess is very slow (takes 300-500ms for
// imports; https://github.com/pypa/setuptools/issues/510)
// -> we spawn `treegen allstructs` once and use request/response approach.
maxdepth
:=
2
// XXX -> 3?
maxsplit
:=
1
// XXX -> 2?
n
:=
10
// XXX -> more?
nkeys
:=
5
;
if
testing
.
Short
()
{
nkeys
-=
2
}
// server to generate AllStructs(kv1, kv2, ...)
sg
,
err
:=
StartAllStructsSrv
();
X
(
err
)
defer
func
()
{
err
:=
sg
.
Close
();
X
(
err
)
}()
// random seed
seed
:=
time
.
Now
()
.
UnixNano
()
seeds
:=
os
.
Getenv
(
"DBTail_SEED"
)
if
seeds
!=
""
{
var
err
error
seed
,
err
=
strconv
.
ParseInt
(
seeds
,
10
,
64
)
if
err
!=
nil
{
t
.
Fatalf
(
"invalid $DBTail_SEED=%s: %s"
,
seeds
,
err
)
}
}
rng
:=
rand
.
New
(
rand
.
NewSource
(
seed
))
t
.
Logf
(
"# maxdepth=%d maxsplit=%d nkeys=%d n=%d seed=%d"
,
maxdepth
,
maxsplit
,
nkeys
,
n
,
seed
)
// generate (kv1, kv2) pairs randomly
// keysv1 and keysv2 are random shuffle of IntSets
var
keysv1
[][]
int
var
keysv2
[][]
int
for
keys
:=
range
IntSets
(
nkeys
)
{
keysv1
=
append
(
keysv1
,
keys
)
keysv2
=
append
(
keysv2
,
keys
)
}
v
:=
keysv1
rng
.
Shuffle
(
len
(
v
),
func
(
i
,
j
int
)
{
v
[
i
],
v
[
j
]
=
v
[
j
],
v
[
i
]
})
v
=
keysv2
rng
.
Shuffle
(
len
(
v
),
func
(
i
,
j
int
)
{
v
[
i
],
v
[
j
]
=
v
[
j
],
v
[
i
]
})
// generate cases: keysv1[i] -> keysv2[i] with values generated
// randomly along the way.
vv
:=
"abcdefgh"
randv
:=
func
()
string
{
i
:=
rng
.
Intn
(
len
(
vv
))
return
vv
[
i
:
i
+
1
]
}
testq
:=
make
(
chan
ΔBTestEntry
)
go
func
()
{
defer
close
(
testq
)
for
i
:=
range
keysv1
{
keys1
:=
keysv1
[
i
]
keys2
:=
keysv2
[
i
]
kv1
:=
map
[
Key
]
string
{}
kv2
:=
map
[
Key
]
string
{}
for
k
:=
range
keys1
{
kv1
[
Key
(
k
)]
=
randv
()
}
for
k
:=
range
keys2
{
kv2
[
Key
(
k
)]
=
randv
()
}
// given (kv1, kv2) - test on automatically generated (tree1 -> tree2)
reqSeed
:=
rng
.
Int63
()
treev
,
err
:=
sg
.
AllStructs
(
kv1
,
kv2
,
maxdepth
,
maxsplit
,
n
,
reqSeed
)
if
err
!=
nil
{
t
.
Fatal
(
err
)
}
for
_
,
tree
:=
range
treev
{
testq
<-
ΔBTestEntry
{
tree
,
nil
}
}
}
}()
testΔBTail
(
t
,
testq
)
}
// ---- misc ----
...
...
@@ -1202,24 +1107,6 @@ func intSets(ch chan []int, lo, hi int) {
close
(
ch
)
}
func
TestIntSets
(
t
*
testing
.
T
)
{
got
:=
[][]
int
{}
for
is
:=
range
IntSets
(
3
)
{
got
=
append
(
got
,
is
)
}
I
:=
func
(
v
...
int
)
[]
int
{
return
v
}
want
:=
[][]
int
{
I
(),
I
(
0
),
I
(
0
,
1
),
I
(
0
,
1
,
2
),
I
(
0
,
2
),
I
(
1
),
I
(
1
,
2
),
I
(
2
),
}
if
!
reflect
.
DeepEqual
(
got
,
want
)
{
t
.
Fatalf
(
"error:
\n
got: %v
\n
want: %v"
,
got
,
want
)
}
}
// kvdiff returns difference in between kv1 and kv2.
var
DEL
=
"ø"
// DEL means key deletion
...
...
@@ -1246,16 +1133,6 @@ func kvdiff(kv1, kv2 map[Key]string) map[Key]Δstring {
return
delta
}
func
TestKVDiff
(
t
*
testing
.
T
)
{
kv1
:=
map
[
Key
]
string
{
1
:
"a"
,
3
:
"c"
,
4
:
"d"
}
kv2
:=
map
[
Key
]
string
{
1
:
"b"
,
4
:
"d"
,
5
:
"e"
}
got
:=
kvdiff
(
kv1
,
kv2
)
want
:=
map
[
Key
]
Δstring
{
1
:
{
"a"
,
"b"
},
3
:
{
"c"
,
DEL
},
5
:
{
DEL
,
"e"
}}
if
!
reflect
.
DeepEqual
(
got
,
want
)
{
t
.
Fatalf
(
"error:
\n
got: %v
\n
want: %v"
,
got
,
want
)
}
}
// kvtxt returns string representation of {} kv.
func
kvtxt
(
kv
map
[
Key
]
string
)
string
{
if
len
(
kv
)
==
0
{
...
...
@@ -1278,15 +1155,6 @@ func kvtxt(kv map[Key]string) string {
return
strings
.
Join
(
sv
,
","
)
}
func
TestKVTxt
(
t
*
testing
.
T
)
{
kv
:=
map
[
Key
]
string
{
3
:
"hello"
,
1
:
"zzz"
,
4
:
"world"
}
got
:=
kvtxt
(
kv
)
want
:=
"1:zzz,3:hello,4:world"
if
got
!=
want
{
t
.
Fatalf
(
"error:
\n
got: %q
\n
want: %q"
,
got
,
want
)
}
}
// xkvFlatten converts xkv with bucket structure into regular dict.
func
xkvFlatten
(
xkv
RBucketSet
)
map
[
Key
]
string
{
kv
:=
make
(
map
[
Key
]
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