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
007ffd40
Commit
007ffd40
authored
Jan 10, 2015
by
Brian Tiger Chow
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
refactor: move LatencyConfig
parent
836e5cab
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
72 additions
and
64 deletions
+72
-64
test/epictest/addcat_test.go
test/epictest/addcat_test.go
+8
-7
test/epictest/bench_test.go
test/epictest/bench_test.go
+11
-7
test/epictest/core.go
test/epictest/core.go
+2
-1
test/epictest/test_config.go
test/epictest/test_config.go
+0
-47
test/epictest/three_legged_cat_test.go
test/epictest/three_legged_cat_test.go
+3
-2
util/testutil/latency_config.go
util/testutil/latency_config.go
+48
-0
No files found.
test/epictest/addcat_test.go
View file @
007ffd40
...
...
@@ -13,12 +13,13 @@ import (
random
"github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-random"
mocknet
"github.com/jbenet/go-ipfs/p2p/net/mock"
errors
"github.com/jbenet/go-ipfs/util/debugerror"
testutil
"github.com/jbenet/go-ipfs/util/testutil"
)
const
kSeed
=
1
func
Test1KBInstantaneous
(
t
*
testing
.
T
)
{
conf
:=
Config
{
conf
:=
testutil
.
Latency
Config
{
NetworkLatency
:
0
,
RoutingLatency
:
0
,
BlockstoreLatency
:
0
,
...
...
@@ -31,7 +32,7 @@ func Test1KBInstantaneous(t *testing.T) {
func
TestDegenerateSlowBlockstore
(
t
*
testing
.
T
)
{
SkipUnlessEpic
(
t
)
conf
:=
Config
{
BlockstoreLatency
:
50
*
time
.
Millisecond
}
conf
:=
testutil
.
Latency
Config
{
BlockstoreLatency
:
50
*
time
.
Millisecond
}
if
err
:=
AddCatPowers
(
conf
,
128
);
err
!=
nil
{
t
.
Fatal
(
err
)
}
...
...
@@ -39,7 +40,7 @@ func TestDegenerateSlowBlockstore(t *testing.T) {
func
TestDegenerateSlowNetwork
(
t
*
testing
.
T
)
{
SkipUnlessEpic
(
t
)
conf
:=
Config
{
NetworkLatency
:
400
*
time
.
Millisecond
}
conf
:=
testutil
.
Latency
Config
{
NetworkLatency
:
400
*
time
.
Millisecond
}
if
err
:=
AddCatPowers
(
conf
,
128
);
err
!=
nil
{
t
.
Fatal
(
err
)
}
...
...
@@ -47,7 +48,7 @@ func TestDegenerateSlowNetwork(t *testing.T) {
func
TestDegenerateSlowRouting
(
t
*
testing
.
T
)
{
SkipUnlessEpic
(
t
)
conf
:=
Config
{
RoutingLatency
:
400
*
time
.
Millisecond
}
conf
:=
testutil
.
Latency
Config
{
RoutingLatency
:
400
*
time
.
Millisecond
}
if
err
:=
AddCatPowers
(
conf
,
128
);
err
!=
nil
{
t
.
Fatal
(
err
)
}
...
...
@@ -55,13 +56,13 @@ func TestDegenerateSlowRouting(t *testing.T) {
func
Test100MBMacbookCoastToCoast
(
t
*
testing
.
T
)
{
SkipUnlessEpic
(
t
)
conf
:=
Config
{}
.
Network_NYtoSF
()
.
Blockstore_SlowSSD2014
()
.
Routing_Slow
()
conf
:=
testutil
.
Latency
Config
{}
.
Network_NYtoSF
()
.
Blockstore_SlowSSD2014
()
.
Routing_Slow
()
if
err
:=
DirectAddCat
(
RandomBytes
(
100
*
1024
*
1024
),
conf
);
err
!=
nil
{
t
.
Fatal
(
err
)
}
}
func
AddCatPowers
(
conf
Config
,
megabytesMax
int64
)
error
{
func
AddCatPowers
(
conf
testutil
.
Latency
Config
,
megabytesMax
int64
)
error
{
var
i
int64
for
i
=
1
;
i
<
megabytesMax
;
i
=
i
*
2
{
fmt
.
Printf
(
"%d MB
\n
"
,
i
)
...
...
@@ -78,7 +79,7 @@ func RandomBytes(n int64) []byte {
return
data
.
Bytes
()
}
func
DirectAddCat
(
data
[]
byte
,
conf
Config
)
error
{
func
DirectAddCat
(
data
[]
byte
,
conf
testutil
.
Latency
Config
)
error
{
ctx
,
cancel
:=
context
.
WithCancel
(
context
.
Background
())
defer
cancel
()
const
numPeers
=
2
...
...
test/epictest/bench_test.go
View file @
007ffd40
package
epictest
import
"testing"
import
(
"testing"
func
benchmarkAddCat
(
numBytes
int64
,
conf
Config
,
b
*
testing
.
B
)
{
testutil
"github.com/jbenet/go-ipfs/util/testutil"
)
func
benchmarkAddCat
(
numBytes
int64
,
conf
testutil
.
LatencyConfig
,
b
*
testing
.
B
)
{
b
.
StopTimer
()
b
.
SetBytes
(
numBytes
)
...
...
@@ -16,7 +20,7 @@ func benchmarkAddCat(numBytes int64, conf Config, b *testing.B) {
}
}
var
instant
=
Config
{}
.
All_Instantaneous
()
var
instant
=
testutil
.
Latency
Config
{}
.
All_Instantaneous
()
func
BenchmarkInstantaneousAddCat1KB
(
b
*
testing
.
B
)
{
benchmarkAddCat
(
1
*
KB
,
instant
,
b
)
}
func
BenchmarkInstantaneousAddCat1MB
(
b
*
testing
.
B
)
{
benchmarkAddCat
(
1
*
MB
,
instant
,
b
)
}
...
...
@@ -29,7 +33,7 @@ func BenchmarkInstantaneousAddCat64MB(b *testing.B) { benchmarkAddCat(64*MB, in
func
BenchmarkInstantaneousAddCat128MB
(
b
*
testing
.
B
)
{
benchmarkAddCat
(
128
*
MB
,
instant
,
b
)
}
func
BenchmarkInstantaneousAddCat256MB
(
b
*
testing
.
B
)
{
benchmarkAddCat
(
256
*
MB
,
instant
,
b
)
}
var
routing
=
Config
{}
.
Routing_Slow
()
var
routing
=
testutil
.
Latency
Config
{}
.
Routing_Slow
()
func
BenchmarkRoutingSlowAddCat1MB
(
b
*
testing
.
B
)
{
benchmarkAddCat
(
1
*
MB
,
routing
,
b
)
}
func
BenchmarkRoutingSlowAddCat2MB
(
b
*
testing
.
B
)
{
benchmarkAddCat
(
2
*
MB
,
routing
,
b
)
}
...
...
@@ -42,7 +46,7 @@ func BenchmarkRoutingSlowAddCat128MB(b *testing.B) { benchmarkAddCat(128*MB, rou
func
BenchmarkRoutingSlowAddCat256MB
(
b
*
testing
.
B
)
{
benchmarkAddCat
(
256
*
MB
,
routing
,
b
)
}
func
BenchmarkRoutingSlowAddCat512MB
(
b
*
testing
.
B
)
{
benchmarkAddCat
(
512
*
MB
,
routing
,
b
)
}
var
network
=
Config
{}
.
Network_NYtoSF
()
var
network
=
testutil
.
Latency
Config
{}
.
Network_NYtoSF
()
func
BenchmarkNetworkSlowAddCat1MB
(
b
*
testing
.
B
)
{
benchmarkAddCat
(
1
*
MB
,
network
,
b
)
}
func
BenchmarkNetworkSlowAddCat2MB
(
b
*
testing
.
B
)
{
benchmarkAddCat
(
2
*
MB
,
network
,
b
)
}
...
...
@@ -54,7 +58,7 @@ func BenchmarkNetworkSlowAddCat64MB(b *testing.B) { benchmarkAddCat(64*MB, netw
func
BenchmarkNetworkSlowAddCat128MB
(
b
*
testing
.
B
)
{
benchmarkAddCat
(
128
*
MB
,
network
,
b
)
}
func
BenchmarkNetworkSlowAddCat256MB
(
b
*
testing
.
B
)
{
benchmarkAddCat
(
256
*
MB
,
network
,
b
)
}
var
hdd
=
Config
{}
.
Blockstore_7200RPM
()
var
hdd
=
testutil
.
Latency
Config
{}
.
Blockstore_7200RPM
()
func
BenchmarkBlockstoreSlowAddCat1MB
(
b
*
testing
.
B
)
{
benchmarkAddCat
(
1
*
MB
,
hdd
,
b
)
}
func
BenchmarkBlockstoreSlowAddCat2MB
(
b
*
testing
.
B
)
{
benchmarkAddCat
(
2
*
MB
,
hdd
,
b
)
}
...
...
@@ -66,7 +70,7 @@ func BenchmarkBlockstoreSlowAddCat64MB(b *testing.B) { benchmarkAddCat(64*MB, h
func
BenchmarkBlockstoreSlowAddCat128MB
(
b
*
testing
.
B
)
{
benchmarkAddCat
(
128
*
MB
,
hdd
,
b
)
}
func
BenchmarkBlockstoreSlowAddCat256MB
(
b
*
testing
.
B
)
{
benchmarkAddCat
(
256
*
MB
,
hdd
,
b
)
}
var
mixed
=
Config
{}
.
Network_NYtoSF
()
.
Blockstore_SlowSSD2014
()
.
Routing_Slow
()
var
mixed
=
testutil
.
Latency
Config
{}
.
Network_NYtoSF
()
.
Blockstore_SlowSSD2014
()
.
Routing_Slow
()
func
BenchmarkMixedAddCat1MBXX
(
b
*
testing
.
B
)
{
benchmarkAddCat
(
1
*
MB
,
mixed
,
b
)
}
func
BenchmarkMixedAddCat2MBXX
(
b
*
testing
.
B
)
{
benchmarkAddCat
(
2
*
MB
,
mixed
,
b
)
}
...
...
test/epictest/core.go
View file @
007ffd40
...
...
@@ -9,6 +9,7 @@ import (
blockstore
"github.com/jbenet/go-ipfs/blocks/blockstore"
blockservice
"github.com/jbenet/go-ipfs/blockservice"
testutil
"github.com/jbenet/go-ipfs/util/testutil"
exchange
"github.com/jbenet/go-ipfs/exchange"
bitswap
"github.com/jbenet/go-ipfs/exchange/bitswap"
bsnet
"github.com/jbenet/go-ipfs/exchange/bitswap/network"
...
...
@@ -130,7 +131,7 @@ func (r *repo) Exchange() exchange.Interface {
return
r
.
exchange
}
func
MocknetTestRepo
(
p
peer
.
ID
,
h
host
.
Host
,
conf
Config
)
RepoFactory
{
func
MocknetTestRepo
(
p
peer
.
ID
,
h
host
.
Host
,
conf
testutil
.
Latency
Config
)
RepoFactory
{
return
func
(
ctx
context
.
Context
)
(
Repo
,
error
)
{
const
kWriteCacheElems
=
100
const
alwaysSendToPeer
=
true
...
...
test/epictest/test_config.go
View file @
007ffd40
package
epictest
import
"time"
type
Config
struct
{
BlockstoreLatency
time
.
Duration
NetworkLatency
time
.
Duration
RoutingLatency
time
.
Duration
}
func
(
c
Config
)
All_Instantaneous
()
Config
{
// Could use a zero value but whatever. Consistency of interface
c
.
NetworkLatency
=
0
c
.
RoutingLatency
=
0
c
.
BlockstoreLatency
=
0
return
c
}
func
(
c
Config
)
Network_NYtoSF
()
Config
{
c
.
NetworkLatency
=
20
*
time
.
Millisecond
return
c
}
func
(
c
Config
)
Network_IntraDatacenter2014
()
Config
{
c
.
NetworkLatency
=
250
*
time
.
Microsecond
return
c
}
func
(
c
Config
)
Blockstore_FastSSD2014
()
Config
{
const
iops
=
100000
c
.
BlockstoreLatency
=
(
1
/
iops
)
*
time
.
Second
return
c
}
func
(
c
Config
)
Blockstore_SlowSSD2014
()
Config
{
c
.
BlockstoreLatency
=
150
*
time
.
Microsecond
return
c
}
func
(
c
Config
)
Blockstore_7200RPM
()
Config
{
c
.
BlockstoreLatency
=
8
*
time
.
Millisecond
return
c
}
func
(
c
Config
)
Routing_Slow
()
Config
{
c
.
RoutingLatency
=
200
*
time
.
Millisecond
return
c
}
test/epictest/three_legged_cat_test.go
View file @
007ffd40
...
...
@@ -9,10 +9,11 @@ import (
context
"github.com/jbenet/go-ipfs/Godeps/_workspace/src/code.google.com/p/go.net/context"
mocknet
"github.com/jbenet/go-ipfs/p2p/net/mock"
errors
"github.com/jbenet/go-ipfs/util/debugerror"
testutil
"github.com/jbenet/go-ipfs/util/testutil"
)
func
TestThreeLeggedCat
(
t
*
testing
.
T
)
{
conf
:=
Config
{
conf
:=
testutil
.
Latency
Config
{
NetworkLatency
:
0
,
RoutingLatency
:
0
,
BlockstoreLatency
:
0
,
...
...
@@ -22,7 +23,7 @@ func TestThreeLeggedCat(t *testing.T) {
}
}
func
RunThreeLeggedCat
(
data
[]
byte
,
conf
Config
)
error
{
func
RunThreeLeggedCat
(
data
[]
byte
,
conf
testutil
.
Latency
Config
)
error
{
ctx
,
cancel
:=
context
.
WithCancel
(
context
.
Background
())
defer
cancel
()
const
numPeers
=
3
...
...
util/testutil/latency_config.go
0 → 100644
View file @
007ffd40
package
testutil
import
"time"
type
LatencyConfig
struct
{
BlockstoreLatency
time
.
Duration
NetworkLatency
time
.
Duration
RoutingLatency
time
.
Duration
}
func
(
c
LatencyConfig
)
All_Instantaneous
()
LatencyConfig
{
// Could use a zero value but whatever. Consistency of interface
c
.
NetworkLatency
=
0
c
.
RoutingLatency
=
0
c
.
BlockstoreLatency
=
0
return
c
}
func
(
c
LatencyConfig
)
Network_NYtoSF
()
LatencyConfig
{
c
.
NetworkLatency
=
20
*
time
.
Millisecond
return
c
}
func
(
c
LatencyConfig
)
Network_IntraDatacenter2014
()
LatencyConfig
{
c
.
NetworkLatency
=
250
*
time
.
Microsecond
return
c
}
func
(
c
LatencyConfig
)
Blockstore_FastSSD2014
()
LatencyConfig
{
const
iops
=
100000
c
.
BlockstoreLatency
=
(
1
/
iops
)
*
time
.
Second
return
c
}
func
(
c
LatencyConfig
)
Blockstore_SlowSSD2014
()
LatencyConfig
{
c
.
BlockstoreLatency
=
150
*
time
.
Microsecond
return
c
}
func
(
c
LatencyConfig
)
Blockstore_7200RPM
()
LatencyConfig
{
c
.
BlockstoreLatency
=
8
*
time
.
Millisecond
return
c
}
func
(
c
LatencyConfig
)
Routing_Slow
()
LatencyConfig
{
c
.
RoutingLatency
=
200
*
time
.
Millisecond
return
c
}
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