Merge pull request #1340 from snyk/test/google_compute_global_address

Add retry policy to google_compute_global_address acc test
main
Elie 2022-02-01 11:25:51 +01:00 committed by GitHub
commit fc821fc46d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 11 additions and 0 deletions

View File

@ -2,6 +2,7 @@ package google_test
import ( import (
"testing" "testing"
"time"
"github.com/snyk/driftctl/test" "github.com/snyk/driftctl/test"
"github.com/snyk/driftctl/test/acceptance" "github.com/snyk/driftctl/test/acceptance"
@ -17,6 +18,16 @@ func TestAcc_Google_ComputeGlobalAddress(t *testing.T) {
}, },
Checks: []acceptance.AccCheck{ Checks: []acceptance.AccCheck{
{ {
// New resources are not visible immediately through GCP API after an apply operation.
// Logic below retries driftctl scan using a back-off strategy of retrying 'n' times
// and doubling the amount of time waited after each one.
ShouldRetry: func(result *test.ScanResult, retryDuration time.Duration, retryCount uint8) bool {
if result.IsSync() || retryDuration > 10*time.Minute {
return false
}
time.Sleep((2 * time.Duration(retryCount)) * time.Minute)
return true
},
Check: func(result *test.ScanResult, stdout string, err error) { Check: func(result *test.ScanResult, stdout string, err error) {
if err != nil { if err != nil {
t.Fatal(err) t.Fatal(err)