diff --git a/sdk/security/keyvault/azadmin/settings/client_test.go b/sdk/security/keyvault/azadmin/settings/client_test.go index 932444a5595c..d638eb6dad5e 100644 --- a/sdk/security/keyvault/azadmin/settings/client_test.go +++ b/sdk/security/keyvault/azadmin/settings/client_test.go @@ -8,10 +8,13 @@ package settings_test import ( "context" + "errors" "testing" + "time" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" + "github.com/Azure/azure-sdk-for-go/sdk/internal/recording" "github.com/Azure/azure-sdk-for-go/sdk/security/keyvault/azadmin/settings" "github.com/stretchr/testify/require" ) @@ -103,7 +106,16 @@ func TestUpdateSetting_InvalidSettingName(t *testing.T) { require.Nil(t, res.Type) require.Nil(t, res.Value) - res, err = client.UpdateSetting(context.Background(), "invalid name", settings.UpdateSettingRequest{Value: to.Ptr("true")}, nil) + for i := 0; i < 4; i++ { + res, err = client.UpdateSetting(context.Background(), "invalid name", settings.UpdateSettingRequest{Value: to.Ptr("true")}, nil) + var httpErr *azcore.ResponseError + // if correct error is returned, break from the loop and check for correctness + if errors.As(err, &httpErr) && httpErr.StatusCode == 400 { + break + } + // else sleep for 30 seconds and try again + recording.Sleep(30 * time.Second) + } require.Error(t, err) require.Nil(t, res.Name) require.Nil(t, res.Type)