mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-20 10:52:25 +00:00
cmd/swarm/swarm-smoke: dont fail hard on timeout for sliding window
This commit is contained in:
parent
2bc8addb42
commit
e3a5773600
3 changed files with 23 additions and 7 deletions
|
|
@ -147,25 +147,25 @@ func main() {
|
||||||
Name: "upload_and_sync",
|
Name: "upload_and_sync",
|
||||||
Aliases: []string{"c"},
|
Aliases: []string{"c"},
|
||||||
Usage: "upload and sync",
|
Usage: "upload and sync",
|
||||||
Action: wrapCliCommand("upload-and-sync", uploadAndSync),
|
Action: wrapCliCommand("upload-and-sync", true, uploadAndSync),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Name: "feed_sync",
|
Name: "feed_sync",
|
||||||
Aliases: []string{"f"},
|
Aliases: []string{"f"},
|
||||||
Usage: "feed update generate, upload and sync",
|
Usage: "feed update generate, upload and sync",
|
||||||
Action: wrapCliCommand("feed-and-sync", feedUploadAndSync),
|
Action: wrapCliCommand("feed-and-sync", true, feedUploadAndSync),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Name: "upload_speed",
|
Name: "upload_speed",
|
||||||
Aliases: []string{"u"},
|
Aliases: []string{"u"},
|
||||||
Usage: "measure upload speed",
|
Usage: "measure upload speed",
|
||||||
Action: wrapCliCommand("upload-speed", uploadSpeed),
|
Action: wrapCliCommand("upload-speed", true, uploadSpeed),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Name: "sliding_window",
|
Name: "sliding_window",
|
||||||
Aliases: []string{"s"},
|
Aliases: []string{"s"},
|
||||||
Usage: "measure network aggregate capacity",
|
Usage: "measure network aggregate capacity",
|
||||||
Action: wrapCliCommand("sliding-window", slidingWindow),
|
Action: wrapCliCommand("sliding-window", false, slidingWindow),
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -111,12 +111,12 @@ outer:
|
||||||
break outer
|
break outer
|
||||||
}
|
}
|
||||||
networkDepth = i
|
networkDepth = i
|
||||||
|
metrics.GetOrRegisterGauge("sliding-window.network-depth", nil).Update(int64(networkDepth))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Info("sliding window test finished", "errored?", errored, "networkDepth", networkDepth, "networkDepth(kb)", networkDepth*filesize)
|
log.Info("sliding window test finished", "errored?", errored, "networkDepth", networkDepth, "networkDepth(kb)", networkDepth*filesize)
|
||||||
log.Info("stats", "uploadedFiles", len(hashes), "uploadedKb", uploadedBytes/1000, "filesizeKb", filesize)
|
log.Info("stats", "uploadedFiles", len(hashes), "uploadedKb", uploadedBytes/1000, "filesizeKb", filesize)
|
||||||
|
|
||||||
metrics.GetOrRegisterMeter("sliding-window.network-depth", nil).Mark(int64(networkDepth))
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -43,15 +43,31 @@ var (
|
||||||
commandName = ""
|
commandName = ""
|
||||||
)
|
)
|
||||||
|
|
||||||
func wrapCliCommand(name string, command func(*cli.Context) error) func(*cli.Context) error {
|
func wrapCliCommand(name string, killOnTimeout bool, command func(*cli.Context) error) func(*cli.Context) error {
|
||||||
return func(ctx *cli.Context) error {
|
return func(ctx *cli.Context) error {
|
||||||
log.PrintOrigins(true)
|
log.PrintOrigins(true)
|
||||||
log.Root().SetHandler(log.LvlFilterHandler(log.Lvl(verbosity), log.StreamHandler(os.Stdout, log.TerminalFormat(true))))
|
log.Root().SetHandler(log.LvlFilterHandler(log.Lvl(verbosity), log.StreamHandler(os.Stdout, log.TerminalFormat(true))))
|
||||||
|
defer func(now time.Time) {
|
||||||
|
totalTime := time.Since(now)
|
||||||
|
|
||||||
|
log.Info("total time", "time", totalTime)
|
||||||
|
metrics.GetOrRegisterCounter(name+".total-time", nil).Inc(int64(totalTime))
|
||||||
|
}(time.Now())
|
||||||
|
|
||||||
log.Info("smoke test starting", "task", name, "timeout", timeout)
|
log.Info("smoke test starting", "task", name, "timeout", timeout)
|
||||||
commandName = name
|
commandName = name
|
||||||
metrics.GetOrRegisterCounter(name, nil).Inc(1)
|
metrics.GetOrRegisterCounter(name, nil).Inc(1)
|
||||||
|
|
||||||
errc := make(chan error)
|
errc := make(chan error)
|
||||||
|
done := make(chan struct{})
|
||||||
|
|
||||||
|
if killOnTimeout {
|
||||||
|
go func() {
|
||||||
|
<-time.After(time.Duration(timeout) * time.Second)
|
||||||
|
close(done)
|
||||||
|
}()
|
||||||
|
}
|
||||||
|
|
||||||
go func() {
|
go func() {
|
||||||
errc <- command(ctx)
|
errc <- command(ctx)
|
||||||
}()
|
}()
|
||||||
|
|
@ -62,7 +78,7 @@ func wrapCliCommand(name string, command func(*cli.Context) error) func(*cli.Con
|
||||||
metrics.GetOrRegisterCounter(fmt.Sprintf("%s.fail", name), nil).Inc(1)
|
metrics.GetOrRegisterCounter(fmt.Sprintf("%s.fail", name), nil).Inc(1)
|
||||||
}
|
}
|
||||||
return err
|
return err
|
||||||
case <-time.After(time.Duration(timeout) * time.Second):
|
case <-done:
|
||||||
metrics.GetOrRegisterCounter(fmt.Sprintf("%s.timeout", name), nil).Inc(1)
|
metrics.GetOrRegisterCounter(fmt.Sprintf("%s.timeout", name), nil).Inc(1)
|
||||||
return fmt.Errorf("timeout after %v sec", timeout)
|
return fmt.Errorf("timeout after %v sec", timeout)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue