aboutsummaryrefslogtreecommitdiffstats
path: root/cmd/swarm
diff options
context:
space:
mode:
authorlash <nolash@users.noreply.github.com>2019-02-28 15:12:50 +0800
committerViktor TrĂ³n <viktor.tron@gmail.com>2019-02-28 15:12:50 +0800
commit62d9d638582fa5fd7bcfaa55e8810fcfb898a4dd (patch)
treed9f0c0bc74f29c36e30b9a9395da7bacf2dc8b42 /cmd/swarm
parent505a49e689683f11326ef30af3b9bcff8f3c2b8f (diff)
downloadgo-tangerine-62d9d638582fa5fd7bcfaa55e8810fcfb898a4dd.tar
go-tangerine-62d9d638582fa5fd7bcfaa55e8810fcfb898a4dd.tar.gz
go-tangerine-62d9d638582fa5fd7bcfaa55e8810fcfb898a4dd.tar.bz2
go-tangerine-62d9d638582fa5fd7bcfaa55e8810fcfb898a4dd.tar.lz
go-tangerine-62d9d638582fa5fd7bcfaa55e8810fcfb898a4dd.tar.xz
go-tangerine-62d9d638582fa5fd7bcfaa55e8810fcfb898a4dd.tar.zst
go-tangerine-62d9d638582fa5fd7bcfaa55e8810fcfb898a4dd.zip
swarm/network: WIP consider all nodes for healthy iteration (#19155)
* swarm/network: WIP consider all nodes for healthy iteration * swarm/network/simulation: extend TestWaitTillHealthy to really check kads are healthy * cmd/swarm/swarm-snapshot: fixed bugs in snapshot creation binary * swarm/network/simulation: addressed PR comments * swarm/network/simulation: defer sim.Clsoe() * swarm/network/simulation: fixed wrong sim.Close() * swarm/network/simulation: addressed PR comments * cmd/swarm/swarm-snapshot: reducing default to 8 nodes, more to 4 * cmd/swarm/swarm-snapshot: extended timeout to 3 mins, or 256 nodes snapshot times out * swarm/network/simulation: More PR comments
Diffstat (limited to 'cmd/swarm')
-rw-r--r--cmd/swarm/swarm-snapshot/create.go11
-rw-r--r--cmd/swarm/swarm-snapshot/create_test.go4
-rw-r--r--cmd/swarm/swarm-snapshot/main.go2
3 files changed, 10 insertions, 7 deletions
diff --git a/cmd/swarm/swarm-snapshot/create.go b/cmd/swarm/swarm-snapshot/create.go
index 127fde8ae..434561a49 100644
--- a/cmd/swarm/swarm-snapshot/create.go
+++ b/cmd/swarm/swarm-snapshot/create.go
@@ -59,13 +59,16 @@ func createSnapshot(filename string, nodes int, services []string) (err error) {
log.Debug("create snapshot", "filename", filename, "nodes", nodes, "services", services)
sim := simulation.New(map[string]simulation.ServiceFunc{
- "bzz": func(ctx *adapters.ServiceContext, b *sync.Map) (node.Service, func(), error) {
+ "bzz": func(ctx *adapters.ServiceContext, bucket *sync.Map) (node.Service, func(), error) {
addr := network.NewAddr(ctx.Config.Node())
kad := network.NewKademlia(addr.Over(), network.NewKadParams())
hp := network.NewHiveParams()
hp.KeepAliveInterval = time.Duration(200) * time.Millisecond
hp.Discovery = true // discovery must be enabled when creating a snapshot
+ // store the kademlia in the bucket, needed later in the WaitTillHealthy function
+ bucket.Store(simulation.BucketKeyKademlia, kad)
+
config := &network.BzzConfig{
OverlayAddr: addr.Over(),
UnderlayAddr: addr.Under(),
@@ -76,17 +79,17 @@ func createSnapshot(filename string, nodes int, services []string) (err error) {
})
defer sim.Close()
- _, err = sim.AddNodes(nodes)
+ ids, err := sim.AddNodes(nodes)
if err != nil {
return fmt.Errorf("add nodes: %v", err)
}
- err = sim.Net.ConnectNodesRing(nil)
+ err = sim.Net.ConnectNodesRing(ids)
if err != nil {
return fmt.Errorf("connect nodes: %v", err)
}
- ctx, cancelSimRun := context.WithTimeout(context.Background(), 2*time.Minute)
+ ctx, cancelSimRun := context.WithTimeout(context.Background(), 3*time.Minute)
defer cancelSimRun()
if _, err := sim.WaitTillHealthy(ctx); err != nil {
return fmt.Errorf("wait for healthy kademlia: %v", err)
diff --git a/cmd/swarm/swarm-snapshot/create_test.go b/cmd/swarm/swarm-snapshot/create_test.go
index c9445168d..b2e30c201 100644
--- a/cmd/swarm/swarm-snapshot/create_test.go
+++ b/cmd/swarm/swarm-snapshot/create_test.go
@@ -48,7 +48,7 @@ func TestSnapshotCreate(t *testing.T) {
},
{
name: "more nodes",
- nodes: defaultNodes + 5,
+ nodes: defaultNodes + 4,
},
{
name: "services",
@@ -81,7 +81,7 @@ func TestSnapshotCreate(t *testing.T) {
}
testCmd := runSnapshot(t, append(args, file.Name())...)
- testCmd.ExpectExit()
+ testCmd.WaitExit()
if code := testCmd.ExitStatus(); code != 0 {
t.Fatalf("command exit code %v, expected 0", code)
}
diff --git a/cmd/swarm/swarm-snapshot/main.go b/cmd/swarm/swarm-snapshot/main.go
index 184727e4d..136295e51 100644
--- a/cmd/swarm/swarm-snapshot/main.go
+++ b/cmd/swarm/swarm-snapshot/main.go
@@ -27,7 +27,7 @@ import (
var gitCommit string // Git SHA1 commit hash of the release (set via linker flags)
// default value for "create" command --nodes flag
-const defaultNodes = 10
+const defaultNodes = 8
func main() {
err := newApp().Run(os.Args)