mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-20 10:52:25 +00:00
cmd/swarm/swarm-smoke: addressed PR comments
This commit is contained in:
parent
30915726d6
commit
dcdff86b8e
2 changed files with 23 additions and 19 deletions
|
|
@ -37,15 +37,16 @@ var (
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
allhosts string
|
allhosts string
|
||||||
hosts []string
|
hosts []string
|
||||||
filesize int
|
filesize int
|
||||||
syncDelay int
|
syncDelay int
|
||||||
httpPort int
|
httpPort int
|
||||||
wsPort int
|
wsPort int
|
||||||
verbosity int
|
verbosity int
|
||||||
timeout int
|
timeout int
|
||||||
single bool
|
single bool
|
||||||
|
getAllRefsTimeout int
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
|
|
@ -102,6 +103,12 @@ func main() {
|
||||||
Usage: "whether to fetch content from a single node or from all nodes",
|
Usage: "whether to fetch content from a single node or from all nodes",
|
||||||
Destination: &single,
|
Destination: &single,
|
||||||
},
|
},
|
||||||
|
cli.IntFlag{
|
||||||
|
Name: "refs-timeout",
|
||||||
|
Value: 5,
|
||||||
|
Usage: "timeout in seconds to wait for GetAllReferences to return",
|
||||||
|
Destination: &getAllRefsTimeout,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
app.Flags = append(app.Flags, []cli.Flag{
|
app.Flags = append(app.Flags, []cli.Flag{
|
||||||
|
|
|
||||||
|
|
@ -55,13 +55,14 @@ func uploadAndSyncCmd(ctx *cli.Context, tuid string) error {
|
||||||
case <-time.After(time.Duration(timeout) * time.Second):
|
case <-time.After(time.Duration(timeout) * time.Second):
|
||||||
metrics.GetOrRegisterCounter(fmt.Sprintf("%s.timeout", commandName), nil).Inc(1)
|
metrics.GetOrRegisterCounter(fmt.Sprintf("%s.timeout", commandName), nil).Inc(1)
|
||||||
|
|
||||||
|
e := fmt.Errorf("timeout after %v sec", timeout)
|
||||||
// trigger debug functionality on randomBytes
|
// trigger debug functionality on randomBytes
|
||||||
err := triggerChunkDebug(randomBytes)
|
err := triggerChunkDebug(randomBytes[:])
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error("test timed out and triggerChunkDebug also produced error", "err", err)
|
e = fmt.Errorf("%v; triggerChunkDebug failed: %v", e, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
return fmt.Errorf("timeout after %v sec", timeout)
|
return e
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -72,6 +73,7 @@ func triggerChunkDebug(testData []byte) error {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
log.Trace("All references retrieved")
|
||||||
|
|
||||||
// has-chunks
|
// has-chunks
|
||||||
for _, host := range hosts {
|
for _, host := range hosts {
|
||||||
|
|
@ -115,16 +117,11 @@ func getAllRefs(testData []byte) (storage.AddressCollection, error) {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
ctx, cancel := context.WithTimeout(context.Background(), 2*time.Second)
|
ctx, cancel := context.WithTimeout(context.Background(), time.Duration(getAllRefsTimeout)*time.Second)
|
||||||
defer cancel()
|
defer cancel()
|
||||||
|
|
||||||
reader := bytes.NewReader(testData)
|
reader := bytes.NewReader(testData)
|
||||||
addrs, err := fileStore.GetAllReferences(ctx, reader, false)
|
return fileStore.GetAllReferences(ctx, reader, false)
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
log.Trace("All references retrieved")
|
|
||||||
return addrs, err
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func uplaodAndSync(c *cli.Context, randomBytes []byte, tuid string) error {
|
func uplaodAndSync(c *cli.Context, randomBytes []byte, tuid string) error {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue