From cdc59aa5d3ca3b09ce496567ba1dafa026f22a97 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?William=20Tisa=CC=88ter?= Date: Tue, 6 May 2014 20:54:27 +0200 Subject: [PATCH] Fix race condition in `TestCheckTTL` Apparently the execution of `TestCheckTTL` could sometime take > 10ms causing it to fail. This commit will eliminate the race condition for most modern hardware. --- command/agent/check_test.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/command/agent/check_test.go b/command/agent/check_test.go index a0a46c75f1..54a9b15c9c 100644 --- a/command/agent/check_test.go +++ b/command/agent/check_test.go @@ -98,13 +98,13 @@ func TestCheckTTL(t *testing.T) { check := &CheckTTL{ Notify: mock, CheckID: "foo", - TTL: 20 * time.Millisecond, + TTL: 100 * time.Millisecond, Logger: log.New(os.Stderr, "", log.LstdFlags), } check.Start() defer check.Stop() - time.Sleep(10 * time.Millisecond) + time.Sleep(50 * time.Millisecond) check.SetStatus(structs.HealthPassing, "") if mock.updates["foo"] != 1 { @@ -116,13 +116,13 @@ func TestCheckTTL(t *testing.T) { } // Ensure we don't fail early - time.Sleep(15 * time.Millisecond) + time.Sleep(75 * time.Millisecond) if mock.updates["foo"] != 1 { t.Fatalf("should have 1 updates %v", mock.updates) } // Wait for the TTL to expire - time.Sleep(15 * time.Millisecond) + time.Sleep(75 * time.Millisecond) if mock.updates["foo"] != 2 { t.Fatalf("should have 2 updates %v", mock.updates)