From ceeb047e6958df32b5dacf0ce29e51c0314f905a Mon Sep 17 00:00:00 2001 From: Anton Evangelatov Date: Fri, 8 Mar 2019 08:52:05 +0100 Subject: [PATCH] cmd/swarm/swarm-smoke: better logs when debug mode triggers (#19237) * cmd/swarm/swarm-smoke: better logs for debug functionality; * cmd/swarm/swarm-smoke: fixup --- cmd/swarm/swarm-smoke/upload_and_sync.go | 28 ++++++++++++++++++++---- 1 file changed, 24 insertions(+), 4 deletions(-) diff --git a/cmd/swarm/swarm-smoke/upload_and_sync.go b/cmd/swarm/swarm-smoke/upload_and_sync.go index 90230df253..50af122e78 100644 --- a/cmd/swarm/swarm-smoke/upload_and_sync.go +++ b/cmd/swarm/swarm-smoke/upload_and_sync.go @@ -23,6 +23,7 @@ import ( "io/ioutil" "math/rand" "os" + "strings" "sync" "time" @@ -75,10 +76,17 @@ func trackChunks(testData []byte) error { } log.Trace("All references retrieved") + for i, ref := range addrs { + log.Trace(fmt.Sprintf("ref %d", i), "ref", ref) + } + // has-chunks for _, host := range hosts { httpHost := fmt.Sprintf("ws://%s:%d", host, 8546) log.Trace("Calling `Has` on host", "httpHost", httpHost) + + hostChunks := []string{} + rpcClient, err := rpc.Dial(httpHost) if err != nil { log.Trace("Error dialing host", "err", err) @@ -93,15 +101,27 @@ func trackChunks(testData []byte) error { } log.Trace("rpc call ok") count := 0 - for _, info := range hasInfo { - if !info.Has { + for i, info := range hasInfo { + if i == 0 { + log.Trace("first hasInfo", "addr", info.Addr, "host", host, "i", i) + } + if i == len(hasInfo)-1 { + log.Trace("last hasInfo", "addr", info.Addr, "host", host, "i", i) + } + + if info.Has { + hostChunks = append(hostChunks, "1") + } else { + hostChunks = append(hostChunks, "0") count++ - log.Error("Host does not have chunk", "host", httpHost, "chunk", info.Addr) } + } if count == 0 { - log.Info("Host reported to have all chunks", "host", httpHost) + log.Info("host reported to have all chunks", "host", host) } + + log.Trace("chunks", "chunks", strings.Join(hostChunks, ""), "host", host) } return nil }