Skip to content

Commit

Permalink
setup default retry options if we have retryable errors
Browse files Browse the repository at this point in the history
  • Loading branch information
lonegunmanb committed Feb 6, 2023
1 parent 1ceff55 commit 168522d
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
1 change: 1 addition & 0 deletions e2etest.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ func RunE2ETest(t *testing.T, moduleRootPath, exampleRelativePath string, option
l := NewMemoryLogger()
defer func() { _ = l.Close() }()
option.Logger = logger.New(l)
option = setupRetryLogic(option)
defer destroy(t, option)

initAndApply(t, &option)
Expand Down
15 changes: 15 additions & 0 deletions upgradetest.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"strconv"
"strings"
"testing"
"time"

"github.com/ahmetb/go-linq/v3"
"github.com/google/go-github/v42/github"
Expand Down Expand Up @@ -37,6 +38,7 @@ func ModuleUpgradeTest(t *testing.T, owner, repo, moduleFolderRelativeToRoot, cu
l := NewMemoryLogger()
defer func() { _ = l.Close() }()
opts.Logger = logger.New(l)
opts = setupRetryLogic(opts)

err := moduleUpgrade(t, owner, repo, moduleFolderRelativeToRoot, currentModulePath, retryableOptions(t, opts), currentMajorVer)
if err == CannotTestError || err == SkipV0Error {
Expand All @@ -47,6 +49,19 @@ func ModuleUpgradeTest(t *testing.T, owner, repo, moduleFolderRelativeToRoot, cu
}
}

func setupRetryLogic(opts terraform.Options) terraform.Options {
if len(opts.RetryableTerraformErrors) == 0 {
return opts
}
if opts.MaxRetries == 0 {
opts.MaxRetries = 10
}
if opts.TimeBetweenRetries == time.Duration(0) {
opts.TimeBetweenRetries = time.Minute
}
return opts
}

//goland:noinspection GoUnusedExportedFunction
func GetCurrentModuleRootPath() (string, error) {
current, err := os.Getwd()
Expand Down

0 comments on commit 168522d

Please sign in to comment.