diff options
Diffstat (limited to 'vendor/github.com/hashicorp/terraform/builtin/provisioners/remote-exec/resource_provisioner_test.go')
-rw-r--r-- | vendor/github.com/hashicorp/terraform/builtin/provisioners/remote-exec/resource_provisioner_test.go | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/vendor/github.com/hashicorp/terraform/builtin/provisioners/remote-exec/resource_provisioner_test.go b/vendor/github.com/hashicorp/terraform/builtin/provisioners/remote-exec/resource_provisioner_test.go index 67faf1fe..8c447788 100644 --- a/vendor/github.com/hashicorp/terraform/builtin/provisioners/remote-exec/resource_provisioner_test.go +++ b/vendor/github.com/hashicorp/terraform/builtin/provisioners/remote-exec/resource_provisioner_test.go @@ -211,6 +211,16 @@ func TestResourceProvider_CollectScripts_scriptsEmpty(t *testing.T) { } func TestRetryFunc(t *testing.T) { + origMax := maxBackoffDelay + maxBackoffDelay = time.Second + origStart := initialBackoffDelay + initialBackoffDelay = 10 * time.Millisecond + + defer func() { + maxBackoffDelay = origMax + initialBackoffDelay = origStart + }() + // succeed on the third try errs := []error{io.EOF, &net.OpError{Err: errors.New("ERROR")}, nil} count := 0 @@ -235,6 +245,29 @@ func TestRetryFunc(t *testing.T) { } } +func TestRetryFuncBackoff(t *testing.T) { + origMax := maxBackoffDelay + maxBackoffDelay = time.Second + origStart := initialBackoffDelay + initialBackoffDelay = 100 * time.Millisecond + + defer func() { + maxBackoffDelay = origMax + initialBackoffDelay = origStart + }() + + count := 0 + + retryFunc(context.Background(), time.Second, func() error { + count++ + return io.EOF + }) + + if count > 4 { + t.Fatalf("retry func failed to backoff. called %d times", count) + } +} + func testConfig(t *testing.T, c map[string]interface{}) *terraform.ResourceConfig { r, err := config.NewRawConfig(c) if err != nil { |