mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-19 18:32:23 +00:00
cmd/swarm/swarm-smoke: timeout flag
This commit is contained in:
parent
3ac633ba84
commit
eac3fdb218
2 changed files with 24 additions and 2 deletions
|
|
@ -35,6 +35,7 @@ var (
|
||||||
from int
|
from int
|
||||||
to int
|
to int
|
||||||
verbosity int
|
verbosity int
|
||||||
|
timeout int
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
|
|
@ -91,6 +92,12 @@ func main() {
|
||||||
Usage: "verbosity",
|
Usage: "verbosity",
|
||||||
Destination: &verbosity,
|
Destination: &verbosity,
|
||||||
},
|
},
|
||||||
|
cli.IntFlag{
|
||||||
|
Name: "timeout",
|
||||||
|
Value: 120,
|
||||||
|
Usage: "timeout in seconds after which kill the process",
|
||||||
|
Destination: &timeout,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
app.Commands = []cli.Command{
|
app.Commands = []cli.Command{
|
||||||
|
|
|
||||||
|
|
@ -40,11 +40,11 @@ import (
|
||||||
|
|
||||||
func generateEndpoints(scheme string, cluster string, app string, from int, to int) {
|
func generateEndpoints(scheme string, cluster string, app string, from int, to int) {
|
||||||
if cluster == "prod" {
|
if cluster == "prod" {
|
||||||
for port := from; port <= to; port++ {
|
for port := from; port < to; port++ {
|
||||||
endpoints = append(endpoints, fmt.Sprintf("%s://%v.swarm-gateways.net", scheme, port))
|
endpoints = append(endpoints, fmt.Sprintf("%s://%v.swarm-gateways.net", scheme, port))
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
for port := from; port <= to; port++ {
|
for port := from; port < to; port++ {
|
||||||
endpoints = append(endpoints, fmt.Sprintf("%s://%s-%v-%s.stg.swarm-gateways.net", scheme, app, port, cluster))
|
endpoints = append(endpoints, fmt.Sprintf("%s://%s-%v-%s.stg.swarm-gateways.net", scheme, app, port, cluster))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -58,6 +58,21 @@ func cliUploadAndSync(c *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))))
|
||||||
|
|
||||||
|
errc := make(chan error)
|
||||||
|
go func() {
|
||||||
|
errc <- uploadAndSync(c)
|
||||||
|
}()
|
||||||
|
|
||||||
|
select {
|
||||||
|
case err := <-errc:
|
||||||
|
return err
|
||||||
|
case <-time.After(time.Duration(timeout) * time.Second):
|
||||||
|
return fmt.Errorf("timeout after %v sec", timeout)
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
func uploadAndSync(c *cli.Context) error {
|
||||||
defer func(now time.Time) { log.Info("total time", "time", time.Since(now), "kb", filesize) }(time.Now())
|
defer func(now time.Time) { log.Info("total time", "time", time.Since(now), "kb", filesize) }(time.Now())
|
||||||
|
|
||||||
generateEndpoints(scheme, cluster, appName, from, to)
|
generateEndpoints(scheme, cluster, appName, from, to)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue