cmd/swarm/swarm-smoke-pss: add msg timeout via flag

This commit is contained in:
Rafael Matias 2019-03-26 18:48:09 +01:00
parent 0d8c530333
commit 709d49218a
No known key found for this signature in database
GPG key ID: 1BC39532FB4A2DBD
2 changed files with 18 additions and 11 deletions

View file

@ -37,14 +37,15 @@ var (
)
var (
allhosts string
hosts []string
inputSeed int
wsPort int
verbosity int
timeout int
pssMessageCount int
pssMessageSize int
allhosts string
hosts []string
inputSeed int
wsPort int
verbosity int
timeout int
pssMessageTimeout int
pssMessageCount int
pssMessageSize int
)
func main() {
@ -84,6 +85,12 @@ func main() {
Usage: "timeout in seconds after which kill the process",
Destination: &timeout,
},
cli.IntFlag{
Name: "msgtimeout",
Value: 1,
Usage: "timeout in seconds until a message is received",
Destination: &pssMessageTimeout,
},
cli.IntFlag{
Name: "msgcount",
Value: 10,
@ -128,7 +135,7 @@ func main() {
{
Name: "all",
Usage: "send and receive raw, sym and asym messages across randome nodes",
Action: wrapCliCommand("raw", pssAllCheck),
Action: wrapCliCommand("all", pssAllCheck),
},
}

View file

@ -303,8 +303,8 @@ func (s *pssSession) waitForMsg() error {
return fmt.Errorf("message mismatch. expected: %s got: %s", resJob.msg, res.Msg)
}
log.Debug("got msg", "job", hexutil.Encode([]byte(resIdx)))
case <-time.After(1 * time.Second):
return errors.New("msg timeout after 1 sec")
case <-time.After(time.Duration(pssMessageTimeout) * time.Second):
return fmt.Errorf("message timeout after %d sec", pssMessageTimeout)
}
return nil
}