swarm/network/stream: enforce waitKademlia, improve TestIntervals

This commit is contained in:
Fabio Barone 2018-07-26 19:43:30 -05:00
parent e8522eab62
commit 0e3a050c87
3 changed files with 13 additions and 20 deletions

View file

@ -424,12 +424,10 @@ func testDeliveryFromNodes(t *testing.T, nodes, conns, chunkCount int, skipCheck
} }
}() }()
if *waitKademlia {
log.Debug("Waiting for kademlia") log.Debug("Waiting for kademlia")
if _, err := sim.WaitTillHealthy(ctx, 2); err != nil { if _, err := sim.WaitTillHealthy(ctx, 2); err != nil {
return err return err
} }
}
log.Debug("Watching for disconnections") log.Debug("Watching for disconnections")
disconnections := sim.PeerEvents( disconnections := sim.PeerEvents(
@ -560,11 +558,9 @@ func benchmarkDeliveryFromNodes(b *testing.B, nodes, conns, chunkCount int, skip
} }
netStore := item.(*storage.NetStore) netStore := item.(*storage.NetStore)
if *waitKademlia {
if _, err := sim.WaitTillHealthy(ctx, 2); err != nil { if _, err := sim.WaitTillHealthy(ctx, 2); err != nil {
return err return err
} }
}
disconnections := sim.PeerEvents( disconnections := sim.PeerEvents(
context.Background(), context.Background(),

View file

@ -96,12 +96,13 @@ func testIntervals(t *testing.T, live bool, history *Range, skipCheck bool) {
defer sim.Close() defer sim.Close()
log.Info("Adding nodes to simulation") log.Info("Adding nodes to simulation")
_, err := sim.AddNodesAndConnectFull(nodes) _, err := sim.AddNodesAndConnectChain(nodes)
if err != nil { if err != nil {
t.Fatal(err) t.Fatal(err)
} }
ctx := context.Background() ctx, cancel := context.WithTimeout(context.Background(), 100*time.Second)
defer cancel()
result := sim.Run(ctx, func(ctx context.Context, sim *simulation.Simulation) error { result := sim.Run(ctx, func(ctx context.Context, sim *simulation.Simulation) error {
nodeIDs := sim.UpNodeIDs() nodeIDs := sim.UpNodeIDs()
@ -139,12 +140,10 @@ func testIntervals(t *testing.T, live bool, history *Range, skipCheck bool) {
liveErrC := make(chan error) liveErrC := make(chan error)
historyErrC := make(chan error) historyErrC := make(chan error)
if *waitKademlia {
if _, err := sim.WaitTillHealthy(ctx, 2); err != nil { if _, err := sim.WaitTillHealthy(ctx, 2); err != nil {
log.Error("WaitKademlia error: %v", "err", err) log.Error("WaitKademlia error: %v", "err", err)
return err return err
} }
}
log.Debug("Watching for disconnections") log.Debug("Watching for disconnections")
disconnections := sim.PeerEvents( disconnections := sim.PeerEvents(

View file

@ -181,11 +181,9 @@ func testSyncBetweenNodes(t *testing.T, nodes, conns, chunkCount int, skipCheck
} }
} }
// here we distribute chunks of a random file into stores 1...nodes // here we distribute chunks of a random file into stores 1...nodes
if *waitKademlia {
if _, err := sim.WaitTillHealthy(ctx, 2); err != nil { if _, err := sim.WaitTillHealthy(ctx, 2); err != nil {
return err return err
} }
}
// collect hashes in po 1 bin for each node // collect hashes in po 1 bin for each node
hashes := make([][]storage.Address, nodes) hashes := make([][]storage.Address, nodes)