fix flaky test by allowing for call invocation overhead

This commit is contained in:
Mahmood Ali
2019-04-30 15:59:05 -04:00
parent 2306928036
commit 538b5c3eba

View File

@@ -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)
}