cmd/swarm/swarm-smoke: more refinements

This commit is contained in:
Elad Nachmias 2019-01-28 18:54:35 +07:00
parent 75b2b3428a
commit 983eb8c7a3
2 changed files with 6 additions and 2 deletions

View file

@ -83,7 +83,7 @@ outer:
uploadedBytes += filesize * 1000 uploadedBytes += filesize * 1000
for i, v := range hashes { for i, v := range hashes {
timeout := time.After(30 * time.Second) timeout := time.After(time.Duration(timeout) * time.Second)
errored = false errored = false
inner: inner:
@ -93,6 +93,7 @@ outer:
errored = true errored = true
log.Error("error retrieving hash. timeout", "hash idx", i, "err", err) log.Error("error retrieving hash. timeout", "hash idx", i, "err", err)
metrics.GetOrRegisterCounter("sliding-window.single.error", nil).Inc(1) metrics.GetOrRegisterCounter("sliding-window.single.error", nil).Inc(1)
break inner
default: default:
randIndex := 1 + rand.Intn(len(endpoints)-1) randIndex := 1 + rand.Intn(len(endpoints)-1)
ruid := uuid.New()[:8] ruid := uuid.New()[:8]

View file

@ -39,11 +39,14 @@ import (
cli "gopkg.in/urfave/cli.v1" cli "gopkg.in/urfave/cli.v1"
) )
var commandName = ""
func wrapCliCommand(name string, command func(*cli.Context) error) func(*cli.Context) error { func wrapCliCommand(name string, 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))))
log.Info("smoke test starting", "task", name, "timeout", timeout) log.Info("smoke test starting", "task", name, "timeout", timeout)
commandName = name
metrics.GetOrRegisterCounter(name, nil).Inc(1) metrics.GetOrRegisterCounter(name, nil).Inc(1)
errc := make(chan error) errc := make(chan error)
@ -162,7 +165,7 @@ func fetch(hash string, endpoint string, original []byte, ruid string) error {
opentracing.HTTPHeaders, opentracing.HTTPHeaders,
opentracing.HTTPHeadersCarrier(req.Header)) opentracing.HTTPHeadersCarrier(req.Header))
trace := client.GetClientTrace("upload-and-sync - http get", "upload-and-sync", ruid, &tn) trace := client.GetClientTrace(commandName+" - http get", commandName, ruid, &tn)
req = req.WithContext(httptrace.WithClientTrace(ctx, trace)) req = req.WithContext(httptrace.WithClientTrace(ctx, trace))
transport := http.DefaultTransport transport := http.DefaultTransport