test(acc): add sleep-based backoff

main
sundowndev 2022-01-21 17:08:31 +04:00
parent 53ace36a32
commit b1bd4c26fd
No known key found for this signature in database
GPG Key ID: 100CE2799D978462
7 changed files with 56 additions and 21 deletions

View File

@ -18,10 +18,15 @@ func TestAcc_Google_BigqueryDataset(t *testing.T) {
},
Checks: []acceptance.AccCheck{
{
// New resources are not visible immediately on GCP api after an apply operation
// Logic below retry driftctl scan until we can retrieve the results (infra will be in sync) and for maximum 60 seconds
// 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 {
return !result.IsSync() && retryDuration < time.Minute
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) {
if err != nil {

View File

@ -18,10 +18,15 @@ func TestAcc_Google_BigqueryTable(t *testing.T) {
},
Checks: []acceptance.AccCheck{
{
// New resources are not visible immediately on GCP api after an apply operation
// Logic below retry driftctl scan until we can retrieve the results (infra will be in sync) and for maximum 60 seconds
// 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 {
return !result.IsSync() && retryDuration < time.Minute
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) {
if err != nil {

View File

@ -18,10 +18,15 @@ func TestAcc_Google_BigtableInstance(t *testing.T) {
},
Checks: []acceptance.AccCheck{
{
// New resources are not visible immediately on GCP api after an apply
// Logic below retry driftctl scan until we can retrieve the results (infra will be in sync) and for maximum 60 seconds
// 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 {
return !result.IsSync() && retryDuration < time.Minute
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) {
if err != nil {

View File

@ -18,10 +18,15 @@ func TestAcc_Google_BigtableTable(t *testing.T) {
},
Checks: []acceptance.AccCheck{
{
// New resources are not visible immediately on GCP api after an apply
// Logic below retry driftctl scan until we can retrieve the results (infra will be in sync) and for maximum 60 seconds
// 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 {
return !result.IsSync() && retryDuration < time.Minute
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) {
if err != nil {

View File

@ -18,10 +18,15 @@ func TestAcc_Google_CloudFunctionsFunction(t *testing.T) {
},
Checks: []acceptance.AccCheck{
{
// New resources are not visible immediately on GCP api after an apply
// Logic below retry driftctl scan until we can retrieve the results (infra will be in sync) and for maximum 60 seconds
// 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 {
return !result.IsSync() && retryDuration < time.Minute
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) {
if err != nil {

View File

@ -18,10 +18,15 @@ func TestAcc_Google_SQLDatabaseInstance(t *testing.T) {
},
Checks: []acceptance.AccCheck{
{
// New resources are not visible immediately on GCP api after an apply
// Logic below retry driftctl scan until we can retrieve the results (infra will be in sync) and for maximum 300 seconds
// 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 {
return !result.IsSync() && retryDuration < 5*time.Minute
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) {
if err != nil {

View File

@ -18,10 +18,15 @@ func TestAcc_Google_StorageBucket(t *testing.T) {
},
Checks: []acceptance.AccCheck{
{
// New resources are not visible immediately on GCP api after an apply
// Logic below retry driftctl scan until we can retrieve the results (infra will be in sync) and for maximum 60 seconds
// 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 {
return !result.IsSync() && retryDuration < time.Minute
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) {
if err != nil {