Skip to content
This repository has been archived by the owner on Jul 16, 2020. It is now read-only.

Commit

Permalink
testutil: use consistent timeout for results channels
Browse files Browse the repository at this point in the history
These timeouts "should never trigger", but if they do we get a test
failure sooner than waiting for go test's very long timeout.  The 25
second number isn't special.  And it's known to possibly be too short
for example in the case of TestReconnects(), where the ssntp client
incurs a series of delays that are 0..5, 0..10, 0..20, 0..40 seconds.
If the server is slow in restarting it _might_ take 4 seconds to restart
in travis.  But worst case we hit client delays of 1,1,1,40 seconds.
In which case despite everything "working correctly" the test case will
timeout for lack of NodeConnected result after 25s, when it would be
coming at 43s.

Signed-off-by: Tim Pepper <[email protected]>
  • Loading branch information
Tim Pepper committed Aug 19, 2016
1 parent b2ea19b commit 4fb5889
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 11 deletions.
8 changes: 4 additions & 4 deletions testutil/agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ func (client *SsntpTestClient) GetCmdChanResult(c *chan Result, cmd ssntp.Comman
if result.Err != nil {
err = fmt.Errorf("Client error sending %s command: %s\n", cmd, result.Err)
}
case <-time.After(5 * time.Second):
case <-time.After(25 * time.Second):
err = fmt.Errorf("Timeout waiting for client %s command result\n", cmd)
}

Expand Down Expand Up @@ -159,7 +159,7 @@ func (client *SsntpTestClient) GetEventChanResult(c *chan Result, evt ssntp.Even
if result.Err != nil {
err = fmt.Errorf("Client error sending %s event: %s\n", evt, result.Err)
}
case <-time.After(20 * time.Second):
case <-time.After(25 * time.Second):
err = fmt.Errorf("Timeout waiting for client %s event result\n", evt)
}

Expand Down Expand Up @@ -198,7 +198,7 @@ func (client *SsntpTestClient) GetErrorChanResult(c *chan Result, error ssntp.Er
if result.Err != nil {
err = fmt.Errorf("Client error sending %s error: %s\n", error, result.Err)
}
case <-time.After(20 * time.Second):
case <-time.After(25 * time.Second):
err = fmt.Errorf("Timeout waiting for client %s error result\n", error)
}

Expand Down Expand Up @@ -237,7 +237,7 @@ func (client *SsntpTestClient) GetStatusChanResult(c *chan Result, status ssntp.
if result.Err != nil {
err = fmt.Errorf("Client error sending %s status: %s\n", status, result.Err)
}
case <-time.After(5 * time.Second):
case <-time.After(25 * time.Second):
err = fmt.Errorf("Timeout waiting for client %s status result\n", status)
}

Expand Down
6 changes: 3 additions & 3 deletions testutil/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ func (ctl *SsntpTestController) GetCmdChanResult(c *chan Result, cmd ssntp.Comma
if result.Err != nil {
err = fmt.Errorf("Controller error sending %s command: %s\n", cmd, result.Err)
}
case <-time.After(5 * time.Second):
case <-time.After(25 * time.Second):
err = fmt.Errorf("Timeout waiting for controller %s command result\n", cmd)
}

Expand Down Expand Up @@ -137,7 +137,7 @@ func (ctl *SsntpTestController) GetEventChanResult(c *chan Result, evt ssntp.Eve
if result.Err != nil {
err = fmt.Errorf("Controller error sending %s event: %s\n", evt, result.Err)
}
case <-time.After(20 * time.Second):
case <-time.After(25 * time.Second):
err = fmt.Errorf("Timeout waiting for controller %s event result\n", evt)
}

Expand Down Expand Up @@ -176,7 +176,7 @@ func (ctl *SsntpTestController) GetErrorChanResult(c *chan Result, error ssntp.E
if result.Err != nil {
err = fmt.Errorf("Controller error sending %s error: %s\n", error, result.Err)
}
case <-time.After(20 * time.Second):
case <-time.After(25 * time.Second):
err = fmt.Errorf("Timeout waiting for controller %s error result\n", error)
}

Expand Down
8 changes: 4 additions & 4 deletions testutil/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ func (server *SsntpTestServer) GetCmdChanResult(c *chan Result, cmd ssntp.Comman
if result.Err != nil {
err = fmt.Errorf("Server error on %s command: %s\n", cmd, result.Err)
}
case <-time.After(5 * time.Second):
case <-time.After(25 * time.Second):
err = fmt.Errorf("Timeout waiting for server %s command result\n", cmd)
}

Expand Down Expand Up @@ -104,7 +104,7 @@ func (server *SsntpTestServer) GetEventChanResult(c *chan Result, evt ssntp.Even
if result.Err != nil {
err = fmt.Errorf("Server error handling %s event: %s\n", evt, result.Err)
}
case <-time.After(20 * time.Second):
case <-time.After(25 * time.Second):
err = fmt.Errorf("Timeout waiting for server %s event result\n", evt)
}

Expand Down Expand Up @@ -143,7 +143,7 @@ func (server *SsntpTestServer) GetErrorChanResult(c *chan Result, error ssntp.Er
if result.Err != nil {
err = fmt.Errorf("Server error handling %s error: %s\n", error, result.Err)
}
case <-time.After(20 * time.Second):
case <-time.After(25 * time.Second):
err = fmt.Errorf("Timeout waiting for server %s error result\n", error)
}

Expand Down Expand Up @@ -182,7 +182,7 @@ func (server *SsntpTestServer) GetStatusChanResult(c *chan Result, status ssntp.
if result.Err != nil {
err = fmt.Errorf("Server error handling %s status: %s\n", status, result.Err)
}
case <-time.After(5 * time.Second):
case <-time.After(25 * time.Second):
err = fmt.Errorf("Timeout waiting for server %s status result\n", status)
}

Expand Down

0 comments on commit 4fb5889

Please sign in to comment.