Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
dms3
go-dms3
Commits
89ba9942
Commit
89ba9942
authored
Nov 18, 2015
by
rht
Committed by
Jeromy
Jan 12, 2016
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Simplify BalancedLayout test
License: MIT Signed-off-by:
rht
<
rhtbot@gmail.com
>
parent
b4a38541
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
21 additions
and
68 deletions
+21
-68
importer/balanced/balanced_test.go
importer/balanced/balanced_test.go
+21
-67
importer/helpers/dagbuilder.go
importer/helpers/dagbuilder.go
+0
-1
No files found.
importer/balanced/balanced_test.go
View file @
89ba9942
...
...
@@ -49,13 +49,11 @@ func TestSizeBasedSplit(t *testing.T) {
t
.
SkipNow
()
}
bs
:=
chunk
.
SizeSplitterGen
(
512
)
testFileConsistency
(
t
,
bs
,
32
*
512
)
bs
=
chunk
.
SizeSplitterGen
(
4096
)
testFileConsistency
(
t
,
bs
,
32
*
4096
)
testFileConsistency
(
t
,
32
*
512
,
512
)
testFileConsistency
(
t
,
32
*
4096
,
4096
)
// Uneven offset
testFileConsistency
(
t
,
bs
,
31
*
4095
)
testFileConsistency
(
t
,
31
*
4095
,
4096
)
}
func
dup
(
b
[]
byte
)
[]
byte
{
...
...
@@ -64,51 +62,20 @@ func dup(b []byte) []byte {
return
o
}
func
testFileConsistency
(
t
*
testing
.
T
,
bs
chunk
.
SplitterGen
,
nbytes
int
)
{
should
:=
make
([]
byte
,
nbytes
)
u
.
NewTimeSeededRand
()
.
Read
(
should
)
read
:=
bytes
.
NewReader
(
should
)
func
testFileConsistency
(
t
*
testing
.
T
,
nbytes
int64
,
blksize
int64
)
{
ds
:=
mdtest
.
Mock
()
nd
,
err
:=
buildTestDag
(
ds
,
bs
(
read
))
if
err
!=
nil
{
t
.
Fatal
(
err
)
}
nd
,
should
:=
getTestDag
(
t
,
ds
,
nbytes
,
blksize
)
r
,
err
:=
uio
.
NewDagReader
(
context
.
Background
(),
nd
,
ds
)
if
err
!=
nil
{
t
.
Fatal
(
err
)
}
out
,
err
:=
ioutil
.
ReadAll
(
r
)
if
err
!=
nil
{
t
.
Fatal
(
err
)
}
err
=
arrComp
(
out
,
should
)
if
err
!=
nil
{
t
.
Fatal
(
err
)
}
dagrArrComp
(
t
,
r
,
should
)
}
func
TestBuilderConsistency
(
t
*
testing
.
T
)
{
dagserv
:=
mdtest
.
Mock
()
nd
,
should
:=
getTestDag
(
t
,
dagserv
,
100000
,
chunk
.
DefaultBlockSize
)
r
,
err
:=
uio
.
NewDagReader
(
context
.
Background
(),
nd
,
dagserv
)
if
err
!=
nil
{
t
.
Fatal
(
err
)
}
out
,
err
:=
ioutil
.
ReadAll
(
r
)
if
err
!=
nil
{
t
.
Fatal
(
err
)
}
err
=
arrComp
(
out
,
should
)
if
err
!=
nil
{
t
.
Fatal
(
err
)
}
testFileConsistency
(
t
,
100000
,
chunk
.
DefaultBlockSize
)
}
func
arrComp
(
a
,
b
[]
byte
)
error
{
...
...
@@ -123,6 +90,17 @@ func arrComp(a, b []byte) error {
return
nil
}
func
dagrArrComp
(
t
*
testing
.
T
,
r
io
.
Reader
,
should
[]
byte
)
{
out
,
err
:=
ioutil
.
ReadAll
(
r
)
if
err
!=
nil
{
t
.
Fatal
(
err
)
}
if
err
:=
arrComp
(
out
,
should
);
err
!=
nil
{
t
.
Fatal
(
err
)
}
}
type
dagservAndPinner
struct
{
ds
dag
.
DAGService
mp
pin
.
Pinner
...
...
@@ -166,15 +144,7 @@ func TestSeekingBasic(t *testing.T) {
t
.
Fatal
(
"Failed to seek to correct offset"
)
}
out
,
err
:=
ioutil
.
ReadAll
(
rs
)
if
err
!=
nil
{
t
.
Fatal
(
err
)
}
err
=
arrComp
(
out
,
should
[
start
:
])
if
err
!=
nil
{
t
.
Fatal
(
err
)
}
dagrArrComp
(
t
,
rs
,
should
[
start
:
])
}
func
TestSeekToBegin
(
t
*
testing
.
T
)
{
...
...
@@ -202,15 +172,7 @@ func TestSeekToBegin(t *testing.T) {
t
.
Fatal
(
"Failed to seek to beginning"
)
}
out
,
err
:=
ioutil
.
ReadAll
(
rs
)
if
err
!=
nil
{
t
.
Fatal
(
err
)
}
err
=
arrComp
(
out
,
should
)
if
err
!=
nil
{
t
.
Fatal
(
err
)
}
dagrArrComp
(
t
,
rs
,
should
)
}
func
TestSeekToAlmostBegin
(
t
*
testing
.
T
)
{
...
...
@@ -238,15 +200,7 @@ func TestSeekToAlmostBegin(t *testing.T) {
t
.
Fatal
(
"Failed to seek to almost beginning"
)
}
out
,
err
:=
ioutil
.
ReadAll
(
rs
)
if
err
!=
nil
{
t
.
Fatal
(
err
)
}
err
=
arrComp
(
out
,
should
[
1
:
])
if
err
!=
nil
{
t
.
Fatal
(
err
)
}
dagrArrComp
(
t
,
rs
,
should
[
1
:
])
}
func
TestSeekEnd
(
t
*
testing
.
T
)
{
...
...
importer/helpers/dagbuilder.go
View file @
89ba9942
...
...
@@ -52,7 +52,6 @@ func (db *DagBuilderHelper) prepareNext() {
func
(
db
*
DagBuilderHelper
)
Done
()
bool
{
// ensure we have an accurate perspective on data
// as `done` this may be called before `next`.
//db.prepareNext() // idempotent
db
.
prepareNext
()
// idempotent
return
db
.
nextData
==
nil
}
...
...
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