Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added tests for isAppEngineRetryableError #2938

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .changelog/4470.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:bug
appengine: added retry for P4SA propagation delay
```
2 changes: 1 addition & 1 deletion google-beta/error_retry_predicates.go
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ func isAppEngineRetryableError(err error) (bool, string) {
if gerr.Code == 409 && strings.Contains(strings.ToLower(gerr.Body), "operation is already in progress") {
return true, "Waiting for other concurrent App Engine changes to finish"
}
if gerr.Code == 404 && strings.Contains(strings.ToLower(gerr.Body), "unable to retrieve P4SA") {
if gerr.Code == 404 && strings.Contains(strings.ToLower(gerr.Body), "unable to retrieve p4sa") {
return true, "Waiting for P4SA propagation to GAIA"
}
}
Expand Down
51 changes: 51 additions & 0 deletions google-beta/error_retry_predicates_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
package google

import (
"testing"

"google.golang.org/api/googleapi"
)

func TestIsAppEngineRetryableError_operationInProgress(t *testing.T) {
err := googleapi.Error{
Code: 409,
Body: "Operation is already in progress",
}
isRetryable, _ := isAppEngineRetryableError(&err)
if !isRetryable {
t.Errorf("Error not detected as retryable")
}
}

func TestIsAppEngineRetryableError_p4saPropagation(t *testing.T) {
err := googleapi.Error{
Code: 404,
Body: "Unable to retrieve P4SA: [service-111111111111@gcp-gae-service.iam.gserviceaccount.com] from GAIA. Could be GAIA propagation delay or request from deleted apps.",
}
isRetryable, _ := isAppEngineRetryableError(&err)
if !isRetryable {
t.Errorf("Error not detected as retryable")
}
}

func TestIsAppEngineRetryableError_missingPage(t *testing.T) {
err := googleapi.Error{
Code: 404,
Body: "Missing page",
}
isRetryable, _ := isAppEngineRetryableError(&err)
if isRetryable {
t.Errorf("Error incorrectly detected as retryable")
}
}

func TestIsAppEngineRetryableError_serverError(t *testing.T) {
err := googleapi.Error{
Code: 500,
Body: "Unable to retrieve P4SA because of a bad thing happening",
}
isRetryable, _ := isAppEngineRetryableError(&err)
if isRetryable {
t.Errorf("Error incorrectly detected as retryable")
}
}