From 538b5c3eba39d4135c09dcc8cd3594689dda7fec Mon Sep 17 00:00:00 2001 From: Mahmood Ali Date: Tue, 30 Apr 2019 15:59:05 -0400 Subject: [PATCH] fix flaky test by allowing for call invocation overhead --- command/agent/consul/unit_test.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/command/agent/consul/unit_test.go b/command/agent/consul/unit_test.go index 4d2009e5aa8..d1531759520 100644 --- a/command/agent/consul/unit_test.go +++ b/command/agent/consul/unit_test.go @@ -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) }