mirror of
https://github.com/ipfs/kubo.git
synced 2026-02-25 04:17:44 +08:00
epictest: fix three-legged-cat
http://gateway.ipfs.io/ipfs/QmfUFkQuqjfQzLNhMLwiibiAxnAaZEJAbYkey9orXJ4aQe/3lcat.jpg
This commit is contained in:
parent
958cc61647
commit
14eceee35e
@ -85,6 +85,9 @@ func Bootstrap(n *IpfsNode, cfg BootstrapConfig) (io.Closer, error) {
|
||||
return ioutil.NopCloser(nil), nil
|
||||
}
|
||||
|
||||
// make a signal to wait for one bootstrap round to complete.
|
||||
doneWithRound := make(chan struct{})
|
||||
|
||||
// the periodic bootstrap function -- the connection supervisor
|
||||
periodic := func(worker goprocess.Process) {
|
||||
ctx := procctx.WithProcessClosing(context.Background(), worker)
|
||||
@ -94,6 +97,8 @@ func Bootstrap(n *IpfsNode, cfg BootstrapConfig) (io.Closer, error) {
|
||||
log.Event(ctx, "bootstrapError", n.Identity, lgbl.Error(err))
|
||||
log.Debugf("%s bootstrap error: %s", n.Identity, err)
|
||||
}
|
||||
|
||||
<-doneWithRound
|
||||
}
|
||||
|
||||
// kick off the node's periodic bootstrapping
|
||||
@ -109,6 +114,8 @@ func Bootstrap(n *IpfsNode, cfg BootstrapConfig) (io.Closer, error) {
|
||||
|
||||
// add dht bootstrap proc as a child, so it is closed automatically when we are.
|
||||
proc.AddChild(dbproc)
|
||||
doneWithRound <- struct{}{}
|
||||
close(doneWithRound) // it no longer blocks periodic
|
||||
return proc, nil
|
||||
}
|
||||
|
||||
|
||||
@ -5,6 +5,7 @@ import (
|
||||
"io"
|
||||
"math"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
context "github.com/jbenet/go-ipfs/Godeps/_workspace/src/code.google.com/p/go.net/context"
|
||||
core "github.com/jbenet/go-ipfs/core"
|
||||
@ -16,7 +17,7 @@ import (
|
||||
testutil "github.com/jbenet/go-ipfs/util/testutil"
|
||||
)
|
||||
|
||||
func TestThreeLeggedCat(t *testing.T) {
|
||||
func TestThreeLeggedCat1KBInstantaneous(t *testing.T) {
|
||||
conf := testutil.LatencyConfig{
|
||||
NetworkLatency: 0,
|
||||
RoutingLatency: 0,
|
||||
@ -27,6 +28,38 @@ func TestThreeLeggedCat(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestThreeLeggedCatDegenerateSlowBlockstore(t *testing.T) {
|
||||
SkipUnlessEpic(t)
|
||||
conf := testutil.LatencyConfig{BlockstoreLatency: 50 * time.Millisecond}
|
||||
if err := RunThreeLeggedCat(RandomBytes(1*unit.KB), conf); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestThreeLeggedCatDegenerateSlowNetwork(t *testing.T) {
|
||||
SkipUnlessEpic(t)
|
||||
conf := testutil.LatencyConfig{NetworkLatency: 400 * time.Millisecond}
|
||||
if err := RunThreeLeggedCat(RandomBytes(1*unit.KB), conf); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestThreeLeggedCatDegenerateSlowRouting(t *testing.T) {
|
||||
SkipUnlessEpic(t)
|
||||
conf := testutil.LatencyConfig{RoutingLatency: 400 * time.Millisecond}
|
||||
if err := RunThreeLeggedCat(RandomBytes(1*unit.KB), conf); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestThreeLeggedCat100MBMacbookCoastToCoast(t *testing.T) {
|
||||
SkipUnlessEpic(t)
|
||||
conf := testutil.LatencyConfig{}.Network_NYtoSF().Blockstore_SlowSSD2014().Routing_Slow()
|
||||
if err := RunThreeLeggedCat(RandomBytes(1*unit.KB), conf); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
||||
func RunThreeLeggedCat(data []byte, conf testutil.LatencyConfig) error {
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
defer cancel()
|
||||
@ -47,6 +80,11 @@ func RunThreeLeggedCat(data []byte, conf testutil.LatencyConfig) error {
|
||||
if len(peers) < numPeers {
|
||||
return errors.New("test initialization error")
|
||||
}
|
||||
bootstrap, err := core.NewIPFSNode(ctx, core.ConfigOption(MocknetTestRepo(peers[2], mn.Host(peers[2]), conf)))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer bootstrap.Close()
|
||||
adder, err := core.NewIPFSNode(ctx, core.ConfigOption(MocknetTestRepo(peers[0], mn.Host(peers[0]), conf)))
|
||||
if err != nil {
|
||||
return err
|
||||
@ -57,11 +95,6 @@ func RunThreeLeggedCat(data []byte, conf testutil.LatencyConfig) error {
|
||||
return err
|
||||
}
|
||||
defer catter.Close()
|
||||
bootstrap, err := core.NewIPFSNode(ctx, core.ConfigOption(MocknetTestRepo(peers[2], mn.Host(peers[2]), conf)))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer bootstrap.Close()
|
||||
|
||||
bis := bootstrap.Peerstore.PeerInfo(bootstrap.PeerHost.ID())
|
||||
bcfg := core.BootstrapConfigWithPeers([]peer.PeerInfo{bis})
|
||||
|
||||
Loading…
Reference in New Issue
Block a user