Merge pull request #94180 from feiskyer/fix-backoff

Ensure backoff step is set to 1 for Azure armclient
This commit is contained in:
Kubernetes Prow Robot 2020-09-02 02:37:49 -07:00 committed by GitHub
commit 54f3b85dc7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 20 additions and 3 deletions

View File

@ -64,10 +64,11 @@ func New(authorizer autorest.Authorizer, baseURI, userAgent, apiVersion, clientR
backoff := clientBackoff
if backoff == nil {
backoff = &retry.Backoff{}
}
if backoff.Steps == 0 {
// 1 steps means no retry.
backoff = &retry.Backoff{
Steps: 1,
}
backoff.Steps = 1
}
return &Client{

View File

@ -36,6 +36,22 @@ const (
testResourceID = "/subscriptions/subscription/resourceGroups/rg/providers/Microsoft.Network/publicIPAddresses/testPIP"
)
func TestNew(t *testing.T) {
backoff := &retry.Backoff{Steps: 3}
armClient := New(nil, "", "test", "2019-01-01", "eastus", backoff)
assert.NotNil(t, armClient.backoff)
assert.Equal(t, 3, armClient.backoff.Steps, "Backoff steps should be same as the value passed in")
backoff = &retry.Backoff{Steps: 0}
armClient = New(nil, "", "test", "2019-01-01", "eastus", backoff)
assert.NotNil(t, armClient.backoff)
assert.Equal(t, 1, armClient.backoff.Steps, "Backoff steps should be default to 1 if it is 0")
armClient = New(nil, "", "test", "2019-01-01", "eastus", nil)
assert.NotNil(t, armClient.backoff)
assert.Equal(t, 1, armClient.backoff.Steps, "Backoff steps should be default to 1 if it is not set")
}
func TestSend(t *testing.T) {
count := 0
server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {