swarm-smoke: add debug flag (#1428)

This commit is contained in:
Anton Evangelatov
2019-06-06 15:06:18 +02:00
committed by acud
parent 5663cb2c76
commit bedd06762d
2 changed files with 17 additions and 7 deletions

View File

@ -48,6 +48,7 @@ var (
timeout int timeout int
single bool single bool
onlyUpload bool onlyUpload bool
debug bool
) )
func main() { func main() {
@ -114,6 +115,11 @@ func main() {
Usage: "whether to only upload content to a single node without fetching", Usage: "whether to only upload content to a single node without fetching",
Destination: &onlyUpload, Destination: &onlyUpload,
}, },
cli.BoolFlag{
Name: "debug",
Usage: "whether to call debug APIs as part of the smoke test",
Destination: &debug,
},
} }
app.Flags = append(app.Flags, []cli.Flag{ app.Flags = append(app.Flags, []cli.Flag{

View File

@ -65,10 +65,12 @@ func uploadAndSyncCmd(ctx *cli.Context) error {
err = fmt.Errorf("timeout after %v sec", timeout) err = fmt.Errorf("timeout after %v sec", timeout)
} }
// trigger debug functionality on randomBytes if debug {
e := trackChunks(randomBytes[:], true) // trigger debug functionality on randomBytes
if e != nil { e := trackChunks(randomBytes[:], true)
log.Error(e.Error()) if e != nil {
log.Error(e.Error())
}
} }
return err return err
@ -291,9 +293,11 @@ func uploadAndSync(c *cli.Context, randomBytes []byte) error {
log.Debug("chunks before fetch attempt", "hash", hash) log.Debug("chunks before fetch attempt", "hash", hash)
err = trackChunks(randomBytes, false) if debug {
if err != nil { err = trackChunks(randomBytes, false)
log.Error(err.Error()) if err != nil {
log.Error(err.Error())
}
} }
} }