Skip to content

Commit

Permalink
fix flaky test by allowing for call invocation overhead
Browse files Browse the repository at this point in the history
  • Loading branch information
Mahmood Ali committed May 8, 2019
1 parent 2306928 commit 538b5c3
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions command/agent/consul/unit_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -886,9 +886,10 @@ func TestConsul_ShutdownSlow(t *testing.T) {
t.Errorf("unexpected error shutting down client: %v", err)
}

// Shutdown time should have taken: 1s <= shutdown <= 3s
// Shutdown time should have taken: ~1s <= shutdown <= 3s
// actual timing might be less than 1s, to account for shutdown invocation overhead
shutdownTime := time.Now().Sub(preShutdown)
if shutdownTime < time.Second || shutdownTime > ctx.ServiceClient.shutdownWait {
if shutdownTime < 900*time.Millisecond || shutdownTime > ctx.ServiceClient.shutdownWait {
t.Errorf("expected shutdown to take >1s and <%s but took: %s", ctx.ServiceClient.shutdownWait, shutdownTime)
}

Expand Down

0 comments on commit 538b5c3

Please sign in to comment.