From eb4b45941c4c81180f42e30889e6037f05a0d2f4 Mon Sep 17 00:00:00 2001 From: James Bardin Date: Wed, 19 Apr 2017 14:19:08 -0400 Subject: [PATCH] fix tests affected by refreshGracePeriod A couple tests require lowering the grace period to keep the test from taking the full 30s timeout. The Retry_hang test also needed to be removed from the Parallel group, becuase it modifies the global refreshGracePeriod variable. --- helper/resource/state_test.go | 6 ++++++ helper/resource/wait_test.go | 8 ++++++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/helper/resource/state_test.go b/helper/resource/state_test.go index 5e0cbe2dca..ca534589ce 100644 --- a/helper/resource/state_test.go +++ b/helper/resource/state_test.go @@ -147,6 +147,12 @@ func TestWaitForState_inconsistent_negative(t *testing.T) { } func TestWaitForState_timeout(t *testing.T) { + old := refreshGracePeriod + refreshGracePeriod = 5 * time.Millisecond + defer func() { + refreshGracePeriod = old + }() + conf := &StateChangeConf{ Pending: []string{"pending", "incomplete"}, Target: []string{"running"}, diff --git a/helper/resource/wait_test.go b/helper/resource/wait_test.go index 957bd18426..526b21ae3b 100644 --- a/helper/resource/wait_test.go +++ b/helper/resource/wait_test.go @@ -54,14 +54,18 @@ func TestRetry_timeout(t *testing.T) { } func TestRetry_hang(t *testing.T) { - t.Parallel() + old := refreshGracePeriod + refreshGracePeriod = 50 * time.Millisecond + defer func() { + refreshGracePeriod = old + }() f := func() *RetryError { time.Sleep(2 * time.Second) return nil } - err := Retry(1*time.Second, f) + err := Retry(50*time.Millisecond, f) if err == nil { t.Fatal("should error") }