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

@ -43,6 +43,7 @@ var (
wsPort int wsPort int
verbosity int verbosity int
timeout int timeout int
pssMessageTimeout int
pssMessageCount int pssMessageCount int
pssMessageSize int pssMessageSize int
) )
@ -84,6 +85,12 @@ func main() {
Usage: "timeout in seconds after which kill the process", Usage: "timeout in seconds after which kill the process",
Destination: &timeout, Destination: &timeout,
}, },
cli.IntFlag{
Name: "msgtimeout",
Value: 1,
Usage: "timeout in seconds until a message is received",
Destination: &pssMessageTimeout,
},
cli.IntFlag{ cli.IntFlag{
Name: "msgcount", Name: "msgcount",
Value: 10, Value: 10,
@ -128,7 +135,7 @@ func main() {
{ {
Name: "all", Name: "all",
Usage: "send and receive raw, sym and asym messages across randome nodes", 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) return fmt.Errorf("message mismatch. expected: %s got: %s", resJob.msg, res.Msg)
} }
log.Debug("got msg", "job", hexutil.Encode([]byte(resIdx))) log.Debug("got msg", "job", hexutil.Encode([]byte(resIdx)))
case <-time.After(1 * time.Second): case <-time.After(time.Duration(pssMessageTimeout) * time.Second):
return errors.New("msg timeout after 1 sec") return fmt.Errorf("message timeout after %d sec", pssMessageTimeout)
} }
return nil return nil
} }